Change error code from CL_INVALID_VALUE to CL_SUCCESSS

when image are not suppoorted

Change-Id: I8350558ada1ab048b02b68cb372a22fdadf8c2f5
Signed-off-by: Katarzyna Cencelewska <katarzyna.cencelewska@intel.com>
This commit is contained in:
Katarzyna Cencelewska
2020-02-11 10:28:27 +01:00
committed by sys_ocldev
parent b28e3fcad8
commit 541e161898
5 changed files with 88 additions and 39 deletions

View File

@@ -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;

View File

@@ -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 = &param;
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<CL_DEVICE_MAX_READ_IMAGE_ARGS>(src, srcSize, retSize);
@@ -247,17 +251,23 @@ bool ClDevice::getDeviceInfoForImage(cl_device_info paramName,
getCap<CL_DEVICE_IMAGE_PITCH_ALIGNMENT>(src, srcSize, retSize);
break;
case CL_DEVICE_PLANAR_YUV_MAX_WIDTH_INTEL:
if (getDeviceInfo().nv12Extension)
if (getDeviceInfo().nv12Extension) {
getCap<CL_DEVICE_PLANAR_YUV_MAX_WIDTH_INTEL>(src, srcSize, retSize);
break;
}
retVal = false;
break;
case CL_DEVICE_PLANAR_YUV_MAX_HEIGHT_INTEL:
if (getDeviceInfo().nv12Extension)
if (getDeviceInfo().nv12Extension) {
getCap<CL_DEVICE_PLANAR_YUV_MAX_HEIGHT_INTEL>(src, srcSize, retSize);
break;
}
retVal = false;
break;
default:
return false;
retVal = false;
}
return true;
return retVal;
}
} // namespace NEO

View File

@@ -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<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&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<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(&hwInfo));
cl_device_id clDevice = device.get();
cl_int retVal;
auto context = ReleaseableObjectPtr<Context>(Context::create<Context>(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) {

View File

@@ -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<ClDevice>(*MockDevice::createWithNewExecutionEnvironment<MockDevice>(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) {

View File

@@ -113,7 +113,7 @@ TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsErrorWhenPlanarYuvExtens
EXPECT_EQ(CL_INVALID_VALUE, retVal);
}
TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsErrorWhenPlanarYuvExtensionEnabledAndSupportImageDisabled) {
TEST(GetDeviceInfo, devicePlanarYuvMaxWidthHeightReturnsSuccessWhenPlanarYuvExtensionEnabledAndSupportImageDisabled) {
auto device = std::make_unique<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(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<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(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<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(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<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(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<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(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<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(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<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(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<MockClDevice>(MockDevice::createWithNewExecutionEnvironment<MockDevice>(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) {