Skip to content

Commit

Permalink
fix(msl-out): use namer for <fun>{Input,Output} structs
Browse files Browse the repository at this point in the history
  • Loading branch information
ErichDonGubler committed Oct 22, 2024
1 parent 2302b5f commit 36fab5c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ By @bradwerth [#6216](https://github.com/gfx-rs/wgpu/pull/6216).
- Added `gl_DrawID` to glsl and `DrawIndex` to spv. By @ChosenName in [#6325](https://github.com/gfx-rs/wgpu/pull/6325).
- Matrices can now be indexed by value (#4337), and indexing arrays by value no longer causes excessive spilling (#6358). By @jimblandy in [#6390](https://github.com/gfx-rs/wgpu/pull/6390).
- Add support for `textureQueryLevels` to the GLSL parser. By @magcius in [#6325](https://github.com/gfx-rs/wgpu/pull/6415).
- Fix unescaped identifiers in the Metal backend shader I/O structures causing shader miscompilation. By @ErichDonGubler in [#6438](https://github.com/gfx-rs/wgpu/pull/6438).

#### General

Expand Down
4 changes: 2 additions & 2 deletions naga/src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5063,7 +5063,7 @@ template <typename A>
// a struct type named `<fun>Input` to hold them. If we are doing
// vertex pulling, we instead update our attribute mapping to
// note the types, names, and zero values of the attributes.
let stage_in_name = format!("{fun_name}Input");
let stage_in_name = self.namer.call(&format!("{fun_name}Input"));
let varyings_member_name = self.namer.call("varyings");
let mut has_varyings = false;
if !flattened_arguments.is_empty() {
Expand Down Expand Up @@ -5115,7 +5115,7 @@ template <typename A>

// Define a struct type named for the return value, if any, named
// `<fun>Output`.
let stage_out_name = format!("{fun_name}Output");
let stage_out_name = self.namer.call(&format!("{fun_name}Output"));
let result_member_name = self.namer.call("member");
let result_type_name = match fun.result {
Some(ref result) => {
Expand Down
6 changes: 3 additions & 3 deletions naga/tests/out/msl/6438-conflicting-idents.msl
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@ struct OurVertexShaderOutput {
struct vsInput {
metal::float2 xy [[attribute(0)]];
};
struct vsOutput {
struct vsOutput_1 {
metal::float4 position [[position]];
metal::float2 texcoord [[user(loc0), center_perspective]];
};
vertex vsOutput vs(
vertex vsOutput_1 vs(
vsInput varyings [[stage_in]]
) {
const auto xy = varyings.xy;
OurVertexShaderOutput vsOutput = {};
vsOutput.position = metal::float4(xy, 0.0, 1.0);
OurVertexShaderOutput _e6 = vsOutput;
const auto _tmp = _e6;
return vsOutput { _tmp.position, _tmp.texcoord };
return vsOutput_1 { _tmp.position, _tmp.texcoord };
}


Expand Down

0 comments on commit 36fab5c

Please sign in to comment.