summaryrefslogtreecommitdiffstats
path: root/wgpu/src/settings.rs
diff options
context:
space:
mode:
Diffstat (limited to 'wgpu/src/settings.rs')
-rw-r--r--wgpu/src/settings.rs26
1 files changed, 26 insertions, 0 deletions
diff --git a/wgpu/src/settings.rs b/wgpu/src/settings.rs
index a6aea0a5..b3c3cf6a 100644
--- a/wgpu/src/settings.rs
+++ b/wgpu/src/settings.rs
@@ -51,3 +51,29 @@ impl From<graphics::Settings> for Settings {
}
}
}
+
+/// Obtains a [`wgpu::PresentMode`] from the current environment
+/// configuration, if set.
+///
+/// The value returned by this function can be changed by setting
+/// the `ICED_PRESENT_MODE` env variable. The possible values are:
+///
+/// - `vsync` → [`wgpu::PresentMode::AutoVsync`]
+/// - `no_vsync` → [`wgpu::PresentMode::AutoNoVsync`]
+/// - `immediate` → [`wgpu::PresentMode::Immediate`]
+/// - `fifo` → [`wgpu::PresentMode::Fifo`]
+/// - `fifo_relaxed` → [`wgpu::PresentMode::FifoRelaxed`]
+/// - `mailbox` → [`wgpu::PresentMode::Mailbox`]
+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,
+ }
+}