-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add PresentMode fallbacks #22108
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
base: main
Are you sure you want to change the base?
Add PresentMode fallbacks #22108
Conversation
tychedelia
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, this is reallly helpful to prevent an unnecessary crash.
janhohenheim
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MInor nit, nothing blocking :)
| ); | ||
| }); | ||
| if new_present_mode != present_mode && fallbacks.contains(&present_mode) { | ||
| info!("PresentMode {present_mode:?} requested but not available. Falling back to {new_present_mode:?}"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This may be a little chatty for something like AutoNoVsync where it's not really like you "requested" Immediate, you're more like "just gimme whatever works"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AutoNoVsync and AutoVsync will not log because of the fallbacks.contains(&present_mode) check
| }; | ||
| let fallbacks = match present_mode { | ||
| wgpu::PresentMode::AutoVsync => { | ||
| &[wgpu::PresentMode::FifoRelaxed, wgpu::PresentMode::Fifo][..] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does the &[][..] syntax do?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It turns it into a slice. Rust thinks these are array references if we dont do that, and the match complains about heterogeneous return value.
| wgpu::PresentMode::Fifo, | ||
| ][..], | ||
| wgpu::PresentMode::Mailbox => &[ | ||
| wgpu::PresentMode::Mailbox, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it intentional that in some cases the fallbacks start with the mode they're for, and in other cases not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, AutoVsync and AutoNoVsync are not actual presentation modes, they never show up in surface caps. Wgpu offers them as a "reasonable defaults" fallback order so that not everyone has to do this cap check type logic in their apps from what i gather. The logic here is the same as in the wgpu source: these two modes convert to this set of fallbacks.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, okay that explains it, thanks.
Objective
Solution
Testing