mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-21 09:14:47 +08:00
fix: correct blit properties for CL_MEM_OBJECT_IMAGE1D_BUFFER images
Resolves: NEO-13984, HSD-18041422852 Signed-off-by: Venevtsev, Igor <igor.venevtsev@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
db99c25c79
commit
edec1ac3fb
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020-2023 Intel Corporation
|
||||
* Copyright (C) 2020-2025 Intel Corporation
|
||||
*
|
||||
* SPDX-License-Identifier: MIT
|
||||
*
|
||||
@@ -169,72 +169,80 @@ struct ClBlitProperties {
|
||||
}
|
||||
}
|
||||
|
||||
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 imageWidth = imageDesc.image_width;
|
||||
auto imageHeight = imageDesc.image_height;
|
||||
auto imageDepth = imageDesc.image_depth;
|
||||
|
||||
if (imageDesc.image_type == CL_MEM_OBJECT_IMAGE2D_ARRAY) {
|
||||
imageDepth = std::max(imageDepth, imageDesc.image_array_size);
|
||||
}
|
||||
|
||||
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;
|
||||
auto &plane = isSource ? blitProperties.srcPlane : blitProperties.dstPlane;
|
||||
|
||||
image->getSurfaceOffsets(surfaceOffsets);
|
||||
gpuAddress += surfaceOffsets.offset;
|
||||
size.x = imageWidth;
|
||||
size.y = imageHeight ? imageHeight : 1;
|
||||
size.z = imageDepth ? imageDepth : 1;
|
||||
bytesPerPixel = image->getSurfaceFormatInfo().surfaceFormat.imageElementSizeInBytes;
|
||||
rowPitch = imageDesc.image_row_pitch;
|
||||
slicePitch = imageDesc.image_slice_pitch;
|
||||
plane = image->getPlane();
|
||||
|
||||
if (imageDesc.image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER) {
|
||||
if (blitDirection == BlitterConstants::BlitDirection::hostPtrToImage) {
|
||||
blitDirection = BlitterConstants::BlitDirection::hostPtrToBuffer;
|
||||
}
|
||||
if (blitDirection == BlitterConstants::BlitDirection::imageToHostPtr) {
|
||||
blitDirection = BlitterConstants::BlitDirection::bufferToHostPtr;
|
||||
}
|
||||
if (blitDirection == BlitterConstants::BlitDirection::imageToImage) {
|
||||
blitDirection = BlitterConstants::BlitDirection::bufferToBuffer;
|
||||
}
|
||||
|
||||
size.x *= bytesPerPixel;
|
||||
copySize.x *= bytesPerPixel;
|
||||
bytesPerPixel = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void setBlitPropertiesForImage(BlitProperties &blitProperties, const BuiltinOpParams &builtinOpParams) {
|
||||
size_t srcRowPitch = builtinOpParams.srcRowPitch;
|
||||
size_t dstRowPitch = builtinOpParams.dstRowPitch;
|
||||
size_t srcSlicePitch = builtinOpParams.srcSlicePitch;
|
||||
size_t dstSlicePitch = builtinOpParams.dstSlicePitch;
|
||||
DEBUG_BREAK_IF(!blitProperties.isImageOperation());
|
||||
|
||||
if (blitProperties.blitDirection == BlitterConstants::BlitDirection::imageToHostPtr ||
|
||||
blitProperties.blitDirection == BlitterConstants::BlitDirection::imageToImage) {
|
||||
adjustBlitPropertiesForImage(builtinOpParams.srcMemObj, blitProperties, srcRowPitch, srcSlicePitch, true);
|
||||
auto srcImage = castToObject<Image>(builtinOpParams.srcMemObj);
|
||||
auto dstImage = castToObject<Image>(builtinOpParams.dstMemObj);
|
||||
|
||||
bool src1DBuffer = false, dst1DBuffer = false;
|
||||
|
||||
if (srcImage) {
|
||||
const auto &imageDesc = srcImage->getImageDesc();
|
||||
blitProperties.srcSize.x = imageDesc.image_width;
|
||||
blitProperties.srcSize.y = std::max(imageDesc.image_height, size_t(1));
|
||||
blitProperties.srcSize.z = std::max(imageDesc.image_depth, size_t(1));
|
||||
if (imageDesc.image_type == CL_MEM_OBJECT_IMAGE2D_ARRAY) {
|
||||
blitProperties.srcSize.z = std::max(blitProperties.srcSize.z, imageDesc.image_array_size);
|
||||
}
|
||||
blitProperties.srcRowPitch = imageDesc.image_row_pitch;
|
||||
blitProperties.srcSlicePitch = imageDesc.image_slice_pitch;
|
||||
blitProperties.srcPlane = srcImage->getPlane();
|
||||
SurfaceOffsets surfaceOffsets;
|
||||
srcImage->getSurfaceOffsets(surfaceOffsets);
|
||||
blitProperties.srcGpuAddress += surfaceOffsets.offset;
|
||||
blitProperties.bytesPerPixel = srcImage->getSurfaceFormatInfo().surfaceFormat.imageElementSizeInBytes;
|
||||
if (imageDesc.image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER) {
|
||||
src1DBuffer = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (blitProperties.blitDirection == BlitterConstants::BlitDirection::hostPtrToImage ||
|
||||
blitProperties.blitDirection == BlitterConstants::BlitDirection::imageToImage) {
|
||||
adjustBlitPropertiesForImage(builtinOpParams.dstMemObj, blitProperties, dstRowPitch, dstSlicePitch, false);
|
||||
if (dstImage) {
|
||||
const auto &imageDesc = dstImage->getImageDesc();
|
||||
blitProperties.dstSize.x = imageDesc.image_width;
|
||||
blitProperties.dstSize.y = std::max(imageDesc.image_height, size_t(1));
|
||||
blitProperties.dstSize.z = std::max(imageDesc.image_depth, size_t(1));
|
||||
if (imageDesc.image_type == CL_MEM_OBJECT_IMAGE2D_ARRAY) {
|
||||
blitProperties.dstSize.z = std::max(blitProperties.dstSize.z, imageDesc.image_array_size);
|
||||
}
|
||||
blitProperties.dstRowPitch = imageDesc.image_row_pitch;
|
||||
blitProperties.dstSlicePitch = imageDesc.image_slice_pitch;
|
||||
blitProperties.dstPlane = dstImage->getPlane();
|
||||
SurfaceOffsets surfaceOffsets;
|
||||
dstImage->getSurfaceOffsets(surfaceOffsets);
|
||||
blitProperties.dstGpuAddress += surfaceOffsets.offset;
|
||||
blitProperties.bytesPerPixel = dstImage->getSurfaceFormatInfo().surfaceFormat.imageElementSizeInBytes;
|
||||
if (imageDesc.image_type == CL_MEM_OBJECT_IMAGE1D_BUFFER) {
|
||||
dst1DBuffer = true;
|
||||
}
|
||||
}
|
||||
|
||||
blitProperties.srcRowPitch = srcRowPitch ? srcRowPitch : blitProperties.srcSize.x * blitProperties.bytesPerPixel;
|
||||
blitProperties.dstRowPitch = dstRowPitch ? dstRowPitch : blitProperties.dstSize.x * blitProperties.bytesPerPixel;
|
||||
blitProperties.srcSlicePitch = srcSlicePitch ? srcSlicePitch : blitProperties.srcSize.y * blitProperties.srcRowPitch;
|
||||
blitProperties.dstSlicePitch = dstSlicePitch ? dstSlicePitch : blitProperties.dstSize.y * blitProperties.dstRowPitch;
|
||||
if (src1DBuffer && dst1DBuffer) {
|
||||
blitProperties.srcSize.x *= blitProperties.bytesPerPixel;
|
||||
blitProperties.dstSize.x *= blitProperties.bytesPerPixel;
|
||||
blitProperties.srcOffset.x *= blitProperties.bytesPerPixel;
|
||||
blitProperties.dstOffset.x *= blitProperties.bytesPerPixel;
|
||||
blitProperties.copySize.x *= blitProperties.bytesPerPixel;
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::bufferToBuffer;
|
||||
blitProperties.bytesPerPixel = 1;
|
||||
} else if (src1DBuffer) {
|
||||
blitProperties.srcSize.x *= blitProperties.bytesPerPixel;
|
||||
blitProperties.srcOffset.x *= blitProperties.bytesPerPixel;
|
||||
blitProperties.copySize.x *= blitProperties.bytesPerPixel;
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::bufferToHostPtr;
|
||||
blitProperties.bytesPerPixel = 1;
|
||||
} else if (dst1DBuffer) {
|
||||
blitProperties.dstSize.x *= blitProperties.bytesPerPixel;
|
||||
blitProperties.dstOffset.x *= blitProperties.bytesPerPixel;
|
||||
blitProperties.copySize.x *= blitProperties.bytesPerPixel;
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::hostPtrToBuffer;
|
||||
blitProperties.bytesPerPixel = 1;
|
||||
}
|
||||
|
||||
blitProperties.srcRowPitch = blitProperties.srcRowPitch ? blitProperties.srcRowPitch : blitProperties.srcSize.x * blitProperties.bytesPerPixel;
|
||||
blitProperties.dstRowPitch = blitProperties.dstRowPitch ? blitProperties.dstRowPitch : blitProperties.dstSize.x * blitProperties.bytesPerPixel;
|
||||
blitProperties.srcSlicePitch = blitProperties.srcSlicePitch ? blitProperties.srcSlicePitch : blitProperties.srcRowPitch * blitProperties.srcSize.y;
|
||||
blitProperties.dstSlicePitch = blitProperties.dstSlicePitch ? blitProperties.dstSlicePitch : blitProperties.dstRowPitch * blitProperties.dstSize.y;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -1839,7 +1839,7 @@ struct BcsTestsImages : public BcsTests {
|
||||
size_t slicePitch = 0;
|
||||
};
|
||||
|
||||
HWTEST_F(BcsTestsImages, givenImage1DWhenAdjustBlitPropertiesForImageIsCalledThenValuesAreSetCorrectly) {
|
||||
HWTEST_F(BcsTestsImages, givenImage1DWhenSetBlitPropertiesForImageIsCalledThenValuesAreSetCorrectly) {
|
||||
cl_image_desc imgDesc = Image1dDefaults::imageDesc;
|
||||
imgDesc.image_width = 10u;
|
||||
imgDesc.image_height = 0u;
|
||||
@@ -1848,25 +1848,40 @@ HWTEST_F(BcsTestsImages, givenImage1DWhenAdjustBlitPropertiesForImageIsCalledThe
|
||||
size_t expectedBytesPerPixel = image->getSurfaceFormatInfo().surfaceFormat.imageElementSizeInBytes;
|
||||
size_t expectedRowPitch = image->getImageDesc().image_row_pitch;
|
||||
size_t expectedSlicePitch = image->getImageDesc().image_slice_pitch;
|
||||
BlitProperties blitProperties{};
|
||||
blitProperties.dstGpuAddress = image->getGraphicsAllocation(0)->getGpuAddress();
|
||||
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), blitProperties, rowPitch, slicePitch, false);
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.srcMemObj = image.get();
|
||||
|
||||
BlitProperties blitProperties{};
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::imageToHostPtr;
|
||||
ClBlitProperties::setBlitPropertiesForImage(blitProperties, builtinOpParams);
|
||||
|
||||
EXPECT_EQ(imgDesc.image_width, blitProperties.srcSize.x);
|
||||
EXPECT_EQ(1u, blitProperties.srcSize.y);
|
||||
EXPECT_EQ(1u, blitProperties.srcSize.z);
|
||||
EXPECT_EQ(expectedBytesPerPixel, blitProperties.bytesPerPixel);
|
||||
EXPECT_EQ(expectedRowPitch, blitProperties.srcRowPitch);
|
||||
EXPECT_EQ(expectedSlicePitch, blitProperties.srcSlicePitch);
|
||||
|
||||
EXPECT_EQ(0u, blitProperties.dstSize.x);
|
||||
EXPECT_EQ(0u, blitProperties.dstSize.y);
|
||||
EXPECT_EQ(0u, blitProperties.dstSize.z);
|
||||
EXPECT_EQ(0u, blitProperties.dstRowPitch);
|
||||
EXPECT_EQ(0u, blitProperties.dstSlicePitch);
|
||||
|
||||
builtinOpParams.dstMemObj = image.get();
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::hostPtrToImage;
|
||||
ClBlitProperties::setBlitPropertiesForImage(blitProperties, builtinOpParams);
|
||||
|
||||
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);
|
||||
EXPECT_EQ(expectedRowPitch, blitProperties.dstRowPitch);
|
||||
EXPECT_EQ(expectedSlicePitch, blitProperties.dstSlicePitch);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTestsImages, givenImage1DBufferWhenAdjustBlitPropertiesForImageIsCalledThenValuesAreSetCorrectly) {
|
||||
using BlitterConstants::BlitDirection;
|
||||
std::array<std::pair<BlitDirection, BlitDirection>, 3> testParams = {{{BlitDirection::hostPtrToImage, BlitDirection::hostPtrToBuffer},
|
||||
{BlitDirection::imageToHostPtr, BlitDirection::bufferToHostPtr},
|
||||
{BlitDirection::imageToImage, BlitDirection::bufferToBuffer}}};
|
||||
|
||||
HWTEST_F(BcsTestsImages, givenImage1DBufferWhenSetBlitPropertiesForImageIsCalledThenValuesAreSetCorrectly) {
|
||||
cl_image_desc imgDesc = Image1dBufferDefaults::imageDesc;
|
||||
imgDesc.image_type = CL_MEM_OBJECT_IMAGE1D_BUFFER;
|
||||
cl_image_format imgFormat{};
|
||||
@@ -1874,29 +1889,61 @@ HWTEST_F(BcsTestsImages, givenImage1DBufferWhenAdjustBlitPropertiesForImageIsCal
|
||||
imgFormat.image_channel_data_type = CL_UNSIGNED_INT8;
|
||||
std::unique_ptr<Image> image(Image1dHelper<>::create(context.get(), &imgDesc, &imgFormat));
|
||||
size_t originalBytesPerPixel = image->getSurfaceFormatInfo().surfaceFormat.imageElementSizeInBytes;
|
||||
size_t expectedBytesPerPixel = 1;
|
||||
BlitProperties blitProperties{};
|
||||
blitProperties.srcGpuAddress = image->getGraphicsAllocation(0)->getGpuAddress();
|
||||
|
||||
for (auto &[blitDirection, expectedBlitDirection] : testParams) {
|
||||
blitProperties.blitDirection = blitDirection;
|
||||
blitProperties.copySize = {1, 1, 1};
|
||||
blitProperties.srcSize = {imgDesc.image_width, imgDesc.image_height, imgDesc.image_depth};
|
||||
BlitProperties initBlitProperties{};
|
||||
initBlitProperties.srcSize = {imgDesc.image_width, imgDesc.image_height, imgDesc.image_depth};
|
||||
initBlitProperties.dstSize = {imgDesc.image_width, imgDesc.image_height, imgDesc.image_depth};
|
||||
initBlitProperties.srcOffset = {2, 0, 0};
|
||||
initBlitProperties.dstOffset = {5, 0, 0};
|
||||
initBlitProperties.copySize = {1, 0, 0};
|
||||
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), blitProperties, rowPitch, slicePitch, true);
|
||||
// imageToHostPtr
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.srcMemObj = image.get();
|
||||
auto blitProperties = initBlitProperties;
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::imageToHostPtr;
|
||||
ClBlitProperties::setBlitPropertiesForImage(blitProperties, builtinOpParams);
|
||||
|
||||
EXPECT_EQ(expectedBlitDirection, blitProperties.blitDirection);
|
||||
EXPECT_EQ(expectedBytesPerPixel, blitProperties.bytesPerPixel);
|
||||
EXPECT_EQ(imgDesc.image_width, blitProperties.srcSize.x / originalBytesPerPixel);
|
||||
EXPECT_EQ(imgDesc.image_height, blitProperties.srcSize.y);
|
||||
EXPECT_EQ(imgDesc.image_depth, blitProperties.srcSize.z);
|
||||
EXPECT_EQ(1u, blitProperties.copySize.x / originalBytesPerPixel);
|
||||
EXPECT_EQ(1u, blitProperties.copySize.y);
|
||||
EXPECT_EQ(1u, blitProperties.copySize.z);
|
||||
}
|
||||
EXPECT_EQ(blitProperties.srcSize.x, initBlitProperties.srcSize.x * originalBytesPerPixel);
|
||||
EXPECT_EQ(blitProperties.dstSize.x, initBlitProperties.dstSize.x);
|
||||
EXPECT_EQ(blitProperties.srcOffset.x, initBlitProperties.srcOffset.x * originalBytesPerPixel);
|
||||
EXPECT_EQ(blitProperties.dstOffset.x, initBlitProperties.dstOffset.x);
|
||||
EXPECT_EQ(blitProperties.copySize.x, initBlitProperties.copySize.x * originalBytesPerPixel);
|
||||
EXPECT_EQ(blitProperties.blitDirection, BlitterConstants::BlitDirection::bufferToHostPtr);
|
||||
EXPECT_EQ(blitProperties.bytesPerPixel, 1u);
|
||||
|
||||
// hostPtrToImage
|
||||
builtinOpParams.srcMemObj = nullptr;
|
||||
builtinOpParams.dstMemObj = image.get();
|
||||
blitProperties = initBlitProperties;
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::hostPtrToImage;
|
||||
ClBlitProperties::setBlitPropertiesForImage(blitProperties, builtinOpParams);
|
||||
|
||||
EXPECT_EQ(blitProperties.srcSize.x, initBlitProperties.srcSize.x);
|
||||
EXPECT_EQ(blitProperties.dstSize.x, initBlitProperties.dstSize.x * originalBytesPerPixel);
|
||||
EXPECT_EQ(blitProperties.srcOffset.x, initBlitProperties.srcOffset.x);
|
||||
EXPECT_EQ(blitProperties.dstOffset.x, initBlitProperties.dstOffset.x * originalBytesPerPixel);
|
||||
EXPECT_EQ(blitProperties.copySize.x, initBlitProperties.copySize.x * originalBytesPerPixel);
|
||||
EXPECT_EQ(blitProperties.blitDirection, BlitterConstants::BlitDirection::hostPtrToBuffer);
|
||||
EXPECT_EQ(blitProperties.bytesPerPixel, 1u);
|
||||
|
||||
// imageToImage
|
||||
builtinOpParams.srcMemObj = image.get();
|
||||
builtinOpParams.dstMemObj = image.get();
|
||||
blitProperties = initBlitProperties;
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::imageToImage;
|
||||
ClBlitProperties::setBlitPropertiesForImage(blitProperties, builtinOpParams);
|
||||
|
||||
EXPECT_EQ(blitProperties.srcSize.x, initBlitProperties.srcSize.x * originalBytesPerPixel);
|
||||
EXPECT_EQ(blitProperties.dstSize.x, initBlitProperties.dstSize.x * originalBytesPerPixel);
|
||||
EXPECT_EQ(blitProperties.srcOffset.x, initBlitProperties.srcOffset.x * originalBytesPerPixel);
|
||||
EXPECT_EQ(blitProperties.dstOffset.x, initBlitProperties.dstOffset.x * originalBytesPerPixel);
|
||||
EXPECT_EQ(blitProperties.copySize.x, initBlitProperties.copySize.x * originalBytesPerPixel);
|
||||
EXPECT_EQ(blitProperties.blitDirection, BlitterConstants::BlitDirection::bufferToBuffer);
|
||||
EXPECT_EQ(blitProperties.bytesPerPixel, 1u);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTestsImages, givenImage2DArrayWhenAdjustBlitPropertiesForImageIsCalledThenValuesAreSetCorrectly) {
|
||||
HWTEST_F(BcsTestsImages, givenImage2DArrayWhenSetBlitPropertiesForImageIsCalledThenValuesAreSetCorrectly) {
|
||||
cl_image_desc imgDesc = Image1dDefaults::imageDesc;
|
||||
imgDesc.image_width = 10u;
|
||||
imgDesc.image_height = 3u;
|
||||
@@ -1908,32 +1955,43 @@ HWTEST_F(BcsTestsImages, givenImage2DArrayWhenAdjustBlitPropertiesForImageIsCall
|
||||
size_t expectedBytesPerPixel = image->getSurfaceFormatInfo().surfaceFormat.imageElementSizeInBytes;
|
||||
size_t expectedRowPitch = image->getImageDesc().image_row_pitch;
|
||||
size_t expectedSlicePitch = image->getImageDesc().image_slice_pitch;
|
||||
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.srcMemObj = image.get();
|
||||
builtinOpParams.dstMemObj = image.get();
|
||||
|
||||
BlitProperties blitProperties{};
|
||||
blitProperties.dstGpuAddress = image->getGraphicsAllocation(0)->getGpuAddress();
|
||||
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), blitProperties, rowPitch, slicePitch, false);
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::imageToImage;
|
||||
ClBlitProperties::setBlitPropertiesForImage(blitProperties, builtinOpParams);
|
||||
|
||||
EXPECT_EQ(imgDesc.image_width, blitProperties.srcSize.x);
|
||||
EXPECT_EQ(imgDesc.image_height, blitProperties.srcSize.y);
|
||||
EXPECT_EQ(imgDesc.image_array_size, blitProperties.srcSize.z);
|
||||
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);
|
||||
EXPECT_EQ(expectedRowPitch, blitProperties.srcRowPitch);
|
||||
EXPECT_EQ(expectedSlicePitch, blitProperties.srcSlicePitch);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTestsImages, givenImageWithSurfaceOffsetWhenAdjustBlitPropertiesForImageIsCalledThenGpuAddressIsCorrect) {
|
||||
HWTEST_F(BcsTestsImages, givenImageWithSurfaceOffsetWhenSetBlitPropertiesForImageIsCalledThenGpuAddressIsCorrect) {
|
||||
cl_image_desc imgDesc = Image1dDefaults::imageDesc;
|
||||
std::unique_ptr<Image> image(Image2dArrayHelper<>::create(context.get(), &imgDesc));
|
||||
|
||||
uint64_t surfaceOffset = 0x01000;
|
||||
image->setSurfaceOffsets(surfaceOffset, 0, 0, 0);
|
||||
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.srcMemObj = image.get();
|
||||
|
||||
BlitProperties blitProperties{};
|
||||
blitProperties.dstGpuAddress = image->getGraphicsAllocation(0)->getGpuAddress();
|
||||
uint64_t expectedGpuAddress = blitProperties.dstGpuAddress + surfaceOffset;
|
||||
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), blitProperties, rowPitch, slicePitch, false);
|
||||
|
||||
EXPECT_EQ(blitProperties.dstGpuAddress, expectedGpuAddress);
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::imageToHostPtr;
|
||||
blitProperties.srcGpuAddress = image->getGraphicsAllocation(0)->getGpuAddress();
|
||||
uint64_t expectedGpuAddress = blitProperties.srcGpuAddress + surfaceOffset;
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::imageToHostPtr;
|
||||
ClBlitProperties::setBlitPropertiesForImage(blitProperties, builtinOpParams);
|
||||
EXPECT_EQ(expectedGpuAddress, blitProperties.srcGpuAddress);
|
||||
}
|
||||
|
||||
HWTEST_F(BcsTestsImages, givenImageWithPlaneSetWhenAdjustBlitPropertiesForImageIsCalledThenPlaneIsCorrect) {
|
||||
@@ -1941,22 +1999,30 @@ HWTEST_F(BcsTestsImages, givenImageWithPlaneSetWhenAdjustBlitPropertiesForImageI
|
||||
std::unique_ptr<Image> image(Image2dArrayHelper<>::create(context.get(), &imgDesc));
|
||||
|
||||
BlitProperties blitProperties{};
|
||||
|
||||
EXPECT_EQ(GMM_YUV_PLANE_ENUM::GMM_NO_PLANE, blitProperties.dstPlane);
|
||||
EXPECT_EQ(GMM_YUV_PLANE_ENUM::GMM_NO_PLANE, blitProperties.srcPlane);
|
||||
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), blitProperties, rowPitch, slicePitch, false);
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), blitProperties, rowPitch, slicePitch, true);
|
||||
BuiltinOpParams builtinOpParams{};
|
||||
builtinOpParams.srcMemObj = image.get();
|
||||
builtinOpParams.dstMemObj = image.get();
|
||||
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::imageToImage;
|
||||
ClBlitProperties::setBlitPropertiesForImage(blitProperties, builtinOpParams);
|
||||
EXPECT_EQ(GMM_YUV_PLANE_ENUM::GMM_NO_PLANE, blitProperties.dstPlane);
|
||||
EXPECT_EQ(GMM_YUV_PLANE_ENUM::GMM_NO_PLANE, blitProperties.srcPlane);
|
||||
|
||||
image->setPlane(GMM_YUV_PLANE_ENUM::GMM_PLANE_Y);
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), blitProperties, rowPitch, slicePitch, false);
|
||||
builtinOpParams.srcMemObj = nullptr;
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::hostPtrToImage;
|
||||
ClBlitProperties::setBlitPropertiesForImage(blitProperties, builtinOpParams);
|
||||
EXPECT_EQ(GMM_YUV_PLANE_ENUM::GMM_PLANE_Y, blitProperties.dstPlane);
|
||||
EXPECT_EQ(GMM_YUV_PLANE_ENUM::GMM_NO_PLANE, blitProperties.srcPlane);
|
||||
|
||||
image->setPlane(GMM_YUV_PLANE_ENUM::GMM_PLANE_U);
|
||||
ClBlitProperties::adjustBlitPropertiesForImage(image.get(), blitProperties, rowPitch, slicePitch, true);
|
||||
builtinOpParams.srcMemObj = image.get();
|
||||
builtinOpParams.dstMemObj = nullptr;
|
||||
blitProperties.blitDirection = BlitterConstants::BlitDirection::imageToHostPtr;
|
||||
ClBlitProperties::setBlitPropertiesForImage(blitProperties, builtinOpParams);
|
||||
EXPECT_EQ(GMM_YUV_PLANE_ENUM::GMM_PLANE_Y, blitProperties.dstPlane);
|
||||
EXPECT_EQ(GMM_YUV_PLANE_ENUM::GMM_PLANE_U, blitProperties.srcPlane);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user