Use *_from_env helpers from wgpu in iced_wgpu
This commit is contained in:
parent
16e6efe020
commit
1872f7fa6d
2 changed files with 7 additions and 21 deletions
|
|
@ -46,7 +46,7 @@ impl Settings {
|
|||
/// - `primary`
|
||||
pub fn from_env() -> Self {
|
||||
Settings {
|
||||
internal_backend: backend_from_env()
|
||||
internal_backend: wgpu::util::backend_bits_from_env()
|
||||
.unwrap_or(wgpu::Backends::all()),
|
||||
..Self::default()
|
||||
}
|
||||
|
|
@ -64,18 +64,3 @@ impl Default for Settings {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn backend_from_env() -> Option<wgpu::Backends> {
|
||||
std::env::var("WGPU_BACKEND").ok().map(|backend| {
|
||||
match backend.to_lowercase().as_str() {
|
||||
"vulkan" => wgpu::Backends::VULKAN,
|
||||
"metal" => wgpu::Backends::METAL,
|
||||
"dx12" => wgpu::Backends::DX12,
|
||||
"dx11" => wgpu::Backends::DX11,
|
||||
"gl" => wgpu::Backends::GL,
|
||||
"webgpu" => wgpu::Backends::BROWSER_WEBGPU,
|
||||
"primary" => wgpu::Backends::PRIMARY,
|
||||
other => panic!("Unknown backend: {other}"),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,11 +53,12 @@ impl<Theme> Compositor<Theme> {
|
|||
|
||||
let adapter = instance
|
||||
.request_adapter(&wgpu::RequestAdapterOptions {
|
||||
power_preference: if settings.antialiasing.is_none() {
|
||||
wgpu::PowerPreference::LowPower
|
||||
} else {
|
||||
wgpu::PowerPreference::HighPerformance
|
||||
},
|
||||
power_preference: wgpu::util::power_preference_from_env()
|
||||
.unwrap_or(if settings.antialiasing.is_none() {
|
||||
wgpu::PowerPreference::LowPower
|
||||
} else {
|
||||
wgpu::PowerPreference::HighPerformance
|
||||
}),
|
||||
compatible_surface: compatible_surface.as_ref(),
|
||||
force_fallback_adapter: false,
|
||||
})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue