2017-12-21 07:45:38 +08:00
|
|
|
/*
|
2021-01-29 01:30:56 +08:00
|
|
|
* Copyright (C) 2018-2021 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
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/command_stream/command_stream_receiver.h"
|
2020-03-27 03:13:10 +08:00
|
|
|
#include "shared/source/direct_submission/direct_submission_hw.h"
|
|
|
|
#include "shared/source/direct_submission/dispatchers/blitter_dispatcher.h"
|
|
|
|
#include "shared/source/direct_submission/dispatchers/render_dispatcher.h"
|
2020-02-24 05:44:01 +08:00
|
|
|
#include "shared/source/execution_environment/execution_environment.h"
|
|
|
|
#include "shared/source/helpers/dirty_state_helpers.h"
|
|
|
|
#include "shared/source/helpers/hw_info.h"
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-07-30 21:02:11 +08:00
|
|
|
#include "hw_cmds.h"
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
namespace NEO {
|
2017-12-21 07:45:38 +08:00
|
|
|
template <typename GfxFamily>
|
|
|
|
class DeviceCommandStreamReceiver;
|
2020-04-27 03:48:59 +08:00
|
|
|
struct PipeControlArgs;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
template <typename GfxFamily>
|
|
|
|
class CommandStreamReceiverHw : public CommandStreamReceiver {
|
|
|
|
typedef typename GfxFamily::MI_BATCH_BUFFER_START MI_BATCH_BUFFER_START;
|
|
|
|
typedef typename GfxFamily::PIPE_CONTROL PIPE_CONTROL;
|
|
|
|
|
|
|
|
public:
|
2020-10-29 22:33:35 +08:00
|
|
|
static CommandStreamReceiver *create(ExecutionEnvironment &executionEnvironment,
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
const DeviceBitfield deviceBitfield) {
|
2020-10-28 23:08:37 +08:00
|
|
|
return new CommandStreamReceiverHw<GfxFamily>(executionEnvironment, rootDeviceIndex, deviceBitfield);
|
2017-12-21 07:45:38 +08:00
|
|
|
}
|
|
|
|
|
2020-10-29 22:33:35 +08:00
|
|
|
CommandStreamReceiverHw(ExecutionEnvironment &executionEnvironment,
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
const DeviceBitfield deviceBitfield);
|
2020-01-16 00:02:47 +08:00
|
|
|
~CommandStreamReceiverHw() override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-11-24 21:50:41 +08:00
|
|
|
bool flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart,
|
2018-04-17 19:50:50 +08:00
|
|
|
const IndirectHeap &dsh, const IndirectHeap &ioh, const IndirectHeap &ssh,
|
2018-08-01 16:01:41 +08:00
|
|
|
uint32_t taskLevel, DispatchFlags &dispatchFlags, Device &device) override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-07-06 15:34:15 +08:00
|
|
|
void forcePipeControl(NEO::LinearStream &commandStreamCSR);
|
|
|
|
|
2019-11-24 21:50:41 +08:00
|
|
|
bool flushBatchedSubmissions() override;
|
2020-05-23 00:11:28 +08:00
|
|
|
void programHardwareContext(LinearStream &cmdStream) override;
|
2020-05-27 21:30:31 +08:00
|
|
|
size_t getCmdsSizeForHardwareContext() const override;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
static void addBatchBufferEnd(LinearStream &commandStream, void **patchLocation);
|
2021-01-29 01:30:56 +08:00
|
|
|
void programEndingCmd(LinearStream &commandStream, Device &device, void **patchLocation, bool directSubmissionEnabled);
|
2018-07-05 17:23:28 +08:00
|
|
|
void addBatchBufferStart(MI_BATCH_BUFFER_START *commandBufferMemory, uint64_t startAddress, bool secondary);
|
2021-07-30 17:56:58 +08:00
|
|
|
|
2021-07-08 23:08:37 +08:00
|
|
|
size_t getRequiredStateBaseAddressSize(const Device &device) const;
|
2018-08-07 15:07:50 +08:00
|
|
|
size_t getRequiredCmdStreamSize(const DispatchFlags &dispatchFlags, Device &device);
|
|
|
|
size_t getRequiredCmdStreamSizeAligned(const DispatchFlags &dispatchFlags, Device &device);
|
2018-08-16 17:18:05 +08:00
|
|
|
size_t getRequiredCmdSizeForPreamble(Device &device) const;
|
2018-04-13 17:05:09 +08:00
|
|
|
size_t getCmdSizeForPreemption(const DispatchFlags &dispatchFlags) const;
|
2019-08-08 01:33:40 +08:00
|
|
|
size_t getCmdSizeForEpilogue(const DispatchFlags &dispatchFlags) const;
|
2019-08-08 17:44:23 +08:00
|
|
|
size_t getCmdSizeForEpilogueCommands(const DispatchFlags &dispatchFlags) const;
|
2018-04-13 17:05:09 +08:00
|
|
|
size_t getCmdSizeForL3Config() const;
|
|
|
|
size_t getCmdSizeForPipelineSelect() const;
|
2018-09-21 20:06:35 +08:00
|
|
|
size_t getCmdSizeForComputeMode();
|
2018-01-19 20:29:25 +08:00
|
|
|
size_t getCmdSizeForMediaSampler(bool mediaSamplerRequired) const;
|
2019-10-11 12:54:10 +08:00
|
|
|
size_t getCmdSizeForEngineMode(const DispatchFlags &dispatchFlags) const;
|
2020-11-27 03:02:18 +08:00
|
|
|
size_t getCmdSizeForPerDssBackedBuffer(const HardwareInfo &hwInfo);
|
2021-09-24 02:13:37 +08:00
|
|
|
size_t getCmdSizeForActivePartitionConfig() const;
|
2021-11-06 09:42:54 +08:00
|
|
|
size_t getCmdSizeForStallingCommands(const DispatchFlags &dispatchFlags) const;
|
|
|
|
size_t getCmdSizeForStallingNoPostSyncCommands() const;
|
2019-11-12 20:59:37 +08:00
|
|
|
|
2020-03-19 22:15:51 +08:00
|
|
|
bool isComputeModeNeeded() const;
|
|
|
|
bool isPipelineSelectAlreadyProgrammed() const;
|
2021-07-06 21:29:10 +08:00
|
|
|
void programComputeMode(LinearStream &csr, DispatchFlags &dispatchFlags, const HardwareInfo &hwInfo);
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2021-09-17 21:05:26 +08:00
|
|
|
void waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, bool forcePowerSavingMode) override;
|
2020-02-12 18:27:28 +08:00
|
|
|
const HardwareInfo &peekHwInfo() const;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2018-03-14 18:07:51 +08:00
|
|
|
void collectStateBaseAddresPatchInfo(
|
2018-04-04 17:34:46 +08:00
|
|
|
uint64_t commandBufferAddress,
|
2018-03-14 18:07:51 +08:00
|
|
|
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
|
|
|
|
2021-09-28 18:56:22 +08:00
|
|
|
void collectStateBaseAddresIohPatchInfo(uint64_t commandBufferAddress, uint64_t commandOffset, const LinearStream &ioh);
|
|
|
|
|
2018-04-10 16:26:59 +08:00
|
|
|
void resetKmdNotifyHelper(KmdNotifyHelper *newHelper);
|
|
|
|
|
2018-06-06 16:34:51 +08:00
|
|
|
CommandStreamReceiverType getType() override {
|
|
|
|
return CommandStreamReceiverType::CSR_HW;
|
|
|
|
}
|
|
|
|
|
2021-07-05 19:39:42 +08:00
|
|
|
uint32_t blitBuffer(const BlitPropertiesContainer &blitPropertiesContainer, bool blocking, bool profilingEnabled, Device &device) override;
|
2019-04-03 21:59:31 +08:00
|
|
|
|
2021-02-23 16:48:08 +08:00
|
|
|
void flushTagUpdate() override;
|
2021-04-13 04:19:19 +08:00
|
|
|
void flushNonKernelTask(GraphicsAllocation *eventAlloc, uint64_t immediateGpuAddress, uint64_t immediateData, PipeControlArgs &args, bool isWaitOnEvent, bool isStartOfDispatch, bool isEndOfDispatch) override;
|
2021-02-23 16:48:08 +08:00
|
|
|
void flushMiFlushDW();
|
2021-04-13 04:19:19 +08:00
|
|
|
void flushMiFlushDW(GraphicsAllocation *eventAlloc, uint64_t immediateGpuAddress, uint64_t immediateData);
|
2021-02-23 16:48:08 +08:00
|
|
|
void flushPipeControl();
|
2021-04-13 04:19:19 +08:00
|
|
|
void flushPipeControl(GraphicsAllocation *eventAlloc, uint64_t immediateGpuAddress, uint64_t immediateData, PipeControlArgs &args);
|
|
|
|
void flushSemaphoreWait(GraphicsAllocation *eventAlloc, uint64_t immediateGpuAddress, uint64_t immediateData, PipeControlArgs &args, bool isStartOfDispatch, bool isEndOfDispatch);
|
2021-02-23 16:48:08 +08:00
|
|
|
void flushSmallTask(LinearStream &commandStreamTask,
|
|
|
|
size_t commandStreamStartTask);
|
|
|
|
void flushHandler(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency);
|
|
|
|
|
2021-10-28 17:21:44 +08:00
|
|
|
bool isUpdateTagFromWaitEnabled() override;
|
2021-02-23 16:48:08 +08:00
|
|
|
void updateTagFromWait() override;
|
|
|
|
|
2019-09-12 23:30:13 +08:00
|
|
|
bool isMultiOsContextCapable() const override;
|
|
|
|
|
2021-08-02 18:44:48 +08:00
|
|
|
MemoryCompressionState getMemoryCompressionState(bool auxTranslationRequired, const HardwareInfo &hwInfo) const override;
|
2020-12-17 08:36:45 +08:00
|
|
|
|
2020-01-16 00:02:47 +08:00
|
|
|
bool isDirectSubmissionEnabled() const override {
|
|
|
|
return directSubmission.get() != nullptr;
|
|
|
|
}
|
|
|
|
|
2020-03-27 03:13:10 +08:00
|
|
|
bool isBlitterDirectSubmissionEnabled() const override {
|
|
|
|
return blitterDirectSubmission.get() != nullptr;
|
|
|
|
}
|
|
|
|
|
2021-07-30 17:56:58 +08:00
|
|
|
void stopDirectSubmission() override;
|
|
|
|
|
2021-06-15 19:31:12 +08:00
|
|
|
virtual bool isKmdWaitModeActive() { return true; }
|
2021-02-17 18:33:41 +08:00
|
|
|
|
2020-07-17 17:28:59 +08:00
|
|
|
bool initDirectSubmission(Device &device, OsContext &osContext) override;
|
2020-11-19 07:58:42 +08:00
|
|
|
GraphicsAllocation *getClearColorAllocation() override;
|
2020-07-17 17:28:59 +08:00
|
|
|
|
2021-03-29 22:46:41 +08:00
|
|
|
TagAllocatorBase *getTimestampPacketAllocator() override;
|
|
|
|
|
2021-05-20 05:41:59 +08:00
|
|
|
void postInitFlagsSetup() override;
|
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
protected:
|
2019-07-31 14:57:00 +08:00
|
|
|
void programPreemption(LinearStream &csr, DispatchFlags &dispatchFlags);
|
2021-11-04 20:54:18 +08:00
|
|
|
void programL3(LinearStream &csr, uint32_t &newL3Config);
|
|
|
|
void programPreamble(LinearStream &csr, Device &device, uint32_t &newL3Config);
|
2019-09-10 22:13:11 +08:00
|
|
|
void programPipelineSelect(LinearStream &csr, PipelineSelectArgs &pipelineSelectArgs);
|
2020-03-19 22:15:51 +08:00
|
|
|
void programAdditionalPipelineSelect(LinearStream &csr, PipelineSelectArgs &pipelineSelectArgs, bool is3DPipeline);
|
2021-06-23 21:34:56 +08:00
|
|
|
void programAdditionalStateBaseAddress(LinearStream &csr, typename GfxFamily::STATE_BASE_ADDRESS &cmd, Device &device);
|
2021-01-29 01:30:56 +08:00
|
|
|
void programEpilogue(LinearStream &csr, Device &device, void **batchBufferEndLocation, DispatchFlags &dispatchFlags);
|
2019-08-08 17:44:23 +08:00
|
|
|
void programEpliogueCommands(LinearStream &csr, const DispatchFlags &dispatchFlags);
|
2018-01-19 20:29:25 +08:00
|
|
|
void programMediaSampler(LinearStream &csr, DispatchFlags &dispatchFlags);
|
2020-11-27 03:02:18 +08:00
|
|
|
void programPerDssBackedBuffer(LinearStream &scr, Device &device, DispatchFlags &dispatchFlags);
|
2018-11-05 18:52:19 +08:00
|
|
|
void programStateSip(LinearStream &cmdStream, Device &device);
|
2019-05-29 21:37:54 +08:00
|
|
|
void programVFEState(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t maxFrontEndThreads);
|
2021-11-06 09:42:54 +08:00
|
|
|
void programStallingCommandsForBarrier(LinearStream &cmdStream, DispatchFlags &dispatchFlags);
|
|
|
|
void programStallingNoPostSyncCommandsForBarrier(LinearStream &cmdStream);
|
2019-10-11 12:54:10 +08:00
|
|
|
void programEngineModeCommands(LinearStream &csr, const DispatchFlags &dispatchFlags);
|
|
|
|
void programEngineModeEpliogue(LinearStream &csr, const DispatchFlags &dispatchFlags);
|
2021-09-24 02:13:37 +08:00
|
|
|
void programActivePartitionConfig();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2020-02-07 22:36:15 +08:00
|
|
|
void programEnginePrologue(LinearStream &csr);
|
2020-05-27 21:30:31 +08:00
|
|
|
size_t getCmdSizeForPrologue() const;
|
2020-01-31 15:50:12 +08:00
|
|
|
|
2021-10-19 00:47:09 +08:00
|
|
|
void setPipeControlPriorToNonPipelinedStateCommandExtraProperties(PipeControlArgs &args);
|
|
|
|
|
2018-05-21 16:57:28 +08:00
|
|
|
void addClearSLMWorkAround(typename GfxFamily::PIPE_CONTROL *pCmd);
|
2020-04-27 03:48:59 +08:00
|
|
|
void addPipeControlBeforeStateBaseAddress(LinearStream &commandStream);
|
2021-10-01 19:47:49 +08:00
|
|
|
void addPipeControlBeforeStateSip(LinearStream &commandStream, Device &device);
|
2021-09-30 19:10:58 +08:00
|
|
|
void addPipeControlBefore3dState(LinearStream &commandStream, DispatchFlags &dispatchFlags);
|
2021-10-01 19:47:49 +08:00
|
|
|
void addPipeControlPriorToNonPipelinedStateCommand(LinearStream &commandStream, PipeControlArgs args);
|
2018-09-03 22:44:42 +08:00
|
|
|
size_t getSshHeapSize();
|
2021-04-01 04:21:59 +08:00
|
|
|
bool are4GbHeapsAvailable() const;
|
2017-12-21 07:45:38 +08:00
|
|
|
|
|
|
|
uint64_t getScratchPatchAddress();
|
2019-03-29 07:49:23 +08:00
|
|
|
void createScratchSpaceController();
|
2017-12-21 07:45:38 +08:00
|
|
|
|
2019-01-28 20:44:59 +08:00
|
|
|
bool detectInitProgrammingFlagsRequired(const DispatchFlags &dispatchFlags) const;
|
2020-09-22 22:29:34 +08:00
|
|
|
bool checkPlatformSupportsNewResourceImplicitFlush() const;
|
|
|
|
bool checkPlatformSupportsGpuIdleImplicitFlush() const;
|
2019-01-28 20:44:59 +08:00
|
|
|
|
2017-12-21 07:45:38 +08:00
|
|
|
HeapDirtyState dshState;
|
|
|
|
HeapDirtyState iohState;
|
|
|
|
HeapDirtyState sshState;
|
|
|
|
|
|
|
|
CsrSizeRequestFlags csrSizeRequestFlags = {};
|
2020-01-16 00:02:47 +08:00
|
|
|
|
2020-11-18 21:56:18 +08:00
|
|
|
bool wasSubmittedToSingleSubdevice = false;
|
|
|
|
|
2020-03-27 03:13:10 +08:00
|
|
|
std::unique_ptr<DirectSubmissionHw<GfxFamily, RenderDispatcher<GfxFamily>>> directSubmission;
|
|
|
|
std::unique_ptr<DirectSubmissionHw<GfxFamily, BlitterDispatcher<GfxFamily>>> blitterDirectSubmission;
|
2021-04-13 04:19:19 +08:00
|
|
|
|
|
|
|
size_t cmdStreamStart = 0;
|
2017-12-21 07:45:38 +08:00
|
|
|
};
|
|
|
|
|
2019-03-26 18:59:46 +08:00
|
|
|
} // namespace NEO
|