From 851b18b2f2d4cf0d6602b337a1ca148847bc3c2d Mon Sep 17 00:00:00 2001 From: James Price Date: Thu, 3 Jun 2021 18:12:15 +0000 Subject: [PATCH] writer/msl: Emit field designators for structures This fixes constructors for structures that contain padding members due to explicit layout attributes. Also fix one test that was wrongly using an identity type constructor for a structure. Fixed: tint:853 Change-Id: I0a3e84fcd7c6a7f2ad92a4970ed11378e6ce2465 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/53240 Auto-Submit: James Price Reviewed-by: Ben Clayton Commit-Queue: James Price Kokoro: Kokoro --- src/writer/msl/generator_impl.cc | 14 ++++++-- .../msl/generator_impl_constructor_test.cc | 2 +- .../msl/generator_impl_function_test.cc | 29 ++++++++------- .../binary_expressions.wgsl.expected.msl | 2 +- test/samples/cube.wgsl.expected.msl | 6 ++-- test/samples/simple.wgsl.expected.msl | 2 +- ...nt_input_builtins_struct.wgsl.expected.msl | 2 +- ...t_input_locations_struct.wgsl.expected.msl | 2 +- .../fragment_input_mixed.wgsl.expected.msl | 4 +-- ...fragment_output_builtins.wgsl.expected.msl | 4 +-- ...t_output_builtins_struct.wgsl.expected.msl | 4 +-- ...ragment_output_locations.wgsl.expected.msl | 8 ++--- ..._output_locations_struct.wgsl.expected.msl | 4 +-- .../fragment_output_mixed.wgsl.expected.msl | 4 +-- ..._struct_different_stages.wgsl.expected.msl | 6 ++-- ...d_struct_helper_function.wgsl.expected.msl | 2 +- ...ed_struct_storage_buffer.wgsl.expected.msl | 26 +++++++++++++- .../vertex_input_locations.wgsl.expected.msl | 2 +- ...x_input_locations_struct.wgsl.expected.msl | 4 +-- .../vertex_output_builtins.wgsl.expected.msl | 2 +- ...x_output_builtins_struct.wgsl.expected.msl | 4 +-- ..._output_locations_struct.wgsl.expected.msl | 4 +-- .../struct/type_constructor.wgsl.expected.msl | 36 +++++++++---------- 23 files changed, 102 insertions(+), 71 deletions(-) diff --git a/src/writer/msl/generator_impl.cc b/src/writer/msl/generator_impl.cc index 2c5c51dc3f..6eec4df053 100644 --- a/src/writer/msl/generator_impl.cc +++ b/src/writer/msl/generator_impl.cc @@ -918,16 +918,24 @@ bool GeneratorImpl::EmitTypeConstructor(ast::TypeConstructorExpression* expr) { out_ << "("; } - bool first = true; + int i = 0; for (auto* e : expr->values()) { - if (!first) { + if (i > 0) { out_ << ", "; } - first = false; + + if (auto* struct_ty = type->As()) { + // Emit field designators for structures to account for padding members. + auto* member = struct_ty->Members()[i]->Declaration(); + auto name = program_->Symbols().NameFor(member->symbol()); + out_ << "." << name << "="; + } if (!EmitExpression(e)) { return false; } + + i++; } if (type->IsAnyOf()) { diff --git a/src/writer/msl/generator_impl_constructor_test.cc b/src/writer/msl/generator_impl_constructor_test.cc index 97f5543a6a..9a44da3bdf 100644 --- a/src/writer/msl/generator_impl_constructor_test.cc +++ b/src/writer/msl/generator_impl_constructor_test.cc @@ -165,7 +165,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Struct) { GeneratorImpl& gen = Build(); ASSERT_TRUE(gen.Generate()) << gen.error(); - EXPECT_THAT(gen.result(), HasSubstr("{1, 2.0f, int3(3, 4, 5)}")); + EXPECT_THAT(gen.result(), HasSubstr("{.a=1, .b=2.0f, .c=int3(3, 4, 5)}")); } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Struct_Empty) { diff --git a/src/writer/msl/generator_impl_function_test.cc b/src/writer/msl/generator_impl_function_test.cc index 3a529afce1..038caf64a3 100644 --- a/src/writer/msl/generator_impl_function_test.cc +++ b/src/writer/msl/generator_impl_function_test.cc @@ -113,7 +113,7 @@ struct tint_symbol_2 { fragment tint_symbol_2 frag_main(tint_symbol_1 tint_symbol [[stage_in]]) { float const foo = tint_symbol.foo; - tint_symbol_2 const tint_symbol_3 = {foo}; + tint_symbol_2 const tint_symbol_3 = {.value=foo}; return tint_symbol_3; } @@ -148,7 +148,7 @@ struct tint_symbol_2 { fragment tint_symbol_2 frag_main(tint_symbol_1 tint_symbol [[stage_in]]) { float4 const coord = tint_symbol.coord; - tint_symbol_2 const tint_symbol_3 = {coord.x}; + tint_symbol_2 const tint_symbol_3 = {.value=coord.x}; return tint_symbol_3; } @@ -216,13 +216,13 @@ struct tint_symbol_3 { }; vertex tint_symbol vert_main() { - Interface const tint_symbol_1 = {0.5f, 0.25f, float4()}; - tint_symbol const tint_symbol_4 = {tint_symbol_1.col1, tint_symbol_1.col2, tint_symbol_1.pos}; + Interface const tint_symbol_1 = {.col1=0.5f, .col2=0.25f, .pos=float4()}; + tint_symbol const tint_symbol_4 = {.col1=tint_symbol_1.col1, .col2=tint_symbol_1.col2, .pos=tint_symbol_1.pos}; return tint_symbol_4; } fragment void frag_main(tint_symbol_3 tint_symbol_2 [[stage_in]]) { - Interface const colors = {tint_symbol_2.col1, tint_symbol_2.col2, tint_symbol_2.pos}; + Interface const colors = {.col1=tint_symbol_2.col1, .col2=tint_symbol_2.col2, .pos=tint_symbol_2.pos}; float const r = colors.col1; float const g = colors.col2; return; @@ -257,13 +257,12 @@ TEST_F(MslGeneratorImplTest, {}); Func("vert_main1", {}, vertex_output_struct, - {Return(Construct(vertex_output_struct, Expr(Call("foo", Expr(0.5f)))))}, + {Return(Expr(Call("foo", Expr(0.5f))))}, {Stage(ast::PipelineStage::kVertex)}); - Func( - "vert_main2", {}, vertex_output_struct, - {Return(Construct(vertex_output_struct, Expr(Call("foo", Expr(0.25f)))))}, - {Stage(ast::PipelineStage::kVertex)}); + Func("vert_main2", {}, vertex_output_struct, + {Return(Expr(Call("foo", Expr(0.25f))))}, + {Stage(ast::PipelineStage::kVertex)}); GeneratorImpl& gen = SanitizeAndBuild(); @@ -282,19 +281,19 @@ struct tint_symbol_2 { }; VertexOutput foo(float x) { - VertexOutput const tint_symbol_4 = {float4(x, x, x, 1.0f)}; + VertexOutput const tint_symbol_4 = {.pos=float4(x, x, x, 1.0f)}; return tint_symbol_4; } vertex tint_symbol vert_main1() { - VertexOutput const tint_symbol_1 = {foo(0.5f)}; - tint_symbol const tint_symbol_5 = {tint_symbol_1.pos}; + VertexOutput const tint_symbol_1 = foo(0.5f); + tint_symbol const tint_symbol_5 = {.pos=tint_symbol_1.pos}; return tint_symbol_5; } vertex tint_symbol_2 vert_main2() { - VertexOutput const tint_symbol_3 = {foo(0.25f)}; - tint_symbol_2 const tint_symbol_6 = {tint_symbol_3.pos}; + VertexOutput const tint_symbol_3 = foo(0.25f); + tint_symbol_2 const tint_symbol_6 = {.pos=tint_symbol_3.pos}; return tint_symbol_6; } diff --git a/test/expressions/binary_expressions.wgsl.expected.msl b/test/expressions/binary_expressions.wgsl.expected.msl index c9fa2eb0f2..afef45645d 100644 --- a/test/expressions/binary_expressions.wgsl.expected.msl +++ b/test/expressions/binary_expressions.wgsl.expected.msl @@ -107,7 +107,7 @@ void matrix_matrix_f32() { } fragment tint_symbol_1 tint_symbol() { - tint_symbol_1 const tint_symbol_2 = {float4(0.0f, 0.0f, 0.0f, 0.0f)}; + tint_symbol_1 const tint_symbol_2 = {.value=float4(0.0f, 0.0f, 0.0f, 0.0f)}; return tint_symbol_2; } diff --git a/test/samples/cube.wgsl.expected.msl b/test/samples/cube.wgsl.expected.msl index 068534d8a2..0e581be1e5 100644 --- a/test/samples/cube.wgsl.expected.msl +++ b/test/samples/cube.wgsl.expected.msl @@ -28,17 +28,17 @@ struct tint_symbol_5 { }; vertex tint_symbol_2 vtx_main(tint_symbol_1 tint_symbol [[stage_in]], constant Uniforms& uniforms [[buffer(0)]]) { - VertexInput const input = {tint_symbol.cur_position, tint_symbol.color}; + VertexInput const input = {.cur_position=tint_symbol.cur_position, .color=tint_symbol.color}; VertexOutput output = {}; output.Position = (uniforms.modelViewProjectionMatrix * input.cur_position); output.vtxFragColor = input.color; - tint_symbol_2 const tint_symbol_6 = {output.vtxFragColor, output.Position}; + tint_symbol_2 const tint_symbol_6 = {.vtxFragColor=output.vtxFragColor, .Position=output.Position}; return tint_symbol_6; } fragment tint_symbol_5 frag_main(tint_symbol_4 tint_symbol_3 [[stage_in]]) { float4 const fragColor = tint_symbol_3.fragColor; - tint_symbol_5 const tint_symbol_7 = {fragColor}; + tint_symbol_5 const tint_symbol_7 = {.value=fragColor}; return tint_symbol_7; } diff --git a/test/samples/simple.wgsl.expected.msl b/test/samples/simple.wgsl.expected.msl index a29d216103..0429e295e8 100644 --- a/test/samples/simple.wgsl.expected.msl +++ b/test/samples/simple.wgsl.expected.msl @@ -11,7 +11,7 @@ void bar() { fragment tint_symbol_1 tint_symbol() { float2 a = float2(); bar(); - tint_symbol_1 const tint_symbol_2 = {float4(0.400000006f, 0.400000006f, 0.800000012f, 1.0f)}; + tint_symbol_1 const tint_symbol_2 = {.value=float4(0.400000006f, 0.400000006f, 0.800000012f, 1.0f)}; return tint_symbol_2; } diff --git a/test/shader_io/fragment_input_builtins_struct.wgsl.expected.msl b/test/shader_io/fragment_input_builtins_struct.wgsl.expected.msl index 5b5ed67c43..7f05ccfecb 100644 --- a/test/shader_io/fragment_input_builtins_struct.wgsl.expected.msl +++ b/test/shader_io/fragment_input_builtins_struct.wgsl.expected.msl @@ -15,7 +15,7 @@ struct tint_symbol_2 { }; fragment void tint_symbol(tint_symbol_2 tint_symbol_1 [[stage_in]]) { - FragmentInputs const inputs = {tint_symbol_1.position, tint_symbol_1.front_facing, tint_symbol_1.sample_index, tint_symbol_1.sample_mask}; + FragmentInputs const inputs = {.position=tint_symbol_1.position, .front_facing=tint_symbol_1.front_facing, .sample_index=tint_symbol_1.sample_index, .sample_mask=tint_symbol_1.sample_mask}; if (inputs.front_facing) { float4 const foo = inputs.position; uint const bar = (inputs.sample_index + inputs.sample_mask); diff --git a/test/shader_io/fragment_input_locations_struct.wgsl.expected.msl b/test/shader_io/fragment_input_locations_struct.wgsl.expected.msl index 3250f3efe7..19145f5e5b 100644 --- a/test/shader_io/fragment_input_locations_struct.wgsl.expected.msl +++ b/test/shader_io/fragment_input_locations_struct.wgsl.expected.msl @@ -15,7 +15,7 @@ struct tint_symbol_2 { }; fragment void tint_symbol(tint_symbol_2 tint_symbol_1 [[stage_in]]) { - FragmentInputs const inputs = {tint_symbol_1.loc0, tint_symbol_1.loc1, tint_symbol_1.loc2, tint_symbol_1.loc3}; + FragmentInputs const inputs = {.loc0=tint_symbol_1.loc0, .loc1=tint_symbol_1.loc1, .loc2=tint_symbol_1.loc2, .loc3=tint_symbol_1.loc3}; int const i = inputs.loc0; uint const u = inputs.loc1; float const f = inputs.loc2; diff --git a/test/shader_io/fragment_input_mixed.wgsl.expected.msl b/test/shader_io/fragment_input_mixed.wgsl.expected.msl index a1159915b5..4e7aa7fe86 100644 --- a/test/shader_io/fragment_input_mixed.wgsl.expected.msl +++ b/test/shader_io/fragment_input_mixed.wgsl.expected.msl @@ -21,11 +21,11 @@ struct tint_symbol_2 { }; fragment void tint_symbol(tint_symbol_2 tint_symbol_1 [[stage_in]]) { - FragmentInputs0 const inputs0 = {tint_symbol_1.position, tint_symbol_1.loc0}; + FragmentInputs0 const inputs0 = {.position=tint_symbol_1.position, .loc0=tint_symbol_1.loc0}; bool const front_facing = tint_symbol_1.front_facing; uint const loc1 = tint_symbol_1.loc1; uint const sample_index = tint_symbol_1.sample_index; - FragmentInputs1 const inputs1 = {tint_symbol_1.loc3, tint_symbol_1.sample_mask}; + FragmentInputs1 const inputs1 = {.loc3=tint_symbol_1.loc3, .sample_mask=tint_symbol_1.sample_mask}; float const loc2 = tint_symbol_1.loc2; if (front_facing) { float4 const foo = inputs0.position; diff --git a/test/shader_io/fragment_output_builtins.wgsl.expected.msl b/test/shader_io/fragment_output_builtins.wgsl.expected.msl index d56fd42fe2..8129f6633a 100644 --- a/test/shader_io/fragment_output_builtins.wgsl.expected.msl +++ b/test/shader_io/fragment_output_builtins.wgsl.expected.msl @@ -9,12 +9,12 @@ struct tint_symbol_1 { }; fragment tint_symbol main1() { - tint_symbol const tint_symbol_2 = {1.0f}; + tint_symbol const tint_symbol_2 = {.value=1.0f}; return tint_symbol_2; } fragment tint_symbol_1 main2() { - tint_symbol_1 const tint_symbol_3 = {1u}; + tint_symbol_1 const tint_symbol_3 = {.value=1u}; return tint_symbol_3; } diff --git a/test/shader_io/fragment_output_builtins_struct.wgsl.expected.msl b/test/shader_io/fragment_output_builtins_struct.wgsl.expected.msl index 343945fb1a..851c83b5e0 100644 --- a/test/shader_io/fragment_output_builtins_struct.wgsl.expected.msl +++ b/test/shader_io/fragment_output_builtins_struct.wgsl.expected.msl @@ -11,8 +11,8 @@ struct tint_symbol_1 { }; fragment tint_symbol_1 tint_symbol() { - FragmentOutputs const tint_symbol_2 = {1.0f, 1u}; - tint_symbol_1 const tint_symbol_3 = {tint_symbol_2.frag_depth, tint_symbol_2.sample_mask}; + FragmentOutputs const tint_symbol_2 = {.frag_depth=1.0f, .sample_mask=1u}; + tint_symbol_1 const tint_symbol_3 = {.frag_depth=tint_symbol_2.frag_depth, .sample_mask=tint_symbol_2.sample_mask}; return tint_symbol_3; } diff --git a/test/shader_io/fragment_output_locations.wgsl.expected.msl b/test/shader_io/fragment_output_locations.wgsl.expected.msl index 58191b09b7..fed3dca381 100644 --- a/test/shader_io/fragment_output_locations.wgsl.expected.msl +++ b/test/shader_io/fragment_output_locations.wgsl.expected.msl @@ -15,22 +15,22 @@ struct tint_symbol_3 { }; fragment tint_symbol main0() { - tint_symbol const tint_symbol_4 = {1}; + tint_symbol const tint_symbol_4 = {.value=1}; return tint_symbol_4; } fragment tint_symbol_1 main1() { - tint_symbol_1 const tint_symbol_5 = {1u}; + tint_symbol_1 const tint_symbol_5 = {.value=1u}; return tint_symbol_5; } fragment tint_symbol_2 main2() { - tint_symbol_2 const tint_symbol_6 = {1.0f}; + tint_symbol_2 const tint_symbol_6 = {.value=1.0f}; return tint_symbol_6; } fragment tint_symbol_3 main3() { - tint_symbol_3 const tint_symbol_7 = {float4(1.0f, 2.0f, 3.0f, 4.0f)}; + tint_symbol_3 const tint_symbol_7 = {.value=float4(1.0f, 2.0f, 3.0f, 4.0f)}; return tint_symbol_7; } diff --git a/test/shader_io/fragment_output_locations_struct.wgsl.expected.msl b/test/shader_io/fragment_output_locations_struct.wgsl.expected.msl index 4e1b359f95..e4e75cb588 100644 --- a/test/shader_io/fragment_output_locations_struct.wgsl.expected.msl +++ b/test/shader_io/fragment_output_locations_struct.wgsl.expected.msl @@ -15,8 +15,8 @@ struct tint_symbol_1 { }; fragment tint_symbol_1 tint_symbol() { - FragmentOutputs const tint_symbol_2 = {1, 1u, 1.0f, float4(1.0f, 2.0f, 3.0f, 4.0f)}; - tint_symbol_1 const tint_symbol_3 = {tint_symbol_2.loc0, tint_symbol_2.loc1, tint_symbol_2.loc2, tint_symbol_2.loc3}; + FragmentOutputs const tint_symbol_2 = {.loc0=1, .loc1=1u, .loc2=1.0f, .loc3=float4(1.0f, 2.0f, 3.0f, 4.0f)}; + tint_symbol_1 const tint_symbol_3 = {.loc0=tint_symbol_2.loc0, .loc1=tint_symbol_2.loc1, .loc2=tint_symbol_2.loc2, .loc3=tint_symbol_2.loc3}; return tint_symbol_3; } diff --git a/test/shader_io/fragment_output_mixed.wgsl.expected.msl b/test/shader_io/fragment_output_mixed.wgsl.expected.msl index a6e33593f7..665936b491 100644 --- a/test/shader_io/fragment_output_mixed.wgsl.expected.msl +++ b/test/shader_io/fragment_output_mixed.wgsl.expected.msl @@ -19,8 +19,8 @@ struct tint_symbol_1 { }; fragment tint_symbol_1 tint_symbol() { - FragmentOutputs const tint_symbol_2 = {1, 2.0f, 1u, 1.0f, 2u, float4(1.0f, 2.0f, 3.0f, 4.0f)}; - tint_symbol_1 const tint_symbol_3 = {tint_symbol_2.loc0, tint_symbol_2.loc1, tint_symbol_2.loc2, tint_symbol_2.loc3, tint_symbol_2.frag_depth, tint_symbol_2.sample_mask}; + FragmentOutputs const tint_symbol_2 = {.loc0=1, .frag_depth=2.0f, .loc1=1u, .loc2=1.0f, .sample_mask=2u, .loc3=float4(1.0f, 2.0f, 3.0f, 4.0f)}; + tint_symbol_1 const tint_symbol_3 = {.loc0=tint_symbol_2.loc0, .loc1=tint_symbol_2.loc1, .loc2=tint_symbol_2.loc2, .loc3=tint_symbol_2.loc3, .frag_depth=tint_symbol_2.frag_depth, .sample_mask=tint_symbol_2.sample_mask}; return tint_symbol_3; } diff --git a/test/shader_io/shared_struct_different_stages.wgsl.expected.msl b/test/shader_io/shared_struct_different_stages.wgsl.expected.msl index f303dc0f1b..7183f0a8f6 100644 --- a/test/shader_io/shared_struct_different_stages.wgsl.expected.msl +++ b/test/shader_io/shared_struct_different_stages.wgsl.expected.msl @@ -18,13 +18,13 @@ struct tint_symbol_3 { }; vertex tint_symbol vert_main() { - Interface const tint_symbol_1 = {0.400000006f, 0.600000024f, float4()}; - tint_symbol const tint_symbol_4 = {tint_symbol_1.col1, tint_symbol_1.col2, tint_symbol_1.pos}; + Interface const tint_symbol_1 = {.col1=0.400000006f, .col2=0.600000024f, .pos=float4()}; + tint_symbol const tint_symbol_4 = {.col1=tint_symbol_1.col1, .col2=tint_symbol_1.col2, .pos=tint_symbol_1.pos}; return tint_symbol_4; } fragment void frag_main(tint_symbol_3 tint_symbol_2 [[stage_in]]) { - Interface const colors = {tint_symbol_2.col1, tint_symbol_2.col2, tint_symbol_2.pos}; + Interface const colors = {.col1=tint_symbol_2.col1, .col2=tint_symbol_2.col2, .pos=tint_symbol_2.pos}; float const r = colors.col1; float const g = colors.col2; return; diff --git a/test/shader_io/shared_struct_helper_function.wgsl.expected.msl b/test/shader_io/shared_struct_helper_function.wgsl.expected.msl index f6c8f250df..5cec366099 100644 --- a/test/shader_io/shared_struct_helper_function.wgsl.expected.msl +++ b/test/shader_io/shared_struct_helper_function.wgsl.expected.msl @@ -7,7 +7,7 @@ struct VertexOutput { }; VertexOutput foo(float x) { - VertexOutput const tint_symbol = {float4(x, x, x, 1.0f), 42}; + VertexOutput const tint_symbol = {.pos=float4(x, x, x, 1.0f), .loc0=42}; return tint_symbol; } diff --git a/test/shader_io/shared_struct_storage_buffer.wgsl.expected.msl b/test/shader_io/shared_struct_storage_buffer.wgsl.expected.msl index 8831e0a346..63eeabf7f1 100644 --- a/test/shader_io/shared_struct_storage_buffer.wgsl.expected.msl +++ b/test/shader_io/shared_struct_storage_buffer.wgsl.expected.msl @@ -1 +1,25 @@ -SKIP: crbug.com/tint/853 type constructors broken with explicit layout structs +#include + +using namespace metal; +struct S { + /* 0x0000 */ float f; + /* 0x0004 */ uint u; + /* 0x0008 */ int8_t tint_pad_0[120]; + /* 0x0080 */ packed_float4 v; + /* 0x0090 */ int8_t tint_pad_1[112]; +}; +struct tint_symbol_1 { + float f [[user(locn0)]]; + uint u [[user(locn1)]]; + float4 v [[position]]; +}; + +fragment void frag_main(tint_symbol_1 tint_symbol [[stage_in]], device S& output [[buffer(0)]]) { + S const input = {.f=tint_symbol.f, .u=tint_symbol.u, .v=tint_symbol.v}; + float const f = input.f; + uint const u = input.u; + float4 const v = input.v; + output = input; + return; +} + diff --git a/test/shader_io/vertex_input_locations.wgsl.expected.msl b/test/shader_io/vertex_input_locations.wgsl.expected.msl index a4c8606b98..4055450a83 100644 --- a/test/shader_io/vertex_input_locations.wgsl.expected.msl +++ b/test/shader_io/vertex_input_locations.wgsl.expected.msl @@ -20,7 +20,7 @@ vertex tint_symbol_3 tint_symbol(tint_symbol_2 tint_symbol_1 [[stage_in]]) { uint const u = loc1; float const f = loc2; float4 const v = loc3; - tint_symbol_3 const tint_symbol_4 = {float4()}; + tint_symbol_3 const tint_symbol_4 = {.value=float4()}; return tint_symbol_4; } diff --git a/test/shader_io/vertex_input_locations_struct.wgsl.expected.msl b/test/shader_io/vertex_input_locations_struct.wgsl.expected.msl index 6cce9d77fb..7b033dc490 100644 --- a/test/shader_io/vertex_input_locations_struct.wgsl.expected.msl +++ b/test/shader_io/vertex_input_locations_struct.wgsl.expected.msl @@ -18,12 +18,12 @@ struct tint_symbol_3 { }; vertex tint_symbol_3 tint_symbol(tint_symbol_2 tint_symbol_1 [[stage_in]]) { - VertexInputs const inputs = {tint_symbol_1.loc0, tint_symbol_1.loc1, tint_symbol_1.loc2, tint_symbol_1.loc3}; + VertexInputs const inputs = {.loc0=tint_symbol_1.loc0, .loc1=tint_symbol_1.loc1, .loc2=tint_symbol_1.loc2, .loc3=tint_symbol_1.loc3}; int const i = inputs.loc0; uint const u = inputs.loc1; float const f = inputs.loc2; float4 const v = inputs.loc3; - tint_symbol_3 const tint_symbol_4 = {float4()}; + tint_symbol_3 const tint_symbol_4 = {.value=float4()}; return tint_symbol_4; } diff --git a/test/shader_io/vertex_output_builtins.wgsl.expected.msl b/test/shader_io/vertex_output_builtins.wgsl.expected.msl index 6cb014c3c0..1bc7c1c0cd 100644 --- a/test/shader_io/vertex_output_builtins.wgsl.expected.msl +++ b/test/shader_io/vertex_output_builtins.wgsl.expected.msl @@ -6,7 +6,7 @@ struct tint_symbol_1 { }; vertex tint_symbol_1 tint_symbol() { - tint_symbol_1 const tint_symbol_2 = {float4(1.0f, 2.0f, 3.0f, 4.0f)}; + tint_symbol_1 const tint_symbol_2 = {.value=float4(1.0f, 2.0f, 3.0f, 4.0f)}; return tint_symbol_2; } diff --git a/test/shader_io/vertex_output_builtins_struct.wgsl.expected.msl b/test/shader_io/vertex_output_builtins_struct.wgsl.expected.msl index 86fbbe5c10..24ea7ac443 100644 --- a/test/shader_io/vertex_output_builtins_struct.wgsl.expected.msl +++ b/test/shader_io/vertex_output_builtins_struct.wgsl.expected.msl @@ -9,8 +9,8 @@ struct tint_symbol_1 { }; vertex tint_symbol_1 tint_symbol() { - VertexOutputs const tint_symbol_2 = {float4(1.0f, 2.0f, 3.0f, 4.0f)}; - tint_symbol_1 const tint_symbol_3 = {tint_symbol_2.position}; + VertexOutputs const tint_symbol_2 = {.position=float4(1.0f, 2.0f, 3.0f, 4.0f)}; + tint_symbol_1 const tint_symbol_3 = {.position=tint_symbol_2.position}; return tint_symbol_3; } diff --git a/test/shader_io/vertex_output_locations_struct.wgsl.expected.msl b/test/shader_io/vertex_output_locations_struct.wgsl.expected.msl index 3bd0de3267..b56fad9379 100644 --- a/test/shader_io/vertex_output_locations_struct.wgsl.expected.msl +++ b/test/shader_io/vertex_output_locations_struct.wgsl.expected.msl @@ -17,8 +17,8 @@ struct tint_symbol_1 { }; vertex tint_symbol_1 tint_symbol() { - VertexOutputs const tint_symbol_2 = {1, 1u, 1.0f, float4(1.0f, 2.0f, 3.0f, 4.0f), float4()}; - tint_symbol_1 const tint_symbol_3 = {tint_symbol_2.loc0, tint_symbol_2.loc1, tint_symbol_2.loc2, tint_symbol_2.loc3, tint_symbol_2.position}; + VertexOutputs const tint_symbol_2 = {.loc0=1, .loc1=1u, .loc2=1.0f, .loc3=float4(1.0f, 2.0f, 3.0f, 4.0f), .position=float4()}; + tint_symbol_1 const tint_symbol_3 = {.loc0=tint_symbol_2.loc0, .loc1=tint_symbol_2.loc1, .loc2=tint_symbol_2.loc2, .loc3=tint_symbol_2.loc3, .position=tint_symbol_2.position}; return tint_symbol_3; } diff --git a/test/struct/type_constructor.wgsl.expected.msl b/test/struct/type_constructor.wgsl.expected.msl index b80fe9568b..1c43642fa0 100644 --- a/test/struct/type_constructor.wgsl.expected.msl +++ b/test/struct/type_constructor.wgsl.expected.msl @@ -29,38 +29,38 @@ struct tint_array_wrapper_1 { kernel void tint_symbol() { int const x = 42; S1 const empty = {}; - S1 const nonempty = {1, 2, 3, 4}; - S1 const nonempty_with_expr = {1, x, (x + 1), nonempty.d}; + S1 const nonempty = {.a=1, .b=2, .c=3, .d=4}; + S1 const nonempty_with_expr = {.a=1, .b=x, .c=(x + 1), .d=nonempty.d}; S3 const nested_empty = {}; - S1 const tint_symbol_1 = {2, 3, 4, 5}; - S1 const tint_symbol_2 = {7, 8, 9, 10}; - S2 const tint_symbol_3 = {6, tint_symbol_2}; - S3 const nested_nonempty = {1, tint_symbol_1, tint_symbol_3}; - S1 const tint_symbol_4 = {2, x, (x + 1), nested_nonempty.i.f.d}; - S2 const tint_symbol_5 = {6, nonempty}; - S3 const nested_nonempty_with_expr = {1, tint_symbol_4, tint_symbol_5}; + S1 const tint_symbol_1 = {.a=2, .b=3, .c=4, .d=5}; + S1 const tint_symbol_2 = {.a=7, .b=8, .c=9, .d=10}; + S2 const tint_symbol_3 = {.e=6, .f=tint_symbol_2}; + S3 const nested_nonempty = {.g=1, .h=tint_symbol_1, .i=tint_symbol_3}; + S1 const tint_symbol_4 = {.a=2, .b=x, .c=(x + 1), .d=nested_nonempty.i.f.d}; + S2 const tint_symbol_5 = {.e=6, .f=nonempty}; + S3 const nested_nonempty_with_expr = {.g=1, .h=tint_symbol_4, .i=tint_symbol_5}; S1 const tint_symbol_6 = {}; int const subexpr_empty = tint_symbol_6.a; - S1 const tint_symbol_7 = {1, 2, 3, 4}; + S1 const tint_symbol_7 = {.a=1, .b=2, .c=3, .d=4}; int const subexpr_nonempty = tint_symbol_7.b; - S1 const tint_symbol_8 = {1, x, (x + 1), nonempty.d}; + S1 const tint_symbol_8 = {.a=1, .b=x, .c=(x + 1), .d=nonempty.d}; int const subexpr_nonempty_with_expr = tint_symbol_8.c; S2 const tint_symbol_9 = {}; S1 const subexpr_nested_empty = tint_symbol_9.f; - S1 const tint_symbol_10 = {2, 3, 4, 5}; - S2 const tint_symbol_11 = {1, tint_symbol_10}; + S1 const tint_symbol_10 = {.a=2, .b=3, .c=4, .d=5}; + S2 const tint_symbol_11 = {.e=1, .f=tint_symbol_10}; S1 const subexpr_nested_nonempty = tint_symbol_11.f; - S1 const tint_symbol_12 = {2, x, (x + 1), nested_nonempty.i.f.d}; - S2 const tint_symbol_13 = {1, tint_symbol_12}; + S1 const tint_symbol_12 = {.a=2, .b=x, .c=(x + 1), .d=nested_nonempty.i.f.d}; + S2 const tint_symbol_13 = {.e=1, .f=tint_symbol_12}; S1 const subexpr_nested_nonempty_with_expr = tint_symbol_13.f; tint_array_wrapper_1 const aosoa_empty = {}; tint_array_wrapper_0 const tint_symbol_14 = {1, 2}; - T const tint_symbol_15 = {tint_symbol_14}; + T const tint_symbol_15 = {.a=tint_symbol_14}; tint_array_wrapper_0 const tint_symbol_16 = {3, 4}; - T const tint_symbol_17 = {tint_symbol_16}; + T const tint_symbol_17 = {.a=tint_symbol_16}; tint_array_wrapper_1 const aosoa_nonempty = {tint_symbol_15, tint_symbol_17}; tint_array_wrapper_0 const tint_symbol_18 = {1, (aosoa_nonempty.array[0].a.array[0] + 1)}; - T const tint_symbol_19 = {tint_symbol_18}; + T const tint_symbol_19 = {.a=tint_symbol_18}; tint_array_wrapper_1 const aosoa_nonempty_with_expr = {tint_symbol_19, aosoa_nonempty.array[1]}; return; }