Optimise GL fence checking by querying less #6427
Merged
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.
Connections
This fixes #5179
Description
By keeping better track of which GL sync object last signalled, we can avoid repeatedly querying the status of them over and over. Additionally, bail early when encountering an unsignalled object as we know the remaining objects can't be signalled.
This has a noticable impact on performance when there are many
Queue::submit()
s per frame. For an extreme and contrived case, testing with the code below shows a reduction in frame time from 2 minutes to 2 seconds for me (with firefox, which seems to have a high cost of each sync check due to IPC)(It's likely we can apply the same optimisation to Vulkan's FencePool too, but, I doubt the cost is nearly as high there as WebGL.)
Testing
Passes tests, and manually tested the impact by adding the following code to
hello_triangle
:Checklist
cargo fmt
.taplo format
.cargo clippy
. If applicable, add:--target wasm32-unknown-unknown
--target wasm32-unknown-emscripten
cargo xtask test
to run tests.CHANGELOG.md
. See simple instructions inside file.