fix(naga msl-out): Fix identifier collision for multiple fragment returns (#9684)

This commit is contained in:
Andy Leiserson authored and GitHub committed 2026-06-17 10:02:56 +02:00
1 parent 4d3492cfcb
commit 0892b3841a
6 files changed
+35 -5

No files matched your search

+1 -1
View File
@@ -3445,7 +3445,7 @@ impl<W: Write> Writer<W> {
let result_ty = context.function.result.as_ref().unwrap().ty;
match context.module.types[result_ty].inner {
crate::TypeInner::Struct { ref members, .. } => {
let tmp = "_tmp";
let tmp = self.namer.call("_tmp");
write!(self.out, "{level}const auto {tmp} = ")?;
self.put_expression(expr_handle, context, true)?;
writeln!(self.out, ";")?;
@@ -0,0 +1 @@
targets = "METAL"
@@ -0,0 +1,9 @@
struct Outputs {
@location(0) color : vec4<f32>,
}
@fragment
fn main() -> Outputs {
return Outputs(vec4f());
return Outputs(vec4f());
}
@@ -63,6 +63,6 @@ fragment main_vec2scalarOutput main_vec2scalar(
output_1.scalari = 0;
output_1.scalaru = 0u;
FragmentOutputVec2Scalar _e16 = output_1;
const auto _tmp = _e16;
return main_vec2scalarOutput { _tmp.vec2f, _tmp.vec2i, _tmp.vec2u, _tmp.scalarf, _tmp.scalari, _tmp.scalaru };
const auto _tmp_1 = _e16;
return main_vec2scalarOutput { _tmp_1.vec2f, _tmp_1.vec2i, _tmp_1.vec2u, _tmp_1.scalarf, _tmp_1.scalari, _tmp_1.scalaru };
}
+2 -2
View File
@@ -62,8 +62,8 @@ fragment fragment_Output fragment_(
const VertexOutput in = { position, varyings_1._varying };
uint mask = sample_mask & (1u << sample_index);
float color_1 = front_facing ? 1.0 : 0.0;
const auto _tmp = FragmentOutput {in._varying, mask, color_1};
return fragment_Output { _tmp.depth, _tmp.sample_mask, _tmp.color };
const auto _tmp_1 = FragmentOutput {in._varying, mask, color_1};
return fragment_Output { _tmp_1.depth, _tmp_1.sample_mask, _tmp_1.color };
}
@@ -0,0 +1,20 @@
// language: metal1.0
#include <metal_stdlib>
#include <simd/simd.h>
using metal::uint;
struct Outputs {
metal::float4 color;
};
struct main_Output {
metal::float4 color [[color(0)]];
};
fragment main_Output main_(
) {
const auto _tmp = Outputs {metal::float4 {}};
return main_Output { _tmp.color };
const auto _tmp_1 = Outputs {metal::float4 {}};
return main_Output { _tmp_1.color };
}