diff --git a/CHANGELOG.md b/CHANGELOG.md index 3061ec4421..c5c606f479 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -126,6 +126,10 @@ By @cwfitzgerald in [#5325](https://github.com/gfx-rs/wgpu/pull/5325). - Cache the sample count to keep `get_texture_format_features` cheap. By @Dinnerbone in [#5346](https://github.com/gfx-rs/wgpu/pull/5346) - Mark `DEPTH32FLOAT_STENCIL8` as supported in GLES. By @Dinnerbone in [#5370](https://github.com/gfx-rs/wgpu/pull/5370) +#### Naga + +- Allow user to select which MSL version to use via `--metal-version` with Naga CLI. By @pcleavelin in [#5392](https://github.com/gfx-rs/wgpu/pull/5392) + ### Bug Fixes #### General diff --git a/naga-cli/src/bin/naga.rs b/naga-cli/src/bin/naga.rs index 7a3a0f260c..29e5a5044b 100644 --- a/naga-cli/src/bin/naga.rs +++ b/naga-cli/src/bin/naga.rs @@ -62,6 +62,10 @@ struct Args { #[argh(option)] shader_model: Option, + /// the metal version to use, for example, 1.0, 1.1, 1.2, etc. + #[argh(option)] + metal_version: Option, + /// if the selected frontends/backends support coordinate space conversions, /// disable them #[argh(switch)] @@ -174,6 +178,30 @@ impl FromStr for GlslProfileArg { } } +/// Newtype so we can implement [`FromStr`] for a Metal Language Version. +#[derive(Clone, Debug)] +struct MslVersionArg((u8, u8)); + +impl FromStr for MslVersionArg { + type Err = String; + + fn from_str(s: &str) -> Result { + let mut iter = s.split('.'); + + let check_value = |iter: &mut core::str::Split<_>| { + iter.next() + .ok_or_else(|| format!("Invalid value for --metal-version: {s}"))? + .parse::() + .map_err(|err| format!("Invalid value for --metal-version: '{s}': {err}")) + }; + + let major = check_value(&mut iter)?; + let minor = check_value(&mut iter)?; + + Ok(Self((major, minor))) + } +} + #[derive(Default)] struct Parameters<'a> { validation_flags: naga::valid::ValidationFlags, @@ -287,6 +315,9 @@ fn run() -> Result<(), Box> { if let Some(ref model) = args.shader_model { params.hlsl.shader_model = model.0; } + if let Some(ref version) = args.metal_version { + params.msl.lang_version = version.0; + } params.keep_coordinate_space = args.keep_coordinate_space; params.dot.cfg_only = args.dot_cfg_only;