mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
Flatten ast::Decoration class hierarchy
Remove the decoration groupings (Array, Function, Struct, StructMember, Type, Variable), such that all *Decoration classes now subclass ast::Decoration directly. This allows for decorations to be used in multiple places; for example, builtin decorations are now valid for both variables and struct members. Checking that decoration lists only contain decorations that are valid for the node that they are attached to is now done inside the validator. Change-Id: Ie8c0e53e5730a7dedea50a1dec8f26f9e7b00e8d Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/44320 Commit-Queue: James Price <jrprice@google.com> Reviewed-by: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
f1773c6700
commit
95d4077648
@@ -103,16 +103,14 @@ TEST_F(AccessControlTest, MinBufferBindingSizeU32) {
|
||||
|
||||
TEST_F(AccessControlTest, MinBufferBindingSizeArray) {
|
||||
U32 u32;
|
||||
Array array(&u32, 4,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
Array array(&u32, 4, ast::DecorationList{create<ast::StrideDecoration>(4)});
|
||||
AccessControl at{ast::AccessControl::kReadOnly, &array};
|
||||
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
}
|
||||
|
||||
TEST_F(AccessControlTest, MinBufferBindingSizeRuntimeArray) {
|
||||
U32 u32;
|
||||
Array array(&u32, 0,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
Array array(&u32, 0, ast::DecorationList{create<ast::StrideDecoration>(4)});
|
||||
AccessControl at{ast::AccessControl::kReadOnly, &array};
|
||||
EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
}
|
||||
@@ -121,7 +119,7 @@ TEST_F(AccessControlTest, MinBufferBindingSizeStruct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
|
||||
auto* struct_type = ty.struct_("struct_type", str);
|
||||
AccessControl at{ast::AccessControl::kReadOnly, struct_type};
|
||||
@@ -137,16 +135,14 @@ TEST_F(AccessControlTest, BaseAlignmentU32) {
|
||||
|
||||
TEST_F(AccessControlTest, BaseAlignmentArray) {
|
||||
U32 u32;
|
||||
Array array(&u32, 4,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
Array array(&u32, 4, ast::DecorationList{create<ast::StrideDecoration>(4)});
|
||||
AccessControl at{ast::AccessControl::kReadOnly, &array};
|
||||
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
}
|
||||
|
||||
TEST_F(AccessControlTest, BaseAlignmentRuntimeArray) {
|
||||
U32 u32;
|
||||
Array array(&u32, 0,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
Array array(&u32, 0, ast::DecorationList{create<ast::StrideDecoration>(4)});
|
||||
AccessControl at{ast::AccessControl::kReadOnly, &array};
|
||||
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
}
|
||||
@@ -155,7 +151,7 @@ TEST_F(AccessControlTest, BaseAlignmentStruct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* struct_type = ty.struct_("struct_type", str);
|
||||
|
||||
AccessControl at{ast::AccessControl::kReadOnly, struct_type};
|
||||
|
||||
@@ -144,7 +144,7 @@ TEST_F(AliasTest, MinBufferBindingSizeU32) {
|
||||
|
||||
TEST_F(AliasTest, MinBufferBindingSizeArray) {
|
||||
Array array(ty.u32(), 4,
|
||||
ast::ArrayDecorationList{
|
||||
ast::DecorationList{
|
||||
create<ast::StrideDecoration>(4),
|
||||
});
|
||||
auto* alias = ty.alias("alias", &array);
|
||||
@@ -153,7 +153,7 @@ TEST_F(AliasTest, MinBufferBindingSizeArray) {
|
||||
|
||||
TEST_F(AliasTest, MinBufferBindingSizeRuntimeArray) {
|
||||
Array array(ty.u32(), 0,
|
||||
ast::ArrayDecorationList{
|
||||
ast::DecorationList{
|
||||
create<ast::StrideDecoration>(4),
|
||||
});
|
||||
auto* alias = ty.alias("alias", &array);
|
||||
@@ -164,7 +164,7 @@ TEST_F(AliasTest, MinBufferBindingSizeStruct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* struct_type = ty.struct_("struct_type", str);
|
||||
auto* alias = ty.alias("alias", struct_type);
|
||||
|
||||
@@ -179,7 +179,7 @@ TEST_F(AliasTest, BaseAlignmentU32) {
|
||||
|
||||
TEST_F(AliasTest, BaseAlignmentArray) {
|
||||
Array array(ty.u32(), 4,
|
||||
ast::ArrayDecorationList{
|
||||
ast::DecorationList{
|
||||
create<ast::StrideDecoration>(4),
|
||||
});
|
||||
auto* alias = ty.alias("alias", &array);
|
||||
@@ -188,7 +188,7 @@ TEST_F(AliasTest, BaseAlignmentArray) {
|
||||
|
||||
TEST_F(AliasTest, BaseAlignmentRuntimeArray) {
|
||||
Array array(ty.u32(), 0,
|
||||
ast::ArrayDecorationList{
|
||||
ast::DecorationList{
|
||||
create<ast::StrideDecoration>(4),
|
||||
});
|
||||
auto* alias = ty.alias("alias", &array);
|
||||
@@ -199,7 +199,7 @@ TEST_F(AliasTest, BaseAlignmentStruct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* struct_type = ty.struct_("struct_type", str);
|
||||
auto* alias = ty.alias("alias", struct_type);
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ TINT_INSTANTIATE_TYPEINFO(tint::type::Array);
|
||||
namespace tint {
|
||||
namespace type {
|
||||
|
||||
Array::Array(Type* subtype, uint32_t size, ast::ArrayDecorationList decorations)
|
||||
Array::Array(Type* subtype, uint32_t size, ast::DecorationList decorations)
|
||||
: subtype_(subtype), size_(size), decos_(decorations) {}
|
||||
|
||||
Array::Array(Array&&) = default;
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "src/ast/array_decoration.h"
|
||||
#include "src/ast/decoration.h"
|
||||
#include "src/type/type.h"
|
||||
|
||||
namespace tint {
|
||||
@@ -31,7 +31,7 @@ class Array : public Castable<Array, Type> {
|
||||
/// @param size the number of elements in the array. `0` represents a
|
||||
/// runtime-sized array.
|
||||
/// @param decorations the array decorations
|
||||
Array(Type* subtype, uint32_t size, ast::ArrayDecorationList decorations);
|
||||
Array(Type* subtype, uint32_t size, ast::DecorationList decorations);
|
||||
/// Move constructor
|
||||
Array(Array&&);
|
||||
~Array() override;
|
||||
@@ -51,7 +51,7 @@ class Array : public Castable<Array, Type> {
|
||||
uint64_t BaseAlignment(MemoryLayout mem_layout) const override;
|
||||
|
||||
/// @returns the array decorations
|
||||
const ast::ArrayDecorationList& decorations() const { return decos_; }
|
||||
const ast::DecorationList& decorations() const { return decos_; }
|
||||
|
||||
/// @returns the array stride or 0 if none set.
|
||||
uint32_t array_stride() const;
|
||||
@@ -79,7 +79,7 @@ class Array : public Castable<Array, Type> {
|
||||
private:
|
||||
Type* const subtype_;
|
||||
uint32_t const size_;
|
||||
ast::ArrayDecorationList const decos_;
|
||||
ast::DecorationList const decos_;
|
||||
};
|
||||
|
||||
} // namespace type
|
||||
|
||||
@@ -24,7 +24,7 @@ using ArrayTest = TestHelper;
|
||||
|
||||
TEST_F(ArrayTest, CreateSizedArray) {
|
||||
U32 u32;
|
||||
Array arr{&u32, 3, ast::ArrayDecorationList{}};
|
||||
Array arr{&u32, 3, ast::DecorationList{}};
|
||||
EXPECT_EQ(arr.type(), &u32);
|
||||
EXPECT_EQ(arr.size(), 3u);
|
||||
EXPECT_TRUE(arr.Is<Array>());
|
||||
@@ -33,7 +33,7 @@ TEST_F(ArrayTest, CreateSizedArray) {
|
||||
|
||||
TEST_F(ArrayTest, CreateRuntimeArray) {
|
||||
U32 u32;
|
||||
Array arr{&u32, 0, ast::ArrayDecorationList{}};
|
||||
Array arr{&u32, 0, ast::DecorationList{}};
|
||||
EXPECT_EQ(arr.type(), &u32);
|
||||
EXPECT_EQ(arr.size(), 0u);
|
||||
EXPECT_TRUE(arr.Is<Array>());
|
||||
@@ -43,7 +43,7 @@ TEST_F(ArrayTest, CreateRuntimeArray) {
|
||||
TEST_F(ArrayTest, Is) {
|
||||
I32 i32;
|
||||
|
||||
Array arr{&i32, 3, ast::ArrayDecorationList{}};
|
||||
Array arr{&i32, 3, ast::DecorationList{}};
|
||||
Type* ty = &arr;
|
||||
EXPECT_FALSE(ty->Is<AccessControl>());
|
||||
EXPECT_FALSE(ty->Is<Alias>());
|
||||
@@ -62,71 +62,66 @@ TEST_F(ArrayTest, Is) {
|
||||
|
||||
TEST_F(ArrayTest, TypeName) {
|
||||
I32 i32;
|
||||
Array arr{&i32, 0, ast::ArrayDecorationList{}};
|
||||
Array arr{&i32, 0, ast::DecorationList{}};
|
||||
EXPECT_EQ(arr.type_name(), "__array__i32");
|
||||
}
|
||||
|
||||
TEST_F(ArrayTest, FriendlyNameRuntimeSized) {
|
||||
Array arr{ty.i32(), 0, ast::ArrayDecorationList{}};
|
||||
Array arr{ty.i32(), 0, ast::DecorationList{}};
|
||||
EXPECT_EQ(arr.FriendlyName(Symbols()), "array<i32>");
|
||||
}
|
||||
|
||||
TEST_F(ArrayTest, FriendlyNameStaticSized) {
|
||||
Array arr{ty.i32(), 5, ast::ArrayDecorationList{}};
|
||||
Array arr{ty.i32(), 5, ast::DecorationList{}};
|
||||
EXPECT_EQ(arr.FriendlyName(Symbols()), "array<i32, 5>");
|
||||
}
|
||||
|
||||
TEST_F(ArrayTest, FriendlyNameWithStride) {
|
||||
Array arr{ty.i32(), 5,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(32)}};
|
||||
ast::DecorationList{create<ast::StrideDecoration>(32)}};
|
||||
EXPECT_EQ(arr.FriendlyName(Symbols()), "[[stride(32)]] array<i32, 5>");
|
||||
}
|
||||
|
||||
TEST_F(ArrayTest, TypeName_RuntimeArray) {
|
||||
I32 i32;
|
||||
Array arr{&i32, 3, ast::ArrayDecorationList{}};
|
||||
Array arr{&i32, 3, ast::DecorationList{}};
|
||||
EXPECT_EQ(arr.type_name(), "__array__i32_3");
|
||||
}
|
||||
|
||||
TEST_F(ArrayTest, TypeName_WithStride) {
|
||||
I32 i32;
|
||||
Array arr{&i32, 3,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(16)}};
|
||||
Array arr{&i32, 3, ast::DecorationList{create<ast::StrideDecoration>(16)}};
|
||||
EXPECT_EQ(arr.type_name(), "__array__i32_3_stride_16");
|
||||
}
|
||||
|
||||
TEST_F(ArrayTest, MinBufferBindingSizeNoStride) {
|
||||
U32 u32;
|
||||
Array arr(&u32, 4, ast::ArrayDecorationList{});
|
||||
Array arr(&u32, 4, ast::DecorationList{});
|
||||
EXPECT_EQ(0u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
}
|
||||
|
||||
TEST_F(ArrayTest, MinBufferBindingSizeArray) {
|
||||
U32 u32;
|
||||
Array arr(&u32, 4,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
Array arr(&u32, 4, ast::DecorationList{create<ast::StrideDecoration>(4)});
|
||||
EXPECT_EQ(16u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
}
|
||||
|
||||
TEST_F(ArrayTest, MinBufferBindingSizeRuntimeArray) {
|
||||
U32 u32;
|
||||
Array arr(&u32, 0,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
Array arr(&u32, 0, ast::DecorationList{create<ast::StrideDecoration>(4)});
|
||||
EXPECT_EQ(4u, arr.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
}
|
||||
|
||||
TEST_F(ArrayTest, BaseAlignmentArray) {
|
||||
U32 u32;
|
||||
Array arr(&u32, 4,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
Array arr(&u32, 4, ast::DecorationList{create<ast::StrideDecoration>(4)});
|
||||
EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||
}
|
||||
|
||||
TEST_F(ArrayTest, BaseAlignmentRuntimeArray) {
|
||||
U32 u32;
|
||||
Array arr(&u32, 0,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
Array arr(&u32, 0, ast::DecorationList{create<ast::StrideDecoration>(4)});
|
||||
EXPECT_EQ(16u, arr.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
EXPECT_EQ(4u, arr.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ uint64_t Matrix::MinBufferBindingSize(MemoryLayout mem_layout) const {
|
||||
|
||||
uint64_t Matrix::BaseAlignment(MemoryLayout mem_layout) const {
|
||||
Vector vec(subtype_, rows_);
|
||||
Array arr(&vec, columns_, ast::ArrayDecorationList{});
|
||||
Array arr(&vec, columns_, ast::DecorationList{});
|
||||
return arr.BaseAlignment(mem_layout);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ using StructTypeTest = TestHelper;
|
||||
|
||||
TEST_F(StructTypeTest, Creation) {
|
||||
auto* impl =
|
||||
create<ast::Struct>(ast::StructMemberList{}, ast::StructDecorationList{});
|
||||
create<ast::Struct>(ast::StructMemberList{}, ast::DecorationList{});
|
||||
auto* ptr = impl;
|
||||
auto* s = ty.struct_("S", impl);
|
||||
EXPECT_EQ(s->impl(), ptr);
|
||||
@@ -32,7 +32,7 @@ TEST_F(StructTypeTest, Creation) {
|
||||
|
||||
TEST_F(StructTypeTest, Is) {
|
||||
auto* impl =
|
||||
create<ast::Struct>(ast::StructMemberList{}, ast::StructDecorationList{});
|
||||
create<ast::Struct>(ast::StructMemberList{}, ast::DecorationList{});
|
||||
auto* s = ty.struct_("S", impl);
|
||||
type::Type* ty = s;
|
||||
EXPECT_FALSE(ty->Is<AccessControl>());
|
||||
@@ -52,14 +52,14 @@ TEST_F(StructTypeTest, Is) {
|
||||
|
||||
TEST_F(StructTypeTest, TypeName) {
|
||||
auto* impl =
|
||||
create<ast::Struct>(ast::StructMemberList{}, ast::StructDecorationList{});
|
||||
create<ast::Struct>(ast::StructMemberList{}, ast::DecorationList{});
|
||||
auto* s = ty.struct_("my_struct", impl);
|
||||
EXPECT_EQ(s->type_name(), "__struct_tint_symbol_1");
|
||||
}
|
||||
|
||||
TEST_F(StructTypeTest, FriendlyName) {
|
||||
auto* impl =
|
||||
create<ast::Struct>(ast::StructMemberList{}, ast::StructDecorationList{});
|
||||
create<ast::Struct>(ast::StructMemberList{}, ast::DecorationList{});
|
||||
auto* s = ty.struct_("my_struct", impl);
|
||||
EXPECT_EQ(s->FriendlyName(Symbols()), "my_struct");
|
||||
}
|
||||
@@ -68,7 +68,7 @@ TEST_F(StructTypeTest, MinBufferBindingSize) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
@@ -76,14 +76,13 @@ TEST_F(StructTypeTest, MinBufferBindingSize) {
|
||||
}
|
||||
|
||||
TEST_F(StructTypeTest, MinBufferBindingSizeArray) {
|
||||
Array arr(ty.u32(), 4,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
Array arr(ty.u32(), 4, ast::DecorationList{create<ast::StrideDecoration>(4)});
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)}),
|
||||
Member("bar", &arr, {MemberOffset(8)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
EXPECT_EQ(32u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
@@ -91,14 +90,13 @@ TEST_F(StructTypeTest, MinBufferBindingSizeArray) {
|
||||
}
|
||||
|
||||
TEST_F(StructTypeTest, MinBufferBindingSizeRuntimeArray) {
|
||||
Array arr(ty.u32(), 0,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
Array arr(ty.u32(), 0, ast::DecorationList{create<ast::StrideDecoration>(4)});
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(8)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
EXPECT_EQ(12u, s_ty->MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
||||
@@ -107,7 +105,7 @@ TEST_F(StructTypeTest, MinBufferBindingSizeRuntimeArray) {
|
||||
TEST_F(StructTypeTest, MinBufferBindingSizeVec2) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.vec2<u32>(), {MemberOffset(0)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
@@ -117,7 +115,7 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec2) {
|
||||
TEST_F(StructTypeTest, MinBufferBindingSizeVec3) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.vec3<u32>(), {MemberOffset(0)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
@@ -127,7 +125,7 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec3) {
|
||||
TEST_F(StructTypeTest, MinBufferBindingSizeVec4) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.vec4<u32>(), {MemberOffset(0)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
EXPECT_EQ(16u, s_ty->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
@@ -138,7 +136,7 @@ TEST_F(StructTypeTest, BaseAlignment) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(8)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
@@ -146,13 +144,12 @@ TEST_F(StructTypeTest, BaseAlignment) {
|
||||
}
|
||||
|
||||
TEST_F(StructTypeTest, BaseAlignmentArray) {
|
||||
Array arr(ty.u32(), 4,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
Array arr(ty.u32(), 4, ast::DecorationList{create<ast::StrideDecoration>(4)});
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)}),
|
||||
Member("bar", &arr, {MemberOffset(8)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
@@ -160,13 +157,12 @@ TEST_F(StructTypeTest, BaseAlignmentArray) {
|
||||
}
|
||||
|
||||
TEST_F(StructTypeTest, BaseAlignmentRuntimeArray) {
|
||||
Array arr(ty.u32(), 0,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
Array arr(ty.u32(), 0, ast::DecorationList{create<ast::StrideDecoration>(4)});
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(8)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
EXPECT_EQ(4u, s_ty->BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||
@@ -175,7 +171,7 @@ TEST_F(StructTypeTest, BaseAlignmentRuntimeArray) {
|
||||
TEST_F(StructTypeTest, BaseAlignmentVec2) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.vec2<u32>(), {MemberOffset(0)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
@@ -185,7 +181,7 @@ TEST_F(StructTypeTest, BaseAlignmentVec2) {
|
||||
TEST_F(StructTypeTest, BaseAlignmentVec3) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.vec3<u32>(), {MemberOffset(0)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
@@ -195,7 +191,7 @@ TEST_F(StructTypeTest, BaseAlignmentVec3) {
|
||||
TEST_F(StructTypeTest, BaseAlignmentVec4) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.vec4<u32>(), {MemberOffset(0)})},
|
||||
ast::StructDecorationList{});
|
||||
ast::DecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
EXPECT_EQ(16u, s_ty->BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
|
||||
Reference in New Issue
Block a user