Repository: gfx-rs/wgpu
Pull request #6534 (2024-11-12 23:29:58)

chore: revert removal of `DISABLE_UNIFORMITY_REQ_FOR_FRAGMENT_STAGE`
Unfortunately, these checks are still causing problems, according to @ErichDonGubler's exploration of apps already out on the web with Firefox. 🙁 Guess we'll have to wait until #4369.


Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 85e81fe9b..36f88095f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -113,6 +113,7 @@ By @ErichDonGubler in [#6456](https://github.com/gfx-rs/wgpu/pull/6456), [#6148]
 #### General
 
 - Make `Surface::as_hal` take an immutable reference to the surface. By @jerzywilczek in [#9999](https://github.com/gfx-rs/wgpu/pull/9999)
+- Add actual sample type to `CreateBindGroupError::InvalidTextureSampleType` error message. By @ErichDonGubler in [#6530](https://github.com/gfx-rs/wgpu/pull/6530).
 
 #### HAL
 
diff --git a/naga/src/valid/analyzer.rs b/naga/src/valid/analyzer.rs
index e169ed1d0..b50238b97 100644
--- a/naga/src/valid/analyzer.rs
+++ b/naga/src/valid/analyzer.rs
@@ -16,6 +16,8 @@ use std::ops;
 
 pub type NonUniformResult = Option<Handle<crate::Expression>>;
 
+const DISABLE_UNIFORMITY_REQ_FOR_FRAGMENT_STAGE: bool = true;
+
 bitflags::bitflags! {
     /// Kinds of expressions that require uniform control flow.
     #[cfg_attr(feature = "serialize", derive(serde::Serialize))]
@@ -23,8 +25,8 @@ bitflags::bitflags! {
     #[derive(Clone, Copy, Debug, Eq, PartialEq)]
     pub struct UniformityRequirements: u8 {
         const WORK_GROUP_BARRIER = 0x1;
-        const DERIVATIVE = 0x2;
-        const IMPLICIT_LEVEL = 0x4;
+        const DERIVATIVE = if DISABLE_UNIFORMITY_REQ_FOR_FRAGMENT_STAGE { 0 } else { 0x2 };
+        const IMPLICIT_LEVEL = if DISABLE_UNIFORMITY_REQ_FOR_FRAGMENT_STAGE { 0 } else { 0x4 };
     }
 }
 
@@ -1350,52 +1352,56 @@ fn uniform_control_flow() {
             &expressions,
             &Arena::new(),
         );
-        assert_eq!(
-            block_info,
-            Err(FunctionError::NonUniformControlFlow(
-                UniformityRequirements::DERIVATIVE,
-                derivative_expr,
-                UniformityDisruptor::Expression(non_uniform_global_expr)
-            )
-            .with_span()),
-        );
-        assert_eq!(info[derivative_expr].ref_count, 1);
-
-        // Test that the same thing passes when we disable the `derivative_uniformity`
-        let mut diagnostic_filters = Arena::new();
-        let diagnostic_filter_leaf = diagnostic_filters.append(
-            DiagnosticFilterNode {
-                inner: crate::diagnostic_filter::DiagnosticFilter {
-                    new_severity: crate::diagnostic_filter::Severity::Off,
-                    triggering_rule: FilterableTriggeringRule::DerivativeUniformity,
+        if DISABLE_UNIFORMITY_REQ_FOR_FRAGMENT_STAGE {
+            assert_eq!(info[derivative_expr].ref_count, 2);
+        } else {
+            assert_eq!(
+                block_info,
+                Err(FunctionError::NonUniformControlFlow(
+                    UniformityRequirements::DERIVATIVE,
+                    derivative_expr,
+                    UniformityDisruptor::Expression(non_uniform_global_expr)
+                )
+                .with_span()),
+            );
+            assert_eq!(info[derivative_expr].ref_count, 1);
+
+            // Test that the same thing passes when we disable the `derivative_uniformity`
+            let mut diagnostic_filters = Arena::new();
+            let diagnostic_filter_leaf = diagnostic_filters.append(
+                DiagnosticFilterNode {
+                    inner: crate::diagnostic_filter::DiagnosticFilter {
+                        new_severity: crate::diagnostic_filter::Severity::Off,
+                        triggering_rule: FilterableTriggeringRule::DerivativeUniformity,
+                    },
+                    parent: None,
                 },
-                parent: None,
-            },
-            crate::Span::default(),
-        );
-        let mut info = FunctionInfo {
-            diagnostic_filter_leaf: Some(diagnostic_filter_leaf),
-            ..info.clone()
-        };
+                crate::Span::default(),
+            );
+            let mut info = FunctionInfo {
+                diagnostic_filter_leaf: Some(diagnostic_filter_leaf),
+                ..info.clone()
+            };
 
-        let block_info = info.process_block(
-            &vec![stmt_emit2, stmt_if_non_uniform].into(),
-            &[],
-            None,
-            &expressions,
-            &diagnostic_filters,
-        );
-        assert_eq!(
-            block_info,
-            Ok(FunctionUniformity {
-                result: Uniformity {
-                    non_uniform_result: None,
-                    requirements: UniformityRequirements::DERIVATIVE,
-                },
-                exit: ExitFlags::empty()
-            }),
-        );
-        assert_eq!(info[derivative_expr].ref_count, 2);
+            let block_info = info.process_block(
+                &vec![stmt_emit2, stmt_if_non_uniform].into(),
+                &[],
+                None,
+                &expressions,
+                &diagnostic_filters,
+            );
+            assert_eq!(
+                block_info,
+                Ok(FunctionUniformity {
+                    result: Uniformity {
+                        non_uniform_result: None,
+                        requirements: UniformityRequirements::DERIVATIVE,
+                    },
+                    exit: ExitFlags::empty()
+                }),
+            );
+            assert_eq!(info[derivative_expr].ref_count, 2);
+        }
     }
     assert_eq!(info[non_uniform_global], GlobalUse::READ);
 
diff --git a/wgpu-core/src/binding_model.rs b/wgpu-core/src/binding_model.rs
index 8906b5875..30275f061 100644
--- a/wgpu-core/src/binding_model.rs
+++ b/wgpu-core/src/binding_model.rs
@@ -142,11 +142,18 @@ pub enum CreateBindGroupError {
         layout_multisampled: bool,
         view_samples: u32,
     },
-    #[error("Texture binding {binding} expects sample type = {layout_sample_type:?}, but given a view with format = {view_format:?}")]
+    #[error(
+        "Texture binding {} expects sample type {:?}, but was given a view with format {:?} (sample type {:?})",
+        binding,
+        layout_sample_type,
+        view_format,
+        view_sample_type
+    )]
     InvalidTextureSampleType {
         binding: u32,
         layout_sample_type: wgt::TextureSampleType,
         view_format: wgt::TextureFormat,
+        view_sample_type: wgt::TextureSampleType,
     },
     #[error("Texture binding {binding} expects dimension = {layout_dimension:?}, but given a view with dimension = {view_dimension:?}")]
     InvalidTextureDimension {
diff --git a/wgpu-core/src/device/resource.rs b/wgpu-core/src/device/resource.rs
index afbf73bc0..2c511baa5 100644
--- a/wgpu-core/src/device/resource.rs
+++ b/wgpu-core/src/device/resource.rs
@@ -2519,6 +2519,7 @@ impl Device {
                             binding,
                             layout_sample_type: sample_type,
                             view_format: view.desc.format,
+                            view_sample_type: compat_sample_type,
                         })
                     }
                 }


Test patch:
diff --git a/tests/tests/float32_filterable.rs b/tests/tests/float32_filterable.rs
index cc1ccd5a2..5376f924d 100644
--- a/tests/tests/float32_filterable.rs
+++ b/tests/tests/float32_filterable.rs
@@ -63,7 +63,11 @@ static FLOAT32_FILTERABLE_WITHOUT_FEATURE: GpuTestConfiguration = GpuTestConfigu
             || {
                 create_texture_binding(device, wgpu::TextureFormat::R32Float, true);
             },
-            Some("texture binding 0 expects sample type = float { filterable: true }, but given a view with format = r32float"),
+            Some(concat!(
+                "texture binding 0 expects sample type float { filterable: true }, ",
+                "but was given a view with format r32float ",
+                "(sample type float { filterable: false })"
+            )),
         );
     });