Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimise GL fence checking by querying less #6427

Merged
merged 2 commits into from
Oct 21, 2024

Conversation

Dinnerbone
Copy link
Contributor

@Dinnerbone Dinnerbone commented Oct 20, 2024

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:

for _ in 0..1000 {
    let encoder = device.create_command_encoder(&Default::default());
    queue.submit(Some(encoder.finish()));
}

Checklist

  • Run cargo fmt.
  • Run taplo format.
  • Run cargo clippy. If applicable, add:
    • --target wasm32-unknown-unknown
    • --target wasm32-unknown-emscripten
  • Run cargo xtask test to run tests.
  • Add change to CHANGELOG.md. See simple instructions inside file.

@Dinnerbone Dinnerbone requested a review from a team as a code owner October 20, 2024 23:19
Copy link
Member

@cwfitzgerald cwfitzgerald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice improvement

@cwfitzgerald cwfitzgerald merged commit 759c326 into gfx-rs:trunk Oct 21, 2024
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GL edge case, overhead of Fence::get_latest() quadratic over number of submits
2 participants