Add clCreateImageWithPropertiesINTEL API
Related-To: NEO-3147 Change-Id: I4a8a9d73fe75e0680226fbd0625342f639ddd201 Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
This commit is contained in:
parent
a9b8c07293
commit
72841e36c2
|
@ -766,6 +766,44 @@ cl_mem CL_API_CALL clCreateImage(cl_context context,
|
|||
return image;
|
||||
}
|
||||
|
||||
cl_mem CL_API_CALL clCreateImageWithPropertiesINTEL(cl_context context,
|
||||
cl_mem_properties_intel *properties,
|
||||
const cl_image_format *imageFormat,
|
||||
const cl_image_desc *imageDesc,
|
||||
void *hostPtr,
|
||||
cl_int *errcodeRet) {
|
||||
cl_int retVal = CL_SUCCESS;
|
||||
|
||||
API_ENTER(&retVal);
|
||||
DBG_LOG_INPUTS("cl_context", context,
|
||||
"cl_mem_properties_intel", properties,
|
||||
"cl_image_format.channel_data_type", imageFormat->image_channel_data_type,
|
||||
"cl_image_format.channel_order", imageFormat->image_channel_order,
|
||||
"cl_image_desc.width", imageDesc->image_width,
|
||||
"cl_image_desc.heigth", imageDesc->image_height,
|
||||
"cl_image_desc.depth", imageDesc->image_depth,
|
||||
"cl_image_desc.type", imageDesc->image_type,
|
||||
"cl_image_desc.array_size", imageDesc->image_array_size,
|
||||
"hostPtr", hostPtr);
|
||||
|
||||
cl_mem image = nullptr;
|
||||
Context *pContext = nullptr;
|
||||
MemoryProperties propertiesStruct{};
|
||||
retVal = validateObjects(WithCastToInternal(context, &pContext));
|
||||
|
||||
if (retVal == CL_SUCCESS) {
|
||||
if (MemObjHelper::parseMemoryProperties(properties, propertiesStruct)) {
|
||||
image = Image::validateAndCreateImage(pContext, propertiesStruct, imageFormat, imageDesc, hostPtr, retVal);
|
||||
} else {
|
||||
retVal = CL_INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
ErrorCodeHelper err(errcodeRet, retVal);
|
||||
DBG_LOG_INPUTS("image", image);
|
||||
return image;
|
||||
}
|
||||
|
||||
// deprecated OpenCL 1.1
|
||||
cl_mem CL_API_CALL clCreateImage2D(cl_context context,
|
||||
cl_mem_flags flags,
|
||||
|
@ -3656,6 +3694,7 @@ void *CL_API_CALL clGetExtensionFunctionAddress(const char *funcName) {
|
|||
RETURN_FUNC_PTR_IF_EXIST(clRetainAcceleratorINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clReleaseAcceleratorINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clCreateBufferWithPropertiesINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clCreateImageWithPropertiesINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clAddCommentINTEL);
|
||||
RETURN_FUNC_PTR_IF_EXIST(clEnqueueVerifyMemoryINTEL);
|
||||
|
||||
|
|
|
@ -144,6 +144,14 @@ cl_mem CL_API_CALL clCreateImage(
|
|||
void *hostPtr,
|
||||
cl_int *errcodeRet);
|
||||
|
||||
cl_mem CL_API_CALL clCreateImageWithPropertiesINTEL(
|
||||
cl_context context,
|
||||
cl_mem_properties_intel *properties,
|
||||
const cl_image_format *imageFormat,
|
||||
const cl_image_desc *imageDesc,
|
||||
void *hostPtr,
|
||||
cl_int *errcodeRet);
|
||||
|
||||
// deprecated OpenCL 1.1
|
||||
cl_mem CL_API_CALL clCreateImage2D(
|
||||
cl_context context,
|
||||
|
|
|
@ -745,6 +745,57 @@ TEST_F(clCreateImage3DTest, GivenInvalidContextsWhenCreating3DImageThenInvalidCo
|
|||
EXPECT_EQ(nullptr, image);
|
||||
}
|
||||
|
||||
using clCreateImageWithPropertiesINTELTest = clCreateImageTest;
|
||||
|
||||
TEST_F(clCreateImageWithPropertiesINTELTest, GivenInvalidContextWhenCreatingImageWithPropertiesThenInvalidContextErrorIsReturned) {
|
||||
|
||||
auto image = clCreateImageWithPropertiesINTEL(
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
nullptr,
|
||||
&retVal);
|
||||
|
||||
ASSERT_EQ(CL_INVALID_CONTEXT, retVal);
|
||||
EXPECT_EQ(nullptr, image);
|
||||
}
|
||||
|
||||
TEST_F(clCreateImageWithPropertiesINTELTest, GivenValidParametersWhenCreatingImageWithPropertiesThenImageIsCreatedAndSuccessReturned) {
|
||||
|
||||
cl_mem_properties_intel properties[] = {CL_MEM_FLAGS, CL_MEM_READ_WRITE, 0};
|
||||
|
||||
auto image = clCreateImageWithPropertiesINTEL(
|
||||
pContext,
|
||||
properties,
|
||||
&imageFormat,
|
||||
&imageDesc,
|
||||
nullptr,
|
||||
&retVal);
|
||||
|
||||
ASSERT_EQ(CL_SUCCESS, retVal);
|
||||
EXPECT_NE(nullptr, image);
|
||||
|
||||
retVal = clReleaseMemObject(image);
|
||||
EXPECT_EQ(CL_SUCCESS, retVal);
|
||||
}
|
||||
|
||||
TEST_F(clCreateImageWithPropertiesINTELTest, GivenInvalidPropertyKeyWhenCreatingImageWithPropertiesThenInvalidValueErrorIsReturned) {
|
||||
|
||||
cl_mem_properties_intel properties[] = {(cl_mem_properties_intel(1) << 31), 0, 0};
|
||||
|
||||
auto image = clCreateImageWithPropertiesINTEL(
|
||||
pContext,
|
||||
properties,
|
||||
&imageFormat,
|
||||
&imageDesc,
|
||||
nullptr,
|
||||
&retVal);
|
||||
|
||||
EXPECT_EQ(nullptr, image);
|
||||
EXPECT_EQ(CL_INVALID_VALUE, retVal);
|
||||
}
|
||||
|
||||
typedef clCreateImageTests<::testing::Test> clCreateImageFromImageTest;
|
||||
|
||||
TEST_F(clCreateImageFromImageTest, GivenImage2dWhenCreatingImage2dFromImageWithTheSameDescriptorAndValidFormatThenImageIsCreatedAndSuccessReturned) {
|
||||
|
|
|
@ -58,6 +58,11 @@ TEST_F(clGetExtensionFunctionAddressTests, GivenClCreateBufferWithPropertiesINTE
|
|||
EXPECT_EQ(functionPointer, reinterpret_cast<void *>(clCreateBufferWithPropertiesINTEL));
|
||||
}
|
||||
|
||||
TEST_F(clGetExtensionFunctionAddressTests, GivenClCreateImageWithPropertiesINTELWhenGettingExtensionFunctionThenCorrectAddressIsReturned) {
|
||||
auto functionPointer = clGetExtensionFunctionAddress("clCreateImageWithPropertiesINTEL");
|
||||
EXPECT_EQ(functionPointer, reinterpret_cast<void *>(clCreateImageWithPropertiesINTEL));
|
||||
}
|
||||
|
||||
TEST_F(clGetExtensionFunctionAddressTests, givenClAddCommentToAubIntelAsInputWhenFunctionIsCalledThenProperPointerIsReturned) {
|
||||
auto functionPointer = clGetExtensionFunctionAddress("clAddCommentINTEL");
|
||||
EXPECT_EQ(functionPointer, reinterpret_cast<void *>(clAddCommentINTEL));
|
||||
|
|
Loading…
Reference in New Issue