From 493b01e3c8e8a0e69b78297875f2965059b07e02 Mon Sep 17 00:00:00 2001 From: Michal Mrozek Date: Wed, 16 Mar 2022 13:50:26 +0000 Subject: [PATCH] Remove invariant code from the loop. Signed-off-by: Michal Mrozek --- .../helpers/blit_commands_helper_base.inl | 42 +++++++++---------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/shared/source/helpers/blit_commands_helper_base.inl b/shared/source/helpers/blit_commands_helper_base.inl index 6f0d65770c..99496f1e2f 100644 --- a/shared/source/helpers/blit_commands_helper_base.inl +++ b/shared/source/helpers/blit_commands_helper_base.inl @@ -183,6 +183,8 @@ void BlitCommandsHelper::dispatchBlitCommandsForBufferPerRow(const Bl const auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); dispatchPreBlitCommand(linearStream, hwInfo); + auto bltCmd = GfxFamily::cmdInitXyCopyBlt; + appendColorDepth(blitProperties, bltCmd); for (uint64_t slice = 0; slice < blitProperties.copySize.z; slice++) { for (uint64_t row = 0; row < blitProperties.copySize.y; row++) { @@ -199,29 +201,24 @@ void BlitCommandsHelper::dispatchBlitCommandsForBufferPerRow(const Bl height = 1; } - { - auto bltCmd = GfxFamily::cmdInitXyCopyBlt; + bltCmd.setDestinationX2CoordinateRight(static_cast(width)); + bltCmd.setDestinationY2CoordinateBottom(static_cast(height)); + bltCmd.setDestinationPitch(static_cast(width)); + bltCmd.setSourcePitch(static_cast(width)); - bltCmd.setDestinationX2CoordinateRight(static_cast(width)); - bltCmd.setDestinationY2CoordinateBottom(static_cast(height)); - bltCmd.setDestinationPitch(static_cast(width)); - bltCmd.setSourcePitch(static_cast(width)); + auto dstAddr = calculateBlitCommandDestinationBaseAddress(blitProperties, offset, row, slice); + auto srcAddr = calculateBlitCommandSourceBaseAddress(blitProperties, offset, row, slice); - auto dstAddr = calculateBlitCommandDestinationBaseAddress(blitProperties, offset, row, slice); - auto srcAddr = calculateBlitCommandSourceBaseAddress(blitProperties, offset, row, slice); + PRINT_DEBUG_STRING(DebugManager.flags.PrintBlitDispatchDetails.get(), stdout, + "\nBlit command. width: %u, height: %u, srcAddr: %#llx, dstAddr: %#llx ", width, height, srcAddr, dstAddr); - 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); - bltCmd.setDestinationBaseAddress(dstAddr); - bltCmd.setSourceBaseAddress(srcAddr); + appendBlitCommandsForBuffer(blitProperties, bltCmd, rootDeviceEnvironment); - appendBlitCommandsForBuffer(blitProperties, bltCmd, rootDeviceEnvironment); - appendColorDepth(blitProperties, bltCmd); - - auto bltStream = linearStream.getSpaceForCmd(); - *bltStream = bltCmd; - } + auto bltStream = linearStream.getSpaceForCmd(); + *bltStream = bltCmd; dispatchPostBlitCommand(linearStream, hwInfo); @@ -382,6 +379,11 @@ void BlitCommandsHelper::dispatchBlitCommandsForBufferRegion(const Bl const auto &hwInfo = *rootDeviceEnvironment.getHardwareInfo(); dispatchPreBlitCommand(linearStream, hwInfo); + auto bltCmd = GfxFamily::cmdInitXyCopyBlt; + bltCmd.setSourcePitch(static_cast(blitProperties.srcRowPitch)); + bltCmd.setDestinationPitch(static_cast(blitProperties.dstRowPitch)); + appendColorDepth(blitProperties, bltCmd); + for (size_t slice = 0u; slice < blitProperties.copySize.z; ++slice) { auto srcAddress = calculateBlitCommandSourceBaseAddressCopyRegion(blitProperties, slice); auto dstAddress = calculateBlitCommandDestinationBaseAddressCopyRegion(blitProperties, slice); @@ -393,17 +395,13 @@ void BlitCommandsHelper::dispatchBlitCommandsForBufferRegion(const Bl while (widthToCopy > 0) { auto width = static_cast(std::min(widthToCopy, static_cast(maxWidthToCopy))); - auto bltCmd = GfxFamily::cmdInitXyCopyBlt; bltCmd.setSourceBaseAddress(srcAddress); bltCmd.setDestinationBaseAddress(dstAddress); bltCmd.setDestinationX2CoordinateRight(width); bltCmd.setDestinationY2CoordinateBottom(height); - bltCmd.setSourcePitch(static_cast(blitProperties.srcRowPitch)); - bltCmd.setDestinationPitch(static_cast(blitProperties.dstRowPitch)); appendBlitCommandsForBuffer(blitProperties, bltCmd, rootDeviceEnvironment); - appendColorDepth(blitProperties, bltCmd); auto cmd = linearStream.getSpaceForCmd(); *cmd = bltCmd;