Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[naga xtask] Run validation jobs in parallel, using jobserver. #4902

Merged
merged 11 commits into from
Dec 27, 2023
Merged
Prev Previous commit
Next Next commit
[naga xtask] Add validate all subcommand.
  • Loading branch information
jimblandy committed Dec 26, 2023
commit 517cde939b42f12b61af9476c470bf3d479f8cfe
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
Loading