Fix Image Copy with null region to handle invalid height/depth in descriptor

Change-Id: Ida41570c1ee12f68f5630bacb357447b6d4dd171
Signed-off-by: Spruit, Neil R <neil.r.spruit@intel.com>
This commit is contained in:
Spruit, Neil R
2020-07-08 18:04:18 +00:00
committed by sys_ocldev
parent 4d356178eb
commit 2ae0260c7d
2 changed files with 233 additions and 0 deletions

View File

@@ -245,6 +245,14 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyFromMemory(ze_i
ze_image_region_t tmpRegion;
if (pDstRegion == nullptr) {
// If this is a 1D or 2D image, then the height or depth is ignored and must be set to 1.
// Internally, all dimensions must be >= 1.
if (image->getImageDesc().type == ZE_IMAGE_TYPE_1D || image->getImageDesc().type == ZE_IMAGE_TYPE_1DARRAY) {
imgSize.y = 1;
}
if (image->getImageDesc().type != ZE_IMAGE_TYPE_3D) {
imgSize.z = 1;
}
tmpRegion = {0,
0,
0,
@@ -351,6 +359,14 @@ ze_result_t CommandListCoreFamily<gfxCoreFamily>::appendImageCopyToMemory(void *
ze_image_region_t tmpRegion;
if (pSrcRegion == nullptr) {
// If this is a 1D or 2D image, then the height or depth is ignored and must be set to 1.
// Internally, all dimensions must be >= 1.
if (image->getImageDesc().type == ZE_IMAGE_TYPE_1D || image->getImageDesc().type == ZE_IMAGE_TYPE_1DARRAY) {
imgSize.y = 1;
}
if (image->getImageDesc().type != ZE_IMAGE_TYPE_3D) {
imgSize.z = 1;
}
tmpRegion = {0,
0,
0,

View File

@@ -757,6 +757,9 @@ HWTEST2_F(CommandListCreate, givenCopyCommandListAndNullDestinationRegionWhenIma
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
imageHW->initialize(device, &zeDesc);
zeDesc.height = 1;
zeDesc.depth = 1;
Vec3<size_t> expectedRegionCopySize = {zeDesc.width, zeDesc.height, zeDesc.depth};
Vec3<size_t> expectedRegionOrigin = {0, 0, 0};
cmdList.appendImageCopyFromMemory(imageHW->toHandle(), srcPtr, nullptr, nullptr, 0, nullptr);
@@ -773,6 +776,9 @@ HWTEST2_F(CommandListCreate, givenCopyCommandListAndNullDestinationRegionWhenIma
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
imageHW->initialize(device, &zeDesc);
zeDesc.height = 1;
zeDesc.depth = 1;
Vec3<size_t> expectedRegionCopySize = {zeDesc.width, zeDesc.height, zeDesc.depth};
Vec3<size_t> expectedRegionOrigin = {0, 0, 0};
cmdList.appendImageCopyToMemory(dstPtr, imageHW->toHandle(), nullptr, nullptr, 0, nullptr);
@@ -780,6 +786,217 @@ HWTEST2_F(CommandListCreate, givenCopyCommandListAndNullDestinationRegionWhenIma
EXPECT_EQ(cmdList.appendImageRegionSrcOrigin, expectedRegionOrigin);
}
HWTEST2_F(CommandListCreate, givenCopyCommandListAndNullDestinationRegionWhen1DImageCopyFromMemoryWithInvalidHeightAndDepthThenBlitImageCopyCalledWithCorrectImageSize, ImageSupport) {
MockCommandList<gfxCoreFamily> cmdList;
cmdList.initialize(device, true);
void *srcPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.type = ZE_IMAGE_TYPE_1D;
zeDesc.height = 9;
zeDesc.depth = 9;
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
imageHW->initialize(device, &zeDesc);
zeDesc.height = 1;
zeDesc.depth = 1;
Vec3<size_t> expectedRegionCopySize = {zeDesc.width, zeDesc.height, zeDesc.depth};
Vec3<size_t> expectedRegionOrigin = {0, 0, 0};
cmdList.appendImageCopyFromMemory(imageHW->toHandle(), srcPtr, nullptr, nullptr, 0, nullptr);
EXPECT_EQ(cmdList.appendImageRegionCopySize, expectedRegionCopySize);
EXPECT_EQ(cmdList.appendImageRegionDstOrigin, expectedRegionOrigin);
}
HWTEST2_F(CommandListCreate, givenCopyCommandListAndNullDestinationRegionWhen1DImageCopyToMemoryWithInvalidHeightAndDepthThenBlitImageCopyCalledWithCorrectImageSize, ImageSupport) {
MockCommandList<gfxCoreFamily> cmdList;
cmdList.initialize(device, true);
void *dstPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.type = ZE_IMAGE_TYPE_1D;
zeDesc.height = 9;
zeDesc.depth = 9;
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
imageHW->initialize(device, &zeDesc);
zeDesc.height = 1;
zeDesc.depth = 1;
Vec3<size_t> expectedRegionCopySize = {zeDesc.width, zeDesc.height, zeDesc.depth};
Vec3<size_t> expectedRegionOrigin = {0, 0, 0};
cmdList.appendImageCopyToMemory(dstPtr, imageHW->toHandle(), nullptr, nullptr, 0, nullptr);
EXPECT_EQ(cmdList.appendImageRegionCopySize, expectedRegionCopySize);
EXPECT_EQ(cmdList.appendImageRegionSrcOrigin, expectedRegionOrigin);
}
HWTEST2_F(CommandListCreate, givenCopyCommandListAndNullDestinationRegionWhen1DArrayImageCopyFromMemoryWithInvalidHeightAndDepthThenBlitImageCopyCalledWithCorrectImageSize, ImageSupport) {
MockCommandList<gfxCoreFamily> cmdList;
cmdList.initialize(device, true);
void *srcPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.type = ZE_IMAGE_TYPE_1DARRAY;
zeDesc.height = 9;
zeDesc.depth = 9;
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
imageHW->initialize(device, &zeDesc);
zeDesc.height = 1;
zeDesc.depth = 1;
Vec3<size_t> expectedRegionCopySize = {zeDesc.width, zeDesc.height, zeDesc.depth};
Vec3<size_t> expectedRegionOrigin = {0, 0, 0};
cmdList.appendImageCopyFromMemory(imageHW->toHandle(), srcPtr, nullptr, nullptr, 0, nullptr);
EXPECT_EQ(cmdList.appendImageRegionCopySize, expectedRegionCopySize);
EXPECT_EQ(cmdList.appendImageRegionDstOrigin, expectedRegionOrigin);
}
HWTEST2_F(CommandListCreate, givenCopyCommandListAndNullDestinationRegionWhen1DArrayImageCopyToMemoryWithInvalidHeightAndDepthThenBlitImageCopyCalledWithCorrectImageSize, ImageSupport) {
MockCommandList<gfxCoreFamily> cmdList;
cmdList.initialize(device, true);
void *dstPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.type = ZE_IMAGE_TYPE_1DARRAY;
zeDesc.height = 9;
zeDesc.depth = 9;
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
imageHW->initialize(device, &zeDesc);
zeDesc.height = 1;
zeDesc.depth = 1;
Vec3<size_t> expectedRegionCopySize = {zeDesc.width, zeDesc.height, zeDesc.depth};
Vec3<size_t> expectedRegionOrigin = {0, 0, 0};
cmdList.appendImageCopyToMemory(dstPtr, imageHW->toHandle(), nullptr, nullptr, 0, nullptr);
EXPECT_EQ(cmdList.appendImageRegionCopySize, expectedRegionCopySize);
EXPECT_EQ(cmdList.appendImageRegionSrcOrigin, expectedRegionOrigin);
}
HWTEST2_F(CommandListCreate, givenCopyCommandListAndNullDestinationRegionWhen2DImageCopyToMemoryThenBlitImageCopyCalledWithCorrectImageSize, ImageSupport) {
MockCommandList<gfxCoreFamily> cmdList;
cmdList.initialize(device, true);
void *dstPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.type = ZE_IMAGE_TYPE_2D;
zeDesc.height = 2;
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
imageHW->initialize(device, &zeDesc);
zeDesc.depth = 1;
Vec3<size_t> expectedRegionCopySize = {zeDesc.width, zeDesc.height, zeDesc.depth};
Vec3<size_t> expectedRegionOrigin = {0, 0, 0};
cmdList.appendImageCopyToMemory(dstPtr, imageHW->toHandle(), nullptr, nullptr, 0, nullptr);
EXPECT_EQ(cmdList.appendImageRegionCopySize, expectedRegionCopySize);
EXPECT_EQ(cmdList.appendImageRegionSrcOrigin, expectedRegionOrigin);
}
HWTEST2_F(CommandListCreate, givenCopyCommandListAndNullDestinationRegionWhen2DImageCopyFromMemoryThenBlitImageCopyCalledWithCorrectImageSize, ImageSupport) {
MockCommandList<gfxCoreFamily> cmdList;
cmdList.initialize(device, true);
void *srcPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.type = ZE_IMAGE_TYPE_2D;
zeDesc.height = 2;
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
imageHW->initialize(device, &zeDesc);
zeDesc.depth = 1;
Vec3<size_t> expectedRegionCopySize = {zeDesc.width, zeDesc.height, zeDesc.depth};
Vec3<size_t> expectedRegionOrigin = {0, 0, 0};
cmdList.appendImageCopyFromMemory(imageHW->toHandle(), srcPtr, nullptr, nullptr, 0, nullptr);
EXPECT_EQ(cmdList.appendImageRegionCopySize, expectedRegionCopySize);
EXPECT_EQ(cmdList.appendImageRegionDstOrigin, expectedRegionOrigin);
}
HWTEST2_F(CommandListCreate, givenCopyCommandListAndNullDestinationRegionWhen2DImageCopyToMemoryWithInvalidDepthThenBlitImageCopyCalledWithCorrectImageSize, ImageSupport) {
MockCommandList<gfxCoreFamily> cmdList;
cmdList.initialize(device, true);
void *dstPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.type = ZE_IMAGE_TYPE_2D;
zeDesc.height = 2;
zeDesc.depth = 9;
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
imageHW->initialize(device, &zeDesc);
zeDesc.depth = 1;
Vec3<size_t> expectedRegionCopySize = {zeDesc.width, zeDesc.height, zeDesc.depth};
Vec3<size_t> expectedRegionOrigin = {0, 0, 0};
cmdList.appendImageCopyToMemory(dstPtr, imageHW->toHandle(), nullptr, nullptr, 0, nullptr);
EXPECT_EQ(cmdList.appendImageRegionCopySize, expectedRegionCopySize);
EXPECT_EQ(cmdList.appendImageRegionSrcOrigin, expectedRegionOrigin);
}
HWTEST2_F(CommandListCreate, givenCopyCommandListAndNullDestinationRegionWhen2DImageCopyFromMemoryWithInvalidDepthThenBlitImageCopyCalledWithCorrectImageSize, ImageSupport) {
MockCommandList<gfxCoreFamily> cmdList;
cmdList.initialize(device, true);
void *srcPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.type = ZE_IMAGE_TYPE_2D;
zeDesc.height = 2;
zeDesc.depth = 9;
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
imageHW->initialize(device, &zeDesc);
zeDesc.depth = 1;
Vec3<size_t> expectedRegionCopySize = {zeDesc.width, zeDesc.height, zeDesc.depth};
Vec3<size_t> expectedRegionOrigin = {0, 0, 0};
cmdList.appendImageCopyFromMemory(imageHW->toHandle(), srcPtr, nullptr, nullptr, 0, nullptr);
EXPECT_EQ(cmdList.appendImageRegionCopySize, expectedRegionCopySize);
EXPECT_EQ(cmdList.appendImageRegionDstOrigin, expectedRegionOrigin);
}
HWTEST2_F(CommandListCreate, givenCopyCommandListAndNullDestinationRegionWhen3DImageCopyToMemoryThenBlitImageCopyCalledWithCorrectImageSize, ImageSupport) {
MockCommandList<gfxCoreFamily> cmdList;
cmdList.initialize(device, true);
void *dstPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.type = ZE_IMAGE_TYPE_3D;
zeDesc.height = 2;
zeDesc.depth = 2;
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
imageHW->initialize(device, &zeDesc);
Vec3<size_t> expectedRegionCopySize = {zeDesc.width, zeDesc.height, zeDesc.depth};
Vec3<size_t> expectedRegionOrigin = {0, 0, 0};
cmdList.appendImageCopyToMemory(dstPtr, imageHW->toHandle(), nullptr, nullptr, 0, nullptr);
EXPECT_EQ(cmdList.appendImageRegionCopySize, expectedRegionCopySize);
EXPECT_EQ(cmdList.appendImageRegionSrcOrigin, expectedRegionOrigin);
}
HWTEST2_F(CommandListCreate, givenCopyCommandListAndNullDestinationRegionWhen3DImageCopyFromMemoryThenBlitImageCopyCalledWithCorrectImageSize, ImageSupport) {
MockCommandList<gfxCoreFamily> cmdList;
cmdList.initialize(device, true);
void *srcPtr = reinterpret_cast<void *>(0x1234);
ze_image_desc_t zeDesc = {};
zeDesc.type = ZE_IMAGE_TYPE_3D;
zeDesc.height = 2;
zeDesc.depth = 2;
auto imageHW = std::make_unique<WhiteBox<::L0::ImageCoreFamily<gfxCoreFamily>>>();
imageHW->initialize(device, &zeDesc);
Vec3<size_t> expectedRegionCopySize = {zeDesc.width, zeDesc.height, zeDesc.depth};
Vec3<size_t> expectedRegionOrigin = {0, 0, 0};
cmdList.appendImageCopyFromMemory(imageHW->toHandle(), srcPtr, nullptr, nullptr, 0, nullptr);
EXPECT_EQ(cmdList.appendImageRegionCopySize, expectedRegionCopySize);
EXPECT_EQ(cmdList.appendImageRegionDstOrigin, expectedRegionOrigin);
}
HWTEST2_F(CommandListCreate, givenCopyCommandListWhenCopyFromImageToMemoryThenBlitImageCopyCalled, ImageSupport) {
MockCommandList<gfxCoreFamily> cmdList;
cmdList.initialize(device, true);