mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-29 09:34:09 +01:00
Support WGPU_BACKEND environment in the examples
This commit is contained in:
1 parent
507770ad73
commit
d8fe188305
1 file changed
+14
-1
+14
-1
@@ -108,7 +108,20 @@ async fn setup<E: Example>(title: &str) -> Setup {
|
||||
|
||||
log::info!("Initializing the surface...");
|
||||
|
||||
let instance = wgpu::Instance::new(wgpu::BackendBit::PRIMARY);
|
||||
let backend = if let Ok(backend) = std::env::var("WGPU_TRACE") {
|
||||
match backend.to_lowercase().as_str() {
|
||||
"vulkan" => wgpu::BackendBit::VULKAN,
|
||||
"metal" => wgpu::BackendBit::METAL,
|
||||
"dx12" => wgpu::BackendBit::DX12,
|
||||
"dx11" => wgpu::BackendBit::DX11,
|
||||
"gl" => wgpu::BackendBit::GL,
|
||||
"webgpu" => wgpu::BackendBit::BROWSER_WEBGPU,
|
||||
other => panic!("Unknown backend: {}", other),
|
||||
}
|
||||
} else {
|
||||
wgpu::BackendBit::PRIMARY
|
||||
};
|
||||
let instance = wgpu::Instance::new(backend);
|
||||
let (size, surface) = unsafe {
|
||||
let size = window.inner_size();
|
||||
let surface = instance.create_surface(&window);
|
||||
|
||||
Reference in new issue
Block a user