Revert d3c49be80f and do it better
This commit is contained in:
@@ -10,8 +10,6 @@
|
||||
#define GPU_TASKS_USE_DEDICATED_CONTEXT 0
|
||||
|
||||
GPUTasksContext::GPUTasksContext(GPUDevice* device)
|
||||
: _tasksDone(64)
|
||||
, _totalTasksDoneCount(0)
|
||||
{
|
||||
// Bump it up to prevent initial state problems with frame index comparison
|
||||
_currentSyncPoint = 10;
|
||||
@@ -30,8 +28,8 @@ GPUTasksContext::~GPUTasksContext()
|
||||
ASSERT(IsInMainThread());
|
||||
|
||||
// Cancel jobs to sync
|
||||
auto tasks = _tasksDone;
|
||||
_tasksDone.Clear();
|
||||
auto tasks = _tasksSyncing;
|
||||
_tasksSyncing.Clear();
|
||||
for (int32 i = 0; i < tasks.Count(); i++)
|
||||
{
|
||||
auto task = tasks[i];
|
||||
@@ -52,15 +50,16 @@ void GPUTasksContext::Run(GPUTask* task)
|
||||
{
|
||||
ASSERT(task != nullptr);
|
||||
|
||||
_tasksDone.Add(task);
|
||||
task->Execute(this);
|
||||
if (task->IsSyncing())
|
||||
_tasksSyncing.Add(task);
|
||||
}
|
||||
|
||||
void GPUTasksContext::OnCancelSync(GPUTask* task)
|
||||
{
|
||||
ASSERT(task != nullptr);
|
||||
|
||||
_tasksDone.Remove(task);
|
||||
_tasksSyncing.Remove(task);
|
||||
|
||||
if (!Engine::IsRequestingExit)
|
||||
LOG(Warning, "{0} has been canceled before a sync", task->ToString());
|
||||
@@ -76,9 +75,9 @@ void GPUTasksContext::OnFrameBegin()
|
||||
++_currentSyncPoint;
|
||||
|
||||
// Try to flush done jobs
|
||||
for (int32 i = 0; i < _tasksDone.Count(); i++)
|
||||
for (int32 i = 0; i < _tasksSyncing.Count(); i++)
|
||||
{
|
||||
auto task = _tasksDone[i];
|
||||
auto task = _tasksSyncing[i];
|
||||
auto state = task->GetState();
|
||||
if (task->GetSyncPoint() <= _currentSyncPoint && state != TaskState::Finished)
|
||||
{
|
||||
@@ -87,12 +86,12 @@ void GPUTasksContext::OnFrameBegin()
|
||||
}
|
||||
if (state == TaskState::Failed || state == TaskState::Canceled)
|
||||
{
|
||||
_tasksDone.RemoveAt(i);
|
||||
_tasksSyncing.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
if (state == TaskState::Finished)
|
||||
{
|
||||
_tasksDone.RemoveAt(i);
|
||||
_tasksSyncing.RemoveAt(i);
|
||||
i--;
|
||||
_totalTasksDoneCount++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user