Skip to content

Commit 23ad107

Browse files
Refactor hardware context programming
- expose programHardwareContext in CSR Change-Id: I05caa352e3b7268c3e07edd6043316ecbb24f815 Signed-off-by: Mateusz Hoppe <[email protected]>
1 parent 639a5a6 commit 23ad107

File tree

5 files changed

+28
-4
lines changed

5 files changed

+28
-4
lines changed

opencl/test/unit_test/kernel/kernel_tests.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -530,6 +530,10 @@ class CommandStreamReceiverMock : public CommandStreamReceiver {
530530
return CommandStreamReceiverType::CSR_HW;
531531
}
532532

533+
void programHardwareContext() override {}
534+
size_t getCmdsSizeForHardwareContext() const override {
535+
return 0;
536+
}
533537
std::map<const void *, size_t> residency;
534538
bool passResidencyCallToBaseClass = true;
535539
std::unique_ptr<ExecutionEnvironment> mockExecutionEnvironment;

shared/source/command_stream/command_stream_receiver.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ class CommandStreamReceiver {
8282

8383
virtual bool flushBatchedSubmissions() = 0;
8484
bool submitBatchBuffer(BatchBuffer &batchBuffer, ResidencyContainer &allocationsForResidency);
85+
virtual void programHardwareContext() = 0;
86+
virtual size_t getCmdsSizeForHardwareContext() const = 0;
8587

8688
MOCKABLE_VIRTUAL void makeResident(GraphicsAllocation &gfxAllocation);
8789
virtual void makeNonResident(GraphicsAllocation &gfxAllocation);

shared/source/command_stream/command_stream_receiver_hw.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
4040
uint32_t taskLevel, DispatchFlags &dispatchFlags, Device &device) override;
4141

4242
bool flushBatchedSubmissions() override;
43+
void programHardwareContext() override;
44+
size_t getCmdsSizeForHardwareContext() const override;
4345

4446
static void addBatchBufferEnd(LinearStream &commandStream, void **patchLocation);
4547
void programEndingCmd(LinearStream &commandStream, void **patchLocation, bool directSubmissionEnabled);
@@ -109,7 +111,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
109111
void programEngineModeEpliogue(LinearStream &csr, const DispatchFlags &dispatchFlags);
110112

111113
void programEnginePrologue(LinearStream &csr);
112-
size_t getCmdSizeForPrologue(const DispatchFlags &dispatchFlags) const;
114+
size_t getCmdSizeForPrologue() const;
113115

114116
void addClearSLMWorkAround(typename GfxFamily::PIPE_CONTROL *pCmd);
115117
void addPipeControlCmd(LinearStream &commandStream, PipeControlArgs &args);

shared/source/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,16 @@ inline void CommandStreamReceiverHw<GfxFamily>::addPipeControlCmd(
142142
MemorySynchronizationCommands<GfxFamily>::addPipeControl(commandStream, args);
143143
}
144144

145+
template <typename GfxFamily>
146+
void CommandStreamReceiverHw<GfxFamily>::programHardwareContext() {
147+
programEnginePrologue(commandStream);
148+
}
149+
150+
template <typename GfxFamily>
151+
size_t CommandStreamReceiverHw<GfxFamily>::getCmdsSizeForHardwareContext() const {
152+
return getCmdSizeForPrologue();
153+
}
154+
145155
template <typename GfxFamily>
146156
CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
147157
LinearStream &commandStreamTask,
@@ -283,7 +293,8 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
283293
if (executionEnvironment.rootDeviceEnvironments[device.getRootDeviceIndex()]->pageTableManager.get() && !pageTableManagerInitialized) {
284294
pageTableManagerInitialized = executionEnvironment.rootDeviceEnvironments[device.getRootDeviceIndex()]->pageTableManager->initPageTableManagerRegisters(this);
285295
}
286-
programEnginePrologue(commandStreamCSR);
296+
297+
programHardwareContext();
287298
programComputeMode(commandStreamCSR, dispatchFlags);
288299
programPipelineSelect(commandStreamCSR, dispatchFlags.pipelineSelectArgs);
289300
programL3(commandStreamCSR, dispatchFlags, newL3Config);
@@ -674,7 +685,7 @@ size_t CommandStreamReceiverHw<GfxFamily>::getRequiredCmdStreamSize(const Dispat
674685
size += getCmdSizeForPipelineSelect();
675686
size += getCmdSizeForPreemption(dispatchFlags);
676687
size += getCmdSizeForEpilogue(dispatchFlags);
677-
size += getCmdSizeForPrologue(dispatchFlags);
688+
size += getCmdsSizeForHardwareContext();
678689

679690
if (executionEnvironment.rootDeviceEnvironments[rootDeviceIndex]->getHardwareInfo()->workaroundTable.waSamplerCacheFlushBetweenRedescribedSurfaceReads) {
680691
if (this->samplerCacheFlushRequired != SamplerCacheFlushState::samplerCacheFlushNotRequired) {
@@ -959,7 +970,7 @@ inline void CommandStreamReceiverHw<GfxFamily>::programEnginePrologue(LinearStre
959970
}
960971

961972
template <typename GfxFamily>
962-
inline size_t CommandStreamReceiverHw<GfxFamily>::getCmdSizeForPrologue(const DispatchFlags &dispatchFlags) const {
973+
inline size_t CommandStreamReceiverHw<GfxFamily>::getCmdSizeForPrologue() const {
963974
return 0u;
964975
}
965976

shared/test/unit_test/mocks/mock_command_stream_receiver.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,9 @@ class MockCommandStreamReceiver : public CommandStreamReceiver {
7575
void downloadAllocations() override {
7676
downloadAllocationsCalled = true;
7777
}
78+
79+
void programHardwareContext() override {}
80+
size_t getCmdsSizeForHardwareContext() const override {
81+
return 0;
82+
}
7883
};

0 commit comments

Comments
 (0)