diff --git a/src/resolver/decoration_validation_test.cc b/src/resolver/decoration_validation_test.cc index bc0898922d..ba261a8ee0 100644 --- a/src/resolver/decoration_validation_test.cc +++ b/src/resolver/decoration_validation_test.cc @@ -359,7 +359,7 @@ using StructDecorationTest = TestWithParams; TEST_P(StructDecorationTest, IsValid) { auto& params = GetParam(); - Structure("mystruct", {}, + Structure("mystruct", {Member("a", ty.f32())}, createDecorations(Source{{12, 34}}, *this, params.kind)); WrapInFunction(); diff --git a/src/resolver/entry_point_validation_test.cc b/src/resolver/entry_point_validation_test.cc index 275bdf89ff..6e89cb8b54 100644 --- a/src/resolver/entry_point_validation_test.cc +++ b/src/resolver/entry_point_validation_test.cc @@ -102,12 +102,13 @@ TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Multiple) { TEST_F(ResolverEntryPointValidationTest, ReturnTypeAttribute_Struct) { // struct Output { + // a : f32; // }; // [[stage(vertex)]] // fn main() -> [[location(0)]] Output { // return Output(); // } - auto* output = Structure("Output", {}); + auto* output = Structure("Output", {Member("a", ty.f32())}); Func(Source{{12, 34}}, "main", {}, ty.Of(output), {Return(Construct(ty.Of(output)))}, {Stage(ast::PipelineStage::kVertex)}, {Location(Source{{13, 43}}, 0)}); @@ -328,10 +329,11 @@ TEST_F(ResolverEntryPointValidationTest, ParameterAttribute_Multiple) { TEST_F(ResolverEntryPointValidationTest, ParameterAttribute_Struct) { // struct Input { + // a : f32; // }; // [[stage(fragment)]] // fn main([[location(0)]] param : Input) {} - auto* input = Structure("Input", {}); + auto* input = Structure("Input", {Member("a", ty.f32())}); auto* param = Param("param", ty.Of(input), {Location(Source{{13, 43}}, 0)}); Func(Source{{12, 34}}, "main", {param}, ty.void_(), {}, {Stage(ast::PipelineStage::kFragment)}); diff --git a/src/resolver/resolver.cc b/src/resolver/resolver.cc index e0a66fce76..8bd7aa076f 100644 --- a/src/resolver/resolver.cc +++ b/src/resolver/resolver.cc @@ -3360,6 +3360,12 @@ bool Resolver::ValidateArrayStrideDecoration(const ast::StrideDecoration* deco, } bool Resolver::ValidateStructure(const sem::Struct* str) { + if (str->Members().empty()) { + AddError("structures must have at least one member", + str->Declaration()->source()); + return false; + } + for (auto* member : str->Members()) { if (auto* r = member->Type()->As()) { if (r->IsRuntimeSized()) { diff --git a/src/transform/binding_remapper_test.cc b/src/transform/binding_remapper_test.cc index 6e77538e40..0f68c60f8d 100644 --- a/src/transform/binding_remapper_test.cc +++ b/src/transform/binding_remapper_test.cc @@ -28,6 +28,7 @@ TEST_F(BindingRemapperTest, NoRemappings) { auto* src = R"( [[block]] struct S { + a : f32; }; [[group(2), binding(1)]] var a : S; @@ -53,6 +54,7 @@ TEST_F(BindingRemapperTest, RemapBindingPoints) { auto* src = R"( [[block]] struct S { + a : f32; }; [[group(2), binding(1)]] var a : S; @@ -67,6 +69,7 @@ fn f() { auto* expect = R"( [[block]] struct S { + a : f32; }; [[group(1), binding(2)]] var a : S; @@ -95,6 +98,7 @@ TEST_F(BindingRemapperTest, RemapAccessControls) { auto* src = R"( [[block]] struct S { + a : f32; }; [[group(2), binding(1)]] var a : S; @@ -111,6 +115,7 @@ fn f() { auto* expect = R"( [[block]] struct S { + a : f32; }; [[group(2), binding(1)]] var a : S; @@ -143,6 +148,7 @@ TEST_F(BindingRemapperTest, DISABLED_RemapAccessControlsWithAliases) { auto* src = R"( [[block]] struct S { + a : f32; }; type, read ReadOnlyS = S; @@ -165,6 +171,7 @@ fn f() { auto* expect = R"( [[block]] struct S { + a : f32; }; type, read ReadOnlyS = S; @@ -201,6 +208,7 @@ TEST_F(BindingRemapperTest, RemapAll) { auto* src = R"( [[block]] struct S { + a : f32; }; [[group(2), binding(1)]] var a : S; @@ -215,6 +223,7 @@ fn f() { auto* expect = R"( [[block]] struct S { + a : f32; }; [[group(4), binding(5)]] var a : S; @@ -363,6 +372,7 @@ TEST_F(BindingRemapperTest, NoData) { auto* src = R"( [[block]] struct S { + a : f32; }; [[group(2), binding(1)]] var a : S; diff --git a/src/transform/msl_test.cc b/src/transform/msl_test.cc index 54b2c79c5a..6defe996fb 100644 --- a/src/transform/msl_test.cc +++ b/src/transform/msl_test.cc @@ -191,6 +191,7 @@ TEST_F(MslTest, HandleModuleScopeVariables_OtherVariables) { auto* src = R"( [[block]] struct S { + a : f32; }; [[group(0), binding(0)]] @@ -204,6 +205,7 @@ fn main() { auto* expect = R"( [[block]] struct S { + a : f32; }; [[group(0), binding(0)]] var u : S; diff --git a/src/writer/msl/generator_impl_constructor_test.cc b/src/writer/msl/generator_impl_constructor_test.cc index c26375cea3..4781c42c42 100644 --- a/src/writer/msl/generator_impl_constructor_test.cc +++ b/src/writer/msl/generator_impl_constructor_test.cc @@ -169,7 +169,11 @@ TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Struct) { } TEST_F(MslGeneratorImplTest, EmitConstructor_Type_Struct_Empty) { - auto* str = Structure("S", {}); + auto* str = Structure("S", { + Member("a", ty.i32()), + Member("b", ty.f32()), + Member("c", ty.vec3()), + }); WrapInFunction(Construct(ty.Of(str))); diff --git a/src/writer/spirv/builder_type_test.cc b/src/writer/spirv/builder_type_test.cc index 45a8d34c7a..e178020322 100644 --- a/src/writer/spirv/builder_type_test.cc +++ b/src/writer/spirv/builder_type_test.cc @@ -266,22 +266,6 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) { EXPECT_EQ(b.GenerateTypeIfNeeded(ptr), 1u); } -TEST_F(BuilderTest_Type, GenerateStruct_Empty) { - auto* s = Structure("S", {}); - - spirv::Builder& b = Build(); - - auto id = b.GenerateTypeIfNeeded(program->TypeOf(s)); - ASSERT_FALSE(b.has_error()) << b.error(); - EXPECT_EQ(id, 1u); - - EXPECT_EQ(b.types().size(), 1u); - EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %1 "S" -)"); - EXPECT_EQ(DumpInstructions(b.types()), R"(%1 = OpTypeStruct -)"); -} - TEST_F(BuilderTest_Type, GenerateStruct) { auto* s = Structure("my_struct", {Member("a", ty.f32())}); diff --git a/test/types/function_scope_declarations.wgsl b/test/types/function_scope_declarations.wgsl index e0ac53a1fe..9f1325032a 100644 --- a/test/types/function_scope_declarations.wgsl +++ b/test/types/function_scope_declarations.wgsl @@ -1,4 +1,5 @@ struct S { + a : f32; }; [[stage(compute), workgroup_size(1)]] diff --git a/test/types/function_scope_declarations.wgsl.expected.hlsl b/test/types/function_scope_declarations.wgsl.expected.hlsl index 10be44af70..de9f19a537 100644 --- a/test/types/function_scope_declarations.wgsl.expected.hlsl +++ b/test/types/function_scope_declarations.wgsl.expected.hlsl @@ -1,4 +1,5 @@ struct S { + float a; }; struct tint_array_wrapper { float arr[4]; @@ -24,7 +25,7 @@ void main() { const float3x4 m3x4_let = float3x4(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); tint_array_wrapper arr_var = {{0.0f, 0.0f, 0.0f, 0.0f}}; const tint_array_wrapper arr_let = {{0.0f, 0.0f, 0.0f, 0.0f}}; - S struct_var = {}; - const S struct_let = {}; + S struct_var = {0.0f}; + const S struct_let = {0.0f}; return; } diff --git a/test/types/function_scope_declarations.wgsl.expected.msl b/test/types/function_scope_declarations.wgsl.expected.msl index 0c50b0227d..687cea4d6e 100644 --- a/test/types/function_scope_declarations.wgsl.expected.msl +++ b/test/types/function_scope_declarations.wgsl.expected.msl @@ -2,6 +2,7 @@ using namespace metal; struct S { + float a; }; struct tint_array_wrapper { float arr[4]; diff --git a/test/types/function_scope_declarations.wgsl.expected.spvasm b/test/types/function_scope_declarations.wgsl.expected.spvasm index d9556cb78e..5caa6833a6 100644 --- a/test/types/function_scope_declarations.wgsl.expected.spvasm +++ b/test/types/function_scope_declarations.wgsl.expected.spvasm @@ -18,8 +18,10 @@ OpName %m2x3_var "m2x3_var" OpName %arr_var "arr_var" OpName %S "S" + OpMemberName %S 0 "a" OpName %struct_var "struct_var" OpDecorate %_arr_float_uint_4 ArrayStride 4 + OpMemberDecorate %S 0 Offset 0 %void = OpTypeVoid %1 = OpTypeFunction %void %bool = OpTypeBool @@ -53,7 +55,7 @@ %_arr_float_uint_4 = OpTypeArray %float %uint_4 %42 = OpConstantNull %_arr_float_uint_4 %_ptr_Function__arr_float_uint_4 = OpTypePointer Function %_arr_float_uint_4 - %S = OpTypeStruct + %S = OpTypeStruct %float %46 = OpConstantNull %S %_ptr_Function_S = OpTypePointer Function %S %main = OpFunction %void None %1 diff --git a/test/types/function_scope_declarations.wgsl.expected.wgsl b/test/types/function_scope_declarations.wgsl.expected.wgsl index 2338ee47ba..4f1194c115 100644 --- a/test/types/function_scope_declarations.wgsl.expected.wgsl +++ b/test/types/function_scope_declarations.wgsl.expected.wgsl @@ -1,4 +1,5 @@ struct S { + a : f32; }; [[stage(compute), workgroup_size(1)]] diff --git a/test/types/module_scope_let.wgsl b/test/types/module_scope_let.wgsl index 846b63217e..85b317cff7 100644 --- a/test/types/module_scope_let.wgsl +++ b/test/types/module_scope_let.wgsl @@ -1,4 +1,5 @@ struct S { + a : f32; }; let bool_let : bool = bool(); diff --git a/test/types/module_scope_let.wgsl.expected.hlsl b/test/types/module_scope_let.wgsl.expected.hlsl index f43a4216cc..0655f1c523 100644 --- a/test/types/module_scope_let.wgsl.expected.hlsl +++ b/test/types/module_scope_let.wgsl.expected.hlsl @@ -1,4 +1,5 @@ struct S { + float a; }; static const bool bool_let = false; @@ -15,7 +16,7 @@ struct tint_array_wrapper { }; static const tint_array_wrapper arr_let = {{0.0f, 0.0f, 0.0f, 0.0f}}; -static const S struct_let = {}; +static const S struct_let = {0.0f}; [numthreads(1, 1, 1)] void main() { diff --git a/test/types/module_scope_let.wgsl.expected.msl b/test/types/module_scope_let.wgsl.expected.msl index 129f5f2bbe..109ae085e5 100644 --- a/test/types/module_scope_let.wgsl.expected.msl +++ b/test/types/module_scope_let.wgsl.expected.msl @@ -2,6 +2,7 @@ using namespace metal; struct S { + float a; }; struct tint_array_wrapper { float arr[4]; diff --git a/test/types/module_scope_let.wgsl.expected.spvasm b/test/types/module_scope_let.wgsl.expected.spvasm index 947c62fb92..9482c0c454 100644 --- a/test/types/module_scope_let.wgsl.expected.spvasm +++ b/test/types/module_scope_let.wgsl.expected.spvasm @@ -17,9 +17,11 @@ OpName %m3x4_let "m3x4_let" OpName %arr_let "arr_let" OpName %S "S" + OpMemberName %S 0 "a" OpName %struct_let "struct_let" OpName %main "main" OpDecorate %_arr_float_uint_4 ArrayStride 4 + OpMemberDecorate %S 0 Offset 0 %bool = OpTypeBool %bool_let = OpConstantNull %bool %int = OpTypeInt 32 1 @@ -39,7 +41,7 @@ %uint_4 = OpConstant %uint 4 %_arr_float_uint_4 = OpTypeArray %float %uint_4 %arr_let = OpConstantNull %_arr_float_uint_4 - %S = OpTypeStruct + %S = OpTypeStruct %float %struct_let = OpConstantNull %S %void = OpTypeVoid %22 = OpTypeFunction %void diff --git a/test/types/module_scope_let.wgsl.expected.wgsl b/test/types/module_scope_let.wgsl.expected.wgsl index 58cea25abd..7243c5cf46 100644 --- a/test/types/module_scope_let.wgsl.expected.wgsl +++ b/test/types/module_scope_let.wgsl.expected.wgsl @@ -1,4 +1,5 @@ struct S { + a : f32; }; let bool_let : bool = bool(); diff --git a/test/types/module_scope_var.wgsl b/test/types/module_scope_var.wgsl index 1e644fd772..e9ab444e16 100644 --- a/test/types/module_scope_var.wgsl +++ b/test/types/module_scope_var.wgsl @@ -1,4 +1,5 @@ struct S { + a : f32; }; var bool_var : bool; diff --git a/test/types/module_scope_var.wgsl.expected.hlsl b/test/types/module_scope_var.wgsl.expected.hlsl index 176ade448a..ce4bdba70c 100644 --- a/test/types/module_scope_var.wgsl.expected.hlsl +++ b/test/types/module_scope_var.wgsl.expected.hlsl @@ -1,4 +1,5 @@ struct S { + float a; }; static bool bool_var = false; @@ -15,7 +16,7 @@ struct tint_array_wrapper { }; static tint_array_wrapper arr_var = {{0.0f, 0.0f, 0.0f, 0.0f}}; -static S struct_var = {}; +static S struct_var = {0.0f}; [numthreads(1, 1, 1)] void main() { @@ -29,7 +30,7 @@ void main() { m2x3_var = float2x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); const tint_array_wrapper tint_symbol = {{0.0f, 0.0f, 0.0f, 0.0f}}; arr_var = tint_symbol; - const S tint_symbol_1 = {}; + const S tint_symbol_1 = {0.0f}; struct_var = tint_symbol_1; return; } diff --git a/test/types/module_scope_var.wgsl.expected.msl b/test/types/module_scope_var.wgsl.expected.msl index 346740d73e..6f48ccd866 100644 --- a/test/types/module_scope_var.wgsl.expected.msl +++ b/test/types/module_scope_var.wgsl.expected.msl @@ -2,6 +2,7 @@ using namespace metal; struct S { + float a; }; struct tint_array_wrapper { float arr[4]; diff --git a/test/types/module_scope_var.wgsl.expected.spvasm b/test/types/module_scope_var.wgsl.expected.spvasm index 2fa75f159d..f6524f053a 100644 --- a/test/types/module_scope_var.wgsl.expected.spvasm +++ b/test/types/module_scope_var.wgsl.expected.spvasm @@ -17,9 +17,11 @@ OpName %m2x3_var "m2x3_var" OpName %arr_var "arr_var" OpName %S "S" + OpMemberName %S 0 "a" OpName %struct_var "struct_var" OpName %main "main" OpDecorate %_arr_float_uint_4 ArrayStride 4 + OpMemberDecorate %S 0 Offset 0 %bool = OpTypeBool %_ptr_Private_bool = OpTypePointer Private %bool %4 = OpConstantNull %bool @@ -58,7 +60,7 @@ %_ptr_Private__arr_float_uint_4 = OpTypePointer Private %_arr_float_uint_4 %38 = OpConstantNull %_arr_float_uint_4 %arr_var = OpVariable %_ptr_Private__arr_float_uint_4 Private %38 - %S = OpTypeStruct + %S = OpTypeStruct %float %_ptr_Private_S = OpTypePointer Private %S %42 = OpConstantNull %S %struct_var = OpVariable %_ptr_Private_S Private %42 diff --git a/test/types/module_scope_var.wgsl.expected.wgsl b/test/types/module_scope_var.wgsl.expected.wgsl index ce37323b7f..0b4bd735bb 100644 --- a/test/types/module_scope_var.wgsl.expected.wgsl +++ b/test/types/module_scope_var.wgsl.expected.wgsl @@ -1,4 +1,5 @@ struct S { + a : f32; }; var bool_var : bool; diff --git a/test/types/module_scope_var_initializers.wgsl b/test/types/module_scope_var_initializers.wgsl index f103449b8b..b7402d0c51 100644 --- a/test/types/module_scope_var_initializers.wgsl +++ b/test/types/module_scope_var_initializers.wgsl @@ -1,4 +1,5 @@ struct S { + a : f32; }; var bool_var : bool = bool(); diff --git a/test/types/module_scope_var_initializers.wgsl.expected.hlsl b/test/types/module_scope_var_initializers.wgsl.expected.hlsl index 176ade448a..ce4bdba70c 100644 --- a/test/types/module_scope_var_initializers.wgsl.expected.hlsl +++ b/test/types/module_scope_var_initializers.wgsl.expected.hlsl @@ -1,4 +1,5 @@ struct S { + float a; }; static bool bool_var = false; @@ -15,7 +16,7 @@ struct tint_array_wrapper { }; static tint_array_wrapper arr_var = {{0.0f, 0.0f, 0.0f, 0.0f}}; -static S struct_var = {}; +static S struct_var = {0.0f}; [numthreads(1, 1, 1)] void main() { @@ -29,7 +30,7 @@ void main() { m2x3_var = float2x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f); const tint_array_wrapper tint_symbol = {{0.0f, 0.0f, 0.0f, 0.0f}}; arr_var = tint_symbol; - const S tint_symbol_1 = {}; + const S tint_symbol_1 = {0.0f}; struct_var = tint_symbol_1; return; } diff --git a/test/types/module_scope_var_initializers.wgsl.expected.msl b/test/types/module_scope_var_initializers.wgsl.expected.msl index 1bc9598427..3f96def136 100644 --- a/test/types/module_scope_var_initializers.wgsl.expected.msl +++ b/test/types/module_scope_var_initializers.wgsl.expected.msl @@ -2,6 +2,7 @@ using namespace metal; struct S { + float a; }; struct tint_array_wrapper { float arr[4]; diff --git a/test/types/module_scope_var_initializers.wgsl.expected.spvasm b/test/types/module_scope_var_initializers.wgsl.expected.spvasm index 0fb2909224..acb72eefaa 100644 --- a/test/types/module_scope_var_initializers.wgsl.expected.spvasm +++ b/test/types/module_scope_var_initializers.wgsl.expected.spvasm @@ -17,9 +17,11 @@ OpName %m2x3_var "m2x3_var" OpName %arr_var "arr_var" OpName %S "S" + OpMemberName %S 0 "a" OpName %struct_var "struct_var" OpName %main "main" OpDecorate %_arr_float_uint_4 ArrayStride 4 + OpMemberDecorate %S 0 Offset 0 %bool = OpTypeBool %2 = OpConstantNull %bool %_ptr_Private_bool = OpTypePointer Private %bool @@ -58,7 +60,7 @@ %36 = OpConstantNull %_arr_float_uint_4 %_ptr_Private__arr_float_uint_4 = OpTypePointer Private %_arr_float_uint_4 %arr_var = OpVariable %_ptr_Private__arr_float_uint_4 Private %36 - %S = OpTypeStruct + %S = OpTypeStruct %float %40 = OpConstantNull %S %_ptr_Private_S = OpTypePointer Private %S %struct_var = OpVariable %_ptr_Private_S Private %40 diff --git a/test/types/module_scope_var_initializers.wgsl.expected.wgsl b/test/types/module_scope_var_initializers.wgsl.expected.wgsl index 81aa7b529c..fa0ef756f1 100644 --- a/test/types/module_scope_var_initializers.wgsl.expected.wgsl +++ b/test/types/module_scope_var_initializers.wgsl.expected.wgsl @@ -1,4 +1,5 @@ struct S { + a : f32; }; var bool_var : bool = bool(); diff --git a/test/types/parameters.wgsl b/test/types/parameters.wgsl index b47d52a5c6..21987c937c 100644 --- a/test/types/parameters.wgsl +++ b/test/types/parameters.wgsl @@ -1,4 +1,5 @@ struct S { + a : f32; }; fn foo( diff --git a/test/types/parameters.wgsl.expected.hlsl b/test/types/parameters.wgsl.expected.hlsl index a6f80fc149..2950517900 100644 --- a/test/types/parameters.wgsl.expected.hlsl +++ b/test/types/parameters.wgsl.expected.hlsl @@ -1,4 +1,5 @@ struct S { + float a; }; struct tint_array_wrapper { float arr[4]; diff --git a/test/types/parameters.wgsl.expected.msl b/test/types/parameters.wgsl.expected.msl index 58b17a3ad6..18d5a35eda 100644 --- a/test/types/parameters.wgsl.expected.msl +++ b/test/types/parameters.wgsl.expected.msl @@ -2,6 +2,7 @@ using namespace metal; struct S { + float a; }; struct tint_array_wrapper { float arr[4]; diff --git a/test/types/parameters.wgsl.expected.spvasm b/test/types/parameters.wgsl.expected.spvasm index 5edf8f0e8a..f59e234d1d 100644 --- a/test/types/parameters.wgsl.expected.spvasm +++ b/test/types/parameters.wgsl.expected.spvasm @@ -8,6 +8,7 @@ OpEntryPoint GLCompute %main "main" OpExecutionMode %main LocalSize 1 1 1 OpName %S "S" + OpMemberName %S 0 "a" OpName %foo "foo" OpName %param_bool "param_bool" OpName %param_i32 "param_i32" @@ -24,6 +25,7 @@ OpName %param_ptr_arr "param_ptr_arr" OpName %main "main" OpDecorate %_arr_float_uint_4 ArrayStride 4 + OpMemberDecorate %S 0 Offset 0 %void = OpTypeVoid %bool = OpTypeBool %int = OpTypeInt 32 1 @@ -36,7 +38,7 @@ %mat2v3float = OpTypeMatrix %v3float 2 %uint_4 = OpConstant %uint 4 %_arr_float_uint_4 = OpTypeArray %float %uint_4 - %S = OpTypeStruct + %S = OpTypeStruct %float %_ptr_Function_float = OpTypePointer Function %float %_ptr_Function_v4float = OpTypePointer Function %v4float %_ptr_Function__arr_float_uint_4 = OpTypePointer Function %_arr_float_uint_4 diff --git a/test/types/parameters.wgsl.expected.wgsl b/test/types/parameters.wgsl.expected.wgsl index b9cf8389bf..87bb564341 100644 --- a/test/types/parameters.wgsl.expected.wgsl +++ b/test/types/parameters.wgsl.expected.wgsl @@ -1,4 +1,5 @@ struct S { + a : f32; }; fn foo(param_bool : bool, param_i32 : i32, param_u32 : u32, param_f32 : f32, param_v2i32 : vec2, param_v3u32 : vec3, param_v4f32 : vec4, param_m2x3 : mat2x3, param_arr : array, param_struct : S, param_ptr_f32 : ptr, param_ptr_vec : ptr>, param_ptr_arr : ptr>) { diff --git a/test/types/return_types.wgsl b/test/types/return_types.wgsl index 9e8ab8912d..c65b996721 100644 --- a/test/types/return_types.wgsl +++ b/test/types/return_types.wgsl @@ -1,4 +1,5 @@ struct S { + a : f32; }; fn ret_bool() -> bool { return bool(); } diff --git a/test/types/return_types.wgsl.expected.hlsl b/test/types/return_types.wgsl.expected.hlsl index f8d31a2faa..bea78fb2f9 100644 --- a/test/types/return_types.wgsl.expected.hlsl +++ b/test/types/return_types.wgsl.expected.hlsl @@ -1,4 +1,5 @@ struct S { + float a; }; bool ret_bool() { @@ -43,7 +44,7 @@ tint_array_wrapper ret_arr() { } S ret_struct() { - const S tint_symbol_1 = {}; + const S tint_symbol_1 = {0.0f}; return tint_symbol_1; } diff --git a/test/types/return_types.wgsl.expected.msl b/test/types/return_types.wgsl.expected.msl index 9bb9a8fa0e..4d43323bf2 100644 --- a/test/types/return_types.wgsl.expected.msl +++ b/test/types/return_types.wgsl.expected.msl @@ -2,6 +2,7 @@ using namespace metal; struct S { + float a; }; struct tint_array_wrapper { float arr[4]; diff --git a/test/types/return_types.wgsl.expected.spvasm b/test/types/return_types.wgsl.expected.spvasm index a13e80b304..765973ded8 100644 --- a/test/types/return_types.wgsl.expected.spvasm +++ b/test/types/return_types.wgsl.expected.spvasm @@ -17,9 +17,11 @@ OpName %ret_m2x3 "ret_m2x3" OpName %ret_arr "ret_arr" OpName %S "S" + OpMemberName %S 0 "a" OpName %ret_struct "ret_struct" OpName %main "main" OpDecorate %_arr_float_uint_4 ArrayStride 4 + OpMemberDecorate %S 0 Offset 0 %bool = OpTypeBool %1 = OpTypeFunction %bool %5 = OpConstantNull %bool @@ -49,7 +51,7 @@ %_arr_float_uint_4 = OpTypeArray %float %uint_4 %42 = OpTypeFunction %_arr_float_uint_4 %47 = OpConstantNull %_arr_float_uint_4 - %S = OpTypeStruct + %S = OpTypeStruct %float %48 = OpTypeFunction %S %52 = OpConstantNull %S %void = OpTypeVoid diff --git a/test/types/return_types.wgsl.expected.wgsl b/test/types/return_types.wgsl.expected.wgsl index 1b255ff17f..517b684fd4 100644 --- a/test/types/return_types.wgsl.expected.wgsl +++ b/test/types/return_types.wgsl.expected.wgsl @@ -1,4 +1,5 @@ struct S { + a : f32; }; fn ret_bool() -> bool { diff --git a/test/types/struct_members.wgsl b/test/types/struct_members.wgsl index fa24282090..2bd0f3396c 100644 --- a/test/types/struct_members.wgsl +++ b/test/types/struct_members.wgsl @@ -1,4 +1,5 @@ struct S_inner { + a : f32; }; struct S { diff --git a/test/types/struct_members.wgsl.expected.hlsl b/test/types/struct_members.wgsl.expected.hlsl index 071c66720e..926bb7dc28 100644 --- a/test/types/struct_members.wgsl.expected.hlsl +++ b/test/types/struct_members.wgsl.expected.hlsl @@ -1,4 +1,5 @@ struct S_inner { + float a; }; struct tint_array_wrapper { float arr[4]; @@ -18,6 +19,6 @@ struct S { [numthreads(1, 1, 1)] void main() { - const S s = {false, 0, 0u, 0.0f, int2(0, 0), uint3(0u, 0u, 0u), float4(0.0f, 0.0f, 0.0f, 0.0f), float2x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), {{0.0f, 0.0f, 0.0f, 0.0f}}, {}}; + const S s = {false, 0, 0u, 0.0f, int2(0, 0), uint3(0u, 0u, 0u), float4(0.0f, 0.0f, 0.0f, 0.0f), float2x3(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f), {{0.0f, 0.0f, 0.0f, 0.0f}}, {0.0f}}; return; } diff --git a/test/types/struct_members.wgsl.expected.msl b/test/types/struct_members.wgsl.expected.msl index 9485542742..59af17da7b 100644 --- a/test/types/struct_members.wgsl.expected.msl +++ b/test/types/struct_members.wgsl.expected.msl @@ -2,6 +2,7 @@ using namespace metal; struct S_inner { + float a; }; struct tint_array_wrapper { float arr[4]; diff --git a/test/types/struct_members.wgsl.expected.spvasm b/test/types/struct_members.wgsl.expected.spvasm index b8fcce5e5a..570a185bcf 100644 --- a/test/types/struct_members.wgsl.expected.spvasm +++ b/test/types/struct_members.wgsl.expected.spvasm @@ -20,6 +20,7 @@ OpMemberName %S 8 "member_arr" OpMemberName %S 9 "member_struct" OpName %S_inner "S_inner" + OpMemberName %S_inner 0 "a" OpMemberDecorate %S 0 Offset 0 OpMemberDecorate %S 1 Offset 4 OpMemberDecorate %S 2 Offset 8 @@ -33,6 +34,7 @@ OpMemberDecorate %S 8 Offset 96 OpDecorate %_arr_float_uint_4 ArrayStride 4 OpMemberDecorate %S 9 Offset 112 + OpMemberDecorate %S_inner 0 Offset 0 %void = OpTypeVoid %1 = OpTypeFunction %void %bool = OpTypeBool @@ -46,7 +48,7 @@ %mat2v3float = OpTypeMatrix %v3float 2 %uint_4 = OpConstant %uint 4 %_arr_float_uint_4 = OpTypeArray %float %uint_4 - %S_inner = OpTypeStruct + %S_inner = OpTypeStruct %float %S = OpTypeStruct %bool %int %uint %float %v2int %v3uint %v4float %mat2v3float %_arr_float_uint_4 %S_inner %18 = OpConstantNull %S %main = OpFunction %void None %1 diff --git a/test/types/struct_members.wgsl.expected.wgsl b/test/types/struct_members.wgsl.expected.wgsl index fa24282090..2bd0f3396c 100644 --- a/test/types/struct_members.wgsl.expected.wgsl +++ b/test/types/struct_members.wgsl.expected.wgsl @@ -1,4 +1,5 @@ struct S_inner { + a : f32; }; struct S {