From f0a145d0fa8f566638f3380936b149de6bae2d33 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 17 May 2021 10:14:07 -0400 Subject: [PATCH] Add VERTEX_WRITABLE_STORAGE feature, refactor the sample border --- wgpu-core/src/device/mod.rs | 1 - wgpu-core/src/instance.rs | 25 ++++++++++++++++++++----- wgpu-types/src/lib.rs | 9 +++++++++ 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index c84702190c..c5ad4a6dc6 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -342,7 +342,6 @@ impl Device { spv::Capability::Image1D, spv::Capability::SampledCubeArray, spv::Capability::ImageCubeArray, - spv::Capability::ImageMSArray, spv::Capability::StorageImageExtendedFormats, ] .iter() diff --git a/wgpu-core/src/instance.rs b/wgpu-core/src/instance.rs index 1f79be13b3..22a4c1e803 100644 --- a/wgpu-core/src/instance.rs +++ b/wgpu-core/src/instance.rs @@ -217,9 +217,14 @@ impl Adapter { wgt::Features::STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING, adapter_features.contains(hal::Features::STORAGE_BUFFER_DESCRIPTOR_INDEXING), ); - #[cfg(not(target_os = "ios"))] - //TODO: https://github.com/gfx-rs/gfx/issues/3346 - features.set(wgt::Features::ADDRESS_MODE_CLAMP_TO_BORDER, true); + features.set( + wgt::Features::VERTEX_WRITABLE_STORAGE, + adapter_features.contains(hal::Features::VERTEX_STORES_AND_ATOMICS), + ); + features.set( + wgt::Features::ADDRESS_MODE_CLAMP_TO_BORDER, + adapter_features.contains(hal::Features::SAMPLER_BORDER_COLOR), + ); let private_features = PrivateFeatures { anisotropic_filtering: adapter_features.contains(hal::Features::SAMPLER_ANISOTROPY), @@ -452,12 +457,12 @@ impl Adapter { // Check features that are always needed let wishful_features = hal::Features::ROBUST_BUFFER_ACCESS - | hal::Features::VERTEX_STORES_AND_ATOMICS | hal::Features::FRAGMENT_STORES_AND_ATOMICS | hal::Features::NDC_Y_UP | hal::Features::INDEPENDENT_BLENDING | hal::Features::SAMPLER_ANISOTROPY - | hal::Features::IMAGE_CUBE_ARRAY; + | hal::Features::IMAGE_CUBE_ARRAY + | hal::Features::SAMPLE_RATE_SHADING; let mut enabled_features = available_features & wishful_features; if enabled_features != wishful_features { log::warn!( @@ -556,6 +561,16 @@ impl Adapter { desc.features .contains(wgt::Features::STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING), ); + enabled_features.set( + hal::Features::VERTEX_STORES_AND_ATOMICS, + desc.features + .contains(wgt::Features::VERTEX_WRITABLE_STORAGE), + ); + enabled_features.set( + hal::Features::SAMPLER_BORDER_COLOR, + desc.features + .contains(wgt::Features::ADDRESS_MODE_CLAMP_TO_BORDER), + ); let family = self .raw diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 09de393569..dd3102009a 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -526,6 +526,15 @@ bitflags::bitflags! { /// /// This is a native only feature. const STORAGE_BUFFER_ARRAY_NON_UNIFORM_INDEXING = 0x0000_0010_0000_0000; + /// Enables bindings of writable storage buffers and textures visible to vertex shaders. + /// + /// Note: some (tiled-based) platforms do not support vertex shaders with any side-effects. + /// + /// Supported Platforms: + /// - All + /// + /// This is a native-only feature. + const VERTEX_WRITABLE_STORAGE = 0x0000_0020_0000_0000; /// Features which are part of the upstream WebGPU standard. const ALL_WEBGPU = 0x0000_0000_0000_FFFF; /// Features that are only available when targeting native (not web).