Skip to content

Commit

Permalink
add Capabilities::MULTISAMPLED_SHADING
Browse files Browse the repository at this point in the history
  • Loading branch information
teoxoy authored and cwfitzgerald committed Feb 16, 2023
1 parent 964d920 commit cc3a8ac
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 6 deletions.
2 changes: 1 addition & 1 deletion benches/criterion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion fuzz/fuzz_targets/ir.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
9 changes: 9 additions & 0 deletions src/valid/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down
9 changes: 8 additions & 1 deletion src/valid/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
}
}

Expand Down
4 changes: 2 additions & 2 deletions tests/snapshots.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion tests/wgsl-errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -903,7 +903,7 @@ fn validation_error(source: &str) -> Result<naga::valid::ModuleInfo, naga::valid
};
naga::valid::Validator::new(
naga::valid::ValidationFlags::all(),
naga::valid::Capabilities::empty(),
naga::valid::Capabilities::default(),
)
.validate(&module)
.map_err(|e| e.into_inner()) // TODO: Add tests for spans, too?
Expand Down

0 comments on commit cc3a8ac

Please sign in to comment.