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

Expose maximum_frame_latency from wgpu to Bevy users #12930

Closed
alice-i-cecile opened this issue Apr 11, 2024 · 2 comments · Fixed by #12954
Closed

Expose maximum_frame_latency from wgpu to Bevy users #12930

alice-i-cecile opened this issue Apr 11, 2024 · 2 comments · Fixed by #12954
Labels
A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets C-Performance A change motivated by improving speed, memory usage or compile times C-Usability A targeted quality-of-life change that makes Bevy easier to use

Comments

@alice-i-cecile
Copy link
Member

What problem does this solve or what need does it fill?

gfx-rs/wgpu#4899 exposes control over the maximum number of frames that should be buffered.

As the linked docs explain

What solution would you like?

Bevy should offer users control over this and document that it exists. We should consider whether to leave this as a manual call, a plugin parameter, or a synchronized resource-based setting. I think that runtime changes to this will be extremely rare, so my preference is a plugin parameter with a documented escape hatch to change the value manually.

What alternative(s) have you considered?

When pipelined rendering is disabled, we should consider swapping to 1, or suggesting that users do so. The sequential-CPU-GPU pattern is what we're already doing in that case, so the lower latency might be a good choice.

Additional context

Thanks to @aevyrie for mentioning this. @JMS55 points out that we're currently defaulting to 2.

@alice-i-cecile alice-i-cecile added A-Rendering Drawing game state to the screen C-Performance A change motivated by improving speed, memory usage or compile times A-UI Graphical user interfaces, styles, layouts, and widgets C-Usability A targeted quality-of-life change that makes Bevy easier to use labels Apr 11, 2024
@Kanabenki
Copy link
Contributor

Some questions regarding that setting:

  • This is technically a per window setting since this is exposed by the surface. While I don't see a use case were the user would want that value to vary per-window, for consistency with other settings like the present mode it may make sense for the user-override to be something like a Option<NonZeroU32> on Window/ExtractedWindow?
  • Wouldn't keeping 2 as the default even when pipeline rendering is disabled prevent stalling on the cpu side if a frame takes longer than the others on the gpu side? I guess this would need some latency benchmarking to see the actual effect of that change.

@alice-i-cecile
Copy link
Member Author

it may make sense for the user-override to be something like a Option on Window/ExtractedWindow

Agreed. We should avoid creating leaky abstractions without a good reason.

Yeah, I'm leaning towards keeping the default as 2 in all cases, but we can add doc notes once people experiment with values further.

github-merge-queue bot pushed a commit that referenced this issue Apr 19, 2024
# Objective

- Closes #12930.

## Solution

- Add a corresponding optional field on `Window` and `ExtractedWindow`

---

## Changelog

### Added

- `wgpu`'s `desired_maximum_frame_latency` is exposed through window
creation. This can be used to override the default maximum number of
queued frames on the GPU (currently 2).

## Migration Guide

- The `desired_maximum_frame_latency` field must be added to instances
of `Window` and `ExtractedWindow` where all fields are explicitly
specified.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-Rendering Drawing game state to the screen A-UI Graphical user interfaces, styles, layouts, and widgets C-Performance A change motivated by improving speed, memory usage or compile times C-Usability A targeted quality-of-life change that makes Bevy easier to use
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants