Correct IMAGE1D_BUFFER width size calculation in BCS
Buffer's default bytesPerPixel value always equals 1 and as IMAGE1D_BUFFER is originally an image, X coordinate needs to be multiplied by bytesPerPixel in both copySize and (src/dst)Size. Signed-off-by: Rafal Maziejuk <rafal.maziejuk@intel.com> Related-To: NEO-6134
This commit is contained in:
parent
6b29b03c29
commit
3490b489ad
|
@ -168,7 +168,7 @@ struct ClBlitProperties {
|
|||
}
|
||||
}
|
||||
|
||||
static void adjustBlitPropertiesForImage(MemObj *memObj, Vec3<size_t> &size, size_t &bytesPerPixel, uint64_t &gpuAddress, size_t &rowPitch, size_t &slicePitch, BlitterConstants::BlitDirection &blitDirection) {
|
||||
static void adjustBlitPropertiesForImage(MemObj *memObj, BlitProperties &blitProperties, size_t &rowPitch, size_t &slicePitch, const bool isSource) {
|
||||
auto image = castToObject<Image>(memObj);
|
||||
const auto &imageDesc = image->getImageDesc();
|
||||
auto image_width = imageDesc.image_width;
|
||||
|
@ -180,6 +180,12 @@ struct ClBlitProperties {
|
|||
}
|
||||
|
||||
SurfaceOffsets surfaceOffsets;
|
||||
auto &gpuAddress = isSource ? blitProperties.srcGpuAddress : blitProperties.dstGpuAddress;
|
||||
auto &size = isSource ? blitProperties.srcSize : blitProperties.dstSize;
|
||||
auto ©Size = blitProperties.copySize;
|
||||
auto &bytesPerPixel = blitProperties.bytesPerPixel;
|
||||
auto &blitDirection = blitProperties.blitDirection;
|
||||
|
||||
image->getSurfaceOffsets(surfaceOffsets);
|
||||
gpuAddress += surfaceOffsets.offset;
|
||||
size.x = image_width;
|
||||
|
@ -201,6 +207,9 @@ struct ClBlitProperties {
|
|||
if (blitDirection == BlitterConstants::BlitDirection::ImageToImage) {
|
||||
blitDirection = BlitterConstants::BlitDirection::BufferToBuffer;
|
||||
}
|
||||
|
||||
size.x *= bytesPerPixel;
|
||||
copySize.x *= bytesPerPixel;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -212,14 +221,12 @@ struct ClBlitProperties {
|
|||
|
||||
if (blitProperties.blitDirection == BlitterConstants::BlitDirection::ImageToHostPtr ||
|
||||
blitProperties.blitDirection == BlitterConstants::BlitDirection::ImageToImage) {
|
||||
adjustBlitPropertiesForImage(builtinOpParams.srcMemObj, blitProperties.srcSize, blitProperties.bytesPerPixel,
|
||||
blitProperties.srcGpuAddress, srcRowPitch, srcSlicePitch, blitProperties.blitDirection);
|
||||
adjustBlitPropertiesForImage(builtinOpParams.srcMemObj, blitProperties, srcRowPitch, srcSlicePitch, true);
|
||||
}
|
||||
|
||||
if (blitProperties.blitDirection == BlitterConstants::BlitDirection::HostPtrToImage ||
|
||||
blitProperties.blitDirection == BlitterConstants::BlitDirection::ImageToImage) {
|
||||
adjustBlitPropertiesForImage(builtinOpParams.dstMemObj, blitProperties.dstSize, blitProperties.bytesPerPixel,
|
||||
blitProperties.dstGpuAddress, dstRowPitch, dstSlicePitch, blitProperties.blitDirection);
|
||||
adjustBlitPropertiesForImage(builtinOpParams.dstMemObj, blitProperties, dstRowPitch, dstSlicePitch, false);
|
||||
}
|
||||
|
||||
blitProperties.srcRowPitch = srcRowPitch ? srcRowPitch : blitProperties.srcSize.x * blitProperties.bytesPerPixel;
|
||||
|
|
|
@ -84,7 +84,7 @@ HWTEST_F(BcsTests, givenDebugCapabilityWhenEstimatingCommandSizeThenAddAllRequir
|
|||
EncodeMiFlushDW<FamilyType>::getMiFlushDwCmdSizeForDataWrite() + sizeof(typename FamilyType::MI_BATCH_BUFFER_END);
|
||||
expectedSize = alignUp(expectedSize, MemoryConstants::cacheLineSize);
|
||||
|
||||
BlitProperties blitProperties;
|
||||
BlitProperties blitProperties{};
|
||||
blitProperties.copySize = {bltSize, 1, 1};
|
||||
BlitPropertiesContainer blitPropertiesContainer;
|
||||
blitPropertiesContainer.push_back(blitProperties);
|
||||
|
@ -1443,20 +1443,18 @@ HWTEST_F(BcsTestsImages, givenImage1DWhenAdjustBlitPropertiesForImageIsCalledThe
|
|||
imgDesc.image_height = 0u;
|
||||
imgDesc.image_depth = 0u;
|
||||
std::unique_ptr<Image> image(Image1dHelper<>::create(context.get(), &imgDesc));
|
||||
Vec3<size_t> size{0, 0, 0};
|
||||
size_t bytesPerPixel = 0u;
|
||||
size_t expectedBytesPerPixel = image->getSurfaceFormatInfo().surfaceFormat.ImageElementSizeInBytes;
|
||||
size_t expectedRowPitch = image->getImageDesc().image_row_pitch;
|
||||
size_t expectedSlicePitch = image->getImageDesc().image_slice_pitch;
|
||||
BlitterConstants::BlitDirection blitDirection = BlitterConstants::BlitDirection::HostPtrToImage;
|
||||
BlitProperties blitProperties{};
|
||||
blitProperties.dstGpuAddress = image->getGraphicsAllocation(0)->getGpuAddress();
|
||||
|
||||
uint64_t gpuAddress = image->getGraphicsAllocation(0)->getGpuAddress();
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), size, bytesPerPixel, gpuAddress, rowPitch, slicePitch, blitDirection);
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), blitProperties, rowPitch, slicePitch, false);
|
||||
|
||||
EXPECT_EQ(imgDesc.image_width, size.x);
|
||||
EXPECT_EQ(1u, size.y);
|
||||
EXPECT_EQ(1u, size.z);
|
||||
EXPECT_EQ(expectedBytesPerPixel, bytesPerPixel);
|
||||
EXPECT_EQ(imgDesc.image_width, blitProperties.dstSize.x);
|
||||
EXPECT_EQ(1u, blitProperties.dstSize.y);
|
||||
EXPECT_EQ(1u, blitProperties.dstSize.z);
|
||||
EXPECT_EQ(expectedBytesPerPixel, blitProperties.bytesPerPixel);
|
||||
EXPECT_EQ(expectedRowPitch, rowPitch);
|
||||
EXPECT_EQ(expectedSlicePitch, slicePitch);
|
||||
}
|
||||
|
@ -1469,15 +1467,28 @@ HWTEST_F(BcsTestsImages, givenImage1DBufferWhenAdjustBlitPropertiesForImageIsCal
|
|||
|
||||
cl_image_desc imgDesc = Image1dBufferDefaults::imageDesc;
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
|
||||
std::unique_ptr<Image> image(Image1dHelper<>::create(context.get(), &imgDesc));
|
||||
Vec3<size_t> size{0, 0, 0};
|
||||
size_t bytesPerPixel = 0u;
|
||||
|
||||
uint64_t gpuAddress = image->getGraphicsAllocation(0)->getGpuAddress();
|
||||
cl_image_format imgFormat{};
|
||||
imgFormat.image_channel_order = CL_RGBA;
|
||||
imgFormat.image_channel_data_type = CL_UNSIGNED_INT8;
|
||||
std::unique_ptr<Image> image(Image1dHelper<>::create(context.get(), &imgDesc, &imgFormat));
|
||||
size_t expectedBytesPerPixel = 4;
|
||||
BlitProperties blitProperties{};
|
||||
blitProperties.srcGpuAddress = image->getGraphicsAllocation(0)->getGpuAddress();
|
||||
|
||||
for (auto &[blitDirection, expectedBlitDirection] : testParams) {
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), size, bytesPerPixel, gpuAddress, rowPitch, slicePitch, blitDirection);
|
||||
EXPECT_EQ(expectedBlitDirection, blitDirection);
|
||||
blitProperties.blitDirection = blitDirection;
|
||||
blitProperties.copySize = {1, 1, 1};
|
||||
blitProperties.srcSize = {imgDesc.image_width, imgDesc.image_height, imgDesc.image_depth};
|
||||
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), blitProperties, rowPitch, slicePitch, true);
|
||||
EXPECT_EQ(expectedBlitDirection, blitProperties.blitDirection);
|
||||
EXPECT_EQ(expectedBytesPerPixel, blitProperties.bytesPerPixel);
|
||||
EXPECT_EQ(imgDesc.image_width, blitProperties.srcSize.x / blitProperties.bytesPerPixel);
|
||||
EXPECT_EQ(imgDesc.image_height, blitProperties.srcSize.y);
|
||||
EXPECT_EQ(imgDesc.image_depth, blitProperties.srcSize.z);
|
||||
EXPECT_EQ(1u, blitProperties.copySize.x / blitProperties.bytesPerPixel);
|
||||
EXPECT_EQ(1u, blitProperties.copySize.y);
|
||||
EXPECT_EQ(1u, blitProperties.copySize.z);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1490,20 +1501,18 @@ HWTEST_F(BcsTestsImages, givenImage2DArrayWhenAdjustBlitPropertiesForImageIsCall
|
|||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE2D_ARRAY;
|
||||
|
||||
std::unique_ptr<Image> image(Image2dArrayHelper<>::create(context.get(), &imgDesc));
|
||||
Vec3<size_t> size{0, 0, 0};
|
||||
size_t bytesPerPixel = 0u;
|
||||
size_t expectedBytesPerPixel = image->getSurfaceFormatInfo().surfaceFormat.ImageElementSizeInBytes;
|
||||
size_t expectedRowPitch = image->getImageDesc().image_row_pitch;
|
||||
size_t expectedSlicePitch = image->getImageDesc().image_slice_pitch;
|
||||
BlitterConstants::BlitDirection blitDirection = BlitterConstants::BlitDirection::HostPtrToImage;
|
||||
BlitProperties blitProperties{};
|
||||
blitProperties.dstGpuAddress = image->getGraphicsAllocation(0)->getGpuAddress();
|
||||
|
||||
uint64_t gpuAddress = image->getGraphicsAllocation(0)->getGpuAddress();
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), size, bytesPerPixel, gpuAddress, rowPitch, slicePitch, blitDirection);
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), blitProperties, rowPitch, slicePitch, false);
|
||||
|
||||
EXPECT_EQ(imgDesc.image_width, size.x);
|
||||
EXPECT_EQ(imgDesc.image_height, size.y);
|
||||
EXPECT_EQ(imgDesc.image_array_size, size.z);
|
||||
EXPECT_EQ(expectedBytesPerPixel, bytesPerPixel);
|
||||
EXPECT_EQ(imgDesc.image_width, blitProperties.dstSize.x);
|
||||
EXPECT_EQ(imgDesc.image_height, blitProperties.dstSize.y);
|
||||
EXPECT_EQ(imgDesc.image_array_size, blitProperties.dstSize.z);
|
||||
EXPECT_EQ(expectedBytesPerPixel, blitProperties.bytesPerPixel);
|
||||
EXPECT_EQ(expectedRowPitch, rowPitch);
|
||||
EXPECT_EQ(expectedSlicePitch, slicePitch);
|
||||
}
|
||||
|
@ -1511,18 +1520,16 @@ HWTEST_F(BcsTestsImages, givenImage2DArrayWhenAdjustBlitPropertiesForImageIsCall
|
|||
HWTEST_F(BcsTestsImages, givenImageWithSurfaceOffsetWhenAdjustBlitPropertiesForImageIsCalledThenGpuAddressIsCorrect) {
|
||||
cl_image_desc imgDesc = Image1dDefaults::imageDesc;
|
||||
std::unique_ptr<Image> image(Image2dArrayHelper<>::create(context.get(), &imgDesc));
|
||||
Vec3<size_t> size{0, 0, 0};
|
||||
size_t bytesPerPixel = 0u;
|
||||
BlitterConstants::BlitDirection blitDirection = BlitterConstants::BlitDirection::HostPtrToImage;
|
||||
|
||||
uint64_t surfaceOffset = 0x01000;
|
||||
image->setSurfaceOffsets(surfaceOffset, 0, 0, 0);
|
||||
uint64_t gpuAddress = image->getGraphicsAllocation(0)->getGpuAddress();
|
||||
uint64_t expectedGpuAddress = gpuAddress + surfaceOffset;
|
||||
BlitProperties blitProperties{};
|
||||
blitProperties.dstGpuAddress = image->getGraphicsAllocation(0)->getGpuAddress();
|
||||
uint64_t expectedGpuAddress = blitProperties.dstGpuAddress + surfaceOffset;
|
||||
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), size, bytesPerPixel, gpuAddress, rowPitch, slicePitch, blitDirection);
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), blitProperties, rowPitch, slicePitch, false);
|
||||
|
||||
EXPECT_EQ(gpuAddress, expectedGpuAddress);
|
||||
EXPECT_EQ(blitProperties.dstGpuAddress, expectedGpuAddress);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTests, givenHostPtrToImageWhenConstructPropertiesIsCalledThenValuesAreSetCorrectly) {
|
||||
|
|
Loading…
Reference in New Issue