diff --git a/benches/criterion.rs b/benches/criterion.rs index ad00cb59e..624744555 100644 --- a/benches/criterion.rs +++ b/benches/criterion.rs @@ -149,7 +149,7 @@ fn backends(c: &mut Criterion) { let inputs = { let mut validator = naga::valid::Validator::new( naga::valid::ValidationFlags::empty(), - naga::valid::Capabilities::empty(), + naga::valid::Capabilities::default(), ); let input_modules = gather_modules(); input_modules diff --git a/fuzz/fuzz_targets/ir.rs b/fuzz/fuzz_targets/ir.rs index 86b7a6aa6..ae1d90747 100644 --- a/fuzz/fuzz_targets/ir.rs +++ b/fuzz/fuzz_targets/ir.rs @@ -5,6 +5,6 @@ fuzz_target!(|module: naga::Module| { use naga::valid as v; // Check if the module validates without errors. //TODO: may also fuzz the flags and capabilities - let mut validator = v::Validator::new(v::ValidationFlags::all(), v::Capabilities::empty()); + let mut validator = v::Validator::new(v::ValidationFlags::all(), v::Capabilities::default()); let _result = validator.validate(&module); }); diff --git a/src/valid/interface.rs b/src/valid/interface.rs index 41f266612..7ba60515c 100644 --- a/src/valid/interface.rs +++ b/src/valid/interface.rs @@ -141,6 +141,7 @@ impl VaryingContext<'_> { Bi::CullDistance => Capabilities::CULL_DISTANCE, Bi::PrimitiveIndex => Capabilities::PRIMITIVE_INDEX, Bi::ViewIndex => Capabilities::MULTIVIEW, + Bi::SampleIndex => Capabilities::MULTISAMPLED_SHADING, _ => Capabilities::empty(), }; if !self.capabilities.contains(required) { @@ -312,6 +313,14 @@ impl VaryingContext<'_> { // qualifiers, so we won't complain about that here. let _ = sampling; + let required = match sampling { + Some(crate::Sampling::Sample) => Capabilities::MULTISAMPLED_SHADING, + _ => Capabilities::empty(), + }; + if !self.capabilities.contains(required) { + return Err(VaryingError::UnsupportedCapability(required)); + } + match ty_inner.scalar_kind() { Some(crate::ScalarKind::Float) => { if needs_interpolation && interpolation.is_none() { diff --git a/src/valid/mod.rs b/src/valid/mod.rs index ab4d81cb1..9d9c3f885 100644 --- a/src/valid/mod.rs +++ b/src/valid/mod.rs @@ -84,7 +84,6 @@ impl Default for ValidationFlags { bitflags::bitflags! { /// Allowed IR capabilities. #[must_use] - #[derive(Default)] #[cfg_attr(feature = "serialize", derive(serde::Serialize))] #[cfg_attr(feature = "deserialize", derive(serde::Deserialize))] pub struct Capabilities: u16 { @@ -110,6 +109,14 @@ bitflags::bitflags! { const MULTIVIEW = 0x200; /// Support for `early_depth_test`. const EARLY_DEPTH_TEST = 0x400; + /// Support for [`Builtin::SampleIndex`] and [`Sampling::Sample`]. + const MULTISAMPLED_SHADING = 0x800; + } +} + +impl Default for Capabilities { + fn default() -> Self { + Self::MULTISAMPLED_SHADING } } diff --git a/tests/snapshots.rs b/tests/snapshots.rs index cc2b30055..7fea12200 100644 --- a/tests/snapshots.rs +++ b/tests/snapshots.rs @@ -98,7 +98,7 @@ fn check_targets(module: &naga::Module, name: &str, targets: Targets) { let capabilities = if params.god_mode { naga::valid::Capabilities::all() } else { - naga::valid::Capabilities::empty() + naga::valid::Capabilities::default() }; let dest = PathBuf::from(root).join(BASE_DIR_OUT); @@ -589,7 +589,7 @@ fn convert_spv(name: &str, adjust_coordinate_space: bool, targets: Targets) { check_targets(&module, name, targets); naga::valid::Validator::new( naga::valid::ValidationFlags::all(), - naga::valid::Capabilities::empty(), + naga::valid::Capabilities::default(), ) .validate(&module) .unwrap(); diff --git a/tests/wgsl-errors.rs b/tests/wgsl-errors.rs index f7c86b403..d76252ced 100644 --- a/tests/wgsl-errors.rs +++ b/tests/wgsl-errors.rs @@ -903,7 +903,7 @@ fn validation_error(source: &str) -> Result