mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Fix image 2d validation
check image sizes only for image without parent mem object Change-Id: I73189f1c73653f609c6e4d7dcb7a85d06a2f858a
This commit is contained in:
@ -455,15 +455,13 @@ cl_int Image::validate(Context *context,
|
||||
if (!parentImage->hasSameDescriptor(*imageDesc) || !parentImage->hasValidParentImageFormat(surfaceFormat->OCLImageFormat)) {
|
||||
retVal = CL_INVALID_IMAGE_FORMAT_DESCRIPTOR;
|
||||
}
|
||||
} else if (imageDesc->image_width == 0 ||
|
||||
imageDesc->image_height == 0) {
|
||||
}
|
||||
if (!imageDesc->mem_object && (imageDesc->image_width == 0 ||
|
||||
imageDesc->image_height == 0)) {
|
||||
retVal = CL_INVALID_IMAGE_DESCRIPTOR;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (parentImage) {
|
||||
retVal = CL_INVALID_IMAGE_DESCRIPTOR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (hostPtr == nullptr) {
|
||||
|
@ -892,3 +892,36 @@ TEST(ImageFormatValidatorTest, givenValidParentChannelOrderAndChannelOrderWhenFo
|
||||
imageFormat.image_channel_order = CL_sBGRA;
|
||||
EXPECT_FALSE(image.hasValidParentImageFormat(imageFormat));
|
||||
};
|
||||
TEST(ImageValidatorTest, givenInvalidImage2dSizesWithoutParentObjectWhenValidateImageThenReturnsError) {
|
||||
MockContext context;
|
||||
cl_image_desc descriptor;
|
||||
void *dummyPtr = reinterpret_cast<void *>(0x17);
|
||||
SurfaceFormatInfo surfaceFormat;
|
||||
descriptor.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
descriptor.image_row_pitch = 0;
|
||||
|
||||
descriptor.image_height = 1;
|
||||
descriptor.image_width = 0;
|
||||
descriptor.mem_object = nullptr;
|
||||
EXPECT_EQ(CL_INVALID_IMAGE_DESCRIPTOR, Image::validate(&context, 0, &surfaceFormat, &descriptor, dummyPtr));
|
||||
|
||||
descriptor.image_height = 0;
|
||||
descriptor.image_width = 1;
|
||||
EXPECT_EQ(CL_INVALID_IMAGE_DESCRIPTOR, Image::validate(&context, 0, &surfaceFormat, &descriptor, dummyPtr));
|
||||
};
|
||||
TEST(ImageValidatorTest, givenNV12Image2dAsParentImageWhenValidateImageZeroSizedThenReturnsSuccess) {
|
||||
NullImage image;
|
||||
cl_image_desc descriptor;
|
||||
MockContext context;
|
||||
void *dummyPtr = reinterpret_cast<void *>(0x17);
|
||||
SurfaceFormatInfo surfaceFormat;
|
||||
image.imageFormat.image_channel_order = CL_NV12_INTEL;
|
||||
|
||||
descriptor.image_type = CL_MEM_OBJECT_IMAGE2D;
|
||||
descriptor.image_height = 0;
|
||||
descriptor.image_width = 0;
|
||||
descriptor.image_row_pitch = 0;
|
||||
descriptor.mem_object = ℑ
|
||||
|
||||
EXPECT_EQ(CL_SUCCESS, Image::validate(&context, 0, &surfaceFormat, &descriptor, dummyPtr));
|
||||
};
|
||||
|
Reference in New Issue
Block a user