Simplify async render flushing code
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
};
|
||||
|
||||
@@ -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++)
|
||||
|
||||
Reference in New Issue
Block a user