mirror of
https://github.com/intel/compute-runtime.git
synced 2025-09-15 13:01:45 +08:00
Check if origin + region doesn't exceed image_array_size
Signed-off-by: Rafal Maziejuk <rafal.maziejuk@intel.com> Related-To: NEO-6137
This commit is contained in:

committed by
Compute-Runtime-Automation

parent
d2fbcc1960
commit
659a67672e
@ -1450,6 +1450,18 @@ cl_int Image::validateRegionAndOrigin(const size_t *origin, const size_t *region
|
||||
}
|
||||
}
|
||||
|
||||
if (imgDesc.image_type == CL_MEM_OBJECT_IMAGE1D_ARRAY) {
|
||||
if (origin[1] + region[1] > imgDesc.image_array_size) {
|
||||
return CL_INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (imgDesc.image_type == CL_MEM_OBJECT_IMAGE2D_ARRAY) {
|
||||
if (origin[2] + region[2] > imgDesc.image_array_size) {
|
||||
return CL_INVALID_VALUE;
|
||||
}
|
||||
}
|
||||
|
||||
bool notMipMapped = (false == isMipMapped(imgDesc));
|
||||
|
||||
if ((imgDesc.image_type == CL_MEM_OBJECT_IMAGE1D || imgDesc.image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER) &&
|
||||
|
@ -1592,6 +1592,7 @@ TEST(ImageTest, givenImageWhenValidateRegionAndOriginIsCalledThenAdditionalOrigi
|
||||
|
||||
desc.image_height = 1;
|
||||
desc.image_depth = 1;
|
||||
desc.image_array_size = 1;
|
||||
EXPECT_EQ(CL_SUCCESS, Image::validateRegionAndOrigin(origin, region, desc));
|
||||
|
||||
if (imageType == CL_MEM_OBJECT_IMAGE3D) {
|
||||
@ -1601,6 +1602,28 @@ TEST(ImageTest, givenImageWhenValidateRegionAndOriginIsCalledThenAdditionalOrigi
|
||||
}
|
||||
}
|
||||
|
||||
TEST(ImageTest, givenImageArrayWhenValidateRegionAndOriginIsCalledThenAdditionalOriginAndRegionCoordinatesAreAnalyzed) {
|
||||
size_t region[3]{1, 1, 1};
|
||||
size_t origin[3]{};
|
||||
cl_image_desc desc = {};
|
||||
|
||||
desc.image_type = CL_MEM_OBJECT_IMAGE1D_ARRAY;
|
||||
desc.image_width = 1;
|
||||
EXPECT_EQ(CL_INVALID_VALUE, Image::validateRegionAndOrigin(origin, region, desc));
|
||||
|
||||
desc.image_array_size = 1;
|
||||
EXPECT_EQ(CL_SUCCESS, Image::validateRegionAndOrigin(origin, region, desc));
|
||||
|
||||
desc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
desc.image_array_size = 0;
|
||||
desc.image_width = 1;
|
||||
desc.image_height = 1;
|
||||
EXPECT_EQ(CL_INVALID_VALUE, Image::validateRegionAndOrigin(origin, region, desc));
|
||||
|
||||
desc.image_array_size = 1;
|
||||
EXPECT_EQ(CL_SUCCESS, Image::validateRegionAndOrigin(origin, region, desc));
|
||||
}
|
||||
|
||||
typedef ::testing::TestWithParam<uint32_t> MipLevelCoordinateTest;
|
||||
|
||||
TEST_P(MipLevelCoordinateTest, givenMipmappedImageWhenValidateRegionAndOriginIsCalledThenAdditionalOriginCoordinateIsAnalyzed) {
|
||||
@ -1612,6 +1635,7 @@ TEST_P(MipLevelCoordinateTest, givenMipmappedImageWhenValidateRegionAndOriginIsC
|
||||
desc.image_width = 1;
|
||||
desc.image_height = 1;
|
||||
desc.image_depth = 1;
|
||||
desc.image_array_size = 1;
|
||||
origin[getMipLevelOriginIdx(desc.image_type)] = 1;
|
||||
EXPECT_EQ(CL_SUCCESS, Image::validateRegionAndOrigin(origin, region, desc));
|
||||
origin[getMipLevelOriginIdx(desc.image_type)] = 2;
|
||||
|
Reference in New Issue
Block a user