Skip to content

Commit 888b067

Browse files
Encapsulate creation of Scratch Space surface
Change-Id: Ifd1d794e0d8b7053cf5c37bdd867ab64f84241cc
1 parent 81a1e43 commit 888b067

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

runtime/command_stream/command_stream_receiver_hw.h

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
9595
void programOutOfDeviceWaitlistSemaphores(LinearStream &csr, DispatchFlags &dispatchFlags, Device &currentDevice);
9696
virtual void programVFEState(LinearStream &csr, DispatchFlags &dispatchFlags);
9797
virtual void initPageTableManagerRegisters(LinearStream &csr){};
98+
void createScratchSpaceAllocation(size_t requiredScratchSizeInBytes);
9899

99100
void addPipeControlWA(LinearStream &commandStream, bool flushDC);
100101
void addDcFlushToPipeControl(typename GfxFamily::PIPE_CONTROL *pCmd, bool flushDC);

runtime/command_stream/command_stream_receiver_hw.inl

+6-1
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
252252
scratchAllocation->taskCount = this->taskCount;
253253
getMemoryManager()->storeAllocation(std::unique_ptr<GraphicsAllocation>(scratchAllocation), TEMPORARY_ALLOCATION);
254254
}
255-
scratchAllocation = getMemoryManager()->allocateGraphicsMemoryInPreferredPool(true, nullptr, requiredScratchSizeInBytes, GraphicsAllocation::AllocationType::SCRATCH_SURFACE);
255+
createScratchSpaceAllocation(requiredScratchSizeInBytes);
256256
overrideMediaVFEStateDirty(true);
257257
if (is64bit && !force32BitAllocations) {
258258
stateBaseAddressDirty = true;
@@ -800,4 +800,9 @@ void CommandStreamReceiverHw<GfxFamily>::programOutOfDeviceWaitlistSemaphores(Li
800800
KernelCommandsHelper<GfxFamily>::programMiSemaphoreWait(csr, compareAddress, 1);
801801
}
802802
}
803+
804+
template <typename GfxFamily>
805+
void CommandStreamReceiverHw<GfxFamily>::createScratchSpaceAllocation(size_t requiredScratchSizeInBytes) {
806+
scratchAllocation = getMemoryManager()->allocateGraphicsMemoryInPreferredPool(true, nullptr, requiredScratchSizeInBytes, GraphicsAllocation::AllocationType::SCRATCH_SURFACE);
807+
}
803808
} // namespace OCLRT

unit_tests/libult/ult_command_stream_receiver.h

+4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
3535
using BaseClass = CommandStreamReceiverHw<GfxFamily>;
3636

3737
public:
38+
using BaseClass::createScratchSpaceAllocation;
3839
using BaseClass::dshState;
40+
using BaseClass::getScratchPatchAddress;
3941
using BaseClass::hwInfo;
4042
using BaseClass::indirectHeap;
4143
using BaseClass::iohState;
@@ -57,7 +59,9 @@ class UltCommandStreamReceiver : public CommandStreamReceiverHw<GfxFamily> {
5759
using BaseClass::CommandStreamReceiver::latestFlushedTaskCount;
5860
using BaseClass::CommandStreamReceiver::latestSentStatelessMocsConfig;
5961
using BaseClass::CommandStreamReceiver::mediaVfeStateDirty;
62+
using BaseClass::CommandStreamReceiver::requiredScratchSize;
6063
using BaseClass::CommandStreamReceiver::requiredThreadArbitrationPolicy;
64+
using BaseClass::CommandStreamReceiver::scratchAllocation;
6165
using BaseClass::CommandStreamReceiver::submissionAggregator;
6266
using BaseClass::CommandStreamReceiver::taskCount;
6367
using BaseClass::CommandStreamReceiver::taskLevel;

0 commit comments

Comments
 (0)