mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 10:49:14 +00:00
Add base class for sem Struct and StructMember
This CL splits the sem::Struct and sem::StructMember classes into having a base class and a sem variant. The sem variant contains the `ast::Declaration` for that sem node. This will allow the base classes to move into the type hierarchy and keep the sem specific requirements in the sem folder. Bug: tint:1718 Change-Id: I83294e957a52b87b8536dbb3582daa06a8516253 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/112860 Commit-Queue: Ben Clayton <bclayton@google.com> Reviewed-by: James Price <jrprice@google.com> Kokoro: Ben Clayton <bclayton@google.com>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
c07de73b0b
commit
ad9cd0a141
@@ -145,7 +145,7 @@ struct ArrayLengthFromUniform::State {
|
||||
if (auto* str = storage_buffer_type->As<sem::Struct>()) {
|
||||
// The variable is a struct, so subtract the byte offset of the array
|
||||
// member.
|
||||
auto* array_member_sem = str->Members().back();
|
||||
auto* array_member_sem = str->Members().Back();
|
||||
array_type = array_member_sem->Type()->As<sem::Array>();
|
||||
total_size = b.Sub(total_storage_buffer_size, u32(array_member_sem->Offset()));
|
||||
} else if (auto* arr = storage_buffer_type->As<sem::Array>()) {
|
||||
|
||||
@@ -207,7 +207,7 @@ Transform::ApplyResult CalculateArrayLength::Apply(const Program* src,
|
||||
[&](const sem::Struct* str) {
|
||||
// The variable is a struct, so subtract the byte offset of
|
||||
// the array member.
|
||||
auto* array_member_sem = str->Members().back();
|
||||
auto* array_member_sem = str->Members().Back();
|
||||
total_size = b.Sub(total_size, u32(array_member_sem->Offset()));
|
||||
return array_member_sem->Type()->As<sem::Array>();
|
||||
},
|
||||
|
||||
@@ -714,7 +714,7 @@ struct DecomposeMemoryAccess::State {
|
||||
TINT_ASSERT(Transform, str && str->Declaration() == nullptr);
|
||||
|
||||
utils::Vector<const ast::StructMember*, 8> ast_members;
|
||||
ast_members.Reserve(str->Members().size());
|
||||
ast_members.Reserve(str->Members().Length());
|
||||
for (auto& m : str->Members()) {
|
||||
ast_members.Push(
|
||||
b.Member(ctx.Clone(m->Name()), CreateASTTypeFor(ctx, m->Type())));
|
||||
|
||||
@@ -117,7 +117,7 @@ Transform::ApplyResult NumWorkgroupsFromUniform::Apply(const Program* src,
|
||||
ctx.Remove(str->Declaration()->members, member->Declaration());
|
||||
|
||||
// If this is the only member, remove the struct and parameter too.
|
||||
if (str->Members().size() == 1) {
|
||||
if (str->Members().Length() == 1) {
|
||||
ctx.Remove(func->params, param->Declaration());
|
||||
ctx.Remove(src->AST().GlobalDeclarations(), str->Declaration());
|
||||
}
|
||||
|
||||
@@ -122,8 +122,8 @@ TEST_F(CreateASTTypeForTest, AliasedArrayWithComplexOverrideLength) {
|
||||
TEST_F(CreateASTTypeForTest, Struct) {
|
||||
auto* str = create([](ProgramBuilder& b) {
|
||||
auto* decl = b.Structure("S", {});
|
||||
return b.create<sem::Struct>(decl, decl->source, decl->name, sem::StructMemberList{},
|
||||
4u /* align */, 4u /* size */, 4u /* size_no_padding */);
|
||||
return b.create<sem::Struct>(decl, decl->source, decl->name, utils::Empty, 4u /* align */,
|
||||
4u /* size */, 4u /* size_no_padding */);
|
||||
});
|
||||
ASSERT_TRUE(str->Is<ast::TypeName>());
|
||||
EXPECT_EQ(ast_type_builder.Symbols().NameFor(str->As<ast::TypeName>()->name), "S");
|
||||
|
||||
Reference in New Issue
Block a user