2017-12-21 00:45:38 +01:00
|
|
|
/*
|
2022-01-07 14:53:31 +00:00
|
|
|
* Copyright (C) 2018-2022 Intel Corporation
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
2018-09-18 12:29:07 -07:00
|
|
|
* SPDX-License-Identifier: MIT
|
2017-12-21 00:45:38 +01:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
2020-02-23 22:44:01 +01:00
|
|
|
#include "shared/source/command_stream/command_stream_receiver.h"
|
2022-01-07 14:53:31 +00:00
|
|
|
#include "shared/source/command_stream/submission_status.h"
|
2022-02-22 12:51:29 +00:00
|
|
|
#include "shared/source/command_stream/wait_status.h"
|
2020-03-26 20:13:10 +01: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-23 22:44:01 +01: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 00:45:38 +01:00
|
|
|
|
2020-07-30 15:02:11 +02:00
|
|
|
#include "hw_cmds.h"
|
|
|
|
|
2022-05-05 16:52:25 +00:00
|
|
|
#include <optional>
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
namespace NEO {
|
2017-12-21 00:45:38 +01:00
|
|
|
template <typename GfxFamily>
|
|
|
|
class DeviceCommandStreamReceiver;
|
2020-04-26 21:48:59 +02:00
|
|
|
struct PipeControlArgs;
|
2022-06-14 14:18:28 +00:00
|
|
|
class LogicalStateHelper;
|
2017-12-21 00:45:38 +01: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 15:33:35 +01:00
|
|
|
static CommandStreamReceiver *create(ExecutionEnvironment &executionEnvironment,
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
const DeviceBitfield deviceBitfield) {
|
2020-10-28 16:08:37 +01:00
|
|
|
return new CommandStreamReceiverHw<GfxFamily>(executionEnvironment, rootDeviceIndex, deviceBitfield);
|
2017-12-21 00:45:38 +01:00
|
|
|
}
|
|
|
|
|
2020-10-29 15:33:35 +01:00
|
|
|
CommandStreamReceiverHw(ExecutionEnvironment &executionEnvironment,
|
|
|
|
uint32_t rootDeviceIndex,
|
|
|
|
const DeviceBitfield deviceBitfield);
|
2020-01-15 17:02:47 +01:00
|
|
|
~CommandStreamReceiverHw() override;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2022-01-07 14:53:31 +00:00
|
|
|
SubmissionStatus flush(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency) override;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
CompletionStamp flushTask(LinearStream &commandStream, size_t commandStreamStart,
|
2022-03-28 12:55:12 +00:00
|
|
|
const IndirectHeap *dsh, const IndirectHeap *ioh, const IndirectHeap *ssh,
|
2018-08-01 10:01:41 +02:00
|
|
|
uint32_t taskLevel, DispatchFlags &dispatchFlags, Device &device) override;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-07-06 09:34:15 +02:00
|
|
|
void forcePipeControl(NEO::LinearStream &commandStreamCSR);
|
|
|
|
|
2019-11-24 14:50:41 +01:00
|
|
|
bool flushBatchedSubmissions() override;
|
2020-05-22 18:11:28 +02:00
|
|
|
void programHardwareContext(LinearStream &cmdStream) override;
|
2020-05-27 15:30:31 +02:00
|
|
|
size_t getCmdsSizeForHardwareContext() const override;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
static void addBatchBufferEnd(LinearStream &commandStream, void **patchLocation);
|
2021-01-28 17:30:56 +00:00
|
|
|
void programEndingCmd(LinearStream &commandStream, Device &device, void **patchLocation, bool directSubmissionEnabled);
|
2018-07-05 11:23:28 +02:00
|
|
|
void addBatchBufferStart(MI_BATCH_BUFFER_START *commandBufferMemory, uint64_t startAddress, bool secondary);
|
2021-07-30 09:56:58 +00:00
|
|
|
|
2021-07-08 15:08:37 +00:00
|
|
|
size_t getRequiredStateBaseAddressSize(const Device &device) const;
|
2018-08-07 09:07:50 +02:00
|
|
|
size_t getRequiredCmdStreamSize(const DispatchFlags &dispatchFlags, Device &device);
|
|
|
|
size_t getRequiredCmdStreamSizeAligned(const DispatchFlags &dispatchFlags, Device &device);
|
2018-08-16 11:18:05 +02:00
|
|
|
size_t getRequiredCmdSizeForPreamble(Device &device) const;
|
2018-04-13 11:05:09 +02:00
|
|
|
size_t getCmdSizeForPreemption(const DispatchFlags &dispatchFlags) const;
|
2019-08-07 19:33:40 +02:00
|
|
|
size_t getCmdSizeForEpilogue(const DispatchFlags &dispatchFlags) const;
|
2019-08-08 11:44:23 +02:00
|
|
|
size_t getCmdSizeForEpilogueCommands(const DispatchFlags &dispatchFlags) const;
|
2018-04-13 11:05:09 +02:00
|
|
|
size_t getCmdSizeForL3Config() const;
|
|
|
|
size_t getCmdSizeForPipelineSelect() const;
|
2018-01-19 13:29:25 +01:00
|
|
|
size_t getCmdSizeForMediaSampler(bool mediaSamplerRequired) const;
|
2019-10-11 12:54:10 +08:00
|
|
|
size_t getCmdSizeForEngineMode(const DispatchFlags &dispatchFlags) const;
|
2020-11-26 19:02:18 +00:00
|
|
|
size_t getCmdSizeForPerDssBackedBuffer(const HardwareInfo &hwInfo);
|
2021-09-23 18:13:37 +00:00
|
|
|
size_t getCmdSizeForActivePartitionConfig() const;
|
2021-11-06 01:42:54 +00:00
|
|
|
size_t getCmdSizeForStallingCommands(const DispatchFlags &dispatchFlags) const;
|
|
|
|
size_t getCmdSizeForStallingNoPostSyncCommands() const;
|
2021-12-09 19:31:27 +00:00
|
|
|
size_t getCmdSizeForStallingPostSyncCommands() const;
|
2022-03-09 17:15:48 +00:00
|
|
|
size_t getCmdSizeForComputeMode();
|
|
|
|
MOCKABLE_VIRTUAL bool hasSharedHandles();
|
2019-11-12 13:59:37 +01:00
|
|
|
|
2020-03-19 15:15:51 +01:00
|
|
|
bool isPipelineSelectAlreadyProgrammed() const;
|
2021-07-06 13:29:10 +00:00
|
|
|
void programComputeMode(LinearStream &csr, DispatchFlags &dispatchFlags, const HardwareInfo &hwInfo);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2022-03-23 14:36:07 +00:00
|
|
|
WaitStatus waitForTaskCountWithKmdNotifyFallback(uint32_t taskCountToWait, FlushStamp flushStampToWait, bool useQuickKmdSleep, QueueThrottle throttle) override;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2018-03-14 11:07:51 +01:00
|
|
|
void collectStateBaseAddresPatchInfo(
|
2018-04-04 11:34:46 +02:00
|
|
|
uint64_t commandBufferAddress,
|
2018-03-14 11:07:51 +01:00
|
|
|
uint64_t commandOffset,
|
2022-03-28 12:55:12 +00:00
|
|
|
const LinearStream *dsh,
|
|
|
|
const LinearStream *ioh,
|
|
|
|
const LinearStream *ssh,
|
2018-04-04 11:34:46 +02:00
|
|
|
uint64_t generalStateBase);
|
2018-03-14 11:07:51 +01:00
|
|
|
|
2021-09-28 10:56:22 +00:00
|
|
|
void collectStateBaseAddresIohPatchInfo(uint64_t commandBufferAddress, uint64_t commandOffset, const LinearStream &ioh);
|
|
|
|
|
2018-04-10 10:26:59 +02:00
|
|
|
void resetKmdNotifyHelper(KmdNotifyHelper *newHelper);
|
|
|
|
|
2018-06-06 10:34:51 +02:00
|
|
|
CommandStreamReceiverType getType() override {
|
|
|
|
return CommandStreamReceiverType::CSR_HW;
|
|
|
|
}
|
|
|
|
|
2022-05-05 16:52:25 +00:00
|
|
|
std::optional<uint32_t> flushBcsTask(const BlitPropertiesContainer &blitPropertiesContainer, bool blocking, bool profilingEnabled, Device &device) override;
|
2019-04-03 15:59:31 +02:00
|
|
|
|
2021-02-23 08:48:08 +00:00
|
|
|
void flushTagUpdate() override;
|
|
|
|
void flushMiFlushDW();
|
|
|
|
void flushPipeControl();
|
|
|
|
void flushSmallTask(LinearStream &commandStreamTask,
|
|
|
|
size_t commandStreamStartTask);
|
|
|
|
void flushHandler(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency);
|
|
|
|
|
2021-10-28 09:21:44 +00:00
|
|
|
bool isUpdateTagFromWaitEnabled() override;
|
2021-02-23 08:48:08 +00:00
|
|
|
void updateTagFromWait() override;
|
|
|
|
|
2019-09-12 17:30:13 +02:00
|
|
|
bool isMultiOsContextCapable() const override;
|
|
|
|
|
2021-08-02 10:44:48 +00:00
|
|
|
MemoryCompressionState getMemoryCompressionState(bool auxTranslationRequired, const HardwareInfo &hwInfo) const override;
|
2020-12-17 00:36:45 +00:00
|
|
|
|
2020-01-15 17:02:47 +01:00
|
|
|
bool isDirectSubmissionEnabled() const override {
|
|
|
|
return directSubmission.get() != nullptr;
|
|
|
|
}
|
|
|
|
|
2020-03-26 20:13:10 +01:00
|
|
|
bool isBlitterDirectSubmissionEnabled() const override {
|
|
|
|
return blitterDirectSubmission.get() != nullptr;
|
|
|
|
}
|
|
|
|
|
2021-07-30 09:56:58 +00:00
|
|
|
void stopDirectSubmission() override;
|
|
|
|
|
2021-06-15 11:31:12 +00:00
|
|
|
virtual bool isKmdWaitModeActive() { return true; }
|
2021-02-17 10:33:41 +00:00
|
|
|
|
2022-04-19 14:44:06 +00:00
|
|
|
bool initDirectSubmission() override;
|
2020-11-18 23:58:42 +00:00
|
|
|
GraphicsAllocation *getClearColorAllocation() override;
|
2020-07-17 11:28:59 +02:00
|
|
|
|
2021-03-29 14:46:41 +00:00
|
|
|
TagAllocatorBase *getTimestampPacketAllocator() override;
|
|
|
|
|
2021-05-19 21:41:59 +00:00
|
|
|
void postInitFlagsSetup() override;
|
2021-11-17 19:51:43 +00:00
|
|
|
void programActivePartitionConfig(LinearStream &csr);
|
2021-05-19 21:41:59 +00:00
|
|
|
|
2021-12-10 21:31:34 +00:00
|
|
|
void programComputeBarrierCommand(LinearStream &cmdStream) override {
|
|
|
|
programStallingNoPostSyncCommandsForBarrier(cmdStream);
|
|
|
|
}
|
|
|
|
size_t getCmdsSizeForComputeBarrierCommand() const override {
|
|
|
|
return getCmdSizeForStallingNoPostSyncCommands();
|
|
|
|
}
|
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
protected:
|
2019-07-31 08:57:00 +02:00
|
|
|
void programPreemption(LinearStream &csr, DispatchFlags &dispatchFlags);
|
2021-11-04 12:54:18 +00:00
|
|
|
void programL3(LinearStream &csr, uint32_t &newL3Config);
|
|
|
|
void programPreamble(LinearStream &csr, Device &device, uint32_t &newL3Config);
|
2019-09-10 16:13:11 +02:00
|
|
|
void programPipelineSelect(LinearStream &csr, PipelineSelectArgs &pipelineSelectArgs);
|
2021-06-23 13:34:56 +00:00
|
|
|
void programAdditionalStateBaseAddress(LinearStream &csr, typename GfxFamily::STATE_BASE_ADDRESS &cmd, Device &device);
|
2021-01-28 17:30:56 +00:00
|
|
|
void programEpilogue(LinearStream &csr, Device &device, void **batchBufferEndLocation, DispatchFlags &dispatchFlags);
|
2019-08-08 11:44:23 +02:00
|
|
|
void programEpliogueCommands(LinearStream &csr, const DispatchFlags &dispatchFlags);
|
2018-01-19 13:29:25 +01:00
|
|
|
void programMediaSampler(LinearStream &csr, DispatchFlags &dispatchFlags);
|
2020-11-26 19:02:18 +00:00
|
|
|
void programPerDssBackedBuffer(LinearStream &scr, Device &device, DispatchFlags &dispatchFlags);
|
2018-11-05 11:52:19 +01:00
|
|
|
void programStateSip(LinearStream &cmdStream, Device &device);
|
2019-05-29 15:37:54 +02:00
|
|
|
void programVFEState(LinearStream &csr, DispatchFlags &dispatchFlags, uint32_t maxFrontEndThreads);
|
2021-11-06 01:42:54 +00:00
|
|
|
void programStallingCommandsForBarrier(LinearStream &cmdStream, DispatchFlags &dispatchFlags);
|
|
|
|
void programStallingNoPostSyncCommandsForBarrier(LinearStream &cmdStream);
|
2021-12-09 19:31:27 +00:00
|
|
|
void programStallingPostSyncCommandsForBarrier(LinearStream &cmdStream, TagNodeBase &tagNode);
|
2019-10-11 12:54:10 +08:00
|
|
|
void programEngineModeCommands(LinearStream &csr, const DispatchFlags &dispatchFlags);
|
|
|
|
void programEngineModeEpliogue(LinearStream &csr, const DispatchFlags &dispatchFlags);
|
2021-11-17 19:51:43 +00:00
|
|
|
void programActivePartitionConfigFlushTask(LinearStream &csr);
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2020-02-07 15:36:15 +01:00
|
|
|
void programEnginePrologue(LinearStream &csr);
|
2020-05-27 15:30:31 +02:00
|
|
|
size_t getCmdSizeForPrologue() const;
|
2020-01-31 08:50:12 +01:00
|
|
|
|
2022-05-13 00:29:53 +00:00
|
|
|
void setClearSlmWorkAroundParameter(PipeControlArgs &args);
|
2021-10-01 11:47:49 +00:00
|
|
|
void addPipeControlBeforeStateSip(LinearStream &commandStream, Device &device);
|
2021-09-30 11:10:58 +00:00
|
|
|
void addPipeControlBefore3dState(LinearStream &commandStream, DispatchFlags &dispatchFlags);
|
2018-09-03 16:44:42 +02:00
|
|
|
size_t getSshHeapSize();
|
2021-03-31 20:21:59 +00:00
|
|
|
bool are4GbHeapsAvailable() const;
|
2017-12-21 00:45:38 +01:00
|
|
|
|
|
|
|
uint64_t getScratchPatchAddress();
|
2019-03-29 00:49:23 +01:00
|
|
|
void createScratchSpaceController();
|
2017-12-21 00:45:38 +01:00
|
|
|
|
2019-01-28 13:44:59 +01:00
|
|
|
bool detectInitProgrammingFlagsRequired(const DispatchFlags &dispatchFlags) const;
|
2020-09-22 16:29:34 +02:00
|
|
|
bool checkPlatformSupportsNewResourceImplicitFlush() const;
|
|
|
|
bool checkPlatformSupportsGpuIdleImplicitFlush() const;
|
2021-11-30 14:41:26 +00:00
|
|
|
void configurePostSyncWriteOffset();
|
2022-03-25 13:00:53 +00:00
|
|
|
void unregisterDirectSubmissionFromController();
|
2022-05-18 18:10:53 +00:00
|
|
|
constexpr bool isGlobalAtomicsProgrammingRequired(bool currentValue) const;
|
2019-01-28 13:44:59 +01:00
|
|
|
|
2017-12-21 00:45:38 +01:00
|
|
|
HeapDirtyState dshState;
|
|
|
|
HeapDirtyState iohState;
|
|
|
|
HeapDirtyState sshState;
|
|
|
|
|
|
|
|
CsrSizeRequestFlags csrSizeRequestFlags = {};
|
2020-01-15 17:02:47 +01:00
|
|
|
|
2020-11-18 13:56:18 +00:00
|
|
|
bool wasSubmittedToSingleSubdevice = false;
|
|
|
|
|
2020-03-26 20:13:10 +01:00
|
|
|
std::unique_ptr<DirectSubmissionHw<GfxFamily, RenderDispatcher<GfxFamily>>> directSubmission;
|
|
|
|
std::unique_ptr<DirectSubmissionHw<GfxFamily, BlitterDispatcher<GfxFamily>>> blitterDirectSubmission;
|
2022-06-14 14:18:28 +00:00
|
|
|
std::unique_ptr<LogicalStateHelper> logicalStateHelper;
|
2021-04-13 01:49:19 +05:30
|
|
|
|
|
|
|
size_t cmdStreamStart = 0;
|
2017-12-21 00:45:38 +01:00
|
|
|
};
|
|
|
|
|
2019-03-26 11:59:46 +01:00
|
|
|
} // namespace NEO
|