Add Symbol to struct type.
This CL adds a Symbol to the struct type along side the name. The name will be removed in a future CL when the symbol is used everywhere. Change-Id: I6c355908651ba0a155a1e0c9ed1192313a405568 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/35620 Commit-Queue: dan sinclair <dsinclair@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com> Auto-Submit: dan sinclair <dsinclair@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
2abecbba16
commit
24bbbbb25f
|
@ -108,7 +108,7 @@ TEST_F(ModuleTest, IsValid_Null_Alias) {
|
||||||
|
|
||||||
TEST_F(ModuleTest, IsValid_Struct) {
|
TEST_F(ModuleTest, IsValid_Struct) {
|
||||||
type::F32 f32;
|
type::F32 f32;
|
||||||
type::Struct st("name", {});
|
type::Struct st(mod.RegisterSymbol("name"), "name", {});
|
||||||
type::Alias alias(mod.RegisterSymbol("name"), "name", &st);
|
type::Alias alias(mod.RegisterSymbol("name"), "name", &st);
|
||||||
|
|
||||||
Module m;
|
Module m;
|
||||||
|
@ -118,7 +118,7 @@ TEST_F(ModuleTest, IsValid_Struct) {
|
||||||
|
|
||||||
TEST_F(ModuleTest, IsValid_Struct_EmptyName) {
|
TEST_F(ModuleTest, IsValid_Struct_EmptyName) {
|
||||||
type::F32 f32;
|
type::F32 f32;
|
||||||
type::Struct st("", {});
|
type::Struct st(mod.RegisterSymbol(""), "", {});
|
||||||
type::Alias alias(mod.RegisterSymbol("name"), "name", &st);
|
type::Alias alias(mod.RegisterSymbol("name"), "name", &st);
|
||||||
|
|
||||||
Module m;
|
Module m;
|
||||||
|
|
|
@ -135,7 +135,7 @@ TEST_F(AccessControlTest, MinBufferBindingSizeStruct) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str);
|
||||||
AccessControl at{ast::AccessControl::kReadOnly, &struct_type};
|
AccessControl at{ast::AccessControl::kReadOnly, &struct_type};
|
||||||
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, at.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(8u, at.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(8u, at.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
||||||
|
@ -180,7 +180,7 @@ TEST_F(AccessControlTest, BaseAlignmentStruct) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str);
|
||||||
AccessControl at{ast::AccessControl::kReadOnly, &struct_type};
|
AccessControl at{ast::AccessControl::kReadOnly, &struct_type};
|
||||||
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, at.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(4u, at.BaseAlignment(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(4u, at.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||||
|
|
|
@ -208,7 +208,7 @@ TEST_F(AliasTest, MinBufferBindingSizeStruct) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str);
|
||||||
Alias alias{mod.RegisterSymbol("alias"), "alias", &struct_type};
|
Alias alias{mod.RegisterSymbol("alias"), "alias", &struct_type};
|
||||||
EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, alias.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(8u, alias.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(8u, alias.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
||||||
|
@ -257,7 +257,7 @@ TEST_F(AliasTest, BaseAlignmentStruct) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str);
|
||||||
Alias alias{mod.RegisterSymbol("alias"), "alias", &struct_type};
|
Alias alias{mod.RegisterSymbol("alias"), "alias", &struct_type};
|
||||||
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
|
EXPECT_EQ(16u, alias.BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(4u, alias.BaseAlignment(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(4u, alias.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||||
|
|
|
@ -30,15 +30,15 @@ namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
namespace type {
|
namespace type {
|
||||||
|
|
||||||
Struct::Struct(const std::string& name, ast::Struct* impl)
|
Struct::Struct(const Symbol& sym, const std::string& name, ast::Struct* impl)
|
||||||
: name_(name), struct_(impl) {}
|
: symbol_(sym), name_(name), struct_(impl) {}
|
||||||
|
|
||||||
Struct::Struct(Struct&&) = default;
|
Struct::Struct(Struct&&) = default;
|
||||||
|
|
||||||
Struct::~Struct() = default;
|
Struct::~Struct() = default;
|
||||||
|
|
||||||
std::string Struct::type_name() const {
|
std::string Struct::type_name() const {
|
||||||
return "__struct_" + name_;
|
return "__struct_" + symbol_.to_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64_t Struct::MinBufferBindingSize(MemoryLayout mem_layout) const {
|
uint64_t Struct::MinBufferBindingSize(MemoryLayout mem_layout) const {
|
||||||
|
@ -84,7 +84,7 @@ uint64_t Struct::BaseAlignment(MemoryLayout mem_layout) const {
|
||||||
}
|
}
|
||||||
|
|
||||||
Struct* Struct::Clone(CloneContext* ctx) const {
|
Struct* Struct::Clone(CloneContext* ctx) const {
|
||||||
return ctx->mod->create<Struct>(name_, ctx->Clone(struct_));
|
return ctx->mod->create<Struct>(symbol_, name_, ctx->Clone(struct_));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace type
|
} // namespace type
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
#include "src/ast/struct.h"
|
#include "src/ast/struct.h"
|
||||||
#include "src/ast/type/type.h"
|
#include "src/ast/type/type.h"
|
||||||
|
#include "src/symbol.h"
|
||||||
|
|
||||||
namespace tint {
|
namespace tint {
|
||||||
namespace ast {
|
namespace ast {
|
||||||
|
@ -29,13 +30,16 @@ namespace type {
|
||||||
class Struct : public Castable<Struct, Type> {
|
class Struct : public Castable<Struct, Type> {
|
||||||
public:
|
public:
|
||||||
/// Constructor
|
/// Constructor
|
||||||
|
/// @param sym the symbol representing the struct
|
||||||
/// @param name the name of the struct
|
/// @param name the name of the struct
|
||||||
/// @param impl the struct data
|
/// @param impl the struct data
|
||||||
Struct(const std::string& name, ast::Struct* impl);
|
Struct(const Symbol& sym, const std::string& name, ast::Struct* impl);
|
||||||
/// Move constructor
|
/// Move constructor
|
||||||
Struct(Struct&&);
|
Struct(Struct&&);
|
||||||
~Struct() override;
|
~Struct() override;
|
||||||
|
|
||||||
|
/// @returns the struct symbol
|
||||||
|
const Symbol& symbol() const { return symbol_; }
|
||||||
/// @returns the struct name
|
/// @returns the struct name
|
||||||
const std::string& name() const { return name_; }
|
const std::string& name() const { return name_; }
|
||||||
|
|
||||||
|
@ -64,6 +68,7 @@ class Struct : public Castable<Struct, Type> {
|
||||||
Struct* Clone(CloneContext* ctx) const override;
|
Struct* Clone(CloneContext* ctx) const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Symbol symbol_;
|
||||||
std::string name_;
|
std::string name_;
|
||||||
ast::Struct* struct_ = nullptr;
|
ast::Struct* struct_ = nullptr;
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ TEST_F(StructTest, Creation) {
|
||||||
auto* impl =
|
auto* impl =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
auto* ptr = impl;
|
auto* ptr = impl;
|
||||||
Struct s{"S", impl};
|
Struct s{mod.RegisterSymbol("S"), "S", impl};
|
||||||
EXPECT_EQ(s.impl(), ptr);
|
EXPECT_EQ(s.impl(), ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ TEST_F(StructTest, Is) {
|
||||||
StructMemberList members;
|
StructMemberList members;
|
||||||
auto* impl =
|
auto* impl =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
Struct s{"S", impl};
|
Struct s{mod.RegisterSymbol("S"), "S", impl};
|
||||||
Type* ty = &s;
|
Type* ty = &s;
|
||||||
EXPECT_FALSE(ty->Is<AccessControl>());
|
EXPECT_FALSE(ty->Is<AccessControl>());
|
||||||
EXPECT_FALSE(ty->Is<Alias>());
|
EXPECT_FALSE(ty->Is<Alias>());
|
||||||
|
@ -73,8 +73,8 @@ TEST_F(StructTest, TypeName) {
|
||||||
StructMemberList members;
|
StructMemberList members;
|
||||||
auto* impl =
|
auto* impl =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
Struct s{"my_struct", impl};
|
Struct s{mod.RegisterSymbol("my_struct"), "my_struct", impl};
|
||||||
EXPECT_EQ(s.type_name(), "__struct_my_struct");
|
EXPECT_EQ(s.type_name(), "__struct_tint_symbol_1");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(StructTest, MinBufferBindingSize) {
|
TEST_F(StructTest, MinBufferBindingSize) {
|
||||||
|
@ -94,7 +94,7 @@ TEST_F(StructTest, MinBufferBindingSize) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str);
|
||||||
EXPECT_EQ(16u,
|
EXPECT_EQ(16u,
|
||||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(8u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(8u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
||||||
|
@ -124,7 +124,7 @@ TEST_F(StructTest, MinBufferBindingSizeArray) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str);
|
||||||
EXPECT_EQ(32u,
|
EXPECT_EQ(32u,
|
||||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(24u,
|
EXPECT_EQ(24u,
|
||||||
|
@ -155,7 +155,7 @@ TEST_F(StructTest, MinBufferBindingSizeRuntimeArray) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str);
|
||||||
EXPECT_EQ(12u,
|
EXPECT_EQ(12u,
|
||||||
struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
||||||
}
|
}
|
||||||
|
@ -173,7 +173,7 @@ TEST_F(StructTest, MinBufferBindingSizeVec2) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str);
|
||||||
EXPECT_EQ(16u,
|
EXPECT_EQ(16u,
|
||||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(8u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(8u, struct_type.MinBufferBindingSize(MemoryLayout::kStorageBuffer));
|
||||||
|
@ -192,7 +192,7 @@ TEST_F(StructTest, MinBufferBindingSizeVec3) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str);
|
||||||
EXPECT_EQ(16u,
|
EXPECT_EQ(16u,
|
||||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(16u,
|
EXPECT_EQ(16u,
|
||||||
|
@ -212,7 +212,7 @@ TEST_F(StructTest, MinBufferBindingSizeVec4) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str);
|
||||||
EXPECT_EQ(16u,
|
EXPECT_EQ(16u,
|
||||||
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
struct_type.MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||||
EXPECT_EQ(16u,
|
EXPECT_EQ(16u,
|
||||||
|
@ -236,7 +236,7 @@ TEST_F(StructTest, BaseAlignment) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", 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));
|
||||||
}
|
}
|
||||||
|
@ -265,7 +265,7 @@ TEST_F(StructTest, BaseAlignmentArray) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", 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));
|
||||||
}
|
}
|
||||||
|
@ -294,7 +294,7 @@ TEST_F(StructTest, BaseAlignmentRuntimeArray) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", str);
|
||||||
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
EXPECT_EQ(4u, struct_type.BaseAlignment(MemoryLayout::kStorageBuffer));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -311,7 +311,7 @@ TEST_F(StructTest, BaseAlignmentVec2) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", 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));
|
||||||
}
|
}
|
||||||
|
@ -329,7 +329,7 @@ TEST_F(StructTest, BaseAlignmentVec3) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", 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));
|
||||||
}
|
}
|
||||||
|
@ -347,7 +347,7 @@ TEST_F(StructTest, BaseAlignmentVec4) {
|
||||||
StructDecorationList decos;
|
StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
Struct struct_type("struct_type", str);
|
Struct struct_type(mod.RegisterSymbol("struct_type"), "struct_type", 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));
|
||||||
}
|
}
|
||||||
|
|
|
@ -310,7 +310,8 @@ class InspectorHelper {
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
|
|
||||||
return std::make_unique<ast::type::Struct>(name, str);
|
return std::make_unique<ast::type::Struct>(mod()->RegisterSymbol(name),
|
||||||
|
name, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates types appropriate for using in an uniform buffer
|
/// Generates types appropriate for using in an uniform buffer
|
||||||
|
@ -1455,7 +1456,8 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingBlockDeco) {
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
auto foo_type = std::make_unique<ast::type::Struct>("foo_type", str);
|
auto foo_type = std::make_unique<ast::type::Struct>(
|
||||||
|
mod()->RegisterSymbol("foo_type"), "foo_type", str);
|
||||||
|
|
||||||
AddUniformBuffer("foo_ub", foo_type.get(), 0, 0);
|
AddUniformBuffer("foo_ub", foo_type.get(), 0, 0);
|
||||||
|
|
||||||
|
|
|
@ -952,8 +952,9 @@ ast::type::Type* ParserImpl::ConvertType(
|
||||||
|
|
||||||
namer_.SuggestSanitizedName(type_id, "S");
|
namer_.SuggestSanitizedName(type_id, "S");
|
||||||
|
|
||||||
auto* result = ast_module_.create<ast::type::Struct>(namer_.GetName(type_id),
|
auto name = namer_.GetName(type_id);
|
||||||
ast_struct);
|
auto* result = ast_module_.create<ast::type::Struct>(
|
||||||
|
ast_module_.RegisterSymbol(name), name, ast_struct);
|
||||||
id_to_type_[type_id] = result;
|
id_to_type_[type_id] = result;
|
||||||
if (num_non_writable_members == members.size()) {
|
if (num_non_writable_members == members.size()) {
|
||||||
read_only_struct_types_.insert(result);
|
read_only_struct_types_.insert(result);
|
||||||
|
|
|
@ -1059,7 +1059,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StructInitializer) {
|
||||||
)"));
|
)"));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str = p->module().to_str();
|
const auto module_str =
|
||||||
|
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1088,7 +1089,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StructNullInitializer) {
|
||||||
)"));
|
)"));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str = p->module().to_str();
|
const auto module_str =
|
||||||
|
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1117,7 +1119,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StructUndefInitializer) {
|
||||||
)"));
|
)"));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str = p->module().to_str();
|
const auto module_str =
|
||||||
|
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
EXPECT_THAT(module_str, HasSubstr(R"(Variable{
|
||||||
x_200
|
x_200
|
||||||
private
|
private
|
||||||
|
@ -1200,7 +1203,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_DescriptorSetDecoration_Valid) {
|
||||||
)"));
|
)"));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str = p->module().to_str();
|
const auto module_str =
|
||||||
|
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
Variable{
|
Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -1254,7 +1258,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_BindingDecoration_Valid) {
|
||||||
)"));
|
)"));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str = p->module().to_str();
|
const auto module_str =
|
||||||
|
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
Variable{
|
Variable{
|
||||||
Decorations{
|
Decorations{
|
||||||
|
@ -1309,7 +1314,8 @@ TEST_F(SpvParserTest,
|
||||||
)"));
|
)"));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions());
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str = p->module().to_str();
|
const auto module_str =
|
||||||
|
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
S Struct{
|
S Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
|
@ -1340,7 +1346,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_ColMajorDecoration_Dropped) {
|
||||||
)"));
|
)"));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str = p->module().to_str();
|
const auto module_str =
|
||||||
|
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
S Struct{
|
S Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
|
@ -1369,7 +1376,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_MatrixStrideDecoration_Dropped) {
|
||||||
)"));
|
)"));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str = p->module().to_str();
|
const auto module_str =
|
||||||
|
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
S Struct{
|
S Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
|
@ -1418,7 +1426,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StorageBuffer_NonWritable_AllMembers) {
|
||||||
)"));
|
)"));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str = p->module().to_str();
|
const auto module_str =
|
||||||
|
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
S Struct{
|
S Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
|
@ -1447,7 +1456,8 @@ TEST_F(SpvParserTest, ModuleScopeVar_StorageBuffer_NonWritable_NotAllMembers) {
|
||||||
)"));
|
)"));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str = p->module().to_str();
|
const auto module_str =
|
||||||
|
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
S Struct{
|
S Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
|
@ -1479,7 +1489,8 @@ TEST_F(
|
||||||
)"));
|
)"));
|
||||||
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
ASSERT_TRUE(p->BuildAndParseInternalModuleExceptFunctions()) << p->error();
|
||||||
EXPECT_TRUE(p->error().empty());
|
EXPECT_TRUE(p->error().empty());
|
||||||
const auto module_str = p->module().to_str();
|
const auto module_str =
|
||||||
|
Demangler().Demangle(p->get_module(), p->get_module().to_str());
|
||||||
EXPECT_THAT(module_str, HasSubstr(R"(
|
EXPECT_THAT(module_str, HasSubstr(R"(
|
||||||
S Struct{
|
S Struct{
|
||||||
[[block]]
|
[[block]]
|
||||||
|
|
|
@ -1192,7 +1192,8 @@ Maybe<std::unique_ptr<ast::type::Struct>> ParserImpl::struct_decl(
|
||||||
return Failure::kErrored;
|
return Failure::kErrored;
|
||||||
|
|
||||||
return std::make_unique<ast::type::Struct>(
|
return std::make_unique<ast::type::Struct>(
|
||||||
name.value, create<ast::Struct>(source, std::move(body.value),
|
module_.RegisterSymbol(name.value), name.value,
|
||||||
|
create<ast::Struct>(source, std::move(body.value),
|
||||||
std::move(struct_decos.value)));
|
std::move(struct_decos.value)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,9 +43,9 @@ TEST_F(ParserImplTest, TypeDecl_ParsesType) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
|
TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
|
||||||
ast::type::Struct str("B", {});
|
|
||||||
|
|
||||||
auto p = parser("type a = B");
|
auto p = parser("type a = B");
|
||||||
|
|
||||||
|
ast::type::Struct str(p->get_module().RegisterSymbol("B"), "B", {});
|
||||||
p->register_constructed("B", &str);
|
p->register_constructed("B", &str);
|
||||||
|
|
||||||
auto t = p->type_alias();
|
auto t = p->type_alias();
|
||||||
|
@ -59,6 +59,7 @@ TEST_F(ParserImplTest, TypeDecl_ParsesStruct_Ident) {
|
||||||
ASSERT_TRUE(alias->type()->Is<ast::type::Struct>());
|
ASSERT_TRUE(alias->type()->Is<ast::type::Struct>());
|
||||||
|
|
||||||
auto* s = alias->type()->As<ast::type::Struct>();
|
auto* s = alias->type()->As<ast::type::Struct>();
|
||||||
|
EXPECT_EQ(s->symbol(), p->get_module().RegisterSymbol("B"));
|
||||||
EXPECT_EQ(s->name(), "B");
|
EXPECT_EQ(s->name(), "B");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,6 +85,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_InvalidType) {
|
||||||
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
||||||
ast::type::I32 i32;
|
ast::type::I32 i32;
|
||||||
|
|
||||||
|
auto p = parser("my_var : [[access(read)]] S");
|
||||||
|
|
||||||
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
||||||
ast::StructMemberList members;
|
ast::StructMemberList members;
|
||||||
members.push_back(&mem);
|
members.push_back(&mem);
|
||||||
|
@ -94,9 +96,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
||||||
decos.push_back(&block_deco);
|
decos.push_back(&block_deco);
|
||||||
|
|
||||||
ast::Struct str(Source{}, members, decos);
|
ast::Struct str(Source{}, members, decos);
|
||||||
ast::type::Struct s("S", &str);
|
ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str);
|
||||||
|
|
||||||
auto p = parser("my_var : [[access(read)]] S");
|
|
||||||
p->register_constructed("S", &s);
|
p->register_constructed("S", &s);
|
||||||
|
|
||||||
auto decl = p->expect_variable_ident_decl("test");
|
auto decl = p->expect_variable_ident_decl("test");
|
||||||
|
@ -111,6 +112,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
||||||
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
||||||
ast::type::I32 i32;
|
ast::type::I32 i32;
|
||||||
|
|
||||||
|
auto p = parser("my_var : [[access(read_write)]] S");
|
||||||
|
|
||||||
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
||||||
ast::StructMemberList members;
|
ast::StructMemberList members;
|
||||||
members.push_back(&mem);
|
members.push_back(&mem);
|
||||||
|
@ -120,9 +123,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
||||||
decos.push_back(&block_deco);
|
decos.push_back(&block_deco);
|
||||||
|
|
||||||
ast::Struct str(Source{}, members, decos);
|
ast::Struct str(Source{}, members, decos);
|
||||||
ast::type::Struct s("S", &str);
|
ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str);
|
||||||
|
|
||||||
auto p = parser("my_var : [[access(read_write)]] S");
|
|
||||||
p->register_constructed("S", &s);
|
p->register_constructed("S", &s);
|
||||||
|
|
||||||
auto decl = p->expect_variable_ident_decl("test");
|
auto decl = p->expect_variable_ident_decl("test");
|
||||||
|
@ -137,6 +139,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
||||||
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
|
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
|
||||||
ast::type::I32 i32;
|
ast::type::I32 i32;
|
||||||
|
|
||||||
|
auto p = parser("my_var : [[access(read), access(read_write)]] S");
|
||||||
|
|
||||||
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
||||||
ast::StructMemberList members;
|
ast::StructMemberList members;
|
||||||
members.push_back(&mem);
|
members.push_back(&mem);
|
||||||
|
@ -146,9 +150,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
|
||||||
decos.push_back(&block_deco);
|
decos.push_back(&block_deco);
|
||||||
|
|
||||||
ast::Struct str(Source{}, members, decos);
|
ast::Struct str(Source{}, members, decos);
|
||||||
ast::type::Struct s("S", &str);
|
ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str);
|
||||||
|
|
||||||
auto p = parser("my_var : [[access(read), access(read_write)]] S");
|
|
||||||
p->register_constructed("S", &s);
|
p->register_constructed("S", &s);
|
||||||
|
|
||||||
auto decl = p->expect_variable_ident_decl("test");
|
auto decl = p->expect_variable_ident_decl("test");
|
||||||
|
@ -160,6 +163,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
|
||||||
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) {
|
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) {
|
||||||
ast::type::I32 i32;
|
ast::type::I32 i32;
|
||||||
|
|
||||||
|
auto p = parser("my_var : [[access(read)]][[access(read_write)]] S");
|
||||||
|
|
||||||
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
||||||
ast::StructMemberList members;
|
ast::StructMemberList members;
|
||||||
members.push_back(&mem);
|
members.push_back(&mem);
|
||||||
|
@ -169,9 +174,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) {
|
||||||
decos.push_back(&block_deco);
|
decos.push_back(&block_deco);
|
||||||
|
|
||||||
ast::Struct str(Source{}, members, decos);
|
ast::Struct str(Source{}, members, decos);
|
||||||
ast::type::Struct s("S", &str);
|
ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str);
|
||||||
|
|
||||||
auto p = parser("my_var : [[access(read)]][[access(read_write)]] S");
|
|
||||||
p->register_constructed("S", &s);
|
p->register_constructed("S", &s);
|
||||||
|
|
||||||
auto decl = p->expect_variable_ident_decl("test");
|
auto decl = p->expect_variable_ident_decl("test");
|
||||||
|
@ -199,6 +203,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_AccessDecoIllegalValue) {
|
||||||
TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) {
|
TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) {
|
||||||
ast::type::I32 i32;
|
ast::type::I32 i32;
|
||||||
|
|
||||||
|
auto p = parser("my_var : [[stride(1)]] S");
|
||||||
|
|
||||||
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
ast::StructMember mem(Source{}, "a", &i32, ast::StructMemberDecorationList{});
|
||||||
ast::StructMemberList members;
|
ast::StructMemberList members;
|
||||||
members.push_back(&mem);
|
members.push_back(&mem);
|
||||||
|
@ -208,9 +214,8 @@ TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) {
|
||||||
decos.push_back(&block_deco);
|
decos.push_back(&block_deco);
|
||||||
|
|
||||||
ast::Struct str(Source{}, members, decos);
|
ast::Struct str(Source{}, members, decos);
|
||||||
ast::type::Struct s("S", &str);
|
ast::type::Struct s(p->get_module().RegisterSymbol("S"), "S", &str);
|
||||||
|
|
||||||
auto p = parser("my_var : [[stride(1)]] S");
|
|
||||||
p->register_constructed("S", &s);
|
p->register_constructed("S", &s);
|
||||||
|
|
||||||
auto decl = p->expect_variable_ident_decl("test");
|
auto decl = p->expect_variable_ident_decl("test");
|
||||||
|
|
|
@ -224,7 +224,7 @@ ast::Variable* FirstIndexOffset::AddUniformBuffer(ast::Module* mod) {
|
||||||
decos.push_back(mod->create<ast::StructBlockDecoration>(Source{}));
|
decos.push_back(mod->create<ast::StructBlockDecoration>(Source{}));
|
||||||
|
|
||||||
auto* struct_type = mod->create<ast::type::Struct>(
|
auto* struct_type = mod->create<ast::type::Struct>(
|
||||||
kStructName,
|
mod->RegisterSymbol(kStructName), kStructName,
|
||||||
mod->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
|
mod->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
|
||||||
|
|
||||||
auto* idx_var = mod->create<ast::Variable>(
|
auto* idx_var = mod->create<ast::Variable>(
|
||||||
|
|
|
@ -264,7 +264,7 @@ void VertexPulling::State::AddVertexStorageBuffers() {
|
||||||
decos.push_back(mod->create<ast::StructBlockDecoration>(Source{}));
|
decos.push_back(mod->create<ast::StructBlockDecoration>(Source{}));
|
||||||
|
|
||||||
auto* struct_type = mod->create<ast::type::Struct>(
|
auto* struct_type = mod->create<ast::type::Struct>(
|
||||||
kStructName,
|
mod->RegisterSymbol(kStructName), kStructName,
|
||||||
mod->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
|
mod->create<ast::Struct>(Source{}, std::move(members), std::move(decos)));
|
||||||
|
|
||||||
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
|
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
|
||||||
|
|
|
@ -1218,7 +1218,7 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) {
|
||||||
auto* strct =
|
auto* strct =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct st("S", strct);
|
ast::type::Struct st(mod->RegisterSymbol("S"), "S", strct);
|
||||||
|
|
||||||
auto* var =
|
auto* var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -1262,7 +1262,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) {
|
||||||
auto* strct =
|
auto* strct =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
auto st = std::make_unique<ast::type::Struct>("alias", strct);
|
auto st = std::make_unique<ast::type::Struct>(mod->RegisterSymbol("alias"),
|
||||||
|
"alias", strct);
|
||||||
ast::type::Alias alias(mod->RegisterSymbol("alias"), "alias", st.get());
|
ast::type::Alias alias(mod->RegisterSymbol("alias"), "alias", st.get());
|
||||||
|
|
||||||
auto* var =
|
auto* var =
|
||||||
|
@ -1391,7 +1392,7 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) {
|
||||||
|
|
||||||
auto* strctB =
|
auto* strctB =
|
||||||
create<ast::Struct>(Source{}, b_members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, b_members, ast::StructDecorationList{});
|
||||||
ast::type::Struct stB("B", strctB);
|
ast::type::Struct stB(mod->RegisterSymbol("B"), "B", strctB);
|
||||||
|
|
||||||
ast::type::Vector vecB(&stB, 3);
|
ast::type::Vector vecB(&stB, 3);
|
||||||
|
|
||||||
|
@ -1401,7 +1402,7 @@ TEST_F(TypeDeterminerTest, Expr_Accessor_MultiLevel) {
|
||||||
auto* strctA =
|
auto* strctA =
|
||||||
create<ast::Struct>(Source{}, a_members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, a_members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct stA("A", strctA);
|
ast::type::Struct stA(mod->RegisterSymbol("A"), "A", strctA);
|
||||||
|
|
||||||
auto* var =
|
auto* var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
|
|
@ -57,7 +57,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLast_Pass) {
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
||||||
auto* st = create<ast::Struct>(Source{}, members, decos);
|
auto* st = create<ast::Struct>(Source{}, members, decos);
|
||||||
ast::type::Struct struct_type("Foo", st);
|
ast::type::Struct struct_type(mod()->RegisterSymbol("Foo"), "Foo", st);
|
||||||
|
|
||||||
mod()->AddConstructedType(&struct_type);
|
mod()->AddConstructedType(&struct_type);
|
||||||
EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types()));
|
EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types()));
|
||||||
|
@ -83,7 +83,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) {
|
||||||
}
|
}
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
auto* st = create<ast::Struct>(Source{}, members, decos);
|
auto* st = create<ast::Struct>(Source{}, members, decos);
|
||||||
ast::type::Struct struct_type("Foo", st);
|
ast::type::Struct struct_type(mod()->RegisterSymbol("Foo"), "Foo", st);
|
||||||
|
|
||||||
mod()->AddConstructedType(&struct_type);
|
mod()->AddConstructedType(&struct_type);
|
||||||
EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types()));
|
EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types()));
|
||||||
|
@ -114,7 +114,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) {
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
||||||
auto* st = create<ast::Struct>(Source{}, members, decos);
|
auto* st = create<ast::Struct>(Source{}, members, decos);
|
||||||
ast::type::Struct struct_type("Foo", st);
|
ast::type::Struct struct_type(mod()->RegisterSymbol("Foo"), "Foo", st);
|
||||||
|
|
||||||
mod()->AddConstructedType(&struct_type);
|
mod()->AddConstructedType(&struct_type);
|
||||||
EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types()));
|
EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types()));
|
||||||
|
@ -149,7 +149,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsNotLast_Fail) {
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
||||||
auto* st = create<ast::Struct>(Source{}, members, decos);
|
auto* st = create<ast::Struct>(Source{}, members, decos);
|
||||||
ast::type::Struct struct_type("s", st);
|
ast::type::Struct struct_type(mod()->RegisterSymbol("s"), "s", st);
|
||||||
mod()->AddConstructedType(&struct_type);
|
mod()->AddConstructedType(&struct_type);
|
||||||
EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types()));
|
EXPECT_FALSE(v()->ValidateConstructedTypes(mod()->constructed_types()));
|
||||||
EXPECT_EQ(v()->error(),
|
EXPECT_EQ(v()->error(),
|
||||||
|
@ -182,7 +182,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) {
|
||||||
ast::StructDecorationList decos;
|
ast::StructDecorationList decos;
|
||||||
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
||||||
auto* st = create<ast::Struct>(Source{}, members, decos);
|
auto* st = create<ast::Struct>(Source{}, members, decos);
|
||||||
ast::type::Struct struct_type("s", st);
|
ast::type::Struct struct_type(mod()->RegisterSymbol("s"), "s", st);
|
||||||
mod()->AddConstructedType(&struct_type);
|
mod()->AddConstructedType(&struct_type);
|
||||||
EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types()));
|
EXPECT_TRUE(v()->ValidateConstructedTypes(mod()->constructed_types()));
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_Struct) {
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("A", str);
|
ast::type::Struct s(mod.RegisterSymbol("A"), "A", str);
|
||||||
ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s);
|
ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitConstructedType(out, &alias)) << gen.error();
|
ASSERT_TRUE(gen.EmitConstructedType(out, &alias)) << gen.error();
|
||||||
|
|
|
@ -358,7 +358,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Uniforms", str);
|
ast::type::Struct s(mod.RegisterSymbol("Uniforms"), "Uniforms", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -443,7 +443,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
|
@ -519,7 +519,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s);
|
ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
|
@ -595,7 +595,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
|
@ -1371,7 +1371,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, s_decos);
|
auto* str = create<ast::Struct>(Source{}, members, s_decos);
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||||
|
|
||||||
auto* data_var =
|
auto* data_var =
|
||||||
|
|
|
@ -56,7 +56,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
|
||||||
auto* strct =
|
auto* strct =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Str", strct);
|
ast::type::Struct s(mod.RegisterSymbol("Str"), "Str", strct);
|
||||||
|
|
||||||
auto* str_var =
|
auto* str_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -108,7 +108,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -162,7 +162,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -221,7 +221,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* b_var =
|
auto* b_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -298,7 +298,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -363,7 +363,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -424,7 +424,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -477,7 +477,7 @@ TEST_F(
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -534,7 +534,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -595,7 +595,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -652,7 +652,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -719,7 +719,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -777,7 +777,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -840,7 +840,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -901,7 +901,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -958,7 +958,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -1034,7 +1034,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct data("Data", data_str);
|
ast::type::Struct data(mod.RegisterSymbol("Data"), "Data", data_str);
|
||||||
|
|
||||||
ast::type::Array ary(&data, 4,
|
ast::type::Array ary(&data, 4,
|
||||||
ast::ArrayDecorationList{
|
ast::ArrayDecorationList{
|
||||||
|
@ -1051,7 +1051,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct pre_struct("Pre", pre_str);
|
ast::type::Struct pre_struct(mod.RegisterSymbol("Pre"), "Pre", pre_str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -1125,7 +1125,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct data("Data", data_str);
|
ast::type::Struct data(mod.RegisterSymbol("Data"), "Data", data_str);
|
||||||
|
|
||||||
ast::type::Array ary(
|
ast::type::Array ary(
|
||||||
&data, 4,
|
&data, 4,
|
||||||
|
@ -1139,7 +1139,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
create<ast::StructMemberOffsetDecoration>(0, Source{})})},
|
create<ast::StructMemberOffsetDecoration>(0, Source{})})},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct pre_struct("Pre", pre_str);
|
ast::type::Struct pre_struct(mod.RegisterSymbol("Pre"), "Pre", pre_str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -1215,7 +1215,7 @@ TEST_F(
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct data("Data", data_str);
|
ast::type::Struct data(mod.RegisterSymbol("Data"), "Data", data_str);
|
||||||
|
|
||||||
ast::type::Array ary(&data, 4,
|
ast::type::Array ary(&data, 4,
|
||||||
ast::ArrayDecorationList{
|
ast::ArrayDecorationList{
|
||||||
|
@ -1230,7 +1230,7 @@ TEST_F(
|
||||||
create<ast::StructMemberOffsetDecoration>(0, Source{})})},
|
create<ast::StructMemberOffsetDecoration>(0, Source{})})},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct pre_struct("Pre", pre_str);
|
ast::type::Struct pre_struct(mod.RegisterSymbol("Pre"), "Pre", pre_str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -1305,7 +1305,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct data("Data", data_str);
|
ast::type::Struct data(mod.RegisterSymbol("Data"), "Data", data_str);
|
||||||
|
|
||||||
ast::type::Array ary(&data, 4,
|
ast::type::Array ary(&data, 4,
|
||||||
ast::ArrayDecorationList{
|
ast::ArrayDecorationList{
|
||||||
|
@ -1320,7 +1320,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
create<ast::StructMemberOffsetDecoration>(0, Source{})})},
|
create<ast::StructMemberOffsetDecoration>(0, Source{})})},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct pre_struct("Pre", pre_str);
|
ast::type::Struct pre_struct(mod.RegisterSymbol("Pre"), "Pre", pre_str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -1395,7 +1395,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct data("Data", data_str);
|
ast::type::Struct data(mod.RegisterSymbol("Data"), "Data", data_str);
|
||||||
|
|
||||||
ast::type::Array ary(&data, 4,
|
ast::type::Array ary(&data, 4,
|
||||||
ast::ArrayDecorationList{
|
ast::ArrayDecorationList{
|
||||||
|
@ -1410,7 +1410,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
create<ast::StructMemberOffsetDecoration>(0, Source{})})},
|
create<ast::StructMemberOffsetDecoration>(0, Source{})})},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct pre_struct("Pre", pre_str);
|
ast::type::Struct pre_struct(mod.RegisterSymbol("Pre"), "Pre", pre_str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
@ -1495,7 +1495,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct data("Data", data_str);
|
ast::type::Struct data(mod.RegisterSymbol("Data"), "Data", data_str);
|
||||||
|
|
||||||
ast::type::Array ary(&data, 4,
|
ast::type::Array ary(&data, 4,
|
||||||
ast::ArrayDecorationList{
|
ast::ArrayDecorationList{
|
||||||
|
@ -1510,7 +1510,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
||||||
create<ast::StructMemberOffsetDecoration>(0, Source{})})},
|
create<ast::StructMemberOffsetDecoration>(0, Source{})})},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct pre_struct("Pre", pre_str);
|
ast::type::Struct pre_struct(mod.RegisterSymbol("Pre"), "Pre", pre_str);
|
||||||
|
|
||||||
auto* coord_var =
|
auto* coord_var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
|
|
@ -184,7 +184,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitStructType(out, &s, "S")) << gen.error();
|
ASSERT_TRUE(gen.EmitStructType(out, &s, "S")) << gen.error();
|
||||||
EXPECT_EQ(result(), R"(struct S {
|
EXPECT_EQ(result(), R"(struct S {
|
||||||
|
@ -209,7 +209,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
|
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
|
||||||
EXPECT_EQ(result(), "S");
|
EXPECT_EQ(result(), "S");
|
||||||
|
@ -234,7 +234,7 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_InjectPadding) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
|
ASSERT_TRUE(gen.EmitType(out, &s, "")) << gen.error();
|
||||||
EXPECT_EQ(result(), R"(struct {
|
EXPECT_EQ(result(), R"(struct {
|
||||||
|
@ -261,7 +261,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitStructType(out, &s, "S")) << gen.error();
|
ASSERT_TRUE(gen.EmitStructType(out, &s, "S")) << gen.error();
|
||||||
EXPECT_EQ(result(), R"(struct S {
|
EXPECT_EQ(result(), R"(struct S {
|
||||||
|
@ -289,7 +289,7 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_WithDecoration) {
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitStructType(out, &s, "B")) << gen.error();
|
ASSERT_TRUE(gen.EmitStructType(out, &s, "B")) << gen.error();
|
||||||
EXPECT_EQ(result(), R"(struct B {
|
EXPECT_EQ(result(), R"(struct B {
|
||||||
|
|
|
@ -64,7 +64,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_Struct) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("a", str);
|
ast::type::Struct s(mod.RegisterSymbol("a"), "a", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitConstructedType(&s)) << gen.error();
|
ASSERT_TRUE(gen.EmitConstructedType(&s)) << gen.error();
|
||||||
EXPECT_EQ(gen.result(), R"(struct a {
|
EXPECT_EQ(gen.result(), R"(struct a {
|
||||||
|
@ -89,7 +89,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_AliasStructIdent) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("b", str);
|
ast::type::Struct s(mod.RegisterSymbol("b"), "b", str);
|
||||||
ast::type::Alias alias(mod.RegisterSymbol("a"), "a", &s);
|
ast::type::Alias alias(mod.RegisterSymbol("a"), "a", &s);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error();
|
ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error();
|
||||||
|
|
|
@ -374,7 +374,7 @@ TEST_F(MslGeneratorImplTest,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||||
|
|
||||||
mod.AddConstructedType(&s);
|
mod.AddConstructedType(&s);
|
||||||
|
@ -459,7 +459,7 @@ TEST_F(MslGeneratorImplTest,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s);
|
ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s);
|
||||||
|
|
||||||
mod.AddConstructedType(&s);
|
mod.AddConstructedType(&s);
|
||||||
|
@ -973,7 +973,7 @@ TEST_F(MslGeneratorImplTest,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||||
|
|
||||||
mod.AddConstructedType(&s);
|
mod.AddConstructedType(&s);
|
||||||
|
@ -1088,7 +1088,7 @@ TEST_F(MslGeneratorImplTest,
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s);
|
ast::type::AccessControl ac(ast::AccessControl::kReadOnly, &s);
|
||||||
|
|
||||||
mod.AddConstructedType(&s);
|
mod.AddConstructedType(&s);
|
||||||
|
@ -1347,7 +1347,7 @@ TEST_F(MslGeneratorImplTest,
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, s_decos);
|
auto* str = create<ast::Struct>(Source{}, members, s_decos);
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||||
|
|
||||||
auto* data_var =
|
auto* data_var =
|
||||||
|
|
|
@ -174,7 +174,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
EXPECT_EQ(132u, gen.calculate_alignment_size(&s));
|
EXPECT_EQ(132u, gen.calculate_alignment_size(&s));
|
||||||
}
|
}
|
||||||
|
@ -199,7 +199,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) {
|
||||||
auto* inner_str =
|
auto* inner_str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct inner_s("Inner", inner_str);
|
ast::type::Struct inner_s(mod.RegisterSymbol("Inner"), "Inner", inner_str);
|
||||||
|
|
||||||
decos.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{}));
|
decos.push_back(create<ast::StructMemberOffsetDecoration>(0, Source{}));
|
||||||
members.push_back(create<ast::StructMember>(Source{}, "d", &f32, decos));
|
members.push_back(create<ast::StructMember>(Source{}, "d", &f32, decos));
|
||||||
|
@ -213,7 +213,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) {
|
||||||
auto* outer_str =
|
auto* outer_str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct outer_s("Outer", outer_str);
|
ast::type::Struct outer_s(mod.RegisterSymbol("Outer"), "Outer", outer_str);
|
||||||
|
|
||||||
EXPECT_EQ(80u, gen.calculate_alignment_size(&outer_s));
|
EXPECT_EQ(80u, gen.calculate_alignment_size(&outer_s));
|
||||||
}
|
}
|
||||||
|
|
|
@ -185,7 +185,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error();
|
ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error();
|
||||||
EXPECT_EQ(gen.result(), "S");
|
EXPECT_EQ(gen.result(), "S");
|
||||||
|
@ -206,7 +206,7 @@ TEST_F(MslGeneratorImplTest, EmitType_StructDecl) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
|
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
|
||||||
EXPECT_EQ(gen.result(), R"(struct S {
|
EXPECT_EQ(gen.result(), R"(struct S {
|
||||||
|
@ -238,7 +238,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_InjectPadding) {
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
|
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
|
||||||
EXPECT_EQ(gen.result(), R"(struct S {
|
EXPECT_EQ(gen.result(), R"(struct S {
|
||||||
|
@ -266,7 +266,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_NameCollision) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
|
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
|
||||||
EXPECT_EQ(gen.result(), R"(struct S {
|
EXPECT_EQ(gen.result(), R"(struct S {
|
||||||
|
@ -293,7 +293,7 @@ TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Struct_WithDecoration) {
|
||||||
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error();
|
ASSERT_TRUE(gen.EmitType(&s, "")) << gen.error();
|
||||||
EXPECT_EQ(gen.result(), R"(struct {
|
EXPECT_EQ(gen.result(), R"(struct {
|
||||||
|
|
|
@ -113,7 +113,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
auto* var =
|
auto* var =
|
||||||
create<ast::Variable>(Source{}, // source
|
create<ast::Variable>(Source{}, // source
|
||||||
|
|
|
@ -305,7 +305,7 @@ TEST_F(BuilderTest, MemberAccessor) {
|
||||||
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, decos));
|
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, decos));
|
||||||
|
|
||||||
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("my_struct", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s);
|
||||||
|
|
||||||
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type,
|
ast::Variable var(Source{}, "ident", ast::StorageClass::kFunction, &s_type,
|
||||||
false, nullptr, ast::VariableDecorationList{});
|
false, nullptr, ast::VariableDecorationList{});
|
||||||
|
@ -361,14 +361,15 @@ TEST_F(BuilderTest, MemberAccessor_Nested) {
|
||||||
create<ast::StructMember>(Source{}, "b", &f32, decos));
|
create<ast::StructMember>(Source{}, "b", &f32, decos));
|
||||||
|
|
||||||
ast::type::Struct inner_struct(
|
ast::type::Struct inner_struct(
|
||||||
"Inner", create<ast::Struct>(Source{}, inner_members,
|
mod->RegisterSymbol("Inner"), "Inner",
|
||||||
|
create<ast::Struct>(Source{}, inner_members,
|
||||||
ast::StructDecorationList{}));
|
ast::StructDecorationList{}));
|
||||||
|
|
||||||
ast::StructMemberList outer_members;
|
ast::StructMemberList outer_members;
|
||||||
outer_members.push_back(
|
outer_members.push_back(
|
||||||
create<ast::StructMember>(Source{}, "inner", &inner_struct, decos));
|
create<ast::StructMember>(Source{}, "inner", &inner_struct, decos));
|
||||||
|
|
||||||
ast::type::Struct s_type("my_struct",
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct",
|
||||||
create<ast::Struct>(Source{}, outer_members,
|
create<ast::Struct>(Source{}, outer_members,
|
||||||
ast::StructDecorationList{}));
|
ast::StructDecorationList{}));
|
||||||
|
|
||||||
|
@ -432,7 +433,8 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) {
|
||||||
create<ast::StructMember>(Source{}, "b", &f32, decos));
|
create<ast::StructMember>(Source{}, "b", &f32, decos));
|
||||||
|
|
||||||
ast::type::Struct inner_struct(
|
ast::type::Struct inner_struct(
|
||||||
"Inner", create<ast::Struct>(Source{}, inner_members,
|
mod->RegisterSymbol("Inner"), "Inner",
|
||||||
|
create<ast::Struct>(Source{}, inner_members,
|
||||||
ast::StructDecorationList{}));
|
ast::StructDecorationList{}));
|
||||||
|
|
||||||
ast::type::Alias alias(mod->RegisterSymbol("Inner"), "Inner", &inner_struct);
|
ast::type::Alias alias(mod->RegisterSymbol("Inner"), "Inner", &inner_struct);
|
||||||
|
@ -441,7 +443,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) {
|
||||||
outer_members.push_back(
|
outer_members.push_back(
|
||||||
create<ast::StructMember>(Source{}, "inner", &alias, decos));
|
create<ast::StructMember>(Source{}, "inner", &alias, decos));
|
||||||
|
|
||||||
ast::type::Struct s_type("Outer",
|
ast::type::Struct s_type(mod->RegisterSymbol("Outer"), "Outer",
|
||||||
create<ast::Struct>(Source{}, outer_members,
|
create<ast::Struct>(Source{}, outer_members,
|
||||||
ast::StructDecorationList{}));
|
ast::StructDecorationList{}));
|
||||||
|
|
||||||
|
@ -505,14 +507,15 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) {
|
||||||
create<ast::StructMember>(Source{}, "b", &f32, decos));
|
create<ast::StructMember>(Source{}, "b", &f32, decos));
|
||||||
|
|
||||||
ast::type::Struct inner_struct(
|
ast::type::Struct inner_struct(
|
||||||
"Inner", create<ast::Struct>(Source{}, inner_members,
|
mod->RegisterSymbol("Inner"), "Inner",
|
||||||
|
create<ast::Struct>(Source{}, inner_members,
|
||||||
ast::StructDecorationList{}));
|
ast::StructDecorationList{}));
|
||||||
|
|
||||||
ast::StructMemberList outer_members;
|
ast::StructMemberList outer_members;
|
||||||
outer_members.push_back(
|
outer_members.push_back(
|
||||||
create<ast::StructMember>(Source{}, "inner", &inner_struct, decos));
|
create<ast::StructMember>(Source{}, "inner", &inner_struct, decos));
|
||||||
|
|
||||||
ast::type::Struct s_type("my_struct",
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct",
|
||||||
create<ast::Struct>(Source{}, outer_members,
|
create<ast::Struct>(Source{}, outer_members,
|
||||||
ast::StructDecorationList{}));
|
ast::StructDecorationList{}));
|
||||||
|
|
||||||
|
@ -583,14 +586,15 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) {
|
||||||
create<ast::StructMember>(Source{}, "b", &f32, decos));
|
create<ast::StructMember>(Source{}, "b", &f32, decos));
|
||||||
|
|
||||||
ast::type::Struct inner_struct(
|
ast::type::Struct inner_struct(
|
||||||
"Inner", create<ast::Struct>(Source{}, inner_members,
|
mod->RegisterSymbol("Inner"), "Inner",
|
||||||
|
create<ast::Struct>(Source{}, inner_members,
|
||||||
ast::StructDecorationList{}));
|
ast::StructDecorationList{}));
|
||||||
|
|
||||||
ast::StructMemberList outer_members;
|
ast::StructMemberList outer_members;
|
||||||
outer_members.push_back(
|
outer_members.push_back(
|
||||||
create<ast::StructMember>(Source{}, "inner", &inner_struct, decos));
|
create<ast::StructMember>(Source{}, "inner", &inner_struct, decos));
|
||||||
|
|
||||||
ast::type::Struct s_type("my_struct",
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct",
|
||||||
create<ast::Struct>(Source{}, outer_members,
|
create<ast::Struct>(Source{}, outer_members,
|
||||||
ast::StructDecorationList{}));
|
ast::StructDecorationList{}));
|
||||||
|
|
||||||
|
@ -881,13 +885,13 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) {
|
||||||
ast::StructMemberList{create<ast::StructMember>(
|
ast::StructMemberList{create<ast::StructMember>(
|
||||||
Source{}, "baz", &vec3, decos)},
|
Source{}, "baz", &vec3, decos)},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
ast::type::Struct c_type("C", s);
|
ast::type::Struct c_type(mod->RegisterSymbol("C"), "C", s);
|
||||||
|
|
||||||
s = create<ast::Struct>(Source{},
|
s = create<ast::Struct>(Source{},
|
||||||
ast::StructMemberList{create<ast::StructMember>(
|
ast::StructMemberList{create<ast::StructMember>(
|
||||||
Source{}, "bar", &c_type, decos)},
|
Source{}, "bar", &c_type, decos)},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
ast::type::Struct b_type("B", s);
|
ast::type::Struct b_type(mod->RegisterSymbol("B"), "B", s);
|
||||||
|
|
||||||
ast::type::Array b_ary_type(&b_type, 3, ast::ArrayDecorationList{});
|
ast::type::Array b_ary_type(&b_type, 3, ast::ArrayDecorationList{});
|
||||||
|
|
||||||
|
@ -895,7 +899,7 @@ TEST_F(BuilderTest, Accessor_Mixed_ArrayAndMember) {
|
||||||
ast::StructMemberList{create<ast::StructMember>(
|
ast::StructMemberList{create<ast::StructMember>(
|
||||||
Source{}, "foo", &b_ary_type, decos)},
|
Source{}, "foo", &b_ary_type, decos)},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
ast::type::Struct a_type("A", s);
|
ast::type::Struct a_type(mod->RegisterSymbol("A"), "A", s);
|
||||||
|
|
||||||
ast::type::Array a_ary_type(&a_type, 2, ast::ArrayDecorationList{});
|
ast::type::Array a_ary_type(&a_type, 2, ast::ArrayDecorationList{});
|
||||||
|
|
||||||
|
|
|
@ -235,7 +235,7 @@ TEST_F(BuilderTest, Assign_StructMember) {
|
||||||
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, decos));
|
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, decos));
|
||||||
|
|
||||||
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("my_struct", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s);
|
||||||
|
|
||||||
ast::Variable v(Source{}, "ident", ast::StorageClass::kFunction, &s_type,
|
ast::Variable v(Source{}, "ident", ast::StorageClass::kFunction, &s_type,
|
||||||
false, nullptr, ast::VariableDecorationList{});
|
false, nullptr, ast::VariableDecorationList{});
|
||||||
|
|
|
@ -949,7 +949,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Struct) {
|
||||||
create<ast::StructMember>(Source{}, "b", ty.vec3<f32>(), decos),
|
create<ast::StructMember>(Source{}, "b", ty.vec3<f32>(), decos),
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("my_struct", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s);
|
||||||
|
|
||||||
auto* t = Construct(&s_type, 2.0f, vec3<f32>(2.0f, 2.0f, 2.0f));
|
auto* t = Construct(&s_type, 2.0f, vec3<f32>(2.0f, 2.0f, 2.0f));
|
||||||
|
|
||||||
|
@ -1088,7 +1088,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Struct) {
|
||||||
create<ast::StructMember>(Source{}, "a", ty.f32, decos),
|
create<ast::StructMember>(Source{}, "a", ty.f32, decos),
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("my_struct", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s);
|
||||||
|
|
||||||
auto* t = Construct(&s_type);
|
auto* t = Construct(&s_type);
|
||||||
|
|
||||||
|
@ -1504,7 +1504,7 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct) {
|
||||||
create<ast::StructMember>(Source{}, "b", ty.vec3<f32>(), decos),
|
create<ast::StructMember>(Source{}, "b", ty.vec3<f32>(), decos),
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("my_struct", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s);
|
||||||
|
|
||||||
auto* t = Construct(&s_type, 2.f, vec3<f32>(2.f, 2.f, 2.f));
|
auto* t = Construct(&s_type, 2.f, vec3<f32>(2.f, 2.f, 2.f));
|
||||||
|
|
||||||
|
@ -1525,7 +1525,7 @@ TEST_F(SpvBuilderConstructorTest,
|
||||||
},
|
},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s_type("my_struct", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s);
|
||||||
|
|
||||||
auto* t = Construct(&s_type, 2.f, "a", 2.f);
|
auto* t = Construct(&s_type, 2.f, "a", 2.f);
|
||||||
|
|
||||||
|
|
|
@ -271,7 +271,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, s_decos);
|
auto* str = create<ast::Struct>(Source{}, members, s_decos);
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod->RegisterSymbol("Data"), "Data", str);
|
||||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||||
|
|
||||||
auto* data_var =
|
auto* data_var =
|
||||||
|
|
|
@ -534,7 +534,8 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) {
|
||||||
members.push_back(create<ast::StructMember>(Source{}, "b", &i32, decos));
|
members.push_back(create<ast::StructMember>(Source{}, "b", &i32, decos));
|
||||||
|
|
||||||
ast::type::Struct A(
|
ast::type::Struct A(
|
||||||
"A", create<ast::Struct>(Source{}, members, ast::StructDecorationList{}));
|
mod->RegisterSymbol("A"), "A",
|
||||||
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{}));
|
||||||
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A};
|
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A};
|
||||||
|
|
||||||
ast::Variable var(Source{}, "b", ast::StorageClass::kStorageBuffer, &ac,
|
ast::Variable var(Source{}, "b", ast::StorageClass::kStorageBuffer, &ac,
|
||||||
|
@ -571,7 +572,8 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) {
|
||||||
members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos));
|
members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos));
|
||||||
|
|
||||||
ast::type::Struct A(
|
ast::type::Struct A(
|
||||||
"A", create<ast::Struct>(Source{}, members, ast::StructDecorationList{}));
|
mod->RegisterSymbol("A"), "A",
|
||||||
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{}));
|
||||||
ast::type::Alias B(mod->RegisterSymbol("B"), "B", &A);
|
ast::type::Alias B(mod->RegisterSymbol("B"), "B", &A);
|
||||||
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &B};
|
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &B};
|
||||||
|
|
||||||
|
@ -607,7 +609,8 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) {
|
||||||
members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos));
|
members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos));
|
||||||
|
|
||||||
ast::type::Struct A(
|
ast::type::Struct A(
|
||||||
"A", create<ast::Struct>(Source{}, members, ast::StructDecorationList{}));
|
mod->RegisterSymbol("A"), "A",
|
||||||
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{}));
|
||||||
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A};
|
ast::type::AccessControl ac{ast::AccessControl::kReadOnly, &A};
|
||||||
ast::type::Alias B(mod->RegisterSymbol("B"), "B", &ac);
|
ast::type::Alias B(mod->RegisterSymbol("B"), "B", &ac);
|
||||||
|
|
||||||
|
@ -643,7 +646,8 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) {
|
||||||
members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos));
|
members.push_back(create<ast::StructMember>(Source{}, "a", &i32, decos));
|
||||||
|
|
||||||
ast::type::Struct A(
|
ast::type::Struct A(
|
||||||
"A", create<ast::Struct>(Source{}, members, ast::StructDecorationList{}));
|
mod->RegisterSymbol("A"), "A",
|
||||||
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{}));
|
||||||
ast::type::AccessControl read{ast::AccessControl::kReadOnly, &A};
|
ast::type::AccessControl read{ast::AccessControl::kReadOnly, &A};
|
||||||
ast::type::AccessControl rw{ast::AccessControl::kReadWrite, &A};
|
ast::type::AccessControl rw{ast::AccessControl::kReadWrite, &A};
|
||||||
|
|
||||||
|
|
|
@ -1312,7 +1312,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) {
|
||||||
create<ast::StructMember>(Source{}, "a", ty.array<f32>(), decos));
|
create<ast::StructMember>(Source{}, "a", ty.array<f32>(), decos));
|
||||||
|
|
||||||
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("my_struct", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s);
|
||||||
|
|
||||||
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
|
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
|
||||||
|
|
||||||
|
@ -1354,7 +1354,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) {
|
||||||
create<ast::StructMember>(Source{}, "a", ty.array<f32>(), decos));
|
create<ast::StructMember>(Source{}, "a", ty.array<f32>(), decos));
|
||||||
|
|
||||||
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("my_struct", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s);
|
||||||
|
|
||||||
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
|
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
|
||||||
auto expr = Call("arrayLength", create<ast::MemberAccessorExpression>(
|
auto expr = Call("arrayLength", create<ast::MemberAccessorExpression>(
|
||||||
|
@ -1398,7 +1398,7 @@ TEST_F(IntrinsicBuilderTest, DISABLED_Call_ArrayLength_Ptr) {
|
||||||
create<ast::StructMember>(Source{}, "a", ty.array<f32>(), decos));
|
create<ast::StructMember>(Source{}, "a", ty.array<f32>(), decos));
|
||||||
|
|
||||||
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("my_struct", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s);
|
||||||
|
|
||||||
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
|
auto* var = Var("b", ast::StorageClass::kPrivate, &s_type);
|
||||||
|
|
||||||
|
|
|
@ -280,7 +280,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) {
|
||||||
TEST_F(BuilderTest_Type, GenerateStruct_Empty) {
|
TEST_F(BuilderTest_Type, GenerateStruct_Empty) {
|
||||||
auto* s = create<ast::Struct>(Source{}, ast::StructMemberList{},
|
auto* s = create<ast::Struct>(Source{}, ast::StructMemberList{},
|
||||||
ast::StructDecorationList{});
|
ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("S", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("S"), "S", s);
|
||||||
|
|
||||||
auto id = b.GenerateTypeIfNeeded(&s_type);
|
auto id = b.GenerateTypeIfNeeded(&s_type);
|
||||||
ASSERT_FALSE(b.has_error()) << b.error();
|
ASSERT_FALSE(b.has_error()) << b.error();
|
||||||
|
@ -301,7 +301,7 @@ TEST_F(BuilderTest_Type, GenerateStruct) {
|
||||||
members.push_back(create<ast::StructMember>(Source{}, "a", &f32, decos));
|
members.push_back(create<ast::StructMember>(Source{}, "a", &f32, decos));
|
||||||
|
|
||||||
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("my_struct", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s);
|
||||||
|
|
||||||
auto id = b.GenerateTypeIfNeeded(&s_type);
|
auto id = b.GenerateTypeIfNeeded(&s_type);
|
||||||
ASSERT_FALSE(b.has_error()) << b.error();
|
ASSERT_FALSE(b.has_error()) << b.error();
|
||||||
|
@ -326,7 +326,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_Decorated) {
|
||||||
struct_decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
struct_decos.push_back(create<ast::StructBlockDecoration>(Source{}));
|
||||||
|
|
||||||
auto* s = create<ast::Struct>(Source{}, members, struct_decos);
|
auto* s = create<ast::Struct>(Source{}, members, struct_decos);
|
||||||
ast::type::Struct s_type("my_struct", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("my_struct"), "my_struct", s);
|
||||||
|
|
||||||
auto id = b.GenerateTypeIfNeeded(&s_type);
|
auto id = b.GenerateTypeIfNeeded(&s_type);
|
||||||
ASSERT_FALSE(b.has_error()) << b.error();
|
ASSERT_FALSE(b.has_error()) << b.error();
|
||||||
|
@ -355,7 +355,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers) {
|
||||||
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_decos));
|
members.push_back(create<ast::StructMember>(Source{}, "b", &f32, b_decos));
|
||||||
|
|
||||||
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("S", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("S"), "S", s);
|
||||||
|
|
||||||
auto id = b.GenerateTypeIfNeeded(&s_type);
|
auto id = b.GenerateTypeIfNeeded(&s_type);
|
||||||
ASSERT_FALSE(b.has_error()) << b.error();
|
ASSERT_FALSE(b.has_error()) << b.error();
|
||||||
|
@ -392,7 +392,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_NonLayout_Matrix) {
|
||||||
create<ast::StructMember>(Source{}, "c", &glsl_mat4x4, empty_c));
|
create<ast::StructMember>(Source{}, "c", &glsl_mat4x4, empty_c));
|
||||||
|
|
||||||
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("S", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("S"), "S", s);
|
||||||
|
|
||||||
auto id = b.GenerateTypeIfNeeded(&s_type);
|
auto id = b.GenerateTypeIfNeeded(&s_type);
|
||||||
ASSERT_FALSE(b.has_error()) << b.error();
|
ASSERT_FALSE(b.has_error()) << b.error();
|
||||||
|
@ -438,7 +438,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutMatrix) {
|
||||||
create<ast::StructMember>(Source{}, "c", &glsl_mat4x4, c_decos));
|
create<ast::StructMember>(Source{}, "c", &glsl_mat4x4, c_decos));
|
||||||
|
|
||||||
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("S", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("S"), "S", s);
|
||||||
|
|
||||||
auto id = b.GenerateTypeIfNeeded(&s_type);
|
auto id = b.GenerateTypeIfNeeded(&s_type);
|
||||||
ASSERT_FALSE(b.has_error()) << b.error();
|
ASSERT_FALSE(b.has_error()) << b.error();
|
||||||
|
@ -505,7 +505,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers_LayoutArraysOfMatrix) {
|
||||||
create<ast::StructMember>(Source{}, "c", &glsl_mat4x4, c_decos));
|
create<ast::StructMember>(Source{}, "c", &glsl_mat4x4, c_decos));
|
||||||
|
|
||||||
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
ast::type::Struct s_type("S", s);
|
ast::type::Struct s_type(mod->RegisterSymbol("S"), "S", s);
|
||||||
|
|
||||||
auto id = b.GenerateTypeIfNeeded(&s_type);
|
auto id = b.GenerateTypeIfNeeded(&s_type);
|
||||||
ASSERT_FALSE(b.has_error()) << b.error();
|
ASSERT_FALSE(b.has_error()) << b.error();
|
||||||
|
|
|
@ -54,7 +54,7 @@ TEST_F(WgslGeneratorImplTest, EmitConstructedType_Struct) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("A", str);
|
ast::type::Struct s(mod.RegisterSymbol("A"), "A", str);
|
||||||
ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s);
|
ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitConstructedType(&s)) << gen.error();
|
ASSERT_TRUE(gen.EmitConstructedType(&s)) << gen.error();
|
||||||
|
@ -83,7 +83,7 @@ TEST_F(WgslGeneratorImplTest, EmitAlias_ToStruct) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("A", str);
|
ast::type::Struct s(mod.RegisterSymbol("A"), "A", str);
|
||||||
ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s);
|
ast::type::Alias alias(mod.RegisterSymbol("B"), "B", &s);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error();
|
ASSERT_TRUE(gen.EmitConstructedType(&alias)) << gen.error();
|
||||||
|
|
|
@ -200,7 +200,7 @@ TEST_F(WgslGeneratorImplTest,
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, s_decos);
|
auto* str = create<ast::Struct>(Source{}, members, s_decos);
|
||||||
|
|
||||||
ast::type::Struct s("Data", str);
|
ast::type::Struct s(mod.RegisterSymbol("Data"), "Data", str);
|
||||||
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
ast::type::AccessControl ac(ast::AccessControl::kReadWrite, &s);
|
||||||
|
|
||||||
auto* data_var =
|
auto* data_var =
|
||||||
|
|
|
@ -75,7 +75,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_Read) {
|
||||||
decos.push_back(&block_deco);
|
decos.push_back(&block_deco);
|
||||||
|
|
||||||
ast::Struct str(Source{}, members, decos);
|
ast::Struct str(Source{}, members, decos);
|
||||||
ast::type::Struct s("S", &str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", &str);
|
||||||
|
|
||||||
ast::type::AccessControl a(ast::AccessControl::kReadOnly, &s);
|
ast::type::AccessControl a(ast::AccessControl::kReadOnly, &s);
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_ReadWrite) {
|
||||||
decos.push_back(&block_deco);
|
decos.push_back(&block_deco);
|
||||||
|
|
||||||
ast::Struct str(Source{}, members, decos);
|
ast::Struct str(Source{}, members, decos);
|
||||||
ast::type::Struct s("S", &str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", &str);
|
||||||
|
|
||||||
ast::type::AccessControl a(ast::AccessControl::kReadWrite, &s);
|
ast::type::AccessControl a(ast::AccessControl::kReadWrite, &s);
|
||||||
|
|
||||||
|
@ -186,7 +186,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Struct) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitType(&s)) << gen.error();
|
ASSERT_TRUE(gen.EmitType(&s)) << gen.error();
|
||||||
EXPECT_EQ(gen.result(), "S");
|
EXPECT_EQ(gen.result(), "S");
|
||||||
|
@ -207,7 +207,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_StructDecl) {
|
||||||
auto* str =
|
auto* str =
|
||||||
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
|
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
|
||||||
EXPECT_EQ(gen.result(), R"(struct S {
|
EXPECT_EQ(gen.result(), R"(struct S {
|
||||||
|
@ -235,7 +235,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Struct_WithDecoration) {
|
||||||
|
|
||||||
auto* str = create<ast::Struct>(Source{}, members, decos);
|
auto* str = create<ast::Struct>(Source{}, members, decos);
|
||||||
|
|
||||||
ast::type::Struct s("S", str);
|
ast::type::Struct s(mod.RegisterSymbol("S"), "S", str);
|
||||||
|
|
||||||
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
|
ASSERT_TRUE(gen.EmitStructType(&s)) << gen.error();
|
||||||
EXPECT_EQ(gen.result(), R"([[block]]
|
EXPECT_EQ(gen.result(), R"([[block]]
|
||||||
|
|
Loading…
Reference in New Issue