ast/types tests: Replace std::make_unique<T> -> create<T>
create() is currently just a simple forwarder to std::make_unique<>, but will be later replaced with a function that returns a raw pointer, and owned by the context. Bug: tint:322 Change-Id: I39e7d1c9a1c64608d41dfd032c419e06d147e064 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/32666 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
327b1c7cd3
commit
b673de0ec3
|
@ -102,7 +102,7 @@ TEST_F(AccessControlTypeTest, MinBufferBindingSizeArray) {
|
||||||
U32Type u32;
|
U32Type u32;
|
||||||
ArrayType array(&u32, 4);
|
ArrayType array(&u32, 4);
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
array.set_decorations(std::move(decos));
|
array.set_decorations(std::move(decos));
|
||||||
AccessControlType at{AccessControl::kReadOnly, &array};
|
AccessControlType at{AccessControl::kReadOnly, &array};
|
||||||
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -112,7 +112,7 @@ TEST_F(AccessControlTypeTest, MinBufferBindingSizeRuntimeArray) {
|
||||||
U32Type u32;
|
U32Type u32;
|
||||||
ArrayType array(&u32);
|
ArrayType array(&u32);
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
array.set_decorations(std::move(decos));
|
array.set_decorations(std::move(decos));
|
||||||
AccessControlType at{AccessControl::kReadOnly, &array};
|
AccessControlType at{AccessControl::kReadOnly, &array};
|
||||||
EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(4u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -123,19 +123,16 @@ TEST_F(AccessControlTypeTest, MinBufferBindingSizeStruct) {
|
||||||
StructMemberList members;
|
StructMemberList members;
|
||||||
|
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &u32, std::move(deco)));
|
|
||||||
|
|
||||||
deco = StructMemberDecorationList();
|
deco = StructMemberDecorationList();
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(4, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &u32, std::move(deco)));
|
|
||||||
|
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
AccessControlType at{AccessControl::kReadOnly, &struct_type};
|
AccessControlType at{AccessControl::kReadOnly, &struct_type};
|
||||||
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -152,7 +149,7 @@ TEST_F(AccessControlTypeTest, BaseAlignmentArray) {
|
||||||
U32Type u32;
|
U32Type u32;
|
||||||
ArrayType array(&u32, 4);
|
ArrayType array(&u32, 4);
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
array.set_decorations(std::move(decos));
|
array.set_decorations(std::move(decos));
|
||||||
AccessControlType at{AccessControl::kReadOnly, &array};
|
AccessControlType at{AccessControl::kReadOnly, &array};
|
||||||
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -162,7 +159,7 @@ TEST_F(AccessControlTypeTest, BaseAlignmentRuntimeArray) {
|
||||||
U32Type u32;
|
U32Type u32;
|
||||||
ArrayType array(&u32);
|
ArrayType array(&u32);
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
array.set_decorations(std::move(decos));
|
array.set_decorations(std::move(decos));
|
||||||
AccessControlType at{AccessControl::kReadOnly, &array};
|
AccessControlType at{AccessControl::kReadOnly, &array};
|
||||||
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -174,20 +171,17 @@ TEST_F(AccessControlTypeTest, BaseAlignmentStruct) {
|
||||||
|
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(4, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
AccessControlType at{AccessControl::kReadOnly, &struct_type};
|
AccessControlType at{AccessControl::kReadOnly, &struct_type};
|
||||||
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
|
|
|
@ -165,7 +165,7 @@ TEST_F(AliasTypeTest, MinBufferBindingSizeArray) {
|
||||||
U32Type u32;
|
U32Type u32;
|
||||||
ArrayType array(&u32, 4);
|
ArrayType array(&u32, 4);
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
array.set_decorations(std::move(decos));
|
array.set_decorations(std::move(decos));
|
||||||
AliasType alias{"alias", &array};
|
AliasType alias{"alias", &array};
|
||||||
EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -175,7 +175,7 @@ TEST_F(AliasTypeTest, MinBufferBindingSizeRuntimeArray) {
|
||||||
U32Type u32;
|
U32Type u32;
|
||||||
ArrayType array(&u32);
|
ArrayType array(&u32);
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
array.set_decorations(std::move(decos));
|
array.set_decorations(std::move(decos));
|
||||||
AliasType alias{"alias", &array};
|
AliasType alias{"alias", &array};
|
||||||
EXPECT_EQ(4u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(4u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -187,20 +187,17 @@ TEST_F(AliasTypeTest, MinBufferBindingSizeStruct) {
|
||||||
|
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(4, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
AliasType alias{"alias", &struct_type};
|
AliasType alias{"alias", &struct_type};
|
||||||
EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -217,7 +214,7 @@ TEST_F(AliasTypeTest, BaseAlignmentArray) {
|
||||||
U32Type u32;
|
U32Type u32;
|
||||||
ArrayType array(&u32, 4);
|
ArrayType array(&u32, 4);
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
array.set_decorations(std::move(decos));
|
array.set_decorations(std::move(decos));
|
||||||
AliasType alias{"alias", &array};
|
AliasType alias{"alias", &array};
|
||||||
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -227,7 +224,7 @@ TEST_F(AliasTypeTest, BaseAlignmentRuntimeArray) {
|
||||||
U32Type u32;
|
U32Type u32;
|
||||||
ArrayType array(&u32);
|
ArrayType array(&u32);
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
array.set_decorations(std::move(decos));
|
array.set_decorations(std::move(decos));
|
||||||
AliasType alias{"alias", &array};
|
AliasType alias{"alias", &array};
|
||||||
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -239,20 +236,17 @@ TEST_F(AliasTypeTest, BaseAlignmentStruct) {
|
||||||
|
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(4, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
AliasType alias{"alias", &struct_type};
|
AliasType alias{"alias", &struct_type};
|
||||||
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
|
|
|
@ -81,7 +81,7 @@ TEST_F(ArrayTypeTest, TypeName_RuntimeArray) {
|
||||||
TEST_F(ArrayTypeTest, TypeName_WithStride) {
|
TEST_F(ArrayTypeTest, TypeName_WithStride) {
|
||||||
I32Type i32;
|
I32Type i32;
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(16, Source{}));
|
decos.push_back(create<StrideDecoration>(16, Source{}));
|
||||||
|
|
||||||
ArrayType arr{&i32, 3};
|
ArrayType arr{&i32, 3};
|
||||||
arr.set_decorations(std::move(decos));
|
arr.set_decorations(std::move(decos));
|
||||||
|
@ -97,7 +97,7 @@ TEST_F(ArrayTypeTest, MinBufferBindingSizeNoStride) {
|
||||||
TEST_F(ArrayTypeTest, MinBufferBindingSizeArray) {
|
TEST_F(ArrayTypeTest, MinBufferBindingSizeArray) {
|
||||||
U32Type u32;
|
U32Type u32;
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
|
|
||||||
ArrayType arr(&u32, 4);
|
ArrayType arr(&u32, 4);
|
||||||
arr.set_decorations(std::move(decos));
|
arr.set_decorations(std::move(decos));
|
||||||
|
@ -107,7 +107,7 @@ TEST_F(ArrayTypeTest, MinBufferBindingSizeArray) {
|
||||||
TEST_F(ArrayTypeTest, MinBufferBindingSizeRuntimeArray) {
|
TEST_F(ArrayTypeTest, MinBufferBindingSizeRuntimeArray) {
|
||||||
U32Type u32;
|
U32Type u32;
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
|
|
||||||
ArrayType arr(&u32);
|
ArrayType arr(&u32);
|
||||||
arr.set_decorations(std::move(decos));
|
arr.set_decorations(std::move(decos));
|
||||||
|
@ -117,7 +117,7 @@ TEST_F(ArrayTypeTest, MinBufferBindingSizeRuntimeArray) {
|
||||||
TEST_F(ArrayTypeTest, BaseAlignmentArray) {
|
TEST_F(ArrayTypeTest, BaseAlignmentArray) {
|
||||||
U32Type u32;
|
U32Type u32;
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
|
|
||||||
ArrayType arr(&u32, 4);
|
ArrayType arr(&u32, 4);
|
||||||
arr.set_decorations(std::move(decos));
|
arr.set_decorations(std::move(decos));
|
||||||
|
@ -128,7 +128,7 @@ TEST_F(ArrayTypeTest, BaseAlignmentArray) {
|
||||||
TEST_F(ArrayTypeTest, BaseAlignmentRuntimeArray) {
|
TEST_F(ArrayTypeTest, BaseAlignmentRuntimeArray) {
|
||||||
U32Type u32;
|
U32Type u32;
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
|
|
||||||
ArrayType arr(&u32);
|
ArrayType arr(&u32);
|
||||||
arr.set_decorations(std::move(decos));
|
arr.set_decorations(std::move(decos));
|
||||||
|
|
|
@ -34,14 +34,14 @@ namespace {
|
||||||
using StructTypeTest = TestHelper;
|
using StructTypeTest = TestHelper;
|
||||||
|
|
||||||
TEST_F(StructTypeTest, Creation) {
|
TEST_F(StructTypeTest, Creation) {
|
||||||
auto impl = std::make_unique<Struct>();
|
auto impl = create<Struct>();
|
||||||
auto* ptr = impl.get();
|
auto* ptr = impl.get();
|
||||||
StructType s{"S", std::move(impl)};
|
StructType s{"S", std::move(impl)};
|
||||||
EXPECT_EQ(s.impl(), ptr);
|
EXPECT_EQ(s.impl(), ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StructTypeTest, Is) {
|
TEST_F(StructTypeTest, Is) {
|
||||||
auto impl = std::make_unique<Struct>();
|
auto impl = create<Struct>();
|
||||||
StructType s{"S", std::move(impl)};
|
StructType s{"S", std::move(impl)};
|
||||||
EXPECT_FALSE(s.IsAccessControl());
|
EXPECT_FALSE(s.IsAccessControl());
|
||||||
EXPECT_FALSE(s.IsAlias());
|
EXPECT_FALSE(s.IsAlias());
|
||||||
|
@ -59,7 +59,7 @@ TEST_F(StructTypeTest, Is) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StructTypeTest, TypeName) {
|
TEST_F(StructTypeTest, TypeName) {
|
||||||
auto impl = std::make_unique<Struct>();
|
auto impl = create<Struct>();
|
||||||
StructType s{"my_struct", std::move(impl)};
|
StructType s{"my_struct", std::move(impl)};
|
||||||
EXPECT_EQ(s.type_name(), "__struct_my_struct");
|
EXPECT_EQ(s.type_name(), "__struct_my_struct");
|
||||||
}
|
}
|
||||||
|
@ -70,20 +70,17 @@ TEST_F(StructTypeTest, MinBufferBindingSize) {
|
||||||
|
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(4, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
EXPECT_EQ(16u,
|
EXPECT_EQ(16u,
|
||||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -95,33 +92,29 @@ TEST_F(StructTypeTest, MinBufferBindingSizeArray) {
|
||||||
ArrayType arr(&u32, 4);
|
ArrayType arr(&u32, 4);
|
||||||
{
|
{
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
arr.set_decorations(std::move(decos));
|
arr.set_decorations(std::move(decos));
|
||||||
}
|
}
|
||||||
|
|
||||||
StructMemberList members;
|
StructMemberList members;
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(4, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(8, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(8, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &arr, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &arr, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
EXPECT_EQ(32u,
|
EXPECT_EQ(32u,
|
||||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -134,33 +127,29 @@ TEST_F(StructTypeTest, MinBufferBindingSizeRuntimeArray) {
|
||||||
ArrayType arr(&u32);
|
ArrayType arr(&u32);
|
||||||
{
|
{
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
arr.set_decorations(std::move(decos));
|
arr.set_decorations(std::move(decos));
|
||||||
}
|
}
|
||||||
|
|
||||||
StructMemberList members;
|
StructMemberList members;
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(4, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(8, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(8, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
EXPECT_EQ(12u,
|
EXPECT_EQ(12u,
|
||||||
struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
||||||
|
@ -173,14 +162,12 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec2) {
|
||||||
StructMemberList members;
|
StructMemberList members;
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &vec2, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &vec2, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
EXPECT_EQ(16u,
|
EXPECT_EQ(16u,
|
||||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -194,14 +181,12 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec3) {
|
||||||
StructMemberList members;
|
StructMemberList members;
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &vec3, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &vec3, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
EXPECT_EQ(16u,
|
EXPECT_EQ(16u,
|
||||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -216,14 +201,12 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec4) {
|
||||||
StructMemberList members;
|
StructMemberList members;
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &vec4, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &vec4, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
EXPECT_EQ(16u,
|
EXPECT_EQ(16u,
|
||||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
|
@ -237,20 +220,17 @@ TEST_F(StructTypeTest, BaseAlignment) {
|
||||||
|
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(4, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||||
|
@ -261,33 +241,29 @@ TEST_F(StructTypeTest, BaseAlignmentArray) {
|
||||||
ArrayType arr(&u32, 4);
|
ArrayType arr(&u32, 4);
|
||||||
{
|
{
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
arr.set_decorations(std::move(decos));
|
arr.set_decorations(std::move(decos));
|
||||||
}
|
}
|
||||||
|
|
||||||
StructMemberList members;
|
StructMemberList members;
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(4, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(8, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(8, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &arr, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &arr, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||||
|
@ -298,33 +274,29 @@ TEST_F(StructTypeTest, BaseAlignmentRuntimeArray) {
|
||||||
ArrayType arr(&u32);
|
ArrayType arr(&u32);
|
||||||
{
|
{
|
||||||
ArrayDecorationList decos;
|
ArrayDecorationList decos;
|
||||||
decos.push_back(std::make_unique<StrideDecoration>(4, Source{}));
|
decos.push_back(create<StrideDecoration>(4, Source{}));
|
||||||
arr.set_decorations(std::move(decos));
|
arr.set_decorations(std::move(decos));
|
||||||
}
|
}
|
||||||
|
|
||||||
StructMemberList members;
|
StructMemberList members;
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(4, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(4, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(8, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(8, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("bar", &u32, std::move(deco)));
|
||||||
std::make_unique<StructMember>("bar", &u32, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||||
}
|
}
|
||||||
|
@ -336,14 +308,12 @@ TEST_F(StructTypeTest, BaseAlignmentVec2) {
|
||||||
StructMemberList members;
|
StructMemberList members;
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &vec2, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &vec2, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(8u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(8u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||||
|
@ -356,14 +326,12 @@ TEST_F(StructTypeTest, BaseAlignmentVec3) {
|
||||||
StructMemberList members;
|
StructMemberList members;
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &vec3, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &vec3, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||||
|
@ -376,14 +344,12 @@ TEST_F(StructTypeTest, BaseAlignmentVec4) {
|
||||||
StructMemberList members;
|
StructMemberList members;
|
||||||
{
|
{
|
||||||
StructMemberDecorationList deco;
|
StructMemberDecorationList deco;
|
||||||
deco.push_back(std::make_unique<StructMemberOffsetDecoration>(0, Source{}));
|
deco.push_back(create<StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(
|
members.push_back(create<StructMember>("foo", &vec4, std::move(deco)));
|
||||||
std::make_unique<StructMember>("foo", &vec4, std::move(deco)));
|
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto str =
|
auto str = create<ast::Struct>(std::move(decos), std::move(members));
|
||||||
std::make_unique<ast::Struct>(std::move(decos), std::move(members));
|
|
||||||
StructType struct_type("struct_type", std::move(str));
|
StructType struct_type("struct_type", std::move(str));
|
||||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(16u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||||
|
|
Loading…
Reference in New Issue