Add blitter support for read/write image OpenCL

Change-Id: I5d8bf0590899751f1f562fd55e44b0ed36ca6110
Signed-off-by: Kamil Kopryk <kamil.kopryk@intel.com>
Related-To: NEO-4692
This commit is contained in:
Kamil Kopryk
2020-09-28 17:52:36 +02:00
committed by sys_ocldev
parent 4623cb3f85
commit cc6d6968dd
16 changed files with 525 additions and 346 deletions

View File

@@ -85,86 +85,44 @@ void BlitCommandsHelper<Family>::appendColorDepth(const BlitProperties &blitProp
}
template <>
void BlitCommandsHelper<Family>::appendTilingType(const GMM_TILE_TYPE srcTilingType, const GMM_TILE_TYPE dstTilingType, typename Family::XY_COPY_BLT &blitCmd) {
using XY_COPY_BLT = typename Family::XY_COPY_BLT;
if (srcTilingType == GMM_TILED_Y) {
blitCmd.setSourceTiling(XY_COPY_BLT::SOURCE_TILING::SOURCE_TILING_YMAJOR);
}
if (dstTilingType == GMM_TILED_Y) {
blitCmd.setDestinationTiling(XY_COPY_BLT::DESTINATION_TILING::DESTINATION_TILING_YMAJOR);
}
}
template <>
void BlitCommandsHelper<Family>::appendSurfaceType(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd) {
}
template <>
void BlitCommandsHelper<Family>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod) {
constexpr uint32_t TILED_Y_PITCH_ALIGNMENT = 128;
constexpr uint32_t NON_TILED_PITCH_ALIGNMENT = 16;
void BlitCommandsHelper<Family>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment) {
if (allocation.getDefaultGmm()) {
auto gmmResInfo = allocation.getDefaultGmm()->gmmResourceInfo.get();
auto resInfo = gmmResInfo->getResourceFlags()->Info;
if (resInfo.TiledY) {
tileType = GMM_TILED_Y;
pitch = static_cast<uint32_t>(gmmResInfo->getRenderPitch());
pitch = alignUp<uint32_t>(pitch, TILED_Y_PITCH_ALIGNMENT);
qPitch = static_cast<uint32_t>(gmmResInfo->getQPitch());
} else {
pitch = alignUp<uint32_t>(pitch, NON_TILED_PITCH_ALIGNMENT);
}
auto gmmResourceInfo = allocation.getDefaultGmm()->gmmResourceInfo.get();
qPitch = gmmResourceInfo->getQPitch() ? static_cast<uint32_t>(gmmResourceInfo->getQPitch()) : qPitch;
pitch = gmmResourceInfo->getRenderPitch() ? static_cast<uint32_t>(gmmResourceInfo->getRenderPitch()) : pitch;
}
}
template <>
void BlitCommandsHelper<Family>::appendSliceOffsets(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, uint32_t sliceIndex) {
void BlitCommandsHelper<Family>::appendSliceOffsets(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, uint32_t sliceIndex, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t srcSlicePitch, uint32_t dstSlicePitch) {
using XY_COPY_BLT = typename Family::XY_COPY_BLT;
auto srcAllocation = blitProperties.srcAllocation;
auto dstAllocation = blitProperties.dstAllocation;
auto srcQPitch = blitProperties.srcSize.y;
auto dstQPitch = blitProperties.dstSize.y;
auto srcPitch = static_cast<uint32_t>(blitProperties.srcRowPitch);
auto dstPitch = static_cast<uint32_t>(blitProperties.dstRowPitch);
auto tileType = GMM_NOT_TILED;
uint32_t mipTailLod = 0;
auto srcAddress = blitProperties.srcGpuAddress;
auto dstAddress = blitProperties.dstGpuAddress;
getBlitAllocationProperties(*srcAllocation, srcPitch, srcQPitch, tileType, mipTailLod);
getBlitAllocationProperties(*dstAllocation, dstPitch, dstQPitch, tileType, mipTailLod);
auto srcSlicePitch = srcPitch * srcQPitch;
auto dstSlicePitch = dstPitch * dstQPitch;
size_t srcOffset = srcSlicePitch * (sliceIndex + blitProperties.srcOffset.z);
size_t dstOffset = dstSlicePitch * (sliceIndex + blitProperties.dstOffset.z);
blitCmd.setSourceBaseAddress(ptrOffset(srcAllocation->getGpuAddress(), srcOffset));
blitCmd.setDestinationBaseAddress(ptrOffset(dstAllocation->getGpuAddress(), dstOffset));
blitCmd.setSourceBaseAddress(ptrOffset(srcAddress, srcSlicePitch * (sliceIndex + blitProperties.srcOffset.z)));
blitCmd.setDestinationBaseAddress(ptrOffset(dstAddress, dstSlicePitch * (sliceIndex + blitProperties.dstOffset.z)));
}
template <>
void BlitCommandsHelper<Family>::appendBlitCommandsForImages(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd) {
auto srcTileType = GMM_NOT_TILED;
auto dstTileType = GMM_NOT_TILED;
void BlitCommandsHelper<Family>::appendBlitCommandsForImages(const BlitProperties &blitProperties, typename Family::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t &srcSlicePitch, uint32_t &dstSlicePitch) {
auto tileType = GMM_NOT_TILED;
auto srcAllocation = blitProperties.srcAllocation;
auto dstAllocation = blitProperties.dstAllocation;
auto srcQPitch = blitProperties.srcSize.y;
auto dstQPitch = blitProperties.dstSize.y;
auto srcPitch = static_cast<uint32_t>(blitProperties.srcRowPitch);
auto dstPitch = static_cast<uint32_t>(blitProperties.dstRowPitch);
auto srcRowPitch = static_cast<uint32_t>(blitProperties.srcRowPitch);
auto dstRowPitch = static_cast<uint32_t>(blitProperties.dstRowPitch);
uint32_t mipTailLod = 0;
auto compressionDetails = 0u;
getBlitAllocationProperties(*srcAllocation, srcPitch, srcQPitch, srcTileType, mipTailLod);
getBlitAllocationProperties(*dstAllocation, dstPitch, dstQPitch, dstTileType, mipTailLod);
getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, tileType, mipTailLod, compressionDetails, rootDeviceEnvironment);
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, tileType, mipTailLod, compressionDetails, rootDeviceEnvironment);
srcPitch = (srcTileType == GMM_NOT_TILED) ? srcPitch : srcPitch / 4;
dstPitch = (dstTileType == GMM_NOT_TILED) ? dstPitch : dstPitch / 4;
blitCmd.setSourcePitch(srcRowPitch);
blitCmd.setDestinationPitch(dstRowPitch);
blitCmd.setSourcePitch(srcPitch);
blitCmd.setDestinationPitch(dstPitch);
appendTilingType(srcTileType, dstTileType, blitCmd);
srcSlicePitch = std::max(srcSlicePitch, srcRowPitch * srcQPitch);
dstSlicePitch = std::max(dstSlicePitch, dstRowPitch * dstQPitch);
}
template <>

