mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-22 07:21:04 +01:00
[msl-out] use separator closure for all fn arguments
This commit is contained in:
1 parent
627bf91c61
commit
98caa62267
1 file changed
+19
-38
+19
-38
@@ -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)?;
|
||||
|
||||
Reference in new issue
Block a user