diff --git a/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp b/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp index 520edd8578..26f7ea715e 100644 --- a/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp +++ b/shared/test/unit_test/helpers/blit_commands_helper_tests.cpp @@ -18,6 +18,7 @@ #include "shared/test/common/helpers/mock_product_helper_hw.h" #include "shared/test/common/helpers/stream_capture.h" #include "shared/test/common/mocks/mock_device.h" +#include "shared/test/common/mocks/mock_gmm.h" #include "shared/test/common/mocks/mock_graphics_allocation.h" #include "shared/test/common/mocks/mock_timestamp_container.h" #include "shared/test/common/mocks/ult_device_factory.h" @@ -561,6 +562,143 @@ HWTEST2_F(BlitTests, givenXe2HpgCoreWhenAppendBlitCommandsMemCopyIsCalledThenNot EXPECT_EQ(bltCmd.getCompressionFormat(), 0); } +HWTEST2_F(BlitTests, givenXe2HpgCoreWhenAppendBlitCommandsMemCopyIsCalledWithDebugFlagSetThenNothingChanged, IsXe2HpgCore) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + DebugManagerStateRestore restore{}; + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(1); + BlitProperties properties = {}; + properties.dstAllocation = nullptr; + properties.srcAllocation = nullptr; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), 0); +} + +HWTEST2_F(BlitTests, givenXe2HpgCoreWhenDstGraphicAlloctionWhenAppendBlitCommandsMemCopyIsCalledThenCompressionChanged, IsXe2HpgCore) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + BlitProperties properties = {}; + DebugManagerStateRestore dbgRestore; + + uint32_t newCompressionFormat = 1; + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(newCompressionFormat)); + + auto gmm = std::make_unique(pDevice->getGmmHelper()); + gmm->setCompressionEnabled(true); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast(0x1234), + 0x1000, 0, sizeof(uint32_t), MemoryPool::localMemory, MemoryManager::maxOsContextCount); + mockAllocation.setGmm(gmm.get(), 0); + + properties.dstAllocation = &mockAllocation; + properties.srcAllocation = nullptr; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), newCompressionFormat); +} + +HWTEST2_F(BlitTests, givenXe2HpgCoreWhenDstGraphicAlloctionAndStatelessFlagSetWhenAppendBlitCommandsMemCopyIsCalledThenCompressionChanged, IsXe2HpgCore) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + BlitProperties properties = {}; + DebugManagerStateRestore dbgRestore; + + uint32_t newCompressionFormat = 1; + uint32_t statelessCompressionFormat = debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get(); + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(newCompressionFormat)); + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(1); + + auto gmm = std::make_unique(pDevice->getGmmHelper()); + gmm->setCompressionEnabled(true); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast(0x1234), + 0x1000, 0, sizeof(uint32_t), MemoryPool::localMemory, MemoryManager::maxOsContextCount); + mockAllocation.setGmm(gmm.get(), 0); + + properties.dstAllocation = &mockAllocation; + properties.srcAllocation = nullptr; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), statelessCompressionFormat); +} + +HWTEST2_F(BlitTests, givenXe2HpgCoreWhenDstGraphicAlloctionAndStatelessFlagSetAndSystemMemoryPoolWhenAppendBlitCommandsMemCopyIsCalledThenCompressionChanged, IsXe2HpgCore) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + BlitProperties properties = {}; + DebugManagerStateRestore dbgRestore; + + uint32_t newCompressionFormat = 1; + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(newCompressionFormat)); + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(1); + + auto gmm = std::make_unique(pDevice->getGmmHelper()); + gmm->setCompressionEnabled(true); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast(0x1234), + 0x1000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + mockAllocation.setGmm(gmm.get(), 0); + + properties.dstAllocation = &mockAllocation; + properties.srcAllocation = nullptr; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), newCompressionFormat); +} + +HWTEST2_F(BlitTests, givenXe2HpgCoreWhenSrcGraphicAlloctionWhenAppendBlitCommandsMemCopyIsCalledThenCompressionChanged, IsXe2HpgCore) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + BlitProperties properties = {}; + DebugManagerStateRestore dbgRestore; + + uint32_t newCompressionFormat = 1; + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(newCompressionFormat)); + + auto gmm = std::make_unique(pDevice->getGmmHelper()); + gmm->setCompressionEnabled(true); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast(0x1234), + 0x1000, 0, sizeof(uint32_t), MemoryPool::localMemory, MemoryManager::maxOsContextCount); + mockAllocation.setGmm(gmm.get(), 0); + + properties.dstAllocation = nullptr; + properties.srcAllocation = &mockAllocation; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), newCompressionFormat); +} + +HWTEST2_F(BlitTests, givenXe2HpgCoreWhenSrcGraphicAlloctionAndStatelessFlagSetWhenAppendBlitCommandsMemCopyIsCalledThenCompressionChanged, IsXe2HpgCore) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + BlitProperties properties = {}; + DebugManagerStateRestore dbgRestore; + + uint32_t newCompressionFormat = 1; + uint32_t statelessCompressionFormat = debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get(); + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(newCompressionFormat)); + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(1); + + auto gmm = std::make_unique(pDevice->getGmmHelper()); + gmm->setCompressionEnabled(true); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast(0x1234), + 0x1000, 0, sizeof(uint32_t), MemoryPool::localMemory, MemoryManager::maxOsContextCount); + mockAllocation.setGmm(gmm.get(), 0); + + properties.dstAllocation = nullptr; + properties.srcAllocation = &mockAllocation; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), statelessCompressionFormat); +} + +HWTEST2_F(BlitTests, givenXe2HpgCoreWhenSrcGraphicAlloctionAndStatelessFlagSetAndSystemMemoryPoolWhenAppendBlitCommandsMemCopyIsCalledThenCompressionChanged, IsXe2HpgCore) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + BlitProperties properties = {}; + DebugManagerStateRestore dbgRestore; + + uint32_t newCompressionFormat = 1; + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(newCompressionFormat)); + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(1); + + auto gmm = std::make_unique(pDevice->getGmmHelper()); + gmm->setCompressionEnabled(true); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast(0x1234), + 0x1000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + mockAllocation.setGmm(gmm.get(), 0); + + properties.dstAllocation = nullptr; + properties.srcAllocation = &mockAllocation; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), newCompressionFormat); +} + HWTEST2_F(BlitTests, givenXe3CoreWhenAppendBlitCommandsMemCopyIsCalledThenNothingChanged, IsXe3Core) { auto bltCmd = FamilyType::cmdInitXyCopyBlt; BlitProperties properties = {}; @@ -570,6 +708,143 @@ HWTEST2_F(BlitTests, givenXe3CoreWhenAppendBlitCommandsMemCopyIsCalledThenNothin EXPECT_EQ(bltCmd.getCompressionFormat(), 0); } +HWTEST2_F(BlitTests, givenXe3CoreWhenAppendBlitCommandsMemCopyIsCalledWithDebugFlagSetThenNothingChanged, IsXe3Core) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + DebugManagerStateRestore restore{}; + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(1); + BlitProperties properties = {}; + properties.dstAllocation = nullptr; + properties.srcAllocation = nullptr; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), 0); +} + +HWTEST2_F(BlitTests, givenXe3CoreWhenDstGraphicAlloctionWhenAppendBlitCommandsMemCopyIsCalledThenCompressionChanged, IsXe3Core) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + BlitProperties properties = {}; + DebugManagerStateRestore dbgRestore; + + uint32_t newCompressionFormat = 1; + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(newCompressionFormat)); + + auto gmm = std::make_unique(pDevice->getGmmHelper()); + gmm->setCompressionEnabled(true); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast(0x1234), + 0x1000, 0, sizeof(uint32_t), MemoryPool::localMemory, MemoryManager::maxOsContextCount); + mockAllocation.setGmm(gmm.get(), 0); + + properties.dstAllocation = &mockAllocation; + properties.srcAllocation = nullptr; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), newCompressionFormat); +} + +HWTEST2_F(BlitTests, givenXe3CoreWhenDstGraphicAlloctionAndStatelessFlagSetWhenAppendBlitCommandsMemCopyIsCalledThenCompressionChanged, IsXe3Core) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + BlitProperties properties = {}; + DebugManagerStateRestore dbgRestore; + + uint32_t newCompressionFormat = 1; + uint32_t statelessCompressionFormat = debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get(); + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(newCompressionFormat)); + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(1); + + auto gmm = std::make_unique(pDevice->getGmmHelper()); + gmm->setCompressionEnabled(true); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast(0x1234), + 0x1000, 0, sizeof(uint32_t), MemoryPool::localMemory, MemoryManager::maxOsContextCount); + mockAllocation.setGmm(gmm.get(), 0); + + properties.dstAllocation = &mockAllocation; + properties.srcAllocation = nullptr; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), statelessCompressionFormat); +} + +HWTEST2_F(BlitTests, givenXe3CoreWhenDstGraphicAlloctionAndStatelessFlagSetAndSystemMemoryPoolWhenAppendBlitCommandsMemCopyIsCalledThenCompressionChanged, IsXe3Core) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + BlitProperties properties = {}; + DebugManagerStateRestore dbgRestore; + + uint32_t newCompressionFormat = 1; + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(newCompressionFormat)); + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(1); + + auto gmm = std::make_unique(pDevice->getGmmHelper()); + gmm->setCompressionEnabled(true); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast(0x1234), + 0x1000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + mockAllocation.setGmm(gmm.get(), 0); + + properties.dstAllocation = &mockAllocation; + properties.srcAllocation = nullptr; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), newCompressionFormat); +} + +HWTEST2_F(BlitTests, givenXe3CoreWhenSrcGraphicAlloctionWhenAppendBlitCommandsMemCopyIsCalledThenCompressionChanged, IsXe3Core) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + BlitProperties properties = {}; + DebugManagerStateRestore dbgRestore; + + uint32_t newCompressionFormat = 1; + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(newCompressionFormat)); + + auto gmm = std::make_unique(pDevice->getGmmHelper()); + gmm->setCompressionEnabled(true); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast(0x1234), + 0x1000, 0, sizeof(uint32_t), MemoryPool::localMemory, MemoryManager::maxOsContextCount); + mockAllocation.setGmm(gmm.get(), 0); + + properties.dstAllocation = nullptr; + properties.srcAllocation = &mockAllocation; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), newCompressionFormat); +} + +HWTEST2_F(BlitTests, givenXe3CoreWhenSrcGraphicAlloctionAndStatelessFlagSetWhenAppendBlitCommandsMemCopyIsCalledThenCompressionChanged, IsXe3Core) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + BlitProperties properties = {}; + DebugManagerStateRestore dbgRestore; + + uint32_t newCompressionFormat = 1; + uint32_t statelessCompressionFormat = debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get(); + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(newCompressionFormat)); + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(1); + + auto gmm = std::make_unique(pDevice->getGmmHelper()); + gmm->setCompressionEnabled(true); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast(0x1234), + 0x1000, 0, sizeof(uint32_t), MemoryPool::localMemory, MemoryManager::maxOsContextCount); + mockAllocation.setGmm(gmm.get(), 0); + + properties.dstAllocation = nullptr; + properties.srcAllocation = &mockAllocation; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), statelessCompressionFormat); +} + +HWTEST2_F(BlitTests, givenXe3CoreWhenSrcGraphicAlloctionAndStatelessFlagSetAndSystemMemoryPoolWhenAppendBlitCommandsMemCopyIsCalledThenCompressionChanged, IsXe3Core) { + auto bltCmd = FamilyType::cmdInitXyCopyBlt; + BlitProperties properties = {}; + DebugManagerStateRestore dbgRestore; + + uint32_t newCompressionFormat = 1; + debugManager.flags.ForceBufferCompressionFormat.set(static_cast(newCompressionFormat)); + debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.set(1); + + auto gmm = std::make_unique(pDevice->getGmmHelper()); + gmm->setCompressionEnabled(true); + MockGraphicsAllocation mockAllocation(0, 1u /*num gmms*/, AllocationType::internalHostMemory, reinterpret_cast(0x1234), + 0x1000, 0, sizeof(uint32_t), MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + mockAllocation.setGmm(gmm.get(), 0); + + properties.dstAllocation = nullptr; + properties.srcAllocation = &mockAllocation; + NEO::BlitCommandsHelper::appendBlitCommandsMemCopy(properties, bltCmd, pDevice->getRootDeviceEnvironment()); + EXPECT_EQ(bltCmd.getCompressionFormat(), newCompressionFormat); +} + HWTEST_F(BlitTests, givenXyBlockCopyBltCommandAndSliceIndex0WhenAppendBaseAddressOffsetIsCalledThenNothingChanged) { using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt;