diff --git a/runtime/api/api.cpp b/runtime/api/api.cpp index 039e5fbdf2..e52314b6c4 100644 --- a/runtime/api/api.cpp +++ b/runtime/api/api.cpp @@ -1016,7 +1016,10 @@ cl_int CL_API_CALL clGetSupportedImageFormats(cl_context context, retVal = pContext->getSupportedImageFormats(&pClDevice->getDevice(), flags, imageType, numEntries, imageFormats, numImageFormats); } else { - retVal = CL_INVALID_VALUE; + if (numImageFormats) { + *numImageFormats = 0u; + } + retVal = CL_SUCCESS; } } else { retVal = CL_INVALID_CONTEXT; diff --git a/runtime/device/device_info.cpp b/runtime/device/device_info.cpp index 0f05fed384..5febab51fa 100644 --- a/runtime/device/device_info.cpp +++ b/runtime/device/device_info.cpp @@ -190,7 +190,10 @@ cl_int ClDevice::getDeviceInfo(cl_device_info paramName, break; } default: - if (device.getDeviceInfo().imageSupport && getDeviceInfoForImage(paramName, src, srcSize, retSize)) { + if (getDeviceInfoForImage(paramName, src, srcSize, retSize) && !device.getDeviceInfo().imageSupport) { + param = 0u; + src = ¶m; + srcSize = retSize = sizeof(param); break; } ClDeviceHelper::getExtraDeviceInfo(*this, paramName, param, src, srcSize, retSize); @@ -209,6 +212,7 @@ bool ClDevice::getDeviceInfoForImage(cl_device_info paramName, const void *&src, size_t &srcSize, size_t &retSize) { + bool retVal = true; switch (paramName) { case CL_DEVICE_MAX_READ_IMAGE_ARGS: getCap(src, srcSize, retSize); @@ -247,17 +251,23 @@ bool ClDevice::getDeviceInfoForImage(cl_device_info paramName, getCap(src, srcSize, retSize); break; case CL_DEVICE_PLANAR_YUV_MAX_WIDTH_INTEL: - if (getDeviceInfo().nv12Extension) + if (getDeviceInfo().nv12Extension) { getCap(src, srcSize, retSize); + break; + } + retVal = false; break; case CL_DEVICE_PLANAR_YUV_MAX_HEIGHT_INTEL: - if (getDeviceInfo().nv12Extension) + if (getDeviceInfo().nv12Extension) { getCap(src, srcSize, retSize); + break; + } + retVal = false; break; default: - return false; + retVal = false; } - return true; + return retVal; } } // namespace NEO diff --git a/unit_tests/api/cl_get_supported_image_formats_tests.inl b/unit_tests/api/cl_get_supported_image_formats_tests.inl index ee364cbde5..26d7ee1c1f 100644 --- a/unit_tests/api/cl_get_supported_image_formats_tests.inl +++ b/unit_tests/api/cl_get_supported_image_formats_tests.inl @@ -49,7 +49,7 @@ TEST_F(clGetSupportedImageFormatsTests, givenInvalidContextWhenGettingSupportIma EXPECT_EQ(CL_INVALID_CONTEXT, retVal); } -TEST(clGetSupportedImageFormatsTest, givenPlatforNotSupportingImageWhenGettingSupportImageFormatsThenClInvalidValueIsReturned) { +TEST(clGetSupportedImageFormatsTest, givenPlatforNotSupportingImageWhenGettingSupportImageFormatsThenCLSuccessReturned) { HardwareInfo hwInfo = *platformDevices[0]; hwInfo.capabilityTable.supportsImages = false; auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); @@ -67,7 +67,28 @@ TEST(clGetSupportedImageFormatsTest, givenPlatforNotSupportingImageWhenGettingSu nullptr, &numImageFormats); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, numImageFormats); +} + +TEST(clGetSupportedImageFormatsTest, givenPlatforNotSupportingImageAndNullPointerToNumFormatsWhenGettingSupportImageFormatsThenCLSuccessReturned) { + HardwareInfo hwInfo = *platformDevices[0]; + hwInfo.capabilityTable.supportsImages = false; + auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(&hwInfo)); + cl_device_id clDevice = device.get(); + cl_int retVal; + auto context = ReleaseableObjectPtr(Context::create(nullptr, ClDeviceVector(&clDevice, 1), nullptr, nullptr, retVal)); + EXPECT_EQ(CL_SUCCESS, retVal); + + retVal = clGetSupportedImageFormats( + context.get(), + CL_MEM_READ_WRITE, + CL_MEM_OBJECT_IMAGE2D, + 0, + nullptr, + nullptr); + + EXPECT_EQ(CL_SUCCESS, retVal); } TEST(clGetSupportedImageFormatsTest, givenPlatformWithoutDevicesWhenClGetSupportedImageFormatIsCalledThenDeviceIsTakenFromContext) { diff --git a/unit_tests/device/get_device_info_size_tests.cpp b/unit_tests/device/get_device_info_size_tests.cpp index c9a37c6bda..10630e5aae 100644 --- a/unit_tests/device/get_device_info_size_tests.cpp +++ b/unit_tests/device/get_device_info_size_tests.cpp @@ -146,7 +146,7 @@ TEST_P(GetDeviceInfoForImage, imageInfoSizeIsValid) { EXPECT_EQ(param.second, sizeReturned); } -TEST_P(GetDeviceInfoForImage, whenImageAreNotSupportedThenClInvalidValueIsReturned) { +TEST_P(GetDeviceInfoForImage, whenImageAreNotSupportedThenClSuccessAndSizeofCluintIsReturned) { auto device = std::make_unique(*MockDevice::createWithNewExecutionEnvironment(nullptr), platform()); if (device->getDeviceInfo().imageSupport) { GTEST_SKIP(); @@ -157,7 +157,8 @@ TEST_P(GetDeviceInfoForImage, whenImageAreNotSupportedThenClInvalidValueIsReturn 0, nullptr, &sizeReturned); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(sizeof(cl_uint), sizeReturned); } TEST_P(GetDeviceInfoForImage, givenInfoImageParamsWhenCallGetDeviceInfoForImageThenSizeIsValidAndTrueReturned) { diff --git a/unit_tests/device/get_device_info_tests.cpp b/unit_tests/device/get_device_info_tests.cpp index 6804f854f3..8c317c1def 100644 --- a/unit_tests/device/get_device_info_tests.cpp +++ b/unit_tests/device/get_device_info_tests.cpp @@ -113,7 +113,7 @@ TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsErrorWhenPlanarYuvExtens EXPECT_EQ(CL_INVALID_VALUE, retVal); } -TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsErrorWhenPlanarYuvExtensionEnabledAndSupportImageDisabled) { +TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsSuccessWhenPlanarYuvExtensionEnabledAndSupportImageDisabled) { auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); device->deviceInfo.imageSupport = false; device->deviceInfo.nv12Extension = true; @@ -121,26 +121,28 @@ TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsErrorWhenPlanarYuvExtens auto retVal = device->getDeviceInfo( CL_DEVICE_PLANAR_YUV_MAX_WIDTH_INTEL, - 4, + sizeof(size_t), &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); retVal = device->getDeviceInfo( CL_DEVICE_PLANAR_YUV_MAX_HEIGHT_INTEL, - 4, + sizeof(size_t), &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); } -TEST(GetDeviceInfo, clDeviceImage2dMaxWidthHeightReturnsErrorWhenImageSupportDisabled) { +TEST(GetDeviceInfo, clDeviceImage2dMaxWidthHeightReturnsSuccessWhenImageSupportDisabled) { auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); device->deviceInfo.imageSupport = false; - uint32_t value; + size_t value = 0; auto retVal = device->getDeviceInfo( CL_DEVICE_IMAGE2D_MAX_WIDTH, @@ -148,7 +150,8 @@ TEST(GetDeviceInfo, clDeviceImage2dMaxWidthHeightReturnsErrorWhenImageSupportDis &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); retVal = device->getDeviceInfo( CL_DEVICE_IMAGE2D_MAX_HEIGHT, @@ -156,7 +159,8 @@ TEST(GetDeviceInfo, clDeviceImage2dMaxWidthHeightReturnsErrorWhenImageSupportDis &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); } TEST(GetDeviceInfo, clDeviceImage2dMaxWidthHeightReturnsCorrectValuesWhenImageSupportEnabled) { @@ -182,11 +186,11 @@ TEST(GetDeviceInfo, clDeviceImage2dMaxWidthHeightReturnsCorrectValuesWhenImageSu EXPECT_EQ(CL_SUCCESS, retVal); } -TEST(GetDeviceInfo, clDeviceImage3dMaxWidthHeightDepthReturnsErrorWhenImageSupportDisabled) { +TEST(GetDeviceInfo, clDeviceImage3dMaxWidthHeightDepthReturnsSuccessWhenImageSupportDisabled) { auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); + size_t value = 0; device->deviceInfo.imageSupport = false; - uint32_t value; auto retVal = device->getDeviceInfo( CL_DEVICE_IMAGE3D_MAX_WIDTH, @@ -194,7 +198,8 @@ TEST(GetDeviceInfo, clDeviceImage3dMaxWidthHeightDepthReturnsErrorWhenImageSuppo &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); retVal = device->getDeviceInfo( CL_DEVICE_IMAGE3D_MAX_HEIGHT, @@ -202,7 +207,8 @@ TEST(GetDeviceInfo, clDeviceImage3dMaxWidthHeightDepthReturnsErrorWhenImageSuppo &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); retVal = device->getDeviceInfo( CL_DEVICE_IMAGE3D_MAX_DEPTH, @@ -210,7 +216,8 @@ TEST(GetDeviceInfo, clDeviceImage3dMaxWidthHeightDepthReturnsErrorWhenImageSuppo &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); } TEST(GetDeviceInfo, clDeviceImage3dMaxWidthHeightDepthReturnsCorrectValuesWhenImageSupportEnabled) { @@ -244,7 +251,7 @@ TEST(GetDeviceInfo, clDeviceImage3dMaxWidthHeightDepthReturnsCorrectValuesWhenIm EXPECT_EQ(CL_SUCCESS, retVal); } -TEST(GetDeviceInfo, clDeviceImageMaxArgsReturnsErrorWhenImageSupportDisabled) { +TEST(GetDeviceInfo, clDeviceImageMaxArgsReturnsSuccessWhenImageSupportDisabled) { auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); device->deviceInfo.imageSupport = false; @@ -256,7 +263,8 @@ TEST(GetDeviceInfo, clDeviceImageMaxArgsReturnsErrorWhenImageSupportDisabled) { &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); retVal = device->getDeviceInfo( CL_DEVICE_MAX_READ_WRITE_IMAGE_ARGS, @@ -264,7 +272,8 @@ TEST(GetDeviceInfo, clDeviceImageMaxArgsReturnsErrorWhenImageSupportDisabled) { &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); retVal = device->getDeviceInfo( CL_DEVICE_MAX_WRITE_IMAGE_ARGS, @@ -272,7 +281,8 @@ TEST(GetDeviceInfo, clDeviceImageMaxArgsReturnsErrorWhenImageSupportDisabled) { &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); } TEST(GetDeviceInfo, clDeviceImageMaxArgsReturnsCorrectValuesWhenImageSupportEnabled) { @@ -306,11 +316,11 @@ TEST(GetDeviceInfo, clDeviceImageMaxArgsReturnsCorrectValuesWhenImageSupportEnab EXPECT_EQ(CL_SUCCESS, retVal); } -TEST(GetDeviceInfo, clDeviceImageBaseAddressAlignmentReturnsErrorWhenImageSupportDisabled) { +TEST(GetDeviceInfo, clDeviceImageBaseAddressAlignmentReturnsSuccessWhenImageSupportDisabled) { auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); + size_t value = 0; device->deviceInfo.imageSupport = false; - uint32_t value; auto retVal = device->getDeviceInfo( CL_DEVICE_IMAGE_BASE_ADDRESS_ALIGNMENT, @@ -318,7 +328,8 @@ TEST(GetDeviceInfo, clDeviceImageBaseAddressAlignmentReturnsErrorWhenImageSuppor &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); } TEST(GetDeviceInfo, clDeviceImageBaseAddressAlignmentReturnsCorrectValuesWhenImageSupportEnabled) { @@ -338,9 +349,9 @@ TEST(GetDeviceInfo, clDeviceImageBaseAddressAlignmentReturnsCorrectValuesWhenIma TEST(GetDeviceInfo, clDeviceImageMaxArraySizeReturnsErrorWhenImageSupportDisabled) { auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); + size_t value = 0; device->deviceInfo.imageSupport = false; - uint32_t value; auto retVal = device->getDeviceInfo( CL_DEVICE_IMAGE_MAX_ARRAY_SIZE, @@ -348,7 +359,8 @@ TEST(GetDeviceInfo, clDeviceImageMaxArraySizeReturnsErrorWhenImageSupportDisable &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); } TEST(GetDeviceInfo, clDeviceImageMaxArraySizeReturnsCorrectValuesWhenImageSupportEnabled) { @@ -366,11 +378,11 @@ TEST(GetDeviceInfo, clDeviceImageMaxArraySizeReturnsCorrectValuesWhenImageSuppor EXPECT_EQ(CL_SUCCESS, retVal); } -TEST(GetDeviceInfo, clDeviceImageMaxBufferSizeReturnsErrorWhenImageSupportDisabled) { +TEST(GetDeviceInfo, clDeviceImageMaxBufferSizeReturnsSuccessWhenImageSupportDisabled) { auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); + size_t value = 0; device->deviceInfo.imageSupport = false; - uint32_t value; auto retVal = device->getDeviceInfo( CL_DEVICE_IMAGE_MAX_BUFFER_SIZE, @@ -378,7 +390,8 @@ TEST(GetDeviceInfo, clDeviceImageMaxBufferSizeReturnsErrorWhenImageSupportDisabl &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); } TEST(GetDeviceInfo, clDeviceImageMaxBufferSizeReturnsCorrectValuesWhenImageSupportEnabled) { @@ -396,11 +409,11 @@ TEST(GetDeviceInfo, clDeviceImageMaxBufferSizeReturnsCorrectValuesWhenImageSuppo EXPECT_EQ(CL_SUCCESS, retVal); } -TEST(GetDeviceInfo, clDeviceImagePtichAlignmentReturnsErrorWhenImageSupportDisabled) { +TEST(GetDeviceInfo, clDeviceImagePtichAlignmentReturnsSuccessWhenImageSupportDisabled) { auto device = std::make_unique(MockDevice::createWithNewExecutionEnvironment(nullptr)); + size_t value = 0; device->deviceInfo.imageSupport = false; - uint32_t value; auto retVal = device->getDeviceInfo( CL_DEVICE_IMAGE_PITCH_ALIGNMENT, @@ -408,7 +421,8 @@ TEST(GetDeviceInfo, clDeviceImagePtichAlignmentReturnsErrorWhenImageSupportDisab &value, nullptr); - EXPECT_EQ(CL_INVALID_VALUE, retVal); + EXPECT_EQ(CL_SUCCESS, retVal); + EXPECT_EQ(0u, value); } TEST(GetDeviceInfo, clDeviceImagePtichAlignmentReturnsCorrectValuesWhenImageSupportEnabled) {