refactor: unify blit memory fill methods and pass BlitProperties

Related-To: NEO-13003

Signed-off-by: Bartosz Dunajski <bartosz.dunajski@intel.com>
This commit is contained in:
Bartosz Dunajski
2025-01-28 13:15:49 +00:00
committed by Compute-Runtime-Automation
parent ad32b93968
commit d7ca6568fc
14 changed files with 155 additions and 77 deletions

View File

@@ -11,6 +11,7 @@
#include "shared/source/helpers/gfx_core_helper.h"
#include "shared/source/helpers/register_offsets.h"
#include "shared/source/helpers/timestamp_packet.h"
#include "shared/source/utilities/lookup_array.h"
#include <cmath>
@@ -253,22 +254,31 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBufferPerRow(const Bl
}
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::appendBlitMemSetCommand(void *blitCmd) {}
void BlitCommandsHelper<GfxFamily>::appendBlitMemSetCommand(const BlitProperties &blitProperties, 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) {
void BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(const BlitProperties &blitProperties, LinearStream &linearStream, RootDeviceEnvironment &rootDeviceEnvironment) {
using XY_COLOR_BLT = typename GfxFamily::XY_COLOR_BLT;
auto blitCmd = GfxFamily::cmdInitXyColorBlt;
const auto maxWidth = getMaxBlitWidth(rootDeviceEnvironment);
const auto maxHeight = getMaxBlitHeight(rootDeviceEnvironment, true);
blitCmd.setFillColor(pattern);
blitCmd.setColorDepth(depth);
const LookupArray<size_t, COLOR_DEPTH, 5> colorDepthSize({{
{1, COLOR_DEPTH::COLOR_DEPTH_8_BIT_COLOR},
{2, COLOR_DEPTH::COLOR_DEPTH_16_BIT_COLOR},
{4, COLOR_DEPTH::COLOR_DEPTH_32_BIT_COLOR},
{8, COLOR_DEPTH::COLOR_DEPTH_64_BIT_COLOR},
{16, COLOR_DEPTH::COLOR_DEPTH_128_BIT_COLOR},
}});
uint64_t sizeToFill = size / patternSize;
blitCmd.setFillColor(blitProperties.fillPattern);
blitCmd.setColorDepth(colorDepthSize.lookUp(blitProperties.fillPatternSize));
uint64_t sizeToFill = blitProperties.copySize.x / blitProperties.fillPatternSize;
uint64_t offset = blitProperties.dstOffset.x;
while (sizeToFill != 0) {
auto tmpCmd = blitCmd;
tmpCmd.setDestinationBaseAddress(ptrOffset(dstAlloc->getGpuAddress(), static_cast<size_t>(offset)));
tmpCmd.setDestinationBaseAddress(ptrOffset(blitProperties.dstAllocation->getGpuAddress(), static_cast<size_t>(offset)));
uint64_t height = 0;
uint64_t width = 0;
if (sizeToFill <= maxWidth) {
@@ -283,15 +293,15 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(NEO::GraphicsAllocati
}
tmpCmd.setDestinationX2CoordinateRight(static_cast<uint32_t>(width));
tmpCmd.setDestinationY2CoordinateBottom(static_cast<uint32_t>(height));
tmpCmd.setDestinationPitch(static_cast<uint32_t>(width * patternSize));
tmpCmd.setDestinationPitch(static_cast<uint32_t>(width * blitProperties.fillPatternSize));
appendBlitMemoryOptionsForFillBuffer(dstAlloc, tmpCmd, rootDeviceEnvironment);
appendBlitFillCommand(tmpCmd);
appendBlitMemoryOptionsForFillBuffer(blitProperties.dstAllocation, tmpCmd, rootDeviceEnvironment);
appendBlitFillCommand(blitProperties, tmpCmd);
auto cmd = linearStream.getSpaceForCmd<XY_COLOR_BLT>();
*cmd = tmpCmd;
auto blitSize = width * height;
offset += (blitSize * patternSize);
offset += (blitSize * blitProperties.fillPatternSize);
sizeToFill -= blitSize;
}
}
@@ -554,25 +564,14 @@ template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::adjustControlSurfaceType(const BlitProperties &blitProperties, typename GfxFamily::XY_BLOCK_COPY_BLT &blitCmd) {}
template <typename GfxFamily>
void BlitCommandsHelper<GfxFamily>::appendBlitFillCommand(typename GfxFamily::XY_COLOR_BLT &blitCmd) {}
void BlitCommandsHelper<GfxFamily>::appendBlitFillCommand(const BlitProperties &blitProperties, 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);
void BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryColorFill(const BlitProperties &blitProperties, LinearStream &linearStream, RootDeviceEnvironment &rootDeviceEnvironment) {
if (blitProperties.fillPatternSize == 1) {
NEO::BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryByteFill(blitProperties, linearStream, rootDeviceEnvironment);
} else {
NEO::BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(blitProperties, linearStream, rootDeviceEnvironment);
}
}