Revert d3c49be80f and do it better

This commit is contained in:
Wojtek Figat
2025-04-17 10:52:00 +02:00
parent 414b229b27
commit ef188d06c4
4 changed files with 27 additions and 44 deletions

View File

@@ -7,16 +7,6 @@
#include "Engine/Core/Types/String.h"
#include "Engine/Graphics/GPUDevice.h"
GPUTask::~GPUTask()
{
// Ensure to dereference task
if (auto context = _context)
{
_context = nullptr;
context->OnCancelSync(this);
}
}
void GPUTask::Execute(GPUTasksContext* context)
{
ASSERT(IsQueued() && _context == nullptr);
@@ -58,6 +48,21 @@ void GPUTask::Enqueue()
GPUDevice::Instance->GetTasksManager()->_tasks.Add(this);
}
void GPUTask::OnCancel()
{
// Check if task is waiting for sync (very likely situation)
if (IsSyncing())
{
// Task has been performed but is waiting for a CPU/GPU sync so we have to cancel that
ASSERT(_context != nullptr);
_context->OnCancelSync(this);
_context = nullptr;
}
// Base
Task::OnCancel();
}
GPUTasksManager::GPUTasksManager()
{
_buffers[0].EnsureCapacity(64);