refactor: unify blit mem set functions

Related-To: NEO-13003

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2025-01-27 17:09:07 +00:00
committed by Compute-Runtime-Automation
parent 105703b1ae
commit ce58cb0784
11 changed files with 156 additions and 203 deletions

View File

@@ -108,25 +108,13 @@ void BlitCommandsHelper<Family>::appendBlitCommandsForImages(const BlitPropertie
}
template <>
void BlitCommandsHelper<Family>::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<Family>::dispatchBlitMemoryFill<1>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR);
break;
case 2:
NEO::BlitCommandsHelper<Family>::dispatchBlitMemoryFill<2>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR);
break;
case 4:
NEO::BlitCommandsHelper<Family>::dispatchBlitMemoryFill<4>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR);
break;
case 8:
NEO::BlitCommandsHelper<Family>::dispatchBlitMemoryFill<8>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_64_BIT_COLOR);
break;
default:
NEO::BlitCommandsHelper<Family>::dispatchBlitMemoryFill<16>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_128_BIT_COLOR);
}
void BlitCommandsHelper<Family>::dispatchBlitMemoryByteFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment) {
NEO::BlitCommandsHelper<Family>::dispatchBlitMemoryFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR, 1);
}
template <>
void BlitCommandsHelper<Family>::appendBlitMemSetCompressionFormat(void *blitCmd, NEO::GraphicsAllocation *dstAlloc, uint32_t compressionFormat) {}
template <>
void BlitCommandsHelper<Family>::appendBlitMemoryOptionsForFillBuffer(NEO::GraphicsAllocation *dstAlloc, typename Family::XY_COLOR_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) {
}

View File

@@ -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()

View File

@@ -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 <size_t patternSize>
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);

View File

@@ -253,8 +253,10 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBufferPerRow(const Bl
}
template <typename GfxFamily>
template <size_t patternSize>
void BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth) {
void BlitCommandsHelper<GfxFamily>::appendBlitMemSetCommand(void *blitCmd) {}
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::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<GfxFamily>::adjustControlSurfaceType(const BlitPropertie
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::appendBlitFillCommand(typename GfxFamily::XY_COLOR_BLT &blitCmd) {}
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::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<GfxFamily>::dispatchBlitMemoryByteFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment);
break;
case 2:
NEO::BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR, 2);
break;
case 4:
NEO::BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR, 4);
break;
case 8:
NEO::BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_64_BIT_COLOR, 8);
break;
default:
NEO::BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_128_BIT_COLOR, 16);
}
}
} // namespace NEO

View File

@@ -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 <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::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<uint32_t>(debugManager.flags.OverrideBlitterMocs.get());
}
blitCmd.setDestinationMOCS(mocs);
uint32_t compressionFormat = 0;
if (dstAlloc->isCompressionEnabled()) {
auto resourceFormat = dstAlloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat();
compressionFormat = static_cast<uint32_t>(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<size_t>(offset)));
size_t height = 0;
size_t width = 0;
if (sizeToFill <= BlitterConstants::maxBlitSetWidth) {
width = sizeToFill;
height = 1;
} else {
width = BlitterConstants::maxBlitSetWidth;
height = std::min<size_t>((sizeToFill / width), BlitterConstants::maxBlitSetHeight);
if (height > 1) {
tmpCmd.setFillType(MEM_SET::FILL_TYPE::FILL_TYPE_MATRIX_FILL);
}
}
tmpCmd.setFillWidth(static_cast<uint32_t>(width));
tmpCmd.setFillHeight(static_cast<uint32_t>(height));
tmpCmd.setDestinationPitch(static_cast<uint32_t>(width));
appendBlitMemSetCommand(&tmpCmd);
auto cmd = linearStream.getSpaceForCmd<MEM_SET>();
*cmd = tmpCmd;
auto blitSize = width * height;
offset += blitSize;
sizeToFill -= blitSize;
}
}
} // namespace NEO

View File

@@ -0,0 +1,29 @@
/*
* Copyright (C) 2025 Intel Corporation
*
* SPDX-License-Identifier: MIT
*
*/
#include "shared/source/helpers/blit_commands_helper.h"
namespace NEO {
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::appendBlitMemSetCompressionFormat(void *blitCmd, NEO::GraphicsAllocation *dstAlloc, uint32_t compressionFormat) {
using MEM_SET = typename Family::MEM_SET;
auto memSetCmd = reinterpret_cast<MEM_SET *>(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

View File

@@ -76,26 +76,6 @@ void BlitCommandsHelper<GfxFamily>::appendBlitMemoryOptionsForFillBuffer(NEO::Gr
}
}
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::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<GfxFamily>::dispatchBlitMemoryFill<1>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR);
break;
case 2:
NEO::BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill<2>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR);
break;
case 4:
NEO::BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill<4>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR);
break;
case 8:
NEO::BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill<8>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_64_BIT_COLOR);
break;
default:
NEO::BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill<16>(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_128_BIT_COLOR);
}
}
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;

View File

