Introduce ICED_PRESENT_MODE env var to pick a wgpu::PresentMode

This commit is contained in:
Héctor Ramón Jiménez 2024-05-07 21:05:29 +02:00
parent db07b9ba9e
commit 8a0701a0d9
No known key found for this signature in database
GPG key ID: 7CC46565708259A7
2 changed files with 29 additions and 10 deletions

View file

@ -51,3 +51,17 @@ impl From<graphics::Settings> for Settings {
}
}
}
pub fn present_mode_from_env() -> Option<wgpu::PresentMode> {
let present_mode = std::env::var("ICED_PRESENT_MODE").ok()?;
match present_mode.to_lowercase().as_str() {
"vsync" => Some(wgpu::PresentMode::AutoVsync),
"no_vsync" => Some(wgpu::PresentMode::AutoNoVsync),
"immediate" => Some(wgpu::PresentMode::Immediate),
"fifo" => Some(wgpu::PresentMode::Fifo),
"fifo_relaxed" => Some(wgpu::PresentMode::FifoRelaxed),
"mailbox" => Some(wgpu::PresentMode::Mailbox),
_ => None,
}
}