mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-12-08 21:26:17 +00:00
Fix initialize_adapter_from_env under no_std.
Without this change, `desired_adapter_name` is an undeclared variable.
This commit is contained in:
parent
c0a8ba69b0
commit
b83c9cfd57
@ -5,20 +5,23 @@ use crate::Backends;
|
||||
|
||||
/// Initialize the adapter obeying the `WGPU_ADAPTER_NAME` environment variable.
|
||||
#[cfg(wgpu_core)]
|
||||
#[cfg_attr(not(std), expect(unused_variables, unreachable_code))]
|
||||
pub fn initialize_adapter_from_env(
|
||||
instance: &Instance,
|
||||
compatible_surface: Option<&Surface<'_>>,
|
||||
) -> Result<Adapter, wgt::RequestAdapterError> {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(std)] {
|
||||
let desired_adapter_name = std::env::var("WGPU_ADAPTER_NAME")
|
||||
.as_deref()
|
||||
.map(str::to_lowercase)
|
||||
.map_err(|_| wgt::RequestAdapterError::EnvNotSet)?;
|
||||
} else {
|
||||
return Err(wgt::RequestAdapterError::EnvNotSet);
|
||||
let desired_adapter_name: alloc::string::String = {
|
||||
cfg_if::cfg_if! {
|
||||
if #[cfg(std)] {
|
||||
std::env::var("WGPU_ADAPTER_NAME")
|
||||
.as_deref()
|
||||
.map(str::to_lowercase)
|
||||
.map_err(|_| wgt::RequestAdapterError::EnvNotSet)?
|
||||
} else {
|
||||
return Err(wgt::RequestAdapterError::EnvNotSet)
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
let adapters = instance.enumerate_adapters(crate::Backends::all());
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user