View File

@@ -41,7 +41,8 @@ BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer(BlitterCons
copySize.y = copySize.y ? copySize.y : 1;
copySize.z = copySize.z ? copySize.z : 1;
if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection) {
if (BlitterConstants::BlitDirection::HostPtrToBuffer == blitDirection ||
BlitterConstants::BlitDirection::HostPtrToImage == blitDirection) {
return {
nullptr, // outputTimestampPacket
blitDirection, // blitDirection
@@ -54,10 +55,10 @@ BlitProperties BlitProperties::constructPropertiesForReadWriteBuffer(BlitterCons
copySize, // copySize
copyOffset, // dstOffset
hostPtrOffset, // srcOffset
gpuRowPitch, //dstRowPitch
gpuSlicePitch, //dstSlicePitch
hostRowPitch, //srcRowPitch
hostSlicePitch}; //srcSlicePitch
gpuRowPitch, // dstRowPitch
gpuSlicePitch, // dstSlicePitch
hostRowPitch, // srcRowPitch
hostSlicePitch}; // srcSlicePitch
} else {
return {

View File

@@ -129,14 +129,14 @@ struct BlitCommandsHelper {
template <size_t patternSize>
static void dispatchBlitMemoryFill(NEO::GraphicsAllocation *dstAlloc, uint32_t *pattern, LinearStream &linearStream, size_t size, const RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth);
static void appendBlitCommandsForBuffer(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment);
static void appendBlitCommandsForImages(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd);
static void appendBlitCommandsForImages(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t &srcSlicePitch, uint32_t &dstSlicePitch);
static void appendColorDepth(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd);
static void appendBlitCommandsForFillBuffer(NEO::GraphicsAllocation *dstAlloc, typename GfxFamily::XY_COLOR_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment);
static void appendSurfaceType(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd);
static void appendTilingEnable(typename GfxFamily::XY_COLOR_BLT &blitCmd);
static void appendTilingType(const GMM_TILE_TYPE srcTilingType, const GMM_TILE_TYPE dstTilingType, typename GfxFamily::XY_COPY_BLT &blitCmd);
static void appendSliceOffsets(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, uint32_t sliceIndex);
static void getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod);
static void appendSliceOffsets(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, uint32_t sliceIndex, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t srcSlicePitch, uint32_t dstSlicePitch);
static void getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment);
static void dispatchDebugPauseCommands(LinearStream &commandStream, uint64_t debugPauseStateGPUAddress, DebugPauseState confirmationTrigger, DebugPauseState waitCondition);
static size_t getSizeForDebugPauseCommands();
static bool useOneBlitCopyCommand(Vec3<size_t> copySize, uint32_t bytesPerPixel);

View File

@@ -217,14 +217,14 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(NEO::GraphicsAllocati
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsRegion(const BlitProperties &blitProperties, LinearStream &linearStream, const RootDeviceEnvironment &rootDeviceEnvironment) {
auto dstAllocation = blitProperties.dstAllocation;
auto srcAllocation = blitProperties.srcAllocation;
auto srcSlicePitch = static_cast<uint32_t>(blitProperties.srcSlicePitch);
auto dstSlicePitch = static_cast<uint32_t>(blitProperties.dstSlicePitch);
UNRECOVERABLE_IF(blitProperties.copySize.x > BlitterConstants::maxBlitWidth || blitProperties.copySize.y > BlitterConstants::maxBlitWidth);
auto bltCmd = GfxFamily::cmdInitXyCopyBlt;
bltCmd.setSourceBaseAddress(srcAllocation->getGpuAddress());
bltCmd.setDestinationBaseAddress(dstAllocation->getGpuAddress());
bltCmd.setSourceBaseAddress(blitProperties.srcAllocation->getGpuAddress());
bltCmd.setDestinationBaseAddress(blitProperties.dstAllocation->getGpuAddress());
bltCmd.setDestinationX1CoordinateLeft(static_cast<uint32_t>(blitProperties.dstOffset.x));
bltCmd.setDestinationY1CoordinateTop(static_cast<uint32_t>(blitProperties.dstOffset.y));
@@ -235,13 +235,14 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsRegion(const BlitPropert
bltCmd.setSourceY1CoordinateTop(static_cast<uint32_t>(blitProperties.srcOffset.y));
appendBlitCommandsForBuffer(blitProperties, bltCmd, rootDeviceEnvironment);
appendBlitCommandsForImages(blitProperties, bltCmd);
appendBlitCommandsForImages(blitProperties, bltCmd, rootDeviceEnvironment, srcSlicePitch, dstSlicePitch);
appendColorDepth(blitProperties, bltCmd);
appendSurfaceType(blitProperties, bltCmd);
for (uint32_t i = 0; i < blitProperties.copySize.z; i++) {
appendSliceOffsets(blitProperties, bltCmd, i);
appendSliceOffsets(blitProperties, bltCmd, i, rootDeviceEnvironment, srcSlicePitch, dstSlicePitch);
auto cmd = linearStream.getSpaceForCmd<typename GfxFamily::XY_COPY_BLT>();
*cmd = bltCmd;
dispatchPostBlitCommand(linearStream);
}
}
@@ -280,10 +281,15 @@ uint32_t BlitCommandsHelper<GfxFamily>::getAvailableBytesPerPixel(size_t copySiz
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::dispatchBlitCommands(const BlitProperties &blitProperties, LinearStream &linearStream, const RootDeviceEnvironment &rootDeviceEnvironment) {
bool preferCopyRegion = isCopyRegionPreferred(blitProperties.copySize, rootDeviceEnvironment);
preferCopyRegion ? dispatchBlitCommandsForBufferRegion(blitProperties, linearStream, rootDeviceEnvironment)
: dispatchBlitCommandsForBufferPerRow(blitProperties, linearStream, rootDeviceEnvironment);
if (blitProperties.blitDirection == BlitterConstants::BlitDirection::HostPtrToImage ||
blitProperties.blitDirection == BlitterConstants::BlitDirection::ImageToHostPtr) {
return dispatchBlitCommandsRegion(blitProperties, linearStream, rootDeviceEnvironment);
}
bool preferCopyBufferRegion = isCopyRegionPreferred(blitProperties.copySize, rootDeviceEnvironment);
preferCopyBufferRegion ? dispatchBlitCommandsForBufferRegion(blitProperties, linearStream, rootDeviceEnvironment)
: dispatchBlitCommandsForBufferPerRow(blitProperties, linearStream, rootDeviceEnvironment);
}
template <typename GfxFamily>

View File

@@ -23,7 +23,7 @@ template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForBuffer(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) {}
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForImages(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd) {
void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForImages(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t &srcSlicePitch, uint32_t &dstSlicePitch) {
appendTilingType(GMM_NOT_TILED, GMM_NOT_TILED, blitCmd);
}
@@ -66,11 +66,11 @@ void BlitCommandsHelper<GfxFamily>::appendColorDepth(const BlitProperties &blitP
}
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::appendSliceOffsets(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, uint32_t sliceIndex) {
void BlitCommandsHelper<GfxFamily>::appendSliceOffsets(const BlitProperties &blitProperties, typename GfxFamily::XY_COPY_BLT &blitCmd, uint32_t sliceIndex, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t srcSlicePitch, uint32_t dstSlicePitch) {
}
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod) {
void BlitCommandsHelper<GfxFamily>::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment) {
}
} // namespace NEO

View File

@@ -67,7 +67,9 @@ constexpr uint64_t maxBytesPerPixel = 0x10;
enum class BlitDirection : uint32_t {
BufferToHostPtr,
HostPtrToBuffer,
BufferToBuffer
BufferToBuffer,
HostPtrToImage,
ImageToHostPtr
};
} // namespace BlitterConstants

View File

@@ -380,8 +380,9 @@ HWTEST2_F(BlitTests, givenGen9AndGetBlitAllocationPropertiesThenCorrectValuesAre
auto expectedQPitch = qPitch;
auto expectedtileType = tileType;
auto expectedMipTailLod = mipTailLod;
auto compressionDetails = 0u;
NEO::BlitCommandsHelper<FamilyType>::getBlitAllocationProperties(alloc, pitch, qPitch, tileType, mipTailLod);
NEO::BlitCommandsHelper<FamilyType>::getBlitAllocationProperties(alloc, pitch, qPitch, tileType, mipTailLod, compressionDetails, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(expectedPitch, pitch);
EXPECT_EQ(expectedQPitch, qPitch);

View File

@@ -72,72 +72,9 @@ HWTEST2_F(BlitTests, givenIncorrectBytePerPixelWhenAppendColorDepthThenAbortIsTh
EXPECT_THROW(BlitCommandsHelper<FamilyType>::appendColorDepth(properties, bltCmd), std::exception);
}
HWTEST2_F(BlitTests, givenNotTiledSrcAndDestinationWhenAppendTilingTypeThenCorrectTilingIsSet, IsGen12LP) {
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
BlitProperties properties = {};
BlitCommandsHelper<FamilyType>::appendTilingType(GMM_NOT_TILED, GMM_NOT_TILED, bltCmd);
EXPECT_EQ(bltCmd.getSourceTiling(), XY_COPY_BLT::SOURCE_TILING::SOURCE_TILING_LINEAR);
EXPECT_EQ(bltCmd.getDestinationTiling(), XY_COPY_BLT::DESTINATION_TILING::DESTINATION_TILING_LINEAR);
}
HWTEST2_F(BlitTests, givenTiledSrcAndDestinationAppendTilingTypeThenCorrectTilingIsSet, IsGen12LP) {
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
BlitProperties properties = {};
BlitCommandsHelper<FamilyType>::appendTilingType(GMM_TILED_Y, GMM_TILED_Y, bltCmd);
EXPECT_EQ(bltCmd.getSourceTiling(), XY_COPY_BLT::SOURCE_TILING::SOURCE_TILING_YMAJOR);
EXPECT_EQ(bltCmd.getDestinationTiling(), XY_COPY_BLT::DESTINATION_TILING::DESTINATION_TILING_YMAJOR);
}
HWTEST2_F(BlitTests, givenTiledSrcAndDestinationWhenAppendImageCommandsThenCorrectTiledIsSet, IsGen12LP) {
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
auto gmm = std::make_unique<MockGmm>();
auto flags = gmm->gmmResourceInfo->getResourceFlags();
flags->Info.TiledY = true;
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
mockAllocationSrc.setGmm(gmm.get(), 0);
mockAllocationDst.setGmm(gmm.get(), 0);
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
BlitProperties properties = {};
properties.srcAllocation = &mockAllocationSrc;
properties.dstAllocation = &mockAllocationDst;
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
EXPECT_EQ(bltCmd.getSourceTiling(), XY_COPY_BLT::SOURCE_TILING::SOURCE_TILING_YMAJOR);
EXPECT_EQ(bltCmd.getDestinationTiling(), XY_COPY_BLT::DESTINATION_TILING::DESTINATION_TILING_YMAJOR);
}
HWTEST2_F(BlitTests, givenNotTiledSrcAndDestinationWhenAppendImageCommandsThenCorrectTiledIsSet, IsGen12LP) {
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
auto gmm = std::make_unique<MockGmm>();
auto flags = gmm->gmmResourceInfo->getResourceFlags();
flags->Info.TiledY = false;
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
mockAllocationSrc.setGmm(gmm.get(), 0);
mockAllocationDst.setGmm(gmm.get(), 0);
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
BlitProperties properties = {};
properties.srcAllocation = &mockAllocationSrc;
properties.dstAllocation = &mockAllocationDst;
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
EXPECT_EQ(bltCmd.getSourceTiling(), XY_COPY_BLT::SOURCE_TILING::SOURCE_TILING_LINEAR);
EXPECT_EQ(bltCmd.getDestinationTiling(), XY_COPY_BLT::DESTINATION_TILING::DESTINATION_TILING_LINEAR);
}
HWTEST2_F(BlitTests, givenSrcAndDestinationImagesWhenAppendSliceOffsetsThenAdressAreCorectOffseted, IsGen12LP) {
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
auto gmm = std::make_unique<MockGmm>();
auto flags = gmm->gmmResourceInfo->getResourceFlags();
flags->Info.TiledY = false;
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
@@ -150,19 +87,22 @@ HWTEST2_F(BlitTests, givenSrcAndDestinationImagesWhenAppendSliceOffsetsThenAdres
BlitProperties properties = {};
properties.srcAllocation = &mockAllocationSrc;
properties.dstAllocation = &mockAllocationDst;
properties.srcGpuAddress = mockAllocationSrc.getGpuAddress();
properties.dstGpuAddress = mockAllocationDst.getGpuAddress();
properties.srcSize.y = 0x10;
properties.srcRowPitch = 0x10;
auto srcSlicePitch = properties.srcSize.y * properties.srcRowPitch;
auto srcSlicePitch = static_cast<uint32_t>(properties.srcSize.y * properties.srcRowPitch);
properties.dstSize.y = 0x20;
properties.dstRowPitch = 0x20;
auto dstSlicePitch = properties.dstSize.y * properties.dstRowPitch;
auto dstSlicePitch = static_cast<uint32_t>(properties.dstSize.y * properties.dstRowPitch);
properties.srcOffset = {0x10, 0x10, 0x10};
properties.dstOffset = {0x20, 0x20, 0x20};
uint32_t index = 7;
BlitCommandsHelper<FamilyType>::appendSliceOffsets(properties, bltCmd, index);
BlitCommandsHelper<FamilyType>::appendSliceOffsets(properties, bltCmd, index, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
auto expectesSrcOffset = (index + properties.srcOffset.z) * srcSlicePitch;
auto expectesDstOffset = (index + properties.dstOffset.z) * dstSlicePitch;
@@ -170,11 +110,9 @@ HWTEST2_F(BlitTests, givenSrcAndDestinationImagesWhenAppendSliceOffsetsThenAdres
EXPECT_EQ(bltCmd.getDestinationBaseAddress(), ptrOffset(mockAllocationDst.getGpuAddress(), expectesDstOffset));
}
HWTEST2_F(BlitTests, givenNotTiledSrcAndDestinationWhenAppendImageCommandsThenPitchIsValueFromProperties, IsGen12LP) {
HWTEST2_F(BlitTests, givenSrcAndDestinationImagesWhenAppendImageCommandsThenPitchIsValueFromGmm, IsGen12LP) {
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
auto gmm = std::make_unique<MockGmm>();
auto flags = gmm->gmmResourceInfo->getResourceFlags();
flags->Info.TiledY = false;
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
@@ -189,9 +127,50 @@ HWTEST2_F(BlitTests, givenNotTiledSrcAndDestinationWhenAppendImageCommandsThenPi
properties.dstAllocation = &mockAllocationDst;
properties.srcRowPitch = 0x1000;
properties.dstRowPitch = 0x4000;
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
EXPECT_EQ(bltCmd.getDestinationPitch(), properties.dstRowPitch);
EXPECT_EQ(bltCmd.getSourcePitch(), properties.srcRowPitch);
auto srcSlicePitch = static_cast<uint32_t>(properties.srcSlicePitch);
auto dstSlicePitch = static_cast<uint32_t>(properties.dstSlicePitch);
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
EXPECT_EQ(bltCmd.getDestinationPitch(), gmm->gmmResourceInfo->getRenderPitch());
EXPECT_EQ(bltCmd.getSourcePitch(), gmm->gmmResourceInfo->getRenderPitch());
}
HWTEST2_F(BlitTests, givenInputAndDefaultSlicePitchWhenAppendBlitCommandsForImagesThenSlicePitchesAreCorrect, IsGen12LP) {
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
BlitProperties properties = {};
properties.srcAllocation = &mockAllocationSrc;
properties.dstAllocation = &mockAllocationDst;
properties.srcSize = {10, 10, 1};
properties.dstSize = {8, 12, 1};
properties.srcRowPitch = 0x10;
properties.dstRowPitch = 0x40;
{
uint32_t inputSlicePitch = 0;
auto srcSlicePitch = inputSlicePitch;
auto dstSlicePitch = inputSlicePitch;
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
EXPECT_EQ(srcSlicePitch, static_cast<uint32_t>(properties.srcRowPitch * properties.srcSize.y));
EXPECT_EQ(dstSlicePitch, static_cast<uint32_t>(properties.dstRowPitch * properties.dstSize.y));
}
{
uint32_t inputSlicePitch = 0x40000;
auto srcSlicePitch = inputSlicePitch;
auto dstSlicePitch = inputSlicePitch;
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
EXPECT_EQ(srcSlicePitch, inputSlicePitch);
EXPECT_EQ(dstSlicePitch, inputSlicePitch);
}
}
struct MyMockResourecInfo : public GmmResourceInfo {
using GmmResourceInfo::resourceInfo;
@@ -213,133 +192,3 @@ struct MyMockResourecInfo : public GmmResourceInfo {
size_t pitch = 0;
GMM_RESOURCE_FLAG flags = {};
};
HWTEST2_F(BlitTests, givenTiledSrcAndDestinationWhenAppendImageCommandsThenPitchIsValueFromGmm, IsGen12LP) {
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
auto gmm = std::make_unique<MockGmm>();
GMM_RESCREATE_PARAMS gmmParams = {};
auto myResourecInfo = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
myResourecInfo->pitch = 0x100;
gmm->gmmResourceInfo.reset(myResourecInfo.release());
auto flags = gmm->gmmResourceInfo->getResourceFlags();
flags->Info.TiledY = true;
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
mockAllocationSrc.setGmm(gmm.get(), 0);
mockAllocationDst.setGmm(gmm.get(), 0);
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
BlitProperties properties = {};
properties.dstRowPitch = 0x1000;
properties.srcRowPitch = 0x1000;
properties.srcAllocation = &mockAllocationSrc;
properties.dstAllocation = &mockAllocationDst;
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
EXPECT_EQ(bltCmd.getDestinationPitch(), gmm->gmmResourceInfo->getRenderPitch() / sizeof(uint32_t));
EXPECT_EQ(bltCmd.getSourcePitch(), gmm->gmmResourceInfo->getRenderPitch() / sizeof(uint32_t));
}
HWTEST2_F(BlitTests, givenTiledSrcAndDestinationWhenGmmReturnsNotAlignedPitchThenValuesInCommandAreAligned, IsGen12LP) {
constexpr uint32_t TILED_Y_PITCH_ALIGNMENT = 128;
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
auto gmm = std::make_unique<MockGmm>();
GMM_RESCREATE_PARAMS gmmParams = {};
auto myResourecInfo = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
myResourecInfo->pitch = 0xFC;
gmm->gmmResourceInfo.reset(myResourecInfo.release());
auto flags = gmm->gmmResourceInfo->getResourceFlags();
flags->Info.TiledY = true;
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
mockAllocationSrc.setGmm(gmm.get(), 0);
mockAllocationDst.setGmm(gmm.get(), 0);
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
BlitProperties properties = {};
properties.dstRowPitch = 0x1000;
properties.srcRowPitch = 0x1000;
properties.srcAllocation = &mockAllocationSrc;
properties.dstAllocation = &mockAllocationDst;
auto expectedPitch = alignUp<uint32_t>(static_cast<uint32_t>(gmm->gmmResourceInfo->getRenderPitch()), TILED_Y_PITCH_ALIGNMENT);
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
EXPECT_EQ(bltCmd.getDestinationPitch(), expectedPitch / sizeof(uint32_t));
EXPECT_EQ(bltCmd.getSourcePitch(), expectedPitch / sizeof(uint32_t));
}
HWTEST2_F(BlitTests, givenDstTiledImageAndNotTiledSourceWhenAppendBlitCommandsForImagesThenPitchIsValueInDwords, IsGen12LP) {
constexpr uint32_t TILED_Y_PITCH_ALIGNMENT = 128;
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
auto gmmSrc = std::make_unique<MockGmm>();
auto gmmDst = std::make_unique<MockGmm>();
GMM_RESCREATE_PARAMS gmmParams = {};
auto myResourecInfoSrc = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
auto myResourecInfoDst = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
myResourecInfoSrc->pitch = 0x100;
myResourecInfoDst->pitch = 0x200;
gmmSrc->gmmResourceInfo.reset(myResourecInfoSrc.release());
gmmDst->gmmResourceInfo.reset(myResourecInfoDst.release());
auto flags = gmmDst->gmmResourceInfo->getResourceFlags();
flags->Info.TiledY = true;
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
mockAllocationSrc.setGmm(gmmSrc.get(), 0);
mockAllocationDst.setGmm(gmmDst.get(), 0);
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
BlitProperties properties = {};
properties.dstRowPitch = 0x1000;
properties.srcRowPitch = 0x1000;
properties.srcAllocation = &mockAllocationSrc;
properties.dstAllocation = &mockAllocationDst;
auto expectedPitch = alignUp<uint32_t>(static_cast<uint32_t>(gmmDst->gmmResourceInfo->getRenderPitch()), TILED_Y_PITCH_ALIGNMENT);
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
EXPECT_EQ(bltCmd.getDestinationPitch(), expectedPitch / sizeof(uint32_t));
EXPECT_EQ(bltCmd.getSourcePitch(), properties.srcRowPitch);
}
HWTEST2_F(BlitTests, givenSrcTiledImageAndNotTiledDstWhenAppendBlitCommandsForImagesThenPitchIsValueInDwords, IsGen12LP) {
constexpr uint32_t TILED_Y_PITCH_ALIGNMENT = 128;
using XY_COPY_BLT = typename FamilyType::XY_COPY_BLT;
auto gmmSrc = std::make_unique<MockGmm>();
auto gmmDst = std::make_unique<MockGmm>();
GMM_RESCREATE_PARAMS gmmParams = {};
auto myResourecInfoSrc = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
auto myResourecInfoDst = std::make_unique<MyMockResourecInfo>(pDevice->getRootDeviceEnvironment().getGmmClientContext(), &gmmParams);
myResourecInfoSrc->pitch = 0x100;
myResourecInfoDst->pitch = 0x200;
gmmSrc->gmmResourceInfo.reset(myResourecInfoSrc.release());
gmmDst->gmmResourceInfo.reset(myResourecInfoDst.release());
auto flags = gmmSrc->gmmResourceInfo->getResourceFlags();
flags->Info.TiledY = true;
MockGraphicsAllocation mockAllocationSrc(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
MockGraphicsAllocation mockAllocationDst(0, GraphicsAllocation::AllocationType::INTERNAL_HOST_MEMORY,
reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t),
MemoryPool::System4KBPages);
mockAllocationSrc.setGmm(gmmSrc.get(), 0);
mockAllocationDst.setGmm(gmmDst.get(), 0);
auto bltCmd = FamilyType::cmdInitXyCopyBlt;
BlitProperties properties = {};
properties.dstRowPitch = 0x1000;
properties.srcRowPitch = 0x1000;
properties.srcAllocation = &mockAllocationSrc;
properties.dstAllocation = &mockAllocationDst;
auto expectedPitch = alignUp<uint32_t>(static_cast<uint32_t>(gmmSrc->gmmResourceInfo->getRenderPitch()), TILED_Y_PITCH_ALIGNMENT);
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, bltCmd);
EXPECT_EQ(bltCmd.getSourcePitch(), expectedPitch / sizeof(uint32_t));
EXPECT_EQ(bltCmd.getDestinationPitch(), properties.dstRowPitch);
}