mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-22 14:55:05 +00:00
Remove backend_bits from initialize_adapter_from_env (#3904)
Remove backend_bits from initialize_adapter_from_env, backends can be specified using the backends field in InstanceDescriptor instead.
This commit is contained in:
parent
17143c149c
commit
1c43272d2a
@ -45,6 +45,7 @@ Bottom level categories:
|
||||
#### Misc Breaking Changes
|
||||
|
||||
- Change `AdapterInfo::{device,vendor}` to be `u32` instead of `usize`. By @ameknite in [#3760](https://github.com/gfx-rs/wgpu/pull/3760)
|
||||
- Remove the `backend_bits` parameter in `initialize_adapter_from_env` and `initialize_adapter_from_env_or_default` - use [InstanceDescriptor::backends](https://docs.rs/wgpu/latest/wgpu/struct.InstanceDescriptor.html#structfield.backends) instead. By @fornwall in [#3904](https://github.com/gfx-rs/wgpu/pull/3904)
|
||||
|
||||
#### DX12
|
||||
|
||||
|
@ -180,10 +180,9 @@ async fn setup<E: Example>(title: &str) -> Setup {
|
||||
|
||||
(size, surface)
|
||||
};
|
||||
let adapter =
|
||||
wgpu::util::initialize_adapter_from_env_or_default(&instance, backends, Some(&surface))
|
||||
.await
|
||||
.expect("No suitable GPU adapters found on the system!");
|
||||
let adapter = wgpu::util::initialize_adapter_from_env_or_default(&instance, Some(&surface))
|
||||
.await
|
||||
.expect("No suitable GPU adapters found on the system!");
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
{
|
||||
|
@ -392,7 +392,6 @@ fn initialize_adapter() -> (Adapter, SurfaceGuard) {
|
||||
let compatible_surface: Option<&Surface> = compatible_surface.as_ref();
|
||||
let adapter = pollster::block_on(wgpu::util::initialize_adapter_from_env_or_default(
|
||||
&instance,
|
||||
backends,
|
||||
compatible_surface,
|
||||
))
|
||||
.expect("could not find suitable adapter on the system");
|
||||
|
@ -37,13 +37,13 @@ pub fn power_preference_from_env() -> Option<PowerPreference> {
|
||||
|
||||
/// Initialize the adapter obeying the WGPU_ADAPTER_NAME environment variable.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
pub fn initialize_adapter_from_env(instance: &Instance, backend_bits: Backends) -> Option<Adapter> {
|
||||
pub fn initialize_adapter_from_env(instance: &Instance) -> Option<Adapter> {
|
||||
let desired_adapter_name = std::env::var("WGPU_ADAPTER_NAME")
|
||||
.as_deref()
|
||||
.map(str::to_lowercase)
|
||||
.ok()?;
|
||||
|
||||
let adapters = instance.enumerate_adapters(backend_bits);
|
||||
let adapters = instance.enumerate_adapters(Backends::all());
|
||||
|
||||
let mut chosen_adapter = None;
|
||||
for adapter in adapters {
|
||||
@ -60,20 +60,16 @@ pub fn initialize_adapter_from_env(instance: &Instance, backend_bits: Backends)
|
||||
|
||||
/// Initialize the adapter obeying the WGPU_ADAPTER_NAME environment variable.
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
pub fn initialize_adapter_from_env(
|
||||
_instance: &Instance,
|
||||
_backend_bits: Backends,
|
||||
) -> Option<Adapter> {
|
||||
pub fn initialize_adapter_from_env(_instance: &Instance) -> Option<Adapter> {
|
||||
None
|
||||
}
|
||||
|
||||
/// Initialize the adapter obeying the WGPU_ADAPTER_NAME environment variable and if it doesn't exist fall back on a default adapter.
|
||||
pub async fn initialize_adapter_from_env_or_default(
|
||||
instance: &Instance,
|
||||
backend_bits: wgt::Backends,
|
||||
compatible_surface: Option<&Surface>,
|
||||
) -> Option<Adapter> {
|
||||
match initialize_adapter_from_env(instance, backend_bits) {
|
||||
match initialize_adapter_from_env(instance) {
|
||||
Some(a) => Some(a),
|
||||
None => {
|
||||
instance
|
||||
|
Loading…
Reference in New Issue
Block a user