From a93cecac3618032d425297e5b3e72be9b860fb81 Mon Sep 17 00:00:00 2001 From: Maciej Plewka Date: Wed, 5 Mar 2025 15:33:02 +0000 Subject: [PATCH] fix: treat tiled 1D images as 2D with height 1 for BLT copies Related-To: NEO-14147, HSD-14024424096, HSD-14024424178 Signed-off-by: Maciej Plewka --- .../blit_commands_helper_xehp_and_later.inl | 6 +- ...st_blit_commands_helper_xehp_and_later.cpp | 76 +++++++++++++++++++ 2 files changed, 80 insertions(+), 2 deletions(-) diff --git a/shared/source/helpers/blit_commands_helper_xehp_and_later.inl b/shared/source/helpers/blit_commands_helper_xehp_and_later.inl index 91a18e1faf..43dfd984ae 100644 --- a/shared/source/helpers/blit_commands_helper_xehp_and_later.inl +++ b/shared/source/helpers/blit_commands_helper_xehp_and_later.inl @@ -84,9 +84,10 @@ void BlitCommandsHelper::appendSurfaceType(const BlitProperties &blit auto resInfo = blitProperties.srcAllocation->getDefaultGmm()->gmmResourceInfo.get(); auto resourceType = resInfo->getResourceType(); auto isArray = resInfo->getArraySize() > 1; + auto isTiled = resInfo->getResourceFlags()->Info.Tile4 || resInfo->getResourceFlags()->Info.Tile64; if (resourceType == GMM_RESOURCE_TYPE::RESOURCE_1D) { - if (isArray) { + if (isArray || isTiled) { blitCmd.setSourceSurfaceType(XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_2D); } else { blitCmd.setSourceSurfaceType(XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_1D); @@ -103,9 +104,10 @@ void BlitCommandsHelper::appendSurfaceType(const BlitProperties &blit auto resInfo = blitProperties.dstAllocation->getDefaultGmm()->gmmResourceInfo.get(); auto resourceType = resInfo->getResourceType(); auto isArray = resInfo->getArraySize() > 1; + auto isTiled = resInfo->getResourceFlags()->Info.Tile4 || resInfo->getResourceFlags()->Info.Tile64; if (resourceType == GMM_RESOURCE_TYPE::RESOURCE_1D) { - if (isArray) { + if (isArray || isTiled) { blitCmd.setDestinationSurfaceType(XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_2D); } else { blitCmd.setDestinationSurfaceType(XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_1D); diff --git a/shared/test/unit_test/helpers/test_blit_commands_helper_xehp_and_later.cpp b/shared/test/unit_test/helpers/test_blit_commands_helper_xehp_and_later.cpp index e82b0c45d8..5f02b70a3b 100644 --- a/shared/test/unit_test/helpers/test_blit_commands_helper_xehp_and_later.cpp +++ b/shared/test/unit_test/helpers/test_blit_commands_helper_xehp_and_later.cpp @@ -698,4 +698,80 @@ HWTEST2_F(BlitTests, givenXeHPOrAboveTiledResourcesWhenAppendSliceOffsetsIsCalle EXPECT_EQ(blitCmd.getDestinationArrayIndex(), sliceIndex + 1); EXPECT_EQ(blitCmd.getSourceArrayIndex(), sliceIndex + 1); +} + +HWTEST2_F(BlitTests, givenBltCmdWhenSrcAndDstImage1DTiled4ThenSrcAndDstTypeIs2D, IsAtLeastXeHpCoreAndNotXe2HpgCoreWith2DArrayImageSupport) { + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + + auto gmmSrc = std::make_unique(pDevice->getGmmHelper()); + auto resourceInfoSrc = static_cast(gmmSrc->gmmResourceInfo.get()); + resourceInfoSrc->getResourceFlags()->Info.Tile4 = 1; + resourceInfoSrc->mockResourceCreateParams.Type = GMM_RESOURCE_TYPE::RESOURCE_1D; + MockGraphicsAllocation mockAllocationSrc(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + MockGraphicsAllocation mockAllocationDst(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + BlitProperties properties{}; + mockAllocationSrc.setGmm(gmmSrc.get(), 0); + mockAllocationDst.setGmm(gmmSrc.get(), 0); + properties.srcAllocation = &mockAllocationSrc; + properties.dstAllocation = &mockAllocationDst; + + auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt; + NEO::BlitCommandsHelper::appendSurfaceType(properties, bltCmd); + EXPECT_EQ(bltCmd.getSourceSurfaceType(), XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_2D); + EXPECT_EQ(bltCmd.getDestinationSurfaceType(), XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_2D); +} + +HWTEST2_F(BlitTests, givenBltCmdWhenSrcAndDstImage1DTiled64ThenSrcAndDstTypeIs2D, IsAtLeastXeHpCoreAndNotXe2HpgCoreWith2DArrayImageSupport) { + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + + auto gmmSrc = std::make_unique(pDevice->getGmmHelper()); + auto resourceInfoSrc = static_cast(gmmSrc->gmmResourceInfo.get()); + resourceInfoSrc->getResourceFlags()->Info.Tile64 = 1; + resourceInfoSrc->mockResourceCreateParams.Type = GMM_RESOURCE_TYPE::RESOURCE_1D; + MockGraphicsAllocation mockAllocationSrc(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + MockGraphicsAllocation mockAllocationDst(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + BlitProperties properties{}; + mockAllocationSrc.setGmm(gmmSrc.get(), 0); + mockAllocationDst.setGmm(gmmSrc.get(), 0); + properties.srcAllocation = &mockAllocationSrc; + properties.dstAllocation = &mockAllocationDst; + + auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt; + NEO::BlitCommandsHelper::appendSurfaceType(properties, bltCmd); + EXPECT_EQ(bltCmd.getSourceSurfaceType(), XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_2D); + EXPECT_EQ(bltCmd.getDestinationSurfaceType(), XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_2D); +} + +HWTEST2_F(BlitTests, givenBltCmdWhenSrcAndDstImage1DNotTiledThenSrcAndDstTypeIs1D, IsAtLeastXeHpCoreAndNotXe2HpgCoreWith2DArrayImageSupport) { + using XY_BLOCK_COPY_BLT = typename FamilyType::XY_BLOCK_COPY_BLT; + + auto gmmSrc = std::make_unique(pDevice->getGmmHelper()); + auto resourceInfoSrc = static_cast(gmmSrc->gmmResourceInfo.get()); + resourceInfoSrc->getResourceFlags()->Info.Tile64 = 0; + resourceInfoSrc->getResourceFlags()->Info.Tile4 = 0; + resourceInfoSrc->mockResourceCreateParams.Type = GMM_RESOURCE_TYPE::RESOURCE_1D; + MockGraphicsAllocation mockAllocationSrc(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + MockGraphicsAllocation mockAllocationDst(0, 1u /*num gmms*/, AllocationType::internalHostMemory, + reinterpret_cast(0x1234), 0x1000, 0, sizeof(uint32_t), + MemoryPool::system4KBPages, MemoryManager::maxOsContextCount); + BlitProperties properties{}; + mockAllocationSrc.setGmm(gmmSrc.get(), 0); + mockAllocationDst.setGmm(gmmSrc.get(), 0); + properties.srcAllocation = &mockAllocationSrc; + properties.dstAllocation = &mockAllocationDst; + + auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt; + NEO::BlitCommandsHelper::appendSurfaceType(properties, bltCmd); + EXPECT_EQ(bltCmd.getSourceSurfaceType(), XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_1D); + EXPECT_EQ(bltCmd.getDestinationSurfaceType(), XY_BLOCK_COPY_BLT::SURFACE_TYPE::SURFACE_TYPE_SURFTYPE_1D); } \ No newline at end of file