@@ -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<Family>::appendBlitCommandsMemCopy(const BlitProperties
DEBUG_BREAK_IF(AuxTranslationDirection::none != blitProperties.auxTranslationDirection);
}
template <>
template <>
void BlitCommandsHelper<Family>::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<uint32_t>(debugManager.flags.OverrideBlitterMocs.get());
}
blitCmd.setDestinationMOCS(mocs);
if (dstAlloc->isCompressionEnabled()) {
auto resourceFormat = dstAlloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat();
auto compressionFormat = static_cast<COMPRESSION_FORMAT30>(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<size_t>(offset)));
size_t height = 0;
size_t width = 0;
if (sizeToFill <= BlitterConstants::maxBlitSetWidth) {
width = sizeToFill;
height = 1;
} else {
width = BlitterConstants::maxBlitSetWidth;
height = std::min<size_t>((sizeToFill / width), BlitterConstants::maxBlitSetHeight);
if (height > 1) {
tmpCmd.setFillType(MEM_SET::FILL_TYPE::FILL_TYPE_MATRIX_FILL);
}
}
tmpCmd.setFillWidth(static_cast<uint32_t>(width));
tmpCmd.setFillHeight(static_cast<uint32_t>(height));
tmpCmd.setDestinationPitch(static_cast<uint32_t>(width));
auto cmd = linearStream.getSpaceForCmd<MEM_SET>();
*cmd = tmpCmd;
auto blitSize = width * height;
offset += blitSize;
sizeToFill -= blitSize;
}
}
template <>
void BlitCommandsHelper<Family>::encodeProfilingStartMmios(LinearStream &cmdStream, const TagNodeBase &timestampPacketNode) {
auto timestampContextStartGpuAddress = TimestampPacketHelper::getContextStartGpuAddress(timestampPacketNode);

View File

@@ -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<Family>::appendBlitCommandsMemCopy(const BlitProperties
DEBUG_BREAK_IF(AuxTranslationDirection::none != blitProperties.auxTranslationDirection);
}
template <>
template <>
void BlitCommandsHelper<Family>::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<uint32_t>(debugManager.flags.OverrideBlitterMocs.get());
}
blitCmd.setDestinationMOCS(mocs);
if (dstAlloc->isCompressionEnabled()) {
auto resourceFormat = dstAlloc->getDefaultGmm()->gmmResourceInfo->getResourceFormat();
auto compressionFormat = static_cast<COMPRESSION_FORMAT30>(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<size_t>(offset)));
size_t height = 0;
size_t width = 0;
if (sizeToFill <= BlitterConstants::maxBlitSetWidth) {
width = sizeToFill;
height = 1;
} else {
width = BlitterConstants::maxBlitSetWidth;
height = std::min<size_t>((sizeToFill / width), BlitterConstants::maxBlitSetHeight);
if (height > 1) {
tmpCmd.setFillType(MEM_SET::FILL_TYPE::FILL_TYPE_MATRIX_FILL);
}
}
tmpCmd.setFillWidth(static_cast<uint32_t>(width));
tmpCmd.setFillHeight(static_cast<uint32_t>(height));
tmpCmd.setDestinationPitch(static_cast<uint32_t>(width));
auto cmd = linearStream.getSpaceForCmd<MEM_SET>();
*cmd = tmpCmd;
auto blitSize = width * height;
offset += blitSize;
sizeToFill -= blitSize;
}
}
template <>
void BlitCommandsHelper<Family>::encodeProfilingStartMmios(LinearStream &cmdStream, const TagNodeBase &timestampPacketNode) {
auto timestampContextStartGpuAddress = TimestampPacketHelper::getContextStartGpuAddress(timestampPacketNode);

View File

@@ -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<Family>::appendBlitCommandsMemCopy(const BlitProperties
}
template <>
template <>
void BlitCommandsHelper<Family>::dispatchBlitMemoryFill<1>(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth) {
void BlitCommandsHelper<Family>::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<uint32_t>(debugManager.flags.OverrideBlitterMocs.get());
}
blitCmd.setDestinationMOCS(mocs);
auto memSetCmd = reinterpret_cast<MEM_SET *>(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<size_t>(offset)));
size_t height = 0;
size_t width = 0;
if (sizeToFill <= BlitterConstants::maxBlitSetWidth) {
width = sizeToFill;
height = 1;
} else {
width = BlitterConstants::maxBlitSetWidth;
height = std::min<size_t>((sizeToFill / width), BlitterConstants::maxBlitSetHeight);
if (height > 1) {
tmpCmd.setFillType(MEM_SET::FILL_TYPE::FILL_TYPE_MATRIX_FILL);
}
}
tmpCmd.setFillWidth(static_cast<uint32_t>(width));
tmpCmd.setFillHeight(static_cast<uint32_t>(height));
tmpCmd.setDestinationPitch(static_cast<uint32_t>(width));
auto cmd = linearStream.getSpaceForCmd<MEM_SET>();
*cmd = tmpCmd;
auto blitSize = width * height;
offset += blitSize;
sizeToFill -= blitSize;
memSetCmd->setDestinationCompressionEnable(MEM_SET::DESTINATION_COMPRESSION_ENABLE::DESTINATION_COMPRESSION_ENABLE_DISABLE);
}
}

View File

@@ -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<Family>::appendBlitCommandsBlockCopy(const BlitPropertie
}
}
template <>
void BlitCommandsHelper<Family>::dispatchBlitMemoryByteFill(NEO::GraphicsAllocation *dstAlloc, uint64_t offset, uint32_t *pattern, LinearStream &linearStream, size_t size, RootDeviceEnvironment &rootDeviceEnvironment) {
NEO::BlitCommandsHelper<Family>::dispatchBlitMemoryFill(dstAlloc, offset, pattern, linearStream, size, rootDeviceEnvironment, COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR, 1);
}
template <>
void BlitCommandsHelper<Family>::appendBlitMemSetCompressionFormat(void *blitCmd, NEO::GraphicsAllocation *dstAlloc, uint32_t compressionFormat) {}
template class CommandStreamReceiverHw<Family>;
template struct BlitCommandsHelper<Family>;
template void BlitCommandsHelper<Family>::appendColorDepth<typename Family::XY_BLOCK_COPY_BLT>(const BlitProperties &blitProperties, typename Family::XY_BLOCK_COPY_BLT &blitCmd);