Skip to content

Commit 5d69b63

Browse files
WIP: fix(metal): print [[clip_distances]] before array length
TODO: more cases?
1 parent 58e2f1e commit 5d69b63

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

naga/src/back/msl/writer.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7190,10 +7190,19 @@ template <typename A>
71907190
};
71917191
let resolved = options.resolve_local_binding(binding, out_mode)?;
71927192
write!(self.out, "{}{} {}", back::INDENT, ty_name, name)?;
7193+
let binding_attr_comes_before_array = matches!(
7194+
resolved,
7195+
super::ResolvedBinding::BuiltIn(crate::BuiltIn::ClipDistances)
7196+
);
7197+
if binding_attr_comes_before_array {
7198+
resolved.try_fmt(&mut self.out)?;
7199+
}
71937200
if let Some(array_len) = array_len {
71947201
write!(self.out, " [{array_len}]")?;
71957202
}
7196-
resolved.try_fmt(&mut self.out)?;
7203+
if !binding_attr_comes_before_array {
7204+
resolved.try_fmt(&mut self.out)?;
7205+
}
71977206
writeln!(self.out, ";")?;
71987207
}
71997208

naga/tests/out/msl/wgsl-clip-distances.metal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ struct VertexOutput {
1515

1616
struct main_Output {
1717
metal::float4 position [[position]];
18-
float clip_distances [1] [[clip_distance]];
18+
float clip_distances [[clip_distance]] [1];
1919
};
2020
vertex main_Output main_(
2121
) {

0 commit comments

Comments
 (0)