Skip to content

Commit 65396fd

Browse files
optimize batching
- removes redundant MI_BATCH_BUFFER_START when target is within same command buffer - this way we do not have jump in command buffer Signed-off-by: Michal Mrozek <[email protected]>
1 parent c389db6 commit 65396fd

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

shared/source/command_stream/command_stream_receiver_hw_base.inl

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -702,7 +702,9 @@ inline bool CommandStreamReceiverHw<GfxFamily>::flushBatchedSubmissions() {
702702
if (DebugManager.flags.FlattenBatchBufferForAUBDump.get()) {
703703
flatBatchBufferHelper->registerCommandChunk(primaryCmdBuffer.get()->batchBuffer, sizeof(MI_BATCH_BUFFER_START));
704704
}
705+
705706
while (nextCommandBuffer && nextCommandBuffer->inspectionId == primaryCmdBuffer->inspectionId) {
707+
706708
//noop pipe control
707709
if (currentPipeControlForNooping) {
708710
if (DebugManager.flags.AddPatchInfoCommentsForAUBDump.get()) {
@@ -718,14 +720,24 @@ inline bool CommandStreamReceiverHw<GfxFamily>::flushBatchedSubmissions() {
718720
flushStampUpdateHelper.insert(nextCommandBuffer->flushStamp->getStampReference());
719721
auto nextCommandBufferAddress = nextCommandBuffer->batchBuffer.commandBufferAllocation->getGpuAddress();
720722
auto offsetedCommandBuffer = (uint64_t)ptrOffset(nextCommandBufferAddress, nextCommandBuffer->batchBuffer.startOffset);
721-
addBatchBufferStart((MI_BATCH_BUFFER_START *)currentBBendLocation, offsetedCommandBuffer, false);
723+
auto cpuAddressForCommandBufferDestination = ptrOffset(nextCommandBuffer->batchBuffer.commandBufferAllocation->getUnderlyingBuffer(), nextCommandBuffer->batchBuffer.startOffset);
724+
auto cpuAddressForCurrentCommandBufferEndingSection = alignUp(ptrOffset(currentBBendLocation, sizeof(MI_BATCH_BUFFER_START)), MemoryConstants::cacheLineSize);
725+
726+
//if we point to exact same command buffer, then batch buffer start is not needed at all
727+
if (cpuAddressForCurrentCommandBufferEndingSection == cpuAddressForCommandBufferDestination) {
728+
memset(currentBBendLocation, 0u, ptrDiff(cpuAddressForCurrentCommandBufferEndingSection, currentBBendLocation));
729+
} else {
730+
addBatchBufferStart((MI_BATCH_BUFFER_START *)currentBBendLocation, offsetedCommandBuffer, false);
731+
}
732+
722733
if (DebugManager.flags.FlattenBatchBufferForAUBDump.get()) {
723734
flatBatchBufferHelper->registerCommandChunk(nextCommandBuffer->batchBuffer, sizeof(MI_BATCH_BUFFER_START));
724735
}
725736

726737
currentBBendLocation = nextCommandBuffer->batchBufferEndLocation;
727738
lastTaskCount = nextCommandBuffer->taskCount;
728739
nextCommandBuffer = nextCommandBuffer->next;
740+
729741
commandBufferList.removeFrontOne();
730742
}
731743
surfacesForSubmit.reserve(resourcePackage.size() + 1);

0 commit comments

Comments
 (0)