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).
This commit is contained in:
Teodor Tanasoaia 2025-10-06 20:59:45 +02:00 committed by GitHub
parent ad15442b89
commit 1072b87894
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 20 additions and 38 deletions

View File

@ -157,3 +157,4 @@ webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="l
webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="loop8"
webgpu:shader,validation,statement,statement_behavior:invalid_statements:body="switch1"
//FAIL: 9 invalid_statements subtests due to https://github.com/gfx-rs/wgpu/issues/7733
webgpu:api,validation,render_pipeline,vertex_state:many_attributes_overlapping:*

View File

@ -6904,16 +6904,25 @@ template <typename A>
// Write the entry point function's name, and begin its argument list.
writeln!(self.out, "{em_str} {result_type_name} {fun_name}(")?;
let mut is_first_argument = true;
let mut separator = || {
if is_first_argument {
is_first_argument = false;
' '
} else {
','
}
};
// If we have produced a struct holding the `EntryPoint`'s
// `Function`'s arguments' varyings, pass that struct first.
if has_varyings {
writeln!(
self.out,
" {stage_in_name} {varyings_member_name} [[stage_in]]"
"{} {stage_in_name} {varyings_member_name} [[stage_in]]",
separator()
)?;
is_first_argument = false;
}
let mut local_invocation_id = None;
@ -6953,13 +6962,7 @@ template <typename A>
};
let resolved = options.resolve_local_binding(binding, in_mode)?;
let separator = if is_first_argument {
is_first_argument = false;
' '
} else {
','
};
write!(self.out, "{separator} {ty_name} {name}")?;
write!(self.out, "{} {ty_name} {name}", separator())?;
resolved.try_fmt(&mut self.out)?;
writeln!(self.out)?;
}
@ -6968,15 +6971,9 @@ template <typename A>
self.need_workgroup_variables_initialization(options, ep, module, fun_info);
if need_workgroup_variables_initialization && local_invocation_id.is_none() {
let separator = if is_first_argument {
is_first_argument = false;
' '
} else {
','
};
writeln!(
self.out,
"{separator} {NAMESPACE}::uint3 __local_invocation_id [[thread_position_in_threadgroup]]"
"{} {NAMESPACE}::uint3 __local_invocation_id [[thread_position_in_threadgroup]]", separator()
)?;
}
@ -7123,15 +7120,6 @@ template <typename A>
}
}
let mut separator = || {
if is_first_argument {
is_first_argument = false;
' '
} else {
','
}
};
match module.types[var.ty].inner {
crate::TypeInner::Image {
class: crate::ImageClass::External,
@ -7203,21 +7191,13 @@ template <typename A>
}
if do_vertex_pulling {
let mut separator = if is_first_argument {
is_first_argument = false;
' '
} else {
','
};
if needs_vertex_id && v_existing_id.is_none() {
// Write the [[vertex_id]] argument.
writeln!(self.out, "{separator} uint {v_id} [[vertex_id]]")?;
separator = ',';
writeln!(self.out, "{} uint {v_id} [[vertex_id]]", separator())?;
}
if needs_instance_id && i_existing_id.is_none() {
writeln!(self.out, "{separator} uint {i_id} [[instance_id]]")?;
writeln!(self.out, "{} uint {i_id} [[instance_id]]", separator())?;
}
// Iterate vbm_resolved, output one argument for every vertex buffer,
@ -7228,7 +7208,8 @@ template <typename A>
let param_name = &vbm.param_name;
writeln!(
self.out,
", const device {ty_name}* {param_name} [[buffer({id})]]"
"{} const device {ty_name}* {param_name} [[buffer({id})]]",
separator()
)?;
}
}
@ -7238,10 +7219,10 @@ template <typename A>
if needs_buffer_sizes {
// this is checked earlier
let resolved = options.resolve_sizes_buffer(ep).unwrap();
let separator = if is_first_argument { ' ' } else { ',' };
write!(
self.out,
"{separator} constant _mslBufferSizes& _buffer_sizes",
"{} constant _mslBufferSizes& _buffer_sizes",
separator()
)?;
resolved.try_fmt(&mut self.out)?;
writeln!(self.out)?;