ast::TypesBuilder: Change const fields to getters
This is required in order to support move operators for TypesBuilder. Bug: tint:390 Change-Id: I9667bda5f5be267df092f5cd94dc40db053ae6e2 Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/38555 Reviewed-by: dan sinclair <dsinclair@chromium.org>
This commit is contained in:
parent
deb02019d5
commit
8d391f7a10
|
@ -27,16 +27,16 @@ using BitcastExpressionTest = TestHelper;
|
|||
TEST_F(BitcastExpressionTest, Create) {
|
||||
auto* expr = Expr("expr");
|
||||
|
||||
auto* exp = create<BitcastExpression>(ty.f32, expr);
|
||||
ASSERT_EQ(exp->type(), ty.f32);
|
||||
auto* exp = create<BitcastExpression>(ty.f32(), expr);
|
||||
ASSERT_EQ(exp->type(), ty.f32());
|
||||
ASSERT_EQ(exp->expr(), expr);
|
||||
}
|
||||
|
||||
TEST_F(BitcastExpressionTest, CreateWithSource) {
|
||||
auto* expr = Expr("expr");
|
||||
|
||||
auto* exp =
|
||||
create<BitcastExpression>(Source{Source::Location{20, 2}}, ty.f32, expr);
|
||||
auto* exp = create<BitcastExpression>(Source{Source::Location{20, 2}},
|
||||
ty.f32(), expr);
|
||||
auto src = exp->source();
|
||||
EXPECT_EQ(src.range.begin.line, 20u);
|
||||
EXPECT_EQ(src.range.begin.column, 2u);
|
||||
|
@ -45,14 +45,14 @@ TEST_F(BitcastExpressionTest, CreateWithSource) {
|
|||
TEST_F(BitcastExpressionTest, IsBitcast) {
|
||||
auto* expr = Expr("expr");
|
||||
|
||||
auto* exp = create<BitcastExpression>(ty.f32, expr);
|
||||
auto* exp = create<BitcastExpression>(ty.f32(), expr);
|
||||
EXPECT_TRUE(exp->Is<BitcastExpression>());
|
||||
}
|
||||
|
||||
TEST_F(BitcastExpressionTest, IsValid) {
|
||||
auto* expr = Expr("expr");
|
||||
|
||||
auto* exp = create<BitcastExpression>(ty.f32, expr);
|
||||
auto* exp = create<BitcastExpression>(ty.f32(), expr);
|
||||
EXPECT_TRUE(exp->IsValid());
|
||||
}
|
||||
|
||||
|
@ -64,20 +64,20 @@ TEST_F(BitcastExpressionTest, IsValid_MissingType) {
|
|||
}
|
||||
|
||||
TEST_F(BitcastExpressionTest, IsValid_MissingExpr) {
|
||||
auto* exp = create<BitcastExpression>(ty.f32, nullptr);
|
||||
auto* exp = create<BitcastExpression>(ty.f32(), nullptr);
|
||||
EXPECT_FALSE(exp->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(BitcastExpressionTest, IsValid_InvalidExpr) {
|
||||
auto* expr = Expr("");
|
||||
auto* e = create<BitcastExpression>(ty.f32, expr);
|
||||
auto* e = create<BitcastExpression>(ty.f32(), expr);
|
||||
EXPECT_FALSE(e->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(BitcastExpressionTest, ToStr) {
|
||||
auto* expr = Expr("expr");
|
||||
|
||||
auto* exp = create<BitcastExpression>(ty.f32, expr);
|
||||
auto* exp = create<BitcastExpression>(ty.f32(), expr);
|
||||
std::ostringstream out;
|
||||
exp->to_str(out, 2);
|
||||
|
||||
|
|
|
@ -18,12 +18,7 @@ namespace tint {
|
|||
namespace ast {
|
||||
|
||||
TypesBuilder::TypesBuilder(Program* p)
|
||||
: bool_(p->create<type::Bool>()),
|
||||
f32(p->create<type::F32>()),
|
||||
i32(p->create<type::I32>()),
|
||||
u32(p->create<type::U32>()),
|
||||
void_(p->create<type::Void>()),
|
||||
program_(p) {}
|
||||
: program_(p) {}
|
||||
|
||||
Builder::Builder(Program* p) : program(p), ty(p), mod(p) {}
|
||||
|
||||
|
|
|
@ -59,23 +59,27 @@ class TypesBuilder {
|
|||
/// @param program the program
|
||||
explicit TypesBuilder(Program* program);
|
||||
|
||||
/// A boolean type
|
||||
type::Bool* const bool_;
|
||||
/// A f32 type
|
||||
type::F32* const f32;
|
||||
/// A i32 type
|
||||
type::I32* const i32;
|
||||
/// A u32 type
|
||||
type::U32* const u32;
|
||||
/// A void type
|
||||
type::Void* const void_;
|
||||
|
||||
/// @return the tint AST type for the C type `T`.
|
||||
template <typename T>
|
||||
type::Type* Of() const {
|
||||
return CToAST<T>::get(this);
|
||||
}
|
||||
|
||||
/// @returns A boolean type
|
||||
type::Bool* bool_() const { return program_->create<type::Bool>(); }
|
||||
|
||||
/// @returns A f32 type
|
||||
type::F32* f32() const { return program_->create<type::F32>(); }
|
||||
|
||||
/// @returns A i32 type
|
||||
type::I32* i32() const { return program_->create<type::I32>(); }
|
||||
|
||||
/// @returns A u32 type
|
||||
type::U32* u32() const { return program_->create<type::U32>(); }
|
||||
|
||||
/// @returns A void type
|
||||
type::Void* void_() const { return program_->create<type::Void>(); }
|
||||
|
||||
/// @return the tint AST type for a 2-element vector of the C type `T`.
|
||||
template <typename T>
|
||||
type::Vector* vec2() const {
|
||||
|
@ -310,19 +314,21 @@ class Builder {
|
|||
|
||||
/// @param val the boolan value
|
||||
/// @return a boolean literal with the given value
|
||||
BoolLiteral* Literal(bool val) { return create<BoolLiteral>(ty.bool_, val); }
|
||||
BoolLiteral* Literal(bool val) {
|
||||
return create<BoolLiteral>(ty.bool_(), val);
|
||||
}
|
||||
|
||||
/// @param val the float value
|
||||
/// @return a float literal with the given value
|
||||
FloatLiteral* Literal(f32 val) { return create<FloatLiteral>(ty.f32, val); }
|
||||
FloatLiteral* Literal(f32 val) { return create<FloatLiteral>(ty.f32(), val); }
|
||||
|
||||
/// @param val the unsigned int value
|
||||
/// @return a UintLiteral with the given value
|
||||
UintLiteral* Literal(u32 val) { return create<UintLiteral>(ty.u32, val); }
|
||||
UintLiteral* Literal(u32 val) { return create<UintLiteral>(ty.u32(), val); }
|
||||
|
||||
/// @param val the integer value
|
||||
/// @return the SintLiteral with the given value
|
||||
SintLiteral* Literal(i32 val) { return create<SintLiteral>(ty.i32, val); }
|
||||
SintLiteral* Literal(i32 val) { return create<SintLiteral>(ty.i32(), val); }
|
||||
|
||||
/// @param args the arguments for the type constructor
|
||||
/// @return an `TypeConstructorExpression` of type `ty`, with the values
|
||||
|
@ -763,23 +769,23 @@ class BuilderWithProgram : public Builder {
|
|||
// Various template specializations for TypesBuilder::CToAST.
|
||||
template <>
|
||||
struct TypesBuilder::CToAST<Builder::i32> {
|
||||
static type::Type* get(const TypesBuilder* t) { return t->i32; }
|
||||
static type::Type* get(const TypesBuilder* t) { return t->i32(); }
|
||||
};
|
||||
template <>
|
||||
struct TypesBuilder::CToAST<Builder::u32> {
|
||||
static type::Type* get(const TypesBuilder* t) { return t->u32; }
|
||||
static type::Type* get(const TypesBuilder* t) { return t->u32(); }
|
||||
};
|
||||
template <>
|
||||
struct TypesBuilder::CToAST<Builder::f32> {
|
||||
static type::Type* get(const TypesBuilder* t) { return t->f32; }
|
||||
static type::Type* get(const TypesBuilder* t) { return t->f32(); }
|
||||
};
|
||||
template <>
|
||||
struct TypesBuilder::CToAST<bool> {
|
||||
static type::Type* get(const TypesBuilder* t) { return t->bool_; }
|
||||
static type::Type* get(const TypesBuilder* t) { return t->bool_(); }
|
||||
};
|
||||
template <>
|
||||
struct TypesBuilder::CToAST<void> {
|
||||
static type::Type* get(const TypesBuilder* t) { return t->void_; }
|
||||
static type::Type* get(const TypesBuilder* t) { return t->void_(); }
|
||||
};
|
||||
//! @endcond
|
||||
|
||||
|
|
|
@ -30,7 +30,7 @@ using CaseStatementTest = TestHelper;
|
|||
|
||||
TEST_F(CaseStatementTest, Creation_i32) {
|
||||
CaseSelectorList b;
|
||||
auto* selector = create<SintLiteral>(ty.i32, 2);
|
||||
auto* selector = create<SintLiteral>(ty.i32(), 2);
|
||||
b.push_back(selector);
|
||||
|
||||
auto* discard = create<DiscardStatement>();
|
||||
|
@ -45,7 +45,7 @@ TEST_F(CaseStatementTest, Creation_i32) {
|
|||
|
||||
TEST_F(CaseStatementTest, Creation_u32) {
|
||||
CaseSelectorList b;
|
||||
auto* selector = create<SintLiteral>(ty.u32, 2);
|
||||
auto* selector = create<SintLiteral>(ty.u32(), 2);
|
||||
b.push_back(selector);
|
||||
|
||||
auto* discard = create<DiscardStatement>();
|
||||
|
@ -60,7 +60,7 @@ TEST_F(CaseStatementTest, Creation_u32) {
|
|||
|
||||
TEST_F(CaseStatementTest, Creation_WithSource) {
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(ty.i32, 2));
|
||||
b.push_back(create<SintLiteral>(ty.i32(), 2));
|
||||
|
||||
auto* body = create<BlockStatement>(StatementList{
|
||||
create<DiscardStatement>(),
|
||||
|
@ -81,7 +81,7 @@ TEST_F(CaseStatementTest, IsDefault_WithoutSelectors) {
|
|||
|
||||
TEST_F(CaseStatementTest, IsDefault_WithSelectors) {
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(ty.i32, 2));
|
||||
b.push_back(create<SintLiteral>(ty.i32(), 2));
|
||||
|
||||
auto* c = create<CaseStatement>(b, create<BlockStatement>(StatementList{}));
|
||||
EXPECT_FALSE(c->IsDefault());
|
||||
|
@ -101,7 +101,7 @@ TEST_F(CaseStatementTest, IsValid) {
|
|||
|
||||
TEST_F(CaseStatementTest, IsValid_NullBodyStatement) {
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(ty.i32, 2));
|
||||
b.push_back(create<SintLiteral>(ty.i32(), 2));
|
||||
|
||||
auto* body = create<BlockStatement>(StatementList{
|
||||
create<DiscardStatement>(),
|
||||
|
@ -113,7 +113,7 @@ TEST_F(CaseStatementTest, IsValid_NullBodyStatement) {
|
|||
|
||||
TEST_F(CaseStatementTest, IsValid_InvalidBodyStatement) {
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(ty.i32, 2));
|
||||
b.push_back(create<SintLiteral>(ty.i32(), 2));
|
||||
|
||||
auto* body = create<BlockStatement>(
|
||||
|
||||
|
@ -127,7 +127,7 @@ TEST_F(CaseStatementTest, IsValid_InvalidBodyStatement) {
|
|||
|
||||
TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) {
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(ty.i32, -2));
|
||||
b.push_back(create<SintLiteral>(ty.i32(), -2));
|
||||
|
||||
auto* body = create<BlockStatement>(StatementList{
|
||||
create<DiscardStatement>(),
|
||||
|
@ -144,7 +144,7 @@ TEST_F(CaseStatementTest, ToStr_WithSelectors_i32) {
|
|||
|
||||
TEST_F(CaseStatementTest, ToStr_WithSelectors_u32) {
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<UintLiteral>(ty.u32, 2));
|
||||
b.push_back(create<UintLiteral>(ty.u32(), 2));
|
||||
|
||||
auto* body = create<BlockStatement>(StatementList{
|
||||
create<DiscardStatement>(),
|
||||
|
@ -161,8 +161,8 @@ TEST_F(CaseStatementTest, ToStr_WithSelectors_u32) {
|
|||
|
||||
TEST_F(CaseStatementTest, ToStr_WithMultipleSelectors) {
|
||||
CaseSelectorList b;
|
||||
b.push_back(create<SintLiteral>(ty.i32, 1));
|
||||
b.push_back(create<SintLiteral>(ty.i32, 2));
|
||||
b.push_back(create<SintLiteral>(ty.i32(), 1));
|
||||
b.push_back(create<SintLiteral>(ty.i32(), 2));
|
||||
|
||||
auto* body = create<BlockStatement>(StatementList{
|
||||
create<DiscardStatement>(),
|
||||
|
|
|
@ -35,13 +35,13 @@ using ExpressionTest = TestHelper;
|
|||
|
||||
TEST_F(ExpressionTest, set_result_type) {
|
||||
FakeExpr e;
|
||||
e.set_result_type(ty.i32);
|
||||
e.set_result_type(ty.i32());
|
||||
ASSERT_NE(e.result_type(), nullptr);
|
||||
EXPECT_TRUE(e.result_type()->Is<type::I32>());
|
||||
}
|
||||
|
||||
TEST_F(ExpressionTest, set_result_type_alias) {
|
||||
auto* a = ty.alias("a", ty.i32);
|
||||
auto* a = ty.alias("a", ty.i32());
|
||||
auto* b = ty.alias("b", a);
|
||||
|
||||
FakeExpr e;
|
||||
|
|
|
@ -28,13 +28,13 @@ namespace {
|
|||
using FloatLiteralTest = TestHelper;
|
||||
|
||||
TEST_F(FloatLiteralTest, Value) {
|
||||
auto* f = create<FloatLiteral>(ty.f32, 47.2f);
|
||||
auto* f = create<FloatLiteral>(ty.f32(), 47.2f);
|
||||
ASSERT_TRUE(f->Is<FloatLiteral>());
|
||||
EXPECT_EQ(f->value(), 47.2f);
|
||||
}
|
||||
|
||||
TEST_F(FloatLiteralTest, Is) {
|
||||
ast::Literal* l = create<FloatLiteral>(ty.f32, 42.f);
|
||||
ast::Literal* l = create<FloatLiteral>(ty.f32(), 42.f);
|
||||
EXPECT_FALSE(l->Is<BoolLiteral>());
|
||||
EXPECT_FALSE(l->Is<SintLiteral>());
|
||||
EXPECT_FALSE(l->Is<IntLiteral>());
|
||||
|
@ -44,13 +44,13 @@ TEST_F(FloatLiteralTest, Is) {
|
|||
}
|
||||
|
||||
TEST_F(FloatLiteralTest, ToStr) {
|
||||
auto* f = create<FloatLiteral>(ty.f32, 42.1f);
|
||||
auto* f = create<FloatLiteral>(ty.f32(), 42.1f);
|
||||
|
||||
EXPECT_EQ(f->to_str(), "42.099998");
|
||||
}
|
||||
|
||||
TEST_F(FloatLiteralTest, ToName) {
|
||||
auto* f = create<FloatLiteral>(ty.f32, 42.1f);
|
||||
auto* f = create<FloatLiteral>(ty.f32(), 42.1f);
|
||||
EXPECT_EQ(f->name(), "__float42.0999985");
|
||||
}
|
||||
|
||||
|
|
|
@ -31,22 +31,22 @@ using FunctionTest = TestHelper;
|
|||
|
||||
TEST_F(FunctionTest, Creation) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32));
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
auto* var = params[0];
|
||||
|
||||
auto* f =
|
||||
Func("func", params, ty.void_, StatementList{}, FunctionDecorationList{});
|
||||
auto* f = Func("func", params, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{});
|
||||
EXPECT_EQ(f->symbol(), mod->Symbols().Register("func"));
|
||||
ASSERT_EQ(f->params().size(), 1u);
|
||||
EXPECT_EQ(f->return_type(), ty.void_);
|
||||
EXPECT_EQ(f->return_type(), ty.void_());
|
||||
EXPECT_EQ(f->params()[0], var);
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, Creation_WithSource) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32));
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
|
||||
auto* f = Func(Source{Source::Location{20, 2}}, "func", params, ty.void_,
|
||||
auto* f = Func(Source{Source::Location{20, 2}}, "func", params, ty.void_(),
|
||||
StatementList{}, FunctionDecorationList{});
|
||||
auto src = f->source();
|
||||
EXPECT_EQ(src.range.begin.line, 20u);
|
||||
|
@ -54,8 +54,8 @@ TEST_F(FunctionTest, Creation_WithSource) {
|
|||
}
|
||||
|
||||
TEST_F(FunctionTest, AddDuplicateReferencedVariables) {
|
||||
auto* v = Var("var", StorageClass::kInput, ty.i32);
|
||||
auto* f = Func("func", VariableList{}, ty.void_, StatementList{},
|
||||
auto* v = Var("var", StorageClass::kInput, ty.i32());
|
||||
auto* f = Func("func", VariableList{}, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{});
|
||||
|
||||
f->add_referenced_module_variable(v);
|
||||
|
@ -65,34 +65,34 @@ TEST_F(FunctionTest, AddDuplicateReferencedVariables) {
|
|||
f->add_referenced_module_variable(v);
|
||||
ASSERT_EQ(f->referenced_module_variables().size(), 1u);
|
||||
|
||||
auto* v2 = Var("var2", StorageClass::kOutput, ty.i32);
|
||||
auto* v2 = Var("var2", StorageClass::kOutput, ty.i32());
|
||||
f->add_referenced_module_variable(v2);
|
||||
ASSERT_EQ(f->referenced_module_variables().size(), 2u);
|
||||
EXPECT_EQ(f->referenced_module_variables()[1], v2);
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, GetReferenceLocations) {
|
||||
auto* loc1 = Var("loc1", StorageClass::kInput, ty.i32, nullptr,
|
||||
auto* loc1 = Var("loc1", StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<LocationDecoration>(0),
|
||||
});
|
||||
|
||||
auto* loc2 = Var("loc2", StorageClass::kInput, ty.i32, nullptr,
|
||||
auto* loc2 = Var("loc2", StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<LocationDecoration>(1),
|
||||
});
|
||||
|
||||
auto* builtin1 = Var("builtin1", StorageClass::kInput, ty.i32, nullptr,
|
||||
auto* builtin1 = Var("builtin1", StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<BuiltinDecoration>(Builtin::kPosition),
|
||||
});
|
||||
|
||||
auto* builtin2 = Var("builtin2", StorageClass::kInput, ty.i32, nullptr,
|
||||
auto* builtin2 = Var("builtin2", StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<BuiltinDecoration>(Builtin::kFragDepth),
|
||||
});
|
||||
|
||||
auto* f = Func("func", VariableList{}, ty.void_, StatementList{},
|
||||
auto* f = Func("func", VariableList{}, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{});
|
||||
|
||||
f->add_referenced_module_variable(loc1);
|
||||
|
@ -110,27 +110,27 @@ TEST_F(FunctionTest, GetReferenceLocations) {
|
|||
}
|
||||
|
||||
TEST_F(FunctionTest, GetReferenceBuiltins) {
|
||||
auto* loc1 = Var("loc1", StorageClass::kInput, ty.i32, nullptr,
|
||||
auto* loc1 = Var("loc1", StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<LocationDecoration>(0),
|
||||
});
|
||||
|
||||
auto* loc2 = Var("loc2", StorageClass::kInput, ty.i32, nullptr,
|
||||
auto* loc2 = Var("loc2", StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<LocationDecoration>(1),
|
||||
});
|
||||
|
||||
auto* builtin1 = Var("builtin1", StorageClass::kInput, ty.i32, nullptr,
|
||||
auto* builtin1 = Var("builtin1", StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<BuiltinDecoration>(Builtin::kPosition),
|
||||
});
|
||||
|
||||
auto* builtin2 = Var("builtin2", StorageClass::kInput, ty.i32, nullptr,
|
||||
auto* builtin2 = Var("builtin2", StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<BuiltinDecoration>(Builtin::kFragDepth),
|
||||
});
|
||||
|
||||
auto* f = Func("func", VariableList{}, ty.void_, StatementList{},
|
||||
auto* f = Func("func", VariableList{}, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{});
|
||||
|
||||
f->add_referenced_module_variable(loc1);
|
||||
|
@ -148,7 +148,7 @@ TEST_F(FunctionTest, GetReferenceBuiltins) {
|
|||
}
|
||||
|
||||
TEST_F(FunctionTest, AddDuplicateEntryPoints) {
|
||||
auto* f = Func("func", VariableList{}, ty.void_, StatementList{},
|
||||
auto* f = Func("func", VariableList{}, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{});
|
||||
|
||||
auto main_sym = mod->Symbols().Register("main");
|
||||
|
@ -163,9 +163,9 @@ TEST_F(FunctionTest, AddDuplicateEntryPoints) {
|
|||
|
||||
TEST_F(FunctionTest, IsValid) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32));
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
|
||||
auto* f = Func("func", params, ty.void_,
|
||||
auto* f = Func("func", params, ty.void_(),
|
||||
StatementList{
|
||||
create<DiscardStatement>(),
|
||||
},
|
||||
|
@ -175,16 +175,16 @@ TEST_F(FunctionTest, IsValid) {
|
|||
|
||||
TEST_F(FunctionTest, IsValid_InvalidName) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32));
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
|
||||
auto* f =
|
||||
Func("", params, ty.void_, StatementList{}, FunctionDecorationList{});
|
||||
Func("", params, ty.void_(), StatementList{}, FunctionDecorationList{});
|
||||
EXPECT_FALSE(f->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, IsValid_MissingReturnType) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32));
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
|
||||
auto* f =
|
||||
Func("func", params, nullptr, StatementList{}, FunctionDecorationList{});
|
||||
|
@ -193,11 +193,11 @@ TEST_F(FunctionTest, IsValid_MissingReturnType) {
|
|||
|
||||
TEST_F(FunctionTest, IsValid_NullParam) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32));
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
params.push_back(nullptr);
|
||||
|
||||
auto* f =
|
||||
Func("func", params, ty.void_, StatementList{}, FunctionDecorationList{});
|
||||
auto* f = Func("func", params, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{});
|
||||
EXPECT_FALSE(f->IsValid());
|
||||
}
|
||||
|
||||
|
@ -205,16 +205,16 @@ TEST_F(FunctionTest, IsValid_InvalidParam) {
|
|||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, nullptr));
|
||||
|
||||
auto* f =
|
||||
Func("func", params, ty.void_, StatementList{}, FunctionDecorationList{});
|
||||
auto* f = Func("func", params, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{});
|
||||
EXPECT_FALSE(f->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, IsValid_NullBodyStatement) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32));
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
|
||||
auto* f = Func("func", params, ty.void_,
|
||||
auto* f = Func("func", params, ty.void_(),
|
||||
StatementList{
|
||||
create<DiscardStatement>(),
|
||||
nullptr,
|
||||
|
@ -226,9 +226,9 @@ TEST_F(FunctionTest, IsValid_NullBodyStatement) {
|
|||
|
||||
TEST_F(FunctionTest, IsValid_InvalidBodyStatement) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32));
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
|
||||
auto* f = Func("func", params, ty.void_,
|
||||
auto* f = Func("func", params, ty.void_(),
|
||||
StatementList{
|
||||
create<DiscardStatement>(),
|
||||
nullptr,
|
||||
|
@ -238,7 +238,7 @@ TEST_F(FunctionTest, IsValid_InvalidBodyStatement) {
|
|||
}
|
||||
|
||||
TEST_F(FunctionTest, ToStr) {
|
||||
auto* f = Func("func", VariableList{}, ty.void_,
|
||||
auto* f = Func("func", VariableList{}, ty.void_(),
|
||||
StatementList{
|
||||
create<DiscardStatement>(),
|
||||
},
|
||||
|
@ -255,7 +255,7 @@ TEST_F(FunctionTest, ToStr) {
|
|||
}
|
||||
|
||||
TEST_F(FunctionTest, ToStr_WithDecoration) {
|
||||
auto* f = Func("func", VariableList{}, ty.void_,
|
||||
auto* f = Func("func", VariableList{}, ty.void_(),
|
||||
StatementList{
|
||||
create<DiscardStatement>(),
|
||||
},
|
||||
|
@ -274,9 +274,9 @@ TEST_F(FunctionTest, ToStr_WithDecoration) {
|
|||
|
||||
TEST_F(FunctionTest, ToStr_WithParams) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32));
|
||||
params.push_back(Var("var", StorageClass::kNone, ty.i32()));
|
||||
|
||||
auto* f = Func("func", params, ty.void_,
|
||||
auto* f = Func("func", params, ty.void_(),
|
||||
StatementList{
|
||||
create<DiscardStatement>(),
|
||||
},
|
||||
|
@ -299,25 +299,25 @@ TEST_F(FunctionTest, ToStr_WithParams) {
|
|||
}
|
||||
|
||||
TEST_F(FunctionTest, TypeName) {
|
||||
auto* f = Func("func", VariableList{}, ty.void_, StatementList{},
|
||||
auto* f = Func("func", VariableList{}, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{});
|
||||
EXPECT_EQ(f->type_name(), "__func__void");
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, TypeName_WithParams) {
|
||||
VariableList params;
|
||||
params.push_back(Var("var1", StorageClass::kNone, ty.i32));
|
||||
params.push_back(Var("var2", StorageClass::kNone, ty.f32));
|
||||
params.push_back(Var("var1", StorageClass::kNone, ty.i32()));
|
||||
params.push_back(Var("var2", StorageClass::kNone, ty.f32()));
|
||||
|
||||
auto* f =
|
||||
Func("func", params, ty.void_, StatementList{}, FunctionDecorationList{});
|
||||
auto* f = Func("func", params, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{});
|
||||
EXPECT_EQ(f->type_name(), "__func__void__i32__f32");
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, GetLastStatement) {
|
||||
VariableList params;
|
||||
auto* stmt = create<DiscardStatement>();
|
||||
auto* f = Func("func", params, ty.void_, StatementList{stmt},
|
||||
auto* f = Func("func", params, ty.void_(), StatementList{stmt},
|
||||
FunctionDecorationList{});
|
||||
|
||||
EXPECT_EQ(f->get_last_statement(), stmt);
|
||||
|
@ -325,14 +325,14 @@ TEST_F(FunctionTest, GetLastStatement) {
|
|||
|
||||
TEST_F(FunctionTest, GetLastStatement_nullptr) {
|
||||
VariableList params;
|
||||
auto* f =
|
||||
Func("func", params, ty.void_, StatementList{}, FunctionDecorationList{});
|
||||
auto* f = Func("func", params, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{});
|
||||
|
||||
EXPECT_EQ(f->get_last_statement(), nullptr);
|
||||
}
|
||||
|
||||
TEST_F(FunctionTest, WorkgroupSize_NoneSet) {
|
||||
auto* f = Func("func", VariableList{}, ty.void_, StatementList{},
|
||||
auto* f = Func("func", VariableList{}, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{});
|
||||
uint32_t x = 0;
|
||||
uint32_t y = 0;
|
||||
|
@ -345,7 +345,7 @@ TEST_F(FunctionTest, WorkgroupSize_NoneSet) {
|
|||
|
||||
TEST_F(FunctionTest, WorkgroupSize) {
|
||||
auto* f =
|
||||
Func("func", VariableList{}, ty.void_, StatementList{},
|
||||
Func("func", VariableList{}, ty.void_(), StatementList{},
|
||||
FunctionDecorationList{create<WorkgroupDecoration>(2u, 4u, 6u)});
|
||||
|
||||
uint32_t x = 0;
|
||||
|
@ -360,7 +360,7 @@ TEST_F(FunctionTest, WorkgroupSize) {
|
|||
using FunctionListTest = TestHelper;
|
||||
|
||||
TEST_F(FunctionListTest, FindSymbol) {
|
||||
auto* func = Func("main", VariableList{}, ty.f32, StatementList{},
|
||||
auto* func = Func("main", VariableList{}, ty.f32(), StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
FunctionList list;
|
||||
list.Add(func);
|
||||
|
@ -373,11 +373,11 @@ TEST_F(FunctionListTest, FindSymbolMissing) {
|
|||
}
|
||||
|
||||
TEST_F(FunctionListTest, FindSymbolStage) {
|
||||
auto* fs = Func("main", VariableList{}, ty.f32, StatementList{},
|
||||
auto* fs = Func("main", VariableList{}, ty.f32(), StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(PipelineStage::kFragment),
|
||||
});
|
||||
auto* vs = Func("main", VariableList{}, ty.f32, StatementList{},
|
||||
auto* vs = Func("main", VariableList{}, ty.f32(), StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(PipelineStage::kVertex),
|
||||
});
|
||||
|
@ -392,7 +392,7 @@ TEST_F(FunctionListTest, FindSymbolStage) {
|
|||
|
||||
TEST_F(FunctionListTest, FindSymbolStageMissing) {
|
||||
FunctionList list;
|
||||
list.Add(Func("main", VariableList{}, ty.f32, StatementList{},
|
||||
list.Add(Func("main", VariableList{}, ty.f32(), StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(PipelineStage::kFragment),
|
||||
}));
|
||||
|
@ -402,7 +402,7 @@ TEST_F(FunctionListTest, FindSymbolStageMissing) {
|
|||
|
||||
TEST_F(FunctionListTest, HasStage) {
|
||||
FunctionList list;
|
||||
list.Add(Func("main", VariableList{}, ty.f32, StatementList{},
|
||||
list.Add(Func("main", VariableList{}, ty.f32(), StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(PipelineStage::kFragment),
|
||||
}));
|
||||
|
|
|
@ -30,12 +30,12 @@ namespace {
|
|||
using IntLiteralTest = TestHelper;
|
||||
|
||||
TEST_F(IntLiteralTest, Sint_IsInt) {
|
||||
auto* i = create<SintLiteral>(ty.i32, 47);
|
||||
auto* i = create<SintLiteral>(ty.i32(), 47);
|
||||
ASSERT_TRUE(i->Is<IntLiteral>());
|
||||
}
|
||||
|
||||
TEST_F(IntLiteralTest, Uint_IsInt) {
|
||||
auto* i = create<UintLiteral>(ty.i32, 42);
|
||||
auto* i = create<UintLiteral>(ty.i32(), 42);
|
||||
EXPECT_TRUE(i->Is<IntLiteral>());
|
||||
}
|
||||
|
||||
|
|
|
@ -139,11 +139,11 @@ type::Type* TextureOverloadCase::resultVectorComponentType(
|
|||
ast::Builder* b) const {
|
||||
switch (texture_data_type) {
|
||||
case ast::intrinsic::test::TextureDataType::kF32:
|
||||
return b->ty.f32;
|
||||
return b->ty.f32();
|
||||
case ast::intrinsic::test::TextureDataType::kU32:
|
||||
return b->ty.u32;
|
||||
return b->ty.u32();
|
||||
case ast::intrinsic::test::TextureDataType::kI32:
|
||||
return b->ty.i32;
|
||||
return b->ty.i32();
|
||||
}
|
||||
|
||||
assert(false /* unreachable */);
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace {
|
|||
using NullLiteralTest = TestHelper;
|
||||
|
||||
TEST_F(NullLiteralTest, Is) {
|
||||
ast::Literal* l = create<NullLiteral>(ty.i32);
|
||||
ast::Literal* l = create<NullLiteral>(ty.i32());
|
||||
EXPECT_FALSE(l->Is<BoolLiteral>());
|
||||
EXPECT_FALSE(l->Is<SintLiteral>());
|
||||
EXPECT_FALSE(l->Is<FloatLiteral>());
|
||||
|
@ -38,13 +38,13 @@ TEST_F(NullLiteralTest, Is) {
|
|||
}
|
||||
|
||||
TEST_F(NullLiteralTest, ToStr) {
|
||||
auto* i = create<NullLiteral>(ty.i32);
|
||||
auto* i = create<NullLiteral>(ty.i32());
|
||||
|
||||
EXPECT_EQ(i->to_str(), "null __i32");
|
||||
}
|
||||
|
||||
TEST_F(NullLiteralTest, Name_I32) {
|
||||
auto* i = create<NullLiteral>(ty.i32);
|
||||
auto* i = create<NullLiteral>(ty.i32());
|
||||
EXPECT_EQ("__null__i32", i->name());
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ namespace {
|
|||
using ScalarConstructorExpressionTest = TestHelper;
|
||||
|
||||
TEST_F(ScalarConstructorExpressionTest, Creation) {
|
||||
auto* b = create<BoolLiteral>(ty.bool_, true);
|
||||
auto* b = create<BoolLiteral>(ty.bool_(), true);
|
||||
auto* c = create<ScalarConstructorExpression>(b);
|
||||
EXPECT_EQ(c->literal(), b);
|
||||
}
|
||||
|
|
|
@ -29,13 +29,13 @@ namespace {
|
|||
using SintLiteralTest = TestHelper;
|
||||
|
||||
TEST_F(SintLiteralTest, Value) {
|
||||
auto* i = create<SintLiteral>(ty.i32, 47);
|
||||
auto* i = create<SintLiteral>(ty.i32(), 47);
|
||||
ASSERT_TRUE(i->Is<SintLiteral>());
|
||||
EXPECT_EQ(i->value(), 47);
|
||||
}
|
||||
|
||||
TEST_F(SintLiteralTest, Is) {
|
||||
ast::Literal* l = create<SintLiteral>(ty.i32, 42);
|
||||
ast::Literal* l = create<SintLiteral>(ty.i32(), 42);
|
||||
EXPECT_FALSE(l->Is<BoolLiteral>());
|
||||
EXPECT_TRUE(l->Is<SintLiteral>());
|
||||
EXPECT_FALSE(l->Is<FloatLiteral>());
|
||||
|
@ -44,13 +44,13 @@ TEST_F(SintLiteralTest, Is) {
|
|||
}
|
||||
|
||||
TEST_F(SintLiteralTest, ToStr) {
|
||||
auto* i = create<SintLiteral>(ty.i32, -42);
|
||||
auto* i = create<SintLiteral>(ty.i32(), -42);
|
||||
|
||||
EXPECT_EQ(i->to_str(), "-42");
|
||||
}
|
||||
|
||||
TEST_F(SintLiteralTest, Name_I32) {
|
||||
auto* i = create<SintLiteral>(ty.i32, 2);
|
||||
auto* i = create<SintLiteral>(ty.i32(), 2);
|
||||
EXPECT_EQ("__sint__i32_2", i->name());
|
||||
}
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@ namespace {
|
|||
using StructMemberTest = TestHelper;
|
||||
|
||||
TEST_F(StructMemberTest, Creation) {
|
||||
auto* st = Member("a", ty.i32, {MemberOffset(4)});
|
||||
auto* st = Member("a", ty.i32(), {MemberOffset(4)});
|
||||
EXPECT_EQ(st->symbol(), Symbol(1));
|
||||
EXPECT_EQ(st->type(), ty.i32);
|
||||
EXPECT_EQ(st->type(), ty.i32());
|
||||
EXPECT_EQ(st->decorations().size(), 1u);
|
||||
EXPECT_TRUE(st->decorations()[0]->Is<StructMemberOffsetDecoration>());
|
||||
EXPECT_EQ(st->source().range.begin.line, 0u);
|
||||
|
@ -42,9 +42,9 @@ TEST_F(StructMemberTest, Creation) {
|
|||
TEST_F(StructMemberTest, CreationWithSource) {
|
||||
auto* st = Member(
|
||||
Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 8}}},
|
||||
"a", ty.i32);
|
||||
"a", ty.i32());
|
||||
EXPECT_EQ(st->symbol(), Symbol(1));
|
||||
EXPECT_EQ(st->type(), ty.i32);
|
||||
EXPECT_EQ(st->type(), ty.i32());
|
||||
EXPECT_EQ(st->decorations().size(), 0u);
|
||||
EXPECT_EQ(st->source().range.begin.line, 27u);
|
||||
EXPECT_EQ(st->source().range.begin.column, 4u);
|
||||
|
@ -53,12 +53,12 @@ TEST_F(StructMemberTest, CreationWithSource) {
|
|||
}
|
||||
|
||||
TEST_F(StructMemberTest, IsValid) {
|
||||
auto* st = Member("a", ty.i32);
|
||||
auto* st = Member("a", ty.i32());
|
||||
EXPECT_TRUE(st->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(StructMemberTest, IsValid_EmptySymbol) {
|
||||
auto* st = Member("", ty.i32);
|
||||
auto* st = Member("", ty.i32());
|
||||
EXPECT_FALSE(st->IsValid());
|
||||
}
|
||||
|
||||
|
@ -68,19 +68,19 @@ TEST_F(StructMemberTest, IsValid_NullType) {
|
|||
}
|
||||
|
||||
TEST_F(StructMemberTest, IsValid_Null_Decoration) {
|
||||
auto* st = Member("a", ty.i32, {MemberOffset(4), nullptr});
|
||||
auto* st = Member("a", ty.i32(), {MemberOffset(4), nullptr});
|
||||
EXPECT_FALSE(st->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(StructMemberTest, ToStr) {
|
||||
auto* st = Member("a", ty.i32, {MemberOffset(4)});
|
||||
auto* st = Member("a", ty.i32(), {MemberOffset(4)});
|
||||
std::ostringstream out;
|
||||
st->to_str(out, 2);
|
||||
EXPECT_EQ(demangle(out.str()), " StructMember{[[ offset 4 ]] a: __i32}\n");
|
||||
}
|
||||
|
||||
TEST_F(StructMemberTest, ToStrNoDecorations) {
|
||||
auto* st = Member("a", ty.i32);
|
||||
auto* st = Member("a", ty.i32());
|
||||
std::ostringstream out;
|
||||
st->to_str(out, 2);
|
||||
EXPECT_EQ(demangle(out.str()), " StructMember{a: __i32}\n");
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace {
|
|||
using StructTest = TestHelper;
|
||||
|
||||
TEST_F(StructTest, Creation) {
|
||||
auto* s = create<Struct>(StructMemberList{Member("a", ty.i32)},
|
||||
auto* s = create<Struct>(StructMemberList{Member("a", ty.i32())},
|
||||
StructDecorationList{});
|
||||
EXPECT_EQ(s->members().size(), 1u);
|
||||
EXPECT_TRUE(s->decorations().empty());
|
||||
|
@ -44,7 +44,7 @@ TEST_F(StructTest, Creation_WithDecorations) {
|
|||
StructDecorationList decos;
|
||||
decos.push_back(create<StructBlockDecoration>());
|
||||
|
||||
auto* s = create<Struct>(StructMemberList{Member("a", ty.i32)}, decos);
|
||||
auto* s = create<Struct>(StructMemberList{Member("a", ty.i32())}, decos);
|
||||
EXPECT_EQ(s->members().size(), 1u);
|
||||
ASSERT_EQ(s->decorations().size(), 1u);
|
||||
EXPECT_TRUE(s->decorations()[0]->Is<StructBlockDecoration>());
|
||||
|
@ -60,7 +60,7 @@ TEST_F(StructTest, CreationWithSourceAndDecorations) {
|
|||
|
||||
auto* s = create<Struct>(
|
||||
Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 8}}},
|
||||
StructMemberList{Member("a", ty.i32)}, decos);
|
||||
StructMemberList{Member("a", ty.i32())}, decos);
|
||||
EXPECT_EQ(s->members().size(), 1u);
|
||||
ASSERT_EQ(s->decorations().size(), 1u);
|
||||
EXPECT_TRUE(s->decorations()[0]->Is<StructBlockDecoration>());
|
||||
|
@ -76,13 +76,13 @@ TEST_F(StructTest, IsValid) {
|
|||
}
|
||||
|
||||
TEST_F(StructTest, IsValid_Null_StructMember) {
|
||||
auto* s = create<Struct>(StructMemberList{Member("a", ty.i32), nullptr},
|
||||
auto* s = create<Struct>(StructMemberList{Member("a", ty.i32()), nullptr},
|
||||
StructDecorationList{});
|
||||
EXPECT_FALSE(s->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(StructTest, IsValid_Invalid_StructMember) {
|
||||
auto* s = create<Struct>(StructMemberList{Member("", ty.i32)},
|
||||
auto* s = create<Struct>(StructMemberList{Member("", ty.i32())},
|
||||
ast::StructDecorationList{});
|
||||
EXPECT_FALSE(s->IsValid());
|
||||
}
|
||||
|
@ -90,7 +90,7 @@ TEST_F(StructTest, IsValid_Invalid_StructMember) {
|
|||
TEST_F(StructTest, ToStr) {
|
||||
StructDecorationList decos;
|
||||
decos.push_back(create<StructBlockDecoration>());
|
||||
auto* s = create<Struct>(StructMemberList{Member("a", ty.i32)}, decos);
|
||||
auto* s = create<Struct>(StructMemberList{Member("a", ty.i32())}, decos);
|
||||
|
||||
std::ostringstream out;
|
||||
s->to_str(out, 2);
|
||||
|
|
|
@ -30,7 +30,7 @@ using SwitchStatementTest = TestHelper;
|
|||
|
||||
TEST_F(SwitchStatementTest, Creation) {
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(ty.i32, 1));
|
||||
lit.push_back(create<SintLiteral>(ty.i32(), 1));
|
||||
|
||||
auto* ident = Expr("ident");
|
||||
CaseStatementList body;
|
||||
|
@ -56,7 +56,7 @@ TEST_F(SwitchStatementTest, Creation_WithSource) {
|
|||
|
||||
TEST_F(SwitchStatementTest, IsSwitch) {
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(ty.i32, 2));
|
||||
lit.push_back(create<SintLiteral>(ty.i32(), 2));
|
||||
|
||||
auto* ident = Expr("ident");
|
||||
CaseStatementList body;
|
||||
|
@ -69,7 +69,7 @@ TEST_F(SwitchStatementTest, IsSwitch) {
|
|||
|
||||
TEST_F(SwitchStatementTest, IsValid) {
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(ty.i32, 2));
|
||||
lit.push_back(create<SintLiteral>(ty.i32(), 2));
|
||||
|
||||
auto* ident = Expr("ident");
|
||||
CaseStatementList body;
|
||||
|
@ -82,7 +82,7 @@ TEST_F(SwitchStatementTest, IsValid) {
|
|||
|
||||
TEST_F(SwitchStatementTest, IsValid_Null_Condition) {
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(ty.i32, 2));
|
||||
lit.push_back(create<SintLiteral>(ty.i32(), 2));
|
||||
|
||||
CaseStatementList body;
|
||||
body.push_back(
|
||||
|
@ -94,7 +94,7 @@ TEST_F(SwitchStatementTest, IsValid_Null_Condition) {
|
|||
|
||||
TEST_F(SwitchStatementTest, IsValid_Invalid_Condition) {
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(ty.i32, 2));
|
||||
lit.push_back(create<SintLiteral>(ty.i32(), 2));
|
||||
|
||||
auto* ident = Expr("");
|
||||
CaseStatementList body;
|
||||
|
@ -107,7 +107,7 @@ TEST_F(SwitchStatementTest, IsValid_Invalid_Condition) {
|
|||
|
||||
TEST_F(SwitchStatementTest, IsValid_Null_BodyStatement) {
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(ty.i32, 2));
|
||||
lit.push_back(create<SintLiteral>(ty.i32(), 2));
|
||||
|
||||
auto* ident = Expr("ident");
|
||||
CaseStatementList body;
|
||||
|
@ -148,7 +148,7 @@ TEST_F(SwitchStatementTest, ToStr_Empty) {
|
|||
|
||||
TEST_F(SwitchStatementTest, ToStr) {
|
||||
CaseSelectorList lit;
|
||||
lit.push_back(create<SintLiteral>(ty.i32, 2));
|
||||
lit.push_back(create<SintLiteral>(ty.i32(), 2));
|
||||
|
||||
auto* ident = Expr("ident");
|
||||
CaseStatementList body;
|
||||
|
|
|
@ -33,8 +33,8 @@ TEST_F(TypeConstructorExpressionTest, Creation) {
|
|||
ExpressionList expr;
|
||||
expr.push_back(Expr("expr"));
|
||||
|
||||
auto* t = create<TypeConstructorExpression>(ty.f32, expr);
|
||||
EXPECT_EQ(t->type(), ty.f32);
|
||||
auto* t = create<TypeConstructorExpression>(ty.f32(), expr);
|
||||
EXPECT_EQ(t->type(), ty.f32());
|
||||
ASSERT_EQ(t->values().size(), 1u);
|
||||
EXPECT_EQ(t->values()[0], expr[0]);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ TEST_F(TypeConstructorExpressionTest, Creation_WithSource) {
|
|||
expr.push_back(Expr("expr"));
|
||||
|
||||
auto* t = create<TypeConstructorExpression>(Source{Source::Location{20, 2}},
|
||||
ty.f32, expr);
|
||||
ty.f32(), expr);
|
||||
auto src = t->source();
|
||||
EXPECT_EQ(src.range.begin.line, 20u);
|
||||
EXPECT_EQ(src.range.begin.column, 2u);
|
||||
|
@ -54,7 +54,7 @@ TEST_F(TypeConstructorExpressionTest, IsTypeConstructor) {
|
|||
ExpressionList expr;
|
||||
expr.push_back(Expr("expr"));
|
||||
|
||||
auto* t = create<TypeConstructorExpression>(ty.f32, expr);
|
||||
auto* t = create<TypeConstructorExpression>(ty.f32(), expr);
|
||||
EXPECT_TRUE(t->Is<TypeConstructorExpression>());
|
||||
}
|
||||
|
||||
|
@ -62,14 +62,14 @@ TEST_F(TypeConstructorExpressionTest, IsValid) {
|
|||
ExpressionList expr;
|
||||
expr.push_back(Expr("expr"));
|
||||
|
||||
auto* t = create<TypeConstructorExpression>(ty.f32, expr);
|
||||
auto* t = create<TypeConstructorExpression>(ty.f32(), expr);
|
||||
EXPECT_TRUE(t->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(TypeConstructorExpressionTest, IsValid_EmptyValue) {
|
||||
ExpressionList expr;
|
||||
|
||||
auto* t = create<TypeConstructorExpression>(ty.f32, expr);
|
||||
auto* t = create<TypeConstructorExpression>(ty.f32(), expr);
|
||||
EXPECT_TRUE(t->IsValid());
|
||||
}
|
||||
|
||||
|
@ -86,7 +86,7 @@ TEST_F(TypeConstructorExpressionTest, IsValid_NullValue) {
|
|||
expr.push_back(Expr("expr"));
|
||||
expr.push_back(nullptr);
|
||||
|
||||
auto* t = create<TypeConstructorExpression>(ty.f32, expr);
|
||||
auto* t = create<TypeConstructorExpression>(ty.f32(), expr);
|
||||
EXPECT_FALSE(t->IsValid());
|
||||
}
|
||||
|
||||
|
@ -94,12 +94,12 @@ TEST_F(TypeConstructorExpressionTest, IsValid_InvalidValue) {
|
|||
ExpressionList expr;
|
||||
expr.push_back(Expr(""));
|
||||
|
||||
auto* t = create<TypeConstructorExpression>(ty.f32, expr);
|
||||
auto* t = create<TypeConstructorExpression>(ty.f32(), expr);
|
||||
EXPECT_FALSE(t->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(TypeConstructorExpressionTest, ToStr) {
|
||||
type::Vector vec(ty.f32, 3);
|
||||
type::Vector vec(ty.f32(), 3);
|
||||
ExpressionList expr;
|
||||
expr.push_back(Expr("expr_1"));
|
||||
expr.push_back(Expr("expr_2"));
|
||||
|
|
|
@ -28,13 +28,13 @@ namespace {
|
|||
using UintLiteralTest = TestHelper;
|
||||
|
||||
TEST_F(UintLiteralTest, Value) {
|
||||
auto* u = create<UintLiteral>(ty.u32, 47);
|
||||
auto* u = create<UintLiteral>(ty.u32(), 47);
|
||||
ASSERT_TRUE(u->Is<UintLiteral>());
|
||||
EXPECT_EQ(u->value(), 47u);
|
||||
}
|
||||
|
||||
TEST_F(UintLiteralTest, Is) {
|
||||
ast::Literal* l = create<UintLiteral>(ty.u32, 42);
|
||||
ast::Literal* l = create<UintLiteral>(ty.u32(), 42);
|
||||
EXPECT_FALSE(l->Is<BoolLiteral>());
|
||||
EXPECT_FALSE(l->Is<SintLiteral>());
|
||||
EXPECT_FALSE(l->Is<FloatLiteral>());
|
||||
|
@ -43,7 +43,7 @@ TEST_F(UintLiteralTest, Is) {
|
|||
}
|
||||
|
||||
TEST_F(UintLiteralTest, ToStr) {
|
||||
auto* u = create<UintLiteral>(ty.u32, 42);
|
||||
auto* u = create<UintLiteral>(ty.u32(), 42);
|
||||
EXPECT_EQ(u->to_str(), "42");
|
||||
}
|
||||
|
||||
|
|
|
@ -25,14 +25,14 @@ namespace {
|
|||
using VariableDeclStatementTest = TestHelper;
|
||||
|
||||
TEST_F(VariableDeclStatementTest, Creation) {
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32());
|
||||
|
||||
auto* stmt = create<VariableDeclStatement>(var);
|
||||
EXPECT_EQ(stmt->variable(), var);
|
||||
}
|
||||
|
||||
TEST_F(VariableDeclStatementTest, Creation_WithSource) {
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32());
|
||||
|
||||
auto* stmt =
|
||||
create<VariableDeclStatement>(Source{Source::Location{20, 2}}, var);
|
||||
|
@ -42,20 +42,20 @@ TEST_F(VariableDeclStatementTest, Creation_WithSource) {
|
|||
}
|
||||
|
||||
TEST_F(VariableDeclStatementTest, IsVariableDecl) {
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32());
|
||||
|
||||
auto* stmt = create<VariableDeclStatement>(var);
|
||||
EXPECT_TRUE(stmt->Is<VariableDeclStatement>());
|
||||
}
|
||||
|
||||
TEST_F(VariableDeclStatementTest, IsValid) {
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32());
|
||||
auto* stmt = create<VariableDeclStatement>(var);
|
||||
EXPECT_TRUE(stmt->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableDeclStatementTest, IsValid_InvalidVariable) {
|
||||
auto* var = Var("", StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("", StorageClass::kNone, ty.f32());
|
||||
auto* stmt = create<VariableDeclStatement>(var);
|
||||
EXPECT_FALSE(stmt->IsValid());
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ TEST_F(VariableDeclStatementTest, IsValid_NullVariable) {
|
|||
}
|
||||
|
||||
TEST_F(VariableDeclStatementTest, ToStr) {
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("a", StorageClass::kNone, ty.f32());
|
||||
|
||||
auto* stmt =
|
||||
create<VariableDeclStatement>(Source{Source::Location{20, 2}}, var);
|
||||
|
|
|
@ -27,11 +27,11 @@ namespace {
|
|||
using VariableTest = TestHelper;
|
||||
|
||||
TEST_F(VariableTest, Creation) {
|
||||
auto* v = Var("my_var", StorageClass::kFunction, ty.i32);
|
||||
auto* v = Var("my_var", StorageClass::kFunction, ty.i32());
|
||||
|
||||
EXPECT_EQ(v->symbol(), Symbol(1));
|
||||
EXPECT_EQ(v->storage_class(), StorageClass::kFunction);
|
||||
EXPECT_EQ(v->type(), ty.i32);
|
||||
EXPECT_EQ(v->type(), ty.i32());
|
||||
EXPECT_EQ(v->source().range.begin.line, 0u);
|
||||
EXPECT_EQ(v->source().range.begin.column, 0u);
|
||||
EXPECT_EQ(v->source().range.end.line, 0u);
|
||||
|
@ -41,11 +41,11 @@ TEST_F(VariableTest, Creation) {
|
|||
TEST_F(VariableTest, CreationWithSource) {
|
||||
auto* v = Var(
|
||||
Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 5}}},
|
||||
"i", StorageClass::kPrivate, ty.f32, nullptr, VariableDecorationList{});
|
||||
"i", StorageClass::kPrivate, ty.f32(), nullptr, VariableDecorationList{});
|
||||
|
||||
EXPECT_EQ(v->symbol(), Symbol(1));
|
||||
EXPECT_EQ(v->storage_class(), StorageClass::kPrivate);
|
||||
EXPECT_EQ(v->type(), ty.f32);
|
||||
EXPECT_EQ(v->type(), ty.f32());
|
||||
EXPECT_EQ(v->source().range.begin.line, 27u);
|
||||
EXPECT_EQ(v->source().range.begin.column, 4u);
|
||||
EXPECT_EQ(v->source().range.end.line, 27u);
|
||||
|
@ -55,12 +55,12 @@ TEST_F(VariableTest, CreationWithSource) {
|
|||
TEST_F(VariableTest, CreationEmpty) {
|
||||
auto* v = Var(
|
||||
Source{Source::Range{Source::Location{27, 4}, Source::Location{27, 7}}},
|
||||
"a_var", StorageClass::kWorkgroup, ty.i32, nullptr,
|
||||
"a_var", StorageClass::kWorkgroup, ty.i32(), nullptr,
|
||||
VariableDecorationList{});
|
||||
|
||||
EXPECT_EQ(v->symbol(), Symbol(1));
|
||||
EXPECT_EQ(v->storage_class(), StorageClass::kWorkgroup);
|
||||
EXPECT_EQ(v->type(), ty.i32);
|
||||
EXPECT_EQ(v->type(), ty.i32());
|
||||
EXPECT_EQ(v->source().range.begin.line, 27u);
|
||||
EXPECT_EQ(v->source().range.begin.column, 4u);
|
||||
EXPECT_EQ(v->source().range.end.line, 27u);
|
||||
|
@ -68,18 +68,18 @@ TEST_F(VariableTest, CreationEmpty) {
|
|||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid) {
|
||||
auto* v = Var("my_var", StorageClass::kNone, ty.i32);
|
||||
auto* v = Var("my_var", StorageClass::kNone, ty.i32());
|
||||
EXPECT_TRUE(v->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid_WithConstructor) {
|
||||
auto* v = Var("my_var", StorageClass::kNone, ty.i32, Expr("ident"),
|
||||
auto* v = Var("my_var", StorageClass::kNone, ty.i32(), Expr("ident"),
|
||||
ast::VariableDecorationList{});
|
||||
EXPECT_TRUE(v->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid_MissingSymbol) {
|
||||
auto* v = Var("", StorageClass::kNone, ty.i32);
|
||||
auto* v = Var("", StorageClass::kNone, ty.i32());
|
||||
EXPECT_FALSE(v->IsValid());
|
||||
}
|
||||
|
||||
|
@ -94,13 +94,13 @@ TEST_F(VariableTest, IsValid_MissingBoth) {
|
|||
}
|
||||
|
||||
TEST_F(VariableTest, IsValid_InvalidConstructor) {
|
||||
auto* v = Var("my_var", StorageClass::kNone, ty.i32, Expr(""),
|
||||
auto* v = Var("my_var", StorageClass::kNone, ty.i32(), Expr(""),
|
||||
ast::VariableDecorationList{});
|
||||
EXPECT_FALSE(v->IsValid());
|
||||
}
|
||||
|
||||
TEST_F(VariableTest, to_str) {
|
||||
auto* v = Var("my_var", StorageClass::kFunction, ty.f32, nullptr,
|
||||
auto* v = Var("my_var", StorageClass::kFunction, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{});
|
||||
std::ostringstream out;
|
||||
v->to_str(out, 2);
|
||||
|
@ -113,7 +113,7 @@ TEST_F(VariableTest, to_str) {
|
|||
}
|
||||
|
||||
TEST_F(VariableTest, WithDecorations) {
|
||||
auto* var = Var("my_var", StorageClass::kFunction, ty.i32, nullptr,
|
||||
auto* var = Var("my_var", StorageClass::kFunction, ty.i32(), nullptr,
|
||||
VariableDecorationList{
|
||||
create<LocationDecoration>(1),
|
||||
create<BuiltinDecoration>(Builtin::kPosition),
|
||||
|
@ -130,7 +130,7 @@ TEST_F(VariableTest, WithDecorations) {
|
|||
}
|
||||
|
||||
TEST_F(VariableTest, ConstantId) {
|
||||
auto* var = Var("my_var", StorageClass::kFunction, ty.i32, nullptr,
|
||||
auto* var = Var("my_var", StorageClass::kFunction, ty.i32(), nullptr,
|
||||
VariableDecorationList{
|
||||
create<ConstantIdDecoration>(1200),
|
||||
});
|
||||
|
@ -139,7 +139,7 @@ TEST_F(VariableTest, ConstantId) {
|
|||
}
|
||||
|
||||
TEST_F(VariableTest, Decorated_to_str) {
|
||||
auto* var = Var("my_var", StorageClass::kFunction, ty.f32, Expr("expr"),
|
||||
auto* var = Var("my_var", StorageClass::kFunction, ty.f32(), Expr("expr"),
|
||||
VariableDecorationList{
|
||||
create<BindingDecoration>(2),
|
||||
create<GroupDecoration>(1),
|
||||
|
|
|
@ -82,7 +82,7 @@ class InspectorHelper : public ast::BuilderWithProgram {
|
|||
ast::Function* MakeEmptyBodyFunction(
|
||||
std::string name,
|
||||
ast::FunctionDecorationList decorations) {
|
||||
return Func(name, ast::VariableList(), ty.void_,
|
||||
return Func(name, ast::VariableList(), ty.void_(),
|
||||
ast::StatementList{create<ast::ReturnStatement>()},
|
||||
decorations);
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ class InspectorHelper : public ast::BuilderWithProgram {
|
|||
std::string caller,
|
||||
std::string callee,
|
||||
ast::FunctionDecorationList decorations) {
|
||||
return Func(caller, ast::VariableList(), ty.void_,
|
||||
return Func(caller, ast::VariableList(), ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::CallStatement>(Call(callee)),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -115,11 +115,11 @@ class InspectorHelper : public ast::BuilderWithProgram {
|
|||
std::tie(in, out) = inout;
|
||||
|
||||
mod->AST().AddGlobalVariable(
|
||||
Var(in, ast::StorageClass::kInput, ty.u32, nullptr,
|
||||
Var(in, ast::StorageClass::kInput, ty.u32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(location++)}));
|
||||
mod->AST().AddGlobalVariable(
|
||||
Var(out, ast::StorageClass::kOutput, ty.u32, nullptr,
|
||||
Var(out, ast::StorageClass::kOutput, ty.u32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(location++)}));
|
||||
}
|
||||
|
@ -142,7 +142,7 @@ class InspectorHelper : public ast::BuilderWithProgram {
|
|||
stmts.emplace_back(create<ast::AssignmentStatement>(Expr(out), Expr(in)));
|
||||
}
|
||||
stmts.emplace_back(create<ast::ReturnStatement>());
|
||||
return Func(name, ast::VariableList(), ty.void_, stmts, decorations);
|
||||
return Func(name, ast::VariableList(), ty.void_(), stmts, decorations);
|
||||
}
|
||||
|
||||
/// Generates a function that references in/out variables and calls another
|
||||
|
@ -167,7 +167,7 @@ class InspectorHelper : public ast::BuilderWithProgram {
|
|||
stmts.emplace_back(create<ast::CallStatement>(Call(callee)));
|
||||
stmts.emplace_back(create<ast::ReturnStatement>());
|
||||
|
||||
return Func(caller, ast::VariableList(), ty.void_, stmts, decorations);
|
||||
return Func(caller, ast::VariableList(), ty.void_(), stmts, decorations);
|
||||
}
|
||||
|
||||
/// Add a Constant ID to the global variables.
|
||||
|
@ -394,7 +394,7 @@ class InspectorHelper : public ast::BuilderWithProgram {
|
|||
|
||||
stmts.emplace_back(create<ast::ReturnStatement>());
|
||||
|
||||
return Func(func_name, ast::VariableList(), ty.void_, stmts,
|
||||
return Func(func_name, ast::VariableList(), ty.void_(), stmts,
|
||||
ast::FunctionDecorationList{});
|
||||
}
|
||||
|
||||
|
@ -508,7 +508,7 @@ class InspectorHelper : public ast::BuilderWithProgram {
|
|||
Call("textureSample", texture_name, sampler_name, coords_name)));
|
||||
stmts.emplace_back(create<ast::ReturnStatement>());
|
||||
|
||||
return Func(func_name, ast::VariableList(), ty.void_, stmts, decorations);
|
||||
return Func(func_name, ast::VariableList(), ty.void_(), stmts, decorations);
|
||||
}
|
||||
|
||||
/// Generates a function that references a specific sampler variable
|
||||
|
@ -541,7 +541,7 @@ class InspectorHelper : public ast::BuilderWithProgram {
|
|||
sampler_name, coords_name, array_index)));
|
||||
stmts.emplace_back(create<ast::ReturnStatement>());
|
||||
|
||||
return Func(func_name, ast::VariableList(), ty.void_, stmts, decorations);
|
||||
return Func(func_name, ast::VariableList(), ty.void_(), stmts, decorations);
|
||||
}
|
||||
|
||||
/// Generates a function that references a specific comparison sampler
|
||||
|
@ -573,7 +573,7 @@ class InspectorHelper : public ast::BuilderWithProgram {
|
|||
sampler_name, coords_name, depth_name)));
|
||||
stmts.emplace_back(create<ast::ReturnStatement>());
|
||||
|
||||
return Func(func_name, ast::VariableList(), ty.void_, stmts, decorations);
|
||||
return Func(func_name, ast::VariableList(), ty.void_(), stmts, decorations);
|
||||
}
|
||||
|
||||
/// Gets an appropriate type for the data in a given texture type.
|
||||
|
@ -582,11 +582,11 @@ class InspectorHelper : public ast::BuilderWithProgram {
|
|||
type::Type* GetBaseType(ResourceBinding::SampledKind sampled_kind) {
|
||||
switch (sampled_kind) {
|
||||
case ResourceBinding::SampledKind::kFloat:
|
||||
return ty.f32;
|
||||
return ty.f32();
|
||||
case ResourceBinding::SampledKind::kSInt:
|
||||
return ty.i32;
|
||||
return ty.i32();
|
||||
case ResourceBinding::SampledKind::kUInt:
|
||||
return ty.u32;
|
||||
return ty.u32();
|
||||
default:
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -617,7 +617,7 @@ class InspectorHelper : public ast::BuilderWithProgram {
|
|||
type::Array* u32_array_type(uint32_t count) {
|
||||
if (array_type_memo_.find(count) == array_type_memo_.end()) {
|
||||
array_type_memo_[count] =
|
||||
create<type::Array>(ty.u32, count,
|
||||
create<type::Array>(ty.u32(), count,
|
||||
ast::ArrayDecorationList{
|
||||
create<ast::StrideDecoration>(4),
|
||||
});
|
||||
|
@ -628,7 +628,7 @@ class InspectorHelper : public ast::BuilderWithProgram {
|
|||
if (vector_type_memo_.find(std::tie(type, count)) ==
|
||||
vector_type_memo_.end()) {
|
||||
vector_type_memo_[std::tie(type, count)] =
|
||||
create<type::Vector>(ty.u32, count);
|
||||
create<type::Vector>(ty.u32(), count);
|
||||
}
|
||||
return vector_type_memo_[std::tie(type, count)];
|
||||
}
|
||||
|
@ -1115,11 +1115,11 @@ TEST_F(InspectorGetEntryPointTest, MultipleEntryPointsSharedInOutVariables) {
|
|||
|
||||
TEST_F(InspectorGetEntryPointTest, BuiltInsNotStageVariables) {
|
||||
mod->AST().AddGlobalVariable(
|
||||
Var("in_var", ast::StorageClass::kInput, ty.u32, nullptr,
|
||||
Var("in_var", ast::StorageClass::kInput, ty.u32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kPosition)}));
|
||||
mod->AST().AddGlobalVariable(
|
||||
Var("out_var", ast::StorageClass::kOutput, ty.u32, nullptr,
|
||||
Var("out_var", ast::StorageClass::kOutput, ty.u32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(0)}));
|
||||
auto* func =
|
||||
MakeInOutVariableBodyFunction("func", {{"in_var", "out_var"}}, {});
|
||||
|
@ -1220,9 +1220,9 @@ TEST_F(InspectorGetRemappedNameForEntryPointTest,
|
|||
TEST_F(InspectorGetConstantIDsTest, Bool) {
|
||||
bool val_true = true;
|
||||
bool val_false = false;
|
||||
AddConstantID<bool>("foo", 1, ty.bool_, nullptr);
|
||||
AddConstantID<bool>("bar", 20, ty.bool_, &val_true);
|
||||
AddConstantID<bool>("baz", 300, ty.bool_, &val_false);
|
||||
AddConstantID<bool>("foo", 1, ty.bool_(), nullptr);
|
||||
AddConstantID<bool>("bar", 20, ty.bool_(), &val_true);
|
||||
AddConstantID<bool>("baz", 300, ty.bool_(), &val_false);
|
||||
|
||||
auto result = inspector()->GetConstantIDs();
|
||||
ASSERT_EQ(3u, result.size());
|
||||
|
@ -1241,8 +1241,8 @@ TEST_F(InspectorGetConstantIDsTest, Bool) {
|
|||
|
||||
TEST_F(InspectorGetConstantIDsTest, U32) {
|
||||
uint32_t val = 42;
|
||||
AddConstantID<uint32_t>("foo", 1, ty.u32, nullptr);
|
||||
AddConstantID<uint32_t>("bar", 20, ty.u32, &val);
|
||||
AddConstantID<uint32_t>("foo", 1, ty.u32(), nullptr);
|
||||
AddConstantID<uint32_t>("bar", 20, ty.u32(), &val);
|
||||
|
||||
auto result = inspector()->GetConstantIDs();
|
||||
ASSERT_EQ(2u, result.size());
|
||||
|
@ -1258,9 +1258,9 @@ TEST_F(InspectorGetConstantIDsTest, U32) {
|
|||
TEST_F(InspectorGetConstantIDsTest, I32) {
|
||||
int32_t val_neg = -42;
|
||||
int32_t val_pos = 42;
|
||||
AddConstantID<int32_t>("foo", 1, ty.i32, nullptr);
|
||||
AddConstantID<int32_t>("bar", 20, ty.i32, &val_neg);
|
||||
AddConstantID<int32_t>("baz", 300, ty.i32, &val_pos);
|
||||
AddConstantID<int32_t>("foo", 1, ty.i32(), nullptr);
|
||||
AddConstantID<int32_t>("bar", 20, ty.i32(), &val_neg);
|
||||
AddConstantID<int32_t>("baz", 300, ty.i32(), &val_pos);
|
||||
|
||||
auto result = inspector()->GetConstantIDs();
|
||||
ASSERT_EQ(3u, result.size());
|
||||
|
@ -1281,10 +1281,10 @@ TEST_F(InspectorGetConstantIDsTest, Float) {
|
|||
float val_zero = 0.0f;
|
||||
float val_neg = -10.0f;
|
||||
float val_pos = 15.0f;
|
||||
AddConstantID<float>("foo", 1, ty.f32, nullptr);
|
||||
AddConstantID<float>("bar", 20, ty.f32, &val_zero);
|
||||
AddConstantID<float>("baz", 300, ty.f32, &val_neg);
|
||||
AddConstantID<float>("x", 4000, ty.f32, &val_pos);
|
||||
AddConstantID<float>("foo", 1, ty.f32(), nullptr);
|
||||
AddConstantID<float>("bar", 20, ty.f32(), &val_zero);
|
||||
AddConstantID<float>("baz", 300, ty.f32(), &val_neg);
|
||||
AddConstantID<float>("x", 4000, ty.f32(), &val_pos);
|
||||
|
||||
auto result = inspector()->GetConstantIDs();
|
||||
ASSERT_EQ(4u, result.size());
|
||||
|
@ -1316,11 +1316,11 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, NonEntryPointFunc) {
|
|||
type::Struct* foo_struct_type;
|
||||
type::AccessControl* foo_control_type;
|
||||
std::tie(foo_struct_type, foo_control_type) =
|
||||
MakeUniformBufferTypes("foo_type", {{ty.i32, 0}});
|
||||
MakeUniformBufferTypes("foo_type", {{ty.i32(), 0}});
|
||||
AddUniformBuffer("foo_ub", foo_control_type, 0, 0);
|
||||
|
||||
auto* ub_func = MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub",
|
||||
{{0, ty.i32}});
|
||||
{{0, ty.i32()}});
|
||||
mod->AST().Functions().Add(ub_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1341,14 +1341,14 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MissingBlockDeco) {
|
|||
ast::StructDecorationList decos;
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{
|
||||
Member(StructMemberName(0, ty.i32), ty.i32, {MemberOffset(0)})},
|
||||
Member(StructMemberName(0, ty.i32()), ty.i32(), {MemberOffset(0)})},
|
||||
decos);
|
||||
|
||||
auto* foo_type = ty.struct_("foo_type", str);
|
||||
AddUniformBuffer("foo_ub", foo_type, 0, 0);
|
||||
|
||||
auto* ub_func = MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub",
|
||||
{{0, ty.i32}});
|
||||
{{0, ty.i32()}});
|
||||
mod->AST().Functions().Add(ub_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1369,11 +1369,11 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, Simple) {
|
|||
type::Struct* foo_struct_type;
|
||||
type::AccessControl* foo_control_type;
|
||||
std::tie(foo_struct_type, foo_control_type) =
|
||||
MakeUniformBufferTypes("foo_type", {{ty.i32, 0}});
|
||||
MakeUniformBufferTypes("foo_type", {{ty.i32(), 0}});
|
||||
AddUniformBuffer("foo_ub", foo_control_type, 0, 0);
|
||||
|
||||
auto* ub_func = MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub",
|
||||
{{0, ty.i32}});
|
||||
{{0, ty.i32()}});
|
||||
mod->AST().Functions().Add(ub_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1398,11 +1398,11 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleMembers) {
|
|||
type::Struct* foo_struct_type;
|
||||
type::AccessControl* foo_control_type;
|
||||
std::tie(foo_struct_type, foo_control_type) = MakeUniformBufferTypes(
|
||||
"foo_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
||||
"foo_type", {{ty.i32(), 0}, {ty.u32(), 4}, {ty.f32(), 8}});
|
||||
AddUniformBuffer("foo_ub", foo_control_type, 0, 0);
|
||||
|
||||
auto* ub_func = MakeStructVariableReferenceBodyFunction(
|
||||
"ub_func", "foo_ub", {{0, ty.i32}, {1, ty.u32}, {2, ty.f32}});
|
||||
"ub_func", "foo_ub", {{0, ty.i32()}, {1, ty.u32()}, {2, ty.f32()}});
|
||||
mod->AST().Functions().Add(ub_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1427,7 +1427,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
|
|||
type::Struct* ub_struct_type;
|
||||
type::AccessControl* ub_control_type;
|
||||
std::tie(ub_struct_type, ub_control_type) = MakeUniformBufferTypes(
|
||||
"ub_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
||||
"ub_type", {{ty.i32(), 0}, {ty.u32(), 4}, {ty.f32(), 8}});
|
||||
AddUniformBuffer("ub_foo", ub_control_type, 0, 0);
|
||||
AddUniformBuffer("ub_bar", ub_control_type, 0, 1);
|
||||
AddUniformBuffer("ub_baz", ub_control_type, 2, 0);
|
||||
|
@ -1435,7 +1435,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
|
|||
auto AddReferenceFunc = [this](const std::string& func_name,
|
||||
const std::string& var_name) {
|
||||
auto* ub_func = MakeStructVariableReferenceBodyFunction(
|
||||
func_name, var_name, {{0, ty.i32}, {1, ty.u32}, {2, ty.f32}});
|
||||
func_name, var_name, {{0, ty.i32()}, {1, ty.u32()}, {2, ty.f32()}});
|
||||
mod->AST().Functions().Add(ub_func);
|
||||
};
|
||||
AddReferenceFunc("ub_foo_func", "ub_foo");
|
||||
|
@ -1447,7 +1447,7 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
|
|||
};
|
||||
|
||||
ast::Function* func =
|
||||
Func("ep_func", ast::VariableList(), ty.void_,
|
||||
Func("ep_func", ast::VariableList(), ty.void_(),
|
||||
ast::StatementList{FuncCall("ub_foo_func"), FuncCall("ub_bar_func"),
|
||||
FuncCall("ub_baz_func"),
|
||||
create<ast::ReturnStatement>()},
|
||||
|
@ -1478,12 +1478,12 @@ TEST_F(InspectorGetUniformBufferResourceBindingsTest, MultipleUniformBuffers) {
|
|||
TEST_F(InspectorGetUniformBufferResourceBindingsTest, ContainingArray) {
|
||||
type::Struct* foo_struct_type;
|
||||
type::AccessControl* foo_control_type;
|
||||
std::tie(foo_struct_type, foo_control_type) =
|
||||
MakeUniformBufferTypes("foo_type", {{ty.i32, 0}, {u32_array_type(4), 4}});
|
||||
std::tie(foo_struct_type, foo_control_type) = MakeUniformBufferTypes(
|
||||
"foo_type", {{ty.i32(), 0}, {u32_array_type(4), 4}});
|
||||
AddUniformBuffer("foo_ub", foo_control_type, 0, 0);
|
||||
|
||||
auto* ub_func = MakeStructVariableReferenceBodyFunction("ub_func", "foo_ub",
|
||||
{{0, ty.i32}});
|
||||
{{0, ty.i32()}});
|
||||
mod->AST().Functions().Add(ub_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1508,11 +1508,11 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, Simple) {
|
|||
type::Struct* foo_struct_type;
|
||||
type::AccessControl* foo_control_type;
|
||||
std::tie(foo_struct_type, foo_control_type) =
|
||||
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}});
|
||||
MakeStorageBufferTypes("foo_type", {{ty.i32(), 0}});
|
||||
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
|
||||
|
||||
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
|
||||
{{0, ty.i32}});
|
||||
{{0, ty.i32()}});
|
||||
mod->AST().Functions().Add(sb_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1537,11 +1537,11 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleMembers) {
|
|||
type::Struct* foo_struct_type;
|
||||
type::AccessControl* foo_control_type;
|
||||
std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes(
|
||||
"foo_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
||||
"foo_type", {{ty.i32(), 0}, {ty.u32(), 4}, {ty.f32(), 8}});
|
||||
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
|
||||
|
||||
auto* sb_func = MakeStructVariableReferenceBodyFunction(
|
||||
"sb_func", "foo_sb", {{0, ty.i32}, {1, ty.u32}, {2, ty.f32}});
|
||||
"sb_func", "foo_sb", {{0, ty.i32()}, {1, ty.u32()}, {2, ty.f32()}});
|
||||
mod->AST().Functions().Add(sb_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1566,7 +1566,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
|
|||
type::Struct* sb_struct_type;
|
||||
type::AccessControl* sb_control_type;
|
||||
std::tie(sb_struct_type, sb_control_type) = MakeStorageBufferTypes(
|
||||
"sb_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
||||
"sb_type", {{ty.i32(), 0}, {ty.u32(), 4}, {ty.f32(), 8}});
|
||||
AddStorageBuffer("sb_foo", sb_control_type, 0, 0);
|
||||
AddStorageBuffer("sb_bar", sb_control_type, 0, 1);
|
||||
AddStorageBuffer("sb_baz", sb_control_type, 2, 0);
|
||||
|
@ -1574,7 +1574,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
|
|||
auto AddReferenceFunc = [this](const std::string& func_name,
|
||||
const std::string& var_name) {
|
||||
auto* sb_func = MakeStructVariableReferenceBodyFunction(
|
||||
func_name, var_name, {{0, ty.i32}, {1, ty.u32}, {2, ty.f32}});
|
||||
func_name, var_name, {{0, ty.i32()}, {1, ty.u32()}, {2, ty.f32()}});
|
||||
mod->AST().Functions().Add(sb_func);
|
||||
};
|
||||
AddReferenceFunc("sb_foo_func", "sb_foo");
|
||||
|
@ -1586,7 +1586,7 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
|
|||
};
|
||||
|
||||
ast::Function* func =
|
||||
Func("ep_func", ast::VariableList(), ty.void_,
|
||||
Func("ep_func", ast::VariableList(), ty.void_(),
|
||||
ast::StatementList{
|
||||
FuncCall("sb_foo_func"),
|
||||
FuncCall("sb_bar_func"),
|
||||
|
@ -1620,12 +1620,12 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, MultipleStorageBuffers) {
|
|||
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) {
|
||||
type::Struct* foo_struct_type;
|
||||
type::AccessControl* foo_control_type;
|
||||
std::tie(foo_struct_type, foo_control_type) =
|
||||
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}, {u32_array_type(4), 4}});
|
||||
std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes(
|
||||
"foo_type", {{ty.i32(), 0}, {u32_array_type(4), 4}});
|
||||
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
|
||||
|
||||
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
|
||||
{{0, ty.i32}});
|
||||
{{0, ty.i32()}});
|
||||
mod->AST().Functions().Add(sb_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1649,12 +1649,12 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingArray) {
|
|||
TEST_F(InspectorGetStorageBufferResourceBindingsTest, ContainingRuntimeArray) {
|
||||
type::Struct* foo_struct_type;
|
||||
type::AccessControl* foo_control_type;
|
||||
std::tie(foo_struct_type, foo_control_type) =
|
||||
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}, {u32_array_type(0), 4}});
|
||||
std::tie(foo_struct_type, foo_control_type) = MakeStorageBufferTypes(
|
||||
"foo_type", {{ty.i32(), 0}, {u32_array_type(0), 4}});
|
||||
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
|
||||
|
||||
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
|
||||
{{0, ty.i32}});
|
||||
{{0, ty.i32()}});
|
||||
mod->AST().Functions().Add(sb_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1679,11 +1679,11 @@ TEST_F(InspectorGetStorageBufferResourceBindingsTest, SkipReadOnly) {
|
|||
type::Struct* foo_struct_type;
|
||||
type::AccessControl* foo_control_type;
|
||||
std::tie(foo_struct_type, foo_control_type) =
|
||||
MakeReadOnlyStorageBufferTypes("foo_type", {{ty.i32, 0}});
|
||||
MakeReadOnlyStorageBufferTypes("foo_type", {{ty.i32(), 0}});
|
||||
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
|
||||
|
||||
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
|
||||
{{0, ty.i32}});
|
||||
{{0, ty.i32()}});
|
||||
mod->AST().Functions().Add(sb_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1704,11 +1704,11 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, Simple) {
|
|||
type::Struct* foo_struct_type;
|
||||
type::AccessControl* foo_control_type;
|
||||
std::tie(foo_struct_type, foo_control_type) =
|
||||
MakeReadOnlyStorageBufferTypes("foo_type", {{ty.i32, 0}});
|
||||
MakeReadOnlyStorageBufferTypes("foo_type", {{ty.i32(), 0}});
|
||||
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
|
||||
|
||||
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
|
||||
{{0, ty.i32}});
|
||||
{{0, ty.i32()}});
|
||||
mod->AST().Functions().Add(sb_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1735,7 +1735,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
|
|||
type::Struct* sb_struct_type;
|
||||
type::AccessControl* sb_control_type;
|
||||
std::tie(sb_struct_type, sb_control_type) = MakeReadOnlyStorageBufferTypes(
|
||||
"sb_type", {{ty.i32, 0}, {ty.u32, 4}, {ty.f32, 8}});
|
||||
"sb_type", {{ty.i32(), 0}, {ty.u32(), 4}, {ty.f32(), 8}});
|
||||
AddStorageBuffer("sb_foo", sb_control_type, 0, 0);
|
||||
AddStorageBuffer("sb_bar", sb_control_type, 0, 1);
|
||||
AddStorageBuffer("sb_baz", sb_control_type, 2, 0);
|
||||
|
@ -1743,7 +1743,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
|
|||
auto AddReferenceFunc = [this](const std::string& func_name,
|
||||
const std::string& var_name) {
|
||||
auto* sb_func = MakeStructVariableReferenceBodyFunction(
|
||||
func_name, var_name, {{0, ty.i32}, {1, ty.u32}, {2, ty.f32}});
|
||||
func_name, var_name, {{0, ty.i32()}, {1, ty.u32()}, {2, ty.f32()}});
|
||||
mod->AST().Functions().Add(sb_func);
|
||||
};
|
||||
AddReferenceFunc("sb_foo_func", "sb_foo");
|
||||
|
@ -1755,7 +1755,7 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
|
|||
};
|
||||
|
||||
ast::Function* func =
|
||||
Func("ep_func", ast::VariableList(), ty.void_,
|
||||
Func("ep_func", ast::VariableList(), ty.void_(),
|
||||
ast::StatementList{
|
||||
FuncCall("sb_foo_func"),
|
||||
FuncCall("sb_bar_func"),
|
||||
|
@ -1791,11 +1791,11 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, ContainingArray) {
|
|||
type::Struct* foo_struct_type;
|
||||
type::AccessControl* foo_control_type;
|
||||
std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes(
|
||||
"foo_type", {{ty.i32, 0}, {u32_array_type(4), 4}});
|
||||
"foo_type", {{ty.i32(), 0}, {u32_array_type(4), 4}});
|
||||
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
|
||||
|
||||
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
|
||||
{{0, ty.i32}});
|
||||
{{0, ty.i32()}});
|
||||
mod->AST().Functions().Add(sb_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1822,11 +1822,11 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest,
|
|||
type::Struct* foo_struct_type;
|
||||
type::AccessControl* foo_control_type;
|
||||
std::tie(foo_struct_type, foo_control_type) = MakeReadOnlyStorageBufferTypes(
|
||||
"foo_type", {{ty.i32, 0}, {u32_array_type(0), 4}});
|
||||
"foo_type", {{ty.i32(), 0}, {u32_array_type(0), 4}});
|
||||
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
|
||||
|
||||
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
|
||||
{{0, ty.i32}});
|
||||
{{0, ty.i32()}});
|
||||
mod->AST().Functions().Add(sb_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1852,11 +1852,11 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
|
|||
type::Struct* foo_struct_type;
|
||||
type::AccessControl* foo_control_type;
|
||||
std::tie(foo_struct_type, foo_control_type) =
|
||||
MakeStorageBufferTypes("foo_type", {{ty.i32, 0}});
|
||||
MakeStorageBufferTypes("foo_type", {{ty.i32(), 0}});
|
||||
AddStorageBuffer("foo_sb", foo_control_type, 0, 0);
|
||||
|
||||
auto* sb_func = MakeStructVariableReferenceBodyFunction("sb_func", "foo_sb",
|
||||
{{0, ty.i32}});
|
||||
{{0, ty.i32()}});
|
||||
mod->AST().Functions().Add(sb_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1876,13 +1876,13 @@ TEST_F(InspectorGetReadOnlyStorageBufferResourceBindingsTest, SkipNonReadOnly) {
|
|||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, Simple) {
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(type::TextureDimension::k1d, ty.f32);
|
||||
MakeSampledTextureType(type::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
||||
auto* func = MakeSamplerReferenceBodyFunction(
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", ty.f32,
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", ty.f32(),
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
@ -1915,13 +1915,13 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, NoSampler) {
|
|||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(type::TextureDimension::k1d, ty.f32);
|
||||
MakeSampledTextureType(type::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
||||
auto* foo_func = MakeSamplerReferenceBodyFunction(
|
||||
"foo_func", "foo_texture", "foo_sampler", "foo_coords", ty.f32, {});
|
||||
"foo_func", "foo_texture", "foo_sampler", "foo_coords", ty.f32(), {});
|
||||
mod->AST().Functions().Add(foo_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -1943,13 +1943,13 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, InFunction) {
|
|||
|
||||
TEST_F(InspectorGetSamplerResourceBindingsTest, UnknownEntryPoint) {
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(type::TextureDimension::k1d, ty.f32);
|
||||
MakeSampledTextureType(type::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
||||
auto* func = MakeSamplerReferenceBodyFunction(
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", ty.f32,
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", ty.f32(),
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
@ -1965,11 +1965,11 @@ TEST_F(InspectorGetSamplerResourceBindingsTest, SkipsComparisonSamplers) {
|
|||
auto* depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
|
||||
AddDepthTexture("foo_texture", depth_texture_type);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32);
|
||||
AddGlobalVariable("foo_depth", ty.f32);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
AddGlobalVariable("foo_depth", ty.f32());
|
||||
|
||||
auto* func = MakeComparisonSamplerReferenceBodyFunction(
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", "foo_depth", ty.f32,
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", "foo_depth", ty.f32(),
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
@ -1987,11 +1987,11 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, Simple) {
|
|||
auto* depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
|
||||
AddDepthTexture("foo_texture", depth_texture_type);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32);
|
||||
AddGlobalVariable("foo_depth", ty.f32);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
AddGlobalVariable("foo_depth", ty.f32());
|
||||
|
||||
auto* func = MakeComparisonSamplerReferenceBodyFunction(
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", "foo_depth", ty.f32,
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", "foo_depth", ty.f32(),
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
@ -2026,12 +2026,12 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, InFunction) {
|
|||
auto* depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
|
||||
AddDepthTexture("foo_texture", depth_texture_type);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32);
|
||||
AddGlobalVariable("foo_depth", ty.f32);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
AddGlobalVariable("foo_depth", ty.f32());
|
||||
|
||||
auto* foo_func = MakeComparisonSamplerReferenceBodyFunction(
|
||||
"foo_func", "foo_texture", "foo_sampler", "foo_coords", "foo_depth",
|
||||
ty.f32, {});
|
||||
ty.f32(), {});
|
||||
mod->AST().Functions().Add(foo_func);
|
||||
|
||||
auto* ep_func = MakeCallerBodyFunction(
|
||||
|
@ -2055,11 +2055,11 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
|
|||
auto* depth_texture_type = MakeDepthTextureType(type::TextureDimension::k2d);
|
||||
AddDepthTexture("foo_texture", depth_texture_type);
|
||||
AddComparisonSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32);
|
||||
AddGlobalVariable("foo_depth", ty.f32);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
AddGlobalVariable("foo_depth", ty.f32());
|
||||
|
||||
auto* func = MakeComparisonSamplerReferenceBodyFunction(
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", "foo_depth", ty.f32,
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", "foo_depth", ty.f32(),
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
@ -2073,13 +2073,13 @@ TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, UnknownEntryPoint) {
|
|||
|
||||
TEST_F(InspectorGetComparisonSamplerResourceBindingsTest, SkipsSamplers) {
|
||||
auto* sampled_texture_type =
|
||||
MakeSampledTextureType(type::TextureDimension::k1d, ty.f32);
|
||||
MakeSampledTextureType(type::TextureDimension::k1d, ty.f32());
|
||||
AddSampledTexture("foo_texture", sampled_texture_type, 0, 0);
|
||||
AddSampler("foo_sampler", 0, 1);
|
||||
AddGlobalVariable("foo_coords", ty.f32);
|
||||
AddGlobalVariable("foo_coords", ty.f32());
|
||||
|
||||
auto* func = MakeSamplerReferenceBodyFunction(
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", ty.f32,
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", ty.f32(),
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
@ -2204,7 +2204,7 @@ TEST_P(InspectorGetSampledArrayTextureResourceBindingsTestWithParam,
|
|||
auto* coord_type =
|
||||
GetCoordsType(GetParam().type_dim, GetParam().sampled_kind);
|
||||
AddGlobalVariable("foo_coords", coord_type);
|
||||
AddGlobalVariable("foo_array_index", ty.u32);
|
||||
AddGlobalVariable("foo_array_index", ty.u32());
|
||||
|
||||
auto* func = MakeSamplerReferenceBodyFunction(
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", "foo_array_index",
|
||||
|
@ -2355,7 +2355,7 @@ TEST_P(InspectorGetMultisampledArrayTextureResourceBindingsTestWithParam,
|
|||
auto* coord_type =
|
||||
GetCoordsType(GetParam().type_dim, GetParam().sampled_kind);
|
||||
AddGlobalVariable("foo_coords", coord_type);
|
||||
AddGlobalVariable("foo_array_index", ty.u32);
|
||||
AddGlobalVariable("foo_array_index", ty.u32());
|
||||
|
||||
auto* func = MakeSamplerReferenceBodyFunction(
|
||||
"ep", "foo_texture", "foo_sampler", "foo_coords", "foo_array_index",
|
||||
|
|
|
@ -45,7 +45,7 @@ TEST_F(ProgramTest, IsValid_Empty) {
|
|||
}
|
||||
|
||||
TEST_F(ProgramTest, IsValid_GlobalVariable) {
|
||||
auto* var = Var("var", ast::StorageClass::kInput, ty.f32);
|
||||
auto* var = Var("var", ast::StorageClass::kInput, ty.f32());
|
||||
mod->AST().AddGlobalVariable(var);
|
||||
EXPECT_TRUE(mod->IsValid());
|
||||
}
|
||||
|
@ -62,7 +62,7 @@ TEST_F(ProgramTest, IsValid_Invalid_GlobalVariable) {
|
|||
}
|
||||
|
||||
TEST_F(ProgramTest, IsValid_Alias) {
|
||||
auto* alias = ty.alias("alias", ty.f32);
|
||||
auto* alias = ty.alias("alias", ty.f32());
|
||||
mod->AST().AddConstructedType(alias);
|
||||
EXPECT_TRUE(mod->IsValid());
|
||||
}
|
||||
|
@ -87,7 +87,7 @@ TEST_F(ProgramTest, IsValid_Struct_EmptyName) {
|
|||
}
|
||||
|
||||
TEST_F(ProgramTest, IsValid_Function) {
|
||||
auto* func = Func("main", ast::VariableList(), ty.f32, ast::StatementList{},
|
||||
auto* func = Func("main", ast::VariableList(), ty.f32(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
mod->AST().Functions().Add(func);
|
||||
|
|
|
@ -57,11 +57,11 @@ fn main() -> { // missing return type
|
|||
|
||||
TEST_F(ParserImplTest, GetRegisteredType) {
|
||||
auto p = parser("");
|
||||
p->register_constructed("my_alias", ty.i32);
|
||||
p->register_constructed("my_alias", ty.i32());
|
||||
|
||||
auto* alias = p->get_constructed("my_alias");
|
||||
ASSERT_NE(alias, nullptr);
|
||||
ASSERT_EQ(alias, ty.i32);
|
||||
ASSERT_EQ(alias, ty.i32());
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, GetUnregisteredType) {
|
||||
|
|
|
@ -756,7 +756,7 @@ TEST_F(ParserImplTest, TypeDecl_Texture_Old) {
|
|||
|
||||
auto& mod = p->get_program();
|
||||
auto* type =
|
||||
mod.create<type::SampledTexture>(type::TextureDimension::kCube, ty.f32);
|
||||
mod.create<type::SampledTexture>(type::TextureDimension::kCube, ty.f32());
|
||||
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
@ -773,7 +773,7 @@ TEST_F(ParserImplTest, TypeDecl_Texture) {
|
|||
|
||||
auto& mod = p->get_program();
|
||||
auto* type =
|
||||
mod.create<type::SampledTexture>(type::TextureDimension::kCube, ty.f32);
|
||||
mod.create<type::SampledTexture>(type::TextureDimension::kCube, ty.f32());
|
||||
|
||||
auto t = p->type_decl();
|
||||
EXPECT_TRUE(t.matched);
|
||||
|
|
|
@ -115,7 +115,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithTextureAccessDeco_Write) {
|
|||
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
||||
auto p = parser("my_var : [[access(read)]] S");
|
||||
|
||||
auto* mem = Member("a", ty.i32, ast::StructMemberDecorationList{});
|
||||
auto* mem = Member("a", ty.i32(), ast::StructMemberDecorationList{});
|
||||
ast::StructMemberList members;
|
||||
members.push_back(mem);
|
||||
|
||||
|
@ -140,7 +140,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_Read) {
|
|||
TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
||||
auto p = parser("my_var : [[access(read_write)]] S");
|
||||
|
||||
auto* mem = Member("a", ty.i32, ast::StructMemberDecorationList{});
|
||||
auto* mem = Member("a", ty.i32(), ast::StructMemberDecorationList{});
|
||||
ast::StructMemberList members;
|
||||
members.push_back(mem);
|
||||
|
||||
|
@ -165,7 +165,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_ParsesWithAccessDeco_ReadWrite) {
|
|||
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
|
||||
auto p = parser("my_var : [[access(read), access(read_write)]] S");
|
||||
|
||||
auto* mem = Member("a", ty.i32, ast::StructMemberDecorationList{});
|
||||
auto* mem = Member("a", ty.i32(), ast::StructMemberDecorationList{});
|
||||
ast::StructMemberList members;
|
||||
members.push_back(mem);
|
||||
|
||||
|
@ -187,7 +187,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDecoFail) {
|
|||
TEST_F(ParserImplTest, VariableIdentDecl_MultipleAccessDeco_MultiBlock_Fail) {
|
||||
auto p = parser("my_var : [[access(read)]][[access(read_write)]] S");
|
||||
|
||||
auto* mem = Member("a", ty.i32, ast::StructMemberDecorationList{});
|
||||
auto* mem = Member("a", ty.i32(), ast::StructMemberDecorationList{});
|
||||
ast::StructMemberList members;
|
||||
members.push_back(mem);
|
||||
|
||||
|
@ -225,7 +225,7 @@ TEST_F(ParserImplTest, VariableIdentDecl_AccessDecoIllegalValue) {
|
|||
TEST_F(ParserImplTest, VariableIdentDecl_NonAccessDecoFail) {
|
||||
auto p = parser("my_var : [[stride(1)]] S");
|
||||
|
||||
auto* mem = Member("a", ty.i32, ast::StructMemberDecorationList{});
|
||||
auto* mem = Member("a", ty.i32(), ast::StructMemberDecorationList{});
|
||||
ast::StructMemberList members;
|
||||
members.push_back(mem);
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ TEST_F(ScopeStackTest, Global) {
|
|||
}
|
||||
|
||||
TEST_F(ScopeStackTest, Global_SetWithPointer) {
|
||||
auto* v = Var("my_var", ast::StorageClass::kNone, ty.f32);
|
||||
auto* v = Var("my_var", ast::StorageClass::kNone, ty.f32());
|
||||
ScopeStack<ast::Variable*> s;
|
||||
s.set_global(v->symbol(), v);
|
||||
|
||||
|
|
|
@ -121,8 +121,8 @@ TEST_F(AccessControlTest, MinBufferBindingSizeRuntimeArray) {
|
|||
|
||||
TEST_F(AccessControlTest, MinBufferBindingSizeStruct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||
Member("bar", ty.u32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* struct_type = ty.struct_("struct_type", str);
|
||||
|
@ -155,8 +155,8 @@ TEST_F(AccessControlTest, BaseAlignmentRuntimeArray) {
|
|||
|
||||
TEST_F(AccessControlTest, BaseAlignmentStruct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||
Member("bar", ty.u32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* struct_type = ty.struct_("struct_type", str);
|
||||
|
||||
|
|
|
@ -41,13 +41,13 @@ namespace {
|
|||
using AliasTest = TestHelper;
|
||||
|
||||
TEST_F(AliasTest, Create) {
|
||||
auto* a = ty.alias("a_type", ty.u32);
|
||||
auto* a = ty.alias("a_type", ty.u32());
|
||||
EXPECT_EQ(a->symbol(), Symbol(1));
|
||||
EXPECT_EQ(a->type(), ty.u32);
|
||||
EXPECT_EQ(a->type(), ty.u32());
|
||||
}
|
||||
|
||||
TEST_F(AliasTest, Is) {
|
||||
auto* at = ty.alias("a", ty.i32);
|
||||
auto* at = ty.alias("a", ty.i32());
|
||||
type::Type* ty = at;
|
||||
EXPECT_FALSE(ty->Is<AccessControl>());
|
||||
EXPECT_TRUE(ty->Is<Alias>());
|
||||
|
@ -65,43 +65,43 @@ TEST_F(AliasTest, Is) {
|
|||
}
|
||||
|
||||
TEST_F(AliasTest, TypeName) {
|
||||
auto* at = ty.alias("Particle", ty.i32);
|
||||
auto* at = ty.alias("Particle", ty.i32());
|
||||
EXPECT_EQ(at->type_name(), "__alias_tint_symbol_1__i32");
|
||||
}
|
||||
|
||||
TEST_F(AliasTest, UnwrapIfNeeded_Alias) {
|
||||
auto* a = ty.alias("a_type", ty.u32);
|
||||
auto* a = ty.alias("a_type", ty.u32());
|
||||
EXPECT_EQ(a->symbol(), Symbol(1));
|
||||
EXPECT_EQ(a->type(), ty.u32);
|
||||
EXPECT_EQ(a->UnwrapIfNeeded(), ty.u32);
|
||||
EXPECT_EQ(ty.u32->UnwrapIfNeeded(), ty.u32);
|
||||
EXPECT_EQ(a->type(), ty.u32());
|
||||
EXPECT_EQ(a->UnwrapIfNeeded(), ty.u32());
|
||||
EXPECT_EQ(ty.u32()->UnwrapIfNeeded(), ty.u32());
|
||||
}
|
||||
|
||||
TEST_F(AliasTest, UnwrapIfNeeded_AccessControl) {
|
||||
AccessControl a{ast::AccessControl::kReadOnly, ty.u32};
|
||||
EXPECT_EQ(a.type(), ty.u32);
|
||||
EXPECT_EQ(a.UnwrapIfNeeded(), ty.u32);
|
||||
AccessControl a{ast::AccessControl::kReadOnly, ty.u32()};
|
||||
EXPECT_EQ(a.type(), ty.u32());
|
||||
EXPECT_EQ(a.UnwrapIfNeeded(), ty.u32());
|
||||
}
|
||||
|
||||
TEST_F(AliasTest, UnwrapIfNeeded_MultiLevel) {
|
||||
auto* a = ty.alias("a_type", ty.u32);
|
||||
auto* a = ty.alias("a_type", ty.u32());
|
||||
auto* aa = ty.alias("aa_type", a);
|
||||
|
||||
EXPECT_EQ(aa->symbol(), Symbol(2));
|
||||
EXPECT_EQ(aa->type(), a);
|
||||
EXPECT_EQ(aa->UnwrapIfNeeded(), ty.u32);
|
||||
EXPECT_EQ(aa->UnwrapIfNeeded(), ty.u32());
|
||||
}
|
||||
|
||||
TEST_F(AliasTest, UnwrapIfNeeded_MultiLevel_AliasAccessControl) {
|
||||
auto* a = ty.alias("a_type", ty.u32);
|
||||
auto* a = ty.alias("a_type", ty.u32());
|
||||
|
||||
AccessControl aa{ast::AccessControl::kReadWrite, a};
|
||||
EXPECT_EQ(aa.type(), a);
|
||||
EXPECT_EQ(aa.UnwrapIfNeeded(), ty.u32);
|
||||
EXPECT_EQ(aa.UnwrapIfNeeded(), ty.u32());
|
||||
}
|
||||
|
||||
TEST_F(AliasTest, UnwrapAll_TwiceAliasPointerTwiceAlias) {
|
||||
auto* a = ty.alias("a_type", ty.u32);
|
||||
auto* a = ty.alias("a_type", ty.u32());
|
||||
auto* aa = ty.alias("aa_type", a);
|
||||
Pointer paa{aa, ast::StorageClass::kUniform};
|
||||
auto* apaa = ty.alias("paa_type", &paa);
|
||||
|
@ -109,11 +109,11 @@ TEST_F(AliasTest, UnwrapAll_TwiceAliasPointerTwiceAlias) {
|
|||
|
||||
EXPECT_EQ(aapaa->symbol(), Symbol(4));
|
||||
EXPECT_EQ(aapaa->type(), apaa);
|
||||
EXPECT_EQ(aapaa->UnwrapAll(), ty.u32);
|
||||
EXPECT_EQ(aapaa->UnwrapAll(), ty.u32());
|
||||
}
|
||||
|
||||
TEST_F(AliasTest, UnwrapAll_SecondConsecutivePointerBlocksUnrapping) {
|
||||
auto* a = ty.alias("a_type", ty.u32);
|
||||
auto* a = ty.alias("a_type", ty.u32());
|
||||
auto* aa = ty.alias("aa_type", a);
|
||||
|
||||
Pointer paa{aa, ast::StorageClass::kUniform};
|
||||
|
@ -123,7 +123,7 @@ TEST_F(AliasTest, UnwrapAll_SecondConsecutivePointerBlocksUnrapping) {
|
|||
}
|
||||
|
||||
TEST_F(AliasTest, UnwrapAll_SecondNonConsecutivePointerBlocksUnrapping) {
|
||||
auto* a = ty.alias("a_type", ty.u32);
|
||||
auto* a = ty.alias("a_type", ty.u32());
|
||||
auto* aa = ty.alias("aa_type", a);
|
||||
Pointer paa{aa, ast::StorageClass::kUniform};
|
||||
|
||||
|
@ -136,27 +136,27 @@ TEST_F(AliasTest, UnwrapAll_SecondNonConsecutivePointerBlocksUnrapping) {
|
|||
}
|
||||
|
||||
TEST_F(AliasTest, UnwrapAll_AccessControlPointer) {
|
||||
AccessControl a{ast::AccessControl::kReadOnly, ty.u32};
|
||||
AccessControl a{ast::AccessControl::kReadOnly, ty.u32()};
|
||||
Pointer pa{&a, ast::StorageClass::kUniform};
|
||||
EXPECT_EQ(pa.type(), &a);
|
||||
EXPECT_EQ(pa.UnwrapAll(), ty.u32);
|
||||
EXPECT_EQ(pa.UnwrapAll(), ty.u32());
|
||||
}
|
||||
|
||||
TEST_F(AliasTest, UnwrapAll_PointerAccessControl) {
|
||||
Pointer p{ty.u32, ast::StorageClass::kUniform};
|
||||
Pointer p{ty.u32(), ast::StorageClass::kUniform};
|
||||
AccessControl a{ast::AccessControl::kReadOnly, &p};
|
||||
|
||||
EXPECT_EQ(a.type(), &p);
|
||||
EXPECT_EQ(a.UnwrapAll(), ty.u32);
|
||||
EXPECT_EQ(a.UnwrapAll(), ty.u32());
|
||||
}
|
||||
|
||||
TEST_F(AliasTest, MinBufferBindingSizeU32) {
|
||||
auto* alias = ty.alias("alias", ty.u32);
|
||||
auto* alias = ty.alias("alias", ty.u32());
|
||||
EXPECT_EQ(4u, alias->MinBufferBindingSize(MemoryLayout::kUniformBuffer));
|
||||
}
|
||||
|
||||
TEST_F(AliasTest, MinBufferBindingSizeArray) {
|
||||
Array array(ty.u32, 4,
|
||||
Array array(ty.u32(), 4,
|
||||
ast::ArrayDecorationList{
|
||||
create<ast::StrideDecoration>(4),
|
||||
});
|
||||
|
@ -165,7 +165,7 @@ TEST_F(AliasTest, MinBufferBindingSizeArray) {
|
|||
}
|
||||
|
||||
TEST_F(AliasTest, MinBufferBindingSizeRuntimeArray) {
|
||||
Array array(ty.u32, 0,
|
||||
Array array(ty.u32(), 0,
|
||||
ast::ArrayDecorationList{
|
||||
create<ast::StrideDecoration>(4),
|
||||
});
|
||||
|
@ -175,8 +175,8 @@ TEST_F(AliasTest, MinBufferBindingSizeRuntimeArray) {
|
|||
|
||||
TEST_F(AliasTest, MinBufferBindingSizeStruct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||
Member("bar", ty.u32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* struct_type = ty.struct_("struct_type", str);
|
||||
auto* alias = ty.alias("alias", struct_type);
|
||||
|
@ -186,12 +186,12 @@ TEST_F(AliasTest, MinBufferBindingSizeStruct) {
|
|||
}
|
||||
|
||||
TEST_F(AliasTest, BaseAlignmentU32) {
|
||||
auto* alias = ty.alias("alias", ty.u32);
|
||||
auto* alias = ty.alias("alias", ty.u32());
|
||||
EXPECT_EQ(4u, alias->BaseAlignment(MemoryLayout::kUniformBuffer));
|
||||
}
|
||||
|
||||
TEST_F(AliasTest, BaseAlignmentArray) {
|
||||
Array array(ty.u32, 4,
|
||||
Array array(ty.u32(), 4,
|
||||
ast::ArrayDecorationList{
|
||||
create<ast::StrideDecoration>(4),
|
||||
});
|
||||
|
@ -200,7 +200,7 @@ TEST_F(AliasTest, BaseAlignmentArray) {
|
|||
}
|
||||
|
||||
TEST_F(AliasTest, BaseAlignmentRuntimeArray) {
|
||||
Array array(ty.u32, 0,
|
||||
Array array(ty.u32(), 0,
|
||||
ast::ArrayDecorationList{
|
||||
create<ast::StrideDecoration>(4),
|
||||
});
|
||||
|
@ -210,8 +210,8 @@ TEST_F(AliasTest, BaseAlignmentRuntimeArray) {
|
|||
|
||||
TEST_F(AliasTest, BaseAlignmentStruct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||
Member("bar", ty.u32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* struct_type = ty.struct_("struct_type", str);
|
||||
auto* alias = ty.alias("alias", struct_type);
|
||||
|
|
|
@ -75,8 +75,8 @@ TEST_F(StructTypeTest, TypeName) {
|
|||
|
||||
TEST_F(StructTypeTest, MinBufferBindingSize) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||
Member("bar", ty.u32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
|
@ -85,12 +85,12 @@ TEST_F(StructTypeTest, MinBufferBindingSize) {
|
|||
}
|
||||
|
||||
TEST_F(StructTypeTest, MinBufferBindingSizeArray) {
|
||||
Array arr(ty.u32, 4,
|
||||
Array arr(ty.u32(), 4,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||
Member("bar", ty.u32, {MemberOffset(4)}),
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)}),
|
||||
Member("bar", &arr, {MemberOffset(8)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
@ -100,13 +100,13 @@ TEST_F(StructTypeTest, MinBufferBindingSizeArray) {
|
|||
}
|
||||
|
||||
TEST_F(StructTypeTest, MinBufferBindingSizeRuntimeArray) {
|
||||
Array arr(ty.u32, 0,
|
||||
Array arr(ty.u32(), 0,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||
Member("bar", ty.u32, {MemberOffset(4)}),
|
||||
Member("bar", ty.u32, {MemberOffset(8)})},
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(8)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
|
@ -145,8 +145,8 @@ TEST_F(StructTypeTest, MinBufferBindingSizeVec4) {
|
|||
|
||||
TEST_F(StructTypeTest, BaseAlignment) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||
Member("bar", ty.u32, {MemberOffset(8)})},
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(8)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
|
@ -155,11 +155,11 @@ TEST_F(StructTypeTest, BaseAlignment) {
|
|||
}
|
||||
|
||||
TEST_F(StructTypeTest, BaseAlignmentArray) {
|
||||
Array arr(ty.u32, 4,
|
||||
Array arr(ty.u32(), 4,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||
Member("bar", ty.u32, {MemberOffset(4)}),
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)}),
|
||||
Member("bar", &arr, {MemberOffset(8)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
@ -169,12 +169,12 @@ TEST_F(StructTypeTest, BaseAlignmentArray) {
|
|||
}
|
||||
|
||||
TEST_F(StructTypeTest, BaseAlignmentRuntimeArray) {
|
||||
Array arr(ty.u32, 0,
|
||||
Array arr(ty.u32(), 0,
|
||||
ast::ArrayDecorationList{create<ast::StrideDecoration>(4)});
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("foo", ty.u32, {MemberOffset(0)}),
|
||||
Member("bar", ty.u32, {MemberOffset(4)}),
|
||||
Member("bar", ty.u32, {MemberOffset(8)})},
|
||||
ast::StructMemberList{Member("foo", ty.u32(), {MemberOffset(0)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(4)}),
|
||||
Member("bar", ty.u32(), {MemberOffset(8)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* s_ty = ty.struct_("s_ty", str);
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ TEST_F(TypeDeterminerTest, Stmt_Case) {
|
|||
create<ast::AssignmentStatement>(lhs, rhs),
|
||||
});
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32, 3));
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32(), 3));
|
||||
auto* cse = create<ast::CaseStatement>(lit, body);
|
||||
|
||||
EXPECT_TRUE(td()->DetermineResultType(cse));
|
||||
|
@ -271,7 +271,7 @@ TEST_F(TypeDeterminerTest, Stmt_Switch) {
|
|||
create<ast::AssignmentStatement>(lhs, rhs),
|
||||
});
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32, 3));
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32(), 3));
|
||||
|
||||
ast::CaseStatementList cases;
|
||||
cases.push_back(create<ast::CaseStatement>(lit, body));
|
||||
|
@ -290,7 +290,7 @@ TEST_F(TypeDeterminerTest, Stmt_Switch) {
|
|||
|
||||
TEST_F(TypeDeterminerTest, Stmt_Call) {
|
||||
ast::VariableList params;
|
||||
auto* func = Func("my_func", params, ty.f32, ast::StatementList{},
|
||||
auto* func = Func("my_func", params, ty.f32(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
|
@ -313,7 +313,7 @@ TEST_F(TypeDeterminerTest, Stmt_Call_undeclared) {
|
|||
auto* call_expr = Call("func");
|
||||
ast::VariableList params0;
|
||||
|
||||
auto* func_main = Func("main", params0, ty.f32,
|
||||
auto* func_main = Func("main", params0, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::CallStatement>(call_expr),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -321,7 +321,7 @@ TEST_F(TypeDeterminerTest, Stmt_Call_undeclared) {
|
|||
ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func_main);
|
||||
|
||||
auto* func = Func("func", params0, ty.f32,
|
||||
auto* func = Func("func", params0, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -334,7 +334,7 @@ TEST_F(TypeDeterminerTest, Stmt_Call_undeclared) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Stmt_VariableDecl) {
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
auto* init = var->constructor();
|
||||
|
||||
|
@ -346,7 +346,7 @@ TEST_F(TypeDeterminerTest, Stmt_VariableDecl) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Stmt_VariableDecl_ModuleScope) {
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
auto* init = var->constructor();
|
||||
|
||||
|
@ -458,9 +458,9 @@ TEST_F(TypeDeterminerTest, Expr_ArrayAccessor_Vector) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Expr_Bitcast) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32, Expr("name"));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr("name"));
|
||||
|
||||
auto* v = Var("name", ast::StorageClass::kPrivate, ty.f32);
|
||||
auto* v = Var("name", ast::StorageClass::kPrivate, ty.f32());
|
||||
td()->RegisterVariableForTesting(v);
|
||||
|
||||
EXPECT_TRUE(td()->DetermineResultType(bitcast));
|
||||
|
@ -470,7 +470,7 @@ TEST_F(TypeDeterminerTest, Expr_Bitcast) {
|
|||
|
||||
TEST_F(TypeDeterminerTest, Expr_Call) {
|
||||
ast::VariableList params;
|
||||
auto* func = Func("my_func", params, ty.f32, ast::StatementList{},
|
||||
auto* func = Func("my_func", params, ty.f32(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
|
@ -485,7 +485,7 @@ TEST_F(TypeDeterminerTest, Expr_Call) {
|
|||
|
||||
TEST_F(TypeDeterminerTest, Expr_Call_WithParams) {
|
||||
ast::VariableList params;
|
||||
auto* func = Func("my_func", params, ty.f32, ast::StatementList{},
|
||||
auto* func = Func("my_func", params, ty.f32(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
|
@ -512,9 +512,9 @@ TEST_F(TypeDeterminerTest, Expr_Call_Intrinsic) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Expr_Cast) {
|
||||
auto* cast = Construct(ty.f32, "name");
|
||||
auto* cast = Construct(ty.f32(), "name");
|
||||
|
||||
auto* v = Var("name", ast::StorageClass::kPrivate, ty.f32);
|
||||
auto* v = Var("name", ast::StorageClass::kPrivate, ty.f32());
|
||||
td()->RegisterVariableForTesting(v);
|
||||
|
||||
EXPECT_TRUE(td()->DetermineResultType(cast));
|
||||
|
@ -540,7 +540,7 @@ TEST_F(TypeDeterminerTest, Expr_Constructor_Type) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalVariable) {
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.f32());
|
||||
mod->AST().AddGlobalVariable(var);
|
||||
|
||||
EXPECT_TRUE(td()->Determine());
|
||||
|
@ -555,7 +555,7 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalVariable) {
|
|||
|
||||
TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalConstant) {
|
||||
mod->AST().AddGlobalVariable(
|
||||
Const("my_var", ast::StorageClass::kNone, ty.f32));
|
||||
Const("my_var", ast::StorageClass::kNone, ty.f32()));
|
||||
|
||||
EXPECT_TRUE(td()->Determine());
|
||||
|
||||
|
@ -568,9 +568,9 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_GlobalConstant) {
|
|||
TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable_Const) {
|
||||
auto* my_var = Expr("my_var");
|
||||
|
||||
auto* var = Const("my_var", ast::StorageClass::kNone, ty.f32);
|
||||
auto* var = Const("my_var", ast::StorageClass::kNone, ty.f32());
|
||||
|
||||
auto* f = Func("my_func", ast::VariableList{}, ty.f32,
|
||||
auto* f = Func("my_func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::AssignmentStatement>(my_var, Expr("my_var")),
|
||||
|
@ -586,10 +586,10 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable_Const) {
|
|||
TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable) {
|
||||
auto* my_var = Expr("my_var");
|
||||
|
||||
auto* f = Func("my_func", ast::VariableList{}, ty.f32,
|
||||
auto* f = Func("my_func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(
|
||||
Var("my_var", ast::StorageClass::kNone, ty.f32)),
|
||||
Var("my_var", ast::StorageClass::kNone, ty.f32())),
|
||||
create<ast::AssignmentStatement>(my_var, Expr("my_var")),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
@ -603,11 +603,11 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_FunctionVariable) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) {
|
||||
type::Pointer ptr(ty.f32, ast::StorageClass::kFunction);
|
||||
type::Pointer ptr(ty.f32(), ast::StorageClass::kFunction);
|
||||
|
||||
auto* my_var = Expr("my_var");
|
||||
|
||||
auto* f = Func("my_func", ast::VariableList{}, ty.f32,
|
||||
auto* f = Func("my_func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(
|
||||
Var("my_var", ast::StorageClass::kNone, &ptr)),
|
||||
|
@ -624,7 +624,7 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Function_Ptr) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Expr_Identifier_Function) {
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.f32,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
|
@ -643,11 +643,11 @@ TEST_F(TypeDeterminerTest, Expr_Identifier_Unknown) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) {
|
||||
auto* in_var = Var("in_var", ast::StorageClass::kInput, ty.f32);
|
||||
auto* out_var = Var("out_var", ast::StorageClass::kOutput, ty.f32);
|
||||
auto* sb_var = Var("sb_var", ast::StorageClass::kStorage, ty.f32);
|
||||
auto* wg_var = Var("wg_var", ast::StorageClass::kWorkgroup, ty.f32);
|
||||
auto* priv_var = Var("priv_var", ast::StorageClass::kPrivate, ty.f32);
|
||||
auto* in_var = Var("in_var", ast::StorageClass::kInput, ty.f32());
|
||||
auto* out_var = Var("out_var", ast::StorageClass::kOutput, ty.f32());
|
||||
auto* sb_var = Var("sb_var", ast::StorageClass::kStorage, ty.f32());
|
||||
auto* wg_var = Var("wg_var", ast::StorageClass::kWorkgroup, ty.f32());
|
||||
auto* priv_var = Var("priv_var", ast::StorageClass::kPrivate, ty.f32());
|
||||
|
||||
mod->AST().AddGlobalVariable(in_var);
|
||||
mod->AST().AddGlobalVariable(out_var);
|
||||
|
@ -656,7 +656,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) {
|
|||
mod->AST().AddGlobalVariable(priv_var);
|
||||
|
||||
auto* func = Func(
|
||||
"my_func", ast::VariableList{}, ty.f32,
|
||||
"my_func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("out_var"), Expr("in_var")),
|
||||
create<ast::AssignmentStatement>(Expr("wg_var"), Expr("wg_var")),
|
||||
|
@ -680,11 +680,11 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) {
|
||||
auto* in_var = Var("in_var", ast::StorageClass::kInput, ty.f32);
|
||||
auto* out_var = Var("out_var", ast::StorageClass::kOutput, ty.f32);
|
||||
auto* sb_var = Var("sb_var", ast::StorageClass::kStorage, ty.f32);
|
||||
auto* wg_var = Var("wg_var", ast::StorageClass::kWorkgroup, ty.f32);
|
||||
auto* priv_var = Var("priv_var", ast::StorageClass::kPrivate, ty.f32);
|
||||
auto* in_var = Var("in_var", ast::StorageClass::kInput, ty.f32());
|
||||
auto* out_var = Var("out_var", ast::StorageClass::kOutput, ty.f32());
|
||||
auto* sb_var = Var("sb_var", ast::StorageClass::kStorage, ty.f32());
|
||||
auto* wg_var = Var("wg_var", ast::StorageClass::kWorkgroup, ty.f32());
|
||||
auto* priv_var = Var("priv_var", ast::StorageClass::kPrivate, ty.f32());
|
||||
|
||||
mod->AST().AddGlobalVariable(in_var);
|
||||
mod->AST().AddGlobalVariable(out_var);
|
||||
|
@ -693,7 +693,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) {
|
|||
mod->AST().AddGlobalVariable(priv_var);
|
||||
|
||||
auto* func = Func(
|
||||
"my_func", ast::VariableList{}, ty.f32,
|
||||
"my_func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("out_var"), Expr("in_var")),
|
||||
create<ast::AssignmentStatement>(Expr("wg_var"), Expr("wg_var")),
|
||||
|
@ -705,7 +705,7 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) {
|
|||
mod->AST().Functions().Add(func);
|
||||
|
||||
auto* func2 = Func(
|
||||
"func", ast::VariableList{}, ty.f32,
|
||||
"func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("out_var"), Call("my_func")),
|
||||
},
|
||||
|
@ -726,10 +726,10 @@ TEST_F(TypeDeterminerTest, Function_RegisterInputOutputVariables_SubFunction) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) {
|
||||
auto* var = Var("in_var", ast::StorageClass::kFunction, ty.f32);
|
||||
auto* var = Var("in_var", ast::StorageClass::kFunction, ty.f32());
|
||||
|
||||
auto* func =
|
||||
Func("my_func", ast::VariableList{}, ty.f32,
|
||||
Func("my_func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::AssignmentStatement>(Expr("var"), Expr(1.f)),
|
||||
|
@ -738,7 +738,7 @@ TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) {
|
|||
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
auto* v = Var("var", ast::StorageClass::kFunction, ty.f32);
|
||||
auto* v = Var("var", ast::StorageClass::kFunction, ty.f32());
|
||||
td()->RegisterVariableForTesting(v);
|
||||
|
||||
// Register the function
|
||||
|
@ -749,8 +749,8 @@ TEST_F(TypeDeterminerTest, Function_NotRegisterFunctionVariable) {
|
|||
|
||||
TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) {
|
||||
auto* strct = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("first_member", ty.i32),
|
||||
Member("second_member", ty.f32)},
|
||||
ast::StructMemberList{Member("first_member", ty.i32()),
|
||||
Member("second_member", ty.f32())},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* st = ty.struct_("S", strct);
|
||||
|
@ -771,8 +771,8 @@ TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct) {
|
|||
|
||||
TEST_F(TypeDeterminerTest, Expr_MemberAccessor_Struct_Alias) {
|
||||
auto* strct = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("first_member", ty.i32),
|
||||
Member("second_member", ty.f32)},
|
||||
ast::StructMemberList{Member("first_member", ty.i32()),
|
||||
Member("second_member", ty.f32())},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* st = ty.struct_("alias", strct);
|
||||
|
@ -876,7 +876,7 @@ using Expr_Binary_BitwiseTest = TypeDeterminerTestWithParam<ast::BinaryOp>;
|
|||
TEST_P(Expr_Binary_BitwiseTest, Scalar) {
|
||||
auto op = GetParam();
|
||||
|
||||
auto* var = Var("val", ast::StorageClass::kNone, ty.i32);
|
||||
auto* var = Var("val", ast::StorageClass::kNone, ty.i32());
|
||||
|
||||
mod->AST().AddGlobalVariable(var);
|
||||
|
||||
|
@ -922,7 +922,7 @@ using Expr_Binary_LogicalTest = TypeDeterminerTestWithParam<ast::BinaryOp>;
|
|||
TEST_P(Expr_Binary_LogicalTest, Scalar) {
|
||||
auto op = GetParam();
|
||||
|
||||
auto* var = Var("val", ast::StorageClass::kNone, ty.bool_);
|
||||
auto* var = Var("val", ast::StorageClass::kNone, ty.bool_());
|
||||
|
||||
mod->AST().AddGlobalVariable(var);
|
||||
|
||||
|
@ -962,7 +962,7 @@ using Expr_Binary_CompareTest = TypeDeterminerTestWithParam<ast::BinaryOp>;
|
|||
TEST_P(Expr_Binary_CompareTest, Scalar) {
|
||||
auto op = GetParam();
|
||||
|
||||
auto* var = Var("val", ast::StorageClass::kNone, ty.i32);
|
||||
auto* var = Var("val", ast::StorageClass::kNone, ty.i32());
|
||||
|
||||
mod->AST().AddGlobalVariable(var);
|
||||
|
||||
|
@ -1003,7 +1003,7 @@ INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
|
|||
ast::BinaryOp::kGreaterThanEqual));
|
||||
|
||||
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Scalar) {
|
||||
auto* var = Var("val", ast::StorageClass::kNone, ty.i32);
|
||||
auto* var = Var("val", ast::StorageClass::kNone, ty.i32());
|
||||
|
||||
mod->AST().AddGlobalVariable(var);
|
||||
|
||||
|
@ -1017,7 +1017,7 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Scalar) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Scalar) {
|
||||
auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32);
|
||||
auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32());
|
||||
auto* vector = Var("vector", ast::StorageClass::kNone, ty.vec3<f32>());
|
||||
mod->AST().AddGlobalVariable(scalar);
|
||||
mod->AST().AddGlobalVariable(vector);
|
||||
|
@ -1034,7 +1034,7 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Scalar) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Vector) {
|
||||
auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32);
|
||||
auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32());
|
||||
auto* vector = Var("vector", ast::StorageClass::kNone, ty.vec3<f32>());
|
||||
mod->AST().AddGlobalVariable(scalar);
|
||||
mod->AST().AddGlobalVariable(vector);
|
||||
|
@ -1066,7 +1066,7 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Vector_Vector) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Scalar) {
|
||||
auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32);
|
||||
auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32());
|
||||
auto* matrix = Var("matrix", ast::StorageClass::kNone, ty.mat2x3<f32>());
|
||||
mod->AST().AddGlobalVariable(scalar);
|
||||
mod->AST().AddGlobalVariable(matrix);
|
||||
|
@ -1086,7 +1086,7 @@ TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Matrix_Scalar) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, Expr_Binary_Multiply_Scalar_Matrix) {
|
||||
auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32);
|
||||
auto* scalar = Var("scalar", ast::StorageClass::kNone, ty.f32());
|
||||
auto* matrix = Var("matrix", ast::StorageClass::kNone, ty.mat2x3<f32>());
|
||||
mod->AST().AddGlobalVariable(scalar);
|
||||
mod->AST().AddGlobalVariable(matrix);
|
||||
|
@ -1163,7 +1163,7 @@ using IntrinsicDerivativeTest = TypeDeterminerTestWithParam<std::string>;
|
|||
TEST_P(IntrinsicDerivativeTest, Scalar) {
|
||||
auto name = GetParam();
|
||||
|
||||
auto* var = Var("ident", ast::StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("ident", ast::StorageClass::kNone, ty.f32());
|
||||
|
||||
mod->AST().AddGlobalVariable(var);
|
||||
|
||||
|
@ -1275,7 +1275,7 @@ TEST_P(Intrinsic_FloatMethod, Vector) {
|
|||
TEST_P(Intrinsic_FloatMethod, Scalar) {
|
||||
auto name = GetParam();
|
||||
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.f32());
|
||||
|
||||
mod->AST().AddGlobalVariable(var);
|
||||
|
||||
|
@ -1291,7 +1291,7 @@ TEST_P(Intrinsic_FloatMethod, Scalar) {
|
|||
TEST_P(Intrinsic_FloatMethod, MissingParam) {
|
||||
auto name = GetParam();
|
||||
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.f32());
|
||||
|
||||
mod->AST().AddGlobalVariable(var);
|
||||
|
||||
|
@ -1306,7 +1306,7 @@ TEST_P(Intrinsic_FloatMethod, MissingParam) {
|
|||
TEST_P(Intrinsic_FloatMethod, TooManyParams) {
|
||||
auto name = GetParam();
|
||||
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.f32());
|
||||
|
||||
mod->AST().AddGlobalVariable(var);
|
||||
|
||||
|
@ -1391,7 +1391,7 @@ TEST_P(Intrinsic_StorageTextureOperation, TextureLoadRo) {
|
|||
auto type = GetParam().type;
|
||||
auto format = GetParam().format;
|
||||
|
||||
auto* coords_type = get_coords_type(dim, ty.i32);
|
||||
auto* coords_type = get_coords_type(dim, ty.i32());
|
||||
|
||||
type::Type* texture_type = mod->create<type::StorageTexture>(dim, format);
|
||||
|
||||
|
@ -1399,7 +1399,7 @@ TEST_P(Intrinsic_StorageTextureOperation, TextureLoadRo) {
|
|||
|
||||
add_call_param("texture", texture_type, &call_params);
|
||||
add_call_param("coords", coords_type, &call_params);
|
||||
add_call_param("lod", ty.i32, &call_params);
|
||||
add_call_param("lod", ty.i32(), &call_params);
|
||||
|
||||
auto* expr = Call("textureLoad", call_params);
|
||||
|
||||
|
@ -1462,14 +1462,14 @@ TEST_P(Intrinsic_SampledTextureOperation, TextureLoadSampled) {
|
|||
auto type = GetParam().type;
|
||||
|
||||
type::Type* s = subtype(type);
|
||||
auto* coords_type = get_coords_type(dim, ty.i32);
|
||||
auto* coords_type = get_coords_type(dim, ty.i32());
|
||||
auto* texture_type = create<type::SampledTexture>(dim, s);
|
||||
|
||||
ast::ExpressionList call_params;
|
||||
|
||||
add_call_param("texture", texture_type, &call_params);
|
||||
add_call_param("coords", coords_type, &call_params);
|
||||
add_call_param("lod", ty.i32, &call_params);
|
||||
add_call_param("lod", ty.i32(), &call_params);
|
||||
|
||||
auto* expr = Call("textureLoad", call_params);
|
||||
|
||||
|
@ -1583,10 +1583,10 @@ INSTANTIATE_TEST_SUITE_P(TypeDeterminerTest,
|
|||
ast::UnaryOp::kNot));
|
||||
|
||||
TEST_F(TypeDeterminerTest, StorageClass_SetsIfMissing) {
|
||||
auto* var = Var("var", ast::StorageClass::kNone, ty.i32);
|
||||
auto* var = Var("var", ast::StorageClass::kNone, ty.i32());
|
||||
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
auto* func = Func("func", ast::VariableList{}, ty.i32,
|
||||
auto* func = Func("func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{stmt}, ast::FunctionDecorationList{});
|
||||
|
||||
mod->AST().Functions().Add(func);
|
||||
|
@ -1596,9 +1596,9 @@ TEST_F(TypeDeterminerTest, StorageClass_SetsIfMissing) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, StorageClass_DoesNotSetOnConst) {
|
||||
auto* var = Const("var", ast::StorageClass::kNone, ty.i32);
|
||||
auto* var = Const("var", ast::StorageClass::kNone, ty.i32());
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
auto* func = Func("func", ast::VariableList{}, ty.i32,
|
||||
auto* func = Func("func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{stmt}, ast::FunctionDecorationList{});
|
||||
|
||||
mod->AST().Functions().Add(func);
|
||||
|
@ -1608,10 +1608,10 @@ TEST_F(TypeDeterminerTest, StorageClass_DoesNotSetOnConst) {
|
|||
}
|
||||
|
||||
TEST_F(TypeDeterminerTest, StorageClass_NonFunctionClassError) {
|
||||
auto* var = Var("var", ast::StorageClass::kWorkgroup, ty.i32);
|
||||
auto* var = Var("var", ast::StorageClass::kWorkgroup, ty.i32());
|
||||
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
auto* func = Func("func", ast::VariableList{}, ty.i32,
|
||||
auto* func = Func("func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{stmt}, ast::FunctionDecorationList{});
|
||||
|
||||
mod->AST().Functions().Add(func);
|
||||
|
@ -2670,7 +2670,7 @@ using ImportData_Matrix_OneParam_Test =
|
|||
TEST_P(ImportData_Matrix_OneParam_Test, Error_Float) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* var = Var("var", ast::StorageClass::kFunction, ty.f32);
|
||||
auto* var = Var("var", ast::StorageClass::kFunction, ty.f32());
|
||||
mod->AST().AddGlobalVariable(var);
|
||||
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
@ -2725,24 +2725,24 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) {
|
|||
// ep_2 -> {}
|
||||
|
||||
ast::VariableList params;
|
||||
auto* func_b = Func("b", params, ty.f32, ast::StatementList{},
|
||||
auto* func_b = Func("b", params, ty.f32(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
auto* func_c =
|
||||
Func("c", params, ty.f32,
|
||||
Func("c", params, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("second"), Call("b")),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
auto* func_a =
|
||||
Func("a", params, ty.f32,
|
||||
Func("a", params, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("first"), Call("c")),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
auto* ep_1 =
|
||||
Func("ep_1", params, ty.f32,
|
||||
Func("ep_1", params, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("call_a"), Call("a")),
|
||||
create<ast::AssignmentStatement>(Expr("call_b"), Call("b")),
|
||||
|
@ -2752,7 +2752,7 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) {
|
|||
});
|
||||
|
||||
auto* ep_2 =
|
||||
Func("ep_2", params, ty.f32,
|
||||
Func("ep_2", params, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("call_c"), Call("c")),
|
||||
},
|
||||
|
@ -2767,15 +2767,15 @@ TEST_F(TypeDeterminerTest, Function_EntryPoints_StageDecoration) {
|
|||
mod->AST().Functions().Add(ep_2);
|
||||
|
||||
mod->AST().AddGlobalVariable(
|
||||
Var("first", ast::StorageClass::kPrivate, ty.f32));
|
||||
Var("first", ast::StorageClass::kPrivate, ty.f32()));
|
||||
mod->AST().AddGlobalVariable(
|
||||
Var("second", ast::StorageClass::kPrivate, ty.f32));
|
||||
Var("second", ast::StorageClass::kPrivate, ty.f32()));
|
||||
mod->AST().AddGlobalVariable(
|
||||
Var("call_a", ast::StorageClass::kPrivate, ty.f32));
|
||||
Var("call_a", ast::StorageClass::kPrivate, ty.f32()));
|
||||
mod->AST().AddGlobalVariable(
|
||||
Var("call_b", ast::StorageClass::kPrivate, ty.f32));
|
||||
Var("call_b", ast::StorageClass::kPrivate, ty.f32()));
|
||||
mod->AST().AddGlobalVariable(
|
||||
Var("call_c", ast::StorageClass::kPrivate, ty.f32));
|
||||
Var("call_c", ast::StorageClass::kPrivate, ty.f32()));
|
||||
|
||||
// Register the functions and calculate the callers
|
||||
ASSERT_TRUE(td()->Determine()) << td()->error();
|
||||
|
@ -3137,7 +3137,7 @@ TEST_P(TypeDeterminerTextureIntrinsicTest, Call) {
|
|||
FAIL() << "invalid texture dimensions: " << param.texture_dimension;
|
||||
case type::TextureDimension::k1d:
|
||||
case type::TextureDimension::k1dArray:
|
||||
EXPECT_EQ(call->result_type()->type_name(), ty.i32->type_name());
|
||||
EXPECT_EQ(call->result_type()->type_name(), ty.i32()->type_name());
|
||||
break;
|
||||
case type::TextureDimension::k2d:
|
||||
case type::TextureDimension::k2dArray:
|
||||
|
@ -3152,13 +3152,13 @@ TEST_P(TypeDeterminerTextureIntrinsicTest, Call) {
|
|||
break;
|
||||
}
|
||||
} else if (std::string(param.function) == "textureNumLayers") {
|
||||
EXPECT_EQ(call->result_type(), ty.i32);
|
||||
EXPECT_EQ(call->result_type(), ty.i32());
|
||||
} else if (std::string(param.function) == "textureNumLevels") {
|
||||
EXPECT_EQ(call->result_type(), ty.i32);
|
||||
EXPECT_EQ(call->result_type(), ty.i32());
|
||||
} else if (std::string(param.function) == "textureNumSamples") {
|
||||
EXPECT_EQ(call->result_type(), ty.i32);
|
||||
EXPECT_EQ(call->result_type(), ty.i32());
|
||||
} else if (std::string(param.function) == "textureStore") {
|
||||
EXPECT_EQ(call->result_type(), ty.void_);
|
||||
EXPECT_EQ(call->result_type(), ty.void_());
|
||||
} else {
|
||||
switch (param.texture_kind) {
|
||||
case ast::intrinsic::test::TextureKind::kRegular:
|
||||
|
@ -3170,7 +3170,7 @@ TEST_P(TypeDeterminerTextureIntrinsicTest, Call) {
|
|||
break;
|
||||
}
|
||||
case ast::intrinsic::test::TextureKind::kDepth: {
|
||||
EXPECT_EQ(call->result_type(), ty.f32);
|
||||
EXPECT_EQ(call->result_type(), ty.f32());
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,7 @@ TEST_F(ValidateControlBlockTest, SwitchSelectorExpressionNoneIntegerType_Fail) {
|
|||
// switch (a) {
|
||||
// default: {}
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32, Expr(3.14f),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32(), Expr(3.14f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
ast::CaseStatementList body;
|
||||
|
@ -71,7 +71,7 @@ TEST_F(ValidateControlBlockTest, SwitchWithoutDefault_Fail) {
|
|||
// switch (a) {
|
||||
// case 1: {}
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
ast::CaseSelectorList csl;
|
||||
|
@ -104,7 +104,7 @@ TEST_F(ValidateControlBlockTest, SwitchWithTwoDefault_Fail) {
|
|||
// case 1: {}
|
||||
// default: {}
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
|
@ -146,12 +146,12 @@ TEST_F(ValidateControlBlockTest,
|
|||
// case 1: {}
|
||||
// default: {}
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
ast::CaseSelectorList csl;
|
||||
csl.push_back(create<ast::UintLiteral>(ty.u32, 1));
|
||||
csl.push_back(create<ast::UintLiteral>(ty.u32(), 1));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl,
|
||||
create<ast::BlockStatement>(ast::StatementList{})));
|
||||
|
@ -181,7 +181,7 @@ TEST_F(ValidateControlBlockTest,
|
|||
// case -1: {}
|
||||
// default: {}
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.u32, Expr(2u),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.u32(), Expr(2u),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
|
@ -216,18 +216,18 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueUint_Fail) {
|
|||
// case 2, 2: {}
|
||||
// default: {}
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.u32, Expr(3u),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.u32(), Expr(3u),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
ast::CaseSelectorList csl_1;
|
||||
csl_1.push_back(create<ast::UintLiteral>(ty.u32, 0));
|
||||
csl_1.push_back(create<ast::UintLiteral>(ty.u32(), 0));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
csl_1, create<ast::BlockStatement>(ast::StatementList{})));
|
||||
|
||||
ast::CaseSelectorList csl_2;
|
||||
csl_2.push_back(create<ast::UintLiteral>(ty.u32, 2));
|
||||
csl_2.push_back(create<ast::UintLiteral>(ty.u32, 2));
|
||||
csl_2.push_back(create<ast::UintLiteral>(ty.u32(), 2));
|
||||
csl_2.push_back(create<ast::UintLiteral>(ty.u32(), 2));
|
||||
switch_body.push_back(create<ast::CaseStatement>(
|
||||
Source{Source::Location{12, 34}}, csl_2,
|
||||
create<ast::BlockStatement>(ast::StatementList{})));
|
||||
|
@ -257,7 +257,7 @@ TEST_F(ValidateControlBlockTest, NonUniqueCaseSelectorValueSint_Fail) {
|
|||
// case 0,1,2,10: {}
|
||||
// default: {}
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
ast::CaseStatementList switch_body;
|
||||
|
@ -298,7 +298,7 @@ TEST_F(ValidateControlBlockTest, LastClauseLastStatementIsFallthrough_Fail) {
|
|||
// switch (a) {
|
||||
// default: { fallthrough; }
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
ast::CaseSelectorList default_csl;
|
||||
|
@ -330,7 +330,7 @@ TEST_F(ValidateControlBlockTest, SwitchCase_Pass) {
|
|||
// default: {}
|
||||
// case 5: {}
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
ast::CaseSelectorList default_csl;
|
||||
|
@ -361,7 +361,7 @@ TEST_F(ValidateControlBlockTest, SwitchCaseAlias_Pass) {
|
|||
// default: {}
|
||||
// }
|
||||
|
||||
auto* my_int = ty.alias("MyInt", ty.u32);
|
||||
auto* my_int = ty.alias("MyInt", ty.u32());
|
||||
auto* var = Var("a", ast::StorageClass::kNone, my_int, Expr(2u),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
|
|
|
@ -38,11 +38,11 @@ class ValidateFunctionTest : public ValidatorTestHelper,
|
|||
TEST_F(ValidateFunctionTest, VoidFunctionEndWithoutReturnStatement_Pass) {
|
||||
// [[stage(vertex)]]
|
||||
// fn func -> void { var a:i32 = 2; }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func = Func(
|
||||
Source{Source::Location{12, 34}}, "func", ast::VariableList{}, ty.void_,
|
||||
Source{Source::Location{12, 34}}, "func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
},
|
||||
|
@ -64,7 +64,7 @@ TEST_F(ValidateFunctionTest,
|
|||
// fn func -> void {}
|
||||
auto* func =
|
||||
Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{},
|
||||
ty.void_, ast::StatementList{},
|
||||
ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
@ -80,11 +80,11 @@ TEST_F(ValidateFunctionTest,
|
|||
TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatement_Fail) {
|
||||
// fn func -> int { var a:i32 = 2; }
|
||||
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func = Func(Source{Source::Location{12, 34}}, "func",
|
||||
ast::VariableList{}, ty.i32,
|
||||
ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
},
|
||||
|
@ -104,7 +104,7 @@ TEST_F(ValidateFunctionTest, FunctionEndWithoutReturnStatementEmptyBody_Fail) {
|
|||
// fn func -> int {}
|
||||
auto* func =
|
||||
Func(Source{Source::Location{12, 34}}, "func", ast::VariableList{},
|
||||
ty.i32, ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
ty.i32(), ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
@ -120,7 +120,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) {
|
|||
// [[stage(vertex)]]
|
||||
// fn func -> void { return; }
|
||||
auto* func =
|
||||
Func("func", ast::VariableList{}, ty.void_,
|
||||
Func("func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -139,7 +139,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_Pass) {
|
|||
|
||||
TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) {
|
||||
// fn func -> void { return 2; }
|
||||
auto* func = Func("func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(
|
||||
Source{Source::Location{12, 34}}, Expr(2)),
|
||||
|
@ -160,7 +160,7 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementType_fail) {
|
|||
|
||||
TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) {
|
||||
// fn func -> f32 { return 2; }
|
||||
auto* func = Func("func", ast::VariableList{}, ty.f32,
|
||||
auto* func = Func("func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(
|
||||
Source{Source::Location{12, 34}}, Expr(2)),
|
||||
|
@ -182,14 +182,14 @@ TEST_F(ValidateFunctionTest, FunctionTypeMustMatchReturnStatementTypeF32_fail) {
|
|||
TEST_F(ValidateFunctionTest, FunctionNamesMustBeUnique_fail) {
|
||||
// fn func -> i32 { return 2; }
|
||||
// fn func -> i32 { return 2; }
|
||||
auto* func = Func("func", ast::VariableList{}, ty.i32,
|
||||
auto* func = Func("func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Expr(2)),
|
||||
},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
auto* func_copy = Func(Source{Source::Location{12, 34}}, "func",
|
||||
ast::VariableList{}, ty.i32,
|
||||
ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Expr(2)),
|
||||
},
|
||||
|
@ -212,7 +212,7 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowed_Fail) {
|
|||
auto* call_expr = create<ast::CallExpression>(
|
||||
Source{Source::Location{12, 34}}, Expr("func"), call_params);
|
||||
|
||||
auto* func0 = Func("func", ast::VariableList{}, ty.f32,
|
||||
auto* func0 = Func("func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::CallStatement>(call_expr),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -233,10 +233,10 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
|
|||
ast::ExpressionList call_params;
|
||||
auto* call_expr = create<ast::CallExpression>(
|
||||
Source{Source::Location{12, 34}}, Expr("func"), call_params);
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, call_expr,
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), call_expr,
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func0 = Func("func", ast::VariableList{}, ty.i32,
|
||||
auto* func0 = Func("func", ast::VariableList{}, ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(Expr(2)),
|
||||
|
@ -255,14 +255,15 @@ TEST_F(ValidateFunctionTest, RecursionIsNotAllowedExpr_Fail) {
|
|||
TEST_F(ValidateFunctionTest, Function_WithPipelineStage_NotVoid_Fail) {
|
||||
// [[stage(vertex)]]
|
||||
// fn vtx_main() -> i32 { return 0; }
|
||||
auto* func = Func(
|
||||
Source{Source::Location{12, 34}}, "vtx_main", ast::VariableList{}, ty.i32,
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Expr(0)),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
auto* func =
|
||||
Func(Source{Source::Location{12, 34}}, "vtx_main", ast::VariableList{},
|
||||
ty.i32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Expr(0)),
|
||||
},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
mod->AST().Functions().Add(func);
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
@ -279,9 +280,9 @@ TEST_F(ValidateFunctionTest, Function_WithPipelineStage_WithParams_Fail) {
|
|||
// fn vtx_func(a : i32) -> void { return; }
|
||||
auto* func =
|
||||
Func(Source{Source::Location{12, 34}}, "vtx_func",
|
||||
ast::VariableList{Var("a", ast::StorageClass::kNone, ty.i32, nullptr,
|
||||
ast::VariableDecorationList{})},
|
||||
ty.void_,
|
||||
ast::VariableList{Var("a", ast::StorageClass::kNone, ty.i32(),
|
||||
nullptr, ast::VariableDecorationList{})},
|
||||
ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -305,7 +306,7 @@ TEST_F(ValidateFunctionTest, PipelineStage_MustBeUnique_Fail) {
|
|||
// [[stage(vertex)]]
|
||||
// fn main() -> void { return; }
|
||||
auto* func = Func(
|
||||
Source{Source::Location{12, 34}}, "main", ast::VariableList{}, ty.void_,
|
||||
Source{Source::Location{12, 34}}, "main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -329,7 +330,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) {
|
|||
// [[stage(vertex)]]
|
||||
// fn vtx_func() -> void { return; }
|
||||
auto* func =
|
||||
Func("vtx_func", ast::VariableList{}, ty.void_,
|
||||
Func("vtx_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -347,7 +348,7 @@ TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Pass) {
|
|||
|
||||
TEST_F(ValidateFunctionTest, OnePipelineStageFunctionMustBePresent_Fail) {
|
||||
// fn vtx_func() -> void { return; }
|
||||
auto* func = Func("vtx_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("vtx_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
|
|
@ -64,7 +64,7 @@ TEST_F(ValidatorTest, AssignToScalar_Fail) {
|
|||
// var my_var : i32 = 2;
|
||||
// 1 = my_var;
|
||||
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("my_var", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* lhs = Expr(1);
|
||||
|
@ -119,7 +119,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInBlockStatement_Fail) {
|
|||
TEST_F(ValidatorTest, AssignCompatibleTypes_Pass) {
|
||||
// var a :i32 = 2;
|
||||
// a = 2
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* lhs = Expr("a");
|
||||
|
@ -140,7 +140,7 @@ TEST_F(ValidatorTest, AssignCompatibleTypesThroughAlias_Pass) {
|
|||
// alias myint = i32;
|
||||
// var a :myint = 2;
|
||||
// a = 2
|
||||
auto* myint = ty.alias("myint", ty.i32);
|
||||
auto* myint = ty.alias("myint", ty.i32());
|
||||
auto* var = Var("a", ast::StorageClass::kNone, myint, Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
|
@ -162,9 +162,9 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInferRHSLoad_Pass) {
|
|||
// var a :i32 = 2;
|
||||
// var b :i32 = 3;
|
||||
// a = b;
|
||||
auto* var_a = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var_a = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
auto* var_b = Var("b", ast::StorageClass::kNone, ty.i32, Expr(3),
|
||||
auto* var_b = Var("b", ast::StorageClass::kNone, ty.i32(), Expr(3),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* lhs = Expr("a");
|
||||
|
@ -187,7 +187,7 @@ TEST_F(ValidatorTest, AssignThroughPointer_Pass) {
|
|||
// const b : ptr<function,i32> = a;
|
||||
// b = 2;
|
||||
const auto func = ast::StorageClass::kFunction;
|
||||
auto* var_a = Var("a", func, ty.i32, Expr(2), {});
|
||||
auto* var_a = Var("a", func, ty.i32(), Expr(2), {});
|
||||
auto* var_b = Const("b", ast::StorageClass::kNone, ty.pointer<int>(func),
|
||||
Expr("a"), {});
|
||||
|
||||
|
@ -213,7 +213,7 @@ TEST_F(ValidatorTest, AssignIncompatibleTypes_Fail) {
|
|||
// a = 2.3;
|
||||
// }
|
||||
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* lhs = Expr("a");
|
||||
|
@ -241,7 +241,7 @@ TEST_F(ValidatorTest, AssignThroughPointerWrongeStoreType_Fail) {
|
|||
// const b : ptr<function,f32> = a;
|
||||
// b = 2;
|
||||
const auto priv = ast::StorageClass::kFunction;
|
||||
auto* var_a = Var("a", priv, ty.f32, Expr(2), {});
|
||||
auto* var_a = Var("a", priv, ty.f32(), Expr(2), {});
|
||||
auto* var_b = Const("b", ast::StorageClass::kNone, ty.pointer<float>(priv),
|
||||
Expr("a"), {});
|
||||
|
||||
|
@ -269,7 +269,7 @@ TEST_F(ValidatorTest, AssignCompatibleTypesInBlockStatement_Pass) {
|
|||
// var a :i32 = 2;
|
||||
// a = 2
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* lhs = Expr("a");
|
||||
|
@ -296,7 +296,7 @@ TEST_F(ValidatorTest, AssignIncompatibleTypesInBlockStatement_Fail) {
|
|||
// a = 2.3;
|
||||
// }
|
||||
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* lhs = Expr("a");
|
||||
|
@ -326,7 +326,7 @@ TEST_F(ValidatorTest, GlobalVariableWithStorageClass_Pass) {
|
|||
// var<in> gloabl_var: f32;
|
||||
mod->AST().AddGlobalVariable(Var(
|
||||
Source{Source::Location{12, 34}}, "global_var", ast::StorageClass::kInput,
|
||||
ty.f32, nullptr, ast::VariableDecorationList{}));
|
||||
ty.f32(), nullptr, ast::VariableDecorationList{}));
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
|
@ -338,7 +338,7 @@ TEST_F(ValidatorTest, GlobalVariableNoStorageClass_Fail) {
|
|||
// var gloabl_var: f32;
|
||||
mod->AST().AddGlobalVariable(Var(
|
||||
Source{Source::Location{12, 34}}, "global_var", ast::StorageClass::kNone,
|
||||
ty.f32, nullptr, ast::VariableDecorationList{}));
|
||||
ty.f32(), nullptr, ast::VariableDecorationList{}));
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
@ -352,7 +352,7 @@ TEST_F(ValidatorTest, GlobalConstantWithStorageClass_Fail) {
|
|||
// const<in> gloabl_var: f32;
|
||||
mod->AST().AddGlobalVariable(Const(
|
||||
Source{Source::Location{12, 34}}, "global_var", ast::StorageClass::kInput,
|
||||
ty.f32, nullptr, ast::VariableDecorationList{}));
|
||||
ty.f32(), nullptr, ast::VariableDecorationList{}));
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
@ -367,7 +367,7 @@ TEST_F(ValidatorTest, GlobalConstNoStorageClass_Pass) {
|
|||
// const gloabl_var: f32;
|
||||
mod->AST().AddGlobalVariable(Const(
|
||||
Source{Source::Location{12, 34}}, "global_var", ast::StorageClass::kNone,
|
||||
ty.f32, nullptr, ast::VariableDecorationList{}));
|
||||
ty.f32(), nullptr, ast::VariableDecorationList{}));
|
||||
EXPECT_TRUE(td()->Determine()) << td()->error();
|
||||
|
||||
ValidatorImpl& v = Build();
|
||||
|
@ -381,14 +381,14 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Fail) {
|
|||
// not_global_var = 3.14f;
|
||||
// }
|
||||
mod->AST().AddGlobalVariable(Var("global_var", ast::StorageClass::kPrivate,
|
||||
ty.f32, Expr(2.1f),
|
||||
ty.f32(), Expr(2.1f),
|
||||
ast::VariableDecorationList{}));
|
||||
|
||||
SetSource(Source{Source::Location{12, 34}});
|
||||
auto* lhs = Expr("not_global_var");
|
||||
auto* rhs = Expr(3.14f);
|
||||
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.f32,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(
|
||||
Source{Source::Location{12, 34}}, lhs, rhs),
|
||||
|
@ -410,11 +410,11 @@ TEST_F(ValidatorTest, UsingUndefinedVariableGlobalVariable_Pass) {
|
|||
// }
|
||||
|
||||
mod->AST().AddGlobalVariable(Var("global_var", ast::StorageClass::kPrivate,
|
||||
ty.f32, Expr(2.1f),
|
||||
ty.f32(), Expr(2.1f),
|
||||
ast::VariableDecorationList{}));
|
||||
|
||||
auto* func = Func(
|
||||
"my_func", ast::VariableList{}, ty.void_,
|
||||
"my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Source{Source::Location{12, 34}},
|
||||
Expr("global_var"), Expr(3.14f)),
|
||||
|
@ -437,7 +437,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableInnerScope_Fail) {
|
|||
// if (true) { var a : f32 = 2.0; }
|
||||
// a = 3.14;
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32, Expr(2.0f),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32(), Expr(2.0f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* cond = Expr(true);
|
||||
|
@ -470,7 +470,7 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) {
|
|||
// var a : f32 = 2.0;
|
||||
// if (true) { a = 3.14; }
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32, Expr(2.0f),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32(), Expr(2.0f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
SetSource(Source{Source::Location{12, 34}});
|
||||
|
@ -500,12 +500,12 @@ TEST_F(ValidatorTest, UsingUndefinedVariableOuterScope_Pass) {
|
|||
TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
|
||||
// var global_var0 : f32 = 0.1;
|
||||
// var global_var1 : i32 = 0;
|
||||
auto* var0 = Var("global_var0", ast::StorageClass::kPrivate, ty.f32,
|
||||
auto* var0 = Var("global_var0", ast::StorageClass::kPrivate, ty.f32(),
|
||||
Expr(0.1f), ast::VariableDecorationList{});
|
||||
mod->AST().AddGlobalVariable(var0);
|
||||
|
||||
auto* var1 = Var(Source{Source::Location{12, 34}}, "global_var1",
|
||||
ast::StorageClass::kPrivate, ty.f32, Expr(0),
|
||||
ast::StorageClass::kPrivate, ty.f32(), Expr(0),
|
||||
ast::VariableDecorationList{});
|
||||
mod->AST().AddGlobalVariable(var1);
|
||||
|
||||
|
@ -518,12 +518,12 @@ TEST_F(ValidatorTest, GlobalVariableUnique_Pass) {
|
|||
TEST_F(ValidatorTest, GlobalVariableNotUnique_Fail) {
|
||||
// var global_var : f32 = 0.1;
|
||||
// var global_var : i32 = 0;
|
||||
auto* var0 = Var("global_var", ast::StorageClass::kPrivate, ty.f32,
|
||||
auto* var0 = Var("global_var", ast::StorageClass::kPrivate, ty.f32(),
|
||||
Expr(0.1f), ast::VariableDecorationList{});
|
||||
mod->AST().AddGlobalVariable(var0);
|
||||
|
||||
auto* var1 = Var(Source{Source::Location{12, 34}}, "global_var",
|
||||
ast::StorageClass::kPrivate, ty.i32, Expr(0),
|
||||
ast::StorageClass::kPrivate, ty.i32(), Expr(0),
|
||||
ast::VariableDecorationList{});
|
||||
mod->AST().AddGlobalVariable(var1);
|
||||
|
||||
|
@ -539,7 +539,7 @@ TEST_F(ValidatorTest, AssignToConstant_Fail) {
|
|||
// const a :i32 = 2;
|
||||
// a = 2
|
||||
// }
|
||||
auto* var = Const("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Const("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* lhs = Expr("a");
|
||||
|
@ -568,14 +568,14 @@ TEST_F(ValidatorTest, GlobalVariableFunctionVariableNotUnique_Fail) {
|
|||
// return 0;
|
||||
// }
|
||||
|
||||
auto* global_var = Var("a", ast::StorageClass::kPrivate, ty.f32, Expr(2.1f),
|
||||
auto* global_var = Var("a", ast::StorageClass::kPrivate, ty.f32(), Expr(2.1f),
|
||||
ast::VariableDecorationList{});
|
||||
mod->AST().AddGlobalVariable(global_var);
|
||||
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32, Expr(2.0f),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32(), Expr(2.0f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var),
|
||||
|
@ -598,13 +598,13 @@ TEST_F(ValidatorTest, RedeclaredIndentifier_Fail) {
|
|||
// var a :i32 = 2;
|
||||
// var a :f21 = 2.0;
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* var_a_float = Var("a", ast::StorageClass::kNone, ty.f32, Expr(0.1f),
|
||||
auto* var_a_float = Var("a", ast::StorageClass::kNone, ty.f32(), Expr(0.1f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::VariableDeclStatement>(
|
||||
|
@ -628,7 +628,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
|||
// if (true) { var a : f32 = 2.0; }
|
||||
// var a : f32 = 3.14;
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32, Expr(2.0f),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32(), Expr(2.0f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* cond = Expr(true);
|
||||
|
@ -636,7 +636,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierInnerScope_Pass) {
|
|||
create<ast::VariableDeclStatement>(var),
|
||||
});
|
||||
|
||||
auto* var_a_float = Var("a", ast::StorageClass::kNone, ty.f32, Expr(3.1f),
|
||||
auto* var_a_float = Var("a", ast::StorageClass::kNone, ty.f32(), Expr(3.1f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* outer_body = create<ast::BlockStatement>(ast::StatementList{
|
||||
|
@ -659,10 +659,10 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
|
|||
// var a : f32 = 3.14;
|
||||
// if (true) { var a : f32 = 2.0; }
|
||||
// }
|
||||
auto* var_a_float = Var("a", ast::StorageClass::kNone, ty.f32, Expr(3.1f),
|
||||
auto* var_a_float = Var("a", ast::StorageClass::kNone, ty.f32(), Expr(3.1f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32, Expr(2.0f),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32(), Expr(2.0f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* cond = Expr(true);
|
||||
|
@ -686,13 +686,13 @@ TEST_F(ValidatorTest, DISABLED_RedeclaredIdentifierInnerScope_False) {
|
|||
TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
||||
// func0 { var a : f32 = 2.0; return; }
|
||||
// func1 { var a : f32 = 3.0; return; }
|
||||
auto* var0 = Var("a", ast::StorageClass::kNone, ty.f32, Expr(2.0f),
|
||||
auto* var0 = Var("a", ast::StorageClass::kNone, ty.f32(), Expr(2.0f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* var1 = Var("a", ast::StorageClass::kNone, ty.void_, Expr(1.0f),
|
||||
auto* var1 = Var("a", ast::StorageClass::kNone, ty.void_(), Expr(1.0f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func0 = Func("func0", ast::VariableList{}, ty.void_,
|
||||
auto* func0 = Func("func0", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var0),
|
||||
|
@ -701,7 +701,7 @@ TEST_F(ValidatorTest, RedeclaredIdentifierDifferentFunctions_Pass) {
|
|||
ast::FunctionDecorationList{});
|
||||
|
||||
auto* func1 =
|
||||
Func("func1", ast::VariableList{}, ty.void_,
|
||||
Func("func1", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{13, 34}}, var1),
|
||||
|
@ -726,7 +726,7 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) {
|
|||
// var a :i32;
|
||||
// a = 2;
|
||||
// }
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32, nullptr,
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
td()->RegisterVariableForTesting(var);
|
||||
|
@ -751,16 +751,16 @@ TEST_F(ValidatorTest, VariableDeclNoConstructor_Pass) {
|
|||
TEST_F(ValidatorTest, IsStorable_Void) {
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_FALSE(v.IsStorable(ty.void_));
|
||||
EXPECT_FALSE(v.IsStorable(ty.void_()));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_Scalar) {
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_TRUE(v.IsStorable(ty.bool_));
|
||||
EXPECT_TRUE(v.IsStorable(ty.i32));
|
||||
EXPECT_TRUE(v.IsStorable(ty.u32));
|
||||
EXPECT_TRUE(v.IsStorable(ty.f32));
|
||||
EXPECT_TRUE(v.IsStorable(ty.bool_()));
|
||||
EXPECT_TRUE(v.IsStorable(ty.i32()));
|
||||
EXPECT_TRUE(v.IsStorable(ty.u32()));
|
||||
EXPECT_TRUE(v.IsStorable(ty.f32()));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_Vector) {
|
||||
|
@ -799,14 +799,14 @@ TEST_F(ValidatorTest, IsStorable_Pointer) {
|
|||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_AliasVoid) {
|
||||
auto* alias = ty.alias("myalias", ty.void_);
|
||||
auto* alias = ty.alias("myalias", ty.void_());
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_FALSE(v.IsStorable(alias));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_AliasI32) {
|
||||
auto* alias = ty.alias("myalias", ty.i32);
|
||||
auto* alias = ty.alias("myalias", ty.i32());
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_TRUE(v.IsStorable(alias));
|
||||
|
@ -815,13 +815,13 @@ TEST_F(ValidatorTest, IsStorable_AliasI32) {
|
|||
TEST_F(ValidatorTest, IsStorable_ArraySizedOfStorable) {
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_TRUE(v.IsStorable(ty.array(ty.i32, 5)));
|
||||
EXPECT_TRUE(v.IsStorable(ty.array(ty.i32(), 5)));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_ArraySizedOfNonStorable) {
|
||||
ValidatorImpl& v = Build();
|
||||
|
||||
EXPECT_FALSE(v.IsStorable(ty.array(ty.void_, 5)));
|
||||
EXPECT_FALSE(v.IsStorable(ty.array(ty.void_(), 5)));
|
||||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_ArrayUnsizedOfStorable) {
|
||||
|
@ -837,7 +837,7 @@ TEST_F(ValidatorTest, IsStorable_ArrayUnsizedOfNonStorable) {
|
|||
}
|
||||
|
||||
TEST_F(ValidatorTest, IsStorable_Struct_AllMembersStorable) {
|
||||
ast::StructMemberList members{Member("a", ty.i32), Member("b", ty.f32)};
|
||||
ast::StructMemberList members{Member("a", ty.i32()), Member("b", ty.f32())};
|
||||
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||
auto* s_ty = ty.struct_("mystruct", s);
|
||||
ValidatorImpl& v = Build();
|
||||
|
@ -847,7 +847,7 @@ TEST_F(ValidatorTest, IsStorable_Struct_AllMembersStorable) {
|
|||
|
||||
TEST_F(ValidatorTest, IsStorable_Struct_SomeMembersNonStorable) {
|
||||
auto* ptr_ty = ty.pointer<int>(ast::StorageClass::kPrivate);
|
||||
ast::StructMemberList members{Member("a", ty.i32), Member("b", ptr_ty)};
|
||||
ast::StructMemberList members{Member("a", ty.i32()), Member("b", ptr_ty)};
|
||||
auto* s = create<ast::Struct>(Source{}, members, ast::StructDecorationList{});
|
||||
auto* s_ty = ty.struct_("mystruct", s);
|
||||
ValidatorImpl& v = Build();
|
||||
|
|
|
@ -45,7 +45,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLast_Pass) {
|
|||
ast::StructDecorationList decos;
|
||||
decos.push_back(create<ast::StructBlockDecoration>());
|
||||
auto* st =
|
||||
create<ast::Struct>(ast::StructMemberList{Member("vf", ty.f32),
|
||||
create<ast::Struct>(ast::StructMemberList{Member("vf", ty.f32()),
|
||||
Member("rt", ty.array<f32>())},
|
||||
decos);
|
||||
|
||||
|
@ -66,7 +66,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsLastNoBlock_Fail) {
|
|||
|
||||
ast::StructDecorationList decos;
|
||||
auto* st =
|
||||
create<ast::Struct>(ast::StructMemberList{Member("vf", ty.f32),
|
||||
create<ast::Struct>(ast::StructMemberList{Member("vf", ty.f32()),
|
||||
Member("rt", ty.array<f32>())},
|
||||
decos);
|
||||
|
||||
|
@ -95,7 +95,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayIsNotLast_Fail) {
|
|||
auto* rt = Member("rt", ty.array<f32>());
|
||||
SetSource(Source{});
|
||||
auto* st = create<ast::Struct>(
|
||||
ast::StructMemberList{rt, Member("vf", ty.f32)}, decos);
|
||||
ast::StructMemberList{rt, Member("vf", ty.f32())}, decos);
|
||||
|
||||
auto* struct_type = ty.struct_("Foo", st);
|
||||
|
||||
|
@ -122,7 +122,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsNotLast_Fail) {
|
|||
ast::StructDecorationList decos;
|
||||
decos.push_back(create<ast::StructBlockDecoration>());
|
||||
auto* st = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("b", alias), Member("a", ty.u32)}, decos);
|
||||
ast::StructMemberList{Member("b", alias), Member("a", ty.u32())}, decos);
|
||||
|
||||
auto* struct_type = ty.struct_("s", st);
|
||||
mod->AST().AddConstructedType(struct_type);
|
||||
|
@ -148,7 +148,7 @@ TEST_F(ValidatorTypeTest, AliasRuntimeArrayIsLast_Pass) {
|
|||
ast::StructDecorationList decos;
|
||||
decos.push_back(create<ast::StructBlockDecoration>());
|
||||
auto* st = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.u32), Member("b", alias)}, decos);
|
||||
ast::StructMemberList{Member("a", ty.u32()), Member("b", alias)}, decos);
|
||||
|
||||
auto* struct_type = ty.struct_("s", st);
|
||||
mod->AST().AddConstructedType(struct_type);
|
||||
|
@ -164,7 +164,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayInFunction_Fail) {
|
|||
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.array<i32>());
|
||||
auto* func =
|
||||
Func("func", ast::VariableList{}, ty.void_,
|
||||
Func("func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(
|
||||
Source{Source::Location{12, 34}}, var),
|
||||
|
@ -192,7 +192,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayAsParameter_Fail) {
|
|||
Var(Source{Source::Location{12, 34}}, "a", ast::StorageClass::kNone,
|
||||
ty.array<i32>(), nullptr, ast::VariableDecorationList{});
|
||||
|
||||
auto* func = Func("func", ast::VariableList{param}, ty.void_,
|
||||
auto* func = Func("func", ast::VariableList{param}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -200,7 +200,7 @@ TEST_F(ValidatorTypeTest, RuntimeArrayAsParameter_Fail) {
|
|||
mod->AST().Functions().Add(func);
|
||||
|
||||
auto* main =
|
||||
Func("main", ast::VariableList{}, ty.void_,
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace {
|
|||
using HlslGeneratorImplTest_Alias = TestHelper;
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_F32) {
|
||||
auto* alias = ty.alias("a", ty.f32);
|
||||
auto* alias = ty.alias("a", ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -37,7 +37,7 @@ TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_F32) {
|
|||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_NameCollision) {
|
||||
auto* alias = ty.alias("float", ty.f32);
|
||||
auto* alias = ty.alias("float", ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -48,8 +48,8 @@ TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_NameCollision) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Alias, EmitAlias_Struct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.f32),
|
||||
Member("b", ty.i32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.f32()),
|
||||
Member("b", ty.i32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("A", str);
|
||||
|
|
|
@ -60,8 +60,8 @@ using HlslBinaryTest = TestParamHelper<BinaryData>;
|
|||
TEST_P(HlslBinaryTest, Emit_f32) {
|
||||
auto params = GetParam();
|
||||
|
||||
auto* left_var = Var("left", ast::StorageClass::kFunction, ty.f32);
|
||||
auto* right_var = Var("right", ast::StorageClass::kFunction, ty.f32);
|
||||
auto* left_var = Var("left", ast::StorageClass::kFunction, ty.f32());
|
||||
auto* right_var = Var("right", ast::StorageClass::kFunction, ty.f32());
|
||||
|
||||
auto* left = Expr("left");
|
||||
auto* right = Expr("right");
|
||||
|
@ -81,8 +81,8 @@ TEST_P(HlslBinaryTest, Emit_f32) {
|
|||
TEST_P(HlslBinaryTest, Emit_u32) {
|
||||
auto params = GetParam();
|
||||
|
||||
auto* left_var = Var("left", ast::StorageClass::kFunction, ty.u32);
|
||||
auto* right_var = Var("right", ast::StorageClass::kFunction, ty.u32);
|
||||
auto* left_var = Var("left", ast::StorageClass::kFunction, ty.u32());
|
||||
auto* right_var = Var("right", ast::StorageClass::kFunction, ty.u32());
|
||||
|
||||
auto* left = Expr("left");
|
||||
auto* right = Expr("right");
|
||||
|
@ -102,8 +102,8 @@ TEST_P(HlslBinaryTest, Emit_u32) {
|
|||
TEST_P(HlslBinaryTest, Emit_i32) {
|
||||
auto params = GetParam();
|
||||
|
||||
auto* left_var = Var("left", ast::StorageClass::kFunction, ty.i32);
|
||||
auto* right_var = Var("right", ast::StorageClass::kFunction, ty.i32);
|
||||
auto* left_var = Var("left", ast::StorageClass::kFunction, ty.i32());
|
||||
auto* right_var = Var("right", ast::StorageClass::kFunction, ty.i32());
|
||||
|
||||
auto* left = Expr("left");
|
||||
auto* right = Expr("right");
|
||||
|
@ -451,7 +451,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Decl_WithLogical) {
|
|||
auto* d = Expr("d");
|
||||
|
||||
auto* var = Var(
|
||||
"a", ast::StorageClass::kFunction, ty.bool_,
|
||||
"a", ast::StorageClass::kFunction, ty.bool_(),
|
||||
create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kLogicalOr,
|
||||
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, b, c), d),
|
||||
|
@ -482,7 +482,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Bitcast_WithLogical) {
|
|||
auto* c = Expr("c");
|
||||
|
||||
auto* expr = create<ast::BitcastExpression>(
|
||||
ty.i32,
|
||||
ty.i32(),
|
||||
create<ast::BinaryExpression>(
|
||||
ast::BinaryOp::kLogicalAnd, a,
|
||||
create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, b, c)));
|
||||
|
@ -505,8 +505,8 @@ if (_tint_tmp) {
|
|||
TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) {
|
||||
// foo(a && b, c || d, (a || c) && (b || d))
|
||||
|
||||
auto* func = Func("foo", ast::VariableList{}, ty.void_, ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
auto* func = Func("foo", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
ast::ExpressionList params;
|
||||
|
|
|
@ -31,7 +31,7 @@ using HlslGeneratorImplTest_Bitcast = TestHelper;
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) {
|
||||
auto* id = Expr("id");
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32, id);
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), id);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -41,7 +41,7 @@ TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Float) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) {
|
||||
auto* id = Expr("id");
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.i32, id);
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.i32(), id);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -51,7 +51,7 @@ TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Int) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Bitcast, EmitExpression_Bitcast_Uint) {
|
||||
auto* id = Expr("id");
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.u32, id);
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.u32(), id);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ using HlslGeneratorImplTest_Call = TestHelper;
|
|||
TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
|
||||
auto* call = Call("my_func");
|
||||
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
|
@ -45,7 +45,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithoutParams) {
|
|||
TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) {
|
||||
auto* call = Call("my_func", "param1", "param2");
|
||||
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
|
@ -58,7 +58,7 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) {
|
|||
TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) {
|
||||
auto* call = create<ast::CallStatement>(Call("my_func", "param1", "param2"));
|
||||
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
|
|
|
@ -44,12 +44,12 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
// int bar : TEXCOORD1;
|
||||
// };
|
||||
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kInput, ty.f32, nullptr,
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kInput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(0),
|
||||
});
|
||||
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kInput, ty.i32, nullptr,
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(1),
|
||||
});
|
||||
|
@ -61,7 +61,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
mod->AST().AddGlobalVariable(bar_var);
|
||||
|
||||
auto* func =
|
||||
Func("vtx_main", ast::VariableList{}, ty.f32,
|
||||
Func("vtx_main", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("foo"), Expr("foo")),
|
||||
create<ast::AssignmentStatement>(Expr("bar"), Expr("bar")),
|
||||
|
@ -97,12 +97,12 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
// int bar : TEXCOORD1;
|
||||
// };
|
||||
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(0),
|
||||
});
|
||||
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.i32, nullptr,
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(1),
|
||||
});
|
||||
|
@ -114,7 +114,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
mod->AST().AddGlobalVariable(bar_var);
|
||||
|
||||
auto* func =
|
||||
Func("vtx_main", ast::VariableList{}, ty.f32,
|
||||
Func("vtx_main", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("foo"), Expr("foo")),
|
||||
create<ast::AssignmentStatement>(Expr("bar"), Expr("bar")),
|
||||
|
@ -150,12 +150,12 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
// int bar : TEXCOORD1;
|
||||
// };
|
||||
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kInput, ty.f32, nullptr,
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kInput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(0),
|
||||
});
|
||||
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kInput, ty.i32, nullptr,
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(1),
|
||||
});
|
||||
|
@ -167,7 +167,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
mod->AST().AddGlobalVariable(bar_var);
|
||||
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.f32,
|
||||
Func("main", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("foo"), Expr("foo")),
|
||||
create<ast::AssignmentStatement>(Expr("bar"), Expr("bar")),
|
||||
|
@ -203,12 +203,12 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
// int bar : SV_Target1;
|
||||
// };
|
||||
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(0),
|
||||
});
|
||||
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.i32, nullptr,
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(1),
|
||||
});
|
||||
|
@ -220,7 +220,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
mod->AST().AddGlobalVariable(bar_var);
|
||||
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.f32,
|
||||
Func("main", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("foo"), Expr("foo")),
|
||||
create<ast::AssignmentStatement>(Expr("bar"), Expr("bar")),
|
||||
|
@ -253,12 +253,12 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
//
|
||||
// -> Error, not allowed
|
||||
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kInput, ty.f32, nullptr,
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kInput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(0),
|
||||
});
|
||||
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kInput, ty.i32, nullptr,
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(1),
|
||||
});
|
||||
|
@ -270,7 +270,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
mod->AST().AddGlobalVariable(bar_var);
|
||||
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.f32,
|
||||
Func("main", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("foo"), Expr("foo")),
|
||||
create<ast::AssignmentStatement>(Expr("bar"), Expr("bar")),
|
||||
|
@ -298,12 +298,12 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
//
|
||||
// -> Error not allowed
|
||||
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(0),
|
||||
});
|
||||
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.i32, nullptr,
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(1),
|
||||
});
|
||||
|
@ -315,7 +315,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
mod->AST().AddGlobalVariable(bar_var);
|
||||
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.f32,
|
||||
Func("main", ast::VariableList{}, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("foo"), Expr("foo")),
|
||||
create<ast::AssignmentStatement>(Expr("bar"), Expr("bar")),
|
||||
|
@ -356,7 +356,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
});
|
||||
|
||||
auto* depth_var =
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth),
|
||||
});
|
||||
|
@ -368,7 +368,7 @@ TEST_F(HlslGeneratorImplTest_EntryPoint,
|
|||
mod->AST().AddGlobalVariable(depth_var);
|
||||
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.void_,
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("depth"),
|
||||
MemberAccessor("coord", "x")),
|
||||
|
|
|
@ -53,7 +53,7 @@ namespace {
|
|||
using HlslGeneratorImplTest_Function = TestHelper;
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Function, Emit_Function) {
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -74,7 +74,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function) {
|
|||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Function, Emit_Function_Name_Collision) {
|
||||
auto* func = Func("GeometryShader", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("GeometryShader", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -97,9 +97,9 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_Name_Collision) {
|
|||
TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) {
|
||||
auto* func =
|
||||
Func("my_func",
|
||||
ast::VariableList{Var("a", ast::StorageClass::kNone, ty.f32),
|
||||
Var("b", ast::StorageClass::kNone, ty.i32)},
|
||||
ty.void_,
|
||||
ast::VariableList{Var("a", ast::StorageClass::kNone, ty.f32()),
|
||||
Var("b", ast::StorageClass::kNone, ty.i32())},
|
||||
ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -122,7 +122,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithParams) {
|
|||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_FunctionDecoration_EntryPoint_NoReturn_Void) {
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.void_,
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{/* no explicit return */},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
|
@ -144,12 +144,12 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_FunctionDecoration_EntryPoint_NoReturn_InOut) {
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kInput, ty.f32, nullptr,
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kInput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(0),
|
||||
});
|
||||
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(1),
|
||||
});
|
||||
|
@ -161,7 +161,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
mod->AST().AddGlobalVariable(bar_var);
|
||||
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.void_,
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("bar"), Expr("foo")),
|
||||
/* no explicit return */},
|
||||
|
@ -195,12 +195,12 @@ main_out main(main_in tint_in) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_FunctionDecoration_EntryPoint_WithInOutVars) {
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kInput, ty.f32, nullptr,
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kInput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(0),
|
||||
});
|
||||
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(1),
|
||||
});
|
||||
|
@ -212,7 +212,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
mod->AST().AddGlobalVariable(bar_var);
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("bar"), Expr("foo")),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -254,7 +254,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
});
|
||||
|
||||
auto* depth_var =
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth),
|
||||
});
|
||||
|
@ -266,7 +266,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
mod->AST().AddGlobalVariable(depth_var);
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("depth"),
|
||||
MemberAccessor("coord", "x")),
|
||||
|
@ -312,11 +312,11 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
td.RegisterVariableForTesting(coord_var);
|
||||
mod->AST().AddGlobalVariable(coord_var);
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
MemberAccessor("coord", "x"), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -363,13 +363,13 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
td.RegisterVariableForTesting(coord_var);
|
||||
mod->AST().AddGlobalVariable(coord_var);
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
create<ast::MemberAccessorExpression>(
|
||||
MemberAccessor("uniforms", "coord"), Expr("x")),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -402,8 +402,8 @@ void frag_main() {
|
|||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_FunctionDecoration_EntryPoint_With_RW_StorageBuffer_Read) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(0)}),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
|
@ -418,11 +418,11 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
td.RegisterVariableForTesting(coord_var);
|
||||
mod->AST().AddGlobalVariable(coord_var);
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
MemberAccessor("coord", "b"), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -451,8 +451,8 @@ void frag_main() {
|
|||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_FunctionDecoration_EntryPoint_With_RO_StorageBuffer_Read) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(0)}),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
|
@ -468,11 +468,11 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
td.RegisterVariableForTesting(coord_var);
|
||||
mod->AST().AddGlobalVariable(coord_var);
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
MemberAccessor("coord", "b"), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -501,8 +501,8 @@ void frag_main() {
|
|||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_FunctionDecoration_EntryPoint_With_StorageBuffer_Store) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(0)}),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
|
@ -518,7 +518,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
mod->AST().AddGlobalVariable(coord_var);
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(MemberAccessor("coord", "b"),
|
||||
Expr(2.0f)),
|
||||
|
@ -548,17 +548,17 @@ void frag_main() {
|
|||
TEST_F(
|
||||
HlslGeneratorImplTest_Function,
|
||||
Emit_FunctionDecoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) { // NOLINT
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kInput, ty.f32, nullptr,
|
||||
auto* foo_var = Var("foo", ast::StorageClass::kInput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(0),
|
||||
});
|
||||
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(1),
|
||||
});
|
||||
|
||||
auto* val_var = Var("val", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
auto* val_var = Var("val", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(0),
|
||||
});
|
||||
|
@ -573,8 +573,8 @@ TEST_F(
|
|||
|
||||
auto* sub_func = Func(
|
||||
"sub_func",
|
||||
ast::VariableList{Var("param", ast::StorageClass::kFunction, ty.f32)},
|
||||
ty.f32,
|
||||
ast::VariableList{Var("param", ast::StorageClass::kFunction, ty.f32())},
|
||||
ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("bar"), Expr("foo")),
|
||||
create<ast::AssignmentStatement>(Expr("val"), Expr("param")),
|
||||
|
@ -585,7 +585,7 @@ TEST_F(
|
|||
mod->AST().Functions().Add(sub_func);
|
||||
|
||||
auto* func_1 = Func(
|
||||
"ep_1", ast::VariableList{}, ty.void_,
|
||||
"ep_1", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("bar"), Call("sub_func", 1.0f)),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -628,7 +628,7 @@ ep_1_out ep_1(ep_1_in tint_in) {
|
|||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_FunctionDecoration_Called_By_EntryPoints_NoUsedGlobals) {
|
||||
auto* depth_var =
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth),
|
||||
});
|
||||
|
@ -639,8 +639,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
|
||||
auto* sub_func = Func(
|
||||
"sub_func",
|
||||
ast::VariableList{Var("param", ast::StorageClass::kFunction, ty.f32)},
|
||||
ty.f32,
|
||||
ast::VariableList{Var("param", ast::StorageClass::kFunction, ty.f32())},
|
||||
ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Expr("param")),
|
||||
},
|
||||
|
@ -649,7 +649,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
mod->AST().Functions().Add(sub_func);
|
||||
|
||||
auto* func_1 =
|
||||
Func("ep_1", ast::VariableList{}, ty.void_,
|
||||
Func("ep_1", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("depth"),
|
||||
Call("sub_func", 1.0f)),
|
||||
|
@ -693,7 +693,7 @@ TEST_F(
|
|||
});
|
||||
|
||||
auto* depth_var =
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth),
|
||||
});
|
||||
|
@ -706,8 +706,8 @@ TEST_F(
|
|||
|
||||
auto* sub_func = Func(
|
||||
"sub_func",
|
||||
ast::VariableList{Var("param", ast::StorageClass::kFunction, ty.f32)},
|
||||
ty.f32,
|
||||
ast::VariableList{Var("param", ast::StorageClass::kFunction, ty.f32())},
|
||||
ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("depth"),
|
||||
MemberAccessor("coord", "x")),
|
||||
|
@ -718,7 +718,7 @@ TEST_F(
|
|||
mod->AST().Functions().Add(sub_func);
|
||||
|
||||
auto* func_1 =
|
||||
Func("ep_1", ast::VariableList{}, ty.void_,
|
||||
Func("ep_1", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("depth"),
|
||||
Call("sub_func", 1.0f)),
|
||||
|
@ -772,8 +772,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
|
||||
auto* sub_func = Func(
|
||||
"sub_func",
|
||||
ast::VariableList{Var("param", ast::StorageClass::kFunction, ty.f32)},
|
||||
ty.f32,
|
||||
ast::VariableList{Var("param", ast::StorageClass::kFunction, ty.f32())},
|
||||
ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(MemberAccessor("coord", "x")),
|
||||
},
|
||||
|
@ -781,11 +781,11 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
|
||||
mod->AST().Functions().Add(sub_func);
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
Call("sub_func", 1.0f), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -832,8 +832,8 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
|
||||
auto* sub_func = Func(
|
||||
"sub_func",
|
||||
ast::VariableList{Var("param", ast::StorageClass::kFunction, ty.f32)},
|
||||
ty.f32,
|
||||
ast::VariableList{Var("param", ast::StorageClass::kFunction, ty.f32())},
|
||||
ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(MemberAccessor("coord", "x")),
|
||||
},
|
||||
|
@ -841,11 +841,11 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
|
||||
mod->AST().Functions().Add(sub_func);
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
Call("sub_func", 1.0f), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -877,7 +877,7 @@ void frag_main() {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_FunctionDecoration_EntryPoints_WithGlobal_Nested_Return) {
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
auto* bar_var = Var("bar", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(1),
|
||||
});
|
||||
|
@ -890,7 +890,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
});
|
||||
|
||||
auto* func_1 = Func(
|
||||
"ep_1", ast::VariableList{}, ty.void_,
|
||||
"ep_1", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("bar"), Expr(1.0f)),
|
||||
create<ast::IfStatement>(create<ast::BinaryExpression>(
|
||||
|
@ -928,7 +928,7 @@ ep_1_out ep_1() {
|
|||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_FunctionDecoration_EntryPoint_WithNameCollision) {
|
||||
auto* func = Func(
|
||||
"GeometryShader", ast::VariableList{}, ty.void_, ast::StatementList{},
|
||||
"GeometryShader", ast::VariableList{}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
@ -948,7 +948,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_FunctionDecoration_EntryPoint_Compute) {
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.void_,
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -974,7 +974,7 @@ void main() {
|
|||
TEST_F(HlslGeneratorImplTest_Function,
|
||||
Emit_FunctionDecoration_EntryPoint_Compute_WithWorkgroup) {
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.void_,
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -1002,7 +1002,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Function_WithArrayParams) {
|
|||
auto* func = Func(
|
||||
"my_func",
|
||||
ast::VariableList{Var("a", ast::StorageClass::kNone, ty.array<f32, 5>())},
|
||||
ty.void_,
|
||||
ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -1041,7 +1041,7 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
// }
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("d", ty.f32, {MemberOffset(0)})},
|
||||
ast::StructMemberList{Member("d", ty.f32(), {MemberOffset(0)})},
|
||||
ast::StructDecorationList{create<ast::StructBlockDecoration>()});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
|
@ -1058,11 +1058,11 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
mod->AST().AddGlobalVariable(data_var);
|
||||
|
||||
{
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
MemberAccessor("data", "d"), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("a", ast::VariableList{}, ty.void_,
|
||||
Func("a", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -1075,11 +1075,11 @@ TEST_F(HlslGeneratorImplTest_Function,
|
|||
}
|
||||
|
||||
{
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
MemberAccessor("data", "d"), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("b", ast::VariableList{}, ty.void_,
|
||||
Func("b", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
|
|
@ -151,13 +151,13 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
|
|||
// }
|
||||
// }
|
||||
|
||||
auto* var = Var("lhs", ast::StorageClass::kFunction, ty.f32, Expr(2.4f),
|
||||
auto* var = Var("lhs", ast::StorageClass::kFunction, ty.f32(), Expr(2.4f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* body = create<ast::BlockStatement>(ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::VariableDeclStatement>(
|
||||
Var("other", ast::StorageClass::kFunction, ty.f32)),
|
||||
Var("other", ast::StorageClass::kFunction, ty.f32())),
|
||||
});
|
||||
|
||||
auto* lhs = Expr("lhs");
|
||||
|
|
|
@ -41,7 +41,7 @@ using HlslGeneratorImplTest_MemberAccessor = TestHelper;
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
|
||||
auto* strct = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("mem", ty.f32, {MemberOffset(0)})},
|
||||
ast::StructMemberList{Member("mem", ty.f32(), {MemberOffset(0)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Str", strct);
|
||||
|
@ -73,8 +73,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// -> asfloat(data.Load(4));
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(0)}),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
|
@ -107,8 +107,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// -> asint(data.Load(0));
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(0)}),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* s = ty.struct_("Data", str);
|
||||
auto* coord_var = Var("data", ast::StorageClass::kStorage, s);
|
||||
|
@ -143,7 +143,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// data.Store3(4 + 16, asuint(_tint_tmp[1]));
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("z", ty.i32, {MemberOffset(0)}),
|
||||
ast::StructMemberList{Member("z", ty.i32(), {MemberOffset(0)}),
|
||||
Member("a", ty.mat2x3<f32>(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
|
@ -191,7 +191,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// data.Store3(4 + 16, asuint(_tint_tmp[1]));
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("z", ty.i32, {MemberOffset(0)}),
|
||||
ast::StructMemberList{Member("z", ty.i32(), {MemberOffset(0)}),
|
||||
Member("a", ty.mat2x3<f32>(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
|
@ -234,7 +234,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// data.Load2(4 + 16)));
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("z", ty.i32, {MemberOffset(0)}),
|
||||
ast::StructMemberList{Member("z", ty.i32(), {MemberOffset(0)}),
|
||||
Member("a", ty.mat3x2<f32>(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
|
@ -275,7 +275,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{
|
||||
Member("z", ty.i32, {MemberOffset(0)}),
|
||||
Member("z", ty.i32(), {MemberOffset(0)}),
|
||||
Member("a", ty.mat2x3<f32>(), {MemberOffset(4)}),
|
||||
},
|
||||
ast::StructDecorationList{});
|
||||
|
@ -347,7 +347,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// -> asfloat(data.Load((2 * 16) + (1 * 4) + 16)))
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("z", ty.i32, {MemberOffset(0)}),
|
||||
ast::StructMemberList{Member("z", ty.i32(), {MemberOffset(0)}),
|
||||
Member("a", ty.mat4x3<f32>(), {MemberOffset(16)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
|
@ -379,7 +379,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// data.a[2];
|
||||
//
|
||||
// -> asint(data.Load((2 * 4));
|
||||
type::Array ary(ty.i32, 5,
|
||||
type::Array ary(ty.i32(), 5,
|
||||
ast::ArrayDecorationList{
|
||||
create<ast::StrideDecoration>(4),
|
||||
});
|
||||
|
@ -414,7 +414,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// data.a[(2 + 4) - 3];
|
||||
//
|
||||
// -> asint(data.Load((4 * ((2 + 4) - 3)));
|
||||
type::Array ary(ty.i32, 5,
|
||||
type::Array ary(ty.i32(), 5,
|
||||
ast::ArrayDecorationList{
|
||||
create<ast::StrideDecoration>(4),
|
||||
});
|
||||
|
@ -453,8 +453,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// -> data.Store(0, asuint(2.0f));
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(0)}),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
|
@ -488,7 +488,7 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
//
|
||||
// -> data.Store((2 * 4), asuint(2.3f));
|
||||
|
||||
type::Array ary(ty.i32, 5,
|
||||
type::Array ary(ty.i32(), 5,
|
||||
ast::ArrayDecorationList{
|
||||
create<ast::StrideDecoration>(4),
|
||||
});
|
||||
|
@ -530,8 +530,8 @@ TEST_F(HlslGeneratorImplTest_MemberAccessor,
|
|||
// -> data.Store(0, asuint(2));
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(0)}),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
|
|
|
@ -44,7 +44,7 @@ TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_ModuleConstant) {
|
|||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant) {
|
||||
auto* var = Const("pos", ast::StorageClass::kNone, ty.f32, Expr(3.0f),
|
||||
auto* var = Const("pos", ast::StorageClass::kNone, ty.f32(), Expr(3.0f),
|
||||
ast::VariableDecorationList{
|
||||
create<ast::ConstantIdDecoration>(23),
|
||||
});
|
||||
|
@ -61,7 +61,7 @@ static const float pos = WGSL_SPEC_CONSTANT_23;
|
|||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_ModuleConstant, Emit_SpecConstant_NoConstructor) {
|
||||
auto* var = Const("pos", ast::StorageClass::kNone, ty.f32, nullptr,
|
||||
auto* var = Const("pos", ast::StorageClass::kNone, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::ConstantIdDecoration>(23),
|
||||
});
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace {
|
|||
using HlslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(HlslGeneratorImplTest, Generate) {
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace {
|
|||
using HlslGeneratorImplTest_Type = TestHelper;
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_Alias) {
|
||||
auto* alias = ty.alias("alias", ty.f32);
|
||||
auto* alias = ty.alias("alias", ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -54,7 +54,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Alias) {
|
|||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_Alias_NameCollision) {
|
||||
auto* alias = ty.alias("bool", ty.f32);
|
||||
auto* alias = ty.alias("bool", ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -130,21 +130,21 @@ TEST_F(HlslGeneratorImplTest_Type,
|
|||
TEST_F(HlslGeneratorImplTest_Type, EmitType_Bool) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(out, ty.bool_, "")) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(out, ty.bool_(), "")) << gen.error();
|
||||
EXPECT_EQ(result(), "bool");
|
||||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_F32) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(out, ty.f32, "")) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(out, ty.f32(), "")) << gen.error();
|
||||
EXPECT_EQ(result(), "float");
|
||||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_I32) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(out, ty.i32, "")) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(out, ty.i32(), "")) << gen.error();
|
||||
EXPECT_EQ(result(), "int");
|
||||
}
|
||||
|
||||
|
@ -157,7 +157,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Matrix) {
|
|||
|
||||
// TODO(dsinclair): How to annotate as workgroup?
|
||||
TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Pointer) {
|
||||
type::Pointer p(ty.f32, ast::StorageClass::kWorkgroup);
|
||||
type::Pointer p(ty.f32(), ast::StorageClass::kWorkgroup);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -167,8 +167,8 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Pointer) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32()),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
@ -184,8 +184,8 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32()),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
@ -197,9 +197,9 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_InjectPadding) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(4)}),
|
||||
Member("b", ty.f32, {MemberOffset(32)}),
|
||||
Member("c", ty.f32, {MemberOffset(128)})},
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(4)}),
|
||||
Member("b", ty.f32(), {MemberOffset(32)}),
|
||||
Member("c", ty.f32(), {MemberOffset(128)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
@ -217,9 +217,10 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_InjectPadding) {
|
|||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("double", ty.i32), Member("float", ty.f32)},
|
||||
ast::StructDecorationList{});
|
||||
auto* str =
|
||||
create<ast::Struct>(ast::StructMemberList{Member("double", ty.i32()),
|
||||
Member("float", ty.f32())},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -238,8 +239,8 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_WithDecoration) {
|
|||
decos.push_back(create<ast::StructBlockDecoration>());
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32()),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
decos);
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
@ -255,7 +256,7 @@ TEST_F(HlslGeneratorImplTest_Type, DISABLED_EmitType_Struct_WithDecoration) {
|
|||
TEST_F(HlslGeneratorImplTest_Type, EmitType_U32) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(out, ty.u32, "")) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(out, ty.u32(), "")) << gen.error();
|
||||
EXPECT_EQ(result(), "uint");
|
||||
}
|
||||
|
||||
|
@ -269,7 +270,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Vector) {
|
|||
TEST_F(HlslGeneratorImplTest_Type, EmitType_Void) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(out, ty.void_, "")) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(out, ty.void_(), "")) << gen.error();
|
||||
EXPECT_EQ(result(), "void");
|
||||
}
|
||||
|
||||
|
@ -333,7 +334,7 @@ using HlslSampledtexturesTest = TestParamHelper<HlslTextureData>;
|
|||
TEST_P(HlslSampledtexturesTest, Emit) {
|
||||
auto params = GetParam();
|
||||
|
||||
type::SampledTexture s(params.dim, ty.f32);
|
||||
type::SampledTexture s(params.dim, ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -354,7 +355,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
"TextureCubeArray"}));
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Type, EmitMultisampledTexture) {
|
||||
type::MultisampledTexture s(type::TextureDimension::k2d, ty.f32);
|
||||
type::MultisampledTexture s(type::TextureDimension::k2d, ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ namespace {
|
|||
using HlslGeneratorImplTest_VariableDecl = TestHelper;
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) {
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32());
|
||||
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
|
@ -46,7 +46,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement) {
|
|||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Const) {
|
||||
auto* var = Const("a", ast::StorageClass::kNone, ty.f32);
|
||||
auto* var = Const("a", ast::StorageClass::kNone, ty.f32());
|
||||
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
|
@ -73,7 +73,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_VariableDecl,
|
||||
Emit_VariableDeclStatement_Function) {
|
||||
auto* var = Var("a", ast::StorageClass::kFunction, ty.f32);
|
||||
auto* var = Var("a", ast::StorageClass::kFunction, ty.f32());
|
||||
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
|
@ -86,7 +86,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl,
|
|||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) {
|
||||
auto* var = Var("a", ast::StorageClass::kPrivate, ty.f32);
|
||||
auto* var = Var("a", ast::StorageClass::kPrivate, ty.f32());
|
||||
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
|
@ -100,7 +100,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) {
|
|||
|
||||
TEST_F(HlslGeneratorImplTest_VariableDecl,
|
||||
Emit_VariableDeclStatement_Initializer_Private) {
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32, Expr("initializer"),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32(), Expr("initializer"),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace {
|
|||
using MslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(MslGeneratorImplTest, EmitConstructedType_F32) {
|
||||
auto* alias = ty.alias("a", ty.f32);
|
||||
auto* alias = ty.alias("a", ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -38,7 +38,7 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_F32) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, EmitConstructedType_NameCollision) {
|
||||
auto* alias = ty.alias("float", ty.f32);
|
||||
auto* alias = ty.alias("float", ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -49,8 +49,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_NameCollision) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, EmitConstructedType_Struct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.f32),
|
||||
Member("b", ty.i32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.f32()),
|
||||
Member("b", ty.i32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("a", str);
|
||||
|
@ -67,8 +67,8 @@ TEST_F(MslGeneratorImplTest, EmitConstructedType_Struct) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, EmitConstructedType_AliasStructIdent) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.f32),
|
||||
Member("b", ty.i32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.f32()),
|
||||
Member("b", ty.i32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("b", str);
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace {
|
|||
using MslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(MslGeneratorImplTest, EmitExpression_Bitcast) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32, Expr("id"));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr("id"));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ using MslGeneratorImplTest = TestHelper;
|
|||
|
||||
TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) {
|
||||
auto* call = Call("my_func");
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
|
@ -45,7 +45,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithoutParams) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) {
|
||||
auto* call = Call("my_func", "param1", "param2");
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
|
@ -57,7 +57,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, EmitStatement_Call) {
|
||||
auto* call = Call("my_func", "param1", "param2");
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
mod->AST().Functions().Add(func);
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case) {
|
|||
create<ast::BreakStatement>(),
|
||||
});
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32(), 5));
|
||||
auto* c = create<ast::CaseStatement>(lit, body);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -53,7 +53,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, Emit_Case_BreaksByDefault) {
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32(), 5));
|
||||
auto* c = create<ast::CaseStatement>(
|
||||
lit, create<ast::BlockStatement>(ast::StatementList{}));
|
||||
|
||||
|
@ -73,7 +73,7 @@ TEST_F(MslGeneratorImplTest, Emit_Case_WithFallthrough) {
|
|||
create<ast::FallthroughStatement>(),
|
||||
});
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32(), 5));
|
||||
auto* c = create<ast::CaseStatement>(lit, body);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -92,8 +92,8 @@ TEST_F(MslGeneratorImplTest, Emit_Case_MultipleSelectors) {
|
|||
create<ast::BreakStatement>(),
|
||||
});
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32, 6));
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32(), 5));
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32(), 6));
|
||||
auto* c = create<ast::CaseStatement>(lit, body);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
|
|
@ -48,11 +48,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Input) {
|
|||
// };
|
||||
|
||||
auto* foo_var =
|
||||
Var("foo", ast::StorageClass::kInput, ty.f32, nullptr,
|
||||
Var("foo", ast::StorageClass::kInput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(0)});
|
||||
|
||||
auto* bar_var =
|
||||
Var("bar", ast::StorageClass::kInput, ty.i32, nullptr,
|
||||
Var("bar", ast::StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -66,7 +66,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Input) {
|
|||
create<ast::AssignmentStatement>(Expr("bar"), Expr("bar")),
|
||||
};
|
||||
auto* func =
|
||||
Func("vtx_main", ast::VariableList{}, ty.f32, body,
|
||||
Func("vtx_main", ast::VariableList{}, ty.f32(), body,
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
@ -96,11 +96,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Output) {
|
|||
// };
|
||||
|
||||
auto* foo_var =
|
||||
Var("foo", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("foo", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(0)});
|
||||
|
||||
auto* bar_var =
|
||||
Var("bar", ast::StorageClass::kOutput, ty.i32, nullptr,
|
||||
Var("bar", ast::StorageClass::kOutput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -114,7 +114,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Vertex_Output) {
|
|||
create<ast::AssignmentStatement>(Expr("bar"), Expr("bar")),
|
||||
};
|
||||
auto* func =
|
||||
Func("vtx_main", ast::VariableList{}, ty.f32, body,
|
||||
Func("vtx_main", ast::VariableList{}, ty.f32(), body,
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
@ -144,11 +144,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Input) {
|
|||
// };
|
||||
|
||||
auto* foo_var =
|
||||
Var("foo", ast::StorageClass::kInput, ty.f32, nullptr,
|
||||
Var("foo", ast::StorageClass::kInput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(0)});
|
||||
|
||||
auto* bar_var =
|
||||
Var("bar", ast::StorageClass::kInput, ty.i32, nullptr,
|
||||
Var("bar", ast::StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -162,7 +162,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Input) {
|
|||
create<ast::AssignmentStatement>(Expr("bar"), Expr("bar")),
|
||||
};
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.f32, body,
|
||||
Func("main", ast::VariableList{}, ty.f32(), body,
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
@ -192,11 +192,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Output) {
|
|||
// };
|
||||
|
||||
auto* foo_var =
|
||||
Var("foo", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("foo", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(0)});
|
||||
|
||||
auto* bar_var =
|
||||
Var("bar", ast::StorageClass::kOutput, ty.i32, nullptr,
|
||||
Var("bar", ast::StorageClass::kOutput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -210,7 +210,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Fragment_Output) {
|
|||
create<ast::AssignmentStatement>(Expr("bar"), Expr("bar")),
|
||||
};
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.f32, body,
|
||||
Func("main", ast::VariableList{}, ty.f32(), body,
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
@ -237,11 +237,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Input) {
|
|||
// -> Error, not allowed
|
||||
|
||||
auto* foo_var =
|
||||
Var("foo", ast::StorageClass::kInput, ty.f32, nullptr,
|
||||
Var("foo", ast::StorageClass::kInput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(0)});
|
||||
|
||||
auto* bar_var =
|
||||
Var("bar", ast::StorageClass::kInput, ty.i32, nullptr,
|
||||
Var("bar", ast::StorageClass::kInput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -255,7 +255,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Input) {
|
|||
create<ast::AssignmentStatement>(Expr("bar"), Expr("bar")),
|
||||
};
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.f32, body,
|
||||
Func("main", ast::VariableList{}, ty.f32(), body,
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
|
||||
});
|
||||
|
@ -277,11 +277,11 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Output) {
|
|||
// -> Error not allowed
|
||||
|
||||
auto* foo_var =
|
||||
Var("foo", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("foo", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(0)});
|
||||
|
||||
auto* bar_var =
|
||||
Var("bar", ast::StorageClass::kOutput, ty.i32, nullptr,
|
||||
Var("bar", ast::StorageClass::kOutput, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -295,7 +295,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Compute_Output) {
|
|||
create<ast::AssignmentStatement>(Expr("bar"), Expr("bar")),
|
||||
};
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.f32, body,
|
||||
Func("main", ast::VariableList{}, ty.f32(), body,
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
|
||||
});
|
||||
|
@ -327,7 +327,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Builtins) {
|
|||
create<ast::BuiltinDecoration>(ast::Builtin::kFragCoord)});
|
||||
|
||||
auto* depth_var =
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth)});
|
||||
|
||||
|
@ -340,7 +340,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_EntryPointData_Builtins) {
|
|||
auto body = ast::StatementList{create<ast::AssignmentStatement>(
|
||||
Expr("depth"), MemberAccessor("coord", "x"))};
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.void_, body,
|
||||
Func("main", ast::VariableList{}, ty.void_(), body,
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
|
|
@ -56,7 +56,7 @@ namespace {
|
|||
using MslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_Function) {
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -79,7 +79,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_Function_Name_Collision) {
|
||||
auto* func = Func("main", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -103,10 +103,10 @@ TEST_F(MslGeneratorImplTest, Emit_Function_Name_Collision) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, Emit_Function_WithParams) {
|
||||
ast::VariableList params;
|
||||
params.push_back(Var("a", ast::StorageClass::kNone, ty.f32));
|
||||
params.push_back(Var("b", ast::StorageClass::kNone, ty.i32));
|
||||
params.push_back(Var("a", ast::StorageClass::kNone, ty.f32()));
|
||||
params.push_back(Var("b", ast::StorageClass::kNone, ty.i32()));
|
||||
|
||||
auto* func = Func("my_func", params, ty.void_,
|
||||
auto* func = Func("my_func", params, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -129,7 +129,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithParams) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_NoReturn_Void) {
|
||||
auto* func = Func("main", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{/* no explicit return */},
|
||||
ast::FunctionDecorationList{create<ast::StageDecoration>(
|
||||
ast::PipelineStage::kFragment)});
|
||||
|
@ -153,11 +153,11 @@ fragment void main_tint_0() {
|
|||
TEST_F(MslGeneratorImplTest,
|
||||
Emit_FunctionDecoration_EntryPoint_NoReturn_InOut) {
|
||||
auto* foo_var =
|
||||
Var("foo", ast::StorageClass::kInput, ty.f32, nullptr,
|
||||
Var("foo", ast::StorageClass::kInput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(0)});
|
||||
|
||||
auto* bar_var =
|
||||
Var("bar", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("bar", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -167,7 +167,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
mod->AST().AddGlobalVariable(bar_var);
|
||||
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.void_,
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("bar"), Expr("foo")),
|
||||
/* no explicit return */},
|
||||
|
@ -202,11 +202,11 @@ fragment main_out main_tint_0(main_in tint_in [[stage_in]]) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOutVars) {
|
||||
auto* foo_var =
|
||||
Var("foo", ast::StorageClass::kInput, ty.f32, nullptr,
|
||||
Var("foo", ast::StorageClass::kInput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(0)});
|
||||
|
||||
auto* bar_var =
|
||||
Var("bar", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("bar", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -219,7 +219,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_WithInOutVars) {
|
|||
create<ast::AssignmentStatement>(Expr("bar"), Expr("foo")),
|
||||
create<ast::ReturnStatement>(),
|
||||
};
|
||||
auto* func = Func("frag_main", ast::VariableList{}, ty.void_, body,
|
||||
auto* func = Func("frag_main", ast::VariableList{}, ty.void_(), body,
|
||||
ast::FunctionDecorationList{create<ast::StageDecoration>(
|
||||
ast::PipelineStage::kFragment)});
|
||||
|
||||
|
@ -257,7 +257,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
create<ast::BuiltinDecoration>(ast::Builtin::kFragCoord)});
|
||||
|
||||
auto* depth_var =
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth)});
|
||||
|
||||
|
@ -273,7 +273,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
create<ast::ReturnStatement>(),
|
||||
};
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_, body,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(), body,
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
@ -310,11 +310,11 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionDecoration_EntryPoint_With_Uniform) {
|
|||
|
||||
mod->AST().AddGlobalVariable(coord_var);
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
MemberAccessor("coord", "x"), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -343,8 +343,8 @@ fragment void frag_main(constant float4& coord [[buffer(0)]]) {
|
|||
TEST_F(MslGeneratorImplTest,
|
||||
Emit_FunctionDecoration_EntryPoint_With_RW_StorageBuffer) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(0)}),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
|
@ -361,11 +361,11 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
mod->AST().AddGlobalVariable(coord_var);
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
MemberAccessor("coord", "b"), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -399,8 +399,8 @@ fragment void frag_main(device Data& coord [[buffer(0)]]) {
|
|||
TEST_F(MslGeneratorImplTest,
|
||||
Emit_FunctionDecoration_EntryPoint_With_RO_StorageBuffer) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(0)}),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
|
@ -415,11 +415,11 @@ TEST_F(MslGeneratorImplTest,
|
|||
td.RegisterVariableForTesting(coord_var);
|
||||
mod->AST().AddGlobalVariable(coord_var);
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
MemberAccessor("coord", "b"), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -454,15 +454,15 @@ TEST_F(
|
|||
MslGeneratorImplTest,
|
||||
Emit_FunctionDecoration_Called_By_EntryPoints_WithLocationGlobals_And_Params) { // NOLINT
|
||||
auto* foo_var =
|
||||
Var("foo", ast::StorageClass::kInput, ty.f32, nullptr,
|
||||
Var("foo", ast::StorageClass::kInput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(0)});
|
||||
|
||||
auto* bar_var =
|
||||
Var("bar", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("bar", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(1)});
|
||||
|
||||
auto* val_var =
|
||||
Var("val", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("val", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(0)});
|
||||
|
||||
td.RegisterVariableForTesting(foo_var);
|
||||
|
@ -474,14 +474,14 @@ TEST_F(
|
|||
mod->AST().AddGlobalVariable(val_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(Var("param", ast::StorageClass::kFunction, ty.f32));
|
||||
params.push_back(Var("param", ast::StorageClass::kFunction, ty.f32()));
|
||||
|
||||
auto body = ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("bar"), Expr("foo")),
|
||||
create<ast::AssignmentStatement>(Expr("val"), Expr("param")),
|
||||
create<ast::ReturnStatement>(Expr("foo"))};
|
||||
auto* sub_func =
|
||||
Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{});
|
||||
Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{});
|
||||
|
||||
mod->AST().Functions().Add(sub_func);
|
||||
|
||||
|
@ -490,7 +490,7 @@ TEST_F(
|
|||
create<ast::ReturnStatement>(),
|
||||
};
|
||||
auto* func_1 =
|
||||
Func("ep_1", ast::VariableList{}, ty.void_, body,
|
||||
Func("ep_1", ast::VariableList{}, ty.void_(), body,
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
@ -531,7 +531,7 @@ fragment ep_1_out ep_1(ep_1_in tint_in [[stage_in]]) {
|
|||
TEST_F(MslGeneratorImplTest,
|
||||
Emit_FunctionDecoration_Called_By_EntryPoints_NoUsedGlobals) {
|
||||
auto* depth_var =
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth)});
|
||||
|
||||
|
@ -539,9 +539,9 @@ TEST_F(MslGeneratorImplTest,
|
|||
mod->AST().AddGlobalVariable(depth_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(Var("param", ast::StorageClass::kFunction, ty.f32));
|
||||
params.push_back(Var("param", ast::StorageClass::kFunction, ty.f32()));
|
||||
|
||||
auto* sub_func = Func("sub_func", params, ty.f32,
|
||||
auto* sub_func = Func("sub_func", params, ty.f32(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(Expr("param")),
|
||||
},
|
||||
|
@ -555,7 +555,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
};
|
||||
|
||||
auto* func_1 =
|
||||
Func("ep_1", ast::VariableList{}, ty.void_, body,
|
||||
Func("ep_1", ast::VariableList{}, ty.void_(), body,
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
@ -595,7 +595,7 @@ TEST_F(
|
|||
create<ast::BuiltinDecoration>(ast::Builtin::kFragCoord)});
|
||||
|
||||
auto* depth_var =
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("depth", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth)});
|
||||
|
||||
|
@ -606,7 +606,7 @@ TEST_F(
|
|||
mod->AST().AddGlobalVariable(depth_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(Var("param", ast::StorageClass::kFunction, ty.f32));
|
||||
params.push_back(Var("param", ast::StorageClass::kFunction, ty.f32()));
|
||||
|
||||
auto body = ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("depth"),
|
||||
|
@ -614,7 +614,7 @@ TEST_F(
|
|||
create<ast::ReturnStatement>(Expr("param")),
|
||||
};
|
||||
auto* sub_func =
|
||||
Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{});
|
||||
Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{});
|
||||
|
||||
mod->AST().Functions().Add(sub_func);
|
||||
|
||||
|
@ -623,7 +623,7 @@ TEST_F(
|
|||
create<ast::ReturnStatement>(),
|
||||
};
|
||||
auto* func_1 =
|
||||
Func("ep_1", ast::VariableList{}, ty.void_, body,
|
||||
Func("ep_1", ast::VariableList{}, ty.void_(), body,
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
@ -666,24 +666,24 @@ TEST_F(MslGeneratorImplTest,
|
|||
mod->AST().AddGlobalVariable(coord_var);
|
||||
|
||||
ast::VariableList params;
|
||||
params.push_back(Var("param", ast::StorageClass::kFunction, ty.f32));
|
||||
params.push_back(Var("param", ast::StorageClass::kFunction, ty.f32()));
|
||||
|
||||
auto body = ast::StatementList{
|
||||
create<ast::ReturnStatement>(MemberAccessor("coord", "x")),
|
||||
};
|
||||
auto* sub_func =
|
||||
Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{});
|
||||
Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{});
|
||||
|
||||
mod->AST().Functions().Add(sub_func);
|
||||
|
||||
ast::ExpressionList expr;
|
||||
expr.push_back(Expr(1.0f));
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
Call("sub_func", 1.0f), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -716,8 +716,8 @@ fragment void frag_main(constant float4& coord [[buffer(0)]]) {
|
|||
TEST_F(MslGeneratorImplTest,
|
||||
Emit_FunctionDecoration_Called_By_EntryPoint_With_RW_StorageBuffer) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(0)}),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
|
@ -734,20 +734,20 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
Var("param", ast::StorageClass::kFunction, ty.f32)); // decorations
|
||||
Var("param", ast::StorageClass::kFunction, ty.f32())); // decorations
|
||||
|
||||
auto body = ast::StatementList{
|
||||
create<ast::ReturnStatement>(MemberAccessor("coord", "b"))};
|
||||
auto* sub_func =
|
||||
Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{});
|
||||
Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{});
|
||||
|
||||
mod->AST().Functions().Add(sub_func);
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
Call("sub_func", 1.0f), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -785,8 +785,8 @@ fragment void frag_main(device Data& coord [[buffer(0)]]) {
|
|||
TEST_F(MslGeneratorImplTest,
|
||||
Emit_FunctionDecoration_Called_By_EntryPoint_With_RO_StorageBuffer) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(0)}),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
|
@ -803,23 +803,23 @@ TEST_F(MslGeneratorImplTest,
|
|||
|
||||
ast::VariableList params;
|
||||
params.push_back(
|
||||
Var("param", ast::StorageClass::kFunction, ty.f32)); // decorations
|
||||
Var("param", ast::StorageClass::kFunction, ty.f32())); // decorations
|
||||
|
||||
auto body = ast::StatementList{
|
||||
create<ast::ReturnStatement>(MemberAccessor("coord", "b"))};
|
||||
auto* sub_func =
|
||||
Func("sub_func", params, ty.f32, body, ast::FunctionDecorationList{});
|
||||
Func("sub_func", params, ty.f32(), body, ast::FunctionDecorationList{});
|
||||
|
||||
mod->AST().Functions().Add(sub_func);
|
||||
|
||||
ast::ExpressionList expr;
|
||||
expr.push_back(Expr(1.0f));
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
Call("sub_func", 1.0f), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("frag_main", ast::VariableList{}, ty.void_,
|
||||
Func("frag_main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -857,7 +857,7 @@ fragment void frag_main(const device Data& coord [[buffer(0)]]) {
|
|||
TEST_F(MslGeneratorImplTest,
|
||||
Emit_FunctionDecoration_EntryPoints_WithGlobal_Nested_Return) {
|
||||
auto* bar_var =
|
||||
Var("bar", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("bar", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{create<ast::LocationDecoration>(1)});
|
||||
|
||||
td.RegisterVariableForTesting(bar_var);
|
||||
|
@ -876,7 +876,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
};
|
||||
|
||||
auto* func_1 =
|
||||
Func("ep_1", ast::VariableList{}, ty.void_, body,
|
||||
Func("ep_1", ast::VariableList{}, ty.void_(), body,
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
@ -909,7 +909,7 @@ fragment ep_1_out ep_1() {
|
|||
TEST_F(MslGeneratorImplTest,
|
||||
Emit_FunctionDecoration_EntryPoint_WithNameCollision) {
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.void_, ast::StatementList{},
|
||||
Func("main", ast::VariableList{}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
|
||||
});
|
||||
|
@ -932,7 +932,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_WithArrayParams) {
|
|||
ast::VariableList params;
|
||||
params.push_back(Var("a", ast::StorageClass::kNone, ty.array<f32, 5>()));
|
||||
|
||||
auto* func = Func("my_func", params, ty.void_,
|
||||
auto* func = Func("my_func", params, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -976,7 +976,7 @@ TEST_F(MslGeneratorImplTest,
|
|||
s_decos.push_back(create<ast::StructBlockDecoration>());
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("d", ty.f32, {MemberOffset(0)})}, s_decos);
|
||||
ast::StructMemberList{Member("d", ty.f32(), {MemberOffset(0)})}, s_decos);
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
type::AccessControl ac(ast::AccessControl::kReadWrite, s);
|
||||
|
@ -991,11 +991,11 @@ TEST_F(MslGeneratorImplTest,
|
|||
mod->AST().AddGlobalVariable(data_var);
|
||||
|
||||
{
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
MemberAccessor("data", "d"), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("a", ast::VariableList{}, ty.void_,
|
||||
Func("a", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -1008,11 +1008,11 @@ TEST_F(MslGeneratorImplTest,
|
|||
}
|
||||
|
||||
{
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
MemberAccessor("data", "d"), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("b", ast::VariableList{}, ty.void_,
|
||||
Func("b", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>()},
|
||||
ast::FunctionDecorationList{
|
||||
|
|
|
@ -150,13 +150,13 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) {
|
|||
// }
|
||||
// }
|
||||
|
||||
auto* var = Var("lhs", ast::StorageClass::kFunction, ty.f32, Expr(2.4f),
|
||||
auto* var = Var("lhs", ast::StorageClass::kFunction, ty.f32(), Expr(2.4f),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* body = create<ast::BlockStatement>(
|
||||
ast::StatementList{create<ast::VariableDeclStatement>(var),
|
||||
create<ast::VariableDeclStatement>(Var(
|
||||
"other", ast::StorageClass::kFunction, ty.f32))});
|
||||
auto* body = create<ast::BlockStatement>(ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::VariableDeclStatement>(
|
||||
Var("other", ast::StorageClass::kFunction, ty.f32()))});
|
||||
|
||||
auto* continuing = create<ast::BlockStatement>(ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("lhs"), Expr("rhs")),
|
||||
|
|
|
@ -46,7 +46,7 @@ TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_SpecConstant) {
|
||||
auto* var = Const("pos", ast::StorageClass::kNone, ty.f32, Expr(3.f),
|
||||
auto* var = Const("pos", ast::StorageClass::kNone, ty.f32(), Expr(3.f),
|
||||
ast::VariableDecorationList{
|
||||
create<ast::ConstantIdDecoration>(23),
|
||||
});
|
||||
|
|
|
@ -49,7 +49,7 @@ using MslGeneratorImplTest = TestHelper;
|
|||
|
||||
TEST_F(MslGeneratorImplTest, Generate) {
|
||||
auto* func =
|
||||
Func("my_func", ast::VariableList{}, ty.void_, ast::StatementList{},
|
||||
Func("my_func", ast::VariableList{}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
|
||||
});
|
||||
|
@ -123,7 +123,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
"thread_position_in_grid"}));
|
||||
|
||||
TEST_F(MslGeneratorImplTest, calculate_alignment_size_alias) {
|
||||
auto* alias = ty.alias("a", ty.f32);
|
||||
auto* alias = ty.alias("a", ty.f32());
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
EXPECT_EQ(4u, gen.calculate_alignment_size(alias));
|
||||
|
@ -138,19 +138,19 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_array) {
|
|||
TEST_F(MslGeneratorImplTest, calculate_alignment_size_bool) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
EXPECT_EQ(1u, gen.calculate_alignment_size(ty.bool_));
|
||||
EXPECT_EQ(1u, gen.calculate_alignment_size(ty.bool_()));
|
||||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, calculate_alignment_size_f32) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
EXPECT_EQ(4u, gen.calculate_alignment_size(ty.f32));
|
||||
EXPECT_EQ(4u, gen.calculate_alignment_size(ty.f32()));
|
||||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, calculate_alignment_size_i32) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
EXPECT_EQ(4u, gen.calculate_alignment_size(ty.i32));
|
||||
EXPECT_EQ(4u, gen.calculate_alignment_size(ty.i32()));
|
||||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, calculate_alignment_size_matrix) {
|
||||
|
@ -160,7 +160,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_matrix) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, calculate_alignment_size_pointer) {
|
||||
type::Pointer ptr(ty.bool_, ast::StorageClass::kPrivate);
|
||||
type::Pointer ptr(ty.bool_(), ast::StorageClass::kPrivate);
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
EXPECT_EQ(0u, gen.calculate_alignment_size(&ptr));
|
||||
|
@ -168,9 +168,9 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_pointer) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(4)}),
|
||||
Member("b", ty.f32, {MemberOffset(32)}),
|
||||
Member("c", ty.f32, {MemberOffset(128)})},
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(4)}),
|
||||
Member("b", ty.f32(), {MemberOffset(32)}),
|
||||
Member("c", ty.f32(), {MemberOffset(128)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
@ -182,17 +182,17 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) {
|
||||
auto* inner_str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32, {MemberOffset(0)}),
|
||||
ast::StructMemberList{Member("a", ty.i32(), {MemberOffset(0)}),
|
||||
Member("b", ty.vec3<f32>(), {MemberOffset(16)}),
|
||||
Member("c", ty.f32, {MemberOffset(32)})},
|
||||
Member("c", ty.f32(), {MemberOffset(32)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* inner_s = ty.struct_("Inner", inner_str);
|
||||
|
||||
auto* outer_str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("d", ty.f32, {MemberOffset(0)}),
|
||||
ast::StructMemberList{Member("d", ty.f32(), {MemberOffset(0)}),
|
||||
Member("e", inner_s, {MemberOffset(32)}),
|
||||
Member("f", ty.f32, {MemberOffset(64)})},
|
||||
Member("f", ty.f32(), {MemberOffset(64)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* outer_s = ty.struct_("Outer", outer_str);
|
||||
|
@ -205,7 +205,7 @@ TEST_F(MslGeneratorImplTest, calculate_alignment_size_struct_of_struct) {
|
|||
TEST_F(MslGeneratorImplTest, calculate_alignment_size_u32) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
EXPECT_EQ(4u, gen.calculate_alignment_size(ty.u32));
|
||||
EXPECT_EQ(4u, gen.calculate_alignment_size(ty.u32()));
|
||||
}
|
||||
|
||||
struct MslVectorSizeData {
|
||||
|
@ -220,7 +220,7 @@ using MslVectorSizeBoolTest = TestParamHelper<MslVectorSizeData>;
|
|||
TEST_P(MslVectorSizeBoolTest, calculate) {
|
||||
auto param = GetParam();
|
||||
|
||||
type::Vector vec(ty.bool_, param.elements);
|
||||
type::Vector vec(ty.bool_(), param.elements);
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec));
|
||||
|
@ -235,7 +235,7 @@ using MslVectorSizeI32Test = TestParamHelper<MslVectorSizeData>;
|
|||
TEST_P(MslVectorSizeI32Test, calculate) {
|
||||
auto param = GetParam();
|
||||
|
||||
type::Vector vec(ty.i32, param.elements);
|
||||
type::Vector vec(ty.i32(), param.elements);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -251,7 +251,7 @@ using MslVectorSizeU32Test = TestParamHelper<MslVectorSizeData>;
|
|||
TEST_P(MslVectorSizeU32Test, calculate) {
|
||||
auto param = GetParam();
|
||||
|
||||
type::Vector vec(ty.u32, param.elements);
|
||||
type::Vector vec(ty.u32(), param.elements);
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec));
|
||||
|
@ -266,7 +266,7 @@ using MslVectorSizeF32Test = TestParamHelper<MslVectorSizeData>;
|
|||
TEST_P(MslVectorSizeF32Test, calculate) {
|
||||
auto param = GetParam();
|
||||
|
||||
type::Vector vec(ty.f32, param.elements);
|
||||
type::Vector vec(ty.f32(), param.elements);
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
EXPECT_EQ(param.byte_size, gen.calculate_alignment_size(&vec));
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace {
|
|||
using MslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(MslGeneratorImplTest, EmitType_Alias) {
|
||||
auto* alias = ty.alias("alias", ty.f32);
|
||||
auto* alias = ty.alias("alias", ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -57,7 +57,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Alias) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, EmitType_Alias_NameCollision) {
|
||||
auto* alias = ty.alias("bool", ty.f32);
|
||||
auto* alias = ty.alias("bool", ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -137,21 +137,21 @@ TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray_NameCollision) {
|
|||
TEST_F(MslGeneratorImplTest, EmitType_Bool) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(ty.bool_, "")) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(ty.bool_(), "")) << gen.error();
|
||||
EXPECT_EQ(gen.result(), "bool");
|
||||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, EmitType_F32) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(ty.f32, "")) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(ty.f32(), "")) << gen.error();
|
||||
EXPECT_EQ(gen.result(), "float");
|
||||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, EmitType_I32) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(ty.i32, "")) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(ty.i32(), "")) << gen.error();
|
||||
EXPECT_EQ(gen.result(), "int");
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Matrix) {
|
|||
|
||||
// TODO(dsinclair): How to annotate as workgroup?
|
||||
TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Pointer) {
|
||||
type::Pointer p(ty.f32, ast::StorageClass::kWorkgroup);
|
||||
type::Pointer p(ty.f32(), ast::StorageClass::kWorkgroup);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -174,8 +174,8 @@ TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Pointer) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, EmitType_Struct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32()),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
@ -188,8 +188,8 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, EmitType_StructDecl) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32()),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
@ -207,9 +207,9 @@ TEST_F(MslGeneratorImplTest, EmitType_StructDecl) {
|
|||
TEST_F(MslGeneratorImplTest, EmitType_Struct_InjectPadding) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{
|
||||
Member("a", ty.i32, {MemberOffset(4)}),
|
||||
Member("b", ty.f32, {MemberOffset(32)}),
|
||||
Member("c", ty.f32, {MemberOffset(128)}),
|
||||
Member("a", ty.i32(), {MemberOffset(4)}),
|
||||
Member("b", ty.f32(), {MemberOffset(32)}),
|
||||
Member("c", ty.f32(), {MemberOffset(128)}),
|
||||
},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
|
@ -230,9 +230,10 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_InjectPadding) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, EmitType_Struct_NameCollision) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("main", ty.i32), Member("float", ty.f32)},
|
||||
ast::StructDecorationList{});
|
||||
auto* str =
|
||||
create<ast::Struct>(ast::StructMemberList{Member("main", ty.i32()),
|
||||
Member("float", ty.f32())},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
||||
|
@ -251,8 +252,8 @@ TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Struct_WithDecoration) {
|
|||
ast::StructDecorationList decos;
|
||||
decos.push_back(create<ast::StructBlockDecoration>());
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32()),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
decos);
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
@ -269,7 +270,7 @@ TEST_F(MslGeneratorImplTest, DISABLED_EmitType_Struct_WithDecoration) {
|
|||
TEST_F(MslGeneratorImplTest, EmitType_U32) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(ty.u32, "")) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(ty.u32(), "")) << gen.error();
|
||||
EXPECT_EQ(gen.result(), "uint");
|
||||
}
|
||||
|
||||
|
@ -283,7 +284,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Vector) {
|
|||
TEST_F(MslGeneratorImplTest, EmitType_Void) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(ty.void_, "")) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(ty.void_(), "")) << gen.error();
|
||||
EXPECT_EQ(gen.result(), "void");
|
||||
}
|
||||
|
||||
|
@ -349,7 +350,7 @@ using MslSampledtexturesTest = TestParamHelper<MslTextureData>;
|
|||
TEST_P(MslSampledtexturesTest, Emit) {
|
||||
auto params = GetParam();
|
||||
|
||||
type::SampledTexture s(params.dim, ty.f32);
|
||||
type::SampledTexture s(params.dim, ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -376,7 +377,7 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
"texturecube_array<float, access::sample>"}));
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_TypeMultisampledTexture) {
|
||||
type::MultisampledTexture s(type::TextureDimension::k2d, ty.u32);
|
||||
type::MultisampledTexture s(type::TextureDimension::k2d, ty.u32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace {
|
|||
using MslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement) {
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32());
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -53,7 +53,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const) {
|
||||
auto* var = Const("a", ast::StorageClass::kNone, ty.f32);
|
||||
auto* var = Const("a", ast::StorageClass::kNone, ty.f32());
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -65,7 +65,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Const) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) {
|
||||
type::Array ary(ty.f32, 5, ast::ArrayDecorationList{});
|
||||
type::Array ary(ty.f32(), 5, ast::ArrayDecorationList{});
|
||||
|
||||
auto* var = Var("a", ast::StorageClass::kNone, &ary);
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
@ -80,8 +80,8 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Array) {
|
|||
|
||||
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Struct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.f32),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.f32()),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
@ -123,7 +123,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Matrix) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) {
|
||||
auto* var = Var("a", ast::StorageClass::kPrivate, ty.f32);
|
||||
auto* var = Var("a", ast::StorageClass::kPrivate, ty.f32());
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -135,7 +135,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) {
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32, Expr("initializer"),
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32(), Expr("initializer"),
|
||||
ast::VariableDecorationList{});
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
|
|
|
@ -87,7 +87,7 @@ TEST_F(BuilderTest, Accessor_Array_LoadIndex) {
|
|||
// ary[idx] -> ptr<f32>
|
||||
|
||||
auto* var = Var("ary", ast::StorageClass::kFunction, ty.vec3<f32>());
|
||||
auto* idx = Var("idx", ast::StorageClass::kFunction, ty.i32);
|
||||
auto* idx = Var("idx", ast::StorageClass::kFunction, ty.i32());
|
||||
|
||||
auto* ary = Expr("ary");
|
||||
auto* idx_expr = Expr("idx");
|
||||
|
@ -253,7 +253,7 @@ TEST_F(BuilderTest, MemberAccessor) {
|
|||
// ident.b
|
||||
|
||||
auto* s = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.f32), Member("b", ty.f32)},
|
||||
ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.f32())},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s_type = ty.struct_("my_struct", s);
|
||||
|
@ -298,8 +298,8 @@ TEST_F(BuilderTest, MemberAccessor_Nested) {
|
|||
// var ident : my_struct
|
||||
// ident.inner.a
|
||||
auto* inner_struct = ty.struct_(
|
||||
"Inner", create<ast::Struct>(ast::StructMemberList{Member("a", ty.f32),
|
||||
Member("b", ty.f32)},
|
||||
"Inner", create<ast::Struct>(ast::StructMemberList{Member("a", ty.f32()),
|
||||
Member("b", ty.f32())},
|
||||
ast::StructDecorationList{}));
|
||||
|
||||
auto* s_type = ty.struct_(
|
||||
|
@ -349,8 +349,8 @@ TEST_F(BuilderTest, MemberAccessor_Nested_WithAlias) {
|
|||
// var ident : my_struct
|
||||
// ident.inner.a
|
||||
auto* inner_struct = ty.struct_(
|
||||
"Inner", create<ast::Struct>(ast::StructMemberList{Member("a", ty.f32),
|
||||
Member("b", ty.f32)},
|
||||
"Inner", create<ast::Struct>(ast::StructMemberList{Member("a", ty.f32()),
|
||||
Member("b", ty.f32())},
|
||||
ast::StructDecorationList{}));
|
||||
|
||||
auto* alias = ty.alias("Inner", inner_struct);
|
||||
|
@ -400,8 +400,8 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_LHS) {
|
|||
// var ident : my_struct
|
||||
// ident.inner.a = 2.0f;
|
||||
auto* inner_struct = ty.struct_(
|
||||
"Inner", create<ast::Struct>(ast::StructMemberList{Member("a", ty.f32),
|
||||
Member("b", ty.f32)},
|
||||
"Inner", create<ast::Struct>(ast::StructMemberList{Member("a", ty.f32()),
|
||||
Member("b", ty.f32())},
|
||||
ast::StructDecorationList{}));
|
||||
|
||||
auto* s_type = ty.struct_(
|
||||
|
@ -454,8 +454,8 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) {
|
|||
// var store : f32 = ident.inner.a
|
||||
|
||||
auto* inner_struct = ty.struct_(
|
||||
"Inner", create<ast::Struct>(ast::StructMemberList{Member("a", ty.f32),
|
||||
Member("b", ty.f32)},
|
||||
"Inner", create<ast::Struct>(ast::StructMemberList{Member("a", ty.f32()),
|
||||
Member("b", ty.f32())},
|
||||
ast::StructDecorationList{}));
|
||||
|
||||
auto* s_type = ty.struct_(
|
||||
|
@ -464,7 +464,7 @@ TEST_F(BuilderTest, MemberAccessor_Nested_Assignment_RHS) {
|
|||
ast::StructDecorationList{}));
|
||||
|
||||
auto* var = Var("ident", ast::StorageClass::kFunction, s_type);
|
||||
auto* store = Var("store", ast::StorageClass::kFunction, ty.f32);
|
||||
auto* store = Var("store", ast::StorageClass::kFunction, ty.f32());
|
||||
|
||||
auto* rhs = MemberAccessor(MemberAccessor("ident", "inner"), "a");
|
||||
auto* expr = create<ast::AssignmentStatement>(Expr("store"), rhs);
|
||||
|
|
|
@ -42,7 +42,7 @@ namespace {
|
|||
using BuilderTest = TestHelper;
|
||||
|
||||
TEST_F(BuilderTest, Assign_Var) {
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32);
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32());
|
||||
|
||||
auto* assign = create<ast::AssignmentStatement>(Expr("var"), Expr(1.f));
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
@ -71,7 +71,7 @@ TEST_F(BuilderTest, Assign_Var) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Assign_Var_OutsideFunction_IsError) {
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32);
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32());
|
||||
|
||||
auto* assign = create<ast::AssignmentStatement>(Expr("var"), Expr(1.f));
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
@ -200,7 +200,7 @@ TEST_F(BuilderTest, Assign_StructMember) {
|
|||
// ident.b = 4.0;
|
||||
|
||||
auto* s = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.f32), Member("b", ty.f32)},
|
||||
ast::StructMemberList{Member("a", ty.f32()), Member("b", ty.f32())},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s_type = ty.struct_("my_struct", s);
|
||||
|
|
|
@ -100,7 +100,7 @@ TEST_P(BinaryArithSignedIntegerTest, Vector) {
|
|||
TEST_P(BinaryArithSignedIntegerTest, Scalar_Loads) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* var = Var("param", ast::StorageClass::kFunction, ty.i32);
|
||||
auto* var = Var("param", ast::StorageClass::kFunction, ty.i32());
|
||||
auto* expr =
|
||||
create<ast::BinaryExpression>(param.op, Expr("param"), Expr("param"));
|
||||
|
||||
|
@ -680,9 +680,9 @@ OpBranch %7
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Binary_LogicalAnd_WithLoads) {
|
||||
auto* a_var = Var("a", ast::StorageClass::kFunction, ty.bool_, Expr(true),
|
||||
auto* a_var = Var("a", ast::StorageClass::kFunction, ty.bool_(), Expr(true),
|
||||
ast::VariableDecorationList{});
|
||||
auto* b_var = Var("b", ast::StorageClass::kFunction, ty.bool_, Expr(false),
|
||||
auto* b_var = Var("b", ast::StorageClass::kFunction, ty.bool_(), Expr(false),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
td.RegisterVariableForTesting(a_var);
|
||||
|
@ -842,9 +842,9 @@ OpBranch %7
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Binary_LogicalOr_WithLoads) {
|
||||
auto* a_var = Var("a", ast::StorageClass::kFunction, ty.bool_, Expr(true),
|
||||
auto* a_var = Var("a", ast::StorageClass::kFunction, ty.bool_(), Expr(true),
|
||||
ast::VariableDecorationList{});
|
||||
auto* b_var = Var("b", ast::StorageClass::kFunction, ty.bool_, Expr(false),
|
||||
auto* b_var = Var("b", ast::StorageClass::kFunction, ty.bool_(), Expr(false),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
td.RegisterVariableForTesting(a_var);
|
||||
|
|
|
@ -32,7 +32,7 @@ namespace {
|
|||
using BuilderTest = TestHelper;
|
||||
|
||||
TEST_F(BuilderTest, Bitcast) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.u32, Expr(2.4f));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.u32(), Expr(2.4f));
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(bitcast)) << td.error();
|
||||
|
||||
|
@ -51,7 +51,7 @@ TEST_F(BuilderTest, Bitcast) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Bitcast_DuplicateType) {
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32, Expr(2.4f));
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr(2.4f));
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(bitcast)) << td.error();
|
||||
|
||||
|
|
|
@ -39,11 +39,11 @@ TEST_F(BuilderTest, Block) {
|
|||
// serves to prove the block code is pushing new scopes as needed.
|
||||
auto* inner = create<ast::BlockStatement>(ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(
|
||||
Var("var", ast::StorageClass::kFunction, ty.f32)),
|
||||
Var("var", ast::StorageClass::kFunction, ty.f32())),
|
||||
create<ast::AssignmentStatement>(Expr("var"), Expr(2.f))});
|
||||
auto* outer = create<ast::BlockStatement>(ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(
|
||||
Var("var", ast::StorageClass::kFunction, ty.f32)),
|
||||
Var("var", ast::StorageClass::kFunction, ty.f32())),
|
||||
create<ast::AssignmentStatement>(Expr("var"), Expr(1.f)), inner,
|
||||
create<ast::AssignmentStatement>(Expr("var"), Expr(3.f))});
|
||||
|
||||
|
|
|
@ -41,15 +41,15 @@ using BuilderTest = TestHelper;
|
|||
|
||||
TEST_F(BuilderTest, Expression_Call) {
|
||||
ast::VariableList func_params;
|
||||
func_params.push_back(Var("a", ast::StorageClass::kFunction, ty.f32));
|
||||
func_params.push_back(Var("b", ast::StorageClass::kFunction, ty.f32));
|
||||
func_params.push_back(Var("a", ast::StorageClass::kFunction, ty.f32()));
|
||||
func_params.push_back(Var("b", ast::StorageClass::kFunction, ty.f32()));
|
||||
|
||||
auto* a_func =
|
||||
Func("a_func", func_params, ty.f32,
|
||||
Func("a_func", func_params, ty.f32(),
|
||||
ast::StatementList{create<ast::ReturnStatement>(Add("a", "b"))},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
auto* func = Func("main", {}, ty.void_, ast::StatementList{},
|
||||
auto* func = Func("main", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
auto* expr = Call("a_func", 1.f, 1.f);
|
||||
|
@ -91,15 +91,15 @@ OpFunctionEnd
|
|||
|
||||
TEST_F(BuilderTest, Statement_Call) {
|
||||
ast::VariableList func_params;
|
||||
func_params.push_back(Var("a", ast::StorageClass::kFunction, ty.f32));
|
||||
func_params.push_back(Var("b", ast::StorageClass::kFunction, ty.f32));
|
||||
func_params.push_back(Var("a", ast::StorageClass::kFunction, ty.f32()));
|
||||
func_params.push_back(Var("b", ast::StorageClass::kFunction, ty.f32()));
|
||||
|
||||
auto* a_func =
|
||||
Func("a_func", func_params, ty.void_,
|
||||
Func("a_func", func_params, ty.void_(),
|
||||
ast::StatementList{create<ast::ReturnStatement>(Add("a", "b"))},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
auto* func = Func("main", {}, ty.void_, ast::StatementList{},
|
||||
auto* func = Func("main", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
auto* expr = create<ast::CallStatement>(Call("a_func", 1.f, 1.f));
|
||||
|
|
|
@ -122,7 +122,7 @@ TEST_F(SpvBuilderConstructorTest, Type_WithAlias) {
|
|||
// type Int = i32
|
||||
// cast<Int>(2.3f)
|
||||
|
||||
auto* alias = ty.alias("Int", ty.i32);
|
||||
auto* alias = ty.alias("Int", ty.i32());
|
||||
auto* cast = Construct(alias, 2.3f);
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(cast)) << td.error();
|
||||
|
@ -142,7 +142,7 @@ TEST_F(SpvBuilderConstructorTest, Type_WithAlias) {
|
|||
}
|
||||
|
||||
TEST_F(SpvBuilderConstructorTest, Type_IdentifierExpression_Param) {
|
||||
auto* var = Var("ident", ast::StorageClass::kFunction, ty.f32);
|
||||
auto* var = Var("ident", ast::StorageClass::kFunction, ty.f32());
|
||||
|
||||
auto* t = vec2<f32>(1.0f, "ident");
|
||||
|
||||
|
@ -1050,7 +1050,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Array_2_Vec3) {
|
|||
TEST_F(SpvBuilderConstructorTest, Type_Struct) {
|
||||
auto* s = create<ast::Struct>(
|
||||
ast::StructMemberList{
|
||||
Member("a", ty.f32),
|
||||
Member("a", ty.f32()),
|
||||
Member("b", ty.vec3<f32>()),
|
||||
},
|
||||
ast::StructDecorationList{});
|
||||
|
@ -1076,7 +1076,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Struct) {
|
|||
}
|
||||
|
||||
TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_F32) {
|
||||
auto* t = Construct(ty.f32);
|
||||
auto* t = Construct(ty.f32());
|
||||
|
||||
EXPECT_TRUE(td.DetermineResultType(t)) << td.error();
|
||||
|
||||
|
@ -1127,7 +1127,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_U32) {
|
|||
}
|
||||
|
||||
TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Bool) {
|
||||
auto* t = Construct(ty.bool_);
|
||||
auto* t = Construct(ty.bool_());
|
||||
|
||||
EXPECT_TRUE(td.DetermineResultType(t)) << td.error();
|
||||
|
||||
|
@ -1203,7 +1203,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Array) {
|
|||
TEST_F(SpvBuilderConstructorTest, Type_ZeroInit_Struct) {
|
||||
auto* s = create<ast::Struct>(
|
||||
ast::StructMemberList{
|
||||
Member("a", ty.f32),
|
||||
Member("a", ty.f32()),
|
||||
},
|
||||
ast::StructDecorationList{});
|
||||
auto* s_type = ty.struct_("my_struct", s);
|
||||
|
@ -1516,9 +1516,9 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_GlobalVector_WithIdent) {
|
|||
// vec3<f32>(a, b, c) -> false -- ERROR
|
||||
auto* t = vec3<f32>("a", "b", "c");
|
||||
|
||||
Var("a", ast::StorageClass::kPrivate, ty.f32);
|
||||
Var("b", ast::StorageClass::kPrivate, ty.f32);
|
||||
Var("c", ast::StorageClass::kPrivate, ty.f32);
|
||||
Var("a", ast::StorageClass::kPrivate, ty.f32());
|
||||
Var("b", ast::StorageClass::kPrivate, ty.f32());
|
||||
Var("c", ast::StorageClass::kPrivate, ty.f32());
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(t)) << td.error();
|
||||
|
||||
|
@ -1591,9 +1591,9 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Vector_WithIdent) {
|
|||
|
||||
auto* t = vec3<f32>("a", "b", "c");
|
||||
|
||||
Var("a", ast::StorageClass::kPrivate, ty.f32);
|
||||
Var("b", ast::StorageClass::kPrivate, ty.f32);
|
||||
Var("c", ast::StorageClass::kPrivate, ty.f32);
|
||||
Var("a", ast::StorageClass::kPrivate, ty.f32());
|
||||
Var("b", ast::StorageClass::kPrivate, ty.f32());
|
||||
Var("c", ast::StorageClass::kPrivate, ty.f32());
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(t)) << td.error();
|
||||
|
||||
|
@ -1662,7 +1662,7 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_BitCastScalars) {
|
|||
TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct) {
|
||||
auto* s = create<ast::Struct>(
|
||||
ast::StructMemberList{
|
||||
Member("a", ty.f32),
|
||||
Member("a", ty.f32()),
|
||||
Member("b", ty.vec3<f32>()),
|
||||
},
|
||||
ast::StructDecorationList{});
|
||||
|
@ -1680,7 +1680,7 @@ TEST_F(SpvBuilderConstructorTest,
|
|||
IsConstructorConst_Struct_WithIdentSubExpression) {
|
||||
auto* s = create<ast::Struct>(
|
||||
ast::StructMemberList{
|
||||
Member("a", ty.f32),
|
||||
Member("a", ty.f32()),
|
||||
Member("b", ty.vec3<f32>()),
|
||||
},
|
||||
ast::StructDecorationList{});
|
||||
|
@ -1688,8 +1688,8 @@ TEST_F(SpvBuilderConstructorTest,
|
|||
auto* s_type = ty.struct_("my_struct", s);
|
||||
auto* t = Construct(s_type, 2.f, "a", 2.f);
|
||||
|
||||
Var("a", ast::StorageClass::kPrivate, ty.f32);
|
||||
Var("b", ast::StorageClass::kPrivate, ty.f32);
|
||||
Var("a", ast::StorageClass::kPrivate, ty.f32());
|
||||
Var("b", ast::StorageClass::kPrivate, ty.f32());
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(t)) << td.error();
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ using BuilderTest = TestHelper;
|
|||
|
||||
TEST_F(BuilderTest, FunctionDecoration_Stage) {
|
||||
auto* func =
|
||||
Func("main", {}, ty.void_, ast::StatementList{},
|
||||
Func("main", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
@ -63,7 +63,7 @@ using FunctionDecoration_StageTest = TestParamHelper<FunctionStageData>;
|
|||
TEST_P(FunctionDecoration_StageTest, Emit) {
|
||||
auto params = GetParam();
|
||||
|
||||
auto* func = Func("main", {}, ty.void_, ast::StatementList{},
|
||||
auto* func = Func("main", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(params.stage),
|
||||
});
|
||||
|
@ -91,14 +91,14 @@ INSTANTIATE_TEST_SUITE_P(
|
|||
|
||||
TEST_F(BuilderTest, FunctionDecoration_Stage_WithUnusedInterfaceIds) {
|
||||
auto* func =
|
||||
Func("main", {}, ty.void_, ast::StatementList{},
|
||||
Func("main", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
auto* v_in = Var("my_in", ast::StorageClass::kInput, ty.f32);
|
||||
auto* v_out = Var("my_out", ast::StorageClass::kOutput, ty.f32);
|
||||
auto* v_wg = Var("my_wg", ast::StorageClass::kWorkgroup, ty.f32);
|
||||
auto* v_in = Var("my_in", ast::StorageClass::kInput, ty.f32());
|
||||
auto* v_out = Var("my_out", ast::StorageClass::kOutput, ty.f32());
|
||||
auto* v_wg = Var("my_wg", ast::StorageClass::kWorkgroup, ty.f32());
|
||||
|
||||
mod->AST().AddGlobalVariable(v_in);
|
||||
mod->AST().AddGlobalVariable(v_out);
|
||||
|
@ -134,7 +134,7 @@ OpName %11 "main"
|
|||
|
||||
TEST_F(BuilderTest, FunctionDecoration_Stage_WithUsedInterfaceIds) {
|
||||
auto* func =
|
||||
Func("main", {}, ty.void_,
|
||||
Func("main", {}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("my_out"), Expr("my_in")),
|
||||
create<ast::AssignmentStatement>(Expr("my_wg"), Expr("my_wg")),
|
||||
|
@ -145,9 +145,9 @@ TEST_F(BuilderTest, FunctionDecoration_Stage_WithUsedInterfaceIds) {
|
|||
create<ast::StageDecoration>(ast::PipelineStage::kVertex),
|
||||
});
|
||||
|
||||
auto* v_in = Var("my_in", ast::StorageClass::kInput, ty.f32);
|
||||
auto* v_out = Var("my_out", ast::StorageClass::kOutput, ty.f32);
|
||||
auto* v_wg = Var("my_wg", ast::StorageClass::kWorkgroup, ty.f32);
|
||||
auto* v_in = Var("my_in", ast::StorageClass::kInput, ty.f32());
|
||||
auto* v_out = Var("my_out", ast::StorageClass::kOutput, ty.f32());
|
||||
auto* v_wg = Var("my_wg", ast::StorageClass::kWorkgroup, ty.f32());
|
||||
|
||||
mod->AST().AddGlobalVariable(v_in);
|
||||
mod->AST().AddGlobalVariable(v_out);
|
||||
|
@ -189,7 +189,7 @@ OpName %11 "main"
|
|||
|
||||
TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_Fragment_OriginUpperLeft) {
|
||||
auto* func =
|
||||
Func("main", {}, ty.void_, ast::StatementList{},
|
||||
Func("main", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
@ -204,7 +204,7 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_Fragment_OriginUpperLeft) {
|
|||
|
||||
TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_WorkgroupSize_Default) {
|
||||
auto* func =
|
||||
Func("main", {}, ty.void_, ast::StatementList{},
|
||||
Func("main", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
|
||||
});
|
||||
|
@ -219,7 +219,7 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_WorkgroupSize_Default) {
|
|||
|
||||
TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_WorkgroupSize) {
|
||||
auto* func =
|
||||
Func("main", {}, ty.void_, ast::StatementList{},
|
||||
Func("main", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::WorkgroupDecoration>(2u, 4u, 6u),
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kCompute),
|
||||
|
@ -235,13 +235,13 @@ TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_WorkgroupSize) {
|
|||
|
||||
TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_MultipleFragment) {
|
||||
auto* func1 =
|
||||
Func("main1", {}, ty.void_, ast::StatementList{},
|
||||
Func("main1", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
||||
auto* func2 =
|
||||
Func("main2", {}, ty.void_, ast::StatementList{},
|
||||
Func("main2", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{
|
||||
create<ast::StageDecoration>(ast::PipelineStage::kFragment),
|
||||
});
|
||||
|
@ -272,14 +272,14 @@ OpFunctionEnd
|
|||
|
||||
TEST_F(BuilderTest, FunctionDecoration_ExecutionMode_FragDepth) {
|
||||
auto* fragdepth =
|
||||
Var("fragdepth", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
Var("fragdepth", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kFragDepth),
|
||||
});
|
||||
mod->AST().AddGlobalVariable(fragdepth);
|
||||
|
||||
auto* func =
|
||||
Func("main", ast::VariableList{}, ty.void_,
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::AssignmentStatement>(Expr("fragdepth"), Expr(1.f)),
|
||||
},
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace {
|
|||
using BuilderTest = TestHelper;
|
||||
|
||||
TEST_F(BuilderTest, Function_Empty) {
|
||||
auto* func = Func("a_func", {}, ty.void_, ast::StatementList{},
|
||||
auto* func = Func("a_func", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -63,7 +63,7 @@ OpFunctionEnd
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Function_Terminator_Return) {
|
||||
auto* func = Func("a_func", {}, ty.void_,
|
||||
auto* func = Func("a_func", {}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -83,10 +83,10 @@ OpFunctionEnd
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Function_Terminator_ReturnValue) {
|
||||
auto* var_a = Var("a", ast::StorageClass::kPrivate, ty.f32);
|
||||
auto* var_a = Var("a", ast::StorageClass::kPrivate, ty.f32());
|
||||
td.RegisterVariableForTesting(var_a);
|
||||
|
||||
auto* func = Func("a_func", {}, ty.void_,
|
||||
auto* func = Func("a_func", {}, ty.void_(),
|
||||
ast::StatementList{create<ast::ReturnStatement>(Expr("a"))},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
|
@ -113,7 +113,7 @@ OpFunctionEnd
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Function_Terminator_Discard) {
|
||||
auto* func = Func("a_func", {}, ty.void_,
|
||||
auto* func = Func("a_func", {}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::DiscardStatement>(),
|
||||
},
|
||||
|
@ -133,10 +133,10 @@ OpFunctionEnd
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Function_WithParams) {
|
||||
ast::VariableList params = {Var("a", ast::StorageClass::kFunction, ty.f32),
|
||||
Var("b", ast::StorageClass::kFunction, ty.i32)};
|
||||
ast::VariableList params = {Var("a", ast::StorageClass::kFunction, ty.f32()),
|
||||
Var("b", ast::StorageClass::kFunction, ty.i32())};
|
||||
|
||||
auto* func = Func("a_func", params, ty.f32,
|
||||
auto* func = Func("a_func", params, ty.f32(),
|
||||
ast::StatementList{create<ast::ReturnStatement>(Expr("a"))},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
|
@ -164,7 +164,7 @@ OpFunctionEnd
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Function_WithBody) {
|
||||
auto* func = Func("a_func", {}, ty.void_,
|
||||
auto* func = Func("a_func", {}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::ReturnStatement>(),
|
||||
},
|
||||
|
@ -184,7 +184,7 @@ OpFunctionEnd
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, FunctionType) {
|
||||
auto* func = Func("a_func", {}, ty.void_, ast::StatementList{},
|
||||
auto* func = Func("a_func", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -196,9 +196,9 @@ TEST_F(BuilderTest, FunctionType) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, FunctionType_DeDuplicate) {
|
||||
auto* func1 = Func("a_func", {}, ty.void_, ast::StatementList{},
|
||||
auto* func1 = Func("a_func", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
auto* func2 = Func("b_func", {}, ty.void_, ast::StatementList{},
|
||||
auto* func2 = Func("b_func", {}, ty.void_(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -231,7 +231,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
|
|||
s_decos.push_back(create<ast::StructBlockDecoration>());
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("d", ty.f32, {MemberOffset(0)})}, s_decos);
|
||||
ast::StructMemberList{Member("d", ty.f32(), {MemberOffset(0)})}, s_decos);
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
type::AccessControl ac(ast::AccessControl::kReadWrite, s);
|
||||
|
@ -248,11 +248,11 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
|
|||
mod->AST().AddGlobalVariable(data_var);
|
||||
|
||||
{
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
MemberAccessor("data", "d"), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("a", ast::VariableList{}, ty.void_,
|
||||
Func("a", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -265,11 +265,11 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) {
|
|||
}
|
||||
|
||||
{
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
auto* var = Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
MemberAccessor("data", "d"), ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("b", ast::VariableList{}, ty.void_,
|
||||
Func("b", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace {
|
|||
using BuilderTest = TestHelper;
|
||||
|
||||
TEST_F(BuilderTest, FunctionVar_NoStorageClass) {
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.f32);
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -68,7 +68,7 @@ TEST_F(BuilderTest, FunctionVar_WithConstantConstructor) {
|
|||
auto* init = vec3<f32>(1.f, 1.f, 3.f);
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32, init,
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32(), init,
|
||||
ast::VariableDecorationList{});
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
||||
|
@ -133,11 +133,11 @@ TEST_F(BuilderTest, FunctionVar_WithNonConstantConstructorLoadedFromVar) {
|
|||
// var v : f32 = 1.0;
|
||||
// var v2 : f32 = v; // Should generate the load and store automatically.
|
||||
|
||||
auto* v = Var("v", ast::StorageClass::kFunction, ty.f32, Expr(1.f),
|
||||
auto* v = Var("v", ast::StorageClass::kFunction, ty.f32(), Expr(1.f),
|
||||
ast::VariableDecorationList{});
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
||||
auto* v2 = Var("v2", ast::StorageClass::kFunction, ty.f32, Expr("v"),
|
||||
auto* v2 = Var("v2", ast::StorageClass::kFunction, ty.f32(), Expr("v"),
|
||||
ast::VariableDecorationList{});
|
||||
td.RegisterVariableForTesting(v2);
|
||||
|
||||
|
@ -174,11 +174,11 @@ TEST_F(BuilderTest, FunctionVar_ConstWithVarInitializer) {
|
|||
// var v : f32 = 1.0;
|
||||
// const v2 : f32 = v; // Should generate the load
|
||||
|
||||
auto* v = Var("v", ast::StorageClass::kFunction, ty.f32, Expr(1.f),
|
||||
auto* v = Var("v", ast::StorageClass::kFunction, ty.f32(), Expr(1.f),
|
||||
ast::VariableDecorationList{});
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
||||
auto* v2 = Var("v2", ast::StorageClass::kFunction, ty.f32, Expr("v"),
|
||||
auto* v2 = Var("v2", ast::StorageClass::kFunction, ty.f32(), Expr("v"),
|
||||
ast::VariableDecorationList{});
|
||||
td.RegisterVariableForTesting(v2);
|
||||
|
||||
|
@ -215,7 +215,7 @@ TEST_F(BuilderTest, FunctionVar_Const) {
|
|||
auto* init = vec3<f32>(1.f, 1.f, 3.f);
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
auto* v = Const("var", ast::StorageClass::kOutput, ty.f32, init,
|
||||
auto* v = Const("var", ast::StorageClass::kOutput, ty.f32(), init,
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
|
|
@ -50,7 +50,7 @@ namespace {
|
|||
using BuilderTest = TestHelper;
|
||||
|
||||
TEST_F(BuilderTest, GlobalVar_NoStorageClass) {
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.f32);
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -65,7 +65,7 @@ TEST_F(BuilderTest, GlobalVar_NoStorageClass) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, GlobalVar_WithStorageClass) {
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32);
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -80,7 +80,7 @@ TEST_F(BuilderTest, GlobalVar_WithStorageClass) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, GlobalVar_WithStorageClass_Input) {
|
||||
auto* v = Var("var", ast::StorageClass::kInput, ty.f32);
|
||||
auto* v = Var("var", ast::StorageClass::kInput, ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -97,7 +97,7 @@ TEST_F(BuilderTest, GlobalVar_WithConstructor) {
|
|||
auto* init = vec3<f32>(1.f, 1.f, 3.f);
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32, init,
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32(), init,
|
||||
ast::VariableDecorationList{});
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
||||
|
@ -122,7 +122,7 @@ TEST_F(BuilderTest, GlobalVar_Const) {
|
|||
auto* init = vec3<f32>(1.f, 1.f, 3.f);
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
auto* v = Const("var", ast::StorageClass::kOutput, ty.f32, init,
|
||||
auto* v = Const("var", ast::StorageClass::kOutput, ty.f32(), init,
|
||||
ast::VariableDecorationList{});
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
||||
|
@ -145,7 +145,7 @@ TEST_F(BuilderTest, GlobalVar_Complex_Constructor) {
|
|||
auto* init = vec3<f32>(ast::ExpressionList{Expr(1.f), Expr(2.f), Expr(3.f)});
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
auto* v = Const("var", ast::StorageClass::kOutput, ty.f32, init,
|
||||
auto* v = Const("var", ast::StorageClass::kOutput, ty.f32(), init,
|
||||
ast::VariableDecorationList{});
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
||||
|
@ -168,7 +168,7 @@ TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) {
|
|||
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
auto* v = Const("var", ast::StorageClass::kOutput, ty.f32, init,
|
||||
auto* v = Const("var", ast::StorageClass::kOutput, ty.f32(), init,
|
||||
ast::VariableDecorationList{});
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
||||
|
@ -194,7 +194,7 @@ TEST_F(BuilderTest, GlobalVar_Complex_ConstructorWithExtract) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, GlobalVar_WithLocation) {
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(5),
|
||||
});
|
||||
|
@ -214,7 +214,7 @@ TEST_F(BuilderTest, GlobalVar_WithLocation) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, GlobalVar_WithBindingAndGroup) {
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BindingDecoration>(2),
|
||||
create<ast::GroupDecoration>(3),
|
||||
|
@ -236,7 +236,7 @@ OpDecorate %1 DescriptorSet 3
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, GlobalVar_WithBuiltin) {
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32, nullptr,
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kPosition),
|
||||
});
|
||||
|
@ -256,7 +256,7 @@ TEST_F(BuilderTest, GlobalVar_WithBuiltin) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) {
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.bool_, Expr(true),
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.bool_(), Expr(true),
|
||||
ast::VariableDecorationList{
|
||||
create<ast::ConstantIdDecoration>(1200),
|
||||
});
|
||||
|
@ -276,7 +276,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) {
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.bool_, nullptr,
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.bool_(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::ConstantIdDecoration>(1200),
|
||||
});
|
||||
|
@ -296,7 +296,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Bool_NoConstructor) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) {
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.f32, Expr(2.f),
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.f32(), Expr(2.f),
|
||||
ast::VariableDecorationList{
|
||||
create<ast::ConstantIdDecoration>(0),
|
||||
});
|
||||
|
@ -316,7 +316,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) {
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.f32, nullptr,
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::ConstantIdDecoration>(0),
|
||||
});
|
||||
|
@ -336,7 +336,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_F32_NoConstructor) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) {
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.i32, nullptr,
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.i32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::ConstantIdDecoration>(0),
|
||||
});
|
||||
|
@ -356,7 +356,7 @@ TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_I32_NoConstructor) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, GlobalVar_ConstantId_Scalar_U32_NoConstructor) {
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.u32, nullptr,
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.u32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::ConstantIdDecoration>(0),
|
||||
});
|
||||
|
@ -418,9 +418,9 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) {
|
|||
// var b : [[access(read)]] A
|
||||
|
||||
auto* A = ty.struct_(
|
||||
"A", create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32), Member("b", ty.i32)},
|
||||
ast::StructDecorationList{}));
|
||||
"A", create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32()),
|
||||
Member("b", ty.i32())},
|
||||
ast::StructDecorationList{}));
|
||||
type::AccessControl ac{ast::AccessControl::kReadOnly, A};
|
||||
|
||||
auto* var = Var("b", ast::StorageClass::kStorage, &ac);
|
||||
|
@ -452,7 +452,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) {
|
|||
// var b : [[access(read)]] B
|
||||
|
||||
auto* A = ty.struct_(
|
||||
"A", create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32)},
|
||||
"A", create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32())},
|
||||
ast::StructDecorationList{}));
|
||||
auto* B = ty.alias("B", A);
|
||||
type::AccessControl ac{ast::AccessControl::kReadOnly, B};
|
||||
|
@ -483,7 +483,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) {
|
|||
// var b : B
|
||||
|
||||
auto* A = ty.struct_(
|
||||
"A", create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32)},
|
||||
"A", create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32())},
|
||||
ast::StructDecorationList{}));
|
||||
type::AccessControl ac{ast::AccessControl::kReadOnly, A};
|
||||
auto* B = ty.alias("B", &ac);
|
||||
|
@ -514,7 +514,7 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) {
|
|||
// var c : [[access(read_write)]] A
|
||||
|
||||
auto* A = ty.struct_(
|
||||
"A", create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32)},
|
||||
"A", create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32())},
|
||||
ast::StructDecorationList{}));
|
||||
type::AccessControl read{ast::AccessControl::kReadOnly, A};
|
||||
type::AccessControl rw{ast::AccessControl::kReadWrite, A};
|
||||
|
|
|
@ -41,7 +41,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) {
|
|||
auto* init = vec3<f32>(1.f, 1.f, 3.f);
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
auto* v = Const("var", ast::StorageClass::kOutput, ty.f32, init,
|
||||
auto* v = Const("var", ast::StorageClass::kOutput, ty.f32(), init,
|
||||
ast::VariableDecorationList{});
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
||||
|
@ -64,7 +64,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, IdentifierExpression_GlobalVar) {
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32);
|
||||
auto* v = Var("var", ast::StorageClass::kOutput, ty.f32());
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
||||
auto* expr = Expr("var");
|
||||
|
@ -89,7 +89,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionConst) {
|
|||
auto* init = vec3<f32>(1.f, 1.f, 3.f);
|
||||
EXPECT_TRUE(td.DetermineResultType(init)) << td.error();
|
||||
|
||||
auto* v = Const("var", ast::StorageClass::kOutput, ty.f32, init,
|
||||
auto* v = Const("var", ast::StorageClass::kOutput, ty.f32(), init,
|
||||
ast::VariableDecorationList{});
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
||||
|
@ -112,7 +112,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionConst) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, IdentifierExpression_FunctionVar) {
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.f32);
|
||||
auto* v = Var("var", ast::StorageClass::kNone, ty.f32());
|
||||
td.RegisterVariableForTesting(v);
|
||||
|
||||
auto* expr = Expr("var");
|
||||
|
@ -138,7 +138,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionVar) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, IdentifierExpression_Load) {
|
||||
auto* var = Var("var", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* var = Var("var", ast::StorageClass::kPrivate, ty.i32());
|
||||
td.RegisterVariableForTesting(var);
|
||||
|
||||
auto* expr = Add("var", "var");
|
||||
|
@ -164,7 +164,7 @@ TEST_F(BuilderTest, IdentifierExpression_Load) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, IdentifierExpression_NoLoadConst) {
|
||||
auto* var = Const("var", ast::StorageClass::kNone, ty.i32, Expr(2),
|
||||
auto* var = Const("var", ast::StorageClass::kNone, ty.i32(), Expr(2),
|
||||
ast::VariableDecorationList{});
|
||||
td.RegisterVariableForTesting(var);
|
||||
|
||||
|
|
|
@ -94,7 +94,7 @@ TEST_F(BuilderTest, If_WithStatements) {
|
|||
// v = 2;
|
||||
// }
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32());
|
||||
auto* body = create<ast::BlockStatement>(
|
||||
ast::StatementList{create<ast::AssignmentStatement>(Expr("v"), Expr(2))});
|
||||
auto* expr =
|
||||
|
@ -134,7 +134,7 @@ TEST_F(BuilderTest, If_WithElse) {
|
|||
// v = 3;
|
||||
// }
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32());
|
||||
auto* body = create<ast::BlockStatement>(
|
||||
ast::StatementList{create<ast::AssignmentStatement>(Expr("v"), Expr(2))});
|
||||
auto* else_body = create<ast::BlockStatement>(
|
||||
|
@ -183,7 +183,7 @@ TEST_F(BuilderTest, If_WithElseIf) {
|
|||
// v = 3;
|
||||
// }
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32());
|
||||
auto* body = create<ast::BlockStatement>(
|
||||
ast::StatementList{create<ast::AssignmentStatement>(Expr("v"), Expr(2))});
|
||||
auto* else_body = create<ast::BlockStatement>(
|
||||
|
@ -243,7 +243,7 @@ TEST_F(BuilderTest, If_WithMultiple) {
|
|||
// v = 5;
|
||||
// }
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32());
|
||||
auto* body = create<ast::BlockStatement>(
|
||||
ast::StatementList{create<ast::AssignmentStatement>(Expr("v"), Expr(2))});
|
||||
auto* elseif_1_body = create<ast::BlockStatement>(
|
||||
|
@ -577,7 +577,7 @@ TEST_F(BuilderTest, If_WithLoad_Bug327) {
|
|||
// if (a) {
|
||||
// }
|
||||
|
||||
auto* var = Var("a", ast::StorageClass::kFunction, ty.bool_);
|
||||
auto* var = Var("a", ast::StorageClass::kFunction, ty.bool_());
|
||||
td.RegisterVariableForTesting(var);
|
||||
|
||||
auto* expr = create<ast::IfStatement>(
|
||||
|
|
|
@ -101,7 +101,7 @@ using IntrinsicFloatTest = IntrinsicBuilderTestWithParam<IntrinsicData>;
|
|||
TEST_P(IntrinsicFloatTest, Call_Float_Scalar) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.f32);
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.f32());
|
||||
auto* expr = Call(param.name, "v");
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
@ -160,7 +160,7 @@ using IntrinsicIntTest = IntrinsicBuilderTestWithParam<IntrinsicData>;
|
|||
TEST_P(IntrinsicIntTest, Call_SInt_Scalar) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32());
|
||||
auto* expr = Call(param.name, "v");
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
@ -211,7 +211,7 @@ TEST_P(IntrinsicIntTest, Call_SInt_Vector) {
|
|||
TEST_P(IntrinsicIntTest, Call_UInt_Scalar) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.u32);
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.u32());
|
||||
auto* expr = Call(param.name, "v");
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
@ -293,7 +293,7 @@ using IntrinsicDeriveTest = IntrinsicBuilderTestWithParam<IntrinsicData>;
|
|||
TEST_P(IntrinsicDeriveTest, Call_Derivative_Scalar) {
|
||||
auto param = GetParam();
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.f32);
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.f32());
|
||||
auto* expr = Call(param.name, "v");
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
@ -447,12 +447,12 @@ TEST_F(IntrinsicBuilderTest, Call_TextureSampleCompare_Twice) {
|
|||
}
|
||||
|
||||
TEST_F(IntrinsicBuilderTest, Call_GLSLMethod_WithLoad) {
|
||||
auto* var = Var("ident", ast::StorageClass::kPrivate, ty.f32);
|
||||
auto* var = Var("ident", ast::StorageClass::kPrivate, ty.f32());
|
||||
auto* expr = Call("round", "ident");
|
||||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -487,7 +487,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Float_Test, Call_Scalar) {
|
|||
auto* expr = Call(param.name, 1.0f);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -516,7 +516,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Float_Test, Call_Vector) {
|
|||
auto* expr = Call(param.name, vec2<f32>(1.0f, 1.0f));
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -571,7 +571,7 @@ TEST_F(IntrinsicBuilderTest, Call_Length_Scalar) {
|
|||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -597,7 +597,7 @@ TEST_F(IntrinsicBuilderTest, Call_Length_Vector) {
|
|||
auto* expr = Call("length", vec2<f32>(1.0f, 1.0f));
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -625,7 +625,7 @@ TEST_F(IntrinsicBuilderTest, Call_Normalize) {
|
|||
auto* expr = Call("normalize", vec2<f32>(1.0f, 1.0f));
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -658,7 +658,7 @@ TEST_P(Intrinsic_Builtin_DualParam_Float_Test, Call_Scalar) {
|
|||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -688,7 +688,7 @@ TEST_P(Intrinsic_Builtin_DualParam_Float_Test, Call_Vector) {
|
|||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -726,7 +726,7 @@ TEST_F(IntrinsicBuilderTest, Call_Distance_Scalar) {
|
|||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -753,7 +753,7 @@ TEST_F(IntrinsicBuilderTest, Call_Distance_Vector) {
|
|||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -783,7 +783,7 @@ TEST_F(IntrinsicBuilderTest, Call_Cross) {
|
|||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -815,7 +815,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Float_Test, Call_Scalar) {
|
|||
auto* expr = Call(param.name, 1.0f, 1.0f, 1.0f);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -846,7 +846,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Float_Test, Call_Vector) {
|
|||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -888,7 +888,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Sint_Test, Call_Scalar) {
|
|||
auto* expr = Call(param.name, 1);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -917,7 +917,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Sint_Test, Call_Vector) {
|
|||
auto* expr = Call(param.name, vec2<i32>(1, 1));
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -953,7 +953,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Uint_Test, Call_Scalar) {
|
|||
auto* expr = Call(param.name, 1u);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -982,7 +982,7 @@ TEST_P(Intrinsic_Builtin_SingleParam_Uint_Test, Call_Vector) {
|
|||
auto* expr = Call(param.name, vec2<u32>(1u, 1u));
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -1018,7 +1018,7 @@ TEST_P(Intrinsic_Builtin_DualParam_SInt_Test, Call_Scalar) {
|
|||
auto* expr = Call(param.name, 1, 1);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -1047,7 +1047,7 @@ TEST_P(Intrinsic_Builtin_DualParam_SInt_Test, Call_Vector) {
|
|||
auto* expr = Call(param.name, vec2<i32>(1, 1), vec2<i32>(1, 1));
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -1084,7 +1084,7 @@ TEST_P(Intrinsic_Builtin_DualParam_UInt_Test, Call_Scalar) {
|
|||
auto* expr = Call(param.name, 1u, 1u);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -1113,7 +1113,7 @@ TEST_P(Intrinsic_Builtin_DualParam_UInt_Test, Call_Vector) {
|
|||
auto* expr = Call(param.name, vec2<u32>(1u, 1u), vec2<u32>(1u, 1u));
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -1150,7 +1150,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Sint_Test, Call_Scalar) {
|
|||
auto* expr = Call(param.name, 1, 1, 1);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -1181,7 +1181,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Sint_Test, Call_Vector) {
|
|||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -1217,7 +1217,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Uint_Test, Call_Scalar) {
|
|||
auto* expr = Call(param.name, 1u, 1u, 1u);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -1248,7 +1248,7 @@ TEST_P(Intrinsic_Builtin_ThreeParam_Uint_Test, Call_Vector) {
|
|||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -1282,7 +1282,7 @@ TEST_F(IntrinsicBuilderTest, Call_Determinant) {
|
|||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -1322,7 +1322,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) {
|
|||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -1349,9 +1349,10 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength) {
|
|||
}
|
||||
|
||||
TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) {
|
||||
auto* s = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("z", ty.f32), Member("a", ty.array<f32>())},
|
||||
ast::StructDecorationList{});
|
||||
auto* s =
|
||||
create<ast::Struct>(ast::StructMemberList{Member("z", ty.f32()),
|
||||
Member("a", ty.array<f32>())},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s_type = ty.struct_("my_struct", s);
|
||||
auto* var = Var("b", ast::StorageClass::kPrivate, s_type);
|
||||
|
@ -1359,7 +1360,7 @@ TEST_F(IntrinsicBuilderTest, Call_ArrayLength_OtherMembersInStruct) {
|
|||
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("a_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{}, ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
|
|
@ -4157,7 +4157,7 @@ TEST_P(IntrinsicTextureTest, ValidateSPIRV) {
|
|||
create<ast::CallExpression>(Expr(param.function), param.args(this));
|
||||
|
||||
auto* main =
|
||||
Func("main", ast::VariableList{}, ty.void_,
|
||||
Func("main", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::CallStatement>(call),
|
||||
},
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace spirv {
|
|||
using BuilderTest = TestHelper;
|
||||
|
||||
TEST_F(BuilderTest, Literal_Bool_True) {
|
||||
auto* b_true = create<ast::BoolLiteral>(ty.bool_, true);
|
||||
auto* b_true = create<ast::BoolLiteral>(ty.bool_(), true);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -48,7 +48,7 @@ TEST_F(BuilderTest, Literal_Bool_True) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Literal_Bool_False) {
|
||||
auto* b_false = create<ast::BoolLiteral>(ty.bool_, false);
|
||||
auto* b_false = create<ast::BoolLiteral>(ty.bool_(), false);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -62,8 +62,8 @@ TEST_F(BuilderTest, Literal_Bool_False) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Literal_Bool_Dedup) {
|
||||
auto* b_true = create<ast::BoolLiteral>(ty.bool_, true);
|
||||
auto* b_false = create<ast::BoolLiteral>(ty.bool_, false);
|
||||
auto* b_true = create<ast::BoolLiteral>(ty.bool_(), true);
|
||||
auto* b_false = create<ast::BoolLiteral>(ty.bool_(), false);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -81,7 +81,7 @@ TEST_F(BuilderTest, Literal_Bool_Dedup) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Literal_I32) {
|
||||
auto* i = create<ast::SintLiteral>(ty.i32, -23);
|
||||
auto* i = create<ast::SintLiteral>(ty.i32(), -23);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -95,8 +95,8 @@ TEST_F(BuilderTest, Literal_I32) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Literal_I32_Dedup) {
|
||||
auto* i1 = create<ast::SintLiteral>(ty.i32, -23);
|
||||
auto* i2 = create<ast::SintLiteral>(ty.i32, -23);
|
||||
auto* i1 = create<ast::SintLiteral>(ty.i32(), -23);
|
||||
auto* i2 = create<ast::SintLiteral>(ty.i32(), -23);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -110,7 +110,7 @@ TEST_F(BuilderTest, Literal_I32_Dedup) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Literal_U32) {
|
||||
auto* i = create<ast::UintLiteral>(ty.u32, 23);
|
||||
auto* i = create<ast::UintLiteral>(ty.u32(), 23);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -124,8 +124,8 @@ TEST_F(BuilderTest, Literal_U32) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Literal_U32_Dedup) {
|
||||
auto* i1 = create<ast::UintLiteral>(ty.u32, 23);
|
||||
auto* i2 = create<ast::UintLiteral>(ty.u32, 23);
|
||||
auto* i1 = create<ast::UintLiteral>(ty.u32(), 23);
|
||||
auto* i2 = create<ast::UintLiteral>(ty.u32(), 23);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -139,7 +139,7 @@ TEST_F(BuilderTest, Literal_U32_Dedup) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Literal_F32) {
|
||||
auto* i = create<ast::FloatLiteral>(ty.f32, 23.245f);
|
||||
auto* i = create<ast::FloatLiteral>(ty.f32(), 23.245f);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -153,8 +153,8 @@ TEST_F(BuilderTest, Literal_F32) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Literal_F32_Dedup) {
|
||||
auto* i1 = create<ast::FloatLiteral>(ty.f32, 23.245f);
|
||||
auto* i2 = create<ast::FloatLiteral>(ty.f32, 23.245f);
|
||||
auto* i1 = create<ast::FloatLiteral>(ty.f32(), 23.245f);
|
||||
auto* i2 = create<ast::FloatLiteral>(ty.f32(), 23.245f);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@ TEST_F(BuilderTest, Loop_WithoutContinuing) {
|
|||
// v = 2;
|
||||
// }
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32());
|
||||
auto* body = create<ast::BlockStatement>(
|
||||
ast::StatementList{create<ast::AssignmentStatement>(Expr("v"), Expr(2))});
|
||||
|
||||
|
@ -112,7 +112,7 @@ TEST_F(BuilderTest, Loop_WithContinuing) {
|
|||
// }
|
||||
// }
|
||||
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* var = Var("v", ast::StorageClass::kPrivate, ty.i32());
|
||||
auto* body = create<ast::BlockStatement>(
|
||||
ast::StatementList{create<ast::AssignmentStatement>(Expr("v"), Expr(2))});
|
||||
auto* continuing = create<ast::BlockStatement>(
|
||||
|
|
|
@ -72,7 +72,7 @@ TEST_F(BuilderTest, Return_WithValue) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Return_WithValue_GeneratesLoad) {
|
||||
auto* var = Var("param", ast::StorageClass::kFunction, ty.f32);
|
||||
auto* var = Var("param", ast::StorageClass::kFunction, ty.f32());
|
||||
|
||||
auto* ret = create<ast::ReturnStatement>(Expr("param"));
|
||||
|
||||
|
|
|
@ -71,8 +71,8 @@ TEST_F(BuilderTest, Switch_WithCase) {
|
|||
// v = 2;
|
||||
// }
|
||||
|
||||
auto* v = Var("v", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* a = Var("a", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* v = Var("v", ast::StorageClass::kPrivate, ty.i32());
|
||||
auto* a = Var("a", ast::StorageClass::kPrivate, ty.i32());
|
||||
|
||||
auto* case_1_body = create<ast::BlockStatement>(
|
||||
ast::StatementList{create<ast::AssignmentStatement>(Expr("v"), Expr(1))});
|
||||
|
@ -96,7 +96,7 @@ TEST_F(BuilderTest, Switch_WithCase) {
|
|||
td.RegisterVariableForTesting(a);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", {}, ty.i32, ast::StatementList{},
|
||||
auto* func = Func("a_func", {}, ty.i32(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -143,8 +143,8 @@ TEST_F(BuilderTest, Switch_WithDefault) {
|
|||
// v = 1;
|
||||
// }
|
||||
|
||||
auto* v = Var("v", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* a = Var("a", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* v = Var("v", ast::StorageClass::kPrivate, ty.i32());
|
||||
auto* a = Var("a", ast::StorageClass::kPrivate, ty.i32());
|
||||
|
||||
auto* default_body = create<ast::BlockStatement>(
|
||||
ast::StatementList{create<ast::AssignmentStatement>(Expr("v"), Expr(1))});
|
||||
|
@ -159,7 +159,7 @@ TEST_F(BuilderTest, Switch_WithDefault) {
|
|||
td.RegisterVariableForTesting(a);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", {}, ty.i32, ast::StatementList{},
|
||||
auto* func = Func("a_func", {}, ty.i32(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -204,8 +204,8 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) {
|
|||
// v = 3;
|
||||
// }
|
||||
|
||||
auto* v = Var("v", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* a = Var("a", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* v = Var("v", ast::StorageClass::kPrivate, ty.i32());
|
||||
auto* a = Var("a", ast::StorageClass::kPrivate, ty.i32());
|
||||
|
||||
auto* case_1_body = create<ast::BlockStatement>(
|
||||
ast::StatementList{create<ast::AssignmentStatement>(Expr("v"), Expr(1))});
|
||||
|
@ -235,7 +235,7 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) {
|
|||
td.RegisterVariableForTesting(a);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", {}, ty.i32, ast::StatementList{},
|
||||
auto* func = Func("a_func", {}, ty.i32(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -289,8 +289,8 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) {
|
|||
// v = 3;
|
||||
// }
|
||||
|
||||
auto* v = Var("v", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* a = Var("a", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* v = Var("v", ast::StorageClass::kPrivate, ty.i32());
|
||||
auto* a = Var("a", ast::StorageClass::kPrivate, ty.i32());
|
||||
|
||||
auto* case_1_body = create<ast::BlockStatement>(
|
||||
ast::StatementList{create<ast::AssignmentStatement>(Expr("v"), Expr(1)),
|
||||
|
@ -320,7 +320,7 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) {
|
|||
td.RegisterVariableForTesting(a);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", {}, ty.i32, ast::StatementList{},
|
||||
auto* func = Func("a_func", {}, ty.i32(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -370,8 +370,8 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) {
|
|||
// fallthrough;
|
||||
// }
|
||||
|
||||
auto* v = Var("v", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* a = Var("a", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* v = Var("v", ast::StorageClass::kPrivate, ty.i32());
|
||||
auto* a = Var("a", ast::StorageClass::kPrivate, ty.i32());
|
||||
|
||||
auto* case_1_body = create<ast::BlockStatement>(
|
||||
ast::StatementList{create<ast::AssignmentStatement>(Expr("v"), Expr(1)),
|
||||
|
@ -389,7 +389,7 @@ TEST_F(BuilderTest, Switch_CaseFallthroughLastStatement) {
|
|||
td.RegisterVariableForTesting(a);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", {}, ty.i32, ast::StatementList{},
|
||||
auto* func = Func("a_func", {}, ty.i32(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
@ -411,8 +411,8 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) {
|
|||
// v = 1;
|
||||
// }
|
||||
|
||||
auto* v = Var("v", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* a = Var("a", ast::StorageClass::kPrivate, ty.i32);
|
||||
auto* v = Var("v", ast::StorageClass::kPrivate, ty.i32());
|
||||
auto* a = Var("a", ast::StorageClass::kPrivate, ty.i32());
|
||||
|
||||
auto* if_body = create<ast::BlockStatement>(ast::StatementList{
|
||||
create<ast::BreakStatement>(),
|
||||
|
@ -434,7 +434,7 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) {
|
|||
td.RegisterVariableForTesting(a);
|
||||
ASSERT_TRUE(td.DetermineResultType(expr)) << td.error();
|
||||
|
||||
auto* func = Func("a_func", {}, ty.i32, ast::StatementList{},
|
||||
auto* func = Func("a_func", {}, ty.i32(), ast::StatementList{},
|
||||
ast::FunctionDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
|
|
@ -52,7 +52,7 @@ namespace {
|
|||
using BuilderTest_Type = TestHelper;
|
||||
|
||||
TEST_F(BuilderTest_Type, GenerateAlias) {
|
||||
auto* alias_type = ty.alias("my_type", ty.f32);
|
||||
auto* alias_type = ty.alias("my_type", ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -66,22 +66,22 @@ TEST_F(BuilderTest_Type, GenerateAlias) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, ReturnsGeneratedAlias) {
|
||||
auto* alias_type = ty.alias("my_type", ty.f32);
|
||||
auto* alias_type = ty.alias("my_type", ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(alias_type), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32), 2u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32()), 2u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(alias_type), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.f32), 1u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.f32()), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, GenerateRuntimeArray) {
|
||||
type::Array ary(ty.i32, 0, ast::ArrayDecorationList{});
|
||||
type::Array ary(ty.i32(), 0, ast::ArrayDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -95,7 +95,7 @@ TEST_F(BuilderTest_Type, GenerateRuntimeArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) {
|
||||
type::Array ary(ty.i32, 0, ast::ArrayDecorationList{});
|
||||
type::Array ary(ty.i32(), 0, ast::ArrayDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -109,7 +109,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, GenerateArray) {
|
||||
type::Array ary(ty.i32, 4, ast::ArrayDecorationList{});
|
||||
type::Array ary(ty.i32(), 4, ast::ArrayDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -125,7 +125,7 @@ TEST_F(BuilderTest_Type, GenerateArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, GenerateArray_WithStride) {
|
||||
type::Array ary(ty.i32, 4,
|
||||
type::Array ary(ty.i32(), 4,
|
||||
ast::ArrayDecorationList{
|
||||
create<ast::StrideDecoration>(16u),
|
||||
});
|
||||
|
@ -147,7 +147,7 @@ TEST_F(BuilderTest_Type, GenerateArray_WithStride) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, ReturnsGeneratedArray) {
|
||||
type::Array ary(ty.i32, 4, ast::ArrayDecorationList{});
|
||||
type::Array ary(ty.i32(), 4, ast::ArrayDecorationList{});
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -165,7 +165,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedArray) {
|
|||
TEST_F(BuilderTest_Type, GenerateBool) {
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
auto id = b.GenerateTypeIfNeeded(ty.bool_);
|
||||
auto id = b.GenerateTypeIfNeeded(ty.bool_());
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(id, 1u);
|
||||
|
||||
|
@ -177,18 +177,18 @@ TEST_F(BuilderTest_Type, GenerateBool) {
|
|||
TEST_F(BuilderTest_Type, ReturnsGeneratedBool) {
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.bool_), 1u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.bool_()), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32), 2u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32()), 2u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.bool_), 1u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.bool_()), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, GenerateF32) {
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
auto id = b.GenerateTypeIfNeeded(ty.f32);
|
||||
auto id = b.GenerateTypeIfNeeded(ty.f32());
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(id, 1u);
|
||||
|
||||
|
@ -200,18 +200,18 @@ TEST_F(BuilderTest_Type, GenerateF32) {
|
|||
TEST_F(BuilderTest_Type, ReturnsGeneratedF32) {
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.f32), 1u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.f32()), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32), 2u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32()), 2u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.f32), 1u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.f32()), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, GenerateI32) {
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
auto id = b.GenerateTypeIfNeeded(ty.i32);
|
||||
auto id = b.GenerateTypeIfNeeded(ty.i32());
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(id, 1u);
|
||||
|
||||
|
@ -223,11 +223,11 @@ TEST_F(BuilderTest_Type, GenerateI32) {
|
|||
TEST_F(BuilderTest_Type, ReturnsGeneratedI32) {
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32), 1u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32()), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.f32), 2u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.f32()), 2u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32), 1u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32()), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
}
|
||||
|
||||
|
@ -252,14 +252,14 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedMatrix) {
|
|||
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(mat), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32), 3u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32()), 3u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(mat), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, GeneratePtr) {
|
||||
type::Pointer ptr(ty.i32, ast::StorageClass::kOutput);
|
||||
type::Pointer ptr(ty.i32(), ast::StorageClass::kOutput);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -273,7 +273,7 @@ TEST_F(BuilderTest_Type, GeneratePtr) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, ReturnsGeneratedPtr) {
|
||||
type::Pointer ptr(ty.i32, ast::StorageClass::kOutput);
|
||||
type::Pointer ptr(ty.i32(), ast::StorageClass::kOutput);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -300,7 +300,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_Empty) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, GenerateStruct) {
|
||||
auto* s = create<ast::Struct>(ast::StructMemberList{Member("a", ty.f32)},
|
||||
auto* s = create<ast::Struct>(ast::StructMemberList{Member("a", ty.f32())},
|
||||
ast::StructDecorationList{});
|
||||
auto* s_type = ty.struct_("my_struct", s);
|
||||
|
||||
|
@ -322,7 +322,7 @@ TEST_F(BuilderTest_Type, GenerateStruct_Decorated) {
|
|||
ast::StructDecorationList struct_decos;
|
||||
struct_decos.push_back(create<ast::StructBlockDecoration>());
|
||||
|
||||
auto* s = create<ast::Struct>(ast::StructMemberList{Member("a", ty.f32)},
|
||||
auto* s = create<ast::Struct>(ast::StructMemberList{Member("a", ty.f32())},
|
||||
struct_decos);
|
||||
auto* s_type = ty.struct_("my_struct", s);
|
||||
|
||||
|
@ -344,8 +344,8 @@ OpMemberName %1 0 "a"
|
|||
|
||||
TEST_F(BuilderTest_Type, GenerateStruct_DecoratedMembers) {
|
||||
auto* s = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.f32, {MemberOffset(0)}),
|
||||
Member("b", ty.f32, {MemberOffset(8)})},
|
||||
ast::StructMemberList{Member("a", ty.f32(), {MemberOffset(0)}),
|
||||
Member("b", ty.f32(), {MemberOffset(8)})},
|
||||
ast::StructDecorationList{});
|
||||
auto* s_type = ty.struct_("S", s);
|
||||
|
||||
|
@ -500,7 +500,7 @@ OpMemberDecorate %1 2 MatrixStride 16
|
|||
TEST_F(BuilderTest_Type, GenerateU32) {
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
auto id = b.GenerateTypeIfNeeded(ty.u32);
|
||||
auto id = b.GenerateTypeIfNeeded(ty.u32());
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(id, 1u);
|
||||
|
||||
|
@ -512,11 +512,11 @@ TEST_F(BuilderTest_Type, GenerateU32) {
|
|||
TEST_F(BuilderTest_Type, ReturnsGeneratedU32) {
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.u32), 1u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.u32()), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.f32), 2u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.f32()), 2u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.u32), 1u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.u32()), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
}
|
||||
|
||||
|
@ -540,7 +540,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedVector) {
|
|||
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(vec_type), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32), 2u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32()), 2u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(vec_type), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
|
@ -549,7 +549,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedVector) {
|
|||
TEST_F(BuilderTest_Type, GenerateVoid) {
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
auto id = b.GenerateTypeIfNeeded(ty.void_);
|
||||
auto id = b.GenerateTypeIfNeeded(ty.void_());
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(id, 1u);
|
||||
|
||||
|
@ -561,11 +561,11 @@ TEST_F(BuilderTest_Type, GenerateVoid) {
|
|||
TEST_F(BuilderTest_Type, ReturnsGeneratedVoid) {
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.void_), 1u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.void_()), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32), 2u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.i32()), 2u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.void_), 1u);
|
||||
EXPECT_EQ(b.GenerateTypeIfNeeded(ty.void_()), 1u);
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
}
|
||||
|
||||
|
@ -662,7 +662,7 @@ TEST_F(BuilderTest_Type, DepthTexture_Generate_CubeArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
|
||||
type::MultisampledTexture ms(type::TextureDimension::k2d, ty.i32);
|
||||
type::MultisampledTexture ms(type::TextureDimension::k2d, ty.i32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -674,7 +674,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_i32) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
|
||||
type::MultisampledTexture ms(type::TextureDimension::k2d, ty.u32);
|
||||
type::MultisampledTexture ms(type::TextureDimension::k2d, ty.u32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -687,7 +687,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_u32) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
|
||||
type::MultisampledTexture ms(type::TextureDimension::k2d, ty.f32);
|
||||
type::MultisampledTexture ms(type::TextureDimension::k2d, ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -700,7 +700,7 @@ TEST_F(BuilderTest_Type, MultisampledTexture_Generate_2d_f32) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
|
||||
type::SampledTexture s(type::TextureDimension::k1d, ty.i32);
|
||||
type::SampledTexture s(type::TextureDimension::k1d, ty.i32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -717,7 +717,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_i32) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
|
||||
type::SampledTexture s(type::TextureDimension::k1d, ty.u32);
|
||||
type::SampledTexture s(type::TextureDimension::k1d, ty.u32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -734,7 +734,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_u32) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
|
||||
type::SampledTexture s(type::TextureDimension::k1d, ty.f32);
|
||||
type::SampledTexture s(type::TextureDimension::k1d, ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -751,7 +751,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1d_f32) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_1dArray) {
|
||||
type::SampledTexture s(type::TextureDimension::k1dArray, ty.f32);
|
||||
type::SampledTexture s(type::TextureDimension::k1dArray, ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -768,7 +768,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_1dArray) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
|
||||
type::SampledTexture s(type::TextureDimension::k2d, ty.f32);
|
||||
type::SampledTexture s(type::TextureDimension::k2d, ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -781,7 +781,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
|
||||
type::SampledTexture s(type::TextureDimension::k2dArray, ty.f32);
|
||||
type::SampledTexture s(type::TextureDimension::k2dArray, ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -794,7 +794,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_2d_array) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
|
||||
type::SampledTexture s(type::TextureDimension::k3d, ty.f32);
|
||||
type::SampledTexture s(type::TextureDimension::k3d, ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -807,7 +807,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_3d) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
|
||||
type::SampledTexture s(type::TextureDimension::kCube, ty.f32);
|
||||
type::SampledTexture s(type::TextureDimension::kCube, ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -821,7 +821,7 @@ TEST_F(BuilderTest_Type, SampledTexture_Generate_Cube) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest_Type, SampledTexture_Generate_CubeArray) {
|
||||
type::SampledTexture s(type::TextureDimension::kCubeArray, ty.f32);
|
||||
type::SampledTexture s(type::TextureDimension::kCubeArray, ty.f32());
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace {
|
|||
using WgslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitAlias_F32) {
|
||||
auto* alias = ty.alias("a", ty.f32);
|
||||
auto* alias = ty.alias("a", ty.f32());
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitConstructedType(alias)) << gen.error();
|
||||
|
@ -38,8 +38,8 @@ TEST_F(WgslGeneratorImplTest, EmitAlias_F32) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitConstructedType_Struct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.f32),
|
||||
Member("b", ty.i32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.f32()),
|
||||
Member("b", ty.i32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("A", str);
|
||||
|
@ -60,8 +60,8 @@ type B = A;
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitAlias_ToStruct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.f32),
|
||||
Member("b", ty.i32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.f32()),
|
||||
Member("b", ty.i32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("A", str);
|
||||
|
|
|
@ -30,7 +30,7 @@ using WgslGeneratorImplTest = TestHelper;
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitExpression_Bitcast) {
|
||||
auto* id = Expr("id");
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32, id);
|
||||
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), id);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Case) {
|
|||
create<ast::BreakStatement>(),
|
||||
});
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32(), 5));
|
||||
auto* c = create<ast::CaseStatement>(lit, body);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -54,8 +54,8 @@ TEST_F(WgslGeneratorImplTest, Emit_Case_MultipleSelectors) {
|
|||
create<ast::BreakStatement>(),
|
||||
});
|
||||
ast::CaseSelectorList lit;
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32, 5));
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32, 6));
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32(), 5));
|
||||
lit.push_back(create<ast::SintLiteral>(ty.i32(), 6));
|
||||
auto* c = create<ast::CaseStatement>(lit, body);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
|
|
@ -41,7 +41,7 @@ namespace {
|
|||
using WgslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_Function) {
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::DiscardStatement>(),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -63,9 +63,9 @@ TEST_F(WgslGeneratorImplTest, Emit_Function) {
|
|||
TEST_F(WgslGeneratorImplTest, Emit_Function_WithParams) {
|
||||
auto* func =
|
||||
Func("my_func",
|
||||
ast::VariableList{Var("a", ast::StorageClass::kNone, ty.f32),
|
||||
Var("b", ast::StorageClass::kNone, ty.i32)},
|
||||
ty.void_,
|
||||
ast::VariableList{Var("a", ast::StorageClass::kNone, ty.f32()),
|
||||
Var("b", ast::StorageClass::kNone, ty.i32())},
|
||||
ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::DiscardStatement>(),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -85,7 +85,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithParams) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_WorkgroupSize) {
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_,
|
||||
auto* func = Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::DiscardStatement>(),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -109,7 +109,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_WorkgroupSize) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_Stage) {
|
||||
auto* func =
|
||||
Func("my_func", ast::VariableList{}, ty.void_,
|
||||
Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::DiscardStatement>(),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -133,7 +133,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_Stage) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_Function_WithDecoration_Multiple) {
|
||||
auto* func =
|
||||
Func("my_func", ast::VariableList{}, ty.void_,
|
||||
Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::DiscardStatement>(),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -179,7 +179,7 @@ TEST_F(WgslGeneratorImplTest,
|
|||
s_decos.push_back(create<ast::StructBlockDecoration>());
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("d", ty.f32, {MemberOffset(0)})}, s_decos);
|
||||
ast::StructMemberList{Member("d", ty.f32(), {MemberOffset(0)})}, s_decos);
|
||||
|
||||
auto* s = ty.struct_("Data", str);
|
||||
type::AccessControl ac(ast::AccessControl::kReadWrite, s);
|
||||
|
@ -198,12 +198,12 @@ TEST_F(WgslGeneratorImplTest,
|
|||
|
||||
{
|
||||
auto* var =
|
||||
Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
create<ast::MemberAccessorExpression>(Expr("data"), Expr("d")),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("a", ast::VariableList{}, ty.void_,
|
||||
Func("a", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
@ -217,12 +217,12 @@ TEST_F(WgslGeneratorImplTest,
|
|||
|
||||
{
|
||||
auto* var =
|
||||
Var("v", ast::StorageClass::kFunction, ty.f32,
|
||||
Var("v", ast::StorageClass::kFunction, ty.f32(),
|
||||
create<ast::MemberAccessorExpression>(Expr("data"), Expr("d")),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
auto* func =
|
||||
Func("b", ast::VariableList{}, ty.void_,
|
||||
Func("b", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{
|
||||
create<ast::VariableDeclStatement>(var),
|
||||
create<ast::ReturnStatement>(),
|
||||
|
|
|
@ -38,7 +38,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Switch) {
|
|||
auto* def = create<ast::CaseStatement>(ast::CaseSelectorList{}, def_body);
|
||||
|
||||
ast::CaseSelectorList case_val;
|
||||
case_val.push_back(create<ast::SintLiteral>(ty.i32, 5));
|
||||
case_val.push_back(create<ast::SintLiteral>(ty.i32(), 5));
|
||||
|
||||
auto* case_body = create<ast::BlockStatement>(ast::StatementList{
|
||||
create<ast::BreakStatement>(),
|
||||
|
|
|
@ -30,7 +30,7 @@ namespace {
|
|||
using WgslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Generate) {
|
||||
mod->AST().Functions().Add(Func("my_func", ast::VariableList{}, ty.void_,
|
||||
mod->AST().Functions().Add(Func("my_func", ast::VariableList{}, ty.void_(),
|
||||
ast::StatementList{},
|
||||
ast::FunctionDecorationList{}));
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace {
|
|||
using WgslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Alias) {
|
||||
auto* alias = ty.alias("alias", ty.f32);
|
||||
auto* alias = ty.alias("alias", ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -69,7 +69,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_Read) {
|
|||
decos.push_back(block_deco);
|
||||
|
||||
auto* str =
|
||||
create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32)}, decos);
|
||||
create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32())}, decos);
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
||||
type::AccessControl a(ast::AccessControl::kReadOnly, s);
|
||||
|
@ -86,7 +86,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_ReadWrite) {
|
|||
decos.push_back(block_deco);
|
||||
|
||||
auto* str =
|
||||
create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32)}, decos);
|
||||
create<ast::Struct>(ast::StructMemberList{Member("a", ty.i32())}, decos);
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
||||
type::AccessControl a(ast::AccessControl::kReadWrite, s);
|
||||
|
@ -98,7 +98,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_AccessControl_ReadWrite) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) {
|
||||
type::Array a(ty.bool_, 4,
|
||||
type::Array a(ty.bool_(), 4,
|
||||
ast::ArrayDecorationList{
|
||||
create<ast::StrideDecoration>(16u),
|
||||
});
|
||||
|
@ -110,7 +110,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array_Decoration) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) {
|
||||
type::Array a(ty.bool_, 4,
|
||||
type::Array a(ty.bool_(), 4,
|
||||
ast::ArrayDecorationList{
|
||||
create<ast::StrideDecoration>(16u),
|
||||
create<ast::StrideDecoration>(32u),
|
||||
|
@ -123,7 +123,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Array_MultipleDecorations) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) {
|
||||
type::Array a(ty.bool_, 0, ast::ArrayDecorationList{});
|
||||
type::Array a(ty.bool_(), 0, ast::ArrayDecorationList{});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -134,21 +134,21 @@ TEST_F(WgslGeneratorImplTest, EmitType_RuntimeArray) {
|
|||
TEST_F(WgslGeneratorImplTest, EmitType_Bool) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(ty.bool_)) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(ty.bool_())) << gen.error();
|
||||
EXPECT_EQ(gen.result(), "bool");
|
||||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_F32) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(ty.f32)) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(ty.f32())) << gen.error();
|
||||
EXPECT_EQ(gen.result(), "f32");
|
||||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_I32) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(ty.i32)) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(ty.i32())) << gen.error();
|
||||
EXPECT_EQ(gen.result(), "i32");
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Matrix) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Pointer) {
|
||||
type::Pointer p(ty.f32, ast::StorageClass::kWorkgroup);
|
||||
type::Pointer p(ty.f32(), ast::StorageClass::kWorkgroup);
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -170,8 +170,8 @@ TEST_F(WgslGeneratorImplTest, EmitType_Pointer) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_Struct) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32()),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
@ -183,8 +183,8 @@ TEST_F(WgslGeneratorImplTest, EmitType_Struct) {
|
|||
|
||||
TEST_F(WgslGeneratorImplTest, EmitType_StructDecl) {
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32()),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
ast::StructDecorationList{});
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
@ -204,8 +204,8 @@ TEST_F(WgslGeneratorImplTest, EmitType_Struct_WithDecoration) {
|
|||
decos.push_back(create<ast::StructBlockDecoration>());
|
||||
|
||||
auto* str = create<ast::Struct>(
|
||||
ast::StructMemberList{Member("a", ty.i32),
|
||||
Member("b", ty.f32, {MemberOffset(4)})},
|
||||
ast::StructMemberList{Member("a", ty.i32()),
|
||||
Member("b", ty.f32(), {MemberOffset(4)})},
|
||||
decos);
|
||||
|
||||
auto* s = ty.struct_("S", str);
|
||||
|
@ -224,7 +224,7 @@ struct S {
|
|||
TEST_F(WgslGeneratorImplTest, EmitType_U32) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(ty.u32)) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(ty.u32())) << gen.error();
|
||||
EXPECT_EQ(gen.result(), "u32");
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ TEST_F(WgslGeneratorImplTest, EmitType_Vector) {
|
|||
TEST_F(WgslGeneratorImplTest, EmitType_Void) {
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
ASSERT_TRUE(gen.EmitType(ty.void_)) << gen.error();
|
||||
ASSERT_TRUE(gen.EmitType(ty.void_())) << gen.error();
|
||||
EXPECT_EQ(gen.result(), "void");
|
||||
}
|
||||
|
||||
|
@ -276,7 +276,7 @@ using WgslGenerator_SampledTextureTest = TestParamHelper<TextureData>;
|
|||
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_F32) {
|
||||
auto param = GetParam();
|
||||
|
||||
type::SampledTexture t(param.dim, ty.f32);
|
||||
type::SampledTexture t(param.dim, ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -287,7 +287,7 @@ TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_F32) {
|
|||
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_I32) {
|
||||
auto param = GetParam();
|
||||
|
||||
type::SampledTexture t(param.dim, ty.i32);
|
||||
type::SampledTexture t(param.dim, ty.i32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -298,7 +298,7 @@ TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_I32) {
|
|||
TEST_P(WgslGenerator_SampledTextureTest, EmitType_SampledTexture_U32) {
|
||||
auto param = GetParam();
|
||||
|
||||
type::SampledTexture t(param.dim, ty.u32);
|
||||
type::SampledTexture t(param.dim, ty.u32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -321,7 +321,7 @@ using WgslGenerator_MultiampledTextureTest = TestParamHelper<TextureData>;
|
|||
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) {
|
||||
auto param = GetParam();
|
||||
|
||||
type::MultisampledTexture t(param.dim, ty.f32);
|
||||
type::MultisampledTexture t(param.dim, ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -332,7 +332,7 @@ TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_F32) {
|
|||
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_I32) {
|
||||
auto param = GetParam();
|
||||
|
||||
type::MultisampledTexture t(param.dim, ty.i32);
|
||||
type::MultisampledTexture t(param.dim, ty.i32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -343,7 +343,7 @@ TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_I32) {
|
|||
TEST_P(WgslGenerator_MultiampledTextureTest, EmitType_MultisampledTexture_U32) {
|
||||
auto param = GetParam();
|
||||
|
||||
type::MultisampledTexture t(param.dim, ty.u32);
|
||||
type::MultisampledTexture t(param.dim, ty.u32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace {
|
|||
using WgslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement) {
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32);
|
||||
auto* var = Var("a", ast::StorageClass::kNone, ty.f32());
|
||||
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
|
@ -48,7 +48,7 @@ TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Function) {
|
|||
// storage class. Rely on defaulting.
|
||||
// https://github.com/gpuweb/gpuweb/issues/654
|
||||
|
||||
auto* var = Var("a", ast::StorageClass::kFunction, ty.f32);
|
||||
auto* var = Var("a", ast::StorageClass::kFunction, ty.f32());
|
||||
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
|
@ -61,7 +61,7 @@ TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Function) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_VariableDeclStatement_Private) {
|
||||
auto* var = Var("a", ast::StorageClass::kPrivate, ty.f32);
|
||||
auto* var = Var("a", ast::StorageClass::kPrivate, ty.f32());
|
||||
|
||||
auto* stmt = create<ast::VariableDeclStatement>(var);
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ namespace {
|
|||
using WgslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitVariable) {
|
||||
auto* v = Var("a", ast::StorageClass::kNone, ty.f32);
|
||||
auto* v = Var("a", ast::StorageClass::kNone, ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -44,7 +44,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitVariable_StorageClass) {
|
||||
auto* v = Var("a", ast::StorageClass::kInput, ty.f32);
|
||||
auto* v = Var("a", ast::StorageClass::kInput, ty.f32());
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
@ -54,7 +54,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_StorageClass) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) {
|
||||
auto* v = Var("a", ast::StorageClass::kNone, ty.f32, nullptr,
|
||||
auto* v = Var("a", ast::StorageClass::kNone, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::LocationDecoration>(2),
|
||||
});
|
||||
|
@ -67,7 +67,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) {
|
||||
auto* v = Var("a", ast::StorageClass::kNone, ty.f32, nullptr,
|
||||
auto* v = Var("a", ast::StorageClass::kNone, ty.f32(), nullptr,
|
||||
ast::VariableDecorationList{
|
||||
create<ast::BuiltinDecoration>(ast::Builtin::kPosition),
|
||||
create<ast::BindingDecoration>(0),
|
||||
|
@ -86,7 +86,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated_Multiple) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) {
|
||||
auto* v = Var("a", ast::StorageClass::kNone, ty.f32, Expr("initializer"),
|
||||
auto* v = Var("a", ast::StorageClass::kNone, ty.f32(), Expr("initializer"),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
@ -97,7 +97,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, EmitVariable_Const) {
|
||||
auto* v = Const("a", ast::StorageClass::kNone, ty.f32, Expr("initializer"),
|
||||
auto* v = Const("a", ast::StorageClass::kNone, ty.f32(), Expr("initializer"),
|
||||
ast::VariableDecorationList{});
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
|
Loading…
Reference in New Issue