|
|
|
use std::env;
|
|
|
|
use wgpu::Backends;
|
|
|
|
|
|
pub fn get_backend() -> Option<Backends> {
|
|
|
|
if let Ok(backend_str) = env::var("WGPU_BACKEND") {
|
|
|
|
match backend_str.to_lowercase().as_str() {
|
|
"vulkan" => {
|
|
return Some(Backends::VULKAN);
|
|
}
|
|
"dx12" => {
|
|
return Some(Backends::DX12);
|
|
}
|
|
"metal" => {
|
|
return Some(Backends::METAL);
|
|
}
|
|
_ => eprintln!("Unsupported backend: {}", backend_str),
|
|
}
|
|
}
|
|
|
|
|
|
if cfg!(target_os = "linux") {
|
|
Some(Backends::VULKAN)
|
|
} else if cfg!(target_os = "windows") {
|
|
Some(Backends::DX12)
|
|
} else if cfg!(target_os = "macos") {
|
|
Some(Backends::METAL)
|
|
} else {
|
|
panic!("Unsupported Operating System!");
|
|
}
|
|
}
|
|
|