Recycle old command buffers of immediate command lists

Related-To: NEO-6242

Signed-off-by: Zbigniew Zdanowicz <zbigniew.zdanowicz@intel.com>
This commit is contained in:
Zbigniew Zdanowicz
2022-03-07 13:14:53 +00:00
committed by Compute-Runtime-Automation
parent dd01cff879
commit 8f93f4f3ec
8 changed files with 96 additions and 28 deletions

View File

@ -229,12 +229,16 @@ IndirectHeap *CommandContainer::getHeapWithRequiredSizeAndAlignment(HeapType hea
void CommandContainer::handleCmdBufferAllocations(size_t startIndex) {
for (size_t i = startIndex; i < cmdBufferAllocations.size(); i++) {
if (this->reusableAllocationList) {
this->device->getMemoryManager()->handleFenceCompletion(cmdBufferAllocations[i]);
reusableAllocationList->pushFrontOne(*cmdBufferAllocations[i]);
} else {
this->device->getMemoryManager()->freeGraphicsMemory(cmdBufferAllocations[i]);
}
handleCmdBufferAllocation(cmdBufferAllocations[i]);
}
}
void CommandContainer::handleCmdBufferAllocation(GraphicsAllocation *allocation) {
if (this->reusableAllocationList) {
this->device->getMemoryManager()->handleFenceCompletion(allocation);
reusableAllocationList->pushFrontOne(*allocation);
} else {
this->device->getMemoryManager()->freeGraphicsMemory(allocation);
}
}
@ -264,6 +268,11 @@ void CommandContainer::allocateNextCommandBuffer() {
auto cmdBufferAllocation = this->obtainNextCommandBufferAllocation();
UNRECOVERABLE_IF(!cmdBufferAllocation);
if (getFlushTaskUsedForImmediate()) {
NEO::GraphicsAllocation *oldCmdBuffer = cmdBufferAllocations.back();
handleCmdBufferAllocation(oldCmdBuffer);
cmdBufferAllocations.pop_back();
}
cmdBufferAllocations.push_back(cmdBufferAllocation);
size_t alignedSize = alignUp<size_t>(totalCmdBufferSize, MemoryConstants::pageSize64k);

View File

@ -88,6 +88,7 @@ class CommandContainer : public NonCopyableOrMovableClass {
void closeAndAllocateNextCommandBuffer();
void handleCmdBufferAllocations(size_t startIndex);
void handleCmdBufferAllocation(GraphicsAllocation *allocation);
GraphicsAllocation *obtainNextCommandBufferAllocation();
void reset();