add Capabilities::MULTISAMPLED_SHADING

This commit is contained in:
teoxoy 2023-02-16 21:44:29 +01:00 committed by Connor Fitzgerald
parent 964d9204bc
commit cc3a8ac737
6 changed files with 22 additions and 6 deletions

View File

@ -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

View File

@ -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);
});

View File

@ -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() {

View File

@ -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
}
}

View File

@ -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();

View File

@ -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?