From 69801c639307e36ad9141081c1017a88bd1add7e Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Mon, 6 Oct 2025 19:35:54 +0200 Subject: [PATCH 1/2] [msl-out] use `separator` closure for all fn arguments --- naga/src/back/msl/writer.rs | 57 +++++++++++++------------------------ 1 file changed, 19 insertions(+), 38 deletions(-) diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index cec92265416..6e51f90181e 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -6904,16 +6904,25 @@ template // 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 }; 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 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 } } - 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 } 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 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 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)?; From c2adb991cecb9c7b8d6707e18c5cfeff6d747c1a Mon Sep 17 00:00:00 2001 From: teoxoy <28601907+teoxoy@users.noreply.github.com> Date: Mon, 6 Oct 2025 20:48:41 +0200 Subject: [PATCH 2/2] add relevant test --- cts_runner/test.lst | 1 + 1 file changed, 1 insertion(+) diff --git a/cts_runner/test.lst b/cts_runner/test.lst index 624fa1274bc..40f49d06b74 100644 --- a/cts_runner/test.lst +++ b/cts_runner/test.lst @@ -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:* \ No newline at end of file