validation: structures cannot be empty
Fixed many tests that had empty structures.
Change-Id: Id91312afa39a6293426f99d0dd12578dba46aa61
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/56621
Auto-Submit: James Price <jrprice@google.com>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/src/resolver/decoration_validation_test.cc b/src/resolver/decoration_validation_test.cc
index bc08989..ba261a8 100644
--- a/src/resolver/decoration_validation_test.cc
+++ b/src/resolver/decoration_validation_test.cc
@@ -359,7 +359,7 @@
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 275bdf8..6e89cb8 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_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_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 e0a66fc..8bd7aa0 100644
--- a/src/resolver/resolver.cc
+++ b/src/resolver/resolver.cc
@@ -3360,6 +3360,12 @@
}
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<sem::Array>()) {
if (r->IsRuntimeSized()) {
diff --git a/src/transform/binding_remapper_test.cc b/src/transform/binding_remapper_test.cc
index 6e77538..0f68c60 100644
--- a/src/transform/binding_remapper_test.cc
+++ b/src/transform/binding_remapper_test.cc
@@ -28,6 +28,7 @@
auto* src = R"(
[[block]]
struct S {
+ a : f32;
};
[[group(2), binding(1)]] var<storage, read> a : S;
@@ -53,6 +54,7 @@
auto* src = R"(
[[block]]
struct S {
+ a : f32;
};
[[group(2), binding(1)]] var<storage, read> a : S;
@@ -67,6 +69,7 @@
auto* expect = R"(
[[block]]
struct S {
+ a : f32;
};
[[group(1), binding(2)]] var<storage, read> a : S;
@@ -95,6 +98,7 @@
auto* src = R"(
[[block]]
struct S {
+ a : f32;
};
[[group(2), binding(1)]] var<storage, read> a : S;
@@ -111,6 +115,7 @@
auto* expect = R"(
[[block]]
struct S {
+ a : f32;
};
[[group(2), binding(1)]] var<storage, write> a : S;
@@ -143,6 +148,7 @@
auto* src = R"(
[[block]]
struct S {
+ a : f32;
};
type, read ReadOnlyS = S;
@@ -165,6 +171,7 @@
auto* expect = R"(
[[block]]
struct S {
+ a : f32;
};
type, read ReadOnlyS = S;
@@ -201,6 +208,7 @@
auto* src = R"(
[[block]]
struct S {
+ a : f32;
};
[[group(2), binding(1)]] var<storage, read> a : S;
@@ -215,6 +223,7 @@
auto* expect = R"(
[[block]]
struct S {
+ a : f32;
};
[[group(4), binding(5)]] var<storage, write> a : S;
@@ -363,6 +372,7 @@
auto* src = R"(
[[block]]
struct S {
+ a : f32;
};
[[group(2), binding(1)]] var<storage, read> a : S;
diff --git a/src/transform/msl_test.cc b/src/transform/msl_test.cc
index 54b2c79..6defe99 100644
--- a/src/transform/msl_test.cc
+++ b/src/transform/msl_test.cc
@@ -191,6 +191,7 @@
auto* src = R"(
[[block]]
struct S {
+ a : f32;
};
[[group(0), binding(0)]]
@@ -204,6 +205,7 @@
auto* expect = R"(
[[block]]
struct S {
+ a : f32;
};
[[group(0), binding(0)]] var<uniform> u : S;
diff --git a/src/writer/msl/generator_impl_constructor_test.cc b/src/writer/msl/generator_impl_constructor_test.cc
index c26375c..4781c42 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_Empty) {
- auto* str = Structure("S", {});
+ auto* str = Structure("S", {
+ Member("a", ty.i32()),
+ Member("b", ty.f32()),
+ Member("c", ty.vec3<i32>()),
+ });
WrapInFunction(Construct(ty.Of(str)));
diff --git a/src/writer/spirv/builder_type_test.cc b/src/writer/spirv/builder_type_test.cc
index 45a8d34..e178020 100644
--- a/src/writer/spirv/builder_type_test.cc
+++ b/src/writer/spirv/builder_type_test.cc
@@ -266,22 +266,6 @@
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 e0ac53a..9f13250 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 10be44a..de9f19a 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 @@
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 0c50b02..687cea4 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 d9556cb..5caa683 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 2338ee4..4f1194c 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 846b632..85b317c 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 f43a421..0655f1c 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 @@
};
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 129f5f2..109ae08 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 947c62f..9482c0c 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 58cea25..7243c5c 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 1e644fd..e9ab444 100644
--- a/test/types/module_scope_var.wgsl
+++ b/test/types/module_scope_var.wgsl
@@ -1,4 +1,5 @@
struct S {
+ a : f32;
};
var<private> bool_var : bool;
diff --git a/test/types/module_scope_var.wgsl.expected.hlsl b/test/types/module_scope_var.wgsl.expected.hlsl
index 176ade4..ce4bdba 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 @@
};
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 @@
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 346740d..6f48ccd 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 2fa75f1..f6524f0 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 ce37323..0b4bd73 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<private> bool_var : bool;
diff --git a/test/types/module_scope_var_initializers.wgsl b/test/types/module_scope_var_initializers.wgsl
index f103449..b7402d0 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<private> 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 176ade4..ce4bdba 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 @@
};
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 @@
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 1bc9598..3f96def 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 0fb2909..acb72ee 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 81aa7b5..fa0ef75 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<private> bool_var : bool = bool();
diff --git a/test/types/parameters.wgsl b/test/types/parameters.wgsl
index b47d52a..21987c9 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 a6f80fc..2950517 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 58b17a3..18d5a35 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 5edf8f0..f59e234 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 b9cf838..87bb564 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<i32>, param_v3u32 : vec3<u32>, param_v4f32 : vec4<f32>, param_m2x3 : mat2x3<f32>, param_arr : array<f32, 4>, param_struct : S, param_ptr_f32 : ptr<function, f32>, param_ptr_vec : ptr<function, vec4<f32>>, param_ptr_arr : ptr<function, array<f32, 4>>) {
diff --git a/test/types/return_types.wgsl b/test/types/return_types.wgsl
index 9e8ab89..c65b996 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 f8d31a2..bea78fb 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 @@
}
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 9bb9a8f..4d43323 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 a13e80b..765973d 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 1b255ff..517b684 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 fa24282..2bd0f33 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 071c667..926bb7d 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 @@
[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 9485542..59af17d 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 b8fcce5..570a185 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 fa24282..2bd0f33 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 {