From 517cde939b42f12b61af9476c470bf3d479f8cfe Mon Sep 17 00:00:00 2001 From: Jim Blandy Date: Tue, 19 Dec 2023 13:51:40 -0800 Subject: [PATCH] [naga xtask] Add `validate all` subcommand. --- CHANGELOG.md | 2 ++ naga/xtask/src/cli.rs | 9 ++++++++- naga/xtask/src/validate.rs | 21 +++++++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fa98cd6f1e..995d3f039d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -83,6 +83,8 @@ Wgpu now exposes backend feature for the Direct3D 12 (`dx12`) and Metal (`metal` - Add `--bulk-validate` option to Naga CLI. By @jimblandy in [#4871](https://github.com/gfx-rs/wgpu/pull/4871). +- Naga's `cargo xtask validate` now runs validation jobs in parallel, using the [jobserver](https://crates.io/crates/jobserver) protocol to limit concurrency, and offers a `validate all` subcommand, which runs all available validation types. By @jimblandy in [#4902](https://github.com/gfx-rs/wgpu/pull/4902). + ### Changes - Arcanization of wgpu core resources: By @gents83 in [#3626](https://github.com/gfx-rs/wgpu/pull/3626) and thanks also to @jimblandy, @nical, @Wumpf, @Elabajaba & @cwfitzgerald diff --git a/naga/xtask/src/cli.rs b/naga/xtask/src/cli.rs index 3b5b1ed69f..cd510124c6 100644 --- a/naga/xtask/src/cli.rs +++ b/naga/xtask/src/cli.rs @@ -77,6 +77,8 @@ impl Subcommand { } } +// If you add a new validation subcommand, be sure to update the code +// that processes `All`. #[derive(Debug)] pub(crate) enum ValidateSubcommand { Spirv, @@ -85,6 +87,7 @@ pub(crate) enum ValidateSubcommand { Dot, Wgsl, Hlsl(ValidateHlslCommand), + All, } impl ValidateSubcommand { @@ -114,7 +117,11 @@ impl ValidateSubcommand { ensure_remaining_args_empty(args)?; Ok(Self::Wgsl) } - "hlsl" => return Ok(Self::Hlsl(ValidateHlslCommand::parse(args)?)), + "hlsl" => Ok(Self::Hlsl(ValidateHlslCommand::parse(args)?)), + "all" => { + ensure_remaining_args_empty(args)?; + Ok(Self::All) + } other => { bail!("unrecognized `validate` subcommand {other:?}; see `--help` for more details") } diff --git a/naga/xtask/src/validate.rs b/naga/xtask/src/validate.rs index cb27786c5b..287d05b759 100644 --- a/naga/xtask/src/validate.rs +++ b/naga/xtask/src/validate.rs @@ -142,6 +142,27 @@ fn collect_validation_jobs(jobs: &mut Vec, cmd: ValidateSubcommand) -> anyh }) }); } + ValidateSubcommand::All => { + collect_validation_jobs(jobs, ValidateSubcommand::Wgsl)?; + collect_validation_jobs(jobs, ValidateSubcommand::Spirv)?; + collect_validation_jobs(jobs, ValidateSubcommand::Glsl)?; + collect_validation_jobs(jobs, ValidateSubcommand::Dot)?; + + #[cfg(any(target_os = "macos", target_os = "ios"))] + collect_validation_jobs(jobs, ValidateSubcommand::Metal)?; + + // The FXC compiler is only available on Windows. + // + // The DXC compiler can be built and run on any platform, + // but they don't make Linux releases and it's not clear + // what Git commit actually works on Linux, so restrict + // that to Windows as well. + #[cfg(windows)] + { + collect_validation_jobs(jobs, ValidateSubcommand::Hlsl(ValidateHlslCommand::Dxc))?; + collect_validation_jobs(jobs, ValidateSubcommand::Hlsl(ValidateHlslCommand::Fxc))?; + } + } }; Ok(())