From ce58cb07842cebe29ce1d2deb91a2b29577026de Mon Sep 17 00:00:00 2001 From: Bartosz Dunajski Date: Mon, 27 Jan 2025 17:09:07 +0000 Subject: [PATCH] refactor: unify blit mem set functions Related-To: NEO-13003 Signed-off-by: Bartosz Dunajski --- .../command_stream_receiver_hw_gen12lp.cpp | 22 ++----- shared/source/helpers/CMakeLists.txt | 2 + shared/source/helpers/blit_commands_helper.h | 6 +- .../helpers/blit_commands_helper_base.inl | 26 +++++++- .../blit_commands_helper_pvc_and_later.inl | 66 +++++++++++++++++++ .../blit_commands_helper_xe2_and_later.inl | 29 ++++++++ .../blit_commands_helper_xehp_and_later.inl | 20 ------ ...ommand_stream_receiver_hw_xe2_hpg_core.cpp | 60 +---------------- .../command_stream_receiver_hw_xe3_core.cpp | 58 +--------------- ...command_stream_receiver_hw_xe_hpc_core.cpp | 60 ++++------------- ...command_stream_receiver_hw_xe_hpg_core.cpp | 10 ++- 11 files changed, 156 insertions(+), 203 deletions(-) create mode 100644 shared/source/helpers/blit_commands_helper_pvc_and_later.inl create mode 100644 shared/source/helpers/blit_commands_helper_xe2_and_later.inl diff --git a/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp b/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp index 797f3cd4ac..f8d0262f2a 100644 --- a/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp +++ b/shared/source/gen12lp/command_stream_receiver_hw_gen12lp.cpp @@ -108,25 +108,13 @@ void BlitCommandsHelper::appendBlitCommandsForImages(const BlitPropertie } template <> -void BlitCommandsHelper::dispatchBlitMemoryColorFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, size_t patternSize, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment) { - switch (patternSize) { - case 1: - NEO::BlitCommandsHelper::dispatchBlitMemoryFill<1>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR); - break; - case 2: - NEO::BlitCommandsHelper::dispatchBlitMemoryFill<2>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR); - break; - case 4: - NEO::BlitCommandsHelper::dispatchBlitMemoryFill<4>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR); - break; - case 8: - NEO::BlitCommandsHelper::dispatchBlitMemoryFill<8>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_64_BIT_COLOR); - break; - default: - NEO::BlitCommandsHelper::dispatchBlitMemoryFill<16>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_128_BIT_COLOR); - } +void BlitCommandsHelper::dispatchBlitMemoryByteFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment) { + NEO::BlitCommandsHelper::dispatchBlitMemoryFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR, 1); } +template <> +void BlitCommandsHelper::appendBlitMemSetCompressionFormat(void *blitCmd, NEO::GraphicsAllocation *dstAlloc, uint32_t compressionFormat) {} + template <> void BlitCommandsHelper::appendBlitMemoryOptionsForFillBuffer(NEO::GraphicsAllocation *dstAlloc, typename Family::XY_COLOR_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) { } diff --git a/shared/source/helpers/CMakeLists.txt b/shared/source/helpers/CMakeLists.txt index ea8213c3c7..c3b656bdfa 100644 --- a/shared/source/helpers/CMakeLists.txt +++ b/shared/source/helpers/CMakeLists.txt @@ -210,12 +210,14 @@ endif() if(SUPPORT_PVC_AND_LATER) list(APPEND NEO_CORE_HELPERS + ${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_pvc_and_later.inl ${CMAKE_CURRENT_SOURCE_DIR}/gfx_core_helper_pvc_and_later.inl ) endif() if(SUPPORT_XE2_AND_LATER) list(APPEND NEO_CORE_HELPERS + ${CMAKE_CURRENT_SOURCE_DIR}/blit_commands_helper_xe2_and_later.inl ${CMAKE_CURRENT_SOURCE_DIR}/gfx_core_helper_xe2_and_later.inl ) endif() diff --git a/shared/source/helpers/blit_commands_helper.h b/shared/source/helpers/blit_commands_helper.h index 1ed069a538..76dc015b4e 100644 --- a/shared/source/helpers/blit_commands_helper.h +++ b/shared/source/helpers/blit_commands_helper.h @@ -50,8 +50,8 @@ struct BlitCommandsHelper { static void dispatchBlitCommandsForBufferPerRow(const BlitProperties &blitProperties, LinearStream &linearStream, RootDeviceEnvironment &rootDeviceEnvironment); static void dispatchBlitCommandsForImageRegion(const BlitProperties &blitProperties, LinearStream &linearStream, RootDeviceEnvironment &rootDeviceEnvironment); static void dispatchBlitMemoryColorFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, size_t patternSize, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment); - template - static void dispatchBlitMemoryFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth); + static void dispatchBlitMemoryByteFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment); + static void dispatchBlitMemoryFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth, size_t patternSize); static void dispatchDummyBlit(LinearStream &linearStream, EncodeDummyBlitWaArgs &waArgs); static size_t getDummyBlitSize(const EncodeDummyBlitWaArgs &waArgs); static bool isDummyBlitWaNeeded(const EncodeDummyBlitWaArgs &waArgs); @@ -68,6 +68,8 @@ struct BlitCommandsHelper { static void appendColorDepth(const BlitProperties &blitProperties, T &blitCmd); static void appendBlitMemoryOptionsForFillBuffer(NEO::GraphicsAllocation *dstAlloc, typename GfxFamily::XY_COLOR_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment); static void appendBlitFillCommand(typename GfxFamily::XY_COLOR_BLT &blitCmd); + static void appendBlitMemSetCompressionFormat(void *blitCmd, NEO::GraphicsAllocation *dstAlloc, uint32_t compressionFormat); + static void appendBlitMemSetCommand(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); diff --git a/shared/source/helpers/blit_commands_helper_base.inl b/shared/source/helpers/blit_commands_helper_base.inl index 3b26af2b98..251ddf65be 100644 --- a/shared/source/helpers/blit_commands_helper_base.inl +++ b/shared/source/helpers/blit_commands_helper_base.inl @@ -253,8 +253,10 @@ void BlitCommandsHelper::dispatchBlitCommandsForBufferPerRow(const Bl } template -template -void BlitCommandsHelper::dispatchBlitMemoryFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth) { +void BlitCommandsHelper::appendBlitMemSetCommand(void *blitCmd) {} + +template +void BlitCommandsHelper::dispatchBlitMemoryFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth, size_t patternSize) { using XY_COLOR_BLT = typename GfxFamily::XY_COLOR_BLT; auto blitCmd = GfxFamily::cmdInitXyColorBlt; const auto maxWidth = getMaxBlitWidth(rootDeviceEnvironment); @@ -554,4 +556,24 @@ void BlitCommandsHelper::adjustControlSurfaceType(const BlitPropertie template void BlitCommandsHelper::appendBlitFillCommand(typename GfxFamily::XY_COLOR_BLT &blitCmd) {} +template +void BlitCommandsHelper::dispatchBlitMemoryColorFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, size_t patternSize, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment) { + switch (patternSize) { + case 1: + NEO::BlitCommandsHelper::dispatchBlitMemoryByteFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment); + break; + case 2: + NEO::BlitCommandsHelper::dispatchBlitMemoryFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR, 2); + break; + case 4: + NEO::BlitCommandsHelper::dispatchBlitMemoryFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR, 4); + break; + case 8: + NEO::BlitCommandsHelper::dispatchBlitMemoryFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_64_BIT_COLOR, 8); + break; + default: + NEO::BlitCommandsHelper::dispatchBlitMemoryFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_128_BIT_COLOR, 16); + } +} + } // namespace NEO diff --git a/shared/source/helpers/blit_commands_helper_pvc_and_later.inl b/shared/source/helpers/blit_commands_helper_pvc_and_later.inl new file mode 100644 index 0000000000..7ded6974f4 --- /dev/null +++ b/shared/source/helpers/blit_commands_helper_pvc_and_later.inl @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/gmm_helper/gmm_helper.h" +#include "shared/source/gmm_helper/resource_info.h" +#include "shared/source/helpers/blit_commands_helper.h" + +namespace NEO { + +template +void BlitCommandsHelper::dispatchBlitMemoryByteFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment) { + using MEM_SET = typename Family::MEM_SET; + auto blitCmd = Family::cmdInitMemSet; + + auto mocs = rootDeviceEnvironment.getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); + if (debugManager.flags.OverrideBlitterMocs.get() != -1) { + mocs = static_cast(debugManager.flags.OverrideBlitterMocs.get()); + } + blitCmd.setDestinationMOCS(mocs); + + uint32_t compressionFormat = 0; + if (dstAlloc->isCompressionEnabled()) { + auto resourceFormat = dstAlloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); + compressionFormat = static_cast(rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat)); + } + + appendBlitMemSetCompressionFormat(&blitCmd, dstAlloc, compressionFormat); + + blitCmd.setFillData(*pattern); + + auto sizeToFill = size; + while (sizeToFill != 0) { + auto tmpCmd = blitCmd; + tmpCmd.setDestinationStartAddress(ptrOffset(dstAlloc->getGpuAddress(), static_cast(offset))); + size_t height = 0; + size_t width = 0; + if (sizeToFill <= BlitterConstants::maxBlitSetWidth) { + width = sizeToFill; + height = 1; + } else { + width = BlitterConstants::maxBlitSetWidth; + height = std::min((sizeToFill / width), BlitterConstants::maxBlitSetHeight); + if (height > 1) { + tmpCmd.setFillType(MEM_SET::FILL_TYPE::FILL_TYPE_MATRIX_FILL); + } + } + tmpCmd.setFillWidth(static_cast(width)); + tmpCmd.setFillHeight(static_cast(height)); + tmpCmd.setDestinationPitch(static_cast(width)); + + appendBlitMemSetCommand(&tmpCmd); + + auto cmd = linearStream.getSpaceForCmd(); + *cmd = tmpCmd; + + auto blitSize = width * height; + offset += blitSize; + sizeToFill -= blitSize; + } +} + +} // namespace NEO diff --git a/shared/source/helpers/blit_commands_helper_xe2_and_later.inl b/shared/source/helpers/blit_commands_helper_xe2_and_later.inl new file mode 100644 index 0000000000..b0ba2e33b1 --- /dev/null +++ b/shared/source/helpers/blit_commands_helper_xe2_and_later.inl @@ -0,0 +1,29 @@ +/* + * Copyright (C) 2025 Intel Corporation + * + * SPDX-License-Identifier: MIT + * + */ + +#include "shared/source/helpers/blit_commands_helper.h" + +namespace NEO { + +template +void BlitCommandsHelper::appendBlitMemSetCompressionFormat(void *blitCmd, NEO::GraphicsAllocation *dstAlloc, uint32_t compressionFormat) { + using MEM_SET = typename Family::MEM_SET; + + auto memSetCmd = reinterpret_cast(blitCmd); + + if (dstAlloc->isCompressionEnabled()) { + memSetCmd->setCompressionFormat(compressionFormat); + } + + if (debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.get()) { + if (!MemoryPoolHelper::isSystemMemoryPool(dstAlloc->getMemoryPool())) { + memSetCmd->setCompressionFormat(debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()); + } + } +} + +} // namespace NEO 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 246f781f9f..872747a40b 100644 --- a/shared/source/helpers/blit_commands_helper_xehp_and_later.inl +++ b/shared/source/helpers/blit_commands_helper_xehp_and_later.inl @@ -76,26 +76,6 @@ void BlitCommandsHelper::appendBlitMemoryOptionsForFillBuffer(NEO::Gr } } -template -void BlitCommandsHelper::dispatchBlitMemoryColorFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, size_t patternSize, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment) { - switch (patternSize) { - case 1: - NEO::BlitCommandsHelper::dispatchBlitMemoryFill<1>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR); - break; - case 2: - NEO::BlitCommandsHelper::dispatchBlitMemoryFill<2>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR); - break; - case 4: - NEO::BlitCommandsHelper::dispatchBlitMemoryFill<4>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR); - break; - case 8: - NEO::BlitCommandsHelper::dispatchBlitMemoryFill<8>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_64_BIT_COLOR); - break; - default: - NEO::BlitCommandsHelper::dispatchBlitMemoryFill<16>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_128_BIT_COLOR); - } -} - template void BlitCommandsHelper::appendSurfaceType(const BlitProperties &blitProperties, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd) { using XY_BLOCK_COPY_BLT = typename GfxFamily::XY_BLOCK_COPY_BLT; diff --git a/shared/source/xe2_hpg_core/command_stream_receiver_hw_xe2_hpg_core.cpp b/shared/source/xe2_hpg_core/command_stream_receiver_hw_xe2_hpg_core.cpp index e5f159e856..b19dd3d385 100644 --- a/shared/source/xe2_hpg_core/command_stream_receiver_hw_xe2_hpg_core.cpp +++ b/shared/source/xe2_hpg_core/command_stream_receiver_hw_xe2_hpg_core.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2024 Intel Corporation + * Copyright (C) 2024-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -15,6 +15,8 @@ using Family = NEO::Xe2HpgCoreFamily; #include "shared/source/command_stream/command_stream_receiver_hw_heap_addressing.inl" #include "shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl" #include "shared/source/gmm_helper/gmm.h" +#include "shared/source/helpers/blit_commands_helper_pvc_and_later.inl" +#include "shared/source/helpers/blit_commands_helper_xe2_and_later.inl" #include "shared/source/helpers/blit_commands_helper_xehp_and_later.inl" #include "shared/source/helpers/blit_properties.h" #include "shared/source/helpers/populate_factory.h" @@ -186,62 +188,6 @@ void BlitCommandsHelper::appendBlitCommandsMemCopy(const BlitProperties DEBUG_BREAK_IF(AuxTranslationDirection::none != blitProperties.auxTranslationDirection); } -template <> -template <> -void BlitCommandsHelper::dispatchBlitMemoryFill<1>(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth) { - using MEM_SET = typename Family::MEM_SET; - using COMPRESSION_FORMAT30 = typename MEM_SET::COMPRESSION_FORMAT30; - auto blitCmd = Family::cmdInitMemSet; - - auto mocs = rootDeviceEnvironment.getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); - if (debugManager.flags.OverrideBlitterMocs.get() != -1) { - mocs = static_cast(debugManager.flags.OverrideBlitterMocs.get()); - } - blitCmd.setDestinationMOCS(mocs); - - if (dstAlloc->isCompressionEnabled()) { - auto resourceFormat = dstAlloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); - auto compressionFormat = static_cast(rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat)); - blitCmd.setCompressionFormat(compressionFormat); - } - - if (debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.get()) { - if (!MemoryPoolHelper::isSystemMemoryPool(dstAlloc->getMemoryPool())) { - blitCmd.setCompressionFormat(debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()); - } - } - - blitCmd.setFillData(*pattern); - - auto sizeToFill = size; - while (sizeToFill != 0) { - auto tmpCmd = blitCmd; - tmpCmd.setDestinationStartAddress(ptrOffset(dstAlloc->getGpuAddress(), static_cast(offset))); - size_t height = 0; - size_t width = 0; - if (sizeToFill <= BlitterConstants::maxBlitSetWidth) { - width = sizeToFill; - height = 1; - } else { - width = BlitterConstants::maxBlitSetWidth; - height = std::min((sizeToFill / width), BlitterConstants::maxBlitSetHeight); - if (height > 1) { - tmpCmd.setFillType(MEM_SET::FILL_TYPE::FILL_TYPE_MATRIX_FILL); - } - } - tmpCmd.setFillWidth(static_cast(width)); - tmpCmd.setFillHeight(static_cast(height)); - tmpCmd.setDestinationPitch(static_cast(width)); - - auto cmd = linearStream.getSpaceForCmd(); - *cmd = tmpCmd; - - auto blitSize = width * height; - offset += blitSize; - sizeToFill -= blitSize; - } -} - template <> void BlitCommandsHelper::encodeProfilingStartMmios(LinearStream &cmdStream, const TagNodeBase ×tampPacketNode) { auto timestampContextStartGpuAddress = TimestampPacketHelper::getContextStartGpuAddress(timestampPacketNode); diff --git a/shared/source/xe3_core/command_stream_receiver_hw_xe3_core.cpp b/shared/source/xe3_core/command_stream_receiver_hw_xe3_core.cpp index 8a42d5d48b..2b0e86a4ad 100644 --- a/shared/source/xe3_core/command_stream_receiver_hw_xe3_core.cpp +++ b/shared/source/xe3_core/command_stream_receiver_hw_xe3_core.cpp @@ -14,6 +14,8 @@ using Family = NEO::Xe3CoreFamily; #include "shared/source/command_stream/command_stream_receiver_hw_heap_addressing.inl" #include "shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl" #include "shared/source/gmm_helper/gmm.h" +#include "shared/source/helpers/blit_commands_helper_pvc_and_later.inl" +#include "shared/source/helpers/blit_commands_helper_xe2_and_later.inl" #include "shared/source/helpers/blit_commands_helper_xehp_and_later.inl" #include "shared/source/helpers/constants.h" #include "shared/source/helpers/populate_factory.h" @@ -184,62 +186,6 @@ void BlitCommandsHelper::appendBlitCommandsMemCopy(const BlitProperties DEBUG_BREAK_IF(AuxTranslationDirection::none != blitProperties.auxTranslationDirection); } -template <> -template <> -void BlitCommandsHelper::dispatchBlitMemoryFill<1>(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth) { - using MEM_SET = typename Family::MEM_SET; - using COMPRESSION_FORMAT30 = typename MEM_SET::COMPRESSION_FORMAT30; - auto blitCmd = Family::cmdInitMemSet; - - auto mocs = rootDeviceEnvironment.getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); - if (debugManager.flags.OverrideBlitterMocs.get() != -1) { - mocs = static_cast(debugManager.flags.OverrideBlitterMocs.get()); - } - blitCmd.setDestinationMOCS(mocs); - - if (dstAlloc->isCompressionEnabled()) { - auto resourceFormat = dstAlloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); - auto compressionFormat = static_cast(rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat)); - blitCmd.setCompressionFormat(compressionFormat); - } - - if (debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.get()) { - if (!MemoryPoolHelper::isSystemMemoryPool(dstAlloc->getMemoryPool())) { - blitCmd.setCompressionFormat(debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()); - } - } - - blitCmd.setFillData(*pattern); - - auto sizeToFill = size; - while (sizeToFill != 0) { - auto tmpCmd = blitCmd; - tmpCmd.setDestinationStartAddress(ptrOffset(dstAlloc->getGpuAddress(), static_cast(offset))); - size_t height = 0; - size_t width = 0; - if (sizeToFill <= BlitterConstants::maxBlitSetWidth) { - width = sizeToFill; - height = 1; - } else { - width = BlitterConstants::maxBlitSetWidth; - height = std::min((sizeToFill / width), BlitterConstants::maxBlitSetHeight); - if (height > 1) { - tmpCmd.setFillType(MEM_SET::FILL_TYPE::FILL_TYPE_MATRIX_FILL); - } - } - tmpCmd.setFillWidth(static_cast(width)); - tmpCmd.setFillHeight(static_cast(height)); - tmpCmd.setDestinationPitch(static_cast(width)); - - auto cmd = linearStream.getSpaceForCmd(); - *cmd = tmpCmd; - - auto blitSize = width * height; - offset += blitSize; - sizeToFill -= blitSize; - } -} - template <> void BlitCommandsHelper::encodeProfilingStartMmios(LinearStream &cmdStream, const TagNodeBase ×tampPacketNode) { auto timestampContextStartGpuAddress = TimestampPacketHelper::getContextStartGpuAddress(timestampPacketNode); 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 f3cdf3029c..dbeb395a0b 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 @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2024 Intel Corporation + * Copyright (C) 2021-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -16,6 +16,7 @@ using Family = NEO::XeHpcCoreFamily; #include "shared/source/command_stream/command_stream_receiver_hw_heap_addressing.inl" #include "shared/source/command_stream/command_stream_receiver_hw_xehp_and_later.inl" #include "shared/source/gmm_helper/gmm.h" +#include "shared/source/helpers/blit_commands_helper_pvc_and_later.inl" #include "shared/source/helpers/blit_commands_helper_xehp_and_later.inl" #include "shared/source/helpers/blit_properties.h" #include "shared/source/helpers/populate_factory.h" @@ -136,64 +137,27 @@ void BlitCommandsHelper::appendBlitCommandsMemCopy(const BlitProperties } template <> -template <> -void BlitCommandsHelper::dispatchBlitMemoryFill<1>(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth) { +void BlitCommandsHelper::appendBlitMemSetCompressionFormat(void *blitCmd, NEO::GraphicsAllocation *dstAlloc, uint32_t compressionFormat) { using MEM_SET = typename Family::MEM_SET; - auto blitCmd = Family::cmdInitMemSet; - auto mocs = rootDeviceEnvironment.getGmmHelper()->getMOCS(GMM_RESOURCE_USAGE_OCL_BUFFER); - if (debugManager.flags.OverrideBlitterMocs.get() != -1) { - mocs = static_cast(debugManager.flags.OverrideBlitterMocs.get()); - } - - blitCmd.setDestinationMOCS(mocs); + auto memSetCmd = reinterpret_cast(blitCmd); if (dstAlloc->isCompressionEnabled()) { - auto resourceFormat = dstAlloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat(); - auto compressionFormat = rootDeviceEnvironment.getGmmClientContext()->getSurfaceStateCompressionFormat(resourceFormat); - blitCmd.setDestinationCompressible(MEM_SET::DESTINATION_COMPRESSIBLE::DESTINATION_COMPRESSIBLE_COMPRESSIBLE); - blitCmd.setCompressionFormat40(compressionFormat); + memSetCmd->setDestinationCompressible(MEM_SET::DESTINATION_COMPRESSIBLE::DESTINATION_COMPRESSIBLE_COMPRESSIBLE); + memSetCmd->setCompressionFormat40(compressionFormat); } + if (debugManager.flags.EnableStatelessCompressionWithUnifiedMemory.get()) { if (!MemoryPoolHelper::isSystemMemoryPool(dstAlloc->getMemoryPool())) { - blitCmd.setDestinationCompressible(MEM_SET::DESTINATION_COMPRESSIBLE::DESTINATION_COMPRESSIBLE_COMPRESSIBLE); - blitCmd.setCompressionFormat40(debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()); + memSetCmd->setDestinationCompressible(MEM_SET::DESTINATION_COMPRESSIBLE::DESTINATION_COMPRESSIBLE_COMPRESSIBLE); + memSetCmd->setCompressionFormat40(debugManager.flags.FormatForStatelessCompressionWithUnifiedMemory.get()); } } - if (blitCmd.getDestinationCompressible() == MEM_SET::DESTINATION_COMPRESSIBLE::DESTINATION_COMPRESSIBLE_COMPRESSIBLE) { - blitCmd.setDestinationCompressionEnable(MEM_SET::DESTINATION_COMPRESSION_ENABLE::DESTINATION_COMPRESSION_ENABLE_ENABLE); + if (memSetCmd->getDestinationCompressible() == MEM_SET::DESTINATION_COMPRESSIBLE::DESTINATION_COMPRESSIBLE_COMPRESSIBLE) { + memSetCmd->setDestinationCompressionEnable(MEM_SET::DESTINATION_COMPRESSION_ENABLE::DESTINATION_COMPRESSION_ENABLE_ENABLE); } else { - blitCmd.setDestinationCompressionEnable(MEM_SET::DESTINATION_COMPRESSION_ENABLE::DESTINATION_COMPRESSION_ENABLE_DISABLE); - } - blitCmd.setFillData(*pattern); - - auto sizeToFill = size; - while (sizeToFill != 0) { - auto tmpCmd = blitCmd; - tmpCmd.setDestinationStartAddress(ptrOffset(dstAlloc->getGpuAddress(), static_cast(offset))); - size_t height = 0; - size_t width = 0; - if (sizeToFill <= BlitterConstants::maxBlitSetWidth) { - width = sizeToFill; - height = 1; - } else { - width = BlitterConstants::maxBlitSetWidth; - height = std::min((sizeToFill / width), BlitterConstants::maxBlitSetHeight); - if (height > 1) { - tmpCmd.setFillType(MEM_SET::FILL_TYPE::FILL_TYPE_MATRIX_FILL); - } - } - tmpCmd.setFillWidth(static_cast(width)); - tmpCmd.setFillHeight(static_cast(height)); - tmpCmd.setDestinationPitch(static_cast(width)); - - auto cmd = linearStream.getSpaceForCmd(); - *cmd = tmpCmd; - - auto blitSize = width * height; - offset += blitSize; - sizeToFill -= blitSize; + memSetCmd->setDestinationCompressionEnable(MEM_SET::DESTINATION_COMPRESSION_ENABLE::DESTINATION_COMPRESSION_ENABLE_DISABLE); } } diff --git a/shared/source/xe_hpg_core/command_stream_receiver_hw_xe_hpg_core.cpp b/shared/source/xe_hpg_core/command_stream_receiver_hw_xe_hpg_core.cpp index 8e01b68d20..c4efed4f2f 100644 --- a/shared/source/xe_hpg_core/command_stream_receiver_hw_xe_hpg_core.cpp +++ b/shared/source/xe_hpg_core/command_stream_receiver_hw_xe_hpg_core.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2021-2024 Intel Corporation + * Copyright (C) 2021-2025 Intel Corporation * * SPDX-License-Identifier: MIT * @@ -149,6 +149,14 @@ void BlitCommandsHelper::appendBlitCommandsBlockCopy(const BlitPropertie } } +template <> +void BlitCommandsHelper::dispatchBlitMemoryByteFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment) { + NEO::BlitCommandsHelper::dispatchBlitMemoryFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR, 1); +} + +template <> +void BlitCommandsHelper::appendBlitMemSetCompressionFormat(void *blitCmd, NEO::GraphicsAllocation *dstAlloc, uint32_t compressionFormat) {} + template class CommandStreamReceiverHw; template struct BlitCommandsHelper; template void BlitCommandsHelper::appendColorDepth(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd);