Let validation check for more unsupported builtins.

Add `valid::Capabilities` flags for the `ClipDistance` and
`CullDistance` builtins, which are not supported by all back ends.

Have the CLI perform valation with only those capabilities that the
requested back ends support.

Fixes #1961.
This commit is contained in:
Jim Blandy
2022-05-31 17:29:40 -07:00
parent 7f5ec31825
commit 1c21fc02fe
3 changed files with 40 additions and 22 deletions

View File

@@ -317,12 +317,23 @@ fn run() -> Result<(), Box<dyn std::error::Error>> {
_ => return Err(CliError("Unknown input file extension").into()),
};
// Decide which capabilities our output formats can support.
let validation_caps =
output_paths
.iter()
.fold(naga::valid::Capabilities::all(), |caps, path| {
use naga::valid::Capabilities as C;
let missing = match Path::new(path).extension().and_then(|ex| ex.to_str()) {
Some("wgsl") => C::CLIP_DISTANCE | C::CULL_DISTANCE,
Some("metal") => C::CULL_DISTANCE,
_ => C::empty(),
};
caps & !missing
});
// validate the IR
let info = match naga::valid::Validator::new(
params.validation_flags,
naga::valid::Capabilities::all(),
)
.validate(&module)
let info = match naga::valid::Validator::new(params.validation_flags, validation_caps)
.validate(&module)
{
Ok(info) => Some(info),
Err(error) => {