Skip to content

Commit 1072b87

Browse files
authored
Fix stray comma in function signatures in Metal (#8311)
Fixes a regression introduced by #8265 where we were mistakenly writing a comma before the first buffer argument (if no other arguments were printed before it).
1 parent ad15442 commit 1072b87

File tree

2 files changed

+20
-38
lines changed

2 files changed

+20
-38
lines changed

cts_runner/test.lst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,3 +157,4 @@ webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="l
157157
webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="loop8"
158158
webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="switch1"
159159
//FAIL: 9 invalid_statements subtests due to https://github.com/gfx-rs/wgpu/issues/7733
160+
webgpu:api,validation,render_pipeline,vertex_state:many_attributes_overlapping:*

naga/src/back/msl/writer.rs

Lines changed: 19 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -6904,16 +6904,25 @@ template <typename A>
69046904

69056905
// Write the entry point function's name, and begin its argument list.
69066906
writeln!(self.out, "{em_str} {result_type_name} {fun_name}(")?;
6907+
69076908
let mut is_first_argument = true;
6909+
let mut separator = || {
6910+
if is_first_argument {
6911+
is_first_argument = false;
6912+
' '
6913+
} else {
6914+
','
6915+
}
6916+
};
69086917

69096918
// If we have produced a struct holding the `EntryPoint`'s
69106919
// `Function`'s arguments' varyings, pass that struct first.
69116920
if has_varyings {
69126921
writeln!(
69136922
self.out,
6914-
" {stage_in_name} {varyings_member_name} [[stage_in]]"
6923+
"{} {stage_in_name} {varyings_member_name} [[stage_in]]",
6924+
separator()
69156925
)?;
6916-
is_first_argument = false;
69176926
}
69186927

69196928
let mut local_invocation_id = None;
@@ -6953,13 +6962,7 @@ template <typename A>
69536962
};
69546963

69556964
let resolved = options.resolve_local_binding(binding, in_mode)?;
6956-
let separator = if is_first_argument {
6957-
is_first_argument = false;
6958-
' '
6959-
} else {
6960-
','
6961-
};
6962-
write!(self.out, "{separator} {ty_name} {name}")?;
6965+
write!(self.out, "{} {ty_name} {name}", separator())?;
69636966
resolved.try_fmt(&mut self.out)?;
69646967
writeln!(self.out)?;
69656968
}
@@ -6968,15 +6971,9 @@ template <typename A>
69686971
self.need_workgroup_variables_initialization(options, ep, module, fun_info);
69696972

69706973
if need_workgroup_variables_initialization && local_invocation_id.is_none() {
6971-
let separator = if is_first_argument {
6972-
is_first_argument = false;
6973-
' '
6974-
} else {
6975-
','
6976-
};
69776974
writeln!(
69786975
self.out,
6979-
"{separator} {NAMESPACE}::uint3 __local_invocation_id [[thread_position_in_threadgroup]]"
6976+
"{} {NAMESPACE}::uint3 __local_invocation_id [[thread_position_in_threadgroup]]", separator()
69806977
)?;
69816978
}
69826979

@@ -7123,15 +7120,6 @@ template <typename A>
71237120
}
71247121
}
71257122

7126-
let mut separator = || {
7127-
if is_first_argument {
7128-
is_first_argument = false;
7129-
' '
7130-
} else {
7131-
','
7132-
}
7133-
};
7134-
71357123
match module.types[var.ty].inner {
71367124
crate::TypeInner::Image {
71377125
class: crate::ImageClass::External,
@@ -7203,21 +7191,13 @@ template <typename A>
72037191
}
72047192

72057193
if do_vertex_pulling {
7206-
let mut separator = if is_first_argument {
7207-
is_first_argument = false;
7208-
' '
7209-
} else {
7210-
','
7211-
};
7212-
72137194
if needs_vertex_id && v_existing_id.is_none() {
72147195
// Write the [[vertex_id]] argument.
7215-
writeln!(self.out, "{separator} uint {v_id} [[vertex_id]]")?;
7216-
separator = ',';
7196+
writeln!(self.out, "{} uint {v_id} [[vertex_id]]", separator())?;
72177197
}
72187198

72197199
if needs_instance_id && i_existing_id.is_none() {
7220-
writeln!(self.out, "{separator} uint {i_id} [[instance_id]]")?;
7200+
writeln!(self.out, "{} uint {i_id} [[instance_id]]", separator())?;
72217201
}
72227202

72237203
// Iterate vbm_resolved, output one argument for every vertex buffer,
@@ -7228,7 +7208,8 @@ template <typename A>
72287208
let param_name = &vbm.param_name;
72297209
writeln!(
72307210
self.out,
7231-
", const device {ty_name}* {param_name} [[buffer({id})]]"
7211+
"{} const device {ty_name}* {param_name} [[buffer({id})]]",
7212+
separator()
72327213
)?;
72337214
}
72347215
}
@@ -7238,10 +7219,10 @@ template <typename A>
72387219
if needs_buffer_sizes {
72397220
// this is checked earlier
72407221
let resolved = options.resolve_sizes_buffer(ep).unwrap();
7241-
let separator = if is_first_argument { ' ' } else { ',' };
72427222
write!(
72437223
self.out,
7244-
"{separator} constant _mslBufferSizes& _buffer_sizes",
7224+
"{} constant _mslBufferSizes& _buffer_sizes",
7225+
separator()
72457226
)?;
72467227
resolved.try_fmt(&mut self.out)?;
72477228
writeln!(self.out)?;

0 commit comments

Comments
 (0)