From 95f69a51078de41e1c8be05bf8b097d6d6890691 Mon Sep 17 00:00:00 2001 From: Mateusz Jablonski Date: Tue, 21 Oct 2025 16:53:38 +0000 Subject: [PATCH] refactor: reduce usage of gmmlib headers use own ImageTilingMode wrapper Signed-off-by: Mateusz Jablonski --- .../command_stream_receiver_hw_gen12lp.cpp | 8 +++---- shared/source/gmm_helper/gmm_wrappers.cpp | 7 ++++++ shared/source/helpers/blit_commands_helper.h | 6 ++--- .../blit_commands_helper_xehp_and_later.inl | 24 +++++++++---------- shared/source/helpers/surface_format_info.h | 10 ++++---- ...command_stream_receiver_hw_xe_hpc_core.cpp | 2 +- ...est_blit_commands_helper_pvc_and_later.cpp | 2 +- ...st_blit_commands_helper_xehp_and_later.cpp | 2 +- 8 files changed, 34 insertions(+), 27 deletions(-) diff --git a/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp b/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp index 5bf43613e2..7b4ff0528d 100644 --- a/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp +++ b/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp @@ -180,12 +180,12 @@ void BlitCommandsHelper::appendTilingEnable(typename GfxFamily::XY_CO } template -void BlitCommandsHelper::appendTilingType(const GMM_TILE_TYPE srcTilingType, const GMM_TILE_TYPE dstTilingType, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd) { +void BlitCommandsHelper::appendTilingType(ImageTilingMode srcTilingType, ImageTilingMode dstTilingType, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd) { } template void BlitCommandsHelper::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, - GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, + ImageTilingMode &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment, ImagePlane plane) { } @@ -266,7 +266,7 @@ void BlitCommandsHelper::appendColorDepth(const BlitProperties &blitProp template <> void BlitCommandsHelper::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, - GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, + ImageTilingMode &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment, ImagePlane plane) { if (allocation.getDefaultGmm()) { auto gmmResourceInfo = allocation.getDefaultGmm()->gmmResourceInfo.get(); @@ -288,7 +288,7 @@ void BlitCommandsHelper::appendSliceOffsets(const BlitProperties &blitPr template <> void BlitCommandsHelper::appendBlitCommandsForImages(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t &srcSlicePitch, uint32_t &dstSlicePitch) { - auto tileType = GMM_NOT_TILED; + auto tileType = ImageTilingMode::notTiled; auto srcAllocation = blitProperties.srcAllocation; auto dstAllocation = blitProperties.dstAllocation; auto srcQPitch = static_cast(blitProperties.srcSize.y); diff --git a/shared/source/gmm_helper/gmm_wrappers.cpp b/shared/source/gmm_helper/gmm_wrappers.cpp index 7b7657ec52..2928214a57 100644 --- a/shared/source/gmm_helper/gmm_wrappers.cpp +++ b/shared/source/gmm_helper/gmm_wrappers.cpp @@ -15,4 +15,11 @@ static_assert(static_cast(ImagePlane::planeU) == GMM_PLANE_U); static_assert(static_cast(ImagePlane::planeV) == GMM_PLANE_V); static_assert(static_cast(gmmNoCubeMap) == __GMM_NO_CUBE_MAP); + +static_assert(static_cast(ImageTilingMode::tiledX) == GMM_TILED_X); +static_assert(static_cast(ImageTilingMode::tiledY) == GMM_TILED_Y); +static_assert(static_cast(ImageTilingMode::tiledW) == GMM_TILED_W); +static_assert(static_cast(ImageTilingMode::notTiled) == GMM_NOT_TILED); +static_assert(static_cast(ImageTilingMode::tiled4) == GMM_TILED_4); +static_assert(static_cast(ImageTilingMode::tiled64) == GMM_TILED_64); } // namespace NEO diff --git a/shared/source/helpers/blit_commands_helper.h b/shared/source/helpers/blit_commands_helper.h index 57c7d6d9d2..a9f685f3a9 100644 --- a/shared/source/helpers/blit_commands_helper.h +++ b/shared/source/helpers/blit_commands_helper.h @@ -6,7 +6,6 @@ */ #pragma once -#include "shared/source/gmm_helper/gmm_lib.h" #include "shared/source/helpers/blit_properties_container.h" #include "shared/source/helpers/vec.h" @@ -15,6 +14,7 @@ namespace NEO { enum class ImagePlane; +enum class ImageTilingMode; class CsrDependencies; class GraphicsAllocation; class LinearStream; @@ -82,10 +82,10 @@ struct BlitCommandsHelper { static void appendBlitMemSetCommand(const BlitProperties &blitProperties, void *blitCmd); static void appendSurfaceType(const BlitProperties &blitProperties, typename GfxFamily::XY_BLOCK_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_BLOCK_COPY_BLT &blitCmd); + static void appendTilingType(ImageTilingMode srcTilingType, ImageTilingMode dstTilingType, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd); static void appendSliceOffsets(const BlitProperties &blitProperties, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd, uint32_t sliceIndex, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t srcSlicePitch, uint32_t dstSlicePitch); static void appendBaseAddressOffset(const BlitProperties &blitProperties, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd, const bool isSource); - static void getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, GMM_TILE_TYPE &tileType, + static void getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, ImageTilingMode &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment, ImagePlane plane); static void dispatchDebugPauseCommands(LinearStream &commandStream, uint64_t debugPauseStateGPUAddress, DebugPauseState confirmationTrigger, 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 7ac7677a4f..ddf1508e80 100644 --- a/shared/source/helpers/blit_commands_helper_xehp_and_later.inl +++ b/shared/source/helpers/blit_commands_helper_xehp_and_later.inl @@ -121,19 +121,19 @@ void BlitCommandsHelper::appendSurfaceType(const BlitProperties &blit } template -void BlitCommandsHelper::appendTilingType(const GMM_TILE_TYPE srcTilingType, const GMM_TILE_TYPE dstTilingType, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd) { +void BlitCommandsHelper::appendTilingType(ImageTilingMode srcTilingType, ImageTilingMode dstTilingType, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd) { using XY_BLOCK_COPY_BLT = typename GfxFamily::XY_BLOCK_COPY_BLT; UNRECOVERABLE_IF((srcTilingType != dstTilingType) && blitCmd.getSpecialModeOfOperation() == XY_BLOCK_COPY_BLT::SPECIAL_MODE_OF_OPERATION::SPECIAL_MODE_OF_OPERATION_FULL_RESOLVE); - if (srcTilingType == GMM_TILED_4) { + if (srcTilingType == ImageTilingMode::tiled4) { blitCmd.setSourceTiling(XY_BLOCK_COPY_BLT::TILING::TILING_TILE4); - } else if (srcTilingType == GMM_TILED_64) { + } else if (srcTilingType == ImageTilingMode::tiled64) { blitCmd.setSourceTiling(XY_BLOCK_COPY_BLT::TILING::TILING_TILE64); } else { blitCmd.setSourceTiling(XY_BLOCK_COPY_BLT::TILING::TILING_LINEAR); } - if (dstTilingType == GMM_TILED_4) { + if (dstTilingType == ImageTilingMode::tiled4) { blitCmd.setDestinationTiling(XY_BLOCK_COPY_BLT::TILING::TILING_TILE4); - } else if (dstTilingType == GMM_TILED_64) { + } else if (dstTilingType == ImageTilingMode::tiled64) { blitCmd.setDestinationTiling(XY_BLOCK_COPY_BLT::TILING::TILING_TILE64); } else { blitCmd.setDestinationTiling(XY_BLOCK_COPY_BLT::TILING::TILING_LINEAR); @@ -170,16 +170,16 @@ void BlitCommandsHelper::appendColorDepth(const BlitProperties &blitP template void BlitCommandsHelper::getBlitAllocationProperties(const GraphicsAllocation &allocation, uint32_t &pitch, uint32_t &qPitch, - GMM_TILE_TYPE &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, + ImageTilingMode &tileType, uint32_t &mipTailLod, uint32_t &compressionDetails, const RootDeviceEnvironment &rootDeviceEnvironment, ImagePlane plane) { if (allocation.getDefaultGmm()) { auto gmmResourceInfo = allocation.getDefaultGmm()->gmmResourceInfo.get(); mipTailLod = gmmResourceInfo->getMipTailStartLODSurfaceState(); auto resInfo = gmmResourceInfo->getResourceFlags()->Info; if (resInfo.Tile4) { - tileType = GMM_TILED_4; + tileType = ImageTilingMode::tiled4; } else if (resInfo.Tile64) { - tileType = GMM_TILED_64; + tileType = ImageTilingMode::tiled64; } if (!resInfo.Linear) { @@ -199,8 +199,8 @@ void BlitCommandsHelper::getBlitAllocationProperties(const GraphicsAl template void BlitCommandsHelper::appendBlitCommandsForImages(const BlitProperties &blitProperties, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t &srcSlicePitch, uint32_t &dstSlicePitch) { - auto srcTileType = GMM_NOT_TILED; - auto dstTileType = GMM_NOT_TILED; + auto srcTileType = ImageTilingMode::notTiled; + auto dstTileType = ImageTilingMode::notTiled; auto srcAllocation = blitProperties.srcAllocation; auto dstAllocation = blitProperties.dstAllocation; auto srcRowPitch = static_cast(blitProperties.srcRowPitch); @@ -224,8 +224,8 @@ void BlitCommandsHelper::appendBlitCommandsForImages(const BlitProper srcSlicePitch = std::max(srcSlicePitch, srcRowPitch * srcQPitch); dstSlicePitch = std::max(dstSlicePitch, dstRowPitch * dstQPitch); - blitCmd.setSourcePitch(srcTileType == GMM_NOT_TILED ? srcRowPitch : srcRowPitch / 4); - blitCmd.setDestinationPitch(dstTileType == GMM_NOT_TILED ? dstRowPitch : dstRowPitch / 4); + blitCmd.setSourcePitch(srcTileType == ImageTilingMode::notTiled ? srcRowPitch : srcRowPitch / 4); + blitCmd.setDestinationPitch(dstTileType == ImageTilingMode::notTiled ? dstRowPitch : dstRowPitch / 4); blitCmd.setSourceSurfaceQpitch(srcQPitch / 4); blitCmd.setDestinationSurfaceQpitch(dstQPitch / 4); blitCmd.setSourceMipTailStartLOD(srcMipTailLod); diff --git a/shared/source/helpers/surface_format_info.h b/shared/source/helpers/surface_format_info.h index e53235fc61..2036711ea2 100644 --- a/shared/source/helpers/surface_format_info.h +++ b/shared/source/helpers/surface_format_info.h @@ -233,14 +233,14 @@ struct ImageDescriptor { }; enum class ImageTilingMode { - tiledAuto = 0, - tiledW, tiledX, tiledY, - tiledYf, - tiledYs, + tiledW, + notTiled, tiled4, tiled64, + tiledYf, + tiledYs, }; struct ImageInfo { @@ -260,7 +260,7 @@ struct ImageInfo { bool linearStorage; bool useLocalMemory; bool isDisplayable; - ImageTilingMode forceTiling; + ImageTilingMode forceTiling = ImageTilingMode::notTiled; }; struct ImageImplicitArgs { diff --git a/shared/source/xe_hpc_core/command_stream_receiver_hw_xe_hpc_core.cpp b/shared/source/xe_hpc_core/command_stream_receiver_hw_xe_hpc_core.cpp index 9e6e811dab..0f498c79b6 100644 --- a/shared/source/xe_hpc_core/command_stream_receiver_hw_xe_hpc_core.cpp +++ b/shared/source/xe_hpc_core/command_stream_receiver_hw_xe_hpc_core.cpp @@ -174,7 +174,7 @@ template <> void BlitCommandsHelper::appendBlitCommandsForImages(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t &srcSlicePitch, uint32_t &dstSlicePitch) {} template <> -void BlitCommandsHelper::appendTilingType(const GMM_TILE_TYPE srcTilingType, const GMM_TILE_TYPE dstTilingType, typename Family::XY_BLOCK_COPY_BLT &blitCmd) {} +void BlitCommandsHelper::appendTilingType(ImageTilingMode srcTilingType, ImageTilingMode dstTilingType, typename Family::XY_BLOCK_COPY_BLT &blitCmd) {} template <> void BlitCommandsHelper::appendSliceOffsets(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd, uint32_t sliceIndex, const RootDeviceEnvironment &rootDeviceEnvironment, uint32_t srcSlicePitch, uint32_t dstSlicePitch) {} diff --git a/shared/test/unit_test/helpers/test_blit_commands_helper_pvc_and_later.cpp b/shared/test/unit_test/helpers/test_blit_commands_helper_pvc_and_later.cpp index d1b08bdbab..575d01fd7e 100644 --- a/shared/test/unit_test/helpers/test_blit_commands_helper_pvc_and_later.cpp +++ b/shared/test/unit_test/helpers/test_blit_commands_helper_pvc_and_later.cpp @@ -388,7 +388,7 @@ HWTEST2_F(BlitTests, givenBlockCopyCommandWhenAppendTilingTypeThenNothingChanged auto bltCmd = FamilyType::cmdInitXyBlockCopyBlt; auto bltCmdBefore = bltCmd; BlitProperties properties = {}; - NEO::BlitCommandsHelper::appendTilingType(GMM_NOT_TILED, GMM_NOT_TILED, bltCmd); + NEO::BlitCommandsHelper::appendTilingType(ImageTilingMode::notTiled, ImageTilingMode::notTiled, bltCmd); EXPECT_EQ(memcmp(&bltCmd, &bltCmdBefore, sizeof(XY_BLOCK_COPY_BLT)), 0); } HWTEST2_F(BlitTests, givenCopyCommandListWhenBytesPerPixelIsCalledForNonBlitCopySupportedPlatformThenExpectOne, IsXeHpcCore) { 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 af0b8c239c..8e5cd60a81 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 @@ -271,7 +271,7 @@ HWTEST2_F(BlitTests, givenPlaneWhenGetBlitAllocationPropertiesIsCalledThenCompre BlitProperties properties = {}; properties.srcAllocation = &mockAllocationSrc; uint32_t qPitch = static_cast(properties.copySize.y); - GMM_TILE_TYPE tileType = GMM_NOT_TILED; + auto tileType = ImageTilingMode::notTiled; uint32_t mipTailLod = 0; uint32_t compressionFormat = 0; auto rowPitch = static_cast(properties.srcRowPitch);