From cc91b38301dd040a9dd786e947c0f11a5a374abc Mon Sep 17 00:00:00 2001 From: Geert Bleyen <71486361+geertbleyen@users.noreply.github.com> Date: Fri, 10 Sep 2021 15:45:25 +0200 Subject: [PATCH] Do MTL feature check for Depth Clamping (#1933) * Do MTL feature check for Depth Clamping (cherry picked from commit ae6e83c3b2e695918ffcd8bbf7ce3a1b32e2b36e) # Conflicts: # wgpu-hal/src/metal/adapter.rs * make feature support check conform * clean code * avoid same featureset checks multiple times * cargo fmt'ed --- wgpu-hal/src/metal/adapter.rs | 6 +++++- wgpu-hal/src/metal/mod.rs | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/wgpu-hal/src/metal/adapter.rs b/wgpu-hal/src/metal/adapter.rs index 2a66889205..62a9a6b147 100644 --- a/wgpu-hal/src/metal/adapter.rs +++ b/wgpu-hal/src/metal/adapter.rs @@ -850,6 +850,9 @@ impl super::PrivateCapabilities { } else { Self::version_at_least(major, minor, 11, 0) }, + //Depth clipping is supported on all macOS GPU families and iOS family 4 and later + supports_depth_clamping: device.supports_feature_set(MTLFeatureSet::iOS_GPUFamily4_v1) + || os_is_mac, } } @@ -857,7 +860,6 @@ impl super::PrivateCapabilities { use wgt::Features as F; let mut features = F::empty() - | F::DEPTH_CLAMPING | F::TEXTURE_COMPRESSION_BC | F::MAPPABLE_PRIMARY_BUFFERS | F::VERTEX_WRITABLE_STORAGE @@ -865,6 +867,8 @@ impl super::PrivateCapabilities { | F::POLYGON_MODE_LINE | F::CLEAR_COMMANDS; + features.set(F::DEPTH_CLAMPING, self.supports_depth_clamping); + features.set( F::TEXTURE_BINDING_ARRAY | F::SAMPLED_TEXTURE_AND_STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING diff --git a/wgpu-hal/src/metal/mod.rs b/wgpu-hal/src/metal/mod.rs index e51806a3d0..ed8deb9bb5 100644 --- a/wgpu-hal/src/metal/mod.rs +++ b/wgpu-hal/src/metal/mod.rs @@ -222,6 +222,7 @@ struct PrivateCapabilities { supports_arrays_of_textures: bool, supports_arrays_of_textures_write: bool, supports_mutability: bool, + supports_depth_clamping: bool, } #[derive(Clone, Debug)]