Skip to content

Commit 7729eb8

Browse files
refactor: move flush task submission to a function
Related-To: NEO-7824 Signed-off-by: Kamil Kopryk <[email protected]>
1 parent 6cdd2d5 commit 7729eb8

File tree

2 files changed

+63
-31
lines changed

2 files changed

+63
-31
lines changed

shared/source/command_stream/command_stream_receiver_hw.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,18 @@ class CommandStreamReceiverHw : public CommandStreamReceiver {
249249
bool &hasStallingCmdsOnTaskStream,
250250
PipeControlArgs &args);
251251

252+
inline CompletionStamp handleFlushTaskSubmission(BatchBuffer &&batchBuffer,
253+
const DispatchFlags &dispatchFlags,
254+
Device &device,
255+
void *currentPipeControlForNooping,
256+
void *epiloguePipeControlLocation,
257+
PipeControlArgs &args,
258+
bool submitTask,
259+
bool submitCSR,
260+
bool hasStallingCmdsOnTaskStream,
261+
bool levelClosed,
262+
bool implicitFlush);
263+
252264
inline CompletionStamp updateTaskCountAndGetCompletionStamp(bool levelClosed);
253265
inline void programSamplerCacheFlushBetweenRedescribedSurfaceReads(LinearStream &commandStreamCSR);
254266
bool bcsRelaxedOrderingAllowed(const BlitPropertiesContainer &blitPropertiesContainer, bool hasStallingCmds) const;

shared/source/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 51 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -570,38 +570,10 @@ CompletionStamp CommandStreamReceiverHw<GfxFamily>::flushTask(
570570
auto batchBuffer = prepareBatchBufferForSubmission(commandStreamTask, commandStreamStartTask, commandStreamCSR, commandStreamStartCSR,
571571
dispatchFlags, device, submitTask, submitCSR, hasStallingCmdsOnTaskStream);
572572

573-
if (submitCSR || submitTask) {
574-
if (this->dispatchMode == DispatchMode::immediateDispatch) {
575-
auto submissionStatus = flushHandler(batchBuffer, this->getResidencyAllocations());
576-
if (submissionStatus != SubmissionStatus::success) {
577-
updateStreamTaskCount(*batchBuffer.stream, taskCount);
578-
CompletionStamp completionStamp = {CompletionStamp::getTaskCountFromSubmissionStatusError(submissionStatus)};
579-
return completionStamp;
580-
}
581-
if (hasStallingCmdsOnTaskStream) {
582-
this->latestFlushedTaskCount = this->taskCount + 1;
583-
}
584-
} else {
585-
auto commandBuffer = new CommandBuffer(device);
586-
commandBuffer->batchBuffer = batchBuffer;
587-
commandBuffer->surfaces.swap(this->getResidencyAllocations());
588-
commandBuffer->batchBufferEndLocation = batchBuffer.endCmdPtr;
589-
commandBuffer->taskCount = this->taskCount + 1;
590-
commandBuffer->flushStamp->replaceStampObject(dispatchFlags.flushStampReference);
591-
commandBuffer->pipeControlThatMayBeErasedLocation = currentPipeControlForNooping;
592-
commandBuffer->epiloguePipeControlLocation = epiloguePipeControlLocation;
593-
commandBuffer->epiloguePipeControlArgs = args;
594-
this->submissionAggregator->recordCommandBuffer(commandBuffer);
595-
}
596-
} else {
597-
this->makeSurfacePackNonResident(this->getResidencyAllocations(), true);
598-
}
573+
auto completionStamp = handleFlushTaskSubmission(std::move(batchBuffer), dispatchFlags, device, currentPipeControlForNooping, epiloguePipeControlLocation,
574+
args, submitTask, submitCSR, hasStallingCmdsOnTaskStream, levelClosed, implicitFlush);
599575

600-
if (this->dispatchMode == DispatchMode::batchedDispatch) {
601-
handleBatchedDispatchImplicitFlush(device.getDeviceInfo().globalMemSize, implicitFlush);
602-
}
603-
604-
return updateTaskCountAndGetCompletionStamp(levelClosed);
576+
return completionStamp;
605577
}
606578

607579
template <typename GfxFamily>
@@ -1837,6 +1809,54 @@ inline void CommandStreamReceiverHw<GfxFamily>::processBarrierWithPostSync(Linea
18371809
}
18381810
}
18391811

1812+
template <typename GfxFamily>
1813+
inline CompletionStamp CommandStreamReceiverHw<GfxFamily>::handleFlushTaskSubmission(BatchBuffer &&batchBuffer,
1814+
const DispatchFlags &dispatchFlags,
1815+
Device &device,
1816+
void *currentPipeControlForNooping,
1817+
void *epiloguePipeControlLocation,
1818+
PipeControlArgs &args,
1819+
bool submitTask,
1820+
bool submitCSR,
1821+
bool hasStallingCmdsOnTaskStream,
1822+
bool levelClosed,
1823+
bool implicitFlush) {
1824+
1825+
if (submitCSR || submitTask) {
1826+
if (this->dispatchMode == DispatchMode::immediateDispatch) {
1827+
auto submissionStatus = flushHandler(batchBuffer, this->getResidencyAllocations());
1828+
if (submissionStatus != SubmissionStatus::success) {
1829+
updateStreamTaskCount(*batchBuffer.stream, taskCount);
1830+
CompletionStamp completionStamp = {CompletionStamp::getTaskCountFromSubmissionStatusError(submissionStatus)};
1831+
return completionStamp;
1832+
}
1833+
if (hasStallingCmdsOnTaskStream) {
1834+
this->latestFlushedTaskCount = this->taskCount + 1;
1835+
}
1836+
} else {
1837+
auto commandBuffer = new CommandBuffer(device);
1838+
commandBuffer->batchBufferEndLocation = batchBuffer.endCmdPtr;
1839+
commandBuffer->batchBuffer = std::move(batchBuffer);
1840+
commandBuffer->surfaces.swap(this->getResidencyAllocations());
1841+
commandBuffer->taskCount = this->taskCount + 1;
1842+
commandBuffer->flushStamp->replaceStampObject(dispatchFlags.flushStampReference);
1843+
commandBuffer->pipeControlThatMayBeErasedLocation = currentPipeControlForNooping;
1844+
commandBuffer->epiloguePipeControlLocation = epiloguePipeControlLocation;
1845+
commandBuffer->epiloguePipeControlArgs = args;
1846+
this->submissionAggregator->recordCommandBuffer(commandBuffer);
1847+
}
1848+
} else {
1849+
this->makeSurfacePackNonResident(this->getResidencyAllocations(), true);
1850+
}
1851+
1852+
if (this->dispatchMode == DispatchMode::batchedDispatch) {
1853+
handleBatchedDispatchImplicitFlush(device.getDeviceInfo().globalMemSize, implicitFlush);
1854+
}
1855+
1856+
CompletionStamp completionStamp = updateTaskCountAndGetCompletionStamp(levelClosed);
1857+
return completionStamp;
1858+
}
1859+
18401860
template <typename GfxFamily>
18411861
inline CompletionStamp CommandStreamReceiverHw<GfxFamily>::updateTaskCountAndGetCompletionStamp(bool levelClosed) {
18421862

0 commit comments

Comments
 (0)