From 6931f45666d7da5de127b4dc3bbca43bc6f09b1e Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 17 Feb 2023 01:39:32 +0100 Subject: [PATCH 1/5] remove redundant flag --- wgpu-hal/src/dx11/adapter.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/wgpu-hal/src/dx11/adapter.rs b/wgpu-hal/src/dx11/adapter.rs index 13b3e92cf5..658b2320b5 100644 --- a/wgpu-hal/src/dx11/adapter.rs +++ b/wgpu-hal/src/dx11/adapter.rs @@ -124,7 +124,6 @@ impl super::Adapter { } if feature_level >= FL10_0 { - downlevel |= wgt::DownlevelFlags::INDEPENDENT_BLEND; downlevel |= wgt::DownlevelFlags::FRAGMENT_STORAGE; downlevel |= wgt::DownlevelFlags::FRAGMENT_WRITABLE_STORAGE; downlevel |= wgt::DownlevelFlags::DEPTH_BIAS_CLAMP; From 8d9c73460c9395aa782b705ef1eeeccc417d7321 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 17 Feb 2023 01:40:35 +0100 Subject: [PATCH 2/5] set the `MULTISAMPLED_SHADING` downlevel flag for gles and dx11 --- wgpu-hal/src/dx11/adapter.rs | 1 + wgpu-hal/src/gles/adapter.rs | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/wgpu-hal/src/dx11/adapter.rs b/wgpu-hal/src/dx11/adapter.rs index 658b2320b5..fed94a8aff 100644 --- a/wgpu-hal/src/dx11/adapter.rs +++ b/wgpu-hal/src/dx11/adapter.rs @@ -135,6 +135,7 @@ impl super::Adapter { if feature_level >= FL10_1 { downlevel |= wgt::DownlevelFlags::CUBE_ARRAY_TEXTURES; + downlevel |= wgt::DownlevelFlags::MULTISAMPLED_SHADING; } if feature_level >= FL11_0 { diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index a1a4ee6ba8..1a767ef6cd 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -325,6 +325,10 @@ impl super::Adapter { wgt::DownlevelFlags::FULL_DRAW_INDEX_UINT32, max_element_index == u32::MAX, ); + downlevel_flags.set( + wgt::DownlevelFlags::MULTISAMPLED_SHADING, + ver >= (3, 2) || extensions.contains("OES_sample_variables"), + ); let mut features = wgt::Features::empty() | wgt::Features::TEXTURE_ADAPTER_SPECIFIC_FORMAT_FEATURES From 6de310663ed5ce4fa0ee9e7d08d31d35fb89a3b0 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 17 Feb 2023 01:52:15 +0100 Subject: [PATCH 3/5] set the right naga capabilities add `Features::SHADER_EARLY_DEPTH_TEST` --- Cargo.lock | 2 +- Cargo.toml | 2 +- wgpu-core/Cargo.toml | 2 +- wgpu-core/src/device/mod.rs | 15 +++++++++++++++ wgpu-hal/Cargo.toml | 4 ++-- wgpu-hal/src/gles/adapter.rs | 1 + wgpu-types/src/lib.rs | 7 +++++++ wgpu/examples/water/main.rs | 4 ++++ 8 files changed, 32 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 1a7b621882..6360c074fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1515,7 +1515,7 @@ dependencies = [ [[package]] name = "naga" version = "0.11.0" -source = "git+https://github.com/gfx-rs/naga?rev=568d7c4c136dada369ef7f59ee8414a263d6c7b2#568d7c4c136dada369ef7f59ee8414a263d6c7b2" +source = "git+https://github.com/gfx-rs/naga?rev=7422ace934b7ed51c1e061eb1d36de8259b5f619#7422ace934b7ed51c1e061eb1d36de8259b5f619" dependencies = [ "bit-set", "bitflags", diff --git a/Cargo.toml b/Cargo.toml index 21380f7bbc..6ae39211ed 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,7 @@ version = "0.15" [workspace.dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "568d7c4c136dada369ef7f59ee8414a263d6c7b2" +rev = "7422ace934b7ed51c1e061eb1d36de8259b5f619" version = "0.11.0" [workspace.dependencies] diff --git a/wgpu-core/Cargo.toml b/wgpu-core/Cargo.toml index 18ebdce4cf..57c11cad6e 100644 --- a/wgpu-core/Cargo.toml +++ b/wgpu-core/Cargo.toml @@ -70,7 +70,7 @@ thiserror = "1" [dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "568d7c4c136dada369ef7f59ee8414a263d6c7b2" +rev = "7422ace934b7ed51c1e061eb1d36de8259b5f619" version = "0.11.0" features = ["clone", "span", "validate"] diff --git a/wgpu-core/src/device/mod.rs b/wgpu-core/src/device/mod.rs index 4e402e55db..1fb2902c58 100644 --- a/wgpu-core/src/device/mod.rs +++ b/wgpu-core/src/device/mod.rs @@ -1388,6 +1388,21 @@ impl Device { self.features .contains(wgt::Features::TEXTURE_FORMAT_16BIT_NORM), ); + caps.set( + Caps::MULTIVIEW, + self.features.contains(wgt::Features::MULTIVIEW), + ); + caps.set( + Caps::EARLY_DEPTH_TEST, + self.features + .contains(wgt::Features::SHADER_EARLY_DEPTH_TEST), + ); + caps.set( + Caps::MULTISAMPLED_SHADING, + self.downlevel + .flags + .contains(wgt::DownlevelFlags::MULTISAMPLED_SHADING), + ); let info = naga::valid::Validator::new(naga::valid::ValidationFlags::all(), caps) .validate(&module) diff --git a/wgpu-hal/Cargo.toml b/wgpu-hal/Cargo.toml index 90cd13c614..2740f7de14 100644 --- a/wgpu-hal/Cargo.toml +++ b/wgpu-hal/Cargo.toml @@ -119,14 +119,14 @@ android_system_properties = "0.1.1" [dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "568d7c4c136dada369ef7f59ee8414a263d6c7b2" +rev = "7422ace934b7ed51c1e061eb1d36de8259b5f619" version = "0.11.0" features = ["clone"] # DEV dependencies [dev-dependencies.naga] git = "https://github.com/gfx-rs/naga" -rev = "568d7c4c136dada369ef7f59ee8414a263d6c7b2" +rev = "7422ace934b7ed51c1e061eb1d36de8259b5f619" version = "0.11.0" features = ["wgsl-in"] diff --git a/wgpu-hal/src/gles/adapter.rs b/wgpu-hal/src/gles/adapter.rs index 1a767ef6cd..04ad75d583 100644 --- a/wgpu-hal/src/gles/adapter.rs +++ b/wgpu-hal/src/gles/adapter.rs @@ -355,6 +355,7 @@ impl super::Adapter { wgt::Features::SHADER_PRIMITIVE_INDEX, ver >= (3, 2) || extensions.contains("OES_geometry_shader"), ); + features.set(wgt::Features::SHADER_EARLY_DEPTH_TEST, ver >= (3, 1)); let gles_bcn_exts = [ "GL_EXT_texture_compression_s3tc_srgb", "GL_EXT_texture_compression_rgtc", diff --git a/wgpu-types/src/lib.rs b/wgpu-types/src/lib.rs index 3f577de29c..ed4c398236 100644 --- a/wgpu-types/src/lib.rs +++ b/wgpu-types/src/lib.rs @@ -681,6 +681,13 @@ bitflags::bitflags! { /// /// This is a native-only feature. const SHADER_INT16 = 1 << 42; + /// Allows shaders to use the `early_depth_test` attribute. + /// + /// Supported platforms: + /// - GLES 3.1+ + /// + /// This is a native-only feature. + const SHADER_EARLY_DEPTH_TEST = 1 << 43; } } diff --git a/wgpu/examples/water/main.rs b/wgpu/examples/water/main.rs index b1ff261f48..5f9e0a44b7 100644 --- a/wgpu/examples/water/main.rs +++ b/wgpu/examples/water/main.rs @@ -269,6 +269,10 @@ impl Example { } impl framework::Example for Example { + fn required_features() -> wgpu::Features { + wgpu::Features::SHADER_EARLY_DEPTH_TEST + } + fn init( config: &wgpu::SurfaceConfiguration, _adapter: &wgpu::Adapter, From cc14ba995daf0e7fd9c28f0eb4148f9cb56d1723 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 17 Feb 2023 02:00:10 +0100 Subject: [PATCH 4/5] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 70d14257d1..843903cddc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -80,6 +80,7 @@ By @teoxoy in [#3436](https://github.com/gfx-rs/wgpu/pull/3436) - Added `TextureFormatFeatureFlags::MULTISAMPLE_X16`. By @Dinnerbone in [#3454](https://github.com/gfx-rs/wgpu/pull/3454) - Support stencil-only views and copying to/from combined depth-stencil textures. By @teoxoy in [#3436](https://github.com/gfx-rs/wgpu/pull/3436) +- Added `Features::SHADER_EARLY_DEPTH_TEST`. By @teoxoy in [#3494](https://github.com/gfx-rs/wgpu/pull/3494) #### WebGPU From 6f5eb07550869c22cd6114e7d7db34dc11c90e35 Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Fri, 17 Feb 2023 02:59:18 +0100 Subject: [PATCH 5/5] remove `@early_depth_test` from water example --- wgpu/examples/water/main.rs | 4 ---- wgpu/examples/water/terrain.wgsl | 1 - 2 files changed, 5 deletions(-) diff --git a/wgpu/examples/water/main.rs b/wgpu/examples/water/main.rs index 5f9e0a44b7..b1ff261f48 100644 --- a/wgpu/examples/water/main.rs +++ b/wgpu/examples/water/main.rs @@ -269,10 +269,6 @@ impl Example { } impl framework::Example for Example { - fn required_features() -> wgpu::Features { - wgpu::Features::SHADER_EARLY_DEPTH_TEST - } - fn init( config: &wgpu::SurfaceConfiguration, _adapter: &wgpu::Adapter, diff --git a/wgpu/examples/water/terrain.wgsl b/wgpu/examples/water/terrain.wgsl index f48b6aaad0..747ef99d6b 100644 --- a/wgpu/examples/water/terrain.wgsl +++ b/wgpu/examples/water/terrain.wgsl @@ -37,7 +37,6 @@ fn vs_main( } @fragment -@early_depth_test fn fs_main( vertex: VertexOutput, ) -> @location(0) vec4 {