2019-04-03 21:59:31 +08:00
|
|
|
/*
|
2020-02-05 23:07:52 +08:00
|
|
|
* Copyright (C) 2019-2020 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-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/helpers/blit_commands_helper.h"
|
|
|
|
#include "shared/source/helpers/hw_helper.h"
|
|
|
|
#include "shared/source/helpers/timestamp_packet.h"
|
2019-04-03 21:59:31 +08:00
|
|
|
|
|
|
|
namespace NEO {
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2019-06-27 22:08:20 +08:00
|
|
|
size_t BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(uint64_t copySize, const CsrDependencies &csrDependencies, bool updateTimestampPacket) {
|
2019-04-03 21:59:31 +08:00
|
|
|
size_t numberOfBlits = 0;
|
|
|
|
uint64_t sizeToBlit = copySize;
|
|
|
|
uint64_t width = 1;
|
|
|
|
uint64_t height = 1;
|
|
|
|
|
|
|
|
while (sizeToBlit != 0) {
|
|
|
|
if (sizeToBlit > BlitterConstants::maxBlitWidth) {
|
|
|
|
// 2D: maxBlitWidth x (1 .. maxBlitHeight)
|
|
|
|
width = BlitterConstants::maxBlitWidth;
|
|
|
|
height = std::min((sizeToBlit / width), BlitterConstants::maxBlitHeight);
|
|
|
|
} else {
|
|
|
|
// 1D: (1 .. maxBlitWidth) x 1
|
|
|
|
width = sizeToBlit;
|
|
|
|
height = 1;
|
|
|
|
}
|
|
|
|
sizeToBlit -= (width * height);
|
|
|
|
numberOfBlits++;
|
|
|
|
}
|
|
|
|
|
2019-11-07 16:15:53 +08:00
|
|
|
return TimestampPacketHelper::getRequiredCmdStreamSize<GfxFamily>(csrDependencies) +
|
|
|
|
(sizeof(typename GfxFamily::XY_COPY_BLT) * numberOfBlits) +
|
2020-03-13 19:29:45 +08:00
|
|
|
(EncodeMiFlushDW<GfxFamily>::getMiFlushDwCmdSizeForDataWrite() * static_cast<size_t>(updateTimestampPacket));
|
2019-11-07 16:15:53 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2020-02-11 01:14:52 +08:00
|
|
|
size_t BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(const BlitPropertiesContainer &blitPropertiesContainer, const HardwareInfo &hwInfo) {
|
2019-11-07 16:15:53 +08:00
|
|
|
size_t size = 0;
|
|
|
|
for (auto &blitProperties : blitPropertiesContainer) {
|
|
|
|
size += BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(blitProperties.copySize, blitProperties.csrDependencies,
|
|
|
|
blitProperties.outputTimestampPacket != nullptr);
|
|
|
|
}
|
2020-02-17 19:45:24 +08:00
|
|
|
size += MemorySynchronizationCommands<GfxFamily>::getSizeForAdditonalSynchronization(hwInfo);
|
2020-03-13 19:29:45 +08:00
|
|
|
size += EncodeMiFlushDW<GfxFamily>::getMiFlushDwCmdSizeForDataWrite() + sizeof(typename GfxFamily::MI_BATCH_BUFFER_END);
|
2019-04-03 21:59:31 +08:00
|
|
|
|
|
|
|
return alignUp(size, MemoryConstants::cacheLineSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
template <typename GfxFamily>
|
2020-02-10 21:17:12 +08:00
|
|
|
void BlitCommandsHelper<GfxFamily>::dispatchBlitCommandsForBuffer(const BlitProperties &blitProperties, LinearStream &linearStream, const RootDeviceEnvironment &rootDeviceEnvironment) {
|
2019-10-28 18:54:59 +08:00
|
|
|
uint64_t sizeToBlit = blitProperties.copySize;
|
2019-04-03 21:59:31 +08:00
|
|
|
uint64_t width = 1;
|
|
|
|
uint64_t height = 1;
|
|
|
|
uint64_t offset = 0;
|
|
|
|
|
|
|
|
while (sizeToBlit != 0) {
|
|
|
|
if (sizeToBlit > BlitterConstants::maxBlitWidth) {
|
|
|
|
// dispatch 2D blit: maxBlitWidth x (1 .. maxBlitHeight)
|
|
|
|
width = BlitterConstants::maxBlitWidth;
|
|
|
|
height = std::min((sizeToBlit / width), BlitterConstants::maxBlitHeight);
|
|
|
|
} else {
|
|
|
|
// dispatch 1D blt: (1 .. maxBlitWidth) x 1
|
|
|
|
width = sizeToBlit;
|
|
|
|
height = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto bltCmd = linearStream.getSpaceForCmd<typename GfxFamily::XY_COPY_BLT>();
|
|
|
|
*bltCmd = GfxFamily::cmdInitXyCopyBlt;
|
|
|
|
|
2019-11-28 17:50:10 +08:00
|
|
|
bltCmd->setTransferWidth(static_cast<uint32_t>(width));
|
|
|
|
bltCmd->setTransferHeight(static_cast<uint32_t>(height));
|
2019-04-03 21:59:31 +08:00
|
|
|
|
2019-05-09 16:56:25 +08:00
|
|
|
bltCmd->setDestinationPitch(static_cast<uint32_t>(width));
|
|
|
|
bltCmd->setSourcePitch(static_cast<uint32_t>(width));
|
|
|
|
|
2019-12-12 17:47:28 +08:00
|
|
|
bltCmd->setDestinationBaseAddress(blitProperties.dstGpuAddress + blitProperties.dstOffset + offset);
|
|
|
|
bltCmd->setSourceBaseAddress(blitProperties.srcGpuAddress + blitProperties.srcOffset + offset);
|
2019-04-03 21:59:31 +08:00
|
|
|
|
2020-02-10 21:17:12 +08:00
|
|
|
appendBlitCommandsForBuffer(blitProperties, *bltCmd, rootDeviceEnvironment);
|
2019-04-11 15:12:52 +08:00
|
|
|
|
2019-04-03 21:59:31 +08:00
|
|
|
auto blitSize = width * height;
|
|
|
|
sizeToBlit -= blitSize;
|
|
|
|
offset += blitSize;
|
|
|
|
}
|
|
|
|
}
|
2019-04-11 15:12:52 +08:00
|
|
|
|
2019-04-03 21:59:31 +08:00
|
|
|
} // namespace NEO
|