2019-04-03 21:59:31 +08:00
|
|
|
/*
|
2021-01-28 18:01:51 +08:00
|
|
|
* Copyright (C) 2019-2021 Intel Corporation
|
2019-04-03 21:59:31 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2020-03-13 19:29:45 +08:00
|
|
|
#include "shared/source/command_container/command_encoder.h"
|
2020-05-21 18:36:23 +08:00
|
|
|
#include "shared/source/gmm_helper/gmm.h"
|
|
|
|
#include "shared/source/gmm_helper/gmm_helper.h"
|
|
|
|
#include "shared/source/gmm_helper/resource_info.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/blit_commands_helper.h"
|
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
2020-10-16 21:58:47 +08:00
|
|
|
#include "shared/source/helpers/register_offsets.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/timestamp_packet.h"
|
2019-04-03 21:59:31 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
2020-05-06 20:54:30 +08:00
|
|
|
template <typename GfxFamily>
|
2020-07-01 20:12:53 +08:00
|
|
|
uint64_t BlitCommandsHelper<GfxFamily>::getMaxBlitWidth(const RootDeviceEnvironment &rootDeviceEnvironment) {
|
2020-05-06 20:54:30 +08:00
|
|
|
if (DebugManager.flags.LimitBlitterMaxWidth.get() != -1) {
|
|
|
|
return static_cast<uint64_t>(DebugManager.flags.LimitBlitterMaxWidth.get());
|
|
|
|
}
|
2020-07-01 20:12:53 +08:00
|
|
|
auto maxBlitWidthOverride = getMaxBlitWidthOverride(rootDeviceEnvironment);
|
|
|
|
if (maxBlitWidthOverride > 0) {
|
|
|
|
return maxBlitWidthOverride;
|
|
|
|
}
|
2020-05-06 20:54:30 +08:00
|
|
|
return BlitterConstants::maxBlitWidth;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2020-07-01 20:12:53 +08:00
|
|
|
uint64_t BlitCommandsHelper<GfxFamily>::getMaxBlitHeight(const RootDeviceEnvironment &rootDeviceEnvironment) {
|
2020-05-06 20:54:30 +08:00
|
|
|
if (DebugManager.flags.LimitBlitterMaxHeight.get() != -1) {
|
|
|
|
return static_cast<uint64_t>(DebugManager.flags.LimitBlitterMaxHeight.get());
|
|
|
|
}
|
2020-07-01 20:12:53 +08:00
|
|
|
auto maxBlitHeightOverride = getMaxBlitHeightOverride(rootDeviceEnvironment);
|
|
|
|
if (maxBlitHeightOverride > 0) {
|
|
|
|
return maxBlitHeightOverride;
|
|
|
|
}
|
2020-05-06 20:54:30 +08:00
|
|
|
return BlitterConstants::maxBlitHeight;
|
|
|
|
}
|
|
|
|
|
2021-01-28 18:01:51 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
void BlitCommandsHelper<GfxFamily>::dispatchPreBlitCommand(LinearStream &linearStream) {
|
|
|
|
if (BlitCommandsHelper<GfxFamily>::preBlitCommandWARequired()) {
|
2021-06-17 19:55:28 +08:00
|
|
|
MiFlushArgs args;
|
|
|
|
EncodeMiFlushDW<GfxFamily>::programMiFlushDw(linearStream, 0, 0, args);
|
2021-01-28 18:01:51 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t BlitCommandsHelper<GfxFamily>::estimatePreBlitCommandSize() {
|
|
|
|
if (BlitCommandsHelper<GfxFamily>::preBlitCommandWARequired()) {
|
|
|
|
return EncodeMiFlushDW<GfxFamily>::getMiFlushDwCmdSizeForDataWrite();
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0u;
|
|
|
|
}
|
|
|
|
|
2020-05-06 20:54:30 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
void BlitCommandsHelper<GfxFamily>::dispatchPostBlitCommand(LinearStream &linearStream) {
|
2021-06-17 19:55:28 +08:00
|
|
|
MiFlushArgs args;
|
2020-11-17 01:12:08 +08:00
|
|
|
if (DebugManager.flags.PostBlitCommand.get() != BlitterConstants::PostBlitMode::Default) {
|
|
|
|
switch (DebugManager.flags.PostBlitCommand.get()) {
|
|
|
|
case BlitterConstants::PostBlitMode::MiArbCheck:
|
|
|
|
EncodeMiArbCheck<GfxFamily>::program(linearStream);
|
|
|
|
return;
|
|
|
|
case BlitterConstants::PostBlitMode::MiFlush:
|
2021-06-17 19:55:28 +08:00
|
|
|
EncodeMiFlushDW<GfxFamily>::programMiFlushDw(linearStream, 0, 0, args);
|
2020-11-17 01:12:08 +08:00
|
|
|
return;
|
|
|
|
default:
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BlitCommandsHelper<GfxFamily>::miArbCheckWaRequired()) {
|
2021-06-17 19:55:28 +08:00
|
|
|
EncodeMiFlushDW<GfxFamily>::programMiFlushDw(linearStream, 0, 0, args);
|
2020-05-06 20:54:30 +08:00
|
|
|
}
|
2020-11-17 01:12:08 +08:00
|
|
|
|
|
|
|
EncodeMiArbCheck<GfxFamily>::program(linearStream);
|
2020-05-06 20:54:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t BlitCommandsHelper<GfxFamily>::estimatePostBlitCommandSize() {
|
2020-11-17 01:12:08 +08:00
|
|
|
if (DebugManager.flags.PostBlitCommand.get() != BlitterConstants::PostBlitMode::Default) {
|
|
|
|
switch (DebugManager.flags.PostBlitCommand.get()) {
|
|
|
|
case BlitterConstants::PostBlitMode::MiArbCheck:
|
|
|
|
return EncodeMiArbCheck<GfxFamily>::getCommandSize();
|
|
|
|
case BlitterConstants::PostBlitMode::MiFlush:
|
|
|
|
return EncodeMiFlushDW<GfxFamily>::getMiFlushDwCmdSizeForDataWrite();
|
|
|
|
default:
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (BlitCommandsHelper<GfxFamily>::miArbCheckWaRequired()) {
|
|
|
|
return (EncodeMiArbCheck<GfxFamily>::getCommandSize() + EncodeMiFlushDW<GfxFamily>::getMiFlushDwCmdSizeForDataWrite());
|
2020-05-06 20:54:30 +08:00
|
|
|
}
|
2020-11-09 20:16:24 +08:00
|
|
|
|
2020-11-17 01:12:08 +08:00
|
|
|
return EncodeMiArbCheck<GfxFamily>::getCommandSize();
|
2020-05-06 20:54:30 +08:00
|
|
|
}
|
|
|
|
|
2019-04-03 21:59:31 +08:00
|
|
|
template <typename GfxFamily>
|
2020-08-25 21:24:09 +08:00
|
|
|
size_t BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(const Vec3<size_t> ©Size, const CsrDependencies &csrDependencies,
|
2020-07-01 20:12:53 +08:00
|
|
|
bool updateTimestampPacket, bool profilingEnabled,
|
|
|
|
const RootDeviceEnvironment &rootDeviceEnvironment) {
|
2020-08-21 22:23:58 +08:00
|
|
|
size_t timestampCmdSize = 0;
|
|
|
|
if (updateTimestampPacket) {
|
2020-10-20 00:10:53 +08:00
|
|
|
timestampCmdSize += EncodeMiFlushDW<GfxFamily>::getMiFlushDwCmdSizeForDataWrite();
|
|
|
|
if (profilingEnabled) {
|
2021-04-01 19:54:16 +08:00
|
|
|
timestampCmdSize += getProfilingMmioCmdsSize();
|
2020-10-20 00:10:53 +08:00
|
|
|
}
|
2020-08-21 22:23:58 +08:00
|
|
|
}
|
2020-08-19 19:33:45 +08:00
|
|
|
|
2020-08-25 21:24:09 +08:00
|
|
|
bool preferRegionCopy = isCopyRegionPreferred(copySize, rootDeviceEnvironment);
|
|
|
|
auto nBlits = preferRegionCopy ? getNumberOfBlitsForCopyRegion(copySize, rootDeviceEnvironment)
|
|
|
|
: getNumberOfBlitsForCopyPerRow(copySize, rootDeviceEnvironment);
|
|
|
|
|
|
|
|
auto sizePerBlit = (sizeof(typename GfxFamily::XY_COPY_BLT) + estimatePostBlitCommandSize());
|
|
|
|
|
2021-06-14 23:33:53 +08:00
|
|
|
return TimestampPacketHelper::getRequiredCmdStreamSize<GfxFamily>(csrDependencies) +
|
|
|
|
TimestampPacketHelper::getRequiredCmdStreamSizeForTaskCountContainer<GfxFamily>(csrDependencies) +
|
|
|
|
(sizePerBlit * nBlits) +
|
|
|
|
timestampCmdSize +
|
|
|
|
estimatePreBlitCommandSize();
|
2019-11-07 16:15:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2020-07-01 20:12:53 +08:00
|
|
|
size_t BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(const BlitPropertiesContainer &blitPropertiesContainer,
|
|
|
|
bool profilingEnabled, bool debugPauseEnabled,
|
2020-10-19 21:36:57 +08:00
|
|
|
bool blitterDirectSubmission, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
2019-11-07 16:15:53 +08:00
|
|
|
size_t size = 0;
|
|
|
|
for (auto &blitProperties : blitPropertiesContainer) {
|
|
|
|
size += BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(blitProperties.copySize, blitProperties.csrDependencies,
|
2020-07-01 20:12:53 +08:00
|
|
|
blitProperties.outputTimestampPacket != nullptr, profilingEnabled,
|
|
|
|
rootDeviceEnvironment);
|
2019-11-07 16:15:53 +08:00
|
|
|
}
|
2020-07-01 20:12:53 +08:00
|
|
|
size += MemorySynchronizationCommands<GfxFamily>::getSizeForAdditonalSynchronization(*rootDeviceEnvironment.getHardwareInfo());
|
2020-08-25 21:24:09 +08:00
|
|
|
size += EncodeMiFlushDW<GfxFamily>::getMiFlushDwCmdSizeForDataWrite();
|
2020-10-19 21:36:57 +08:00
|
|
|
if (blitterDirectSubmission) {
|
|
|
|
size += sizeof(typename GfxFamily::MI_BATCH_BUFFER_START);
|
|
|
|
} else {
|
|
|
|
size += sizeof(typename GfxFamily::MI_BATCH_BUFFER_END);
|
|
|
|
}
|
2019-04-03 21:59:31 +08:00
|
|
|
|
2020-06-17 20:58:28 +08:00
|
|
|
if (debugPauseEnabled) {
|
|
|
|
size += BlitCommandsHelper<GfxFamily>::getSizeForDebugPauseCommands();
|
|
|
|
}
|
|
|
|
|
2020-10-16 21:58:47 +08:00
|
|
|
size += BlitCommandsHelper<GfxFamily>::getSizeForGlobalSequencerFlush();
|
|
|
|
|
2019-04-03 21:59:31 +08:00
|
|
|
return alignUp(size, MemoryConstants::cacheLineSize);
|
|
|
|
}
|
|
|
|
|
2020-02-25 16:55:13 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
uint64_t BlitCommandsHelper<GfxFamily>::calculateBlitCommandDestinationBaseAddress(const BlitProperties &blitProperties, uint64_t offset, uint64_t row, uint64_t slice) {
|
|
|
|
return blitProperties.dstGpuAddress + blitProperties.dstOffset.x + offset +
|
|
|
|
blitProperties.dstOffset.y * blitProperties.dstRowPitch +
|
|
|
|
blitProperties.dstOffset.z * blitProperties.dstSlicePitch +
|
|
|
|
row * blitProperties.dstRowPitch +
|
|
|
|
slice * blitProperties.dstSlicePitch;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
uint64_t BlitCommandsHelper<GfxFamily>::calculateBlitCommandSourceBaseAddress(const BlitProperties &blitProperties, uint64_t offset, uint64_t row, uint64_t slice) {
|
|
|
|
return blitProperties.srcGpuAddress + blitProperties.srcOffset.x + offset +
|
|
|
|
blitProperties.srcOffset.y * blitProperties.srcRowPitch +
|
|
|
|
blitProperties.srcOffset.z * blitProperties.srcSlicePitch +
|
|
|
|
row * blitProperties.srcRowPitch +
|
|
|
|
slice * blitProperties.srcSlicePitch;
|
|
|
|
}
|
|
|
|
|
2019-04-03 21:59:31 +08:00
|
|
|
template <typename GfxFamily>
|
2020-07-02 22:07:22 +08:00
|
|
|
void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBufferPerRow(const BlitProperties &blitProperties, LinearStream &linearStream, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
2019-04-03 21:59:31 +08:00
|
|
|
uint64_t width = 1;
|
|
|
|
uint64_t height = 1;
|
|
|
|
|
2020-10-22 20:08:50 +08:00
|
|
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintBlitDispatchDetails.get(), stdout,
|
|
|
|
"\nBlit dispatch with AuxTranslationDirection %u ", static_cast<uint32_t>(blitProperties.auxTranslationDirection));
|
|
|
|
|
2021-01-28 18:01:51 +08:00
|
|
|
dispatchPreBlitCommand(linearStream);
|
|
|
|
|
2020-02-25 16:55:13 +08:00
|
|
|
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;
|
|
|
|
while (sizeToBlit != 0) {
|
2020-07-01 20:12:53 +08:00
|
|
|
if (sizeToBlit > getMaxBlitWidth(rootDeviceEnvironment)) {
|
2020-02-25 16:55:13 +08:00
|
|
|
// dispatch 2D blit: maxBlitWidth x (1 .. maxBlitHeight)
|
2020-07-01 20:12:53 +08:00
|
|
|
width = getMaxBlitWidth(rootDeviceEnvironment);
|
|
|
|
height = std::min((sizeToBlit / width), getMaxBlitHeight(rootDeviceEnvironment));
|
2020-02-25 16:55:13 +08:00
|
|
|
} else {
|
|
|
|
// dispatch 1D blt: (1 .. maxBlitWidth) x 1
|
|
|
|
width = sizeToBlit;
|
|
|
|
height = 1;
|
|
|
|
}
|
|
|
|
|
2020-04-24 18:24:40 +08:00
|
|
|
{
|
|
|
|
auto bltCmd = GfxFamily::cmdInitXyCopyBlt;
|
|
|
|
|
2021-06-04 23:22:06 +08:00
|
|
|
bltCmd.setDestinationX2CoordinateRight(static_cast<uint32_t>(width));
|
|
|
|
bltCmd.setDestinationY2CoordinateBottom(static_cast<uint32_t>(height));
|
2020-04-24 18:24:40 +08:00
|
|
|
bltCmd.setDestinationPitch(static_cast<uint32_t>(width));
|
|
|
|
bltCmd.setSourcePitch(static_cast<uint32_t>(width));
|
2020-02-25 16:55:13 +08:00
|
|
|
|
2020-04-24 18:24:40 +08:00
|
|
|
auto dstAddr = calculateBlitCommandDestinationBaseAddress(blitProperties, offset, row, slice);
|
|
|
|
auto srcAddr = calculateBlitCommandSourceBaseAddress(blitProperties, offset, row, slice);
|
2020-02-25 16:55:13 +08:00
|
|
|
|
2020-10-22 20:08:50 +08:00
|
|
|
PRINT_DEBUG_STRING(DebugManager.flags.PrintBlitDispatchDetails.get(), stdout,
|
|
|
|
"\nBlit command. width: %u, height: %u, srcAddr: %#llx, dstAddr: %#llx ", width, height, srcAddr, dstAddr);
|
|
|
|
|
2020-04-24 18:24:40 +08:00
|
|
|
bltCmd.setDestinationBaseAddress(dstAddr);
|
|
|
|
bltCmd.setSourceBaseAddress(srcAddr);
|
2020-02-25 16:55:13 +08:00
|
|
|
|
2020-04-24 18:24:40 +08:00
|
|
|
appendBlitCommandsForBuffer(blitProperties, bltCmd, rootDeviceEnvironment);
|
2020-02-25 16:55:13 +08:00
|
|
|
|
2020-04-24 18:24:40 +08:00
|
|
|
auto bltStream = linearStream.getSpaceForCmd<typename GfxFamily::XY_COPY_BLT>();
|
|
|
|
*bltStream = bltCmd;
|
|
|
|
}
|
|
|
|
|
2020-05-06 20:54:30 +08:00
|
|
|
dispatchPostBlitCommand(linearStream);
|
2020-02-25 16:55:13 +08:00
|
|
|
|
|
|
|
auto blitSize = width * height;
|
|
|
|
sizeToBlit -= blitSize;
|
|
|
|
offset += blitSize;
|
|
|
|
}
|
|
|
|
}
|
2019-04-03 21:59:31 +08:00
|
|
|
}
|
|
|
|
}
|
2020-08-25 21:24:09 +08:00
|
|
|
|
2020-04-28 16:24:22 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
template <size_t patternSize>
|
|
|
|
void BlitCommandsHelper<GfxFamily>::dispatchBlitMemoryFill(NEO::GraphicsAllocation *dstAlloc, uint32_t *pattern, LinearStream &linearStream, size_t size, const RootDeviceEnvironment &rootDeviceEnvironment, COLOR_DEPTH depth) {
|
|
|
|
using XY_COLOR_BLT = typename GfxFamily::XY_COLOR_BLT;
|
|
|
|
auto blitCmd = GfxFamily::cmdInitXyColorBlt;
|
|
|
|
|
|
|
|
blitCmd.setFillColor(pattern);
|
|
|
|
blitCmd.setColorDepth(depth);
|
|
|
|
|
|
|
|
uint64_t offset = 0;
|
2020-09-28 23:24:59 +08:00
|
|
|
uint64_t sizeToFill = size / patternSize;
|
2020-04-28 16:24:22 +08:00
|
|
|
while (sizeToFill != 0) {
|
|
|
|
auto tmpCmd = blitCmd;
|
|
|
|
tmpCmd.setDestinationBaseAddress(ptrOffset(dstAlloc->getGpuAddress(), static_cast<size_t>(offset)));
|
|
|
|
uint64_t height = 0;
|
|
|
|
uint64_t width = 0;
|
2020-07-01 20:12:53 +08:00
|
|
|
if (sizeToFill <= getMaxBlitWidth(rootDeviceEnvironment)) {
|
2020-04-28 16:24:22 +08:00
|
|
|
width = sizeToFill;
|
|
|
|
height = 1;
|
|
|
|
} else {
|
2020-07-01 20:12:53 +08:00
|
|
|
width = getMaxBlitWidth(rootDeviceEnvironment);
|
|
|
|
height = std::min((sizeToFill / width), getMaxBlitHeight(rootDeviceEnvironment));
|
2020-04-28 16:24:22 +08:00
|
|
|
if (height > 1) {
|
|
|
|
appendTilingEnable(tmpCmd);
|
|
|
|
}
|
|
|
|
}
|
2021-06-04 23:22:06 +08:00
|
|
|
tmpCmd.setDestinationX2CoordinateRight(static_cast<uint32_t>(width));
|
|
|
|
tmpCmd.setDestinationY2CoordinateBottom(static_cast<uint32_t>(height));
|
2020-11-03 16:57:50 +08:00
|
|
|
tmpCmd.setDestinationPitch(static_cast<uint32_t>(width));
|
2020-05-21 18:36:23 +08:00
|
|
|
|
|
|
|
appendBlitCommandsForFillBuffer(dstAlloc, tmpCmd, rootDeviceEnvironment);
|
|
|
|
|
2020-04-28 16:24:22 +08:00
|
|
|
auto cmd = linearStream.getSpaceForCmd<XY_COLOR_BLT>();
|
|
|
|
*cmd = tmpCmd;
|
|
|
|
auto blitSize = width * height;
|
2020-09-28 23:24:59 +08:00
|
|
|
offset += (blitSize * patternSize);
|
2020-04-28 16:24:22 +08:00
|
|
|
sizeToFill -= blitSize;
|
|
|
|
}
|
|
|
|
}
|
2019-04-11 15:12:52 +08:00
|
|
|
|
2020-05-21 18:36:23 +08:00
|
|
|
template <typename GfxFamily>
|
2020-07-02 22:07:22 +08:00
|
|
|
void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsRegion(const BlitProperties &blitProperties, LinearStream &linearStream, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
2020-10-20 21:27:49 +08:00
|
|
|
auto srcSlicePitch = static_cast<uint32_t>(blitProperties.srcSlicePitch);
|
|
|
|
auto dstSlicePitch = static_cast<uint32_t>(blitProperties.dstSlicePitch);
|
2020-05-21 18:36:23 +08:00
|
|
|
|
2020-10-28 00:17:26 +08:00
|
|
|
UNRECOVERABLE_IF(blitProperties.copySize.x > BlitterConstants::maxBlitWidth || blitProperties.copySize.y > BlitterConstants::maxBlitHeight);
|
2020-05-21 18:36:23 +08:00
|
|
|
auto bltCmd = GfxFamily::cmdInitXyCopyBlt;
|
|
|
|
|
2020-10-20 21:27:49 +08:00
|
|
|
bltCmd.setSourceBaseAddress(blitProperties.srcAllocation->getGpuAddress());
|
|
|
|
bltCmd.setDestinationBaseAddress(blitProperties.dstAllocation->getGpuAddress());
|
2020-05-21 18:36:23 +08:00
|
|
|
|
|
|
|
bltCmd.setDestinationX1CoordinateLeft(static_cast<uint32_t>(blitProperties.dstOffset.x));
|
|
|
|
bltCmd.setDestinationY1CoordinateTop(static_cast<uint32_t>(blitProperties.dstOffset.y));
|
2021-06-04 23:22:06 +08:00
|
|
|
bltCmd.setDestinationX2CoordinateRight(static_cast<uint32_t>(blitProperties.dstOffset.x + blitProperties.copySize.x));
|
|
|
|
bltCmd.setDestinationY2CoordinateBottom(static_cast<uint32_t>(blitProperties.dstOffset.y + blitProperties.copySize.y));
|
2020-05-21 18:36:23 +08:00
|
|
|
|
|
|
|
bltCmd.setSourceX1CoordinateLeft(static_cast<uint32_t>(blitProperties.srcOffset.x));
|
|
|
|
bltCmd.setSourceY1CoordinateTop(static_cast<uint32_t>(blitProperties.srcOffset.y));
|
|
|
|
|
|
|
|
appendBlitCommandsForBuffer(blitProperties, bltCmd, rootDeviceEnvironment);
|
2020-10-20 21:27:49 +08:00
|
|
|
appendBlitCommandsForImages(blitProperties, bltCmd, rootDeviceEnvironment, srcSlicePitch, dstSlicePitch);
|
2020-05-21 18:36:23 +08:00
|
|
|
appendColorDepth(blitProperties, bltCmd);
|
|
|
|
appendSurfaceType(blitProperties, bltCmd);
|
2021-01-28 18:01:51 +08:00
|
|
|
dispatchPreBlitCommand(linearStream);
|
2020-05-21 18:36:23 +08:00
|
|
|
for (uint32_t i = 0; i < blitProperties.copySize.z; i++) {
|
2020-10-20 21:27:49 +08:00
|
|
|
appendSliceOffsets(blitProperties, bltCmd, i, rootDeviceEnvironment, srcSlicePitch, dstSlicePitch);
|
2020-05-21 18:36:23 +08:00
|
|
|
auto cmd = linearStream.getSpaceForCmd<typename GfxFamily::XY_COPY_BLT>();
|
|
|
|
*cmd = bltCmd;
|
2020-10-20 21:27:49 +08:00
|
|
|
dispatchPostBlitCommand(linearStream);
|
2020-05-21 18:36:23 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-06-17 20:58:28 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
void BlitCommandsHelper<GfxFamily>::dispatchDebugPauseCommands(LinearStream &commandStream, uint64_t debugPauseStateGPUAddress, DebugPauseState confirmationTrigger, DebugPauseState waitCondition) {
|
|
|
|
using MI_SEMAPHORE_WAIT = typename GfxFamily::MI_SEMAPHORE_WAIT;
|
|
|
|
|
2021-06-17 19:55:28 +08:00
|
|
|
MiFlushArgs args;
|
|
|
|
args.commandWithPostSync = true;
|
|
|
|
EncodeMiFlushDW<GfxFamily>::programMiFlushDw(commandStream, debugPauseStateGPUAddress, static_cast<uint32_t>(confirmationTrigger), args);
|
2020-06-17 20:58:28 +08:00
|
|
|
|
2020-10-01 17:59:59 +08:00
|
|
|
EncodeSempahore<GfxFamily>::addMiSemaphoreWaitCommand(commandStream, debugPauseStateGPUAddress, static_cast<uint32_t>(waitCondition), MI_SEMAPHORE_WAIT::COMPARE_OPERATION::COMPARE_OPERATION_SAD_EQUAL_SDD);
|
2020-06-17 20:58:28 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t BlitCommandsHelper<GfxFamily>::getSizeForDebugPauseCommands() {
|
|
|
|
return (EncodeMiFlushDW<GfxFamily>::getMiFlushDwCmdSizeForDataWrite() + EncodeSempahore<GfxFamily>::getSizeMiSemaphoreWait()) * 2;
|
|
|
|
}
|
|
|
|
|
2020-07-02 22:07:22 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
bool BlitCommandsHelper<GfxFamily>::useOneBlitCopyCommand(Vec3<size_t> copySize, uint32_t bytesPerPixel) {
|
|
|
|
return (copySize.x / bytesPerPixel <= BlitterConstants::maxBlitWidth && copySize.y <= BlitterConstants::maxBlitHeight);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2021-06-07 21:58:03 +08:00
|
|
|
uint32_t BlitCommandsHelper<GfxFamily>::getAvailableBytesPerPixel(size_t copySize, uint32_t srcOrigin, uint32_t dstOrigin, size_t srcSize, size_t dstSize) {
|
2020-07-02 22:07:22 +08:00
|
|
|
uint32_t bytesPerPixel = BlitterConstants::maxBytesPerPixel;
|
|
|
|
while (bytesPerPixel > 1) {
|
|
|
|
if (copySize % bytesPerPixel == 0 && srcSize % bytesPerPixel == 0 && dstSize % bytesPerPixel == 0) {
|
|
|
|
if ((srcOrigin ? (srcOrigin % bytesPerPixel == 0) : true) && (dstOrigin ? (dstOrigin % bytesPerPixel == 0) : true)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
bytesPerPixel >>= 1;
|
|
|
|
}
|
|
|
|
return bytesPerPixel;
|
|
|
|
}
|
|
|
|
|
2020-08-25 21:24:09 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
void BlitCommandsHelper<GfxFamily>::dispatchBlitCommands(const BlitProperties &blitProperties, LinearStream &linearStream, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
|
|
|
|
2020-10-20 21:27:49 +08:00
|
|
|
if (blitProperties.blitDirection == BlitterConstants::BlitDirection::HostPtrToImage ||
|
|
|
|
blitProperties.blitDirection == BlitterConstants::BlitDirection::ImageToHostPtr) {
|
2020-11-26 21:50:04 +08:00
|
|
|
dispatchBlitCommandsRegion(blitProperties, linearStream, rootDeviceEnvironment);
|
|
|
|
return;
|
2020-10-20 21:27:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
bool preferCopyBufferRegion = isCopyRegionPreferred(blitProperties.copySize, rootDeviceEnvironment);
|
|
|
|
preferCopyBufferRegion ? dispatchBlitCommandsForBufferRegion(blitProperties, linearStream, rootDeviceEnvironment)
|
|
|
|
: dispatchBlitCommandsForBufferPerRow(blitProperties, linearStream, rootDeviceEnvironment);
|
2020-08-25 21:24:09 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
uint64_t BlitCommandsHelper<GfxFamily>::calculateBlitCommandSourceBaseAddressCopyRegion(const BlitProperties &blitProperties, size_t slice) {
|
|
|
|
return blitProperties.srcGpuAddress + blitProperties.srcOffset.x +
|
|
|
|
(blitProperties.srcOffset.y * blitProperties.srcRowPitch) +
|
|
|
|
(blitProperties.srcSlicePitch * (slice + blitProperties.srcOffset.z));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
uint64_t BlitCommandsHelper<GfxFamily>::calculateBlitCommandDestinationBaseAddressCopyRegion(const BlitProperties &blitProperties, size_t slice) {
|
|
|
|
return blitProperties.dstGpuAddress + blitProperties.dstOffset.x +
|
|
|
|
(blitProperties.dstOffset.y * blitProperties.dstRowPitch) +
|
|
|
|
(blitProperties.dstSlicePitch * (slice + blitProperties.dstOffset.z));
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBufferRegion(const BlitProperties &blitProperties, LinearStream &linearStream, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
|
|
|
const auto maxWidthToCopy = getMaxBlitWidth(rootDeviceEnvironment);
|
|
|
|
const auto maxHeightToCopy = getMaxBlitHeight(rootDeviceEnvironment);
|
|
|
|
|
2021-01-28 18:01:51 +08:00
|
|
|
dispatchPreBlitCommand(linearStream);
|
|
|
|
|
2020-08-25 21:24:09 +08:00
|
|
|
for (size_t slice = 0u; slice < blitProperties.copySize.z; ++slice) {
|
|
|
|
auto srcAddress = calculateBlitCommandSourceBaseAddressCopyRegion(blitProperties, slice);
|
|
|
|
auto dstAddress = calculateBlitCommandDestinationBaseAddressCopyRegion(blitProperties, slice);
|
|
|
|
auto heightToCopy = blitProperties.copySize.y;
|
|
|
|
|
|
|
|
while (heightToCopy > 0) {
|
|
|
|
auto height = static_cast<uint32_t>(std::min(heightToCopy, static_cast<size_t>(maxHeightToCopy)));
|
|
|
|
auto widthToCopy = blitProperties.copySize.x;
|
|
|
|
|
|
|
|
while (widthToCopy > 0) {
|
|
|
|
auto width = static_cast<uint32_t>(std::min(widthToCopy, static_cast<size_t>(maxWidthToCopy)));
|
|
|
|
auto bltCmd = GfxFamily::cmdInitXyCopyBlt;
|
|
|
|
|
|
|
|
bltCmd.setSourceBaseAddress(srcAddress);
|
|
|
|
bltCmd.setDestinationBaseAddress(dstAddress);
|
2021-06-04 23:22:06 +08:00
|
|
|
bltCmd.setDestinationX2CoordinateRight(width);
|
|
|
|
bltCmd.setDestinationY2CoordinateBottom(height);
|
2020-08-25 21:24:09 +08:00
|
|
|
bltCmd.setSourcePitch(static_cast<uint32_t>(blitProperties.srcRowPitch));
|
|
|
|
bltCmd.setDestinationPitch(static_cast<uint32_t>(blitProperties.dstRowPitch));
|
|
|
|
|
|
|
|
appendBlitCommandsForBuffer(blitProperties, bltCmd, rootDeviceEnvironment);
|
|
|
|
|
|
|
|
auto cmd = linearStream.getSpaceForCmd<typename GfxFamily::XY_COPY_BLT>();
|
|
|
|
*cmd = bltCmd;
|
|
|
|
dispatchPostBlitCommand(linearStream);
|
|
|
|
|
|
|
|
srcAddress += width;
|
|
|
|
dstAddress += width;
|
|
|
|
widthToCopy -= width;
|
|
|
|
}
|
|
|
|
|
|
|
|
heightToCopy -= height;
|
|
|
|
srcAddress += (blitProperties.srcRowPitch - blitProperties.copySize.x);
|
|
|
|
srcAddress += (blitProperties.srcRowPitch * (height - 1));
|
|
|
|
dstAddress += (blitProperties.dstRowPitch - blitProperties.copySize.x);
|
|
|
|
dstAddress += (blitProperties.dstRowPitch * (height - 1));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
bool BlitCommandsHelper<GfxFamily>::isCopyRegionPreferred(const Vec3<size_t> ©Size, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
|
|
|
bool preferCopyRegion = getNumberOfBlitsForCopyRegion(copySize, rootDeviceEnvironment) < getNumberOfBlitsForCopyPerRow(copySize, rootDeviceEnvironment);
|
|
|
|
return preferCopyRegion;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t BlitCommandsHelper<GfxFamily>::getNumberOfBlitsForCopyRegion(const Vec3<size_t> ©Size, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
|
|
|
auto maxWidthToCopy = getMaxBlitWidth(rootDeviceEnvironment);
|
|
|
|
auto maxHeightToCopy = getMaxBlitHeight(rootDeviceEnvironment);
|
|
|
|
auto xBlits = static_cast<size_t>(std::ceil(copySize.x / static_cast<double>(maxWidthToCopy)));
|
|
|
|
auto yBlits = static_cast<size_t>(std::ceil(copySize.y / static_cast<double>(maxHeightToCopy)));
|
|
|
|
auto zBlits = static_cast<size_t>(copySize.z);
|
|
|
|
auto nBlits = xBlits * yBlits * zBlits;
|
|
|
|
|
|
|
|
return nBlits;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t BlitCommandsHelper<GfxFamily>::getNumberOfBlitsForCopyPerRow(const Vec3<size_t> ©Size, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
|
|
|
size_t xBlits = 0u;
|
|
|
|
uint64_t width = 1;
|
|
|
|
uint64_t height = 1;
|
|
|
|
uint64_t sizeToBlit = copySize.x;
|
|
|
|
|
|
|
|
while (sizeToBlit != 0) {
|
|
|
|
if (sizeToBlit > getMaxBlitWidth(rootDeviceEnvironment)) {
|
|
|
|
// dispatch 2D blit: maxBlitWidth x (1 .. maxBlitHeight)
|
|
|
|
width = getMaxBlitWidth(rootDeviceEnvironment);
|
|
|
|
height = std::min((sizeToBlit / width), getMaxBlitHeight(rootDeviceEnvironment));
|
|
|
|
|
|
|
|
} else {
|
|
|
|
// dispatch 1D blt: (1 .. maxBlitWidth) x 1
|
|
|
|
width = sizeToBlit;
|
|
|
|
height = 1;
|
|
|
|
}
|
|
|
|
sizeToBlit -= (width * height);
|
|
|
|
xBlits++;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto yBlits = copySize.y;
|
|
|
|
auto zBlits = copySize.z;
|
|
|
|
auto nBlits = xBlits * yBlits * zBlits;
|
|
|
|
|
|
|
|
return nBlits;
|
|
|
|
}
|
|
|
|
|
2021-01-28 18:01:51 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
bool BlitCommandsHelper<GfxFamily>::preBlitCommandWARequired() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-11-26 00:09:44 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
void BlitCommandsHelper<GfxFamily>::appendExtraMemoryProperties(typename GfxFamily::XY_COPY_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) {}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
void BlitCommandsHelper<GfxFamily>::appendExtraMemoryProperties(typename GfxFamily::XY_COLOR_BLT &blitCmd, const RootDeviceEnvironment &rootDeviceEnvironment) {}
|
|
|
|
|
2021-04-01 19:54:16 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
void BlitCommandsHelper<GfxFamily>::encodeProfilingStartMmios(LinearStream &cmdStream, const TagNodeBase ×tampPacketNode) {
|
|
|
|
auto timestampContextStartGpuAddress = TimestampPacketHelper::getContextStartGpuAddress(timestampPacketNode);
|
|
|
|
auto timestampGlobalStartAddress = TimestampPacketHelper::getGlobalStartGpuAddress(timestampPacketNode);
|
|
|
|
|
|
|
|
EncodeStoreMMIO<GfxFamily>::encode(cmdStream, GP_THREAD_TIME_REG_ADDRESS_OFFSET_LOW, timestampContextStartGpuAddress);
|
|
|
|
EncodeStoreMMIO<GfxFamily>::encode(cmdStream, REG_GLOBAL_TIMESTAMP_LDW, timestampGlobalStartAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
void BlitCommandsHelper<GfxFamily>::encodeProfilingEndMmios(LinearStream &cmdStream, const TagNodeBase ×tampPacketNode) {
|
|
|
|
auto timestampContextEndGpuAddress = TimestampPacketHelper::getContextEndGpuAddress(timestampPacketNode);
|
|
|
|
auto timestampGlobalEndAddress = TimestampPacketHelper::getGlobalEndGpuAddress(timestampPacketNode);
|
|
|
|
|
|
|
|
EncodeStoreMMIO<GfxFamily>::encode(cmdStream, GP_THREAD_TIME_REG_ADDRESS_OFFSET_LOW, timestampContextEndGpuAddress);
|
|
|
|
EncodeStoreMMIO<GfxFamily>::encode(cmdStream, REG_GLOBAL_TIMESTAMP_LDW, timestampGlobalEndAddress);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
size_t BlitCommandsHelper<GfxFamily>::getProfilingMmioCmdsSize() {
|
|
|
|
return 4 * sizeof(typename GfxFamily::MI_STORE_REGISTER_MEM);
|
|
|
|
}
|
2019-04-03 21:59:31 +08:00
|
|
|
} // namespace NEO
|