mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 06:44:14 +00:00
refactor: use linear flow instead of broken loop
for determining fallback
This commit is contained in:
parent
b9e787e667
commit
4a1174b5ed
@ -1916,37 +1916,39 @@ impl Global {
|
||||
}
|
||||
|
||||
if !caps.present_modes.contains(&config.present_mode) {
|
||||
let new_mode = 'error: {
|
||||
// Automatic present mode checks.
|
||||
//
|
||||
// The "Automatic" modes are never supported by the backends.
|
||||
let fallbacks = match config.present_mode {
|
||||
wgt::PresentMode::AutoVsync => {
|
||||
&[wgt::PresentMode::FifoRelaxed, wgt::PresentMode::Fifo][..]
|
||||
}
|
||||
// Always end in FIFO to make sure it's always supported
|
||||
wgt::PresentMode::AutoNoVsync => &[
|
||||
wgt::PresentMode::Immediate,
|
||||
wgt::PresentMode::Mailbox,
|
||||
wgt::PresentMode::Fifo,
|
||||
][..],
|
||||
_ => {
|
||||
return Err(E::UnsupportedPresentMode {
|
||||
requested: config.present_mode,
|
||||
available: caps.present_modes.clone(),
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
for &fallback in fallbacks {
|
||||
if caps.present_modes.contains(&fallback) {
|
||||
break 'error fallback;
|
||||
}
|
||||
// Automatic present mode checks.
|
||||
//
|
||||
// The "Automatic" modes are never supported by the backends.
|
||||
let fallbacks = match config.present_mode {
|
||||
wgt::PresentMode::AutoVsync => {
|
||||
&[wgt::PresentMode::FifoRelaxed, wgt::PresentMode::Fifo][..]
|
||||
}
|
||||
// Always end in FIFO to make sure it's always supported
|
||||
wgt::PresentMode::AutoNoVsync => &[
|
||||
wgt::PresentMode::Immediate,
|
||||
wgt::PresentMode::Mailbox,
|
||||
wgt::PresentMode::Fifo,
|
||||
][..],
|
||||
_ => {
|
||||
return Err(E::UnsupportedPresentMode {
|
||||
requested: config.present_mode,
|
||||
available: caps.present_modes.clone(),
|
||||
});
|
||||
}
|
||||
|
||||
unreachable!("Fallback system failed to choose present mode. This is a bug. Mode: {:?}, Options: {:?}", config.present_mode, &caps.present_modes);
|
||||
};
|
||||
|
||||
let new_mode = fallbacks
|
||||
.iter()
|
||||
.copied()
|
||||
.find(|fallback| caps.present_modes.contains(fallback))
|
||||
.unwrap_or_else(|| {
|
||||
unreachable!(
|
||||
"Fallback system failed to choose present mode. \
|
||||
This is a bug. Mode: {:?}, Options: {:?}",
|
||||
config.present_mode, &caps.present_modes
|
||||
);
|
||||
});
|
||||
|
||||
api_log!(
|
||||
"Automatically choosing presentation mode by rule {:?}. Chose {new_mode:?}",
|
||||
config.present_mode
|
||||
|
Loading…
Reference in New Issue
Block a user