ProgramBuilder: Migrate arrays to typ::TypePair

Used as a stepping stone to emitting the ast::Types instead.

Bug: tint:724
Change-Id: Idadb7d8b5d6fce1d898127675442221de07a633d
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/48685
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
Ben Clayton 2021-04-22 14:32:53 +00:00 committed by Commit Bot service account
parent fdb91fd85e
commit 7241a504f0
13 changed files with 72 additions and 56 deletions

View File

@ -18,6 +18,7 @@
#include <string> #include <string>
#include <utility> #include <utility>
#include "src/ast/array.h"
#include "src/ast/array_accessor_expression.h" #include "src/ast/array_accessor_expression.h"
#include "src/ast/assignment_statement.h" #include "src/ast/assignment_statement.h"
#include "src/ast/binary_expression.h" #include "src/ast/binary_expression.h"
@ -520,34 +521,39 @@ class ProgramBuilder {
/// @param subtype the array element type /// @param subtype the array element type
/// @param n the array size. 0 represents a runtime-array. /// @param n the array size. 0 represents a runtime-array.
/// @return the tint AST type for a array of size `n` of type `T` /// @return the tint AST type for a array of size `n` of type `T`
sem::ArrayType* array(sem::Type* subtype, uint32_t n = 0) const { typ::Array array(typ::Type subtype, uint32_t n = 0) const {
return builder->create<sem::ArrayType>(subtype, n, ast::DecorationList{}); return {
builder->create<ast::Array>(subtype, n, ast::DecorationList{}),
builder->create<sem::ArrayType>(subtype, n, ast::DecorationList{})};
} }
/// @param subtype the array element type /// @param subtype the array element type
/// @param n the array size. 0 represents a runtime-array. /// @param n the array size. 0 represents a runtime-array.
/// @param stride the array stride. /// @param stride the array stride.
/// @return the tint AST type for a array of size `n` of type `T` /// @return the tint AST type for a array of size `n` of type `T`
sem::ArrayType* array(sem::Type* subtype, typ::Array array(typ::Type subtype, uint32_t n, uint32_t stride) const {
uint32_t n, return {builder->create<ast::Array>(
uint32_t stride) const {
return builder->create<sem::ArrayType>(
subtype, n, subtype, n,
ast::DecorationList{ ast::DecorationList{
builder->create<ast::StrideDecoration>(stride), builder->create<ast::StrideDecoration>(stride),
}); }),
builder->create<sem::ArrayType>(
subtype, n,
ast::DecorationList{
builder->create<ast::StrideDecoration>(stride),
})};
} }
/// @return the tint AST type for an array of size `N` of type `T` /// @return the tint AST type for an array of size `N` of type `T`
template <typename T, int N = 0> template <typename T, int N = 0>
sem::ArrayType* array() const { typ::Array array() const {
return array(Of<T>(), N); return array(Of<T>(), N);
} }
/// @param stride the array stride /// @param stride the array stride
/// @return the tint AST type for an array of size `N` of type `T` /// @return the tint AST type for an array of size `N` of type `T`
template <typename T, int N = 0> template <typename T, int N = 0>
sem::ArrayType* array(uint32_t stride) const { typ::Array array(uint32_t stride) const {
return array(Of<T>(), N, stride); return array(Of<T>(), N, stride);
} }

View File

@ -438,7 +438,7 @@ using StructBlockTest = ResolverTest;
TEST_F(StructBlockTest, StructUsedAsArrayElement) { TEST_F(StructBlockTest, StructUsedAsArrayElement) {
auto* s = Structure("S", {Member("x", ty.i32())}, auto* s = Structure("S", {Member("x", ty.i32())},
{create<ast::StructBlockDecoration>()}); {create<ast::StructBlockDecoration>()});
auto* a = ty.array(s, 4); auto a = ty.array(s, 4);
Global("G", a, ast::StorageClass::kPrivate); Global("G", a, ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve()); EXPECT_FALSE(r()->Resolve());

View File

@ -759,7 +759,7 @@ INSTANTIATE_TEST_SUITE_P(
using ResolverIntrinsicDataTest = ResolverTest; using ResolverIntrinsicDataTest = ResolverTest;
TEST_F(ResolverIntrinsicDataTest, ArrayLength_Vector) { TEST_F(ResolverIntrinsicDataTest, ArrayLength_Vector) {
auto* ary = ty.array<i32>(); auto ary = ty.array<i32>();
auto* str = Structure("S", {Member("x", ary)}, auto* str = Structure("S", {Member("x", ary)},
{create<ast::StructBlockDecoration>()}); {create<ast::StructBlockDecoration>()});
auto* ac = ty.access(ast::AccessControl::kReadOnly, str); auto* ac = ty.access(ast::AccessControl::kReadOnly, str);

View File

@ -61,7 +61,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferPointer) {
TEST_F(ResolverStorageClassValidationTest, StorageBufferArray) { TEST_F(ResolverStorageClassValidationTest, StorageBufferArray) {
// var<storage> g : [[access(read)]] array<S, 3>; // var<storage> g : [[access(read)]] array<S, 3>;
auto* s = Structure("S", {Member("a", ty.f32())}); auto* s = Structure("S", {Member("a", ty.f32())});
auto* a = ty.array(s, 3); auto a = ty.array(s, 3);
auto* ac = ty.access(ast::AccessControl::kReadOnly, a); auto* ac = ty.access(ast::AccessControl::kReadOnly, a);
Global(Source{{56, 78}}, "g", ac, ast::StorageClass::kStorage); Global(Source{{56, 78}}, "g", ac, ast::StorageClass::kStorage);
@ -166,7 +166,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferPointer) {
TEST_F(ResolverStorageClassValidationTest, UniformBufferArray) { TEST_F(ResolverStorageClassValidationTest, UniformBufferArray) {
// var<uniform> g : [[access(read)]] array<S, 3>; // var<uniform> g : [[access(read)]] array<S, 3>;
auto* s = Structure("S", {Member("a", ty.f32())}); auto* s = Structure("S", {Member("a", ty.f32())});
auto* a = ty.array(s, 3); auto a = ty.array(s, 3);
auto* ac = ty.access(ast::AccessControl::kReadOnly, a); auto* ac = ty.access(ast::AccessControl::kReadOnly, a);
Global(Source{{56, 78}}, "g", ac, ast::StorageClass::kUniform); Global(Source{{56, 78}}, "g", ac, ast::StorageClass::kUniform);

View File

@ -168,8 +168,8 @@ TEST_F(ResolverStructLayoutTest, ExplicitStrideArrayRuntimeSized) {
} }
TEST_F(ResolverStructLayoutTest, ImplicitStrideArrayOfExplicitStrideArray) { TEST_F(ResolverStructLayoutTest, ImplicitStrideArrayOfExplicitStrideArray) {
auto* inner = ty.array<i32, 2>(/*stride*/ 16); // size: 32 auto inner = ty.array<i32, 2>(/*stride*/ 16); // size: 32
auto* outer = ty.array(inner, 12); // size: 12 * 32 auto outer = ty.array(inner, 12); // size: 12 * 32
auto* s = Structure("S", { auto* s = Structure("S", {
Member("c", outer), Member("c", outer),
}); });
@ -193,7 +193,7 @@ TEST_F(ResolverStructLayoutTest, ImplicitStrideArrayOfStructure) {
Member("b", ty.vec3<i32>()), Member("b", ty.vec3<i32>()),
Member("c", ty.vec4<i32>()), Member("c", ty.vec4<i32>()),
}); // size: 48 }); // size: 48
auto* outer = ty.array(inner, 12); // size: 12 * 48 auto outer = ty.array(inner, 12); // size: 12 * 48
auto* s = Structure("S", { auto* s = Structure("S", {
Member("c", outer), Member("c", outer),
}); });

View File

@ -104,7 +104,7 @@ TEST_F(ResolverStorageClassUseTest, StructReachableViaGlobalStruct) {
TEST_F(ResolverStorageClassUseTest, StructReachableViaGlobalArray) { TEST_F(ResolverStorageClassUseTest, StructReachableViaGlobalArray) {
auto* s = Structure("S", {Member("a", ty.f32())}); auto* s = Structure("S", {Member("a", ty.f32())});
auto* a = ty.array(s, 3); auto a = ty.array(s, 3);
Global("g", a, ast::StorageClass::kPrivate); Global("g", a, ast::StorageClass::kPrivate);
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -156,7 +156,7 @@ TEST_F(ResolverStorageClassUseTest, StructReachableViaLocalStruct) {
TEST_F(ResolverStorageClassUseTest, StructReachableViaLocalArray) { TEST_F(ResolverStorageClassUseTest, StructReachableViaLocalArray) {
auto* s = Structure("S", {Member("a", ty.f32())}); auto* s = Structure("S", {Member("a", ty.f32())});
auto* a = ty.array(s, 3); auto a = ty.array(s, 3);
WrapInFunction(Var("g", a, ast::StorageClass::kFunction)); WrapInFunction(Var("g", a, ast::StorageClass::kFunction));
ASSERT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(r()->Resolve()) << r()->error();

View File

@ -220,7 +220,7 @@ void Spirv::HandleSampleMaskBuiltins(CloneContext& ctx) const {
// Use the same name as the old variable. // Use the same name as the old variable.
auto var_name = ctx.Clone(var->symbol()); auto var_name = ctx.Clone(var->symbol());
// Use `array<u32, 1>` for the new variable. // Use `array<u32, 1>` for the new variable.
auto* type = ctx.dst->ty.array(ctx.dst->ty.u32(), 1u); auto type = ctx.dst->ty.array(ctx.dst->ty.u32(), 1u);
// Create the new variable. // Create the new variable.
auto* var_arr = ctx.dst->Var(var->source(), var_name, type, auto* var_arr = ctx.dst->Var(var->source(), var_name, type,
var->declared_storage_class(), nullptr, var->declared_storage_class(), nullptr,

View File

@ -22,6 +22,7 @@
namespace tint { namespace tint {
namespace ast { namespace ast {
class Array;
class Bool; class Bool;
class F32; class F32;
class I32; class I32;
@ -32,6 +33,7 @@ class Void;
} // namespace ast } // namespace ast
namespace sem { namespace sem {
class ArrayType;
class Bool; class Bool;
class F32; class F32;
class I32; class I32;
@ -63,8 +65,15 @@ struct TypePair {
/// Constructor /// Constructor
TypePair() = default; TypePair() = default;
/// Copy constructor
/// @param other the TypePair to copy
template <typename OTHER_AST, typename OTHER_SEM>
TypePair(const TypePair<OTHER_AST, OTHER_SEM>& other)
: ast(static_cast<const AST*>(other.ast)),
sem(static_cast<const SEM*>(other.sem)) {}
/// Constructor /// Constructor
/// @param a the ast::Type pointer /// @param a the ast::Type pointer
template <typename U>
TypePair(const AST* a) : ast(a) {} // NOLINT: explicit TypePair(const AST* a) : ast(a) {} // NOLINT: explicit
/// Constructor /// Constructor
/// @param s the sem::Type pointer /// @param s the sem::Type pointer
@ -84,6 +93,7 @@ struct TypePair {
using Type = TypePair<ast::Type, sem::Type>; using Type = TypePair<ast::Type, sem::Type>;
using Array = TypePair<ast::Array, sem::ArrayType>;
using Bool = TypePair<ast::Bool, sem::Bool>; using Bool = TypePair<ast::Bool, sem::Bool>;
using F32 = TypePair<ast::F32, sem::F32>; using F32 = TypePair<ast::F32, sem::F32>;
using I32 = TypePair<ast::I32, sem::I32>; using I32 = TypePair<ast::I32, sem::I32>;

View File

@ -43,7 +43,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Alias) {
} }
TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) { TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) {
auto* arr = ty.array<bool, 4>(); auto arr = ty.array<bool, 4>();
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -53,7 +53,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) {
} }
TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) { TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
auto* arr = ty.array(ty.array<bool, 4>(), 5); auto arr = ty.array(ty.array<bool, 4>(), 5);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -65,7 +65,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
// TODO(dsinclair): Is this possible? What order should it output in? // TODO(dsinclair): Is this possible? What order should it output in?
TEST_F(HlslGeneratorImplTest_Type, TEST_F(HlslGeneratorImplTest_Type,
DISABLED_EmitType_ArrayOfArrayOfRuntimeArray) { DISABLED_EmitType_ArrayOfArrayOfRuntimeArray) {
auto* arr = ty.array(ty.array(ty.array<bool, 4>(), 5), 0); auto arr = ty.array(ty.array(ty.array<bool, 4>(), 5), 0);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -75,7 +75,7 @@ TEST_F(HlslGeneratorImplTest_Type,
} }
TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) { TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
auto* arr = ty.array(ty.array(ty.array<bool, 4>(), 5), 6); auto arr = ty.array(ty.array(ty.array<bool, 4>(), 5), 6);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -85,7 +85,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
} }
TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_WithoutName) { TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
auto* arr = ty.array<bool, 4>(); auto arr = ty.array<bool, 4>();
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -95,7 +95,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
} }
TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_RuntimeArray) { TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_RuntimeArray) {
auto* arr = ty.array<bool>(); auto arr = ty.array<bool>();
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();

View File

@ -67,7 +67,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Alias) {
} }
TEST_F(MslGeneratorImplTest, EmitType_Array) { TEST_F(MslGeneratorImplTest, EmitType_Array) {
auto* arr = ty.array<bool, 4>(); auto arr = ty.array<bool, 4>();
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -76,8 +76,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Array) {
} }
TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArray) { TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArray) {
auto* a = ty.array<bool, 4>(); auto a = ty.array<bool, 4>();
auto* b = ty.array(a, 5); auto b = ty.array(a, 5);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -87,9 +87,9 @@ TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArray) {
// TODO(dsinclair): Is this possible? What order should it output in? // TODO(dsinclair): Is this possible? What order should it output in?
TEST_F(MslGeneratorImplTest, DISABLED_EmitType_ArrayOfArrayOfRuntimeArray) { TEST_F(MslGeneratorImplTest, DISABLED_EmitType_ArrayOfArrayOfRuntimeArray) {
auto* a = ty.array<bool, 4>(); auto a = ty.array<bool, 4>();
auto* b = ty.array(a, 5); auto b = ty.array(a, 5);
auto* c = ty.array(b, 0); auto c = ty.array(b, 0);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -98,9 +98,9 @@ TEST_F(MslGeneratorImplTest, DISABLED_EmitType_ArrayOfArrayOfRuntimeArray) {
} }
TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArrayOfArray) { TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArrayOfArray) {
auto* a = ty.array<bool, 4>(); auto a = ty.array<bool, 4>();
auto* b = ty.array(a, 5); auto b = ty.array(a, 5);
auto* c = ty.array(b, 6); auto c = ty.array(b, 6);
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -109,7 +109,7 @@ TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArrayOfArray) {
} }
TEST_F(MslGeneratorImplTest, EmitType_Array_WithoutName) { TEST_F(MslGeneratorImplTest, EmitType_Array_WithoutName) {
auto* arr = ty.array<bool, 4>(); auto arr = ty.array<bool, 4>();
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -118,7 +118,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Array_WithoutName) {
} }
TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray) { TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray) {
auto* arr = ty.array<bool, 1>(); auto arr = ty.array<bool, 1>();
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();
@ -408,13 +408,13 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayDefaultStride) {
}); });
// array_x: size(28), align(4) // array_x: size(28), align(4)
auto* array_x = ty.array<f32, 7>(); auto array_x = ty.array<f32, 7>();
// array_y: size(4096), align(512) // array_y: size(4096), align(512)
auto* array_y = ty.array(inner, 4); auto array_y = ty.array(inner, 4);
// array_z: size(4), align(4) // array_z: size(4), align(4)
auto* array_z = ty.array<f32>(); auto array_z = ty.array<f32>();
auto* s = auto* s =
Structure("S", Structure("S",

View File

@ -135,7 +135,7 @@ TEST_F(BuilderTest, ArrayAccessor_Dynamic) {
} }
TEST_F(BuilderTest, ArrayAccessor_MultiLevel) { TEST_F(BuilderTest, ArrayAccessor_MultiLevel) {
auto* ary4 = ty.array(ty.vec3<f32>(), 4); auto ary4 = ty.array(ty.vec3<f32>(), 4);
// ary = array<vec3<f32>, 4> // ary = array<vec3<f32>, 4>
// ary[3][2]; // ary[3][2];
@ -173,7 +173,7 @@ TEST_F(BuilderTest, ArrayAccessor_MultiLevel) {
} }
TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) { TEST_F(BuilderTest, Accessor_ArrayWithSwizzle) {
auto* ary4 = ty.array(ty.vec3<f32>(), 4); auto ary4 = ty.array(ty.vec3<f32>(), 4);
// var a : array<vec3<f32>, 4>; // var a : array<vec3<f32>, 4>;
// a[2].xy; // a[2].xy;
@ -696,10 +696,10 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) {
auto* c_type = Structure("C", {Member("baz", ty.vec3<f32>())}); auto* c_type = Structure("C", {Member("baz", ty.vec3<f32>())});
auto* b_type = Structure("B", {Member("bar", c_type)}); auto* b_type = Structure("B", {Member("bar", c_type)});
auto* b_ary_type = ty.array(b_type, 3); auto b_ary_type = ty.array(b_type, 3);
auto* a_type = Structure("A", {Member("foo", b_ary_type)}); auto* a_type = Structure("A", {Member("foo", b_ary_type)});
auto* a_ary_type = ty.array(a_type, 2); auto a_ary_type = ty.array(a_type, 2);
auto* var = Global("index", a_ary_type, ast::StorageClass::kFunction); auto* var = Global("index", a_ary_type, ast::StorageClass::kFunction);
auto* expr = MemberAccessor( auto* expr = MemberAccessor(
MemberAccessor( MemberAccessor(
@ -754,7 +754,7 @@ TEST_F(BuilderTest, Accessor_Array_Of_Vec) {
// vec2<f32>(0.5, -0.5)); // vec2<f32>(0.5, -0.5));
// pos[1] // pos[1]
auto* arr = ty.array(ty.vec2<f32>(), 3); auto arr = ty.array(ty.vec2<f32>(), 3);
auto* var = auto* var =
GlobalConst("pos", arr, GlobalConst("pos", arr,

View File

@ -58,7 +58,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedAlias) {
} }
TEST_F(BuilderTest_Type, GenerateRuntimeArray) { TEST_F(BuilderTest_Type, GenerateRuntimeArray) {
auto* ary = ty.array(ty.i32(), 0); auto ary = ty.array(ty.i32(), 0);
auto* str = Structure("S", {Member("x", ary)}, auto* str = Structure("S", {Member("x", ary)},
{create<ast::StructBlockDecoration>()}); {create<ast::StructBlockDecoration>()});
auto* ac = ty.access(ast::AccessControl::kReadOnly, str); auto* ac = ty.access(ast::AccessControl::kReadOnly, str);
@ -76,7 +76,7 @@ TEST_F(BuilderTest_Type, GenerateRuntimeArray) {
} }
TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) { TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) {
auto* ary = ty.array(ty.i32(), 0); auto ary = ty.array(ty.i32(), 0);
auto* str = Structure("S", {Member("x", ary)}, auto* str = Structure("S", {Member("x", ary)},
{create<ast::StructBlockDecoration>()}); {create<ast::StructBlockDecoration>()});
auto* ac = ty.access(ast::AccessControl::kReadOnly, str); auto* ac = ty.access(ast::AccessControl::kReadOnly, str);
@ -94,7 +94,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) {
} }
TEST_F(BuilderTest_Type, GenerateArray) { TEST_F(BuilderTest_Type, GenerateArray) {
auto* ary = ty.array(ty.i32(), 4); auto ary = ty.array(ty.i32(), 4);
Global("a", ary, ast::StorageClass::kInput); Global("a", ary, ast::StorageClass::kInput);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -111,7 +111,7 @@ TEST_F(BuilderTest_Type, GenerateArray) {
} }
TEST_F(BuilderTest_Type, GenerateArray_WithStride) { TEST_F(BuilderTest_Type, GenerateArray_WithStride) {
auto* ary = ty.array(ty.i32(), 4, 16u); auto ary = ty.array(ty.i32(), 4, 16u);
Global("a", ary, ast::StorageClass::kInput); Global("a", ary, ast::StorageClass::kInput);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -131,7 +131,7 @@ TEST_F(BuilderTest_Type, GenerateArray_WithStride) {
} }
TEST_F(BuilderTest_Type, ReturnsGeneratedArray) { TEST_F(BuilderTest_Type, ReturnsGeneratedArray) {
auto* ary = ty.array(ty.i32(), 4); auto ary = ty.array(ty.i32(), 4);
Global("a", ary, ast::StorageClass::kInput); Global("a", ary, ast::StorageClass::kInput);
spirv::Builder& b = Build(); spirv::Builder& b = Build();
@ -445,9 +445,9 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutArraysOfMatrix) {
// We have to infer layout for matrix when it also has an offset. // We have to infer layout for matrix when it also has an offset.
// The decoration goes on the struct member, even if the matrix is buried // The decoration goes on the struct member, even if the matrix is buried
// in levels of arrays. // in levels of arrays.
auto* arr_mat2x2 = ty.array(ty.mat2x2<f32>(), 1); // Singly nested array auto arr_mat2x2 = ty.array(ty.mat2x2<f32>(), 1); // Singly nested array
auto* arr_arr_mat2x3 = ty.array(ty.mat2x3<f32>(), 1); // Doubly nested array auto arr_arr_mat2x3 = ty.array(ty.mat2x3<f32>(), 1); // Doubly nested array
auto* rtarr_mat4x4 = ty.array(ty.mat4x4<f32>(), 0); // Runtime array auto rtarr_mat4x4 = ty.array(ty.mat4x4<f32>(), 0); // Runtime array
auto* s = auto* s =
Structure("S", Structure("S",

View File

@ -37,7 +37,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Alias) {
} }
TEST_F(WgslGeneratorImplTest, EmitType_Array) { TEST_F(WgslGeneratorImplTest, EmitType_Array) {
auto* arr = ty.array<bool, 4>(); auto arr = ty.array<bool, 4>();
AST().AddConstructedType(ty.alias("make_type_reachable", arr)); AST().AddConstructedType(ty.alias("make_type_reachable", arr));
GeneratorImpl& gen = Build(); GeneratorImpl& gen = Build();