mirror of
https://github.com/intel/compute-runtime.git
synced 2025-12-20 00:24:58 +08:00
fix: apply additional blit only for first and last blit commands
Modified BlitCommandsHelper object to apply additional blit properties only to first and last blit commands properly Related-To: NEO-13003 Signed-off-by: Young Jin Yoon <young.jin.yoon@intel.com>
This commit is contained in:
committed by
Compute-Runtime-Automation
parent
195ce3049e
commit
eae350bc45
@@ -211,16 +211,14 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBufferPerRow(const Bl
|
||||
|
||||
const bool useAdditionalBlitProperties = rootDeviceEnvironment.getHelper<ProductHelper>().useAdditionalBlitProperties();
|
||||
|
||||
if (useAdditionalBlitProperties) {
|
||||
applyAdditionalBlitProperties(blitProperties, bltCmd, rootDeviceEnvironment, false);
|
||||
}
|
||||
|
||||
bool firstCommand = true;
|
||||
for (uint64_t slice = 0; slice < blitProperties.copySize.z; slice++) {
|
||||
for (uint64_t row = 0; row < blitProperties.copySize.y; row++) {
|
||||
uint64_t offset = 0;
|
||||
uint64_t sizeToBlit = blitProperties.copySize.x;
|
||||
bool lastIteration = (slice == blitProperties.copySize.z - 1) && (row == blitProperties.copySize.y - 1);
|
||||
while (sizeToBlit != 0) {
|
||||
auto tmpCmd = bltCmd;
|
||||
if (sizeToBlit > maxWidth) {
|
||||
// dispatch 2D blit: maxBlitWidth x (1 .. maxBlitHeight)
|
||||
width = maxWidth;
|
||||
@@ -231,12 +229,12 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBufferPerRow(const Bl
|
||||
height = 1;
|
||||
}
|
||||
auto blitSize = width * height;
|
||||
auto lastCommand = lastIteration && (sizeToBlit - blitSize == 0);
|
||||
bool lastCommand = lastIteration && (sizeToBlit - blitSize == 0);
|
||||
|
||||
bltCmd.setDestinationX2CoordinateRight(static_cast<uint32_t>(width));
|
||||
bltCmd.setDestinationY2CoordinateBottom(static_cast<uint32_t>(height));
|
||||
bltCmd.setDestinationPitch(static_cast<uint32_t>(width));
|
||||
bltCmd.setSourcePitch(static_cast<uint32_t>(width));
|
||||
tmpCmd.setDestinationX2CoordinateRight(static_cast<uint32_t>(width));
|
||||
tmpCmd.setDestinationY2CoordinateBottom(static_cast<uint32_t>(height));
|
||||
tmpCmd.setDestinationPitch(static_cast<uint32_t>(width));
|
||||
tmpCmd.setSourcePitch(static_cast<uint32_t>(width));
|
||||
|
||||
auto dstAddr = calculateBlitCommandDestinationBaseAddress(blitProperties, offset, row, slice);
|
||||
auto srcAddr = calculateBlitCommandSourceBaseAddress(blitProperties, offset, row, slice);
|
||||
@@ -244,16 +242,17 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBufferPerRow(const Bl
|
||||
PRINT_DEBUG_STRING(debugManager.flags.PrintBlitDispatchDetails.get(), stdout,
|
||||
"\nBlit command. width: %u, height: %u, srcAddr: %#llx, dstAddr: %#llx ", width, height, srcAddr, dstAddr);
|
||||
|
||||
bltCmd.setDestinationBaseAddress(dstAddr);
|
||||
bltCmd.setSourceBaseAddress(srcAddr);
|
||||
if (useAdditionalBlitProperties && lastCommand) {
|
||||
applyAdditionalBlitProperties(blitProperties, bltCmd, rootDeviceEnvironment, lastCommand);
|
||||
tmpCmd.setDestinationBaseAddress(dstAddr);
|
||||
tmpCmd.setSourceBaseAddress(srcAddr);
|
||||
if (useAdditionalBlitProperties && (firstCommand || lastCommand)) {
|
||||
applyAdditionalBlitProperties(blitProperties, tmpCmd, rootDeviceEnvironment, lastCommand);
|
||||
firstCommand = false;
|
||||
}
|
||||
|
||||
appendBlitCommandsForBuffer(blitProperties, bltCmd, rootDeviceEnvironment);
|
||||
appendBlitCommandsForBuffer(blitProperties, tmpCmd, rootDeviceEnvironment);
|
||||
|
||||
auto bltStream = linearStream.getSpaceForCmd<typename GfxFamily::XY_COPY_BLT>();
|
||||
*bltStream = bltCmd;
|
||||
*bltStream = tmpCmd;
|
||||
|
||||
dispatchPostBlitCommand(linearStream, rootDeviceEnvironment);
|
||||
|
||||
@@ -294,10 +293,7 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(const BlitProperties
|
||||
blitCmd.setColorDepth(colorDepth);
|
||||
const bool useAdditionalBlitProperties = rootDeviceEnvironment.getHelper<ProductHelper>().useAdditionalBlitProperties();
|
||||
|
||||
if (useAdditionalBlitProperties) {
|
||||
applyAdditionalBlitProperties(blitProperties, blitCmd, rootDeviceEnvironment, false);
|
||||
}
|
||||
|
||||
bool firstCommand = true;
|
||||
uint64_t sizeToFill = blitProperties.copySize.x / patternSize;
|
||||
uint64_t offset = blitProperties.dstOffset.x;
|
||||
while (sizeToFill != 0) {
|
||||
@@ -321,12 +317,13 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(const BlitProperties
|
||||
tmpCmd.setDestinationY2CoordinateBottom(static_cast<uint32_t>(height));
|
||||
tmpCmd.setDestinationPitch(static_cast<uint32_t>(width * patternSize));
|
||||
|
||||
if (useAdditionalBlitProperties && lastCommand) {
|
||||
applyAdditionalBlitProperties(blitProperties, tmpCmd, rootDeviceEnvironment, lastCommand);
|
||||
}
|
||||
appendBlitMemoryOptionsForFillBuffer(blitProperties.dstAllocation, tmpCmd, rootDeviceEnvironment);
|
||||
appendBlitFillCommand(blitProperties, tmpCmd);
|
||||
|
||||
if (useAdditionalBlitProperties && (firstCommand || lastCommand)) {
|
||||
applyAdditionalBlitProperties(blitProperties, tmpCmd, rootDeviceEnvironment, lastCommand);
|
||||
firstCommand = false;
|
||||
}
|
||||
auto cmd = linearStream.getSpaceForCmd<XY_COLOR_BLT>();
|
||||
*cmd = tmpCmd;
|
||||
offset += (blitSize * patternSize);
|
||||
@@ -362,22 +359,19 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForImageRegion(const Bli
|
||||
dispatchPreBlitCommand(linearStream, rootDeviceEnvironment);
|
||||
const bool useAdditionalBlitProperties = rootDeviceEnvironment.getHelper<ProductHelper>().useAdditionalBlitProperties();
|
||||
|
||||
if (useAdditionalBlitProperties) {
|
||||
applyAdditionalBlitProperties(blitProperties, bltCmd, rootDeviceEnvironment, false);
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < blitProperties.copySize.z; i++) {
|
||||
appendSliceOffsets(blitProperties, bltCmd, i, rootDeviceEnvironment, srcSlicePitch, dstSlicePitch);
|
||||
auto tmpCmd = bltCmd;
|
||||
appendSliceOffsets(blitProperties, tmpCmd, i, rootDeviceEnvironment, srcSlicePitch, dstSlicePitch);
|
||||
|
||||
if (debugManager.flags.PrintImageBlitBlockCopyCmdDetails.get()) {
|
||||
printImageBlitBlockCopyCommand(bltCmd, i);
|
||||
printImageBlitBlockCopyCommand(tmpCmd, i);
|
||||
}
|
||||
|
||||
if (useAdditionalBlitProperties && i == (blitProperties.copySize.z - 1)) {
|
||||
applyAdditionalBlitProperties(blitProperties, bltCmd, rootDeviceEnvironment, true);
|
||||
bool lastCommand = (i == (blitProperties.copySize.z - 1));
|
||||
if (useAdditionalBlitProperties && (i == 0 || lastCommand)) {
|
||||
applyAdditionalBlitProperties(blitProperties, tmpCmd, rootDeviceEnvironment, lastCommand);
|
||||
}
|
||||
auto cmd = linearStream.getSpaceForCmd<typename GfxFamily::XY_BLOCK_COPY_BLT>();
|
||||
*cmd = bltCmd;
|
||||
*cmd = tmpCmd;
|
||||
dispatchPostBlitCommand(linearStream, rootDeviceEnvironment);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -34,12 +34,9 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryByteFill(const BlitPropert
|
||||
|
||||
const bool useAdditionalBlitProperties = rootDeviceEnvironment.getHelper<ProductHelper>().useAdditionalBlitProperties();
|
||||
|
||||
if (useAdditionalBlitProperties) {
|
||||
applyAdditionalBlitProperties(blitProperties, blitCmd, rootDeviceEnvironment, false);
|
||||
}
|
||||
|
||||
auto sizeToFill = blitProperties.copySize.x;
|
||||
uint64_t offset = blitProperties.dstOffset.x;
|
||||
bool firstCommand = true;
|
||||
while (sizeToFill != 0) {
|
||||
auto tmpCmd = blitCmd;
|
||||
tmpCmd.setDestinationStartAddress(ptrOffset(blitProperties.dstAllocation->getGpuAddress(), static_cast<size_t>(offset)));
|
||||
@@ -61,8 +58,9 @@ void BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryByteFill(const BlitPropert
|
||||
tmpCmd.setFillHeight(static_cast<uint32_t>(height));
|
||||
tmpCmd.setDestinationPitch(static_cast<uint32_t>(width));
|
||||
|
||||
if (useAdditionalBlitProperties && lastCommand) {
|
||||
if (useAdditionalBlitProperties && (firstCommand || lastCommand)) {
|
||||
applyAdditionalBlitProperties(blitProperties, tmpCmd, rootDeviceEnvironment, lastCommand);
|
||||
firstCommand = false;
|
||||
}
|
||||
appendBlitMemSetCommand(blitProperties, &tmpCmd);
|
||||
|
||||
|
||||
@@ -764,9 +764,9 @@ HWTEST2_F(BlitTests, givenPlatformWithBlitSyncPropertiesWithAndWithoutUseAdditio
|
||||
|
||||
size_t copySizeX = BlitterConstants::maxBlitWidth - 1;
|
||||
size_t copySizeY = BlitterConstants::maxBlitHeight - 1;
|
||||
Vec3<size_t> copySize = {copySizeX, copySizeY, 0x2};
|
||||
Vec3<size_t> srcSize = {copySizeX, copySizeY, 0x2};
|
||||
Vec3<size_t> dstSize = {copySizeX, copySizeY, 0x2};
|
||||
Vec3<size_t> copySize = {copySizeX, copySizeY, 0x3};
|
||||
Vec3<size_t> srcSize = {copySizeX, copySizeY, 0x3};
|
||||
Vec3<size_t> dstSize = {copySizeX, copySizeY, 0x3};
|
||||
|
||||
size_t srcRowPitch = srcSize.x;
|
||||
size_t srcSlicePitch = srcSize.y;
|
||||
@@ -798,7 +798,7 @@ HWTEST2_F(BlitTests, givenPlatformWithBlitSyncPropertiesWithAndWithoutUseAdditio
|
||||
}
|
||||
|
||||
HWTEST2_F(BlitTests, givenPlatformWithBlitSyncPropertiesAndSingleBytePatternWithAndWithoutUseAdditionalPropertiesWhenCallingDispatchBlitMemoryColorFillThenTheResultsAreTheSame, MatchAny) {
|
||||
size_t dstSize = sizeof(uint8_t) * (BlitterConstants::maxBlitWidth * BlitterConstants::maxBlitHeight);
|
||||
size_t dstSize = 2 * BlitterConstants::maxBlitSetWidth + sizeof(uint8_t);
|
||||
MockGraphicsAllocation dstAlloc(0, 1u /*num gmms*/, AllocationType::internalHostMemory,
|
||||
reinterpret_cast<void *>(0x1234), 0x1000, 0, dstSize,
|
||||
MemoryPool::system4KBPages, MemoryManager::maxOsContextCount);
|
||||
@@ -806,16 +806,17 @@ HWTEST2_F(BlitTests, givenPlatformWithBlitSyncPropertiesAndSingleBytePatternWith
|
||||
pattern[0] = 0x1;
|
||||
auto blitProperties = BlitProperties::constructPropertiesForMemoryFill(&dstAlloc, dstSize, pattern, sizeof(uint8_t), 0);
|
||||
|
||||
uint32_t streamBuffer[800] = {};
|
||||
uint32_t streamBuffer[1200] = {};
|
||||
LinearStream stream(streamBuffer, sizeof(streamBuffer));
|
||||
NEO::BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(blitProperties, stream, pDevice->getRootDeviceEnvironmentRef());
|
||||
|
||||
EXPECT_EQ(1u, blitProperties.fillPatternSize);
|
||||
// change productHelper to return true
|
||||
pDevice->getRootDeviceEnvironmentRef().productHelper.reset(new MockProductHelperHw<productFamily>);
|
||||
auto *mockProductHelper = static_cast<MockProductHelperHw<productFamily> *>(pDevice->getRootDeviceEnvironmentRef().productHelper.get());
|
||||
mockProductHelper->enableAdditionalBlitProperties = true;
|
||||
|
||||
uint32_t streamBuffer2[800] = {};
|
||||
uint32_t streamBuffer2[1200] = {};
|
||||
LinearStream stream2(streamBuffer2, sizeof(streamBuffer2));
|
||||
NEO::BlitCommandsHelper<FamilyType>::dispatchBlitMemoryColorFill(blitProperties, stream2, pDevice->getRootDeviceEnvironmentRef());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user