| 63 | } |
| 64 | |
| 65 | void GPUTasksContext::OnFrameBegin() |
| 66 | { |
| 67 | #if GPU_TASKS_USE_DEDICATED_CONTEXT |
| 68 | GPU->FrameBegin(); |
| 69 | #endif |
| 70 | |
| 71 | // Move forward one frame |
| 72 | ++_currentSyncPoint; |
| 73 | |
| 74 | // Try to flush done jobs |
| 75 | for (int32 i = 0; i < _tasksSyncing.Count(); i++) |
| 76 | { |
| 77 | auto task = _tasksSyncing[i]; |
| 78 | auto state = task->GetState(); |
| 79 | if (task->GetSyncPoint() <= _currentSyncPoint && state != TaskState::Finished) |
| 80 | { |
| 81 | // TODO: add stats counter and count performed jobs, print to log on exit. |
| 82 | task->Sync(); |
| 83 | } |
| 84 | if (state == TaskState::Failed || state == TaskState::Canceled) |
| 85 | { |
| 86 | _tasksSyncing.RemoveAt(i); |
| 87 | i--; |
| 88 | } |
| 89 | if (state == TaskState::Finished) |
| 90 | { |
| 91 | _tasksSyncing.RemoveAt(i); |
| 92 | i--; |
| 93 | _totalTasksDoneCount++; |
| 94 | } |
| 95 | } |
| 96 | } |
| 97 | |
| 98 | void GPUTasksContext::OnFrameEnd() |
| 99 | { |
no test coverage detected