feature: system allocator support for image APIs

Related-To: NEO-15461

Signed-off-by: Young Jin Yoon <young.jin.yoon@intel.com>
Signed-off-by: Narendra Bagria <narendra.bagria@intel.com>
This commit is contained in:
Narendra Bagria
2025-08-26 06:55:23 +00:00
committed by Compute-Runtime-Automation
parent f7739f8dea
commit 31bcea128f
15 changed files with 736 additions and 93 deletions

View File

@@ -1086,8 +1086,8 @@ TaskCountType CommandStreamReceiverHw<GfxFamily>::flushBcsTask(const BlitPropert
if (blitProperties.blitSyncProperties.outputTimestampPacket) {
bool deviceToHostPostSyncFenceRequired = getProductHelper().isDeviceToHostCopySignalingFenceRequired() &&
!blitProperties.dstAllocation->isAllocatedInLocalMemoryPool() &&
blitProperties.srcAllocation->isAllocatedInLocalMemoryPool();
(blitProperties.dstAllocation && !blitProperties.dstAllocation->isAllocatedInLocalMemoryPool()) &&
(blitProperties.srcAllocation && blitProperties.srcAllocation->isAllocatedInLocalMemoryPool());
if (deviceToHostPostSyncFenceRequired) {
MemorySynchronizationCommands<GfxFamily>::addAdditionalSynchronization(commandStream, tagAllocation->getGpuAddress(), NEO::FenceType::release, peekRootDeviceEnvironment());
@@ -1106,8 +1106,12 @@ TaskCountType CommandStreamReceiverHw<GfxFamily>::flushBcsTask(const BlitPropert
}
blitProperties.csrDependencies.makeResident(*this);
blitProperties.srcAllocation->prepareHostPtrForResidency(this);
blitProperties.dstAllocation->prepareHostPtrForResidency(this);
if (blitProperties.srcAllocation) {
blitProperties.srcAllocation->prepareHostPtrForResidency(this);
}
if (blitProperties.dstAllocation) {
blitProperties.dstAllocation->prepareHostPtrForResidency(this);
}
makeResident(*blitProperties.srcAllocation);
makeResident(*blitProperties.dstAllocation);
if (blitProperties.clearColorAllocation) {

View File

@@ -291,12 +291,14 @@ void BlitCommandsHelper<Family>::appendBlitCommandsForImages(const BlitPropertie
auto dstRowPitch = static_cast<uint32_t>(blitProperties.dstRowPitch);
uint32_t mipTailLod = 0;
auto compressionDetails = 0u;
getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, tileType, mipTailLod, compressionDetails,
rootDeviceEnvironment, blitProperties.srcPlane);
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, tileType, mipTailLod, compressionDetails,
rootDeviceEnvironment, blitProperties.dstPlane);
if (srcAllocation) {
getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, tileType, mipTailLod, compressionDetails,
rootDeviceEnvironment, blitProperties.srcPlane);
}
if (dstAllocation) {
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, tileType, mipTailLod, compressionDetails,
rootDeviceEnvironment, blitProperties.dstPlane);
}
blitCmd.setSourcePitch(srcRowPitch);
blitCmd.setDestinationPitch(dstRowPitch);

View File

@@ -80,7 +80,7 @@ template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::appendSurfaceType(const BlitProperties &blitProperties, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd) {
using XY_BLOCK_COPY_BLT = typename GfxFamily::XY_BLOCK_COPY_BLT;
if (blitProperties.srcAllocation->getDefaultGmm()) {
if (blitProperties.srcAllocation && blitProperties.srcAllocation->getDefaultGmm()) {
auto resInfo = blitProperties.srcAllocation->getDefaultGmm()->gmmResourceInfo.get();
auto resourceType = resInfo->getResourceType();
auto isArray = resInfo->getArraySize() > 1;
@@ -100,7 +100,7 @@ void BlitCommandsHelper<GfxFamily>::appendSurfaceType(const BlitProperties &blit
}
}
if (blitProperties.dstAllocation->getDefaultGmm()) {
if (blitProperties.dstAllocation && blitProperties.dstAllocation->getDefaultGmm()) {
auto resInfo = blitProperties.dstAllocation->getDefaultGmm()->gmmResourceInfo.get();
auto resourceType = resInfo->getResourceType();
auto isArray = resInfo->getArraySize() > 1;
@@ -212,10 +212,14 @@ void BlitCommandsHelper<GfxFamily>::appendBlitCommandsForImages(const BlitProper
auto srcCompressionFormat = blitCmd.getSourceCompressionFormat();
auto dstCompressionFormat = blitCmd.getDestinationCompressionFormat();
getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, srcTileType, srcMipTailLod, srcCompressionFormat,
rootDeviceEnvironment, blitProperties.srcPlane);
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, dstTileType, dstMipTailLod, dstCompressionFormat,
rootDeviceEnvironment, blitProperties.dstPlane);
if (srcAllocation) {
getBlitAllocationProperties(*srcAllocation, srcRowPitch, srcQPitch, srcTileType, srcMipTailLod, srcCompressionFormat,
rootDeviceEnvironment, blitProperties.srcPlane);
}
if (dstAllocation) {
getBlitAllocationProperties(*dstAllocation, dstRowPitch, dstQPitch, dstTileType, dstMipTailLod, dstCompressionFormat,
rootDeviceEnvironment, blitProperties.dstPlane);
}
srcSlicePitch = std::max(srcSlicePitch, srcRowPitch * srcQPitch);
dstSlicePitch = std::max(dstSlicePitch, dstRowPitch * dstQPitch);

View File

@@ -244,13 +244,13 @@ bool BlitProperties::isImageOperation() const {
blitDirection == BlitterConstants::BlitDirection::imageToImage;
}
bool BlitProperties::isSrc1DTiledArray() const {
if (srcAllocation->getDefaultGmm()) {
if (srcAllocation && srcAllocation->getDefaultGmm()) {
return is1DTiledArray(srcAllocation->getDefaultGmm()->gmmResourceInfo.get());
}
return false;
}
bool BlitProperties::isDst1DTiledArray() const {
if (dstAllocation->getDefaultGmm()) {
if (dstAllocation && dstAllocation->getDefaultGmm()) {
return is1DTiledArray(dstAllocation->getDefaultGmm()->gmmResourceInfo.get());
}
return false;

View File

@@ -68,35 +68,35 @@ void BlitCommandsHelper<Family>::appendBlitCommandsBlockCopy(const BlitPropertie
auto dstAllocation = blitProperties.dstAllocation;
auto srcAllocation = blitProperties.srcAllocation;
if (srcAllocation->isCompressionEnabled()) {
if (srcAllocation && srcAllocation->isCompressionEnabled()) {
auto resourceFormat = srcAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat();
srcCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat);
}
if (dstAllocation->isCompressionEnabled()) {
if (dstAllocation && dstAllocation->isCompressionEnabled()) {
auto resourceFormat = dstAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat();
dstCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat);
}
if (debugManager.flags.ForceBufferCompressionFormat.get() != -1) {
if (srcAllocation->isCompressionEnabled()) {
if (srcAllocation && srcAllocation->isCompressionEnabled()) {
srcCompressionFormat = static_cast<uint8_t>(debugManager.flags.ForceBufferCompressionFormat.get());
}
if (dstAllocation->isCompressionEnabled()) {
if (dstAllocation && dstAllocation->isCompressionEnabled()) {
dstCompressionFormat = static_cast<uint8_t>(debugManager.flags.ForceBufferCompressionFormat.get());
}
}
DEBUG_BREAK_IF((AuxTranslationDirection::none != blitProperties.auxTranslationDirection) &&
(blitProperties.dstAllocation != blitProperties.srcAllocation || !blitProperties.dstAllocation->isCompressionEnabled()));
(blitProperties.dstAllocation != blitProperties.srcAllocation || (blitProperties.dstAllocation && !blitProperties.dstAllocation->isCompressionEnabled())));
blitCmd.setSourceCompressionFormat(static_cast<XY_BLOCK_COPY_BLT::SOURCE_COMPRESSION_FORMAT>(srcCompressionFormat));
blitCmd.setDestinationCompressionFormat(static_cast<XY_BLOCK_COPY_BLT::DESTINATION_COMPRESSION_FORMAT>(dstCompressionFormat));
if (MemoryPoolHelper::isSystemMemoryPool(blitProperties.dstAllocation->getMemoryPool())) {
if (!dstAllocation || MemoryPoolHelper::isSystemMemoryPool(dstAllocation->getMemoryPool())) {
blitCmd.setDestinationTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}
if (MemoryPoolHelper::isSystemMemoryPool(blitProperties.srcAllocation->getMemoryPool())) {
if (!srcAllocation || MemoryPoolHelper::isSystemMemoryPool(srcAllocation->getMemoryPool())) {
blitCmd.setSourceTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}

View File

@@ -67,35 +67,35 @@ void BlitCommandsHelper<Family>::appendBlitCommandsBlockCopy(const BlitPropertie
auto dstAllocation = blitProperties.dstAllocation;
auto srcAllocation = blitProperties.srcAllocation;
if (srcAllocation->isCompressionEnabled()) {
if (srcAllocation && srcAllocation->isCompressionEnabled()) {
auto resourceFormat = srcAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat();
srcCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat);
}
if (dstAllocation->isCompressionEnabled()) {
if (dstAllocation && dstAllocation->isCompressionEnabled()) {
auto resourceFormat = dstAllocation->getDefaultGmm()->gmmResourceInfo->getResourceFormat();
dstCompressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat);
}
if (debugManager.flags.ForceBufferCompressionFormat.get() != -1) {
if (srcAllocation->isCompressionEnabled()) {
if (srcAllocation && srcAllocation->isCompressionEnabled()) {
srcCompressionFormat = static_cast<uint8_t>(debugManager.flags.ForceBufferCompressionFormat.get());
}
if (dstAllocation->isCompressionEnabled()) {
if (dstAllocation && dstAllocation->isCompressionEnabled()) {
dstCompressionFormat = static_cast<uint8_t>(debugManager.flags.ForceBufferCompressionFormat.get());
}
}
DEBUG_BREAK_IF((AuxTranslationDirection::none != blitProperties.auxTranslationDirection) &&
(blitProperties.dstAllocation != blitProperties.srcAllocation || !blitProperties.dstAllocation->isCompressionEnabled()));
(blitProperties.dstAllocation != blitProperties.srcAllocation || (blitProperties.dstAllocation && !blitProperties.dstAllocation->isCompressionEnabled())));
blitCmd.setSourceCompressionFormat(static_cast<XY_BLOCK_COPY_BLT::SOURCE_COMPRESSION_FORMAT>(srcCompressionFormat));
blitCmd.setDestinationCompressionFormat(static_cast<XY_BLOCK_COPY_BLT::DESTINATION_COMPRESSION_FORMAT>(dstCompressionFormat));
if (MemoryPoolHelper::isSystemMemoryPool(blitProperties.dstAllocation->getMemoryPool())) {
if (!dstAllocation || MemoryPoolHelper::isSystemMemoryPool(dstAllocation->getMemoryPool())) {
blitCmd.setDestinationTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}
if (MemoryPoolHelper::isSystemMemoryPool(blitProperties.srcAllocation->getMemoryPool())) {
if (!srcAllocation || MemoryPoolHelper::isSystemMemoryPool(srcAllocation->getMemoryPool())) {
blitCmd.setSourceTargetMemory(XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}

View File

@@ -142,7 +142,7 @@ void BlitCommandsHelper<Family>::appendBlitCommandsMemCopy(const BlitProperties
}
DEBUG_BREAK_IF((AuxTranslationDirection::none != blitProperties.auxTranslationDirection) &&
(dstAllocation != srcAllocation || !dstAllocation->isCompressionEnabled()));
(dstAllocation != srcAllocation || (dstAllocation && !dstAllocation->isCompressionEnabled())));
}
template <>
@@ -209,8 +209,8 @@ void BlitCommandsHelper<Family>::encodeWa(LinearStream &cmdStream, const BlitPro
const bool applyForDst = (debugManager.flags.EnableBcsSwControlWa.get() & dstInSystemMemOnly);
const bool applyAlways = (debugManager.flags.EnableBcsSwControlWa.get() == enableAlways);
const bool enableWa = (!blitProperties.srcAllocation->isAllocatedInLocalMemoryPool() && applyForSrc) ||
(!blitProperties.dstAllocation->isAllocatedInLocalMemoryPool() && applyForDst) ||
const bool enableWa = ((blitProperties.srcAllocation && !blitProperties.srcAllocation->isAllocatedInLocalMemoryPool()) && applyForSrc) ||
((blitProperties.dstAllocation && !blitProperties.dstAllocation->isAllocatedInLocalMemoryPool()) && applyForDst) ||
applyAlways;
uint32_t newValue = enableWa ? waEnabledMMioValue : waDisabledMMioValue;

View File

@@ -49,9 +49,9 @@ template <>
void BlitCommandsHelper<Family>::adjustControlSurfaceType(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd) {
using CONTROL_SURFACE_TYPE = typename Family::XY_BLOCK_COPY_BLT::CONTROL_SURFACE_TYPE;
using COMPRESSION_ENABLE = typename Family::XY_BLOCK_COPY_BLT::COMPRESSION_ENABLE;
auto srcAllocation = blitProperties.srcAllocation;
if (srcAllocation->getDefaultGmm()) {
auto srcAllocation = blitProperties.srcAllocation;
if (srcAllocation && srcAllocation->getDefaultGmm()) {
auto gmmResourceInfo = srcAllocation->getDefaultGmm()->gmmResourceInfo.get();
auto resInfo = gmmResourceInfo->getResourceFlags()->Info;
if (resInfo.MediaCompressed) {
@@ -62,7 +62,7 @@ void BlitCommandsHelper<Family>::adjustControlSurfaceType(const BlitProperties &
}
auto dstAllocation = blitProperties.dstAllocation;
if (dstAllocation->getDefaultGmm()) {
if (dstAllocation && dstAllocation->getDefaultGmm()) {
auto gmmResourceInfo = dstAllocation->getDefaultGmm()->gmmResourceInfo.get();
auto resInfo = gmmResourceInfo->getResourceFlags()->Info;
if (resInfo.MediaCompressed) {
@@ -90,12 +90,13 @@ void BlitCommandsHelper<Family>::appendBlitCommandsBlockCopy(const BlitPropertie
compressionEnabledField = static_cast<typename XY_BLOCK_COPY_BLT::COMPRESSION_ENABLE>(debugManager.flags.ForceCompressionDisabledForCompressedBlitCopies.get());
}
if (blitProperties.dstAllocation->isCompressionEnabled()) {
if (blitProperties.dstAllocation && blitProperties.dstAllocation->isCompressionEnabled()) {
blitCmd.setDestinationCompressionEnable(compressionEnabledField);
blitCmd.setDestinationAuxiliarysurfacemode(XY_BLOCK_COPY_BLT::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
blitCmd.setDestinationCompressionFormat(compressionFormat);
}
if (blitProperties.srcAllocation->isCompressionEnabled()) {
if (blitProperties.srcAllocation && blitProperties.srcAllocation->isCompressionEnabled()) {
blitCmd.setSourceCompressionEnable(compressionEnabledField);
blitCmd.setSourceAuxiliarysurfacemode(XY_BLOCK_COPY_BLT::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
blitCmd.setSourceCompressionFormat(compressionFormat);
@@ -128,7 +129,7 @@ void BlitCommandsHelper<Family>::appendBlitCommandsBlockCopy(const BlitPropertie
}
DEBUG_BREAK_IF((AuxTranslationDirection::none != blitProperties.auxTranslationDirection) &&
(blitProperties.dstAllocation != blitProperties.srcAllocation || !blitProperties.dstAllocation->isCompressionEnabled()));
(blitProperties.dstAllocation != blitProperties.srcAllocation || (blitProperties.dstAllocation && !blitProperties.dstAllocation->isCompressionEnabled())));
auto mocs = rootDeviceEnvironment.getGmmHelper()->getUncachedMOCS();

View File

@@ -99,6 +99,7 @@ TEST_F(BlitPropertiesTests, givenBlitPropertiesWhenDstIs1DTiledArrayThenTransfor
EXPECT_EQ(blitProperties.dstOffset.y, 0u);
EXPECT_EQ(blitProperties.dstOffset.z, size.y);
}
TEST_F(BlitPropertiesTests, givenBlitPropertiesWhenDstAndSrcIsNot1DTiledArrayThenSizeAndOffsetNotchanged) {
blitProperties.transform1DArrayTo2DArrayIfNeeded();
@@ -143,4 +144,24 @@ TEST_F(BlitPropertiesTests, givenGmmResInfoForTiled1DWhenIs1DTiledArrayCalledThe
resourceInfoSrc->mockResourceCreateParams.ArraySize = 1;
EXPECT_FALSE(blitProperties.is1DTiledArray(resourceInfoSrc));
}
TEST_F(BlitPropertiesTests, givenNullSrcAllocationWhenCallingIsSrc1DTiledArrayThenFalseIsReturned) {
blitProperties.srcAllocation = nullptr;
EXPECT_FALSE(blitProperties.isSrc1DTiledArray());
}
TEST_F(BlitPropertiesTests, givenNullDstAllocationWhenCallingIsDst1DTiledArrayThenFalseIsReturned) {
blitProperties.dstAllocation = nullptr;
EXPECT_FALSE(blitProperties.isDst1DTiledArray());
}
TEST_F(BlitPropertiesTests, givenSrcAllocationWithNullGmmWhenCallingIsSrc1DTiledArrayThenFalseIsReturned) {
blitProperties.srcAllocation->setGmm(nullptr, 0);
EXPECT_FALSE(blitProperties.isSrc1DTiledArray());
}
TEST_F(BlitPropertiesTests, givenDstAllocationWithNullGmmWhenCallingIsDst1DTiledArrayThenFalseIsReturned) {
blitProperties.dstAllocation->setGmm(nullptr, 0);
EXPECT_FALSE(blitProperties.isDst1DTiledArray());
}
} // namespace NEO

View File

@@ -1422,3 +1422,258 @@ HWTEST2_F(BlitTests, givenXyCopyBltCommandWhenApplyBlitPropertiesIsCalledThenNot
NEO::BlitCommandsHelper<FamilyType>::applyAdditionalBlitProperties(properties, bltCmd, pDevice->getRootDeviceEnvironment(), true);
EXPECT_EQ(memcmp(&bltCmd, &bltCmdBefore, sizeof(XY_COPY_BLT)), 0);
}
HWTEST2_F(BlitTests, givenSrcAndDstAllocationWithCompressionEnabledWhenAppendBlitCommandsBlockCopyThenSetSrcAndDstTargetMemToLocalMemAndCompressionHandled, IsXeHpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties{};
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->setCompressionEnabled(true);
MockGraphicsAllocation mockDstAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x1234),
0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
MockGraphicsAllocation mockSrcAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x2345),
0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
mockDstAllocation.setGmm(gmm.get(), 0);
mockSrcAllocation.setGmm(gmm.get(), 0);
properties.dstAllocation = &mockDstAllocation;
properties.srcAllocation = &mockSrcAllocation;
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM);
EXPECT_EQ(blitCmd.getDestinationCompressionEnable(), XY_BLOCK_COPY_BLT::COMPRESSION_ENABLE::COMPRESSION_ENABLE_COMPRESSION_ENABLE);
EXPECT_EQ(blitCmd.getSourceCompressionEnable(), XY_BLOCK_COPY_BLT::COMPRESSION_ENABLE::COMPRESSION_ENABLE_COMPRESSION_ENABLE);
EXPECT_EQ(blitCmd.getDestinationAuxiliarysurfacemode(), XY_BLOCK_COPY_BLT::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
EXPECT_EQ(blitCmd.getSourceAuxiliarysurfacemode(), XY_BLOCK_COPY_BLT::AUXILIARY_SURFACE_MODE_AUX_CCS_E);
}
HWTEST2_F(BlitTests, givenSrcAndDstAllocationWithoutCompressionEnabledWhenAppendBlitCommandsBlockCopyThenSetSrcAndDstTargetMemToLocalMemAndCompressionHandled, IsXeHpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties{};
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->setCompressionEnabled(false);
MockGraphicsAllocation mockDstAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x1234),
0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
MockGraphicsAllocation mockSrcAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x2345),
0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
mockDstAllocation.setGmm(gmm.get(), 0);
mockSrcAllocation.setGmm(gmm.get(), 0);
properties.dstAllocation = &mockDstAllocation;
properties.srcAllocation = &mockSrcAllocation;
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM);
EXPECT_EQ(blitCmd.getDestinationCompressionEnable(), 0u);
EXPECT_EQ(blitCmd.getSourceCompressionEnable(), 0u);
EXPECT_EQ(blitCmd.getDestinationAuxiliarysurfacemode(), 0u);
EXPECT_EQ(blitCmd.getSourceAuxiliarysurfacemode(), 0u);
}
HWTEST2_F(BlitTests, givenNullAllocationsWhenAppendBlitCommandsBlockCopyThenSetSrcAndDstTargetMemToLocalMemAndCompressionHandled, IsXeHpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties{};
properties.dstAllocation = nullptr;
properties.srcAllocation = nullptr;
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_LOCAL_MEM);
EXPECT_EQ(blitCmd.getDestinationCompressionEnable(), 0u);
EXPECT_EQ(blitCmd.getSourceCompressionEnable(), 0u);
EXPECT_EQ(blitCmd.getDestinationAuxiliarysurfacemode(), 0u);
EXPECT_EQ(blitCmd.getSourceAuxiliarysurfacemode(), 0u);
}
HWTEST2_F(BlitTests, givenNullAllocationsWhenAdjustControlSurfaceTypeThenSurfaceTypeWillNotChange, IsXeHpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
BlitProperties properties{};
properties.srcAllocation = nullptr;
properties.dstAllocation = nullptr;
constexpr auto initialSrcSurface = 0; // CONTROL_SURFACE_TYPE_3D
constexpr auto initialDstSurface = 0; // CONTROL_SURFACE_TYPE_3D
BlitCommandsHelper<FamilyType>::adjustControlSurfaceType(properties, blitCmd);
EXPECT_EQ(blitCmd.getSourceControlSurfaceType(), initialSrcSurface);
EXPECT_EQ(blitCmd.getDestinationControlSurfaceType(), initialDstSurface);
}
HWTEST2_F(BlitTests, givenSrcAndDstAllocationWithCompressionEnabledAndForceBufferCompressionFormatSetWhenAppendBlitCommandsBlockCopyIsCalledThenSetSrcAndDstTargetMemToSystemMemAndCompressionHandled, IsAtLeastXe2HpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties = {};
DebugManagerStateRestore dbgRestore;
uint32_t compressionFormat = 1;
debugManager.flags.ForceBufferCompressionFormat.set(static_cast<int32_t>(compressionFormat));
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->setCompressionEnabled(true);
MockGraphicsAllocation mockDstAllocation(0, 1u /*num gmms*/, AllocationType::buffer, reinterpret_cast<void *>(0x1234), 0x1000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
MockGraphicsAllocation mockSrcAllocation(0, 1u /*num gmms*/, AllocationType::buffer, reinterpret_cast<void *>(0x2345), 0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
mockDstAllocation.setGmm(gmm.get(), 0);
mockSrcAllocation.setGmm(gmm.get(), 0);
properties.dstAllocation = &mockDstAllocation;
properties.srcAllocation = &mockSrcAllocation;
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationCompressionFormat(), compressionFormat);
EXPECT_EQ(blitCmd.getSourceCompressionFormat(), compressionFormat);
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}
HWTEST2_F(BlitTests, givenSrcAllocationWithoutCompressionEnabledAndForceBufferCompressionFormatSetWhenAppendBlitCommandsBlockCopyIsCalledThenSetSrcTargetMemToSystemMemAndCompressionHandled, IsAtLeastXe2HpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties = {};
DebugManagerStateRestore dbgRestore;
MockGraphicsAllocation mockSrcAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x1234),
0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->setCompressionEnabled(false);
mockSrcAllocation.setGmm(gmm.get(), 0);
properties.srcAllocation = &mockSrcAllocation;
properties.dstAllocation = nullptr;
debugManager.flags.ForceBufferCompressionFormat.set(1);
auto initialDstCompressionFormat = blitCmd.getDestinationCompressionFormat();
auto initialSrcCompressionFormat = blitCmd.getSourceCompressionFormat();
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationCompressionFormat(), initialDstCompressionFormat);
EXPECT_EQ(blitCmd.getSourceCompressionFormat(), initialSrcCompressionFormat);
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}
HWTEST2_F(BlitTests, givenDstAllocationWithoutCompressionEnabledAndForceBufferCompressionFormatSetWhenAppendBlitCommandsBlockCopyIsCalledThenSetDstTargetMemToSystemMemAndCompressionHandled, IsAtLeastXe2HpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties = {};
DebugManagerStateRestore dbgRestore;
MockGraphicsAllocation mockDstAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast<void *>(0x1234),
0x2000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
auto gmm = std::make_unique<MockGmm>(pDevice->getGmmHelper());
gmm->setCompressionEnabled(false);
mockDstAllocation.setGmm(gmm.get(), 0);
properties.dstAllocation = &mockDstAllocation;
properties.srcAllocation = nullptr;
debugManager.flags.ForceBufferCompressionFormat.set(1);
auto initialDstCompressionFormat = blitCmd.getDestinationCompressionFormat();
auto initialSrcCompressionFormat = blitCmd.getSourceCompressionFormat();
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationCompressionFormat(), initialDstCompressionFormat);
EXPECT_EQ(blitCmd.getSourceCompressionFormat(), initialSrcCompressionFormat);
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}
HWTEST2_F(BlitTests, givenNullAllocationsAndForceBufferCompressionFormatSetWhenAppendBlitCommandsBlockCopyIsCalledThenSetSrcAndDstTargetMemToSystemMemAndCompressionHandled, IsAtLeastXe2HpgCore) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
blitCmd.setSourceX1CoordinateLeft(0);
blitCmd.setSourceY1CoordinateTop(0);
blitCmd.setDestinationX2CoordinateRight(1);
blitCmd.setDestinationY2CoordinateBottom(1);
BlitProperties properties = {};
DebugManagerStateRestore dbgRestore;
properties.dstAllocation = nullptr;
properties.srcAllocation = nullptr;
debugManager.flags.ForceBufferCompressionFormat.set(1);
auto initialDstCompressionFormat = blitCmd.getDestinationCompressionFormat();
auto initialSrcCompressionFormat = blitCmd.getSourceCompressionFormat();
BlitCommandsHelper<FamilyType>::appendBlitCommandsBlockCopy(properties, blitCmd, pDevice->getRootDeviceEnvironment());
EXPECT_EQ(blitCmd.getDestinationCompressionFormat(), initialDstCompressionFormat);
EXPECT_EQ(blitCmd.getSourceCompressionFormat(), initialSrcCompressionFormat);
EXPECT_EQ(blitCmd.getDestinationTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
EXPECT_EQ(blitCmd.getSourceTargetMemory(), XY_BLOCK_COPY_BLT::TARGET_MEMORY::TARGET_MEMORY_SYSTEM_MEM);
}
HWTEST2_F(BlitTests, givenNullAllocationsWhenAppendBlitCommandsForImagesThenSlicePitchesWillBeUpdated, IsNotPVC) {
using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT;
XY_BLOCK_COPY_BLT blitCmd = FamilyType::cmdInitXyBlockCopyBlt;
BlitProperties properties{};
properties.dstAllocation = nullptr;
properties.srcAllocation = nullptr;
properties.dstSize = {8, 12, 1};
properties.srcSize = {10, 10, 1};
properties.dstRowPitch = 0x40;
properties.srcRowPitch = 0x10;
uint32_t dstSlicePitch = 0;
uint32_t srcSlicePitch = 0;
BlitCommandsHelper<FamilyType>::appendBlitCommandsForImages(properties, blitCmd, pDevice->getRootDeviceEnvironment(), srcSlicePitch, dstSlicePitch);
EXPECT_NE(dstSlicePitch, 0u);
EXPECT_NE(srcSlicePitch, 0u);
}