From 321bd64ba2e1674937116333d76d27dd05b429c9 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Thu, 12 Sep 2024 12:04:19 +0200 Subject: [PATCH] add `Adapter::backend()` --- wgpu-core/src/device/resource.rs | 4 ++-- wgpu-core/src/instance.rs | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs index 883703fa1..f84b2c573 100644 --- a/wgpu-core/src/device/resource.rs +++ b/wgpu-core/src/device/resource.rs @@ -285,7 +285,7 @@ impl Device { Ok(mut trace) => { trace.add(trace::Action::Init { desc: desc.clone(), - backend: adapter.raw.backend(), + backend: adapter.backend(), }); Some(trace) } @@ -311,7 +311,7 @@ impl Device { /// Returns the backend this device is using. pub fn backend(&self) -> wgt::Backend { - self.adapter.raw.backend() + self.adapter.backend() } pub fn is_valid(&self) -> bool { diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 02a23740c..517eabfeb 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -273,6 +273,11 @@ impl Adapter { Self { raw } } + /// Returns the backend this adapter is using. + pub fn backend(&self) -> Backend { + self.raw.backend() + } + pub fn is_surface_supported(&self, surface: &Surface) -> bool { // If get_capabilities returns Err, then the API does not advertise support for the surface. // @@ -389,7 +394,7 @@ impl Adapter { } let caps = &self.raw.capabilities; - if Backends::PRIMARY.contains(Backends::from(self.raw.backend())) + if Backends::PRIMARY.contains(Backends::from(self.backend())) && !caps.downlevel.is_webgpu_compliant() { let missing_flags = wgt::DownlevelFlags::compliant() - caps.downlevel.flags;