Simplify async render flushing code

This commit is contained in:
2026-06-03 05:03:22 +02:00
parent fca6ed43cc
commit c2ec3fe2cb
3 changed files with 14 additions and 6 deletions
+7
View File
@@ -507,3 +507,10 @@ RenderContextBatch::RenderContextBatch(const RenderContext& context)
Contexts.Add(context);
EnableAsync = JobSystem::GetThreadsCount() > 1;
}
void RenderContextBatch::FlushWaitLabels()
{
for (const int64 label : WaitLabels)
JobSystem::Wait(label);
WaitLabels.Clear();
}
+5
View File
@@ -533,4 +533,9 @@ API_STRUCT(NoDefault) struct FLAXENGINE_API RenderContextBatch
{
return Contexts.Get()[0];
}
/// <summary>
/// Waits for all scheduled async jobs to complete and clears WaitLabels.
/// </summary>
void FlushWaitLabels();
};
+2 -6
View File
@@ -356,9 +356,7 @@ void Renderer::DrawActors(RenderContext& renderContext, const Array<Actor*>& cus
Level::DrawActors(renderContextBatch, SceneRendering::DrawCategory::SceneDraw);
Level::DrawActors(renderContextBatch, SceneRendering::DrawCategory::SceneDrawAsync);
JobSystem::SetJobStartingOnDispatch(true);
for (const int64 label : renderContextBatch.WaitLabels)
JobSystem::Wait(label);
renderContextBatch.WaitLabels.Clear();
renderContextBatch.FlushWaitLabels();
}
}
@@ -483,9 +481,7 @@ void RenderInner(SceneRenderTask* task, RenderContext& renderContext, RenderCont
// Wait for async jobs to finish
JobSystem::SetJobStartingOnDispatch(true);
for (const int64 label : renderContextBatch.WaitLabels)
JobSystem::Wait(label);
renderContextBatch.WaitLabels.Clear();
renderContextBatch.FlushWaitLabels();
// Perform custom post-scene drawing (eg. GPU dispatches used by VFX)
for (int32 i = 0; i < renderContextBatch.Contexts.Count(); i++)