tint: Rename GlobalConst() -> GlobalLet()
GlobalConst() is going to mean a module-scope `const`, once we support `const`. `GlobalLet()` will then be removed. Bug: tint:1580 Change-Id: Ie00e9ccdee8c111266850bfe1e1e24f022a59a06 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94603 Commit-Queue: Ben Clayton <bclayton@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Reviewed-by: David Neto <dneto@google.com>
This commit is contained in:
parent
bd8449f37d
commit
41486e1135
|
@ -1466,7 +1466,7 @@ class ProgramBuilder {
|
|||
/// @returns an `ast::Let` constructed by calling Let() with the arguments of `args`, which is
|
||||
/// automatically registered as a global variable with the ast::Module.
|
||||
template <typename NAME>
|
||||
const ast::Let* GlobalConst(NAME&& name,
|
||||
const ast::Let* GlobalLet(NAME&& name,
|
||||
const ast::Type* type,
|
||||
const ast::Expression* constructor,
|
||||
ast::AttributeList attributes = {}) {
|
||||
|
@ -1484,7 +1484,7 @@ class ProgramBuilder {
|
|||
/// arguments of `args`, which is automatically registered as a global
|
||||
/// variable with the ast::Module.
|
||||
template <typename NAME>
|
||||
const ast::Let* GlobalConst(const Source& source,
|
||||
const ast::Let* GlobalLet(const Source& source,
|
||||
NAME&& name,
|
||||
const ast::Type* type,
|
||||
const ast::Expression* constructor,
|
||||
|
|
|
@ -65,7 +65,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions_Dynamic_Ref) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic) {
|
||||
GlobalConst("my_const", ty.mat2x3<f32>(), Construct(ty.mat2x3<f32>()));
|
||||
GlobalLet("my_const", ty.mat2x3<f32>(), Construct(ty.mat2x3<f32>()));
|
||||
auto* idx = Var("idx", ty.i32(), Construct(ty.i32()));
|
||||
auto* acc = IndexAccessor("my_const", Expr(Source{{12, 34}}, idx));
|
||||
WrapInFunction(Decl(idx), acc);
|
||||
|
@ -80,7 +80,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Matrix_XDimension_Dynamic) {
|
||||
GlobalConst("my_var", ty.mat4x4<f32>(), Construct(ty.mat4x4<f32>()));
|
||||
GlobalLet("my_var", ty.mat4x4<f32>(), Construct(ty.mat4x4<f32>()));
|
||||
auto* idx = Var("idx", ty.u32(), Expr(3_u));
|
||||
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, idx));
|
||||
WrapInFunction(Decl(idx), acc);
|
||||
|
@ -95,7 +95,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_XDimension_Dynamic) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Matrix_BothDimension_Dynamic) {
|
||||
GlobalConst("my_var", ty.mat4x4<f32>(), Construct(ty.mat4x4<f32>()));
|
||||
GlobalLet("my_var", ty.mat4x4<f32>(), Construct(ty.mat4x4<f32>()));
|
||||
auto* idx = Var("idy", ty.u32(), Expr(2_u));
|
||||
auto* acc = IndexAccessor(IndexAccessor("my_var", Expr(Source{{12, 34}}, idx)), 1_i);
|
||||
WrapInFunction(Decl(idx), acc);
|
||||
|
@ -174,7 +174,7 @@ TEST_F(ResolverIndexAccessorTest, Vector_Dynamic_Ref) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Vector_Dynamic) {
|
||||
GlobalConst("my_var", ty.vec3<f32>(), Construct(ty.vec3<f32>()));
|
||||
GlobalLet("my_var", ty.vec3<f32>(), Construct(ty.vec3<f32>()));
|
||||
auto* idx = Var("idx", ty.i32(), Expr(2_i));
|
||||
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, idx));
|
||||
WrapInFunction(Decl(idx), acc);
|
||||
|
@ -278,7 +278,7 @@ TEST_F(ResolverIndexAccessorTest, Alias_Array) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverIndexAccessorTest, Array_Constant) {
|
||||
GlobalConst("my_var", ty.array<f32, 3>(), array<f32, 3>());
|
||||
GlobalLet("my_var", ty.array<f32, 3>(), array<f32, 3>());
|
||||
|
||||
auto* acc = IndexAccessor("my_var", 2_i);
|
||||
WrapInFunction(acc);
|
||||
|
|
|
@ -68,7 +68,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignArraysWithDifferentSizeExpression
|
|||
// a = b;
|
||||
// }
|
||||
|
||||
GlobalConst("len", nullptr, Expr(4_u));
|
||||
GlobalLet("len", nullptr, Expr(4_u));
|
||||
|
||||
auto* a = Var("a", ty.array(ty.f32(), 4_u));
|
||||
auto* b = Var("b", ty.array(ty.f32(), "len"));
|
||||
|
@ -87,7 +87,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignArraysWithDifferentSizeExpression
|
|||
// a = b;
|
||||
// }
|
||||
|
||||
GlobalConst("len", nullptr, Expr(5_u));
|
||||
GlobalLet("len", nullptr, Expr(5_u));
|
||||
|
||||
auto* a = Var("a", ty.array(ty.f32(), 4_u));
|
||||
auto* b = Var("b", ty.array(ty.f32(), "len"));
|
||||
|
|
|
@ -774,7 +774,7 @@ using ConstantAttributeTest = TestWithParams;
|
|||
TEST_P(ConstantAttributeTest, IsValid) {
|
||||
auto& params = GetParam();
|
||||
|
||||
GlobalConst("a", ty.f32(), Expr(1.23_f),
|
||||
GlobalLet("a", ty.f32(), Expr(1.23_f),
|
||||
createAttributes(Source{{12, 34}}, *this, params.kind));
|
||||
|
||||
WrapInFunction();
|
||||
|
@ -805,7 +805,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
|
|||
TestParams{AttributeKind::kBindingAndGroup, false}));
|
||||
|
||||
TEST_F(ConstantAttributeTest, DuplicateAttribute) {
|
||||
GlobalConst("a", ty.f32(), Expr(1.23_f),
|
||||
GlobalLet("a", ty.f32(), Expr(1.23_f),
|
||||
ast::AttributeList{
|
||||
create<ast::IdAttribute>(Source{{12, 34}}, 0),
|
||||
create<ast::IdAttribute>(Source{{56, 78}}, 1),
|
||||
|
@ -852,7 +852,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
|
|||
TestParams{AttributeKind::kBindingAndGroup, false}));
|
||||
|
||||
TEST_F(OverrideAttributeTest, DuplicateAttribute) {
|
||||
GlobalConst("a", ty.f32(), Expr(1.23_f),
|
||||
GlobalLet("a", ty.f32(), Expr(1.23_f),
|
||||
ast::AttributeList{
|
||||
create<ast::IdAttribute>(Source{{12, 34}}, 0),
|
||||
create<ast::IdAttribute>(Source{{56, 78}}, 1),
|
||||
|
|
|
@ -86,7 +86,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsFunction) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalLet) {
|
||||
GlobalConst(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i));
|
||||
GlobalLet(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
|
@ -97,7 +97,8 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalVar) {
|
|||
Global(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
EXPECT_EQ(
|
||||
r()->error(),
|
||||
R"(12:34 error: 'mix' is a builtin and cannot be redeclared as a module-scope 'var')");
|
||||
}
|
||||
|
||||
|
@ -266,7 +267,7 @@ TEST_P(BuiltinTextureConstExprArgValidationTest, Immediate) {
|
|||
}
|
||||
}
|
||||
|
||||
TEST_P(BuiltinTextureConstExprArgValidationTest, GlobalConst) {
|
||||
TEST_P(BuiltinTextureConstExprArgValidationTest, GlobalLet) {
|
||||
auto& p = GetParam();
|
||||
auto overload = std::get<0>(p);
|
||||
auto param = std::get<1>(p);
|
||||
|
@ -277,7 +278,7 @@ TEST_P(BuiltinTextureConstExprArgValidationTest, GlobalConst) {
|
|||
overload.BuildSamplerVariable(this);
|
||||
|
||||
// Build the module-scope let 'G' with the offset value
|
||||
GlobalConst("G", nullptr, expr({}, *this));
|
||||
GlobalLet("G", nullptr, expr({}, *this));
|
||||
|
||||
auto args = overload.args(this);
|
||||
auto*& arg_to_replace = (param.position == Position::kFirst) ? args.front() : args.back();
|
||||
|
|
|
@ -54,7 +54,7 @@ using ResolverDependencyGraphTest = ResolverDependencyGraphTestWithParam<::testi
|
|||
/// kinds of symbol declarations.
|
||||
enum class SymbolDeclKind {
|
||||
GlobalVar,
|
||||
GlobalConst,
|
||||
GlobalLet,
|
||||
Alias,
|
||||
Struct,
|
||||
Function,
|
||||
|
@ -66,7 +66,7 @@ enum class SymbolDeclKind {
|
|||
};
|
||||
|
||||
static constexpr SymbolDeclKind kAllSymbolDeclKinds[] = {
|
||||
SymbolDeclKind::GlobalVar, SymbolDeclKind::GlobalConst, SymbolDeclKind::Alias,
|
||||
SymbolDeclKind::GlobalVar, SymbolDeclKind::GlobalLet, SymbolDeclKind::Alias,
|
||||
SymbolDeclKind::Struct, SymbolDeclKind::Function, SymbolDeclKind::Parameter,
|
||||
SymbolDeclKind::LocalVar, SymbolDeclKind::LocalLet, SymbolDeclKind::NestedLocalVar,
|
||||
SymbolDeclKind::NestedLocalLet,
|
||||
|
@ -78,13 +78,13 @@ static constexpr SymbolDeclKind kTypeDeclKinds[] = {
|
|||
};
|
||||
|
||||
static constexpr SymbolDeclKind kValueDeclKinds[] = {
|
||||
SymbolDeclKind::GlobalVar, SymbolDeclKind::GlobalConst, SymbolDeclKind::Parameter,
|
||||
SymbolDeclKind::GlobalVar, SymbolDeclKind::GlobalLet, SymbolDeclKind::Parameter,
|
||||
SymbolDeclKind::LocalVar, SymbolDeclKind::LocalLet, SymbolDeclKind::NestedLocalVar,
|
||||
SymbolDeclKind::NestedLocalLet,
|
||||
};
|
||||
|
||||
static constexpr SymbolDeclKind kGlobalDeclKinds[] = {
|
||||
SymbolDeclKind::GlobalVar, SymbolDeclKind::GlobalConst, SymbolDeclKind::Alias,
|
||||
SymbolDeclKind::GlobalVar, SymbolDeclKind::GlobalLet, SymbolDeclKind::Alias,
|
||||
SymbolDeclKind::Struct, SymbolDeclKind::Function,
|
||||
};
|
||||
|
||||
|
@ -95,7 +95,7 @@ static constexpr SymbolDeclKind kLocalDeclKinds[] = {
|
|||
|
||||
static constexpr SymbolDeclKind kGlobalValueDeclKinds[] = {
|
||||
SymbolDeclKind::GlobalVar,
|
||||
SymbolDeclKind::GlobalConst,
|
||||
SymbolDeclKind::GlobalLet,
|
||||
};
|
||||
|
||||
static constexpr SymbolDeclKind kFuncDeclKinds[] = {
|
||||
|
@ -181,7 +181,7 @@ std::ostream& operator<<(std::ostream& out, SymbolDeclKind kind) {
|
|||
switch (kind) {
|
||||
case SymbolDeclKind::GlobalVar:
|
||||
return out << "global var";
|
||||
case SymbolDeclKind::GlobalConst:
|
||||
case SymbolDeclKind::GlobalLet:
|
||||
return out << "global let";
|
||||
case SymbolDeclKind::Alias:
|
||||
return out << "alias";
|
||||
|
@ -320,7 +320,7 @@ std::string DiagString(SymbolUseKind kind) {
|
|||
int ScopeDepth(SymbolDeclKind kind) {
|
||||
switch (kind) {
|
||||
case SymbolDeclKind::GlobalVar:
|
||||
case SymbolDeclKind::GlobalConst:
|
||||
case SymbolDeclKind::GlobalLet:
|
||||
case SymbolDeclKind::Alias:
|
||||
case SymbolDeclKind::Struct:
|
||||
case SymbolDeclKind::Function:
|
||||
|
@ -426,8 +426,8 @@ const ast::Node* SymbolTestHelper::Add(SymbolDeclKind kind, Symbol symbol, Sourc
|
|||
switch (kind) {
|
||||
case SymbolDeclKind::GlobalVar:
|
||||
return b.Global(source, symbol, b.ty.i32(), ast::StorageClass::kPrivate);
|
||||
case SymbolDeclKind::GlobalConst:
|
||||
return b.GlobalConst(source, symbol, b.ty.i32(), b.Expr(1_i));
|
||||
case SymbolDeclKind::GlobalLet:
|
||||
return b.GlobalLet(source, symbol, b.ty.i32(), b.Expr(1_i));
|
||||
case SymbolDeclKind::Alias:
|
||||
return b.Alias(source, symbol, b.ty.i32());
|
||||
case SymbolDeclKind::Struct:
|
||||
|
@ -508,32 +508,32 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
|
|||
}
|
||||
case SymbolUseKind::GlobalLetType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
b.GlobalConst(b.Sym(), node, b.Expr(1_i));
|
||||
b.GlobalLet(b.Sym(), node, b.Expr(1_i));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::GlobalLetArrayElemType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
b.GlobalConst(b.Sym(), b.ty.array(node, 4_i), b.Expr(1_i));
|
||||
b.GlobalLet(b.Sym(), b.ty.array(node, 4_i), b.Expr(1_i));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::GlobalLetArraySizeValue: {
|
||||
auto* node = b.Expr(source, symbol);
|
||||
b.GlobalConst(b.Sym(), b.ty.array(b.ty.i32(), node), b.Expr(1_i));
|
||||
b.GlobalLet(b.Sym(), b.ty.array(b.ty.i32(), node), b.Expr(1_i));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::GlobalLetVectorElemType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
b.GlobalConst(b.Sym(), b.ty.vec3(node), b.Expr(1_i));
|
||||
b.GlobalLet(b.Sym(), b.ty.vec3(node), b.Expr(1_i));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::GlobalLetMatrixElemType: {
|
||||
auto* node = b.ty.type_name(source, symbol);
|
||||
b.GlobalConst(b.Sym(), b.ty.mat3x4(node), b.Expr(1_i));
|
||||
b.GlobalLet(b.Sym(), b.ty.mat3x4(node), b.Expr(1_i));
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::GlobalLetValue: {
|
||||
auto* node = b.Expr(source, symbol);
|
||||
b.GlobalConst(b.Sym(), b.ty.i32(), node);
|
||||
b.GlobalLet(b.Sym(), b.ty.i32(), node);
|
||||
return node;
|
||||
}
|
||||
case SymbolUseKind::AliasType: {
|
||||
|
@ -777,9 +777,9 @@ TEST_F(ResolverDependencyGraphDeclSelfUse, GlobalVar) {
|
|||
12:34 note: var 'SYMBOL' references var 'SYMBOL' here)");
|
||||
}
|
||||
|
||||
TEST_F(ResolverDependencyGraphDeclSelfUse, GlobalConst) {
|
||||
TEST_F(ResolverDependencyGraphDeclSelfUse, GlobalLet) {
|
||||
const Symbol symbol = Sym("SYMBOL");
|
||||
GlobalConst(symbol, ty.i32(), Mul(Expr(Source{{12, 34}}, symbol), 123_i));
|
||||
GlobalLet(symbol, ty.i32(), Mul(Expr(Source{{12, 34}}, symbol), 123_i));
|
||||
Build(R"(error: cyclic dependency found: 'SYMBOL' -> 'SYMBOL'
|
||||
12:34 note: let 'SYMBOL' references let 'SYMBOL' here)");
|
||||
}
|
||||
|
@ -910,7 +910,7 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, GlobalVar_Direct) {
|
|||
TEST_F(ResolverDependencyGraphCyclicRefTest, GlobalLet_Direct) {
|
||||
// let V : i32 = V;
|
||||
|
||||
GlobalConst(Source{{12, 34}}, "V", ty.i32(), Expr(Source{{56, 78}}, "V"));
|
||||
GlobalLet(Source{{12, 34}}, "V", ty.i32(), Expr(Source{{56, 78}}, "V"));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
|
@ -940,9 +940,9 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, GlobalLet_Indirect) {
|
|||
// 2: let X : i32 = Y;
|
||||
// 3: let Z : i32 = X;
|
||||
|
||||
GlobalConst(Source{{1, 1}}, "Y", ty.i32(), Expr(Source{{1, 10}}, "Z"));
|
||||
GlobalConst(Source{{2, 1}}, "X", ty.i32(), Expr(Source{{2, 10}}, "Y"));
|
||||
GlobalConst(Source{{3, 1}}, "Z", ty.i32(), Expr(Source{{3, 10}}, "X"));
|
||||
GlobalLet(Source{{1, 1}}, "Y", ty.i32(), Expr(Source{{1, 10}}, "Z"));
|
||||
GlobalLet(Source{{2, 1}}, "X", ty.i32(), Expr(Source{{2, 10}}, "Y"));
|
||||
GlobalLet(Source{{3, 1}}, "Z", ty.i32(), Expr(Source{{3, 10}}, "X"));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
|
@ -966,7 +966,7 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, Mixed_RecursiveDependencies) {
|
|||
Structure(Source{{3, 1}}, "S", {Member("a", ty.type_name(Source{{3, 10}}, "A"))});
|
||||
Global(Source{{4, 1}}, "Z", nullptr, Expr(Source{{4, 10}}, "L"));
|
||||
Alias(Source{{5, 1}}, "R", ty.type_name(Source{{5, 10}}, "A"));
|
||||
GlobalConst(Source{{6, 1}}, "L", ty.type_name(Source{{5, 5}}, "S"), Expr(Source{{5, 10}}, "Z"));
|
||||
GlobalLet(Source{{6, 1}}, "L", ty.type_name(Source{{5, 5}}, "S"), Expr(Source{{5, 10}}, "Z"));
|
||||
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
|
@ -1225,7 +1225,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
|
|||
Alias(Sym(), T);
|
||||
Structure(Sym(), {Member(Sym(), T)});
|
||||
Global(Sym(), T, V);
|
||||
GlobalConst(Sym(), T, V);
|
||||
GlobalLet(Sym(), T, V);
|
||||
Func(Sym(), //
|
||||
{Param(Sym(), T)}, //
|
||||
T, // Return type
|
||||
|
@ -1293,7 +1293,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
|
|||
TEST_F(ResolverDependencyGraphTraversalTest, InferredType) {
|
||||
// Check that the nullptr of the var / let type doesn't make things explode
|
||||
Global("a", nullptr, Expr(1_i));
|
||||
GlobalConst("b", nullptr, Expr(1_i));
|
||||
GlobalLet("b", nullptr, Expr(1_i));
|
||||
WrapInFunction(Var("c", nullptr, Expr(1_i)), //
|
||||
Let("d", nullptr, Expr(1_i)));
|
||||
Build();
|
||||
|
|
|
@ -433,8 +433,8 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_GoodType_ConstU32) {
|
|||
// let x = 8u;
|
||||
// @compute @workgroup_size(x, y, 16u)
|
||||
// fn main() {}
|
||||
auto* x = GlobalConst("x", ty.u32(), Expr(4_u));
|
||||
auto* y = GlobalConst("y", ty.u32(), Expr(8_u));
|
||||
auto* x = GlobalLet("x", ty.u32(), Expr(4_u));
|
||||
auto* y = GlobalLet("y", ty.u32(), Expr(8_u));
|
||||
auto* func = Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize("x", "y", 16_u)});
|
||||
|
||||
|
@ -520,7 +520,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_TypeMismatch) {
|
|||
// let x = 64u;
|
||||
// @compute @workgroup_size(1i, x)
|
||||
// fn main() {}
|
||||
GlobalConst("x", ty.u32(), Expr(64_u));
|
||||
GlobalLet("x", ty.u32(), Expr(64_u));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Source{{12, 34}}, 1_i, "x")});
|
||||
|
||||
|
@ -534,8 +534,8 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_TypeMismatch2) {
|
|||
// let y = 32i;
|
||||
// @compute @workgroup_size(x, y)
|
||||
// fn main() {}
|
||||
GlobalConst("x", ty.u32(), Expr(64_u));
|
||||
GlobalConst("y", ty.i32(), Expr(32_i));
|
||||
GlobalLet("x", ty.u32(), Expr(64_u));
|
||||
GlobalLet("y", ty.i32(), Expr(32_i));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Source{{12, 34}}, "x", "y")});
|
||||
|
||||
|
@ -548,8 +548,8 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Mismatch_ConstU32) {
|
|||
// let x = 8u;
|
||||
// @compute @workgroup_size(x, y, 16i)
|
||||
// fn main() {}
|
||||
GlobalConst("x", ty.u32(), Expr(4_u));
|
||||
GlobalConst("y", ty.u32(), Expr(8_u));
|
||||
GlobalLet("x", ty.u32(), Expr(4_u));
|
||||
GlobalLet("y", ty.u32(), Expr(8_u));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Source{{12, 34}}, "x", "y", 16_i)});
|
||||
|
||||
|
@ -597,7 +597,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_BadType) {
|
|||
// let x = 64.0;
|
||||
// @compute @workgroup_size(x)
|
||||
// fn main() {}
|
||||
GlobalConst("x", ty.f32(), Expr(64_f));
|
||||
GlobalLet("x", ty.f32(), Expr(64_f));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
|
||||
|
||||
|
@ -611,7 +611,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_Negative) {
|
|||
// let x = -2i;
|
||||
// @compute @workgroup_size(x)
|
||||
// fn main() {}
|
||||
GlobalConst("x", ty.i32(), Expr(-2_i));
|
||||
GlobalLet("x", ty.i32(), Expr(-2_i));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
|
||||
|
||||
|
@ -623,7 +623,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_Zero) {
|
|||
// let x = 0i;
|
||||
// @compute @workgroup_size(x)
|
||||
// fn main() {}
|
||||
GlobalConst("x", ty.i32(), Expr(0_i));
|
||||
GlobalLet("x", ty.i32(), Expr(0_i));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
|
||||
|
||||
|
@ -635,7 +635,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_Const_NestedZeroValueConstr
|
|||
// let x = i32(i32(i32()));
|
||||
// @compute @workgroup_size(x)
|
||||
// fn main() {}
|
||||
GlobalConst("x", ty.i32(), Construct(ty.i32(), Construct(ty.i32(), Construct(ty.i32()))));
|
||||
GlobalLet("x", ty.i32(), Construct(ty.i32(), Construct(ty.i32(), Construct(ty.i32()))));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ TEST_P(ResolverInferredTypeParamTest, GlobalLet_Pass) {
|
|||
|
||||
// let a = <type constructor>;
|
||||
auto* ctor_expr = params.create_value(*this, 0);
|
||||
auto* var = GlobalConst("a", nullptr, ctor_expr);
|
||||
auto* var = GlobalLet("a", nullptr, ctor_expr);
|
||||
WrapInFunction();
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
|
|
@ -38,7 +38,7 @@ class ResolverPipelineOverridableConstantTest : public ResolverTest {
|
|||
};
|
||||
|
||||
TEST_F(ResolverPipelineOverridableConstantTest, NonOverridable) {
|
||||
auto* a = GlobalConst("a", ty.f32(), Expr(1_f));
|
||||
auto* a = GlobalLet("a", ty.f32(), Expr(1_f));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
||||
|
|
|
@ -451,7 +451,7 @@ TEST_F(ResolverTest, ArraySize_SignedLiteral) {
|
|||
TEST_F(ResolverTest, ArraySize_UnsignedConstant) {
|
||||
// let size = 0u;
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(10_u));
|
||||
GlobalLet("size", nullptr, Expr(10_u));
|
||||
auto* a = Global("a", ty.array(ty.f32(), Expr("size")), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
@ -466,7 +466,7 @@ TEST_F(ResolverTest, ArraySize_UnsignedConstant) {
|
|||
TEST_F(ResolverTest, ArraySize_SignedConstant) {
|
||||
// let size = 0;
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(10_i));
|
||||
GlobalLet("size", nullptr, Expr(10_i));
|
||||
auto* a = Global("a", ty.array(ty.f32(), Expr("size")), ast::StorageClass::kPrivate);
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
|
@ -616,7 +616,7 @@ TEST_F(ResolverTest, Expr_Identifier_GlobalVariable) {
|
|||
}
|
||||
|
||||
TEST_F(ResolverTest, Expr_Identifier_GlobalConstant) {
|
||||
auto* my_var = GlobalConst("my_var", ty.f32(), Construct(ty.f32()));
|
||||
auto* my_var = GlobalLet("my_var", ty.f32(), Construct(ty.f32()));
|
||||
|
||||
auto* ident = Expr("my_var");
|
||||
WrapInFunction(ident);
|
||||
|
@ -951,9 +951,9 @@ TEST_F(ResolverTest, Function_WorkgroupSize_Consts) {
|
|||
// let depth = 2i;
|
||||
// @compute @workgroup_size(width, height, depth)
|
||||
// fn main() {}
|
||||
GlobalConst("width", ty.i32(), Expr(16_i));
|
||||
GlobalConst("height", ty.i32(), Expr(8_i));
|
||||
GlobalConst("depth", ty.i32(), Expr(2_i));
|
||||
GlobalLet("width", ty.i32(), Expr(16_i));
|
||||
GlobalLet("height", ty.i32(), Expr(8_i));
|
||||
GlobalLet("depth", ty.i32(), Expr(2_i));
|
||||
auto* func = Func("main", {}, ty.void_(), {},
|
||||
{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
|
@ -978,9 +978,9 @@ TEST_F(ResolverTest, Function_WorkgroupSize_Consts_NestedInitializer) {
|
|||
// let height = i32(i32(i32(4i)));
|
||||
// @compute @workgroup_size(width, height)
|
||||
// fn main() {}
|
||||
GlobalConst("width", ty.i32(),
|
||||
GlobalLet("width", ty.i32(),
|
||||
Construct(ty.i32(), Construct(ty.i32(), Construct(ty.i32(), 8_i))));
|
||||
GlobalConst("height", ty.i32(),
|
||||
GlobalLet("height", ty.i32(),
|
||||
Construct(ty.i32(), Construct(ty.i32(), Construct(ty.i32(), 4_i))));
|
||||
auto* func = Func("main", {}, ty.void_(), {},
|
||||
{
|
||||
|
@ -1063,7 +1063,7 @@ TEST_F(ResolverTest, Function_WorkgroupSize_Mixed) {
|
|||
// @compute @workgroup_size(8, height, depth)
|
||||
// fn main() {}
|
||||
auto* height = Override("height", ty.i32(), Expr(2_i), {Id(0)});
|
||||
GlobalConst("depth", ty.i32(), Expr(3_i));
|
||||
GlobalLet("depth", ty.i32(), Expr(3_i));
|
||||
auto* func = Func("main", {}, ty.void_(), {},
|
||||
{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
|
|
|
@ -92,8 +92,8 @@ TEST_F(ResolverSourceVariableTest, GlobalOverride) {
|
|||
EXPECT_EQ(Sem().Get(expr)->SourceVariable(), sem_a);
|
||||
}
|
||||
|
||||
TEST_F(ResolverSourceVariableTest, GlobalConst) {
|
||||
auto* a = GlobalConst("a", ty.f32(), Expr(1_f));
|
||||
TEST_F(ResolverSourceVariableTest, GlobalLet) {
|
||||
auto* a = GlobalLet("a", ty.f32(), Expr(1_f));
|
||||
auto* expr = Expr(a);
|
||||
WrapInFunction(expr);
|
||||
|
||||
|
|
|
@ -89,7 +89,7 @@ TEST_F(ResolverTypeValidationTest, GlobalVariableWithStorageClass_Pass) {
|
|||
|
||||
TEST_F(ResolverTypeValidationTest, GlobalConstNoStorageClass_Pass) {
|
||||
// let global_var: f32;
|
||||
GlobalConst(Source{{12, 34}}, "global_var", ty.f32(), Construct(ty.f32()));
|
||||
GlobalLet(Source{{12, 34}}, "global_var", ty.f32(), Construct(ty.f32()));
|
||||
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
@ -199,7 +199,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Pass) {
|
|||
TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLet_Pass) {
|
||||
// let size = 4u;
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(4_u));
|
||||
GlobalLet("size", nullptr, Expr(4_u));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
@ -207,7 +207,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLet_Pass) {
|
|||
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLet_Pass) {
|
||||
// let size = 4i;
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(4_i));
|
||||
GlobalLet("size", nullptr, Expr(4_i));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_TRUE(r()->Resolve()) << r()->error();
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Negative) {
|
|||
TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLet_Zero) {
|
||||
// let size = 0u;
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(0_u));
|
||||
GlobalLet("size", nullptr, Expr(0_u));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size (0) must be greater than 0");
|
||||
|
@ -252,7 +252,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLet_Zero) {
|
|||
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLet_Zero) {
|
||||
// let size = 0i;
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(0_i));
|
||||
GlobalLet("size", nullptr, Expr(0_i));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size (0) must be greater than 0");
|
||||
|
@ -261,7 +261,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedLet_Zero) {
|
|||
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLet_Negative) {
|
||||
// let size = -10i;
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(-10_i));
|
||||
GlobalLet("size", nullptr, Expr(-10_i));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(), "12:34 error: array size (-10) must be greater than 0");
|
||||
|
@ -289,7 +289,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_IVecLiteral) {
|
|||
TEST_F(ResolverTypeValidationTest, ArraySize_FloatLet) {
|
||||
// let size = 10.0;
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Expr(10_f));
|
||||
GlobalLet("size", nullptr, Expr(10_f));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
|
@ -300,7 +300,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FloatLet) {
|
|||
TEST_F(ResolverTypeValidationTest, ArraySize_IVecLet) {
|
||||
// let size = vec2<i32>(100, 100);
|
||||
// var<private> a : array<f32, size>;
|
||||
GlobalConst("size", nullptr, Construct(ty.vec2<i32>(), 100_i, 100_i));
|
||||
GlobalLet("size", nullptr, Construct(ty.vec2<i32>(), 100_i, 100_i));
|
||||
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
|
||||
EXPECT_FALSE(r()->Resolve());
|
||||
EXPECT_EQ(r()->error(),
|
||||
|
|
|
@ -244,7 +244,7 @@ TEST_F(ResolverVariableTest, LocalVar_ShadowsGlobalLet) {
|
|||
// var a = (a == 123);
|
||||
// }
|
||||
|
||||
auto* g = GlobalConst("a", ty.i32(), Expr(1_i));
|
||||
auto* g = GlobalLet("a", ty.i32(), Expr(1_i));
|
||||
auto* v = Var("a", nullptr, Expr("a"));
|
||||
Func("F", {}, ty.void_(), {Decl(v)});
|
||||
|
||||
|
@ -527,7 +527,7 @@ TEST_F(ResolverVariableTest, LocalLet_ShadowsGlobalLet) {
|
|||
// let a = (a == 321);
|
||||
// }
|
||||
|
||||
auto* g = GlobalConst("a", ty.i32(), Expr(1_i));
|
||||
auto* g = GlobalLet("a", ty.i32(), Expr(1_i));
|
||||
auto* l = Let("a", nullptr, Expr("a"));
|
||||
Func("F", {}, ty.void_(), {Decl(l)});
|
||||
|
||||
|
@ -725,7 +725,7 @@ TEST_F(ResolverVariableTest, Param_ShadowsGlobalLet) {
|
|||
// fn F(a : bool) {
|
||||
// }
|
||||
|
||||
auto* g = GlobalConst("a", ty.i32(), Expr(1_i));
|
||||
auto* g = GlobalLet("a", ty.i32(), Expr(1_i));
|
||||
auto* p = Param("a", ty.bool_());
|
||||
Func("F", {p}, ty.void_(), {});
|
||||
|
||||
|
|
|
@ -806,9 +806,9 @@ void main() {
|
|||
}
|
||||
|
||||
TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWorkgroup_Const) {
|
||||
GlobalConst("width", ty.i32(), Construct(ty.i32(), 2_i));
|
||||
GlobalConst("height", ty.i32(), Construct(ty.i32(), 3_i));
|
||||
GlobalConst("depth", ty.i32(), Construct(ty.i32(), 4_i));
|
||||
GlobalLet("width", ty.i32(), Construct(ty.i32(), 2_i));
|
||||
GlobalLet("height", ty.i32(), Construct(ty.i32(), 3_i));
|
||||
GlobalLet("depth", ty.i32(), Construct(ty.i32(), 4_i));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
|
|
|
@ -706,9 +706,9 @@ void main() {
|
|||
}
|
||||
|
||||
TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_Compute_WithWorkgroup_Const) {
|
||||
GlobalConst("width", ty.i32(), Construct(ty.i32(), 2_i));
|
||||
GlobalConst("height", ty.i32(), Construct(ty.i32(), 3_i));
|
||||
GlobalConst("depth", ty.i32(), Construct(ty.i32(), 4_i));
|
||||
GlobalLet("width", ty.i32(), Construct(ty.i32(), 2_i));
|
||||
GlobalLet("height", ty.i32(), Construct(ty.i32(), 3_i));
|
||||
GlobalLet("depth", ty.i32(), Construct(ty.i32(), 4_i));
|
||||
Func("main", {}, ty.void_(), {},
|
||||
{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace {
|
|||
using MslGeneratorImplTest = TestHelper;
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_ModuleConstant) {
|
||||
auto* var = GlobalConst("pos", ty.array<f32, 3>(), array<f32, 3>(1_f, 2_f, 3_f));
|
||||
auto* var = GlobalLet("pos", ty.array<f32, 3>(), array<f32, 3>(1_f, 2_f, 3_f));
|
||||
|
||||
GeneratorImpl& gen = Build();
|
||||
|
||||
|
|
|
@ -124,7 +124,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) {
|
|||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) {
|
||||
GlobalConst("initializer", ty.f32(), Expr(0_f));
|
||||
GlobalLet("initializer", ty.f32(), Expr(0_f));
|
||||
Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr("initializer"));
|
||||
|
||||
WrapInFunction(Expr("a"));
|
||||
|
@ -132,7 +132,11 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) {
|
|||
GeneratorImpl& gen = SanitizeAndBuild();
|
||||
|
||||
ASSERT_TRUE(gen.Generate()) << gen.error();
|
||||
EXPECT_THAT(gen.result(), HasSubstr("thread float tint_symbol_1 = initializer;\n float const tint_symbol = tint_symbol_1;\n return;\n"));
|
||||
EXPECT_THAT(gen.result(), HasSubstr(R"(
|
||||
thread float tint_symbol_1 = initializer;
|
||||
float const tint_symbol = tint_symbol_1;
|
||||
return;
|
||||
)"));
|
||||
}
|
||||
|
||||
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Workgroup) {
|
||||
|
|
|
@ -1075,7 +1075,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Vec4_With_Vec4) {
|
|||
|
||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_F32_With_F32) {
|
||||
auto* ctor = Construct<f32>(2_f);
|
||||
GlobalConst("g", ty.f32(), ctor);
|
||||
GlobalLet("g", ty.f32(), ctor);
|
||||
|
||||
spirv::Builder& b = SanitizeAndBuild();
|
||||
ASSERT_TRUE(b.Build());
|
||||
|
@ -1090,7 +1090,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_F32_With_F32) {
|
|||
|
||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_U32_With_F32) {
|
||||
auto* ctor = Construct<u32>(1.5_f);
|
||||
GlobalConst("g", ty.u32(), ctor);
|
||||
GlobalLet("g", ty.u32(), ctor);
|
||||
|
||||
spirv::Builder& b = SanitizeAndBuild();
|
||||
ASSERT_TRUE(b.Build());
|
||||
|
@ -1121,7 +1121,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec2_With_F32) {
|
|||
|
||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec2_With_Vec2) {
|
||||
auto* cast = vec2<f32>(vec2<f32>(2_f, 2_f));
|
||||
GlobalConst("a", ty.vec2<f32>(), cast);
|
||||
GlobalLet("a", ty.vec2<f32>(), cast);
|
||||
|
||||
spirv::Builder& b = SanitizeAndBuild();
|
||||
ASSERT_TRUE(b.Build());
|
||||
|
@ -1139,7 +1139,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec2_With_Vec2) {
|
|||
|
||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_Vec3) {
|
||||
auto* cast = vec3<f32>(vec3<f32>(2_f, 2_f, 2_f));
|
||||
GlobalConst("a", ty.vec3<f32>(), cast);
|
||||
GlobalLet("a", ty.vec3<f32>(), cast);
|
||||
|
||||
spirv::Builder& b = SanitizeAndBuild();
|
||||
ASSERT_TRUE(b.Build());
|
||||
|
@ -1157,7 +1157,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_Vec3) {
|
|||
|
||||
TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec4) {
|
||||
auto* cast = vec4<f32>(vec4<f32>(2_f, 2_f, 2_f, 2_f));
|
||||
GlobalConst("a", ty.vec4<f32>(), cast);
|
||||
GlobalLet("a", ty.vec4<f32>(), cast);
|
||||
|
||||
spirv::Builder& b = SanitizeAndBuild();
|
||||
ASSERT_TRUE(b.Build());
|
||||
|
|
|
@ -132,9 +132,9 @@ TEST_F(BuilderTest, Decoration_ExecutionMode_WorkgroupSize_Literals) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, Decoration_ExecutionMode_WorkgroupSize_Const) {
|
||||
GlobalConst("width", ty.i32(), Construct(ty.i32(), 2_i));
|
||||
GlobalConst("height", ty.i32(), Construct(ty.i32(), 3_i));
|
||||
GlobalConst("depth", ty.i32(), Construct(ty.i32(), 4_i));
|
||||
GlobalLet("width", ty.i32(), Construct(ty.i32(), 2_i));
|
||||
GlobalLet("height", ty.i32(), Construct(ty.i32(), 3_i));
|
||||
GlobalLet("depth", ty.i32(), Construct(ty.i32(), 4_i));
|
||||
auto* func = Func("main", {}, ty.void_(), {},
|
||||
{
|
||||
WorkgroupSize("width", "height", "depth"),
|
||||
|
@ -181,7 +181,7 @@ OpDecorate %3 BuiltIn WorkgroupSize
|
|||
|
||||
TEST_F(BuilderTest, Decoration_ExecutionMode_WorkgroupSize_LiteralAndConst) {
|
||||
Override("height", ty.i32(), Construct(ty.i32(), 2_i), {Id(7u)});
|
||||
GlobalConst("depth", ty.i32(), Construct(ty.i32(), 3_i));
|
||||
GlobalLet("depth", ty.i32(), Construct(ty.i32(), 3_i));
|
||||
auto* func = Func("main", {}, ty.void_(), {},
|
||||
{
|
||||
WorkgroupSize(4_i, "height", "depth"),
|
||||
|
|
|
@ -64,14 +64,14 @@ TEST_F(BuilderTest, GlobalVar_WithConstructor) {
|
|||
TEST_F(BuilderTest, GlobalVar_Const) {
|
||||
auto* init = vec3<f32>(1_f, 1_f, 3_f);
|
||||
|
||||
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
|
||||
auto* v = GlobalLet("l", ty.vec3<f32>(), init);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
EXPECT_TRUE(b.GenerateGlobalVariable(v)) << b.error();
|
||||
ASSERT_FALSE(b.has_error()) << b.error();
|
||||
|
||||
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %5 "var"
|
||||
EXPECT_EQ(DumpInstructions(b.debug()), R"(OpName %5 "l"
|
||||
)");
|
||||
EXPECT_EQ(DumpInstructions(b.types()), R"(%2 = OpTypeFloat 32
|
||||
%1 = OpTypeVector %2 3
|
||||
|
@ -84,7 +84,7 @@ TEST_F(BuilderTest, GlobalVar_Const) {
|
|||
TEST_F(BuilderTest, GlobalVar_Complex_Constructor) {
|
||||
auto* init = vec3<f32>(1_f, 2_f, 3_f);
|
||||
|
||||
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
|
||||
auto* v = GlobalLet("l", ty.vec3<f32>(), init);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
@ -103,7 +103,7 @@ TEST_F(BuilderTest, GlobalVar_Complex_Constructor) {
|
|||
TEST_F(BuilderTest, GlobalVar_Complex_ConstructorNestedVector) {
|
||||
auto* init = vec3<f32>(vec2<f32>(1_f, 2_f), 3_f);
|
||||
|
||||
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
|
||||
auto* v = GlobalLet("l", ty.vec3<f32>(), init);
|
||||
|
||||
spirv::Builder& b = Build();
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ using BuilderTest = TestHelper;
|
|||
TEST_F(BuilderTest, IdentifierExpression_GlobalConst) {
|
||||
auto* init = vec3<f32>(1_f, 1_f, 3_f);
|
||||
|
||||
auto* v = GlobalConst("var", ty.vec3<f32>(), init);
|
||||
auto* v = GlobalLet("var", ty.vec3<f32>(), init);
|
||||
|
||||
auto* expr = Expr("var");
|
||||
WrapInFunction(expr);
|
||||
|
@ -138,7 +138,7 @@ TEST_F(BuilderTest, IdentifierExpression_Load) {
|
|||
}
|
||||
|
||||
TEST_F(BuilderTest, IdentifierExpression_NoLoadConst) {
|
||||
auto* var = GlobalConst("var", ty.i32(), Expr(2_i));
|
||||
auto* var = GlobalLet("var", ty.i32(), Expr(2_i));
|
||||
|
||||
auto* expr = Add("var", "var");
|
||||
WrapInFunction(expr);
|
||||
|
|
|
@ -78,7 +78,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_WithAttribute_WorkgroupSize) {
|
|||
}
|
||||
|
||||
TEST_F(WgslGeneratorImplTest, Emit_Function_WithAttribute_WorkgroupSize_WithIdent) {
|
||||
GlobalConst("height", ty.i32(), Expr(2_i));
|
||||
GlobalLet("height", ty.i32(), Expr(2_i));
|
||||
auto* func = Func("my_func", {}, ty.void_(), {Return()},
|
||||
{
|
||||
Stage(ast::PipelineStage::kCompute),
|
||||
|
|
Loading…
Reference in New Issue