2017-12-21 07:45:38 +08:00
/*
2019-12-31 17:45:14 +08:00
* Copyright (C) 2019-2020 Intel Corporation
2017-12-21 07:45:38 +08:00
*
2018-09-19 03:29:07 +08:00
* SPDX-License-Identifier: MIT
2017-12-21 07:45:38 +08:00
*
*/
2020-02-24 05:44:01 +08:00
#include "shared/source/command_stream/command_stream_receiver_hw.h"
#include "shared/source/command_stream/experimental_command_buffer.h"
#include "shared/source/command_stream/linear_stream.h"
#include "shared/source/command_stream/preemption.h"
#include "shared/source/command_stream/scratch_space_controller_base.h"
#include "shared/source/debug_settings/debug_settings_manager.h"
#include "shared/source/device/device.h"
#include "shared/source/direct_submission/direct_submission_hw.h"
#include "shared/source/execution_environment/root_device_environment.h"
#include "shared/source/gmm_helper/page_table_mngr.h"
#include "shared/source/helpers/blit_commands_helper.h"
#include "shared/source/helpers/cache_policy.h"
#include "shared/source/helpers/flat_batch_buffer_helper_hw.h"
#include "shared/source/helpers/flush_stamp.h"
#include "shared/source/helpers/hw_helper.h"
#include "shared/source/helpers/preamble.h"
#include "shared/source/helpers/ptr_math.h"
#include "shared/source/helpers/state_base_address.h"
#include "shared/source/helpers/timestamp_packet.h"
#include "shared/source/indirect_heap/indirect_heap.h"
#include "shared/source/memory_manager/internal_allocation_storage.h"
#include "shared/source/memory_manager/memory_manager.h"
#include "shared/source/os_interface/os_context.h"
#include "shared/source/utilities/tag_allocator.h"
2017-12-21 07:45:38 +08:00
2019-10-11 12:54:10 +08:00
#include "command_stream_receiver_hw_ext.inl"
2020-04-27 03:48:59 +08:00
#include "pipe_control_args.h"
2019-10-11 12:54:10 +08:00
2019-03-26 18:59:46 +08:00
namespace NEO {
2017-12-21 07:45:38 +08:00
2020-01-16 00:02:47 +08:00
template <typename GfxFamily>
CommandStreamReceiverHw<GfxFamily>::~CommandStreamReceiverHw() = default;
2018-02-20 15:11:24 +08:00
template <typename GfxFamily>
2019-10-29 15:01:53 +08:00
CommandStreamReceiverHw<GfxFamily>::CommandStreamReceiverHw(ExecutionEnvironment &executionEnvironment, uint32_t rootDeviceIndex)
: CommandStreamReceiver(executionEnvironment, rootDeviceIndex) {
2018-10-18 19:40:53 +08:00
2019-05-08 22:00:24 +08:00
auto &hwHelper = HwHelper::get(peekHwInfo().platform.eRenderCoreFamily);
2019-02-27 17:06:14 +08:00
localMemoryEnabled = hwHelper.getEnableLocalMemory(peekHwInfo());
2018-10-18 19:40:53 +08:00
2020-08-04 02:39:06 +08:00
requiredThreadArbitrationPolicy = hwHelper.getDefaultThreadArbitrationPolicy();
2019-02-27 17:06:14 +08:00
resetKmdNotifyHelper(new KmdNotifyHelper(&peekHwInfo().capabilityTable.kmdNotifyProperties));
2018-10-11 17:19:49 +08:00
flatBatchBufferHelper.reset(new FlatBatchBufferHelperHw<GfxFamily>(executionEnvironment));
2018-09-03 22:44:42 +08:00
defaultSshSize = getSshHeapSize();
2018-10-18 19:40:53 +08:00
timestampPacketWriteEnabled = hwHelper.timestampPacketWriteSupported();
if (DebugManager.flags.EnableTimestampPacket.get() != -1) {
timestampPacketWriteEnabled = !!DebugManager.flags.EnableTimestampPacket.get();
}
2019-03-29 07:49:23 +08:00
createScratchSpaceController();
2018-02-20 15:11:24 +08:00
}
2018-02-02 17:33:31 +08:00
template <typename GfxFamily>
2019-11-24 21:50:41 +08:00
bool CommandStreamReceiverHw<GfxFamily>::flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) {
return true;
2018-02-02 17:33:31 +08:00
}
2017-12-21 07:45:38 +08:00
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::addBatchBufferEnd(LinearStream &commandStream, void **patchLocation) {
2020-04-27 03:48:59 +08:00
using MI_BATCH_BUFFER_END = typename GfxFamily::MI_BATCH_BUFFER_END;
2017-12-21 07:45:38 +08:00
2020-04-27 03:48:59 +08:00
auto pCmd = commandStream.getSpaceForCmd<MI_BATCH_BUFFER_END>();
2017-12-21 07:45:38 +08:00
*pCmd = GfxFamily::cmdInitBatchBufferEnd;
if (patchLocation) {
*patchLocation = pCmd;
}
}
2020-01-16 00:02:47 +08:00
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::programEndingCmd(LinearStream &commandStream, void **patchLocation, bool directSubmissionEnabled) {
if (directSubmissionEnabled) {
*patchLocation = commandStream.getSpace(sizeof(MI_BATCH_BUFFER_START));
auto bbStart = reinterpret_cast<MI_BATCH_BUFFER_START *>(*patchLocation);
2020-04-28 00:55:26 +08:00
MI_BATCH_BUFFER_START cmd = {};
addBatchBufferStart(&cmd, 0ull, false);
*bbStart = cmd;
2020-01-16 00:02:47 +08:00
} else {
this->addBatchBufferEnd(commandStream, patchLocation);
}
}
2017-12-21 07:45:38 +08:00
template <typename GfxFamily>
2018-07-05 17:23:28 +08:00
inline void CommandStreamReceiverHw<GfxFamily>::addBatchBufferStart(MI_BATCH_BUFFER_START *commandBufferMemory, uint64_t startAddress, bool secondary) {
2020-04-28 00:55:26 +08:00
MI_BATCH_BUFFER_START cmd = GfxFamily::cmdInitBatchBufferStart;
cmd.setBatchBufferStartAddressGraphicsaddress472(startAddress);
cmd.setAddressSpaceIndicator(MI_BATCH_BUFFER_START::ADDRESS_SPACE_INDICATOR_PPGTT);
2018-07-05 17:23:28 +08:00
if (secondary) {
2020-04-28 00:55:26 +08:00
cmd.setSecondLevelBatchBuffer(MI_BATCH_BUFFER_START::SECOND_LEVEL_BATCH_BUFFER_SECOND_LEVEL_BATCH);
2018-07-05 17:23:28 +08:00
}
2018-04-04 17:34:46 +08:00
if (DebugManager.flags.FlattenBatchBufferForAUBDump.get()) {
flatBatchBufferHelper->registerBatchBufferStartAddress(reinterpret_cast<uint64_t>(commandBufferMemory), startAddress);
}
2020-04-28 00:55:26 +08:00
*commandBufferMemory = cmd;
2017-12-21 07:45:38 +08:00
}
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::alignToCacheLine(LinearStream &commandStream) {
auto used = commandStream.getUsed();
auto alignment = MemoryConstants::cacheLineSize;
auto partialCacheline = used & (alignment - 1);
if (partialCacheline) {
auto amountToPad = alignment - partialCacheline;
auto pCmd = commandStream.getSpace(amountToPad);
memset(pCmd, 0, amountToPad);
}
}
2019-05-16 23:17:53 +08:00
template <typename GfxFamily>
inline size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdSizeForPreamble(Device &device) const {
size_t size = 0;
if (mediaVfeStateDirty) {
size += PreambleHelper<GfxFamily>::getVFECommandsSize();
}
if (!this->isPreambleSent) {
size += PreambleHelper<GfxFamily>::getAdditionalCommandsSize(device);
}
if (!this->isPreambleSent || this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy) {
size += PreambleHelper<GfxFamily>::getThreadArbitrationCommandsSize();
}
2019-09-04 22:44:27 +08:00
if (DebugManager.flags.ForcePerDssBackedBufferProgramming.get()) {
if (!this->isPreambleSent) {
size += PreambleHelper<GfxFamily>::getPerDssBackedBufferCommandsSize(device.getHardwareInfo());
}
}
2020-06-24 20:53:51 +08:00
if (!this->isPreambleSent) {
if (DebugManager.flags.ForceSemaphoreDelayBetweenWaits.get() > -1) {
size += PreambleHelper<GfxFamily>::getSemaphoreDelayCommandSize();
}
}
2019-05-16 23:17:53 +08:00
return size;
}
2017-12-21 07:45:38 +08:00
template <typename GfxFamily>
2020-04-27 03:48:59 +08:00
inline void CommandStreamReceiverHw<GfxFamily>::addPipeControlCmd(
LinearStream &commandStream,
PipeControlArgs &args) {
MemorySynchronizationCommands<GfxFamily>::addPipeControl(commandStream, args);
2017-12-21 07:45:38 +08:00
}
2020-05-27 21:30:31 +08:00
template <typename GfxFamily>
2020-05-23 00:11:28 +08:00
void CommandStreamReceiverHw<GfxFamily>::programHardwareContext(LinearStream &cmdStream) {
programEnginePrologue(cmdStream);
2020-05-27 21:30:31 +08:00
}
template <typename GfxFamily>
size_t CommandStreamReceiverHw<GfxFamily>::getCmdsSizeForHardwareContext() const {
return getCmdSizeForPrologue();
}
2017-12-21 07:45:38 +08:00
template <typename GfxFamily>
CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
LinearStream &commandStreamTask,
size_t commandStreamStartTask,
2018-04-17 19:50:50 +08:00
const IndirectHeap &dsh,
const IndirectHeap &ioh,
const IndirectHeap &ssh,
2017-12-21 07:45:38 +08:00
uint32_t taskLevel,
2018-08-01 16:01:41 +08:00
DispatchFlags &dispatchFlags,
Device &device) {
2017-12-21 07:45:38 +08:00
typedef typename GfxFamily::MI_BATCH_BUFFER_START MI_BATCH_BUFFER_START;
typedef typename GfxFamily::MI_BATCH_BUFFER_END MI_BATCH_BUFFER_END;
typedef typename GfxFamily::PIPE_CONTROL PIPE_CONTROL;
typedef typename GfxFamily::STATE_BASE_ADDRESS STATE_BASE_ADDRESS;
DEBUG_BREAK_IF(&commandStreamTask == &commandStream);
2018-08-01 16:01:41 +08:00
DEBUG_BREAK_IF(!(dispatchFlags.preemptionMode == PreemptionMode::Disabled ? device.getPreemptionMode() == PreemptionMode::Disabled : true));
2020-06-16 19:19:11 +08:00
DEBUG_BREAK_IF(taskLevel >= CompletionStamp::notReady);
2017-12-21 07:45:38 +08:00
DBG_LOG(LogTaskCounts, __FUNCTION__, "Line: ", __LINE__, "taskLevel", taskLevel);
auto levelClosed = false;
void *currentPipeControlForNooping = nullptr;
2018-02-15 15:29:57 +08:00
void *epiloguePipeControlLocation = nullptr;
2017-12-21 07:45:38 +08:00
2018-06-13 02:33:03 +08:00
if (DebugManager.flags.ForceCsrFlushing.get()) {
flushBatchedSubmissions();
}
2020-06-19 15:50:04 +08:00
if (DebugManager.flags.ForceImplicitFlush.get()) {
dispatchFlags.implicitFlush = true;
}
2019-01-28 20:44:59 +08:00
if (detectInitProgrammingFlagsRequired(dispatchFlags)) {
2018-06-13 02:33:03 +08:00
initProgrammingFlags();
}
2017-12-21 07:45:38 +08:00
if (dispatchFlags.blocking || dispatchFlags.dcFlush || dispatchFlags.guardCommandBufferWithPipeControl) {
2018-04-04 17:34:46 +08:00
if (this->dispatchMode == DispatchMode::ImmediateDispatch) {
2017-12-21 07:45:38 +08:00
//for ImmediateDispatch we will send this right away, therefore this pipe control will close the level
//for BatchedSubmissions it will be nooped and only last ppc in batch will be emitted.
levelClosed = true;
2018-02-13 17:01:20 +08:00
//if we guard with ppc, flush dc as well to speed up completion latency
if (dispatchFlags.guardCommandBufferWithPipeControl) {
dispatchFlags.dcFlush = true;
}
2017-12-21 07:45:38 +08:00
}
2018-03-05 18:03:38 +08:00
epiloguePipeControlLocation = ptrOffset(commandStreamTask.getCpuBase(), commandStreamTask.getUsed());
2018-02-15 15:29:57 +08:00
2018-09-06 15:03:07 +08:00
if ((dispatchFlags.outOfOrderExecutionAllowed || timestampPacketWriteEnabled) &&
2018-08-30 17:05:18 +08:00
!dispatchFlags.dcFlush) {
2018-02-15 15:29:57 +08:00
currentPipeControlForNooping = epiloguePipeControlLocation;
2017-12-21 07:45:38 +08:00
}
2018-11-23 17:32:15 +08:00
auto address = getTagAllocation()->getGpuAddress();
2020-04-27 03:48:59 +08:00
PipeControlArgs args(dispatchFlags.dcFlush);
MemorySynchronizationCommands<GfxFamily>::addPipeControlAndProgramPostSyncOperation(
commandStreamTask,
PIPE_CONTROL::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA,
address,
taskCount + 1,
peekHwInfo(),
args);
2017-12-21 07:45:38 +08:00
this->latestSentTaskCount = taskCount + 1;
2020-07-18 00:33:16 +08:00
DBG_LOG(LogTaskCounts, __FUNCTION__, "Line: ", __LINE__, "taskCount", peekTaskCount());
2018-04-04 17:34:46 +08:00
if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) {
flatBatchBufferHelper->setPatchInfoData(PatchInfoData(address, 0u,
PatchInfoAllocationType::TagAddress,
commandStreamTask.getGraphicsAllocation()->getGpuAddress(),
commandStreamTask.getUsed() - 2 * sizeof(uint64_t),
PatchInfoAllocationType::Default));
flatBatchBufferHelper->setPatchInfoData(PatchInfoData(address, 0u,
PatchInfoAllocationType::TagValue,
commandStreamTask.getGraphicsAllocation()->getGpuAddress(),
commandStreamTask.getUsed() - sizeof(uint64_t),
PatchInfoAllocationType::Default));
}
2017-12-21 07:45:38 +08:00
}
if (DebugManager.flags.ForceSLML3Config.get()) {
dispatchFlags.useSLM = true;
}
2018-02-20 15:11:24 +08:00
if (DebugManager.flags.OverrideThreadArbitrationPolicy.get() != -1) {
2019-11-12 20:59:37 +08:00
dispatchFlags.threadArbitrationPolicy = static_cast<uint32_t>(DebugManager.flags.OverrideThreadArbitrationPolicy.get());
2018-02-20 15:11:24 +08:00
}
2017-12-21 07:45:38 +08:00
2018-02-15 03:14:20 +08:00
auto newL3Config = PreambleHelper<GfxFamily>::getL3Config(peekHwInfo(), dispatchFlags.useSLM);
2017-12-21 07:45:38 +08:00
csrSizeRequestFlags.l3ConfigChanged = this->lastSentL3Config != newL3Config;
csrSizeRequestFlags.coherencyRequestChanged = this->lastSentCoherencyRequest != static_cast<int8_t>(dispatchFlags.requiresCoherency);
csrSizeRequestFlags.preemptionRequestChanged = this->lastPreemptionMode != dispatchFlags.preemptionMode;
2019-09-10 22:13:11 +08:00
csrSizeRequestFlags.mediaSamplerConfigChanged = this->lastMediaSamplerConfig != static_cast<int8_t>(dispatchFlags.pipelineSelectArgs.mediaSamplerRequired);
csrSizeRequestFlags.specialPipelineSelectModeChanged = this->lastSpecialPipelineSelectMode != dispatchFlags.pipelineSelectArgs.specialPipelineSelectMode;
2019-10-25 23:55:22 +08:00
csrSizeRequestFlags.numGrfRequiredChanged = this->lastSentNumGrfRequired != dispatchFlags.numGrfRequired;
lastSentNumGrfRequired = dispatchFlags.numGrfRequired;
2017-12-21 07:45:38 +08:00
2019-11-12 20:59:37 +08:00
if (dispatchFlags.threadArbitrationPolicy != ThreadArbitrationPolicy::NotPresent) {
this->requiredThreadArbitrationPolicy = dispatchFlags.threadArbitrationPolicy;
}
2017-12-21 07:45:38 +08:00
auto force32BitAllocations = getMemoryManager()->peekForce32BitAllocations();
bool stateBaseAddressDirty = false;
2018-11-22 22:16:20 +08:00
bool checkVfeStateDirty = false;
2019-07-15 15:12:53 +08:00
if (requiredScratchSize || requiredPrivateScratchSize) {
2018-11-22 22:16:20 +08:00
scratchSpaceController->setRequiredScratchSpace(ssh.getCpuBase(),
requiredScratchSize,
2019-06-28 15:37:04 +08:00
requiredPrivateScratchSize,
2018-11-22 22:16:20 +08:00
this->taskCount,
2019-09-16 20:59:54 +08:00
*this->osContext,
2018-11-22 22:16:20 +08:00
stateBaseAddressDirty,
checkVfeStateDirty);
if (checkVfeStateDirty) {
2018-12-13 18:06:28 +08:00
setMediaVFEStateDirty(true);
2017-12-21 07:45:38 +08:00
}
2019-07-15 15:12:53 +08:00
if (scratchSpaceController->getScratchSpaceAllocation()) {
makeResident(*scratchSpaceController->getScratchSpaceAllocation());
}
if (scratchSpaceController->getPrivateScratchSpaceAllocation()) {
makeResident(*scratchSpaceController->getPrivateScratchSpaceAllocation());
}
2017-12-21 07:45:38 +08:00
}
2020-01-29 21:15:10 +08:00
if (dispatchFlags.usePerDssBackedBuffer) {
2019-09-04 22:44:27 +08:00
if (!perDssBackedBuffer) {
createPerDssBackedBuffer(device);
}
makeResident(*perDssBackedBuffer);
}
2018-08-07 15:07:50 +08:00
auto &commandStreamCSR = this->getCS(getRequiredCmdStreamSizeAligned(dispatchFlags, device));
2018-05-15 15:46:22 +08:00
auto commandStreamStartCSR = commandStreamCSR.getUsed();
2020-05-14 20:33:03 +08:00
TimestampPacketHelper::programCsrDependencies<GfxFamily>(commandStreamCSR, dispatchFlags.csrDependencies, getOsContext().getNumSupportedDevices());
2019-01-25 17:20:32 +08:00
2018-10-15 16:35:45 +08:00
if (stallingPipeControlOnNextFlushRequired) {
2019-10-03 20:38:49 +08:00
programStallingPipeControlForBarrier(commandStreamCSR, dispatchFlags);
2018-10-06 03:51:57 +08:00
}
2019-10-03 20:38:49 +08:00
2019-10-11 12:54:10 +08:00
programEngineModeCommands(commandStreamCSR, dispatchFlags);
2019-12-31 17:45:14 +08:00
if (executionEnvironment.rootDeviceEnvironments[device.getRootDeviceIndex()]->pageTableManager.get() && !pageTableManagerInitialized) {
pageTableManagerInitialized = executionEnvironment.rootDeviceEnvironments[device.getRootDeviceIndex()]->pageTableManager->initPageTableManagerRegisters(this);
2019-11-07 01:14:30 +08:00
}
2020-05-27 21:30:31 +08:00
2020-05-23 00:11:28 +08:00
programHardwareContext(commandStreamCSR);
2018-09-21 20:06:35 +08:00
programComputeMode(commandStreamCSR, dispatchFlags);
2019-09-10 22:13:11 +08:00
programPipelineSelect(commandStreamCSR, dispatchFlags.pipelineSelectArgs);
2020-03-19 22:15:51 +08:00
programL3(commandStreamCSR, dispatchFlags, newL3Config);
2018-08-16 17:18:05 +08:00
programPreamble(commandStreamCSR, device, dispatchFlags, newL3Config);
2018-05-15 15:46:22 +08:00
programMediaSampler(commandStreamCSR, dispatchFlags);
2018-02-20 15:11:24 +08:00
if (this->lastSentThreadArbitrationPolicy != this->requiredThreadArbitrationPolicy) {
2017-12-21 07:45:38 +08:00
PreambleHelper<GfxFamily>::programThreadArbitration(&commandStreamCSR, this->requiredThreadArbitrationPolicy);
2018-02-20 15:11:24 +08:00
this->lastSentThreadArbitrationPolicy = this->requiredThreadArbitrationPolicy;
2017-12-21 07:45:38 +08:00
}
2019-09-13 18:00:30 +08:00
stateBaseAddressDirty |= ((GSBAFor32BitProgrammed ^ dispatchFlags.gsba32BitRequired) && force32BitAllocations);
2017-12-21 07:45:38 +08:00
2019-05-29 21:37:54 +08:00
programVFEState(commandStreamCSR, dispatchFlags, device.getDeviceInfo().maxFrontEndThreads);
2017-12-21 07:45:38 +08:00
2019-10-08 01:54:39 +08:00
programPreemption(commandStreamCSR, dispatchFlags);
2017-12-21 07:45:38 +08:00
bool dshDirty = dshState.updateAndCheck(&dsh);
bool iohDirty = iohState.updateAndCheck(&ioh);
bool sshDirty = sshState.updateAndCheck(&ssh);
2018-03-27 18:55:20 +08:00
auto isStateBaseAddressDirty = dshDirty || iohDirty || sshDirty || stateBaseAddressDirty;
2017-12-21 07:45:38 +08:00
2020-08-20 17:48:10 +08:00
auto mocsIndex = latestSentStatelessMocsConfig;
if (dispatchFlags.l3CacheSettings != L3CachingSettings::NotApplicable) {
auto &hwHelper = HwHelper::get(peekHwInfo().platform.eRenderCoreFamily);
auto l3On = dispatchFlags.l3CacheSettings != L3CachingSettings::l3CacheOff;
auto l1On = dispatchFlags.l3CacheSettings == L3CachingSettings::l3AndL1On;
mocsIndex = hwHelper.getMocsIndex(*device.getGmmHelper(), l3On, l1On);
}
2017-12-21 07:45:38 +08:00
2019-08-26 21:15:22 +08:00
if (mocsIndex != latestSentStatelessMocsConfig) {
2017-12-21 07:45:38 +08:00
isStateBaseAddressDirty = true;
2019-08-27 20:18:06 +08:00
latestSentStatelessMocsConfig = mocsIndex;
2017-12-21 07:45:38 +08:00
}
2020-06-22 23:13:30 +08:00
bool sourceLevelDebuggerActive = device.getSourceLevelDebugger() != nullptr ? true : false;
2017-12-21 07:45:38 +08:00
//Reprogram state base address if required
2020-06-22 23:13:30 +08:00
if (isStateBaseAddressDirty || sourceLevelDebuggerActive) {
2019-07-19 18:45:56 +08:00
addPipeControlBeforeStateBaseAddress(commandStreamCSR);
2020-03-19 22:15:51 +08:00
programAdditionalPipelineSelect(commandStreamCSR, dispatchFlags.pipelineSelectArgs, true);
2017-12-21 07:45:38 +08:00
uint64_t newGSHbase = 0;
GSBAFor32BitProgrammed = false;
2018-11-22 22:16:20 +08:00
if (is64bit && scratchSpaceController->getScratchSpaceAllocation() && !force32BitAllocations) {
newGSHbase = scratchSpaceController->calculateNewGSH();
2019-09-13 18:00:30 +08:00
} else if (is64bit && force32BitAllocations && dispatchFlags.gsba32BitRequired) {
2020-07-01 20:03:46 +08:00
bool useLocalMemory = scratchSpaceController->getScratchSpaceAllocation() ? scratchSpaceController->getScratchSpaceAllocation()->isAllocatedInLocalMemoryPool() : false;
newGSHbase = getMemoryManager()->getExternalHeapBaseAddress(rootDeviceIndex, useLocalMemory);
2017-12-21 07:45:38 +08:00
GSBAFor32BitProgrammed = true;
}
2018-03-14 18:07:51 +08:00
auto stateBaseAddressCmdOffset = commandStreamCSR.getUsed();
2020-08-03 19:13:58 +08:00
auto pCmd = static_cast<STATE_BASE_ADDRESS *>(commandStreamCSR.getSpace(sizeof(STATE_BASE_ADDRESS)));
STATE_BASE_ADDRESS cmd;
2017-12-21 07:45:38 +08:00
StateBaseAddressHelper<GfxFamily>::programStateBaseAddress(
2020-08-03 19:13:58 +08:00
&cmd,
2019-12-06 16:50:33 +08:00
&dsh,
&ioh,
&ssh,
2017-12-21 07:45:38 +08:00
newGSHbase,
2020-01-22 23:39:40 +08:00
true,
2019-08-26 21:15:22 +08:00
mocsIndex,
2020-07-01 20:03:46 +08:00
getMemoryManager()->getInternalHeapBaseAddress(rootDeviceIndex, ioh.getGraphicsAllocation()->isAllocatedInLocalMemoryPool()),
2020-01-22 23:39:40 +08:00
true,
2019-02-15 00:12:15 +08:00
device.getGmmHelper(),
2019-12-06 20:28:25 +08:00
isMultiOsContextCapable());
2020-08-03 19:13:58 +08:00
*pCmd = cmd;
2018-03-14 18:07:51 +08:00
2018-08-29 19:39:27 +08:00
if (sshDirty) {
2019-04-26 23:04:03 +08:00
bindingTableBaseAddressRequired = true;
}
if (bindingTableBaseAddressRequired) {
2019-12-09 23:29:59 +08:00
StateBaseAddressHelper<GfxFamily>::programBindingTableBaseAddress(commandStreamCSR, ssh, device.getGmmHelper());
2019-04-26 23:04:03 +08:00
bindingTableBaseAddressRequired = false;
2018-08-29 19:39:27 +08:00
}
2020-03-19 22:15:51 +08:00
programAdditionalPipelineSelect(commandStreamCSR, dispatchFlags.pipelineSelectArgs, false);
2018-11-05 18:52:19 +08:00
programStateSip(commandStreamCSR, device);
2018-03-14 18:07:51 +08:00
if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) {
2018-04-04 17:34:46 +08:00
collectStateBaseAddresPatchInfo(commandStream.getGraphicsAllocation()->getGpuAddress(), stateBaseAddressCmdOffset, dsh, ioh, ssh, newGSHbase);
2018-03-14 18:07:51 +08:00
}
2017-12-21 07:45:38 +08:00
}
DBG_LOG(LogTaskCounts, __FUNCTION__, "Line: ", __LINE__, "this->taskLevel", (uint32_t)this->taskLevel);
2020-02-12 18:27:28 +08:00
if (executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo()->workaroundTable.waSamplerCacheFlushBetweenRedescribedSurfaceReads) {
2018-01-10 21:05:34 +08:00
if (this->samplerCacheFlushRequired != SamplerCacheFlushState::samplerCacheFlushNotRequired) {
2020-04-27 03:48:59 +08:00
PipeControlArgs args;
args.textureCacheInvalidationEnable = true;
addPipeControlCmd(commandStreamCSR, args);
2018-01-10 21:05:34 +08:00
if (this->samplerCacheFlushRequired == SamplerCacheFlushState::samplerCacheFlushBefore) {
this->samplerCacheFlushRequired = SamplerCacheFlushState::samplerCacheFlushAfter;
} else {
this->samplerCacheFlushRequired = SamplerCacheFlushState::samplerCacheFlushNotRequired;
}
}
}
2018-07-05 17:23:28 +08:00
if (experimentalCmdBuffer.get() != nullptr) {
size_t startingOffset = experimentalCmdBuffer->programExperimentalCommandBuffer<GfxFamily>();
experimentalCmdBuffer->injectBufferStart<GfxFamily>(commandStreamCSR, startingOffset);
}
2019-08-28 01:14:24 +08:00
if (requiresInstructionCacheFlush) {
2020-04-27 03:48:59 +08:00
PipeControlArgs args;
args.instructionCacheInvalidateEnable = true;
MemorySynchronizationCommands<GfxFamily>::addPipeControl(commandStreamCSR, args);
2019-08-28 01:14:24 +08:00
requiresInstructionCacheFlush = false;
}
2017-12-21 07:45:38 +08:00
// Add a PC if we have a dependency on a previous walker to avoid concurrency issues.
if (taskLevel > this->taskLevel) {
2018-09-06 15:03:07 +08:00
if (!timestampPacketWriteEnabled) {
2020-04-27 03:48:59 +08:00
PipeControlArgs args;
MemorySynchronizationCommands<GfxFamily>::addPipeControl(commandStreamCSR, args);
2018-08-30 17:05:18 +08:00
}
2017-12-21 07:45:38 +08:00
this->taskLevel = taskLevel;
2020-07-18 00:33:16 +08:00
DBG_LOG(LogTaskCounts, __FUNCTION__, "Line: ", __LINE__, "this->taskCount", peekTaskCount());
2017-12-21 07:45:38 +08:00
}
2020-07-06 15:34:15 +08:00
if (DebugManager.flags.ForcePipeControlPriorToWalker.get()) {
forcePipeControl(commandStreamCSR);
}
2017-12-21 07:45:38 +08:00
auto dshAllocation = dsh.getGraphicsAllocation();
auto iohAllocation = ioh.getGraphicsAllocation();
auto sshAllocation = ssh.getGraphicsAllocation();
this->makeResident(*dshAllocation);
2018-04-12 16:05:35 +08:00
dshAllocation->setEvictable(false);
2017-12-21 07:45:38 +08:00
this->makeResident(*iohAllocation);
this->makeResident(*sshAllocation);
2018-04-12 16:05:35 +08:00
iohAllocation->setEvictable(false);
2017-12-21 07:45:38 +08:00
this->makeResident(*tagAllocation);
2020-02-06 03:00:08 +08:00
if (globalFenceAllocation) {
makeResident(*globalFenceAllocation);
}
if (preemptionAllocation) {
2019-06-28 03:33:05 +08:00
makeResident(*preemptionAllocation);
2020-02-06 03:00:08 +08:00
}
2017-12-21 07:45:38 +08:00
2020-06-22 23:13:30 +08:00
if (dispatchFlags.preemptionMode == PreemptionMode::MidThread || sourceLevelDebuggerActive) {
2020-01-21 02:10:01 +08:00
makeResident(*SipKernel::getSipKernelAllocation(device));
2018-11-15 23:08:22 +08:00
if (debugSurface) {
makeResident(*debugSurface);
}
2018-03-13 00:18:00 +08:00
}
2018-07-05 17:23:28 +08:00
if (experimentalCmdBuffer.get() != nullptr) {
experimentalCmdBuffer->makeResidentAllocations();
}
2017-12-21 07:45:38 +08:00
// If the CSR has work in its CS, flush it before the task
bool submitTask = commandStreamStartTask != commandStreamTask.getUsed();
2019-04-01 23:26:32 +08:00
bool submitCSR = (commandStreamStartCSR != commandStreamCSR.getUsed()) || this->isMultiOsContextCapable();
2017-12-21 07:45:38 +08:00
bool submitCommandStreamFromCsr = false;
void *bbEndLocation = nullptr;
auto bbEndPaddingSize = this->dispatchMode == DispatchMode::ImmediateDispatch ? 0 : sizeof(MI_BATCH_BUFFER_START) - sizeof(MI_BATCH_BUFFER_END);
2018-03-01 05:50:41 +08:00
size_t chainedBatchBufferStartOffset = 0;
GraphicsAllocation *chainedBatchBuffer = nullptr;
2020-01-16 00:02:47 +08:00
bool directSubmissionEnabled = isDirectSubmissionEnabled();
2017-12-21 07:45:38 +08:00
if (submitTask) {
2020-01-16 00:02:47 +08:00
programEndingCmd(commandStreamTask, &bbEndLocation, directSubmissionEnabled);
2017-12-21 07:45:38 +08:00
this->emitNoop(commandStreamTask, bbEndPaddingSize);
this->alignToCacheLine(commandStreamTask);
if (submitCSR) {
2018-03-01 05:50:41 +08:00
chainedBatchBufferStartOffset = commandStreamCSR.getUsed();
chainedBatchBuffer = commandStreamTask.getGraphicsAllocation();
2017-12-21 07:45:38 +08:00
// Add MI_BATCH_BUFFER_START to chain from CSR -> Task
auto pBBS = reinterpret_cast<MI_BATCH_BUFFER_START *>(commandStreamCSR.getSpace(sizeof(MI_BATCH_BUFFER_START)));
2018-07-05 17:23:28 +08:00
addBatchBufferStart(pBBS, ptrOffset(commandStreamTask.getGraphicsAllocation()->getGpuAddress(), commandStreamStartTask), false);
2018-04-04 17:34:46 +08:00
if (DebugManager.flags.FlattenBatchBufferForAUBDump.get()) {
flatBatchBufferHelper->registerCommandChunk(commandStreamTask.getGraphicsAllocation()->getGpuAddress(),
reinterpret_cast<uint64_t>(commandStreamTask.getCpuBase()),
commandStreamStartTask,
static_cast<uint64_t>(ptrDiff(bbEndLocation,
commandStreamTask.getGraphicsAllocation()->getGpuAddress())) +
sizeof(MI_BATCH_BUFFER_START));
}
2017-12-21 07:45:38 +08:00
auto commandStreamAllocation = commandStreamTask.getGraphicsAllocation();
DEBUG_BREAK_IF(commandStreamAllocation == nullptr);
this->makeResident(*commandStreamAllocation);
this->alignToCacheLine(commandStreamCSR);
submitCommandStreamFromCsr = true;
2019-08-08 01:33:40 +08:00
} else if (dispatchFlags.epilogueRequired) {
this->makeResident(*commandStreamCSR.getGraphicsAllocation());
2017-12-21 07:45:38 +08:00
}
2019-08-08 01:33:40 +08:00
this->programEpilogue(commandStreamCSR, &bbEndLocation, dispatchFlags);
2017-12-21 07:45:38 +08:00
} else if (submitCSR) {
2020-01-16 00:02:47 +08:00
programEndingCmd(commandStreamCSR, &bbEndLocation, directSubmissionEnabled);
2017-12-21 07:45:38 +08:00
this->emitNoop(commandStreamCSR, bbEndPaddingSize);
this->alignToCacheLine(commandStreamCSR);
DEBUG_BREAK_IF(commandStreamCSR.getUsed() > commandStreamCSR.getMaxAvailableSpace());
submitCommandStreamFromCsr = true;
}
size_t startOffset = submitCommandStreamFromCsr ? commandStreamStartCSR : commandStreamStartTask;
auto &streamToSubmit = submitCommandStreamFromCsr ? commandStreamCSR : commandStreamTask;
2020-01-16 00:02:47 +08:00
BatchBuffer batchBuffer{streamToSubmit.getGraphicsAllocation(), startOffset, chainedBatchBufferStartOffset, chainedBatchBuffer,
dispatchFlags.requiresCoherency, dispatchFlags.lowPriority, dispatchFlags.throttle, dispatchFlags.sliceCount,
streamToSubmit.getUsed(), &streamToSubmit, bbEndLocation};
2017-12-21 07:45:38 +08:00
if (submitCSR | submitTask) {
if (this->dispatchMode == DispatchMode::ImmediateDispatch) {
2019-11-24 21:50:41 +08:00
this->flush(batchBuffer, this->getResidencyAllocations());
2017-12-21 07:45:38 +08:00
this->latestFlushedTaskCount = this->taskCount + 1;
2018-11-26 21:04:52 +08:00
this->makeSurfacePackNonResident(this->getResidencyAllocations());
2017-12-21 07:45:38 +08:00
} else {
2018-08-16 17:18:05 +08:00
auto commandBuffer = new CommandBuffer(device);
2017-12-21 07:45:38 +08:00
commandBuffer->batchBuffer = batchBuffer;
2018-09-12 15:47:01 +08:00
commandBuffer->surfaces.swap(this->getResidencyAllocations());
2017-12-21 07:45:38 +08:00
commandBuffer->batchBufferEndLocation = bbEndLocation;
commandBuffer->taskCount = this->taskCount + 1;
commandBuffer->flushStamp->replaceStampObject(dispatchFlags.flushStampReference);
2018-02-15 15:29:57 +08:00
commandBuffer->pipeControlThatMayBeErasedLocation = currentPipeControlForNooping;
commandBuffer->epiloguePipeControlLocation = epiloguePipeControlLocation;
2017-12-21 07:45:38 +08:00
this->submissionAggregator->recordCommandBuffer(commandBuffer);
}
} else {
2018-11-26 21:04:52 +08:00
this->makeSurfacePackNonResident(this->getResidencyAllocations());
2017-12-21 07:45:38 +08:00
}
//check if we are not over the budget, if we are do implicit flush
if (getMemoryManager()->isMemoryBudgetExhausted()) {
2018-08-01 16:01:41 +08:00
if (this->totalMemoryUsed >= device.getDeviceInfo().globalMemSize / 4) {
2017-12-21 07:45:38 +08:00
dispatchFlags.implicitFlush = true;
}
}
if (this->dispatchMode == DispatchMode::BatchedDispatch && (dispatchFlags.blocking || dispatchFlags.implicitFlush)) {
this->flushBatchedSubmissions();
}
++taskCount;
2020-07-18 00:33:16 +08:00
DBG_LOG(LogTaskCounts, __FUNCTION__, "Line: ", __LINE__, "taskCount", peekTaskCount());
2017-12-21 07:45:38 +08:00
DBG_LOG(LogTaskCounts, __FUNCTION__, "Line: ", __LINE__, "Current taskCount:", tagAddress ? *tagAddress : 0);
CompletionStamp completionStamp = {
taskCount,
this->taskLevel,
2018-11-26 21:04:52 +08:00
flushStamp->peekStamp()};
2017-12-21 07:45:38 +08:00
this->taskLevel += levelClosed ? 1 : 0;
2018-02-08 23:00:20 +08:00
2017-12-21 07:45:38 +08:00
return completionStamp;
}
2020-07-06 15:34:15 +08:00
template <typename GfxFamily>
void CommandStreamReceiverHw<GfxFamily>::forcePipeControl(NEO::LinearStream &commandStreamCSR) {
PipeControlArgs args;
MemorySynchronizationCommands<GfxFamily>::addPipeControlWithCSStallOnly(commandStreamCSR, args);
MemorySynchronizationCommands<GfxFamily>::addPipeControl(commandStreamCSR, args);
}
2019-10-03 20:38:49 +08:00
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::programStallingPipeControlForBarrier(LinearStream &cmdStream, DispatchFlags &dispatchFlags) {
stallingPipeControlOnNextFlushRequired = false;
auto barrierTimestampPacketNodes = dispatchFlags.barrierTimestampPacketNodes;
if (barrierTimestampPacketNodes && barrierTimestampPacketNodes->peekNodes().size() != 0) {
2020-05-19 22:20:41 +08:00
auto barrierTimestampPacketGpuAddress = TimestampPacketHelper::getContextEndGpuAddress(*dispatchFlags.barrierTimestampPacketNodes->peekNodes()[0]);
2019-10-03 20:38:49 +08:00
2020-04-27 03:48:59 +08:00
PipeControlArgs args(true);
MemorySynchronizationCommands<GfxFamily>::addPipeControlAndProgramPostSyncOperation(
cmdStream,
PIPE_CONTROL::POST_SYNC_OPERATION::POST_SYNC_OPERATION_WRITE_IMMEDIATE_DATA,
barrierTimestampPacketGpuAddress,
0,
peekHwInfo(),
args);
2019-11-12 16:37:16 +08:00
dispatchFlags.barrierTimestampPacketNodes->makeResident(*this);
2019-10-03 20:38:49 +08:00
} else {
2020-04-27 03:48:59 +08:00
PipeControlArgs args;
MemorySynchronizationCommands<GfxFamily>::addPipeControl(cmdStream, args);
2019-10-03 20:38:49 +08:00
}
}
2017-12-21 07:45:38 +08:00
template <typename GfxFamily>
2019-11-24 21:50:41 +08:00
inline bool CommandStreamReceiverHw<GfxFamily>::flushBatchedSubmissions() {
2018-04-04 17:34:46 +08:00
if (this->dispatchMode == DispatchMode::ImmediateDispatch) {
2019-11-24 21:50:41 +08:00
return true;
2017-12-21 07:45:38 +08:00
}
typedef typename GfxFamily::MI_BATCH_BUFFER_START MI_BATCH_BUFFER_START;
2018-02-13 17:01:20 +08:00
typedef typename GfxFamily::PIPE_CONTROL PIPE_CONTROL;
2018-08-06 20:55:04 +08:00
std::unique_lock<MutexType> lockGuard(ownershipMutex);
2019-11-24 21:50:41 +08:00
bool submitResult = true;
2017-12-21 07:45:38 +08:00
auto &commandBufferList = this->submissionAggregator->peekCmdBufferList();
if (!commandBufferList.peekIsEmpty()) {
2018-12-04 22:11:29 +08:00
const auto totalMemoryBudget = static_cast<size_t>(commandBufferList.peekHead()->device.getDeviceInfo().globalMemSize / 2);
2018-08-16 17:18:05 +08:00
2017-12-21 07:45:38 +08:00
ResidencyContainer surfacesForSubmit;
ResourcePackage resourcePackage;
2020-02-17 19:45:24 +08:00
auto pipeControlLocationSize = MemorySynchronizationCommands<GfxFamily>::getSizeForPipeControlWithPostSyncOperation(peekHwInfo());
2018-02-15 15:29:57 +08:00
void *currentPipeControlForNooping = nullptr;
void *epiloguePipeControlLocation = nullptr;
2017-12-21 07:45:38 +08:00
while (!commandBufferList.peekIsEmpty()) {
size_t totalUsedSize = 0u;
2018-12-04 22:11:29 +08:00
this->submissionAggregator->aggregateCommandBuffers(resourcePackage, totalUsedSize, totalMemoryBudget, osContext->getContextId());
2017-12-21 07:45:38 +08:00
auto primaryCmdBuffer = commandBufferList.removeFrontOne();
auto nextCommandBuffer = commandBufferList.peekHead();
auto currentBBendLocation = primaryCmdBuffer->batchBufferEndLocation;
auto lastTaskCount = primaryCmdBuffer->taskCount;
FlushStampUpdateHelper flushStampUpdateHelper;
flushStampUpdateHelper.insert(primaryCmdBuffer->flushStamp->getStampReference());
2018-02-15 15:29:57 +08:00
currentPipeControlForNooping = primaryCmdBuffer->pipeControlThatMayBeErasedLocation;
epiloguePipeControlLocation = primaryCmdBuffer->epiloguePipeControlLocation;
2017-12-21 07:45:38 +08:00
2018-04-04 17:34:46 +08:00
if (DebugManager.flags.FlattenBatchBufferForAUBDump.get()) {
flatBatchBufferHelper->registerCommandChunk(primaryCmdBuffer.get()->batchBuffer, sizeof(MI_BATCH_BUFFER_START));
}
2017-12-21 07:45:38 +08:00
while (nextCommandBuffer && nextCommandBuffer->inspectionId == primaryCmdBuffer->inspectionId) {
//noop pipe control
2018-02-15 15:29:57 +08:00
if (currentPipeControlForNooping) {
2018-04-04 17:34:46 +08:00
if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) {
2020-02-12 01:25:21 +08:00
flatBatchBufferHelper->removePipeControlData(pipeControlLocationSize, currentPipeControlForNooping, peekHwInfo());
2018-04-04 17:34:46 +08:00
}
2018-02-15 15:29:57 +08:00
memset(currentPipeControlForNooping, 0, pipeControlLocationSize);
2017-12-21 07:45:38 +08:00
}
//obtain next candidate for nooping
2018-02-15 15:29:57 +08:00
currentPipeControlForNooping = nextCommandBuffer->pipeControlThatMayBeErasedLocation;
//track epilogue pipe control
epiloguePipeControlLocation = nextCommandBuffer->epiloguePipeControlLocation;
2017-12-21 07:45:38 +08:00
flushStampUpdateHelper.insert(nextCommandBuffer->flushStamp->getStampReference());
2018-08-24 21:23:45 +08:00
auto nextCommandBufferAddress = nextCommandBuffer->batchBuffer.commandBufferAllocation->getGpuAddress();
2017-12-21 07:45:38 +08:00
auto offsetedCommandBuffer = (uint64_t)ptrOffset(nextCommandBufferAddress, nextCommandBuffer->batchBuffer.startOffset);
2018-07-05 17:23:28 +08:00
addBatchBufferStart((MI_BATCH_BUFFER_START *)currentBBendLocation, offsetedCommandBuffer, false);
2018-04-04 17:34:46 +08:00
if (DebugManager.flags.FlattenBatchBufferForAUBDump.get()) {
flatBatchBufferHelper->registerCommandChunk(nextCommandBuffer->batchBuffer, sizeof(MI_BATCH_BUFFER_START));
}
2017-12-21 07:45:38 +08:00
currentBBendLocation = nextCommandBuffer->batchBufferEndLocation;
lastTaskCount = nextCommandBuffer->taskCount;
nextCommandBuffer = nextCommandBuffer->next;
commandBufferList.removeFrontOne();
}
surfacesForSubmit.reserve(resourcePackage.size() + 1);
for (auto &surface : resourcePackage) {
surfacesForSubmit.push_back(surface);
}
2019-02-05 22:11:38 +08:00
//make sure we flush DC if needed
2018-03-09 21:48:42 +08:00
if (epiloguePipeControlLocation) {
2019-02-08 03:39:26 +08:00
bool flushDcInEpilogue = true;
if (DebugManager.flags.DisableDcFlushInEpilogue.get()) {
flushDcInEpilogue = false;
}
((PIPE_CONTROL *)epiloguePipeControlLocation)->setDcFlushEnable(flushDcInEpilogue);
2018-03-09 21:48:42 +08:00
}
2019-11-24 21:50:41 +08:00
if (!this->flush(primaryCmdBuffer->batchBuffer, surfacesForSubmit)) {
submitResult = false;
break;
}
2017-12-21 07:45:38 +08:00
//after flush task level is closed
this->taskLevel++;
2019-11-24 21:50:41 +08:00
flushStampUpdateHelper.updateAll(flushStamp->peekStamp());
2017-12-21 07:45:38 +08:00
this->latestFlushedTaskCount = lastTaskCount;
2018-11-26 21:04:52 +08:00
this->makeSurfacePackNonResident(surfacesForSubmit);
2017-12-21 07:45:38 +08:00
resourcePackage.clear();
}
this->totalMemoryUsed = 0;
}
2019-11-24 21:50:41 +08:00
return submitResult;
2017-12-21 07:45:38 +08:00
}
2018-01-24 17:11:37 +08:00
template <typename GfxFamily>
2018-08-07 15:07:50 +08:00
size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdStreamSizeAligned(const DispatchFlags &dispatchFlags, Device &device) {
size_t size = getRequiredCmdStreamSize(dispatchFlags, device);
2018-01-24 17:11:37 +08:00
return alignUp(size, MemoryConstants::cacheLineSize);
}
2017-12-21 07:45:38 +08:00
template <typename GfxFamily>
2018-08-07 15:07:50 +08:00
size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdStreamSize(const DispatchFlags &dispatchFlags, Device &device) {
2018-08-16 17:18:05 +08:00
size_t size = getRequiredCmdSizeForPreamble(device);
2018-08-29 19:39:27 +08:00
size += getRequiredStateBaseAddressSize();
2020-02-10 22:57:49 +08:00
if (!this->isStateSipSent || device.isDebuggerActive()) {
2018-11-05 18:52:19 +08:00
size += PreemptionHelper::getRequiredStateSipCmdSize<GfxFamily>(device);
}
2020-02-17 19:45:24 +08:00
size += MemorySynchronizationCommands<GfxFamily>::getSizeForSinglePipeControl();
2018-04-20 19:55:54 +08:00
size += sizeof(typename GfxFamily::MI_BATCH_BUFFER_START);
2018-04-13 17:05:09 +08:00
size += getCmdSizeForL3Config();
2018-09-21 20:06:35 +08:00
size += getCmdSizeForComputeMode();
2019-09-10 22:13:11 +08:00
size += getCmdSizeForMediaSampler(dispatchFlags.pipelineSelectArgs.mediaSamplerRequired);
2018-04-13 17:05:09 +08:00
size += getCmdSizeForPipelineSelect();
size += getCmdSizeForPreemption(dispatchFlags);
2019-08-08 01:33:40 +08:00
size += getCmdSizeForEpilogue(dispatchFlags);
2020-05-27 21:30:31 +08:00
size += getCmdsSizeForHardwareContext();
2017-12-21 07:45:38 +08:00
2020-02-12 18:27:28 +08:00
if (executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo()->workaroundTable.waSamplerCacheFlushBetweenRedescribedSurfaceReads) {
2018-01-10 21:05:34 +08:00
if (this->samplerCacheFlushRequired != SamplerCacheFlushState::samplerCacheFlushNotRequired) {
size += sizeof(typename GfxFamily::PIPE_CONTROL);
}
}
2018-07-05 17:23:28 +08:00
if (experimentalCmdBuffer.get() != nullptr) {
size += experimentalCmdBuffer->getRequiredInjectionSize<GfxFamily>();
}
2019-01-25 17:20:32 +08:00
size += TimestampPacketHelper::getRequiredCmdStreamSize<GfxFamily>(dispatchFlags.csrDependencies);
2018-10-15 16:35:45 +08:00
if (stallingPipeControlOnNextFlushRequired) {
2019-10-03 20:38:49 +08:00
auto barrierTimestampPacketNodes = dispatchFlags.barrierTimestampPacketNodes;
if (barrierTimestampPacketNodes && barrierTimestampPacketNodes->peekNodes().size() > 0) {
2020-02-17 19:45:24 +08:00
size += MemorySynchronizationCommands<GfxFamily>::getSizeForPipeControlWithPostSyncOperation(peekHwInfo());
2019-10-03 20:38:49 +08:00
} else {
size += sizeof(typename GfxFamily::PIPE_CONTROL);
}
2018-10-15 16:35:45 +08:00
}
2019-10-03 20:38:49 +08:00
2019-08-28 01:14:24 +08:00
if (requiresInstructionCacheFlush) {
size += sizeof(typename GfxFamily::PIPE_CONTROL);
}
2020-07-06 15:34:15 +08:00
if (DebugManager.flags.ForcePipeControlPriorToWalker.get()) {
size += 2 * sizeof(PIPE_CONTROL);
}
2018-01-24 17:11:37 +08:00
return size;
2017-12-21 07:45:38 +08:00
}
2019-08-21 20:08:51 +08:00
template <typename GfxFamily>
inline size_t CommandStreamReceiverHw<GfxFamily>::getCmdSizeForPipelineSelect() const {
2019-09-10 22:13:11 +08:00
size_t size = 0;
2020-03-19 22:15:51 +08:00
if ((csrSizeRequestFlags.mediaSamplerConfigChanged ||
csrSizeRequestFlags.specialPipelineSelectModeChanged ||
!isPreambleSent) &&
!isPipelineSelectAlreadyProgrammed()) {
2019-09-10 22:13:11 +08:00
size += PreambleHelper<GfxFamily>::getCmdSizeForPipelineSelect(peekHwInfo());
2019-08-21 20:08:51 +08:00
}
return size;
}
2017-12-21 07:45:38 +08:00
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::emitNoop(LinearStream &commandStream, size_t bytesToUpdate) {
if (bytesToUpdate) {
auto ptr = commandStream.getSpace(bytesToUpdate);
memset(ptr, 0, bytesToUpdate);
}
}
template <typename GfxFamily>
2018-11-26 21:04:52 +08:00
inline void CommandStreamReceiverHw<GfxFamily>::waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) {
2018-04-10 16:26:59 +08:00
int64_t waitTimeout = 0;
2018-11-16 19:46:49 +08:00
bool enableTimeout = kmdNotifyHelper->obtainTimeoutParams(waitTimeout, useQuickKmdSleep, *getTagAddress(), taskCountToWait, flushStampToWait, forcePowerSavingMode);
2018-03-21 17:00:49 +08:00
2020-08-17 17:38:52 +08:00
printDebugString(DebugManager.flags.LogWaitingForCompletion.get(), stdout,
2020-08-19 21:51:25 +08:00
"\nWaiting for task count %u at location %p. Current value: %u\n",
2020-08-17 17:38:52 +08:00
taskCountToWait, getTagAddress(), *getTagAddress());
2018-04-10 16:26:59 +08:00
auto status = waitForCompletionWithTimeout(enableTimeout, waitTimeout, taskCountToWait);
2017-12-21 07:45:38 +08:00
if (!status) {
2018-11-26 21:04:52 +08:00
waitForFlushStamp(flushStampToWait);
2017-12-21 07:45:38 +08:00
//now call blocking wait, this is to ensure that task count is reached
2018-03-22 16:41:17 +08:00
waitForCompletionWithTimeout(false, 0, taskCountToWait);
2017-12-21 07:45:38 +08:00
}
UNRECOVERABLE_IF(*getTagAddress() < taskCountToWait);
2018-03-22 16:41:17 +08:00
2018-04-10 16:26:59 +08:00
if (kmdNotifyHelper->quickKmdSleepForSporadicWaitsEnabled()) {
kmdNotifyHelper->updateLastWaitForCompletionTimestamp();
2018-03-22 16:41:17 +08:00
}
2020-08-17 17:38:52 +08:00
printDebugString(DebugManager.flags.LogWaitingForCompletion.get(), stdout,
"\nWaiting completed. Current value: %u\n", *getTagAddress());
2017-12-21 07:45:38 +08:00
}
2020-02-12 18:27:28 +08:00
template <typename GfxFamily>
inline const HardwareInfo &CommandStreamReceiverHw<GfxFamily>::peekHwInfo() const {
return *executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo();
}
2017-12-21 07:45:38 +08:00
template <typename GfxFamily>
2019-07-31 14:57:00 +08:00
inline void CommandStreamReceiverHw<GfxFamily>::programPreemption(LinearStream &csr, DispatchFlags &dispatchFlags) {
PreemptionHelper::programCmdStream<GfxFamily>(csr, dispatchFlags.preemptionMode, this->lastPreemptionMode, preemptionAllocation);
2018-01-08 22:58:02 +08:00
this->lastPreemptionMode = dispatchFlags.preemptionMode;
2017-12-21 07:45:38 +08:00
}
2018-04-13 17:05:09 +08:00
template <typename GfxFamily>
inline size_t CommandStreamReceiverHw<GfxFamily>::getCmdSizeForPreemption(const DispatchFlags &dispatchFlags) const {
return PreemptionHelper::getRequiredCmdStreamSize<GfxFamily>(dispatchFlags.preemptionMode, this->lastPreemptionMode);
}
2018-11-05 18:52:19 +08:00
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::programStateSip(LinearStream &cmdStream, Device &device) {
2020-02-10 22:57:49 +08:00
if (!this->isStateSipSent || device.isDebuggerActive()) {
2018-11-05 18:52:19 +08:00
PreemptionHelper::programStateSip<GfxFamily>(cmdStream, device);
this->isStateSipSent = true;
}
}
2017-12-21 07:45:38 +08:00
template <typename GfxFamily>
2018-08-16 17:18:05 +08:00
inline void CommandStreamReceiverHw<GfxFamily>::programPreamble(LinearStream &csr, Device &device, DispatchFlags &dispatchFlags, uint32_t &newL3Config) {
2017-12-21 07:45:38 +08:00
if (!this->isPreambleSent) {
2020-01-29 21:15:10 +08:00
GraphicsAllocation *perDssBackedBufferToUse = dispatchFlags.usePerDssBackedBuffer ? this->perDssBackedBuffer : nullptr;
PreambleHelper<GfxFamily>::programPreamble(&csr, device, newL3Config, this->requiredThreadArbitrationPolicy, this->preemptionAllocation, perDssBackedBufferToUse);
2017-12-21 07:45:38 +08:00
this->isPreambleSent = true;
this->lastSentL3Config = newL3Config;
2018-02-20 15:11:24 +08:00
this->lastSentThreadArbitrationPolicy = this->requiredThreadArbitrationPolicy;
2017-12-21 07:45:38 +08:00
}
}
template <typename GfxFamily>
2019-05-29 21:37:54 +08:00
inline void CommandStreamReceiverHw<GfxFamily>::programVFEState(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t maxFrontEndThreads) {
2017-12-21 07:45:38 +08:00
if (mediaVfeStateDirty) {
2020-02-06 23:06:00 +08:00
auto commandOffset = PreambleHelper<GfxFamily>::programVFEState(&csr, peekHwInfo(), requiredScratchSize, getScratchPatchAddress(), maxFrontEndThreads, getOsContext().getEngineType());
2019-08-13 17:34:56 +08:00
if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) {
flatBatchBufferHelper->collectScratchSpacePatchInfo(getScratchPatchAddress(), commandOffset, csr);
}
2018-12-13 18:06:28 +08:00
setMediaVFEStateDirty(false);
2017-12-21 07:45:38 +08:00
}
}
2018-01-19 20:29:25 +08:00
template <typename GfxFamily>
void CommandStreamReceiverHw<GfxFamily>::programMediaSampler(LinearStream &commandStream, DispatchFlags &dispatchFlags) {
}
template <typename GfxFamily>
size_t CommandStreamReceiverHw<GfxFamily>::getCmdSizeForMediaSampler(bool mediaSamplerRequired) const {
return 0;
}
2018-03-23 02:02:58 +08:00
2018-03-14 18:07:51 +08:00
template <typename GfxFamily>
void CommandStreamReceiverHw<GfxFamily>::collectStateBaseAddresPatchInfo(
uint64_t baseAddress,
uint64_t commandOffset,
const LinearStream &dsh,
const LinearStream &ioh,
const LinearStream &ssh,
2018-04-04 17:34:46 +08:00
uint64_t generalStateBase) {
2018-03-14 18:07:51 +08:00
typedef typename GfxFamily::STATE_BASE_ADDRESS STATE_BASE_ADDRESS;
2018-04-04 17:34:46 +08:00
PatchInfoData dynamicStatePatchInfo = {dsh.getGraphicsAllocation()->getGpuAddress(), 0u, PatchInfoAllocationType::DynamicStateHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::DYNAMICSTATEBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default};
2018-03-14 18:07:51 +08:00
PatchInfoData generalStatePatchInfo = {generalStateBase, 0u, PatchInfoAllocationType::GeneralStateHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::GENERALSTATEBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default};
2018-04-04 17:34:46 +08:00
PatchInfoData surfaceStatePatchInfo = {ssh.getGraphicsAllocation()->getGpuAddress(), 0u, PatchInfoAllocationType::SurfaceStateHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::SURFACESTATEBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default};
PatchInfoData indirectObjectPatchInfo = {ioh.getGraphicsAllocation()->getGpuAddress(), 0u, PatchInfoAllocationType::IndirectObjectHeap, baseAddress, commandOffset + STATE_BASE_ADDRESS::PATCH_CONSTANTS::INDIRECTOBJECTBASEADDRESS_BYTEOFFSET, PatchInfoAllocationType::Default};
flatBatchBufferHelper->setPatchInfoData(dynamicStatePatchInfo);
flatBatchBufferHelper->setPatchInfoData(generalStatePatchInfo);
flatBatchBufferHelper->setPatchInfoData(surfaceStatePatchInfo);
flatBatchBufferHelper->setPatchInfoData(indirectObjectPatchInfo);
2018-03-14 18:07:51 +08:00
}
2018-04-10 16:26:59 +08:00
template <typename GfxFamily>
void CommandStreamReceiverHw<GfxFamily>::resetKmdNotifyHelper(KmdNotifyHelper *newHelper) {
kmdNotifyHelper.reset(newHelper);
kmdNotifyHelper->updateAcLineStatus();
if (kmdNotifyHelper->quickKmdSleepForSporadicWaitsEnabled()) {
kmdNotifyHelper->updateLastWaitForCompletionTimestamp();
}
}
2018-05-21 16:57:28 +08:00
template <typename GfxFamily>
void CommandStreamReceiverHw<GfxFamily>::addClearSLMWorkAround(typename GfxFamily::PIPE_CONTROL *pCmd) {
}
2018-09-07 20:31:37 +08:00
2018-11-22 22:16:20 +08:00
template <typename GfxFamily>
uint64_t CommandStreamReceiverHw<GfxFamily>::getScratchPatchAddress() {
return scratchSpaceController->getScratchPatchAddress();
2018-09-12 22:32:42 +08:00
}
2019-01-28 20:44:59 +08:00
template <typename GfxFamily>
bool CommandStreamReceiverHw<GfxFamily>::detectInitProgrammingFlagsRequired(const DispatchFlags &dispatchFlags) const {
return DebugManager.flags.ForceCsrReprogramming.get();
}
2019-03-21 00:08:05 +08:00
2019-04-03 21:59:31 +08:00
template <typename GfxFamily>
2020-04-29 20:06:01 +08:00
uint32_t CommandStreamReceiverHw<GfxFamily>::blitBuffer(const BlitPropertiesContainer &blitPropertiesContainer, bool blocking, bool profilingEnabled) {
2019-04-03 21:59:31 +08:00
using MI_BATCH_BUFFER_END = typename GfxFamily::MI_BATCH_BUFFER_END;
using MI_FLUSH_DW = typename GfxFamily::MI_FLUSH_DW;
2019-04-15 14:54:38 +08:00
auto lock = obtainUniqueOwnership();
2019-11-07 16:15:53 +08:00
2020-06-17 20:58:28 +08:00
bool pauseOnBlitCopyAllowed = (DebugManager.flags.PauseOnBlitCopy.get() == static_cast<int32_t>(taskCount));
2020-07-01 20:12:53 +08:00
auto &commandStream = getCS(BlitCommandsHelper<GfxFamily>::estimateBlitCommandsSize(blitPropertiesContainer, profilingEnabled, pauseOnBlitCopyAllowed,
*this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]));
2019-04-15 14:54:38 +08:00
auto commandStreamStart = commandStream.getUsed();
auto newTaskCount = taskCount + 1;
2019-04-16 19:02:34 +08:00
latestSentTaskCount = newTaskCount;
2019-04-03 21:59:31 +08:00
2020-06-17 20:58:28 +08:00
if (pauseOnBlitCopyAllowed) {
BlitCommandsHelper<GfxFamily>::dispatchDebugPauseCommands(commandStream, getDebugPauseStateGPUAddress(), DebugPauseState::waitingForUserStartConfirmation, DebugPauseState::hasUserStartConfirmation);
}
2020-02-07 22:36:15 +08:00
programEnginePrologue(commandStream);
2019-11-07 16:15:53 +08:00
for (auto &blitProperties : blitPropertiesContainer) {
2020-05-14 20:33:03 +08:00
TimestampPacketHelper::programCsrDependencies<GfxFamily>(commandStream, blitProperties.csrDependencies, getOsContext().getNumSupportedDevices());
2019-05-20 18:00:02 +08:00
2020-04-29 20:06:01 +08:00
if (blitProperties.outputTimestampPacket && profilingEnabled) {
auto timestampContextStartGpuAddress = blitProperties.outputTimestampPacket->getGpuAddress() + offsetof(TimestampPacketStorage, packets[0].contextStart);
auto timestampGlobalStartAddress = blitProperties.outputTimestampPacket->getGpuAddress() + offsetof(TimestampPacketStorage, packets[0].globalStart);
EncodeStoreMMIO<GfxFamily>::encode(commandStream, GP_THREAD_TIME_REG_ADDRESS_OFFSET_LOW, timestampContextStartGpuAddress);
EncodeStoreMMIO<GfxFamily>::encode(commandStream, REG_GLOBAL_TIMESTAMP_LDW, timestampGlobalStartAddress);
}
2020-08-19 19:33:45 +08:00
BlitCommandsHelper<GfxFamily>::dispatchBlitCommands(blitProperties, commandStream, *this->executionEnvironment.rootDeviceEnvironments[this->rootDeviceIndex]);
2019-04-03 21:59:31 +08:00
2019-11-07 16:15:53 +08:00
if (blitProperties.outputTimestampPacket) {
2020-04-29 20:06:01 +08:00
if (profilingEnabled) {
auto timestampContextEndGpuAddress = blitProperties.outputTimestampPacket->getGpuAddress() + offsetof(TimestampPacketStorage, packets[0].contextEnd);
auto timestampGlobalEndAddress = blitProperties.outputTimestampPacket->getGpuAddress() + offsetof(TimestampPacketStorage, packets[0].globalEnd);
EncodeStoreMMIO<GfxFamily>::encode(commandStream, GP_THREAD_TIME_REG_ADDRESS_OFFSET_LOW, timestampContextEndGpuAddress);
EncodeStoreMMIO<GfxFamily>::encode(commandStream, REG_GLOBAL_TIMESTAMP_LDW, timestampGlobalEndAddress);
} else {
auto timestampPacketGpuAddress = TimestampPacketHelper::getContextEndGpuAddress(*blitProperties.outputTimestampPacket);
EncodeMiFlushDW<GfxFamily>::programMiFlushDw(commandStream, timestampPacketGpuAddress, 0, true, true);
}
2019-11-13 00:56:10 +08:00
makeResident(*blitProperties.outputTimestampPacket->getBaseGraphicsAllocation());
2019-11-07 16:15:53 +08:00
}
2019-04-03 21:59:31 +08:00
2019-11-07 16:15:53 +08:00
blitProperties.csrDependencies.makeResident(*this);
makeResident(*blitProperties.srcAllocation);
makeResident(*blitProperties.dstAllocation);
2019-06-13 17:45:27 +08:00
}
2020-02-17 19:45:24 +08:00
MemorySynchronizationCommands<GfxFamily>::addAdditionalSynchronization(commandStream, tagAllocation->getGpuAddress(), peekHwInfo());
2020-02-07 22:36:15 +08:00
2020-04-07 22:50:09 +08:00
EncodeMiFlushDW<GfxFamily>::programMiFlushDw(commandStream, tagAllocation->getGpuAddress(), newTaskCount, false, true);
2019-11-07 16:15:53 +08:00
2020-02-17 19:45:24 +08:00
MemorySynchronizationCommands<GfxFamily>::addAdditionalSynchronization(commandStream, tagAllocation->getGpuAddress(), peekHwInfo());
2020-02-12 01:25:21 +08:00
2020-06-17 20:58:28 +08:00
if (pauseOnBlitCopyAllowed) {
BlitCommandsHelper<GfxFamily>::dispatchDebugPauseCommands(commandStream, getDebugPauseStateGPUAddress(), DebugPauseState::waitingForUserEndConfirmation, DebugPauseState::hasUserEndConfirmation);
}
2019-04-03 21:59:31 +08:00
auto batchBufferEnd = reinterpret_cast<MI_BATCH_BUFFER_END *>(commandStream.getSpace(sizeof(MI_BATCH_BUFFER_END)));
*batchBufferEnd = GfxFamily::cmdInitBatchBufferEnd;
alignToCacheLine(commandStream);
2019-04-11 17:34:35 +08:00
makeResident(*tagAllocation);
2020-02-07 22:36:15 +08:00
if (globalFenceAllocation) {
makeResident(*globalFenceAllocation);
}
2019-04-11 17:34:35 +08:00
2019-08-21 18:50:47 +08:00
BatchBuffer batchBuffer{commandStream.getGraphicsAllocation(), commandStreamStart, 0, nullptr, false, false, QueueThrottle::MEDIUM, QueueSliceCount::defaultSliceCount,
2020-01-16 00:02:47 +08:00
commandStream.getUsed(), &commandStream, nullptr};
2019-04-15 14:54:38 +08:00
2019-11-24 21:50:41 +08:00
flush(batchBuffer, getResidencyAllocations());
2019-04-15 14:54:38 +08:00
makeSurfacePackNonResident(getResidencyAllocations());
latestFlushedTaskCount = newTaskCount;
taskCount = newTaskCount;
2019-04-25 15:59:08 +08:00
auto flushStampToWait = flushStamp->peekStamp();
2019-04-15 14:54:38 +08:00
lock.unlock();
2019-11-07 16:15:53 +08:00
if (blocking) {
2019-06-04 19:37:22 +08:00
waitForTaskCountWithKmdNotifyFallback(newTaskCount, flushStampToWait, false, false);
internalAllocationStorage->cleanAllocationList(newTaskCount, TEMPORARY_ALLOCATION);
}
2019-10-22 17:25:14 +08:00
return newTaskCount;
2019-04-03 21:59:31 +08:00
}
2020-03-19 22:15:51 +08:00
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::programAdditionalPipelineSelect(LinearStream &csr, PipelineSelectArgs &pipelineSelectArgs, bool is3DPipeline) {
auto &hwHelper = HwHelper::get(peekHwInfo().platform.eRenderCoreFamily);
if (hwHelper.is3DPipelineSelectWARequired(peekHwInfo()) && isRcs()) {
auto localPipelineSelectArgs = pipelineSelectArgs;
localPipelineSelectArgs.is3DPipelineRequired = is3DPipeline;
PreambleHelper<GfxFamily>::programPipelineSelect(&csr, localPipelineSelectArgs, peekHwInfo());
}
}
template <typename GfxFamily>
inline bool CommandStreamReceiverHw<GfxFamily>::isComputeModeNeeded() const {
return false;
}
template <typename GfxFamily>
inline bool CommandStreamReceiverHw<GfxFamily>::isPipelineSelectAlreadyProgrammed() const {
auto &hwHelper = HwHelper::get(peekHwInfo().platform.eRenderCoreFamily);
return isComputeModeNeeded() && hwHelper.is3DPipelineSelectWARequired(peekHwInfo()) && isRcs();
}
2019-08-08 01:33:40 +08:00
template <typename GfxFamily>
inline void CommandStreamReceiverHw<GfxFamily>::programEpilogue(LinearStream &csr, void **batchBufferEndLocation, DispatchFlags &dispatchFlags) {
if (dispatchFlags.epilogueRequired) {
auto currentOffset = ptrDiff(csr.getSpace(0u), csr.getCpuBase());
auto gpuAddress = ptrOffset(csr.getGraphicsAllocation()->getGpuAddress(), currentOffset);
addBatchBufferStart(reinterpret_cast<typename GfxFamily::MI_BATCH_BUFFER_START *>(*batchBufferEndLocation), gpuAddress, false);
2019-08-08 17:44:23 +08:00
this->programEpliogueCommands(csr, dispatchFlags);
2020-01-16 00:02:47 +08:00
programEndingCmd(csr, batchBufferEndLocation, isDirectSubmissionEnabled());
2019-08-08 01:33:40 +08:00
this->alignToCacheLine(csr);
}
}
template <typename GfxFamily>
inline size_t CommandStreamReceiverHw<GfxFamily>::getCmdSizeForEpilogue(const DispatchFlags &dispatchFlags) const {
if (dispatchFlags.epilogueRequired) {
2020-01-16 00:02:47 +08:00
size_t terminateCmd = sizeof(typename GfxFamily::MI_BATCH_BUFFER_END);
if (isDirectSubmissionEnabled()) {
terminateCmd = sizeof(typename GfxFamily::MI_BATCH_BUFFER_START);
}
auto size = getCmdSizeForEpilogueCommands(dispatchFlags) + terminateCmd;
2019-08-08 17:44:23 +08:00
return alignUp(size, MemoryConstants::cacheLineSize);
2019-08-08 01:33:40 +08:00
}
return 0u;
}
2020-01-31 15:50:12 +08:00
template <typename GfxFamily>
2020-02-07 22:36:15 +08:00
inline void CommandStreamReceiverHw<GfxFamily>::programEnginePrologue(LinearStream &csr) {
2020-01-31 15:50:12 +08:00
}
template <typename GfxFamily>
2020-05-27 21:30:31 +08:00
inline size_t CommandStreamReceiverHw<GfxFamily>::getCmdSizeForPrologue() const {
2020-01-31 15:50:12 +08:00
return 0u;
}
2020-07-17 17:28:59 +08:00
template <typename GfxFamily>
inline bool CommandStreamReceiverHw<GfxFamily>::initDirectSubmission(Device &device, OsContext &osContext) {
bool ret = true;
if (DebugManager.flags.EnableDirectSubmission.get() == 1) {
auto contextEngineType = osContext.getEngineType();
const DirectSubmissionProperties &directSubmissionProperty =
device.getHardwareInfo().capabilityTable.directSubmissionEngines.data[contextEngineType];
bool startDirect = true;
if (!osContext.isDefaultContext()) {
startDirect = directSubmissionProperty.useNonDefault;
}
if (osContext.isLowPriority()) {
startDirect = directSubmissionProperty.useLowPriority;
}
if (osContext.isInternalEngine()) {
startDirect = directSubmissionProperty.useInternal;
}
if (osContext.isRootDevice()) {
startDirect = directSubmissionProperty.useRootDevice;
}
if (directSubmissionProperty.engineSupported && startDirect) {
if (contextEngineType == aub_stream::ENGINE_BCS) {
blitterDirectSubmission = DirectSubmissionHw<GfxFamily, BlitterDispatcher<GfxFamily>>::create(device, osContext);
ret = blitterDirectSubmission->initialize(directSubmissionProperty.submitOnInit);
} else {
directSubmission = DirectSubmissionHw<GfxFamily, RenderDispatcher<GfxFamily>>::create(device, osContext);
ret = directSubmission->initialize(directSubmissionProperty.submitOnInit);
this->dispatchMode = DispatchMode::ImmediateDispatch;
}
}
}
return ret;
}
2019-03-26 18:59:46 +08:00
} // namespace NEO