diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index 193e4e7d47..e569945497 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -1311,7 +1311,9 @@ bool GeneratorImpl::EmitFunctionInternal(ast::Function* func, auto* type = program_->Sem().Get(v)->Type(); - if (!EmitType(type, program_->Symbols().NameFor(v->symbol()))) { + std::string param_name = + "const " + program_->Symbols().NameFor(v->symbol()); + if (!EmitType(type, param_name)) { return false; } // Parameter name is output as part of the type for arrays and pointers. diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc index 5cf1eb85d8..8ec73fb222 100644 --- a/src/writer/msl/generator_impl_function_test.cc +++ b/src/writer/msl/generator_impl_function_test.cc @@ -770,7 +770,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) { EXPECT_EQ(gen.result(), R"(#include using namespace metal; - void my_func(float a[5]) { + void my_func(float const a[5]) { return; } diff --git a/test/ptr_ref/load/param/ptr.spvasm.expected.msl b/test/ptr_ref/load/param/ptr.spvasm.expected.msl index cf1067f7c1..19998585a0 100644 --- a/test/ptr_ref/load/param/ptr.spvasm.expected.msl +++ b/test/ptr_ref/load/param/ptr.spvasm.expected.msl @@ -1,7 +1,7 @@ #include using namespace metal; -int func(int value, thread int* pointer) { +int func(int value, thread int* const pointer) { int const x_9 = *(pointer); return (value + x_9); } diff --git a/test/ptr_ref/load/param/ptr.wgsl.expected.msl b/test/ptr_ref/load/param/ptr.wgsl.expected.msl index 20a0cc99c0..a2154743c9 100644 --- a/test/ptr_ref/load/param/ptr.wgsl.expected.msl +++ b/test/ptr_ref/load/param/ptr.wgsl.expected.msl @@ -1,7 +1,7 @@ #include using namespace metal; -int func(int value, thread int* pointer) { +int func(int value, thread int* const pointer) { return (value + *(pointer)); } diff --git a/test/ptr_ref/store/param/ptr.spvasm.expected.msl b/test/ptr_ref/store/param/ptr.spvasm.expected.msl index 0633ba656c..98cc63cb88 100644 --- a/test/ptr_ref/store/param/ptr.spvasm.expected.msl +++ b/test/ptr_ref/store/param/ptr.spvasm.expected.msl @@ -1,7 +1,7 @@ #include using namespace metal; -void func(int value, thread int* pointer) { +void func(int value, thread int* const pointer) { *(pointer) = value; return; } diff --git a/test/ptr_ref/store/param/ptr.wgsl.expected.msl b/test/ptr_ref/store/param/ptr.wgsl.expected.msl index 9a64bcb243..7460a3e745 100644 --- a/test/ptr_ref/store/param/ptr.wgsl.expected.msl +++ b/test/ptr_ref/store/param/ptr.wgsl.expected.msl @@ -1,7 +1,7 @@ #include using namespace metal; -void func(int value, thread int* pointer) { +void func(int value, thread int* const pointer) { *(pointer) = value; } diff --git a/test/types/parameters.wgsl.expected.msl b/test/types/parameters.wgsl.expected.msl index 9134d86bf8..81ca7b35a3 100644 --- a/test/types/parameters.wgsl.expected.msl +++ b/test/types/parameters.wgsl.expected.msl @@ -4,7 +4,7 @@ using namespace metal; struct S { }; -void foo(bool param_bool, int param_i32, uint param_u32, float param_f32, int2 param_v2i32, uint3 param_v3u32, float4 param_v4f32, float2x3 param_m2x3, float param_arr[4], S param_struct, thread float* param_ptr_f32, thread float4* param_ptr_vec, thread float (*param_ptr_arr)[4]) { +void foo(bool param_bool, int param_i32, uint param_u32, float param_f32, int2 param_v2i32, uint3 param_v3u32, float4 param_v4f32, float2x3 param_m2x3, float const param_arr[4], S param_struct, thread float* const param_ptr_f32, thread float4* const param_ptr_vec, thread float (*const param_ptr_arr)[4]) { } kernel void tint_symbol() {