Move the stage that acquires a new texture from the swap chain as late as possible in the rendering pipeline. #16964
+61
−37
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Currently, we retrieve a new texture from the pipeline in
prepare_windows
, which executes during theManageViews
rendering phase. This is inefficient if we're GPU bound, becauseManageViews
happens beforequeue_material_meshes
andbatch_and_prepare_binned_render_phase
among other frequently-slow systems. Retrieving a new texture from the swap chain can block for considerable time, during which we don't want the CPU to be sitting idle. Additionally, we don't want the GPU to be sitting idle while the CPU works onqueue_material_meshes
and so forth.This commit fixes the issue by moving the acquisition of a new swap chain texture late in the pipeline, to a new phase
PrepareWindows
that occurs right before render graph evaluation. Because render graph evaluation needs to bind the swap chain textures in order to issue drawing commands, this is the last possible moment where it's safe to do so.This shows Bistro on
main
with shadows enabled before these changes. Note thatqueue_material_meshes
andbatch_and_prepare_binned_render_phase
occur afterprepare_windows
and therefore the GPU is idle during this time.This shows Bistro with these changes applied and shadows enabled. Observe that
queue_material_meshes
andbatch_and_prepare_binned_render_phase
are moved beforeprepare_windows
, allowing for simultaneous GPU/CPU execution.