Fix crash when GPUTask gets deleted before sync happens

This commit is contained in:
Wojtek Figat
2025-04-17 10:40:05 +02:00
parent 980473cce6
commit d3c49be80f
2 changed files with 12 additions and 0 deletions

View File

@@ -58,6 +58,8 @@ protected:
{
}
~GPUTask();
public:
/// <summary>
/// Gets a task type.

View File

@@ -7,6 +7,16 @@
#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);