Revert "fix: Remove fence handling when reuse cmd buffer"

This reverts commit f3bbd70a58.

Signed-off-by: Compute-Runtime-Validation <compute-runtime-validation@intel.com>
This commit is contained in:
Compute-Runtime-Validation
2024-01-27 07:53:40 +01:00
committed by Compute-Runtime-Automation
parent 46fb73026e
commit 63a5b64c7e
4 changed files with 99 additions and 1 deletions

View File

@@ -296,9 +296,28 @@ void CommandContainer::handleCmdBufferAllocations(size_t startIndex) {
}
for (size_t i = startIndex; i < cmdBufferAllocations.size(); i++) {
if (this->reusableAllocationList) {
if (isHandleFenceCompletionRequired) {
bool allocationHandled = false;
for (auto &engine : this->device->getMemoryManager()->getRegisteredEngines(cmdBufferAllocations[i]->getRootDeviceIndex())) {
auto osContextId = engine.osContext->getContextId();
if (cmdBufferAllocations[i]->isUsedByOsContext(osContextId) && engine.commandStreamReceiver->isAnyDirectSubmissionEnabled()) {
auto lock = engine.commandStreamReceiver->obtainUniqueOwnership();
auto taskCount = engine.commandStreamReceiver->peekTaskCount() + 1;
cmdBufferAllocations[i]->updateTaskCount(taskCount, osContextId);
cmdBufferAllocations[i]->updateResidencyTaskCount(taskCount, osContextId);
engine.commandStreamReceiver->flushTagUpdate();
engine.commandStreamReceiver->waitForTaskCount(taskCount);
allocationHandled = true;
}
}
if (!allocationHandled && isHandleFenceCompletionRequired) {
this->device->getMemoryManager()->handleFenceCompletion(cmdBufferAllocations[i]);
}
for (auto &engine : this->device->getMemoryManager()->getRegisteredEngines(cmdBufferAllocations[i]->getRootDeviceIndex())) {
auto osContextId = engine.osContext->getContextId();
cmdBufferAllocations[i]->releaseUsageInOsContext(osContextId);
}
reusableAllocationList->pushFrontOne(*cmdBufferAllocations[i]);
} else {
this->device->getMemoryManager()->freeGraphicsMemory(cmdBufferAllocations[i]);