Skip to content

Commit

Permalink
[naga xtask] Add validate all subcommand.
Browse files Browse the repository at this point in the history
  • Loading branch information
jimblandy committed Dec 26, 2023
1 parent cd6262d commit 517cde9
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 8 additions & 1 deletion naga/xtask/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -85,6 87,7 @@ pub(crate) enum ValidateSubcommand {
Dot,
Wgsl,
Hlsl(ValidateHlslCommand),
All,
}

impl ValidateSubcommand {
Expand Down Expand Up @@ -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")
}
Expand Down
21 changes: 21 additions & 0 deletions naga/xtask/src/validate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 142,27 @@ fn collect_validation_jobs(jobs: &mut Vec<Job>, 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(())
Expand Down

0 comments on commit 517cde9

Please sign in to comment.