tint: Rename Global() -> GlobalVar()

We have `GlobalLet()`, `Let()`, `Var()`, so this just
keeps things consistent

Change-Id: Ie9f79b62e737a15b995c5a2b19f84621a5ac3cc9
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/94604
Commit-Queue: Ben Clayton <bclayton@google.com>
Reviewed-by: David Neto <dneto@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton 2022-06-25 08:12:59 +00:00 committed by Dawn LUCI CQ
parent 41486e1135
commit 01208e7e42
122 changed files with 1655 additions and 1637 deletions

View File

@ -147,25 +147,26 @@ const ast::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b
};
switch (texture_kind) {
case ast::builtin::test::TextureKind::kRegular:
return b->Global(
return b->GlobalVar(
"texture",
b->ty.sampled_texture(texture_dimension, BuildResultVectorComponentType(b)), attrs);
case ast::builtin::test::TextureKind::kDepth:
return b->Global("texture", b->ty.depth_texture(texture_dimension), attrs);
return b->GlobalVar("texture", b->ty.depth_texture(texture_dimension), attrs);
case ast::builtin::test::TextureKind::kDepthMultisampled:
return b->Global("texture", b->ty.depth_multisampled_texture(texture_dimension), attrs);
return b->GlobalVar("texture", b->ty.depth_multisampled_texture(texture_dimension),
attrs);
case ast::builtin::test::TextureKind::kMultisampled:
return b->Global(
return b->GlobalVar(
"texture",
b->ty.multisampled_texture(texture_dimension, BuildResultVectorComponentType(b)),
attrs);
case ast::builtin::test::TextureKind::kStorage: {
auto* st = b->ty.storage_texture(texture_dimension, texel_format, access);
return b->Global("texture", st, attrs);
return b->GlobalVar("texture", st, attrs);
}
}
@ -178,7 +179,7 @@ const ast::Variable* TextureOverloadCase::BuildSamplerVariable(ProgramBuilder* b
b->create<ast::GroupAttribute>(0),
b->create<ast::BindingAttribute>(1),
};
return b->Global("sampler", b->ty.sampler(sampler_kind), attrs);
return b->GlobalVar("sampler", b->ty.sampler(sampler_kind), attrs);
}
std::vector<TextureOverloadCase> TextureOverloadCase::ValidCases() {

View File

@ -92,7 +92,7 @@ TEST_F(ModuleTest, CloneOrder) {
ProgramBuilder b;
b.Func("F", {}, b.ty.void_(), {});
b.Alias("A", b.ty.u32());
b.Global("V", b.ty.i32(), ast::StorageClass::kPrivate);
b.GlobalVar("V", b.ty.i32(), ast::StorageClass::kPrivate);
return Program(std::move(b));
}();

View File

@ -121,7 +121,7 @@ void InspectorBuilder::AddUniformBuffer(const std::string& name,
const ast::Type* type,
uint32_t group,
uint32_t binding) {
Global(name, type, ast::StorageClass::kUniform,
GlobalVar(name, type, ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(binding),
create<ast::GroupAttribute>(group),
@ -129,7 +129,7 @@ void InspectorBuilder::AddUniformBuffer(const std::string& name,
}
void InspectorBuilder::AddWorkgroupStorage(const std::string& name, const ast::Type* type) {
Global(name, type, ast::StorageClass::kWorkgroup);
GlobalVar(name, type, ast::StorageClass::kWorkgroup);
}
void InspectorBuilder::AddStorageBuffer(const std::string& name,
@ -137,7 +137,7 @@ void InspectorBuilder::AddStorageBuffer(const std::string& name,
ast::Access access,
uint32_t group,
uint32_t binding) {
Global(name, type, ast::StorageClass::kStorage, access,
GlobalVar(name, type, ast::StorageClass::kStorage, access,
ast::AttributeList{
create<ast::BindingAttribute>(binding),
create<ast::GroupAttribute>(group),
@ -173,7 +173,7 @@ void InspectorBuilder::MakeStructVariableReferenceBodyFunction(
}
void InspectorBuilder::AddSampler(const std::string& name, uint32_t group, uint32_t binding) {
Global(name, sampler_type(),
GlobalVar(name, sampler_type(),
ast::AttributeList{
create<ast::BindingAttribute>(binding),
create<ast::GroupAttribute>(group),
@ -183,7 +183,7 @@ void InspectorBuilder::AddSampler(const std::string& name, uint32_t group, uint3
void InspectorBuilder::AddComparisonSampler(const std::string& name,
uint32_t group,
uint32_t binding) {
Global(name, comparison_sampler_type(),
GlobalVar(name, comparison_sampler_type(),
ast::AttributeList{
create<ast::BindingAttribute>(binding),
create<ast::GroupAttribute>(group),
@ -194,7 +194,7 @@ void InspectorBuilder::AddResource(const std::string& name,
const ast::Type* type,
uint32_t group,
uint32_t binding) {
Global(name, type,
GlobalVar(name, type,
ast::AttributeList{
create<ast::BindingAttribute>(binding),
create<ast::GroupAttribute>(group),
@ -202,7 +202,7 @@ void InspectorBuilder::AddResource(const std::string& name,
}
void InspectorBuilder::AddGlobalVariable(const std::string& name, const ast::Type* type) {
Global(name, type, ast::StorageClass::kPrivate);
GlobalVar(name, type, ast::StorageClass::kPrivate);
}
const ast::Function* InspectorBuilder::MakeSamplerReferenceBodyFunction(
@ -305,7 +305,7 @@ void InspectorBuilder::AddStorageTexture(const std::string& name,
const ast::Type* type,
uint32_t group,
uint32_t binding) {
Global(name, type,
GlobalVar(name, type,
ast::AttributeList{
create<ast::BindingAttribute>(binding),
create<ast::GroupAttribute>(group),

View File

@ -128,7 +128,7 @@ class ProgramBuilder {
traits::EnableIfIsNotType<traits::Decay<traits::NthTypeOf<0, TYPES..., void>>, Source>;
/// VarOptionals is a helper for accepting a number of optional, extra
/// arguments for Var() and Global().
/// arguments for Var() and GlobalVar().
struct VarOptionals {
template <typename... ARGS>
explicit VarOptionals(ARGS&&... args) {
@ -1429,7 +1429,7 @@ class ProgramBuilder {
/// @returns a new `ast::Var`, which is automatically registered as a global variable with the
/// ast::Module.
template <typename NAME, typename... OPTIONAL, typename = DisableIfSource<NAME>>
const ast::Var* Global(NAME&& name, const ast::Type* type, OPTIONAL&&... optional) {
const ast::Var* GlobalVar(NAME&& name, const ast::Type* type, OPTIONAL&&... optional) {
auto* var = Var(std::forward<NAME>(name), type, std::forward<OPTIONAL>(optional)...);
AST().AddGlobalVariable(var);
return var;
@ -1449,7 +1449,7 @@ class ProgramBuilder {
/// @returns a new `ast::Var`, which is automatically registered as a global variable with the
/// ast::Module.
template <typename NAME, typename... OPTIONAL>
const ast::Var* Global(const Source& source,
const ast::Var* GlobalVar(const Source& source,
NAME&& name,
const ast::Type* type,
OPTIONAL&&... optional) {

View File

@ -46,7 +46,7 @@ TEST_F(ProgramTest, IDsAreUnique) {
}
TEST_F(ProgramTest, Assert_GlobalVariable) {
Global("var", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("var", ty.f32(), ast::StorageClass::kPrivate);
Program program(std::move(*this));
EXPECT_TRUE(program.IsValid());

View File

@ -27,7 +27,7 @@ namespace {
using ResolverIndexAccessorTest = ResolverTest;
TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_F32) {
Global("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 1_f));
WrapInFunction(acc);
@ -36,7 +36,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_F32) {
}
TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_Ref) {
Global("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
auto* idx = Var("idx", ty.i32(), Construct(ty.i32()));
auto* acc = IndexAccessor("my_var", idx);
WrapInFunction(Decl(idx), acc);
@ -50,7 +50,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_Ref) {
}
TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions_Dynamic_Ref) {
Global("my_var", ty.mat4x4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.mat4x4<f32>(), ast::StorageClass::kPrivate);
auto* idx = Var("idx", ty.u32(), Expr(3_u));
auto* idy = Var("idy", ty.u32(), Expr(2_u));
auto* acc = IndexAccessor(IndexAccessor("my_var", idx), idy);
@ -110,7 +110,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_BothDimension_Dynamic) {
}
TEST_F(ResolverIndexAccessorTest, Matrix) {
Global("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor("my_var", 2_i);
WrapInFunction(acc);
@ -131,7 +131,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix) {
}
TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions) {
Global("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor(IndexAccessor("my_var", 2_i), 1_i);
WrapInFunction(acc);
@ -151,7 +151,7 @@ TEST_F(ResolverIndexAccessorTest, Matrix_BothDimensions) {
}
TEST_F(ResolverIndexAccessorTest, Vector_F32) {
Global("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor("my_var", Expr(Source{{12, 34}}, 2_f));
WrapInFunction(acc);
@ -160,7 +160,7 @@ TEST_F(ResolverIndexAccessorTest, Vector_F32) {
}
TEST_F(ResolverIndexAccessorTest, Vector_Dynamic_Ref) {
Global("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* idx = Var("idx", ty.i32(), Expr(2_i));
auto* acc = IndexAccessor("my_var", idx);
WrapInFunction(Decl(idx), acc);
@ -188,7 +188,7 @@ TEST_F(ResolverIndexAccessorTest, Vector_Dynamic) {
}
TEST_F(ResolverIndexAccessorTest, Vector) {
Global("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor("my_var", 2_i);
WrapInFunction(acc);
@ -208,7 +208,7 @@ TEST_F(ResolverIndexAccessorTest, Vector) {
}
TEST_F(ResolverIndexAccessorTest, Array_Literal_i32) {
Global("my_var", ty.array<f32, 3>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.array<f32, 3>(), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor("my_var", 2_i);
WrapInFunction(acc);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -224,7 +224,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_i32) {
}
TEST_F(ResolverIndexAccessorTest, Array_Literal_u32) {
Global("my_var", ty.array<f32, 3>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.array<f32, 3>(), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor("my_var", 2_u);
WrapInFunction(acc);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -240,7 +240,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_u32) {
}
TEST_F(ResolverIndexAccessorTest, Array_Literal_AInt) {
Global("my_var", ty.array<f32, 3>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.array<f32, 3>(), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor("my_var", 2_a);
WrapInFunction(acc);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -258,7 +258,7 @@ TEST_F(ResolverIndexAccessorTest, Array_Literal_AInt) {
TEST_F(ResolverIndexAccessorTest, Alias_Array) {
auto* aary = Alias("myarrty", ty.array<f32, 3>());
Global("my_var", ty.Of(aary), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.Of(aary), ast::StorageClass::kPrivate);
auto* acc = IndexAccessor("my_var", 2_i);
WrapInFunction(acc);

View File

@ -30,7 +30,7 @@ TEST_F(ResolverAssignmentValidationTest, ReadOnlyBuffer) {
// @group(0) @binding(0)
// var<storage,read> a : S;
auto* s = Structure("S", {Member("m", ty.i32())});
Global(Source{{12, 34}}, "a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{12, 34}}, "a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -235,12 +235,12 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) {
ast::Access::kWrite);
};
Global("a", make_type(), ast::StorageClass::kNone,
GlobalVar("a", make_type(), ast::StorageClass::kNone,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
});
Global("b", make_type(), ast::StorageClass::kNone,
GlobalVar("b", make_type(), ast::StorageClass::kNone,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(0),
@ -258,7 +258,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Atomic) {
// v.a = v.a;
auto* s = Structure("S", {Member("a", ty.atomic(ty.i32()))});
Global(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -276,7 +276,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_RuntimeArray) {
// v.a = v.a;
auto* s = Structure("S", {Member("a", ty.array(ty.f32()))});
Global(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -297,7 +297,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_NonConstructibleStruct_Fa
// _ = s;
// }
auto* s = Structure("S", {Member("arr", ty.array<i32>())});
Global("s", ty.Of(s), ast::StorageClass::kStorage, GroupAndBinding(0, 0));
GlobalVar("s", ty.Of(s), ast::StorageClass::kStorage, GroupAndBinding(0, 0));
WrapInFunction(Assign(Phony(), Expr(Source{{12, 34}}, "s")));
@ -317,7 +317,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_DynamicArray_Fail) {
// _ = s.arr;
// }
auto* s = Structure("S", {Member("arr", ty.array<i32>())});
Global("s", ty.Of(s), ast::StorageClass::kStorage, GroupAndBinding(0, 0));
GlobalVar("s", ty.Of(s), ast::StorageClass::kStorage, GroupAndBinding(0, 0));
WrapInFunction(Assign(Phony(), MemberAccessor(Source{{12, 34}}, "s", "arr")));
@ -365,11 +365,12 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_Pass) {
Member("arr", ty.array<i32>()),
});
auto* U = Structure("U", {Member("i", ty.i32())});
Global("tex", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(0, 0));
Global("smp", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(0, 1));
Global("u", ty.Of(U), ast::StorageClass::kUniform, GroupAndBinding(0, 2));
Global("s", ty.Of(S), ast::StorageClass::kStorage, GroupAndBinding(0, 3));
Global("wg", ty.array<f32, 10>(), ast::StorageClass::kWorkgroup);
GlobalVar("tex", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
GroupAndBinding(0, 0));
GlobalVar("smp", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(0, 1));
GlobalVar("u", ty.Of(U), ast::StorageClass::kUniform, GroupAndBinding(0, 2));
GlobalVar("s", ty.Of(S), ast::StorageClass::kStorage, GroupAndBinding(0, 3));
GlobalVar("wg", ty.array<f32, 10>(), ast::StorageClass::kWorkgroup);
WrapInFunction(Assign(Phony(), 1_i), //
Assign(Phony(), 2_u), //

View File

@ -25,7 +25,7 @@ namespace {
struct ResolverAtomicTest : public resolver::TestHelper, public testing::Test {};
TEST_F(ResolverAtomicTest, GlobalWorkgroupI32) {
auto* g = Global("a", ty.atomic(Source{{12, 34}}, ty.i32()), ast::StorageClass::kWorkgroup);
auto* g = GlobalVar("a", ty.atomic(Source{{12, 34}}, ty.i32()), ast::StorageClass::kWorkgroup);
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_TRUE(TypeOf(g)->Is<sem::Reference>());
@ -35,7 +35,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupI32) {
}
TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) {
auto* g = Global("a", ty.atomic(Source{{12, 34}}, ty.u32()), ast::StorageClass::kWorkgroup);
auto* g = GlobalVar("a", ty.atomic(Source{{12, 34}}, ty.u32()), ast::StorageClass::kWorkgroup);
EXPECT_TRUE(r()->Resolve()) << r()->error();
ASSERT_TRUE(TypeOf(g)->Is<sem::Reference>());
@ -46,7 +46,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) {
TEST_F(ResolverAtomicTest, GlobalStorageStruct) {
auto* s = Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))});
auto* g = Global("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
auto* g = GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),

View File

@ -27,13 +27,13 @@ namespace {
struct ResolverAtomicValidationTest : public resolver::TestHelper, public testing::Test {};
TEST_F(ResolverAtomicValidationTest, StorageClass_WorkGroup) {
Global("a", ty.atomic(Source{{12, 34}}, ty.i32()), ast::StorageClass::kWorkgroup);
GlobalVar("a", ty.atomic(Source{{12, 34}}, ty.i32()), ast::StorageClass::kWorkgroup);
EXPECT_TRUE(r()->Resolve());
}
TEST_F(ResolverAtomicValidationTest, StorageClass_Storage) {
Global("g", ty.atomic(Source{{12, 34}}, ty.i32()), ast::StorageClass::kStorage,
GlobalVar("g", ty.atomic(Source{{12, 34}}, ty.i32()), ast::StorageClass::kStorage,
ast::Access::kReadWrite, GroupAndBinding(0, 0));
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -41,21 +41,21 @@ TEST_F(ResolverAtomicValidationTest, StorageClass_Storage) {
TEST_F(ResolverAtomicValidationTest, StorageClass_Storage_Struct) {
auto* s = Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))});
Global("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GroupAndBinding(0, 0));
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverAtomicValidationTest, InvalidType) {
Global("a", ty.atomic(ty.f32(Source{{12, 34}})), ast::StorageClass::kWorkgroup);
GlobalVar("a", ty.atomic(ty.f32(Source{{12, 34}})), ast::StorageClass::kWorkgroup);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: atomic only supports i32 or u32 types");
}
TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_Simple) {
Global("a", ty.atomic(Source{{12, 34}}, ty.i32()), ast::StorageClass::kPrivate);
GlobalVar("a", ty.atomic(Source{{12, 34}}, ty.i32()), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -64,7 +64,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_Simple) {
}
TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_Array) {
Global("a", ty.atomic(Source{{12, 34}}, ty.i32()), ast::StorageClass::kPrivate);
GlobalVar("a", ty.atomic(Source{{12, 34}}, ty.i32()), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -74,7 +74,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_Array) {
TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_Struct) {
auto* s = Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))});
Global("g", ty.Of(s), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(s), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -90,7 +90,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_StructOfStruct) {
auto* Inner = Structure("Inner", {Member("m", ty.atomic(Source{{12, 34}}, ty.i32()))});
auto* Outer = Structure("Outer", {Member("m", ty.Of(Inner))});
Global("g", ty.Of(Outer), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(Outer), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -106,7 +106,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_StructOfStructOfArray)
auto* Inner = Structure("Inner", {Member(Source{{12, 34}}, "m", ty.atomic(ty.i32()))});
auto* Outer = Structure("Outer", {Member("m", ty.Of(Inner))});
Global("g", ty.Of(Outer), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(Outer), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -121,7 +121,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_ArrayOfArray) {
auto* atomic_array =
Alias(Source{{12, 34}}, "AtomicArray", ty.atomic(Source{{12, 34}}, ty.i32()));
Global(Source{{56, 78}}, "v", ty.Of(atomic_array), ast::StorageClass::kPrivate);
GlobalVar(Source{{56, 78}}, "v", ty.Of(atomic_array), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -136,7 +136,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_ArrayOfStruct) {
// var<private> v: array<S, 5u>;
auto* s = Structure("S", {Member("m", ty.atomic<u32>())});
Global(Source{{56, 78}}, "v", ty.array(ty.Of(s), 5_u), ast::StorageClass::kPrivate);
GlobalVar(Source{{56, 78}}, "v", ty.array(ty.Of(s), 5_u), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -155,7 +155,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_ArrayOfStructOfArray) {
auto* atomic_array =
Alias(Source{{12, 34}}, "AtomicArray", ty.atomic(Source{{12, 34}}, ty.i32()));
auto* s = Structure("S", {Member("m", ty.Of(atomic_array))});
Global(Source{{56, 78}}, "v", ty.array(ty.Of(s), 5_u), ast::StorageClass::kPrivate);
GlobalVar(Source{{56, 78}}, "v", ty.array(ty.Of(s), 5_u), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -196,7 +196,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_Complex) {
auto* s2 = Structure("S2", {Member("x", ty.Of(s3))});
auto* s1 = Structure("S1", {Member("x", ty.Of(s2))});
auto* s0 = Structure("S0", {Member("x", ty.Of(s1))});
Global(Source{{56, 78}}, "g", ty.Of(s0), ast::StorageClass::kPrivate);
GlobalVar(Source{{56, 78}}, "g", ty.Of(s0), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -207,7 +207,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_Complex) {
TEST_F(ResolverAtomicValidationTest, Struct_AccessMode_Read) {
auto* s = Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))});
Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GroupAndBinding(0, 0));
EXPECT_FALSE(r()->Resolve());
@ -219,7 +219,7 @@ TEST_F(ResolverAtomicValidationTest, Struct_AccessMode_Read) {
TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Struct) {
auto* s = Structure("s", {Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))});
Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GroupAndBinding(0, 0));
EXPECT_FALSE(r()->Resolve());
@ -236,7 +236,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStruct) {
auto* Inner = Structure("Inner", {Member("m", ty.atomic(Source{{12, 34}}, ty.i32()))});
auto* Outer = Structure("Outer", {Member("m", ty.Of(Inner))});
Global(Source{{56, 78}}, "g", ty.Of(Outer), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), ast::StorageClass::kStorage, ast::Access::kRead,
GroupAndBinding(0, 0));
EXPECT_FALSE(r()->Resolve());
@ -253,7 +253,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStructOfArray) {
auto* Inner = Structure("Inner", {Member(Source{{12, 34}}, "m", ty.atomic(ty.i32()))});
auto* Outer = Structure("Outer", {Member("m", ty.Of(Inner))});
Global(Source{{56, 78}}, "g", ty.Of(Outer), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), ast::StorageClass::kStorage, ast::Access::kRead,
GroupAndBinding(0, 0));
EXPECT_FALSE(r()->Resolve());
@ -295,7 +295,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Complex) {
auto* s2 = Structure("S2", {Member("x", ty.Of(s3))});
auto* s1 = Structure("S1", {Member("x", ty.Of(s2))});
auto* s0 = Structure("S0", {Member("x", ty.Of(s1))});
Global(Source{{56, 78}}, "g", ty.Of(s0), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{56, 78}}, "g", ty.Of(s0), ast::StorageClass::kStorage, ast::Access::kRead,
GroupAndBinding(0, 0));
EXPECT_FALSE(r()->Resolve());

View File

@ -707,10 +707,10 @@ TEST_P(VariableAttributeTest, IsValid) {
auto& params = GetParam();
if (IsBindingAttribute(params.kind)) {
Global("a", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr,
GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr,
createAttributes(Source{{12, 34}}, *this, params.kind));
} else {
Global("a", ty.f32(), ast::StorageClass::kPrivate, nullptr,
GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate, nullptr,
createAttributes(Source{{12, 34}}, *this, params.kind));
}
@ -743,7 +743,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest,
TestParams{AttributeKind::kBindingAndGroup, true}));
TEST_F(VariableAttributeTest, DuplicateAttribute) {
Global("a", ty.sampler(ast::SamplerKind::kSampler),
GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler),
ast::AttributeList{
create<ast::BindingAttribute>(Source{{12, 34}}, 2),
create<ast::GroupAttribute>(2),
@ -774,8 +774,7 @@ using ConstantAttributeTest = TestWithParams;
TEST_P(ConstantAttributeTest, IsValid) {
auto& params = GetParam();
GlobalLet("a", ty.f32(), Expr(1.23_f),
createAttributes(Source{{12, 34}}, *this, params.kind));
GlobalLet("a", ty.f32(), Expr(1.23_f), createAttributes(Source{{12, 34}}, *this, params.kind));
WrapInFunction();
@ -897,7 +896,7 @@ TEST_P(ArrayStrideTest, All) {
auto* arr = ty.array(Source{{12, 34}}, el_ty, 4_u, params.stride);
Global("myarray", arr, ast::StorageClass::kPrivate);
GlobalVar("myarray", arr, ast::StorageClass::kPrivate);
if (params.should_pass) {
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -980,7 +979,7 @@ TEST_F(ArrayStrideTest, DuplicateAttribute) {
create<ast::StrideAttribute>(Source{{56, 78}}, 4_i),
});
Global("myarray", arr, ast::StorageClass::kPrivate);
GlobalVar("myarray", arr, ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -997,7 +996,7 @@ namespace {
using ResourceAttributeTest = ResolverTest;
TEST_F(ResourceAttributeTest, UniformBufferMissingBinding) {
auto* s = Structure("S", {Member("x", ty.i32())});
Global(Source{{12, 34}}, "G", ty.Of(s), ast::StorageClass::kUniform);
GlobalVar(Source{{12, 34}}, "G", ty.Of(s), ast::StorageClass::kUniform);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -1006,7 +1005,7 @@ TEST_F(ResourceAttributeTest, UniformBufferMissingBinding) {
TEST_F(ResourceAttributeTest, StorageBufferMissingBinding) {
auto* s = Structure("S", {Member("x", ty.i32())});
Global(Source{{12, 34}}, "G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead);
GlobalVar(Source{{12, 34}}, "G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -1014,7 +1013,7 @@ TEST_F(ResourceAttributeTest, StorageBufferMissingBinding) {
}
TEST_F(ResourceAttributeTest, TextureMissingBinding) {
Global(Source{{12, 34}}, "G", ty.depth_texture(ast::TextureDimension::k2d),
GlobalVar(Source{{12, 34}}, "G", ty.depth_texture(ast::TextureDimension::k2d),
ast::StorageClass::kNone);
EXPECT_FALSE(r()->Resolve());
@ -1023,7 +1022,8 @@ TEST_F(ResourceAttributeTest, TextureMissingBinding) {
}
TEST_F(ResourceAttributeTest, SamplerMissingBinding) {
Global(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone);
GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler),
ast::StorageClass::kNone);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -1031,7 +1031,8 @@ TEST_F(ResourceAttributeTest, SamplerMissingBinding) {
}
TEST_F(ResourceAttributeTest, BindingPairMissingBinding) {
Global(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone,
GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler),
ast::StorageClass::kNone,
ast::AttributeList{
create<ast::GroupAttribute>(1),
});
@ -1042,7 +1043,8 @@ TEST_F(ResourceAttributeTest, BindingPairMissingBinding) {
}
TEST_F(ResourceAttributeTest, BindingPairMissingGroup) {
Global(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone,
GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler),
ast::StorageClass::kNone,
ast::AttributeList{
create<ast::BindingAttribute>(1),
});
@ -1053,13 +1055,13 @@ TEST_F(ResourceAttributeTest, BindingPairMissingGroup) {
}
TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) {
Global(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
ast::StorageClass::kNone,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
});
Global(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
ast::StorageClass::kNone,
ast::AttributeList{
create<ast::BindingAttribute>(1),
@ -1085,13 +1087,13 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) {
}
TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) {
Global(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
ast::StorageClass::kNone,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
});
Global(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
ast::StorageClass::kNone,
ast::AttributeList{
create<ast::BindingAttribute>(1),
@ -1119,7 +1121,7 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) {
}
TEST_F(ResourceAttributeTest, BindingPointOnNonResource) {
Global(Source{{12, 34}}, "G", ty.f32(), ast::StorageClass::kPrivate,
GlobalVar(Source{{12, 34}}, "G", ty.f32(), ast::StorageClass::kPrivate,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),

View File

@ -52,7 +52,7 @@ using ResolverBuiltinDerivativeTest = ResolverTestWithParam<std::string>;
TEST_P(ResolverBuiltinDerivativeTest, Scalar) {
auto name = GetParam();
Global("ident", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("ident", ty.f32(), ast::StorageClass::kPrivate);
auto* expr = Call(name, "ident");
Func("func", {}, ty.void_(), {Ignore(expr)},
@ -66,7 +66,7 @@ TEST_P(ResolverBuiltinDerivativeTest, Scalar) {
TEST_P(ResolverBuiltinDerivativeTest, Vector) {
auto name = GetParam();
Global("ident", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("ident", ty.vec4<f32>(), ast::StorageClass::kPrivate);
auto* expr = Call(name, "ident");
Func("func", {}, ty.void_(), {Ignore(expr)},
@ -110,7 +110,7 @@ using ResolverBuiltinTest_BoolMethod = ResolverTestWithParam<std::string>;
TEST_P(ResolverBuiltinTest_BoolMethod, Scalar) {
auto name = GetParam();
Global("my_var", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr = Call(name, "my_var");
WrapInFunction(expr);
@ -123,7 +123,7 @@ TEST_P(ResolverBuiltinTest_BoolMethod, Scalar) {
TEST_P(ResolverBuiltinTest_BoolMethod, Vector) {
auto name = GetParam();
Global("my_var", ty.vec3<bool>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.vec3<bool>(), ast::StorageClass::kPrivate);
auto* expr = Call(name, "my_var");
WrapInFunction(expr);
@ -185,14 +185,14 @@ class ResolverBuiltinTest_TextureOperation : public ResolverTestWithParam<Textur
void add_call_param(std::string name, const ast::Type* type, ast::ExpressionList* call_params) {
if (type->IsAnyOf<ast::Texture, ast::Sampler>()) {
Global(name, type,
GlobalVar(name, type,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
});
} else {
Global(name, type, ast::StorageClass::kPrivate);
GlobalVar(name, type, ast::StorageClass::kPrivate);
}
call_params->push_back(Expr(name));
@ -251,7 +251,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverTest,
TextureTestParams{ast::TextureDimension::k3d}));
TEST_F(ResolverBuiltinTest, Dot_Vec2) {
Global("my_var", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.vec2<f32>(), ast::StorageClass::kPrivate);
auto* expr = Call("dot", "my_var", "my_var");
WrapInFunction(expr);
@ -263,7 +263,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec2) {
}
TEST_F(ResolverBuiltinTest, Dot_Vec3) {
Global("my_var", ty.vec3<i32>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.vec3<i32>(), ast::StorageClass::kPrivate);
auto* expr = Call("dot", "my_var", "my_var");
WrapInFunction(expr);
@ -275,7 +275,7 @@ TEST_F(ResolverBuiltinTest, Dot_Vec3) {
}
TEST_F(ResolverBuiltinTest, Dot_Vec4) {
Global("my_var", ty.vec4<u32>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.vec4<u32>(), ast::StorageClass::kPrivate);
auto* expr = Call("dot", "my_var", "my_var");
WrapInFunction(expr);
@ -301,9 +301,9 @@ TEST_F(ResolverBuiltinTest, Dot_Error_Scalar) {
}
TEST_F(ResolverBuiltinTest, Select) {
Global("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
Global("bool_var", ty.vec3<bool>(), ast::StorageClass::kPrivate);
GlobalVar("bool_var", ty.vec3<bool>(), ast::StorageClass::kPrivate);
auto* expr = Call("select", "my_var", "my_var", "bool_var");
WrapInFunction(expr);
@ -616,7 +616,7 @@ using ResolverBuiltinDataTest = ResolverTest;
TEST_F(ResolverBuiltinDataTest, ArrayLength_Vector) {
auto* ary = ty.array<i32>();
auto* str = Structure("S", {Member("x", ary)});
Global("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -632,7 +632,7 @@ TEST_F(ResolverBuiltinDataTest, ArrayLength_Vector) {
}
TEST_F(ResolverBuiltinDataTest, ArrayLength_Error_ArraySized) {
Global("arr", ty.array<i32, 4>(), ast::StorageClass::kPrivate);
GlobalVar("arr", ty.array<i32, 4>(), ast::StorageClass::kPrivate);
auto* call = Call("arrayLength", AddressOf("arr"));
WrapInFunction(call);
@ -733,7 +733,7 @@ TEST_F(ResolverBuiltinDataTest, FrexpVector) {
}
TEST_F(ResolverBuiltinDataTest, Frexp_Error_FirstParamInt) {
Global("v", ty.i32(), ast::StorageClass::kWorkgroup);
GlobalVar("v", ty.i32(), ast::StorageClass::kWorkgroup);
auto* call = Call("frexp", 1_i, AddressOf("v"));
WrapInFunction(call);
@ -749,7 +749,7 @@ TEST_F(ResolverBuiltinDataTest, Frexp_Error_FirstParamInt) {
}
TEST_F(ResolverBuiltinDataTest, Frexp_Error_SecondParamFloatPtr) {
Global("v", ty.f32(), ast::StorageClass::kWorkgroup);
GlobalVar("v", ty.f32(), ast::StorageClass::kWorkgroup);
auto* call = Call("frexp", 1_f, AddressOf("v"));
WrapInFunction(call);
@ -779,7 +779,7 @@ TEST_F(ResolverBuiltinDataTest, Frexp_Error_SecondParamNotAPointer) {
}
TEST_F(ResolverBuiltinDataTest, Frexp_Error_VectorSizesDontMatch) {
Global("v", ty.vec4<i32>(), ast::StorageClass::kWorkgroup);
GlobalVar("v", ty.vec4<i32>(), ast::StorageClass::kWorkgroup);
auto* call = Call("frexp", vec2<f32>(1_f, 2_f), AddressOf("v"));
WrapInFunction(call);
@ -857,7 +857,7 @@ TEST_F(ResolverBuiltinDataTest, ModfVector) {
}
TEST_F(ResolverBuiltinDataTest, Modf_Error_FirstParamInt) {
Global("whole", ty.f32(), ast::StorageClass::kWorkgroup);
GlobalVar("whole", ty.f32(), ast::StorageClass::kWorkgroup);
auto* call = Call("modf", 1_i, AddressOf("whole"));
WrapInFunction(call);
@ -873,7 +873,7 @@ TEST_F(ResolverBuiltinDataTest, Modf_Error_FirstParamInt) {
}
TEST_F(ResolverBuiltinDataTest, Modf_Error_SecondParamIntPtr) {
Global("whole", ty.i32(), ast::StorageClass::kWorkgroup);
GlobalVar("whole", ty.i32(), ast::StorageClass::kWorkgroup);
auto* call = Call("modf", 1_f, AddressOf("whole"));
WrapInFunction(call);
@ -903,7 +903,7 @@ TEST_F(ResolverBuiltinDataTest, Modf_Error_SecondParamNotAPointer) {
}
TEST_F(ResolverBuiltinDataTest, Modf_Error_VectorSizesDontMatch) {
Global("whole", ty.vec4<f32>(), ast::StorageClass::kWorkgroup);
GlobalVar("whole", ty.vec4<f32>(), ast::StorageClass::kWorkgroup);
auto* call = Call("modf", vec2<f32>(1_f, 2_f), AddressOf("whole"));
WrapInFunction(call);
@ -1512,7 +1512,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverTest,
BuiltinData{"max", BuiltinType::kMax}));
TEST_F(ResolverBuiltinTest, Determinant_2x2) {
Global("var", ty.mat2x2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("var", ty.mat2x2<f32>(), ast::StorageClass::kPrivate);
auto* call = Call("determinant", "var");
WrapInFunction(call);
@ -1524,7 +1524,7 @@ TEST_F(ResolverBuiltinTest, Determinant_2x2) {
}
TEST_F(ResolverBuiltinTest, Determinant_3x3) {
Global("var", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("var", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* call = Call("determinant", "var");
WrapInFunction(call);
@ -1536,7 +1536,7 @@ TEST_F(ResolverBuiltinTest, Determinant_3x3) {
}
TEST_F(ResolverBuiltinTest, Determinant_4x4) {
Global("var", ty.mat4x4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("var", ty.mat4x4<f32>(), ast::StorageClass::kPrivate);
auto* call = Call("determinant", "var");
WrapInFunction(call);
@ -1548,7 +1548,7 @@ TEST_F(ResolverBuiltinTest, Determinant_4x4) {
}
TEST_F(ResolverBuiltinTest, Determinant_NotSquare) {
Global("var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
auto* call = Call("determinant", "var");
WrapInFunction(call);
@ -1563,7 +1563,7 @@ TEST_F(ResolverBuiltinTest, Determinant_NotSquare) {
}
TEST_F(ResolverBuiltinTest, Determinant_NotMatrix) {
Global("var", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("var", ty.f32(), ast::StorageClass::kPrivate);
auto* call = Call("determinant", "var");
WrapInFunction(call);

View File

@ -94,7 +94,7 @@ TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalLet) {
}
TEST_F(ResolverBuiltinValidationTest, BuiltinRedeclaredAsGlobalVar) {
Global(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i), ast::StorageClass::kPrivate);
GlobalVar(Source{{12, 34}}, "mix", ty.i32(), Expr(1_i), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(

View File

@ -92,7 +92,7 @@ using ResolverBuiltinsStageTest = ResolverTestWithParam<Params>;
TEST_P(ResolverBuiltinsStageTest, All_input) {
const Params& params = GetParam();
auto* p = Global("p", ty.vec4<f32>(), ast::StorageClass::kPrivate);
auto* p = GlobalVar("p", ty.vec4<f32>(), ast::StorageClass::kPrivate);
auto* input = Param("input", params.type(*this), {Builtin(Source{{12, 34}}, params.builtin)});
switch (params.stage) {
case ast::PipelineStage::kVertex:

View File

@ -219,7 +219,7 @@ TEST_F(ResolverCallValidationTest, LetPointerPrivate) {
// var c: i32 = foo(p);
// }
Func("foo", {Param("p", ty.pointer<i32>(ast::StorageClass::kPrivate))}, ty.void_(), {});
auto* v = Global("v", ty.i32(), ast::StorageClass::kPrivate);
auto* v = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate);
auto* p = Let("p", ty.pointer(ty.i32(), ast::StorageClass::kPrivate), AddressOf(v));
auto* c = Var("c", ty.i32(), ast::StorageClass::kNone, Call("foo", Expr(Source{{12, 34}}, p)));
Func("main", {}, ty.void_(),
@ -241,7 +241,7 @@ TEST_F(ResolverCallValidationTest, CallVariable) {
// fn f() {
// v();
// }
Global("v", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate);
Func("f", {}, ty.void_(), {CallStmt(Call(Source{{12, 34}}, "v"))});
EXPECT_FALSE(r()->Resolve());

View File

@ -233,7 +233,7 @@ TEST_F(ResolverCompoundAssignmentValidationTest, ReadOnlyBuffer) {
// {
// a += 1i;
// }
Global(Source{{12, 34}}, "a", ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{12, 34}}, "a", ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead,
GroupAndBinding(0, 0));
WrapInFunction(CompoundAssign(Source{{56, 78}}, "a", 1_i, ast::BinaryOp::kAdd));
@ -264,7 +264,7 @@ TEST_F(ResolverCompoundAssignmentValidationTest, LhsLiteral) {
TEST_F(ResolverCompoundAssignmentValidationTest, LhsAtomic) {
// var<workgroup> a : atomic<i32>;
// a += a;
Global(Source{{12, 34}}, "a", ty.atomic(ty.i32()), ast::StorageClass::kWorkgroup);
GlobalVar(Source{{12, 34}}, "a", ty.atomic(ty.i32()), ast::StorageClass::kWorkgroup);
WrapInFunction(CompoundAssign(Source{{56, 78}}, "a", "a", ast::BinaryOp::kAdd));
EXPECT_FALSE(r()->Resolve());

View File

@ -425,7 +425,7 @@ const ast::Node* SymbolTestHelper::Add(SymbolDeclKind kind, Symbol symbol, Sourc
auto& b = *builder;
switch (kind) {
case SymbolDeclKind::GlobalVar:
return b.Global(source, symbol, b.ty.i32(), ast::StorageClass::kPrivate);
return b.GlobalVar(source, symbol, b.ty.i32(), ast::StorageClass::kPrivate);
case SymbolDeclKind::GlobalLet:
return b.GlobalLet(source, symbol, b.ty.i32(), b.Expr(1_i));
case SymbolDeclKind::Alias:
@ -468,42 +468,42 @@ const ast::Node* SymbolTestHelper::Add(SymbolUseKind kind, Symbol symbol, Source
switch (kind) {
case SymbolUseKind::GlobalVarType: {
auto* node = b.ty.type_name(source, symbol);
b.Global(b.Sym(), node, ast::StorageClass::kPrivate);
b.GlobalVar(b.Sym(), node, ast::StorageClass::kPrivate);
return node;
}
case SymbolUseKind::GlobalVarArrayElemType: {
auto* node = b.ty.type_name(source, symbol);
b.Global(b.Sym(), b.ty.array(node, 4_i), ast::StorageClass::kPrivate);
b.GlobalVar(b.Sym(), b.ty.array(node, 4_i), ast::StorageClass::kPrivate);
return node;
}
case SymbolUseKind::GlobalVarArraySizeValue: {
auto* node = b.Expr(source, symbol);
b.Global(b.Sym(), b.ty.array(b.ty.i32(), node), ast::StorageClass::kPrivate);
b.GlobalVar(b.Sym(), b.ty.array(b.ty.i32(), node), ast::StorageClass::kPrivate);
return node;
}
case SymbolUseKind::GlobalVarVectorElemType: {
auto* node = b.ty.type_name(source, symbol);
b.Global(b.Sym(), b.ty.vec3(node), ast::StorageClass::kPrivate);
b.GlobalVar(b.Sym(), b.ty.vec3(node), ast::StorageClass::kPrivate);
return node;
}
case SymbolUseKind::GlobalVarMatrixElemType: {
auto* node = b.ty.type_name(source, symbol);
b.Global(b.Sym(), b.ty.mat3x4(node), ast::StorageClass::kPrivate);
b.GlobalVar(b.Sym(), b.ty.mat3x4(node), ast::StorageClass::kPrivate);
return node;
}
case SymbolUseKind::GlobalVarSampledTexElemType: {
auto* node = b.ty.type_name(source, symbol);
b.Global(b.Sym(), b.ty.sampled_texture(ast::TextureDimension::k2d, node));
b.GlobalVar(b.Sym(), b.ty.sampled_texture(ast::TextureDimension::k2d, node));
return node;
}
case SymbolUseKind::GlobalVarMultisampledTexElemType: {
auto* node = b.ty.type_name(source, symbol);
b.Global(b.Sym(), b.ty.multisampled_texture(ast::TextureDimension::k2d, node));
b.GlobalVar(b.Sym(), b.ty.multisampled_texture(ast::TextureDimension::k2d, node));
return node;
}
case SymbolUseKind::GlobalVarValue: {
auto* node = b.Expr(source, symbol);
b.Global(b.Sym(), b.ty.i32(), ast::StorageClass::kPrivate, node);
b.GlobalVar(b.Sym(), b.ty.i32(), ast::StorageClass::kPrivate, node);
return node;
}
case SymbolUseKind::GlobalLetType: {
@ -722,7 +722,7 @@ TEST_F(ResolverDependencyGraphUsedBeforeDeclTest, VarUsed) {
Block(Assign(Expr(Source{{12, 34}}, "G"), 3.14_f)),
});
Global(Source{{56, 78}}, "G", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
GlobalVar(Source{{56, 78}}, "G", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
Build();
}
@ -772,7 +772,7 @@ using ResolverDependencyGraphDeclSelfUse = ResolverDependencyGraphTest;
TEST_F(ResolverDependencyGraphDeclSelfUse, GlobalVar) {
const Symbol symbol = Sym("SYMBOL");
Global(symbol, ty.i32(), Mul(Expr(Source{{12, 34}}, symbol), 123_i));
GlobalVar(symbol, ty.i32(), Mul(Expr(Source{{12, 34}}, symbol), 123_i));
Build(R"(error: cyclic dependency found: 'SYMBOL' -> 'SYMBOL'
12:34 note: var 'SYMBOL' references var 'SYMBOL' here)");
}
@ -899,7 +899,7 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, Struct_Indirect) {
TEST_F(ResolverDependencyGraphCyclicRefTest, GlobalVar_Direct) {
// var<private> V : i32 = V;
Global(Source{{12, 34}}, "V", ty.i32(), Expr(Source{{56, 78}}, "V"));
GlobalVar(Source{{12, 34}}, "V", ty.i32(), Expr(Source{{56, 78}}, "V"));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -923,9 +923,9 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, GlobalVar_Indirect) {
// 2: var<private> X : i32 = Y;
// 3: var<private> Z : i32 = X;
Global(Source{{1, 1}}, "Y", ty.i32(), Expr(Source{{1, 10}}, "Z"));
Global(Source{{2, 1}}, "X", ty.i32(), Expr(Source{{2, 10}}, "Y"));
Global(Source{{3, 1}}, "Z", ty.i32(), Expr(Source{{3, 10}}, "X"));
GlobalVar(Source{{1, 1}}, "Y", ty.i32(), Expr(Source{{1, 10}}, "Z"));
GlobalVar(Source{{2, 1}}, "X", ty.i32(), Expr(Source{{2, 10}}, "Y"));
GlobalVar(Source{{3, 1}}, "Z", ty.i32(), Expr(Source{{3, 10}}, "X"));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -964,7 +964,7 @@ TEST_F(ResolverDependencyGraphCyclicRefTest, Mixed_RecursiveDependencies) {
{Return(Expr(Source{{1, 10}}, "Z"))});
Alias(Source{{2, 1}}, "A", ty.type_name(Source{{2, 10}}, "S"));
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"));
GlobalVar(Source{{4, 1}}, "Z", nullptr, Expr(Source{{4, 10}}, "L"));
Alias(Source{{5, 1}}, "R", ty.type_name(Source{{5, 10}}, "A"));
GlobalLet(Source{{6, 1}}, "L", ty.type_name(Source{{5, 5}}, "S"), Expr(Source{{5, 10}}, "Z"));
@ -1086,9 +1086,9 @@ TEST_F(ResolverDependencyGraphOrderedGlobalsTest, EnableFirst) {
// Although all enable directives in a valid WGSL program must go before any other global
// declaration, a transform may produce such a AST tree that has some declarations before enable
// nodes. DependencyGraph should deal with these cases.
auto* var_1 = Global("SYMBOL1", ty.i32(), nullptr);
auto* var_1 = GlobalVar("SYMBOL1", ty.i32(), nullptr);
auto* enable_1 = Enable(ast::Extension::kF16);
auto* var_2 = Global("SYMBOL2", ty.f32(), nullptr);
auto* var_2 = GlobalVar("SYMBOL2", ty.f32(), nullptr);
auto* enable_2 = Enable(ast::Extension::kF16);
EXPECT_THAT(AST().GlobalDeclarations(), ElementsAre(var_1, enable_1, var_2, enable_2));
@ -1201,7 +1201,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
const auto type_sym = Sym("TYPE");
const auto func_sym = Sym("FUNC");
const auto* value_decl = Global(value_sym, ty.i32(), ast::StorageClass::kPrivate);
const auto* value_decl = GlobalVar(value_sym, ty.i32(), ast::StorageClass::kPrivate);
const auto* type_decl = Alias(type_sym, ty.i32());
const auto* func_decl = Func(func_sym, {}, ty.void_(), {});
@ -1224,7 +1224,7 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
Alias(Sym(), T);
Structure(Sym(), {Member(Sym(), T)});
Global(Sym(), T, V);
GlobalVar(Sym(), T, V);
GlobalLet(Sym(), T, V);
Func(Sym(), //
{Param(Sym(), T)}, //
@ -1261,23 +1261,23 @@ TEST_F(ResolverDependencyGraphTraversalTest, SymbolsReached) {
Discard(), //
}); //
// Exercise type traversal
Global(Sym(), ty.atomic(T));
Global(Sym(), ty.bool_());
Global(Sym(), ty.i32());
Global(Sym(), ty.u32());
Global(Sym(), ty.f32());
Global(Sym(), ty.array(T, V, 4));
Global(Sym(), ty.vec3(T));
Global(Sym(), ty.mat3x2(T));
Global(Sym(), ty.pointer(T, ast::StorageClass::kPrivate));
Global(Sym(), ty.sampled_texture(ast::TextureDimension::k2d, T));
Global(Sym(), ty.depth_texture(ast::TextureDimension::k2d));
Global(Sym(), ty.depth_multisampled_texture(ast::TextureDimension::k2d));
Global(Sym(), ty.external_texture());
Global(Sym(), ty.multisampled_texture(ast::TextureDimension::k2d, T));
Global(Sym(), ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float,
GlobalVar(Sym(), ty.atomic(T));
GlobalVar(Sym(), ty.bool_());
GlobalVar(Sym(), ty.i32());
GlobalVar(Sym(), ty.u32());
GlobalVar(Sym(), ty.f32());
GlobalVar(Sym(), ty.array(T, V, 4));
GlobalVar(Sym(), ty.vec3(T));
GlobalVar(Sym(), ty.mat3x2(T));
GlobalVar(Sym(), ty.pointer(T, ast::StorageClass::kPrivate));
GlobalVar(Sym(), ty.sampled_texture(ast::TextureDimension::k2d, T));
GlobalVar(Sym(), ty.depth_texture(ast::TextureDimension::k2d));
GlobalVar(Sym(), ty.depth_multisampled_texture(ast::TextureDimension::k2d));
GlobalVar(Sym(), ty.external_texture());
GlobalVar(Sym(), ty.multisampled_texture(ast::TextureDimension::k2d, T));
GlobalVar(Sym(), ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float,
ast::Access::kRead)); //
Global(Sym(), ty.sampler(ast::SamplerKind::kSampler));
GlobalVar(Sym(), ty.sampler(ast::SamplerKind::kSampler));
Func(Sym(), {}, ty.void_(), {});
#undef V
#undef T
@ -1292,7 +1292,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));
GlobalVar("a", nullptr, Expr(1_i));
GlobalLet("b", nullptr, Expr(1_i));
WrapInFunction(Var("c", nullptr, Expr(1_i)), //
Let("d", nullptr, Expr(1_i)));

View File

@ -39,7 +39,7 @@ TEST_F(ResolverFunctionValidationTest, DuplicateParameterName) {
TEST_F(ResolverFunctionValidationTest, ParameterMayShadowGlobal) {
// var<private> common_name : f32;
// fn func(common_name : f32) { }
Global("common_name", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("common_name", ty.f32(), ast::StorageClass::kPrivate);
Func("func", {Param("common_name", ty.f32())}, ty.void_(), {});
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -647,7 +647,7 @@ TEST_F(ResolverFunctionValidationTest, WorkgroupSize_NonConst) {
// var<private> x = 64i;
// @compute @workgroup_size(x)
// fn main() {}
Global("x", ty.i32(), ast::StorageClass::kPrivate, Expr(64_i));
GlobalVar("x", ty.i32(), ast::StorageClass::kPrivate, Expr(64_i));
Func("main", {}, ty.void_(), {},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(Expr(Source{{12, 34}}, "x"))});

View File

@ -26,7 +26,7 @@ using ResolverHostShareableValidationTest = ResolverTest;
TEST_F(ResolverHostShareableValidationTest, BoolMember) {
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.bool_())});
Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -44,7 +44,7 @@ TEST_F(ResolverHostShareableValidationTest, BoolMember) {
TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) {
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.vec3<bool>())});
Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -63,7 +63,7 @@ TEST_F(ResolverHostShareableValidationTest, Aliases) {
auto* a1 = Alias("a1", ty.bool_());
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.Of(a1))});
auto* a2 = Alias("a2", ty.Of(s));
Global(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -85,7 +85,7 @@ TEST_F(ResolverHostShareableValidationTest, NestedStructures) {
auto* s = Structure("S", {Member(Source{{7, 8}}, "m", ty.Of(i3))});
Global(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -123,7 +123,7 @@ TEST_F(ResolverHostShareableValidationTest, NoError) {
auto* s = Structure("S", {Member(Source{{7, 8}}, "m", ty.Of(i3))});
Global(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),

View File

@ -127,7 +127,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, Vector) {
TEST_F(ResolverIncrementDecrementValidationTest, Atomic) {
// var<workgroup> a : atomic<i32>;
// a++;
Global(Source{{12, 34}}, "a", ty.atomic(ty.i32()), ast::StorageClass::kWorkgroup);
GlobalVar(Source{{12, 34}}, "a", ty.atomic(ty.i32()), ast::StorageClass::kWorkgroup);
WrapInFunction(Increment(Expr(Source{{56, 78}}, "a")));
EXPECT_FALSE(r()->Resolve());
@ -187,7 +187,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, ReadOnlyBuffer) {
// {
// a++;
// }
Global(Source{{12, 34}}, "a", ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{12, 34}}, "a", ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead,
GroupAndBinding(0, 0));
WrapInFunction(Increment(Source{{56, 78}}, "a"));

View File

@ -96,7 +96,7 @@ TEST_P(ResolverInferredTypeParamTest, GlobalVar_Pass) {
// var a = <type constructor>;
auto* ctor_expr = params.create_value(*this, 0);
auto* var = Global("a", nullptr, ast::StorageClass::kPrivate, ctor_expr);
auto* var = GlobalVar("a", nullptr, ast::StorageClass::kPrivate, ctor_expr);
WrapInFunction();
EXPECT_TRUE(r()->Resolve()) << r()->error();

View File

@ -726,7 +726,7 @@ TEST_P(MaterializeAbstractNumericToDefaultType, Test) {
{WorkgroupSize(abstract_expr()), Stage(ast::PipelineStage::kCompute)});
break;
case Method::kIndex:
Global("arr", ty.array<i32, 4>(), ast::StorageClass::kPrivate);
GlobalVar("arr", ty.array<i32, 4>(), ast::StorageClass::kPrivate);
WrapInFunction(IndexAccessor("arr", abstract_expr()));
break;
}

View File

@ -59,14 +59,14 @@ TEST_F(ResolverPtrRefTest, DefaultPtrStorageClass) {
auto* buf = Structure("S", {Member("m", ty.i32())});
auto* function = Var("f", ty.i32());
auto* private_ = Global("p", ty.i32(), ast::StorageClass::kPrivate);
auto* workgroup = Global("w", ty.i32(), ast::StorageClass::kWorkgroup);
auto* uniform = Global("ub", ty.Of(buf), ast::StorageClass::kUniform,
auto* private_ = GlobalVar("p", ty.i32(), ast::StorageClass::kPrivate);
auto* workgroup = GlobalVar("w", ty.i32(), ast::StorageClass::kWorkgroup);
auto* uniform = GlobalVar("ub", ty.Of(buf), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
});
auto* storage = Global("sb", ty.Of(buf), ast::StorageClass::kStorage,
auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(0),

View File

@ -54,7 +54,8 @@ TEST_F(ResolverPtrRefValidationTest, AddressOfLet) {
TEST_F(ResolverPtrRefValidationTest, AddressOfHandle) {
// @group(0) @binding(0) var t: texture_3d<f32>;
// &t
Global("t", ty.sampled_texture(ast::TextureDimension::k3d, ty.f32()), GroupAndBinding(0u, 0u));
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k3d, ty.f32()),
GroupAndBinding(0u, 0u));
auto* expr = AddressOf(Expr(Source{{12, 34}}, "t"));
WrapInFunction(expr);
@ -93,7 +94,8 @@ TEST_F(ResolverPtrRefValidationTest, AddressOfVectorComponent_IndexAccessor) {
TEST_F(ResolverPtrRefValidationTest, IndirectOfAddressOfHandle) {
// @group(0) @binding(0) var t: texture_3d<f32>;
// *&t
Global("t", ty.sampled_texture(ast::TextureDimension::k3d, ty.f32()), GroupAndBinding(0u, 0u));
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k3d, ty.f32()),
GroupAndBinding(0u, 0u));
auto* expr = Deref(AddressOf(Expr(Source{{12, 34}}, "t")));
WrapInFunction(expr);
@ -141,7 +143,7 @@ TEST_F(ResolverPtrRefValidationTest, InferredPtrAccessMismatch) {
// }
auto* inner = Structure("Inner", {Member("arr", ty.array<i32, 4>())});
auto* buf = Structure("S", {Member("inner", ty.Of(inner))});
auto* storage = Global("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite,
auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),

View File

@ -316,7 +316,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_Alias) {
TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScope) {
auto* init = Expr(2_i);
Global("my_var", ty.i32(), ast::StorageClass::kPrivate, init);
GlobalVar("my_var", ty.i32(), ast::StorageClass::kPrivate, init);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -424,7 +424,7 @@ TEST_F(ResolverTest, Stmt_VariableDecl_ModuleScopeAfterFunctionScope) {
TEST_F(ResolverTest, ArraySize_UnsignedLiteral) {
// var<private> a : array<f32, 10u>;
auto* a = Global("a", ty.array(ty.f32(), Expr(10_u)), ast::StorageClass::kPrivate);
auto* a = GlobalVar("a", ty.array(ty.f32(), Expr(10_u)), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -437,7 +437,7 @@ TEST_F(ResolverTest, ArraySize_UnsignedLiteral) {
TEST_F(ResolverTest, ArraySize_SignedLiteral) {
// var<private> a : array<f32, 10i>;
auto* a = Global("a", ty.array(ty.f32(), Expr(10_i)), ast::StorageClass::kPrivate);
auto* a = GlobalVar("a", ty.array(ty.f32(), Expr(10_i)), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -452,7 +452,7 @@ TEST_F(ResolverTest, ArraySize_UnsignedConstant) {
// let size = 0u;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(10_u));
auto* a = Global("a", ty.array(ty.f32(), Expr("size")), ast::StorageClass::kPrivate);
auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -467,7 +467,7 @@ TEST_F(ResolverTest, ArraySize_SignedConstant) {
// let size = 0;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(10_i));
auto* a = Global("a", ty.array(ty.f32(), Expr("size")), ast::StorageClass::kPrivate);
auto* a = GlobalVar("a", ty.array(ty.f32(), Expr("size")), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -479,7 +479,7 @@ TEST_F(ResolverTest, ArraySize_SignedConstant) {
}
TEST_F(ResolverTest, Expr_Bitcast) {
Global("name", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("name", ty.f32(), ast::StorageClass::kPrivate);
auto* bitcast = create<ast::BitcastExpression>(ty.f32(), Expr("name"));
WrapInFunction(bitcast);
@ -542,7 +542,7 @@ TEST_F(ResolverTest, Expr_Call_Builtin) {
}
TEST_F(ResolverTest, Expr_Cast) {
Global("name", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("name", ty.f32(), ast::StorageClass::kPrivate);
auto* cast = Construct(ty.f32(), "name");
WrapInFunction(cast);
@ -600,7 +600,7 @@ TEST_F(ResolverTest, Expr_Constructor_Type_Vec4) {
}
TEST_F(ResolverTest, Expr_Identifier_GlobalVariable) {
auto* my_var = Global("my_var", ty.f32(), ast::StorageClass::kPrivate);
auto* my_var = GlobalVar("my_var", ty.f32(), ast::StorageClass::kPrivate);
auto* ident = Expr("my_var");
WrapInFunction(ident);
@ -776,13 +776,14 @@ TEST_F(ResolverTest, Function_Parameters) {
TEST_F(ResolverTest, Function_RegisterInputOutputVariables) {
auto* s = Structure("S", {Member("m", ty.u32())});
auto* sb_var = Global("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
auto* sb_var =
GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
});
auto* wg_var = Global("wg_var", ty.f32(), ast::StorageClass::kWorkgroup);
auto* priv_var = Global("priv_var", ty.f32(), ast::StorageClass::kPrivate);
auto* wg_var = GlobalVar("wg_var", ty.f32(), ast::StorageClass::kWorkgroup);
auto* priv_var = GlobalVar("priv_var", ty.f32(), ast::StorageClass::kPrivate);
auto* func = Func("my_func", {}, ty.void_(),
{
@ -808,13 +809,14 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables) {
TEST_F(ResolverTest, Function_RegisterInputOutputVariables_SubFunction) {
auto* s = Structure("S", {Member("m", ty.u32())});
auto* sb_var = Global("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
auto* sb_var =
GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
});
auto* wg_var = Global("wg_var", ty.f32(), ast::StorageClass::kWorkgroup);
auto* priv_var = Global("priv_var", ty.f32(), ast::StorageClass::kPrivate);
auto* wg_var = GlobalVar("wg_var", ty.f32(), ast::StorageClass::kWorkgroup);
auto* priv_var = GlobalVar("priv_var", ty.f32(), ast::StorageClass::kPrivate);
Func("my_func", {}, ty.f32(),
{Assign("wg_var", "wg_var"), Assign("sb_var", "sb_var"), Assign("priv_var", "priv_var"),
@ -1086,7 +1088,7 @@ TEST_F(ResolverTest, Function_WorkgroupSize_Mixed) {
TEST_F(ResolverTest, Expr_MemberAccessor_Struct) {
auto* st =
Structure("S", {Member("first_member", ty.i32()), Member("second_member", ty.f32())});
Global("my_struct", ty.Of(st), ast::StorageClass::kPrivate);
GlobalVar("my_struct", ty.Of(st), ast::StorageClass::kPrivate);
auto* mem = MemberAccessor("my_struct", "second_member");
WrapInFunction(mem);
@ -1110,7 +1112,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct_Alias) {
auto* st =
Structure("S", {Member("first_member", ty.i32()), Member("second_member", ty.f32())});
auto* alias = Alias("alias", ty.Of(st));
Global("my_struct", ty.Of(alias), ast::StorageClass::kPrivate);
GlobalVar("my_struct", ty.Of(alias), ast::StorageClass::kPrivate);
auto* mem = MemberAccessor("my_struct", "second_member");
WrapInFunction(mem);
@ -1130,7 +1132,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_Struct_Alias) {
}
TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle) {
Global("my_vec", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_vec", ty.vec4<f32>(), ast::StorageClass::kPrivate);
auto* mem = MemberAccessor("my_vec", "xzyw");
WrapInFunction(mem);
@ -1148,7 +1150,7 @@ TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle) {
}
TEST_F(ResolverTest, Expr_MemberAccessor_VectorSwizzle_SingleElement) {
Global("my_vec", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_vec", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* mem = MemberAccessor("my_vec", "b");
WrapInFunction(mem);
@ -1184,7 +1186,7 @@ TEST_F(ResolverTest, Expr_Accessor_MultiLevel) {
auto* stB = Structure("B", {Member("foo", ty.vec4<f32>())});
auto* stA = Structure("A", {Member("mem", ty.array(ty.Of(stB), 3_i))});
Global("c", ty.Of(stA), ast::StorageClass::kPrivate);
GlobalVar("c", ty.Of(stA), ast::StorageClass::kPrivate);
auto* mem =
MemberAccessor(MemberAccessor(IndexAccessor(MemberAccessor("c", "mem"), 0_i), "foo"), "yx");
@ -1202,7 +1204,7 @@ TEST_F(ResolverTest, Expr_Accessor_MultiLevel) {
TEST_F(ResolverTest, Expr_MemberAccessor_InBinaryOp) {
auto* st =
Structure("S", {Member("first_member", ty.f32()), Member("second_member", ty.f32())});
Global("my_struct", ty.Of(st), ast::StorageClass::kPrivate);
GlobalVar("my_struct", ty.Of(st), ast::StorageClass::kPrivate);
auto* expr = Add(MemberAccessor("my_struct", "first_member"),
MemberAccessor("my_struct", "second_member"));
@ -1505,8 +1507,8 @@ TEST_P(Expr_Binary_Test_Valid, All) {
ss << FriendlyName(lhs_type) << " " << params.op << " " << FriendlyName(rhs_type);
SCOPED_TRACE(ss.str());
Global("lhs", lhs_type, ast::StorageClass::kPrivate);
Global("rhs", rhs_type, ast::StorageClass::kPrivate);
GlobalVar("lhs", lhs_type, ast::StorageClass::kPrivate);
GlobalVar("rhs", rhs_type, ast::StorageClass::kPrivate);
auto* expr = create<ast::BinaryExpression>(params.op, Expr("lhs"), Expr("rhs"));
WrapInFunction(expr);
@ -1540,8 +1542,8 @@ TEST_P(Expr_Binary_Test_WithAlias_Valid, All) {
<< FriendlyName(rhs_type);
SCOPED_TRACE(ss.str());
Global("lhs", lhs_type, ast::StorageClass::kPrivate);
Global("rhs", rhs_type, ast::StorageClass::kPrivate);
GlobalVar("lhs", lhs_type, ast::StorageClass::kPrivate);
GlobalVar("rhs", rhs_type, ast::StorageClass::kPrivate);
auto* expr = create<ast::BinaryExpression>(params.op, Expr("lhs"), Expr("rhs"));
WrapInFunction(expr);
@ -1586,8 +1588,8 @@ TEST_P(Expr_Binary_Test_Invalid, All) {
ss << FriendlyName(lhs_type) << " " << op << " " << FriendlyName(rhs_type);
SCOPED_TRACE(ss.str());
Global("lhs", lhs_type, ast::StorageClass::kPrivate);
Global("rhs", rhs_type, ast::StorageClass::kPrivate);
GlobalVar("lhs", lhs_type, ast::StorageClass::kPrivate);
GlobalVar("rhs", rhs_type, ast::StorageClass::kPrivate);
auto* expr = create<ast::BinaryExpression>(Source{{12, 34}}, op, Expr("lhs"), Expr("rhs"));
WrapInFunction(expr);
@ -1626,8 +1628,8 @@ TEST_P(Expr_Binary_Test_Invalid_VectorMatrixMultiply, All) {
is_valid_expr = vec_size == mat_cols;
}
Global("lhs", lhs_type, ast::StorageClass::kPrivate);
Global("rhs", rhs_type, ast::StorageClass::kPrivate);
GlobalVar("lhs", lhs_type, ast::StorageClass::kPrivate);
GlobalVar("rhs", rhs_type, ast::StorageClass::kPrivate);
auto* expr = Mul(Source{{12, 34}}, Expr("lhs"), Expr("rhs"));
WrapInFunction(expr);
@ -1663,8 +1665,8 @@ TEST_P(Expr_Binary_Test_Invalid_MatrixMatrixMultiply, All) {
auto* col = create<sem::Vector>(f32, lhs_mat_rows);
auto* result_type = create<sem::Matrix>(col, rhs_mat_cols);
Global("lhs", lhs_type, ast::StorageClass::kPrivate);
Global("rhs", rhs_type, ast::StorageClass::kPrivate);
GlobalVar("lhs", lhs_type, ast::StorageClass::kPrivate);
GlobalVar("rhs", rhs_type, ast::StorageClass::kPrivate);
auto* expr = Mul(Source{{12, 34}}, Expr("lhs"), Expr("rhs"));
WrapInFunction(expr);
@ -1692,11 +1694,11 @@ TEST_P(UnaryOpExpressionTest, Expr_UnaryOp) {
auto op = GetParam();
if (op == ast::UnaryOp::kNot) {
Global("ident", ty.vec4<bool>(), ast::StorageClass::kPrivate);
GlobalVar("ident", ty.vec4<bool>(), ast::StorageClass::kPrivate);
} else if (op == ast::UnaryOp::kNegation || op == ast::UnaryOp::kComplement) {
Global("ident", ty.vec4<i32>(), ast::StorageClass::kPrivate);
GlobalVar("ident", ty.vec4<i32>(), ast::StorageClass::kPrivate);
} else {
Global("ident", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("ident", ty.vec4<f32>(), ast::StorageClass::kPrivate);
}
auto* der = create<ast::UnaryOpExpression>(op, Expr("ident"));
WrapInFunction(der);
@ -1733,7 +1735,7 @@ TEST_F(ResolverTest, StorageClass_SetsIfMissing) {
TEST_F(ResolverTest, StorageClass_SetForSampler) {
auto* t = ty.sampler(ast::SamplerKind::kSampler);
auto* var = Global("var", t,
auto* var = GlobalVar("var", t,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -1746,7 +1748,7 @@ TEST_F(ResolverTest, StorageClass_SetForSampler) {
TEST_F(ResolverTest, StorageClass_SetForTexture) {
auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
auto* var = Global("var", t,
auto* var = GlobalVar("var", t,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -1771,7 +1773,7 @@ TEST_F(ResolverTest, Access_SetForStorageBuffer) {
// struct S { x : i32 };
// var<storage> g : S;
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())});
auto* var = Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage,
auto* var = GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -1785,10 +1787,10 @@ TEST_F(ResolverTest, Access_SetForStorageBuffer) {
TEST_F(ResolverTest, BindingPoint_SetForResources) {
// @group(1) @binding(2) var s1 : sampler;
// @group(3) @binding(4) var s2 : sampler;
auto* s1 = Global(
auto* s1 = GlobalVar(
Sym(), ty.sampler(ast::SamplerKind::kSampler),
ast::AttributeList{create<ast::GroupAttribute>(1), create<ast::BindingAttribute>(2)});
auto* s2 = Global(
auto* s2 = GlobalVar(
Sym(), ty.sampler(ast::SamplerKind::kSampler),
ast::AttributeList{create<ast::GroupAttribute>(3), create<ast::BindingAttribute>(4)});
@ -1811,11 +1813,11 @@ TEST_F(ResolverTest, Function_EntryPoints_StageAttribute) {
// ep_1 -> {}
// ep_2 -> {}
Global("first", ty.f32(), ast::StorageClass::kPrivate);
Global("second", ty.f32(), ast::StorageClass::kPrivate);
Global("call_a", ty.f32(), ast::StorageClass::kPrivate);
Global("call_b", ty.f32(), ast::StorageClass::kPrivate);
Global("call_c", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("first", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("second", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("call_a", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("call_b", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("call_c", ty.f32(), ast::StorageClass::kPrivate);
auto* func_b = Func("b", {}, ty.f32(),
{
@ -1955,8 +1957,8 @@ TEST_F(ResolverTest, ASTNodeReachedTwice) {
{
ProgramBuilder b;
auto* expr = b.Expr(1_i);
b.Global("a", b.ty.i32(), ast::StorageClass::kPrivate, expr);
b.Global("b", b.ty.i32(), ast::StorageClass::kPrivate, expr);
b.GlobalVar("a", b.ty.i32(), ast::StorageClass::kPrivate, expr);
b.GlobalVar("b", b.ty.i32(), ast::StorageClass::kPrivate, expr);
Resolver(&b).Resolve();
},
"internal compiler error: AST node 'tint::ast::IntLiteralExpression' was encountered twice "
@ -1964,7 +1966,7 @@ TEST_F(ResolverTest, ASTNodeReachedTwice) {
}
TEST_F(ResolverTest, UnaryOp_Not) {
Global("ident", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("ident", ty.vec4<f32>(), ast::StorageClass::kPrivate);
auto* der = create<ast::UnaryOpExpression>(ast::UnaryOp::kNot, Expr(Source{{12, 34}}, "ident"));
WrapInFunction(der);
@ -1973,7 +1975,7 @@ TEST_F(ResolverTest, UnaryOp_Not) {
}
TEST_F(ResolverTest, UnaryOp_Complement) {
Global("ident", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("ident", ty.vec4<f32>(), ast::StorageClass::kPrivate);
auto* der =
create<ast::UnaryOpExpression>(ast::UnaryOp::kComplement, Expr(Source{{12, 34}}, "ident"));
WrapInFunction(der);
@ -1983,7 +1985,7 @@ TEST_F(ResolverTest, UnaryOp_Complement) {
}
TEST_F(ResolverTest, UnaryOp_Negation) {
Global("ident", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("ident", ty.u32(), ast::StorageClass::kPrivate);
auto* der =
create<ast::UnaryOpExpression>(ast::UnaryOp::kNegation, Expr(Source{{12, 34}}, "ident"));
WrapInFunction(der);
@ -1993,8 +1995,8 @@ TEST_F(ResolverTest, UnaryOp_Negation) {
}
TEST_F(ResolverTest, TextureSampler_TextureSample) {
Global("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
auto* call = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1_f, 2_f)));
const ast::Function* f =
@ -2010,8 +2012,8 @@ TEST_F(ResolverTest, TextureSampler_TextureSample) {
}
TEST_F(ResolverTest, TextureSampler_TextureSampleInFunction) {
Global("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
auto* inner_call = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1_f, 2_f)));
const ast::Function* inner_func = Func("inner_func", {}, ty.void_(), {inner_call});
@ -2033,8 +2035,8 @@ TEST_F(ResolverTest, TextureSampler_TextureSampleInFunction) {
}
TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondSameVariables) {
Global("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 2));
auto* inner_call_1 = CallStmt(Call("textureSample", "t", "s", vec2<f32>(1_f, 2_f)));
const ast::Function* inner_func_1 = Func("inner_func_1", {}, ty.void_(), {inner_call_1});
@ -2065,9 +2067,11 @@ TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondSameVariables) {
}
TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondDifferentVariables) {
Global("t1", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 1));
Global("t2", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 2));
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 3));
GlobalVar("t1", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
GroupAndBinding(1, 1));
GlobalVar("t2", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
GroupAndBinding(1, 2));
GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(1, 3));
auto* inner_call_1 = CallStmt(Call("textureSample", "t1", "s", vec2<f32>(1_f, 2_f)));
const ast::Function* inner_func_1 = Func("inner_func_1", {}, ty.void_(), {inner_call_1});
@ -2100,7 +2104,7 @@ TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondDifferentVariabl
}
TEST_F(ResolverTest, TextureSampler_TextureDimensions) {
Global("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 2));
GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), GroupAndBinding(1, 2));
auto* call = Call("textureDimensions", "t");
const ast::Function* f = WrapInFunction(call);
@ -2116,15 +2120,15 @@ TEST_F(ResolverTest, TextureSampler_TextureDimensions) {
TEST_F(ResolverTest, ModuleDependencyOrderedDeclarations) {
auto* f0 = Func("f0", {}, ty.void_(), {});
auto* v0 = Global("v0", ty.i32(), ast::StorageClass::kPrivate);
auto* v0 = GlobalVar("v0", ty.i32(), ast::StorageClass::kPrivate);
auto* a0 = Alias("a0", ty.i32());
auto* s0 = Structure("s0", {Member("m", ty.i32())});
auto* f1 = Func("f1", {}, ty.void_(), {});
auto* v1 = Global("v1", ty.i32(), ast::StorageClass::kPrivate);
auto* v1 = GlobalVar("v1", ty.i32(), ast::StorageClass::kPrivate);
auto* a1 = Alias("a1", ty.i32());
auto* s1 = Structure("s1", {Member("m", ty.i32())});
auto* f2 = Func("f2", {}, ty.void_(), {});
auto* v2 = Global("v2", ty.i32(), ast::StorageClass::kPrivate);
auto* v2 = GlobalVar("v2", ty.i32(), ast::StorageClass::kPrivate);
auto* a2 = Alias("a2", ty.i32());
auto* s2 = Structure("s2", {Member("m", ty.i32())});

View File

@ -519,7 +519,7 @@ struct DataType<ptr<T>> {
/// @return a new AST expression of the alias type
static inline const ast::Expression* Expr(ProgramBuilder& b, double /*unused*/) {
auto sym = b.Symbols().New("global_for_ptr");
b.Global(sym, DataType<T>::AST(b), ast::StorageClass::kPrivate);
b.GlobalVar(sym, DataType<T>::AST(b), ast::StorageClass::kPrivate);
return b.AddressOf(sym);
}
/// @returns the WGSL name for the type

View File

@ -29,7 +29,7 @@ struct SideEffectsTest : ResolverTest {
template <typename T>
void MakeSideEffectFunc(const char* name) {
auto global = Sym();
Global(global, ty.Of<T>(), ast::StorageClass::kPrivate);
GlobalVar(global, ty.Of<T>(), ast::StorageClass::kPrivate);
auto local = Sym();
Func(name, {}, ty.Of<T>(),
{
@ -42,7 +42,7 @@ struct SideEffectsTest : ResolverTest {
template <typename MAKE_TYPE_FUNC>
void MakeSideEffectFunc(const char* name, MAKE_TYPE_FUNC make_type) {
auto global = Sym();
Global(global, make_type(), ast::StorageClass::kPrivate);
GlobalVar(global, make_type(), ast::StorageClass::kPrivate);
auto local = Sym();
Func(name, {}, make_type(),
{
@ -87,7 +87,7 @@ TEST_F(SideEffectsTest, VariableUser) {
}
TEST_F(SideEffectsTest, Call_Builtin_NoSE) {
Global("a", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate);
auto* expr = Call("dpdx", "a");
Func("f", {}, ty.void_(), {Ignore(expr)},
{create<ast::StageAttribute>(ast::PipelineStage::kFragment)});
@ -113,7 +113,7 @@ TEST_F(SideEffectsTest, Call_Builtin_NoSE_WithSEArg) {
}
TEST_F(SideEffectsTest, Call_Builtin_SE) {
Global("a", ty.atomic(ty.i32()), ast::StorageClass::kWorkgroup);
GlobalVar("a", ty.atomic(ty.i32()), ast::StorageClass::kWorkgroup);
auto* expr = Call("atomicAdd", AddressOf("a"), 1_i);
WrapInFunction(expr);

View File

@ -26,7 +26,7 @@ namespace {
class ResolverSourceVariableTest : public ResolverTest {};
TEST_F(ResolverSourceVariableTest, GlobalPrivateVar) {
auto* a = Global("a", ty.f32(), ast::StorageClass::kPrivate);
auto* a = GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate);
auto* expr = Expr(a);
WrapInFunction(expr);
@ -37,7 +37,7 @@ TEST_F(ResolverSourceVariableTest, GlobalPrivateVar) {
}
TEST_F(ResolverSourceVariableTest, GlobalWorkgroupVar) {
auto* a = Global("a", ty.f32(), ast::StorageClass::kWorkgroup);
auto* a = GlobalVar("a", ty.f32(), ast::StorageClass::kWorkgroup);
auto* expr = Expr(a);
WrapInFunction(expr);
@ -48,7 +48,7 @@ TEST_F(ResolverSourceVariableTest, GlobalWorkgroupVar) {
}
TEST_F(ResolverSourceVariableTest, GlobalStorageVar) {
auto* a = Global("a", ty.f32(), ast::StorageClass::kStorage, GroupAndBinding(0, 0));
auto* a = GlobalVar("a", ty.f32(), ast::StorageClass::kStorage, GroupAndBinding(0, 0));
auto* expr = Expr(a);
WrapInFunction(expr);
@ -59,7 +59,7 @@ TEST_F(ResolverSourceVariableTest, GlobalStorageVar) {
}
TEST_F(ResolverSourceVariableTest, GlobalUniformVar) {
auto* a = Global("a", ty.f32(), ast::StorageClass::kUniform, GroupAndBinding(0, 0));
auto* a = GlobalVar("a", ty.f32(), ast::StorageClass::kUniform, GroupAndBinding(0, 0));
auto* expr = Expr(a);
WrapInFunction(expr);
@ -70,7 +70,7 @@ TEST_F(ResolverSourceVariableTest, GlobalUniformVar) {
}
TEST_F(ResolverSourceVariableTest, GlobalTextureVar) {
auto* a = Global("a", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
auto* a = GlobalVar("a", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
ast::StorageClass::kNone, GroupAndBinding(0, 0));
auto* expr = Expr(a);
WrapInFunction(Call("textureDimensions", expr));
@ -197,7 +197,7 @@ TEST_F(ResolverSourceVariableTest, ThroughIndexAccessor) {
// {
// a[2i]
// }
auto* a = Global("a", ty.array(ty.f32(), 4_u), ast::StorageClass::kPrivate);
auto* a = GlobalVar("a", ty.array(ty.f32(), 4_u), ast::StorageClass::kPrivate);
auto* expr = IndexAccessor(a, 2_i);
WrapInFunction(expr);
@ -214,7 +214,7 @@ TEST_F(ResolverSourceVariableTest, ThroughMemberAccessor) {
// a.f
// }
auto* S = Structure("S", {Member("f", ty.f32())});
auto* a = Global("a", ty.Of(S), ast::StorageClass::kPrivate);
auto* a = GlobalVar("a", ty.Of(S), ast::StorageClass::kPrivate);
auto* expr = MemberAccessor(a, "f");
WrapInFunction(expr);
@ -230,7 +230,7 @@ TEST_F(ResolverSourceVariableTest, ThroughPointers) {
// let a_ptr1 = &*&a;
// let a_ptr2 = &*a_ptr1;
// }
auto* a = Global("a", ty.f32(), ast::StorageClass::kPrivate);
auto* a = GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate);
auto* address_of_1 = AddressOf(a);
auto* deref_1 = Deref(address_of_1);
auto* address_of_2 = AddressOf(deref_1);

View File

@ -37,7 +37,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, StorageBuffer_UnalignedMember)
{Member("a", ty.f32(), {MemberSize(5)}),
Member(Source{{34, 56}}, "b", ty.f32(), {MemberAlign(1)})});
Global(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage,
GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage,
GroupAndBinding(0, 0));
ASSERT_FALSE(r()->Resolve());
@ -65,7 +65,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, StorageBuffer_UnalignedMember_S
{Member("a", ty.f32(), {MemberSize(5)}),
Member(Source{{34, 56}}, "b", ty.f32(), {MemberAlign(4)})});
Global(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage,
GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage,
GroupAndBinding(0, 0));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -93,7 +93,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_UnalignedMember_S
Member(Source{{56, 78}}, "inner", ty.type_name("Inner")),
});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GroupAndBinding(0, 0));
ASSERT_FALSE(r()->Resolve());
@ -134,7 +134,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
Member(Source{{56, 78}}, "inner", ty.type_name("Inner"), {MemberAlign(16)}),
});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GroupAndBinding(0, 0));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -159,7 +159,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_UnalignedMember_A
Member(Source{{56, 78}}, "inner", ty.type_name("Inner")),
});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GroupAndBinding(0, 0));
ASSERT_FALSE(r()->Resolve());
@ -192,7 +192,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_UnalignedMember_A
Member(Source{{34, 56}}, "inner", ty.type_name("Inner"), {MemberAlign(16)}),
});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GroupAndBinding(0, 0));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -222,7 +222,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_MembersOffsetNotM
Member(Source{{78, 90}}, "scalar", ty.i32()),
});
Global(Source{{22, 24}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GlobalVar(Source{{22, 24}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GroupAndBinding(0, 0));
ASSERT_FALSE(r()->Resolve());
@ -274,7 +274,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
Member(Source{{78, 90}}, "scalar", ty.i32()),
});
Global(Source{{22, 24}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GlobalVar(Source{{22, 24}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GroupAndBinding(0, 0));
ASSERT_FALSE(r()->Resolve());
@ -320,7 +320,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest,
Member(Source{{78, 90}}, "scalar", ty.i32(), {MemberAlign(16)}),
});
Global(Source{{22, 34}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GlobalVar(Source{{22, 34}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GroupAndBinding(0, 0));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -341,7 +341,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_Vec3MemberOffset_
Member("s", ty.f32()),
});
Global(Source{{78, 90}}, "a", ty.type_name("ScalarPackedAtEndOfVec3"),
GlobalVar(Source{{78, 90}}, "a", ty.type_name("ScalarPackedAtEndOfVec3"),
ast::StorageClass::kUniform, GroupAndBinding(0, 0));
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -367,7 +367,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
Member("scalar", ty.i32()),
});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GroupAndBinding(0, 0));
ASSERT_FALSE(r()->Resolve());
@ -401,7 +401,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
Member("scalar", ty.i32()),
});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GroupAndBinding(0, 0));
ASSERT_FALSE(r()->Resolve());
@ -444,7 +444,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
Member("scalar", ty.i32()),
});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GroupAndBinding(0, 0));
ASSERT_FALSE(r()->Resolve());
@ -462,7 +462,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStride_TopLevelArray) {
// @group(0) @binding(0)
// var<uniform> a : array<f32, 4u>;
Global(Source{{78, 90}}, "a", ty.array(Source{{34, 56}}, ty.f32(), 4_u),
GlobalVar(Source{{78, 90}}, "a", ty.array(Source{{34, 56}}, ty.f32(), 4_u),
ast::StorageClass::kUniform, GroupAndBinding(0, 0));
ASSERT_FALSE(r()->Resolve());
@ -484,7 +484,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
Member("inner", ty.array(Source{{34, 56}}, ty.array(ty.f32(), 4_u), 4_u)),
});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GroupAndBinding(0, 0));
ASSERT_FALSE(r()->Resolve());
@ -517,7 +517,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid
Member("scalar", ty.i32()),
});
Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform,
GroupAndBinding(0, 0));
ASSERT_TRUE(r()->Resolve()) << r()->error();

View File

@ -27,7 +27,7 @@ using ResolverStorageClassValidationTest = ResolverTest;
TEST_F(ResolverStorageClassValidationTest, GlobalVariableNoStorageClass_Fail) {
// var g : f32;
Global(Source{{12, 34}}, "g", ty.f32(), ast::StorageClass::kNone);
GlobalVar(Source{{12, 34}}, "g", ty.f32(), ast::StorageClass::kNone);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -36,7 +36,7 @@ TEST_F(ResolverStorageClassValidationTest, GlobalVariableNoStorageClass_Fail) {
TEST_F(ResolverStorageClassValidationTest, GlobalVariableFunctionStorageClass_Fail) {
// var<function> g : f32;
Global(Source{{12, 34}}, "g", ty.f32(), ast::StorageClass::kFunction);
GlobalVar(Source{{12, 34}}, "g", ty.f32(), ast::StorageClass::kFunction);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -44,7 +44,7 @@ TEST_F(ResolverStorageClassValidationTest, GlobalVariableFunctionStorageClass_Fa
}
TEST_F(ResolverStorageClassValidationTest, Private_RuntimeArray) {
Global(Source{{12, 34}}, "v", ty.array(ty.i32()), ast::StorageClass::kPrivate);
GlobalVar(Source{{12, 34}}, "v", ty.array(ty.i32()), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -54,7 +54,7 @@ TEST_F(ResolverStorageClassValidationTest, Private_RuntimeArray) {
TEST_F(ResolverStorageClassValidationTest, Private_RuntimeArrayInStruct) {
auto* s = Structure("S", {Member("m", ty.array(ty.i32()))});
Global(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kPrivate);
GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -64,7 +64,7 @@ note: while analysing structure member S.m
}
TEST_F(ResolverStorageClassValidationTest, Workgroup_RuntimeArray) {
Global(Source{{12, 34}}, "v", ty.array(ty.i32()), ast::StorageClass::kWorkgroup);
GlobalVar(Source{{12, 34}}, "v", ty.array(ty.i32()), ast::StorageClass::kWorkgroup);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -74,7 +74,7 @@ TEST_F(ResolverStorageClassValidationTest, Workgroup_RuntimeArray) {
TEST_F(ResolverStorageClassValidationTest, Workgroup_RuntimeArrayInStruct) {
auto* s = Structure("S", {Member("m", ty.array(ty.i32()))});
Global(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kWorkgroup);
GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kWorkgroup);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -85,7 +85,7 @@ note: while analysing structure member S.m
TEST_F(ResolverStorageClassValidationTest, StorageBufferBool) {
// var<storage> g : bool;
Global(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kStorage,
GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kStorage,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -101,7 +101,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferBool) {
TEST_F(ResolverStorageClassValidationTest, StorageBufferPointer) {
// var<storage> g : ptr<private, f32>;
Global(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate),
GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate),
ast::StorageClass::kStorage,
ast::AttributeList{
create<ast::BindingAttribute>(0),
@ -118,7 +118,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferPointer) {
TEST_F(ResolverStorageClassValidationTest, StorageBufferIntScalar) {
// var<storage> g : i32;
Global(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kStorage,
GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kStorage,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -129,7 +129,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferIntScalar) {
TEST_F(ResolverStorageClassValidationTest, StorageBufferVector) {
// var<storage> g : vec4<f32>;
Global(Source{{56, 78}}, "g", ty.vec4<f32>(), ast::StorageClass::kStorage,
GlobalVar(Source{{56, 78}}, "g", ty.vec4<f32>(), ast::StorageClass::kStorage,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -142,7 +142,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferArray) {
// var<storage, read> g : array<S, 3u>;
auto* s = Structure("S", {Member("a", ty.f32())});
auto* a = ty.array(ty.Of(s), 3_u);
Global(Source{{56, 78}}, "g", a, ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -155,7 +155,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferBoolAlias) {
// type a = bool;
// var<storage, read> g : a;
auto* a = Alias("a", ty.bool_());
Global(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kStorage,
GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kStorage,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -171,7 +171,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferBoolAlias) {
TEST_F(ResolverStorageClassValidationTest, NotStorage_AccessMode) {
// var<private, read> g : a;
Global(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kPrivate, ast::Access::kRead);
GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kPrivate, ast::Access::kRead);
ASSERT_FALSE(r()->Resolve());
@ -184,7 +184,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Basic) {
// struct S { x : i32 };
// var<storage, read> g : S;
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())});
Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -200,7 +200,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Aliases) {
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())});
auto* a1 = Alias("a1", ty.Of(s));
auto* a2 = Alias("a2", ty.Of(a1));
Global(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -215,7 +215,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBuffer_Struct_Runtime) {
auto* s = Structure(Source{{12, 34}}, "S", {Member("m", ty.array<i32>())});
Global(Source{{56, 78}}, "svar", ty.Of(s), ast::StorageClass::kUniform,
GlobalVar(Source{{56, 78}}, "svar", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -230,7 +230,7 @@ note: while analysing structure member S.m
TEST_F(ResolverStorageClassValidationTest, UniformBufferBool) {
// var<uniform> g : bool;
Global(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kUniform,
GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -246,7 +246,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferBool) {
TEST_F(ResolverStorageClassValidationTest, UniformBufferPointer) {
// var<uniform> g : ptr<private, f32>;
Global(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate),
GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate),
ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
@ -263,7 +263,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferPointer) {
TEST_F(ResolverStorageClassValidationTest, UniformBufferIntScalar) {
// var<uniform> g : i32;
Global(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kUniform,
GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -274,7 +274,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferIntScalar) {
TEST_F(ResolverStorageClassValidationTest, UniformBufferVector) {
// var<uniform> g : vec4<f32>;
Global(Source{{56, 78}}, "g", ty.vec4<f32>(), ast::StorageClass::kUniform,
GlobalVar(Source{{56, 78}}, "g", ty.vec4<f32>(), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -290,7 +290,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferArray) {
// var<uniform> g : array<S, 3u>;
auto* s = Structure("S", {Member("a", ty.f32(), {MemberSize(16)})});
auto* a = ty.array(ty.Of(s), 3_u);
Global(Source{{56, 78}}, "g", a, ast::StorageClass::kUniform,
GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -303,7 +303,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferBoolAlias) {
// type a = bool;
// var<uniform> g : a;
auto* a = Alias("a", ty.bool_());
Global(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kUniform,
GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -321,7 +321,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Basic) {
// struct S { x : i32 };
// var<uniform> g : S;
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())});
Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kUniform,
GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -336,7 +336,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Aliases) {
// var<uniform> g : a1;
auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())});
auto* a1 = Alias("a1", ty.Of(s));
Global(Source{{56, 78}}, "g", ty.Of(a1), ast::StorageClass::kUniform,
GlobalVar(Source{{56, 78}}, "g", ty.Of(a1), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),

View File

@ -64,7 +64,7 @@ TEST_F(ResolverStorageClassUseTest, StructReachableFromReturnType) {
TEST_F(ResolverStorageClassUseTest, StructReachableFromGlobal) {
auto* s = Structure("S", {Member("a", ty.f32())});
Global("g", ty.Of(s), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(s), ast::StorageClass::kPrivate);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -76,7 +76,7 @@ TEST_F(ResolverStorageClassUseTest, StructReachableFromGlobal) {
TEST_F(ResolverStorageClassUseTest, StructReachableViaGlobalAlias) {
auto* s = Structure("S", {Member("a", ty.f32())});
auto* a = Alias("A", ty.Of(s));
Global("g", ty.Of(a), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(a), ast::StorageClass::kPrivate);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -88,7 +88,7 @@ TEST_F(ResolverStorageClassUseTest, StructReachableViaGlobalAlias) {
TEST_F(ResolverStorageClassUseTest, StructReachableViaGlobalStruct) {
auto* s = Structure("S", {Member("a", ty.f32())});
auto* o = Structure("O", {Member("a", ty.Of(s))});
Global("g", ty.Of(o), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(o), ast::StorageClass::kPrivate);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -100,7 +100,7 @@ TEST_F(ResolverStorageClassUseTest, StructReachableViaGlobalStruct) {
TEST_F(ResolverStorageClassUseTest, StructReachableViaGlobalArray) {
auto* s = Structure("S", {Member("a", ty.f32())});
auto* a = ty.array(ty.Of(s), 3_u);
Global("g", a, ast::StorageClass::kPrivate);
GlobalVar("g", a, ast::StorageClass::kPrivate);
ASSERT_TRUE(r()->Resolve()) << r()->error();
@ -159,12 +159,12 @@ TEST_F(ResolverStorageClassUseTest, StructReachableViaLocalArray) {
TEST_F(ResolverStorageClassUseTest, StructMultipleStorageClassUses) {
auto* s = Structure("S", {Member("a", ty.f32())});
Global("x", ty.Of(s), ast::StorageClass::kUniform,
GlobalVar("x", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
});
Global("y", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("y", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(0),

View File

@ -1591,7 +1591,7 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_NestedVectorConst
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vector_Alias_Argument_Error) {
auto* alias = Alias("UnsignedInt", ty.u32());
Global("uint_var", ty.Of(alias), ast::StorageClass::kPrivate);
GlobalVar("uint_var", ty.Of(alias), ast::StorageClass::kPrivate);
auto* tc = Construct(Source{{12, 34}}, ty.vec2<f32>(), "uint_var");
WrapInFunction(tc);
@ -1603,8 +1603,8 @@ TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vector_Alias_Argu
TEST_F(ResolverTypeConstructorValidationTest, Expr_Constructor_Vector_Alias_Argument_Success) {
auto* f32_alias = Alias("Float32", ty.f32());
auto* vec2_alias = Alias("VectorFloat2", ty.vec2<f32>());
Global("my_f32", ty.Of(f32_alias), ast::StorageClass::kPrivate);
Global("my_vec2", ty.Of(vec2_alias), ast::StorageClass::kPrivate);
GlobalVar("my_f32", ty.Of(f32_alias), ast::StorageClass::kPrivate);
GlobalVar("my_vec2", ty.Of(vec2_alias), ast::StorageClass::kPrivate);
auto* tc = vec3<f32>("my_vec2", "my_f32");
WrapInFunction(tc);

View File

@ -82,7 +82,7 @@ TEST_F(ResolverTypeValidationTest, GlobalOverrideNoConstructor_Pass) {
TEST_F(ResolverTypeValidationTest, GlobalVariableWithStorageClass_Pass) {
// var<private> global_var: f32;
Global(Source{{12, 34}}, "global_var", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar(Source{{12, 34}}, "global_var", ty.f32(), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@ -98,9 +98,9 @@ TEST_F(ResolverTypeValidationTest, GlobalVariableUnique_Pass) {
// var global_var0 : f32 = 0.1;
// var global_var1 : i32 = 0;
Global("global_var0", ty.f32(), ast::StorageClass::kPrivate, Expr(0.1_f));
GlobalVar("global_var0", ty.f32(), ast::StorageClass::kPrivate, Expr(0.1_f));
Global(Source{{12, 34}}, "global_var1", ty.f32(), ast::StorageClass::kPrivate, Expr(1_f));
GlobalVar(Source{{12, 34}}, "global_var1", ty.f32(), ast::StorageClass::kPrivate, Expr(1_f));
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@ -116,7 +116,7 @@ TEST_F(ResolverTypeValidationTest, GlobalVariableFunctionVariableNotUnique_Pass)
Decl(Var("a", ty.f32(), ast::StorageClass::kNone, Expr(2_f))),
});
Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@ -180,19 +180,19 @@ TEST_F(ResolverTypeValidationTest, RedeclaredIdentifierDifferentFunctions_Pass)
TEST_F(ResolverTypeValidationTest, ArraySize_AIntLiteral_Pass) {
// var<private> a : array<f32, 4>;
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_a)), ast::StorageClass::kPrivate);
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_a)), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLiteral_Pass) {
// var<private> a : array<f32, 4u>;
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_u)), ast::StorageClass::kPrivate);
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_u)), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Pass) {
// var<private> a : array<f32, 4i>;
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_i)), ast::StorageClass::kPrivate);
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 4_i)), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@ -200,7 +200,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLet_Pass) {
// let size = 4u;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(4_u));
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@ -208,34 +208,34 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedLet_Pass) {
// let size = 4i;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(4_i));
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverTypeValidationTest, ArraySize_AIntLiteral_Zero) {
// var<private> a : array<f32, 0>;
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_a)), ast::StorageClass::kPrivate);
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_a)), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: array size (0) must be greater than 0");
}
TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLiteral_Zero) {
// var<private> a : array<f32, 0u>;
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_u)), ast::StorageClass::kPrivate);
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_u)), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: array size (0) must be greater than 0");
}
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Zero) {
// var<private> a : array<f32, 0i>;
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_i)), ast::StorageClass::kPrivate);
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 0_i)), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: array size (0) must be greater than 0");
}
TEST_F(ResolverTypeValidationTest, ArraySize_SignedLiteral_Negative) {
// var<private> a : array<f32, -10i>;
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, -10_i)), ast::StorageClass::kPrivate);
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, -10_i)), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: array size (-10) must be greater than 0");
}
@ -244,7 +244,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_UnsignedLet_Zero) {
// let size = 0u;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(0_u));
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
GlobalVar("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");
}
@ -253,7 +253,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedLet_Zero) {
// let size = 0i;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(0_i));
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
GlobalVar("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");
}
@ -262,14 +262,14 @@ TEST_F(ResolverTypeValidationTest, ArraySize_SignedLet_Negative) {
// let size = -10i;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(-10_i));
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
GlobalVar("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");
}
TEST_F(ResolverTypeValidationTest, ArraySize_FloatLiteral) {
// var<private> a : array<f32, 10.0>;
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 10_f)), ast::StorageClass::kPrivate);
GlobalVar("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, 10_f)), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
"12:34 error: array size must evaluate to a constant integer expression, but is type "
@ -278,7 +278,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FloatLiteral) {
TEST_F(ResolverTypeValidationTest, ArraySize_IVecLiteral) {
// var<private> a : array<f32, vec2<i32>(10, 10)>;
Global("a", ty.array(ty.f32(), Construct(Source{{12, 34}}, ty.vec2<i32>(), 10_i, 10_i)),
GlobalVar("a", ty.array(ty.f32(), Construct(Source{{12, 34}}, ty.vec2<i32>(), 10_i, 10_i)),
ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -290,7 +290,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FloatLet) {
// let size = 10.0;
// var<private> a : array<f32, size>;
GlobalLet("size", nullptr, Expr(10_f));
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
GlobalVar("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 must evaluate to a constant integer expression, but is type "
@ -301,7 +301,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_IVecLet) {
// let size = vec2<i32>(100, 100);
// var<private> a : array<f32, size>;
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);
GlobalVar("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 must evaluate to a constant integer expression, but is type "
@ -310,7 +310,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_IVecLet) {
TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ImplicitStride) {
// var<private> a : array<f32, 0x40000000u>;
Global("a", ty.array(Source{{12, 34}}, ty.f32(), 0x40000000_u), ast::StorageClass::kPrivate);
GlobalVar("a", ty.array(Source{{12, 34}}, ty.f32(), 0x40000000_u), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
"12:34 error: array size (0x100000000) must not exceed 0xffffffff bytes");
@ -318,7 +318,8 @@ TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ImplicitStride) {
TEST_F(ResolverTypeValidationTest, ArraySize_TooBig_ExplicitStride) {
// var<private> a : @stride(8) array<f32, 0x20000000u>;
Global("a", ty.array(Source{{12, 34}}, ty.f32(), 0x20000000_u, 8), ast::StorageClass::kPrivate);
GlobalVar("a", ty.array(Source{{12, 34}}, ty.f32(), 0x20000000_u, 8),
ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
"12:34 error: array size (0x100000000) must not exceed 0xffffffff bytes");
@ -328,7 +329,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_Overridable) {
// override size = 10i;
// var<private> a : array<f32, size>;
Override("size", nullptr, Expr(10_i));
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
GlobalVar("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 must evaluate to a constant integer expression");
@ -337,8 +338,8 @@ TEST_F(ResolverTypeValidationTest, ArraySize_Overridable) {
TEST_F(ResolverTypeValidationTest, ArraySize_ModuleVar) {
// var<private> size : i32 = 10i;
// var<private> a : array<f32, size>;
Global("size", ty.i32(), Expr(10_i), ast::StorageClass::kPrivate);
Global("a", ty.array(ty.f32(), Expr(Source{{12, 34}}, "size")), ast::StorageClass::kPrivate);
GlobalVar("size", ty.i32(), Expr(10_i), ast::StorageClass::kPrivate);
GlobalVar("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 must evaluate to a constant integer expression");
@ -479,7 +480,7 @@ TEST_F(ResolverTypeValidationTest, RuntimeArrayInStructInArray) {
// var<private> a : array<Foo, 4>;
auto* foo = Structure("Foo", {Member("rt", ty.array<f32>())});
Global("v", ty.array(Source{{12, 34}}, ty.Of(foo), 4_u), ast::StorageClass::kPrivate);
GlobalVar("v", ty.array(Source{{12, 34}}, ty.Of(foo), 4_u), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve()) << r()->error();
EXPECT_EQ(r()->error(),
@ -522,7 +523,7 @@ TEST_F(ResolverTypeValidationTest, RuntimeArrayIsNotLast_Fail) {
}
TEST_F(ResolverTypeValidationTest, RuntimeArrayAsGlobalVariable) {
Global(Source{{56, 78}}, "g", ty.array<i32>(), ast::StorageClass::kPrivate);
GlobalVar(Source{{56, 78}}, "g", ty.array<i32>(), ast::StorageClass::kPrivate);
ASSERT_FALSE(r()->Resolve());
@ -624,7 +625,7 @@ TEST_F(ResolverTypeValidationTest, AliasRuntimeArrayIsLast_Pass) {
TEST_F(ResolverTypeValidationTest, ArrayOfNonStorableType) {
auto* tex_ty = ty.sampled_texture(ast::TextureDimension::k2d, ty.f32());
Global("arr", ty.array(Source{{12, 34}}, tex_ty, 4_i), ast::StorageClass::kPrivate);
GlobalVar("arr", ty.array(Source{{12, 34}}, tex_ty, 4_i), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -634,8 +635,8 @@ TEST_F(ResolverTypeValidationTest, ArrayOfNonStorableType) {
TEST_F(ResolverTypeValidationTest, VariableAsType) {
// var<private> a : i32;
// var<private> b : a;
Global("a", ty.i32(), ast::StorageClass::kPrivate);
Global("b", ty.type_name("a"), ast::StorageClass::kPrivate);
GlobalVar("a", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.type_name("a"), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -647,7 +648,7 @@ TEST_F(ResolverTypeValidationTest, FunctionAsType) {
// fn f() {}
// var<private> v : f;
Func("f", {}, ty.void_(), {});
Global("v", ty.type_name("f"), ast::StorageClass::kPrivate);
GlobalVar("v", ty.type_name("f"), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -657,7 +658,7 @@ note: 'f' declared here)");
TEST_F(ResolverTypeValidationTest, BuiltinAsType) {
// var<private> v : max;
Global("v", ty.type_name("max"), ast::StorageClass::kPrivate);
GlobalVar("v", ty.type_name("max"), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "error: cannot use builtin 'max' as type");
@ -668,14 +669,14 @@ TEST_F(ResolverTypeValidationTest, F16TypeUsedWithExtension) {
// var<private> v : f16;
Enable(ast::Extension::kF16);
Global("v", ty.f16(), ast::StorageClass::kPrivate);
GlobalVar("v", ty.f16(), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
TEST_F(ResolverTypeValidationTest, F16TypeUsedWithoutExtension) {
// var<private> v : f16;
Global("v", ty.f16(), ast::StorageClass::kPrivate);
GlobalVar("v", ty.f16(), ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "error: f16 used without 'f16' extension enabled");
@ -747,7 +748,7 @@ struct DimensionParams {
using SampledTextureDimensionTest = ResolverTestWithParam<DimensionParams>;
TEST_P(SampledTextureDimensionTest, All) {
auto& params = GetParam();
Global(Source{{12, 34}}, "a", ty.sampled_texture(params.dim, ty.i32()),
GlobalVar(Source{{12, 34}}, "a", ty.sampled_texture(params.dim, ty.i32()),
ast::StorageClass::kNone, nullptr, ast::AttributeList{GroupAndBinding(0, 0)});
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -765,7 +766,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
using MultisampledTextureDimensionTest = ResolverTestWithParam<DimensionParams>;
TEST_P(MultisampledTextureDimensionTest, All) {
auto& params = GetParam();
Global("a", ty.multisampled_texture(Source{{12, 34}}, params.dim, ty.i32()),
GlobalVar("a", ty.multisampled_texture(Source{{12, 34}}, params.dim, ty.i32()),
ast::StorageClass::kNone, nullptr, ast::AttributeList{GroupAndBinding(0, 0)});
if (params.is_valid) {
@ -816,7 +817,7 @@ static constexpr TypeParams type_cases[] = {
using SampledTextureTypeTest = ResolverTestWithParam<TypeParams>;
TEST_P(SampledTextureTypeTest, All) {
auto& params = GetParam();
Global(
GlobalVar(
"a",
ty.sampled_texture(Source{{12, 34}}, ast::TextureDimension::k2d, params.type_func(*this)),
ast::StorageClass::kNone, nullptr, ast::AttributeList{GroupAndBinding(0, 0)});
@ -835,7 +836,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
using MultisampledTextureTypeTest = ResolverTestWithParam<TypeParams>;
TEST_P(MultisampledTextureTypeTest, All) {
auto& params = GetParam();
Global("a",
GlobalVar("a",
ty.multisampled_texture(Source{{12, 34}}, ast::TextureDimension::k2d,
params.type_func(*this)),
ast::StorageClass::kNone, nullptr, ast::AttributeList{GroupAndBinding(0, 0)});
@ -877,7 +878,7 @@ TEST_P(StorageTextureDimensionTest, All) {
auto* st = ty.storage_texture(Source{{12, 34}}, params.dim, ast::TexelFormat::kR32Uint,
ast::Access::kWrite);
Global("a", st, ast::StorageClass::kNone, ast::AttributeList{GroupAndBinding(0, 0)});
GlobalVar("a", st, ast::StorageClass::kNone, ast::AttributeList{GroupAndBinding(0, 0)});
if (params.is_valid) {
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -927,17 +928,17 @@ TEST_P(StorageTextureFormatTest, All) {
auto* st_a = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d, params.format,
ast::Access::kWrite);
Global("a", st_a, ast::StorageClass::kNone, ast::AttributeList{GroupAndBinding(0, 0)});
GlobalVar("a", st_a, ast::StorageClass::kNone, ast::AttributeList{GroupAndBinding(0, 0)});
auto* st_b = ty.storage_texture(ast::TextureDimension::k2d, params.format, ast::Access::kWrite);
Global("b", st_b, ast::StorageClass::kNone, ast::AttributeList{GroupAndBinding(0, 1)});
GlobalVar("b", st_b, ast::StorageClass::kNone, ast::AttributeList{GroupAndBinding(0, 1)});
auto* st_c =
ty.storage_texture(ast::TextureDimension::k2dArray, params.format, ast::Access::kWrite);
Global("c", st_c, ast::StorageClass::kNone, ast::AttributeList{GroupAndBinding(0, 2)});
GlobalVar("c", st_c, ast::StorageClass::kNone, ast::AttributeList{GroupAndBinding(0, 2)});
auto* st_d = ty.storage_texture(ast::TextureDimension::k3d, params.format, ast::Access::kWrite);
Global("d", st_d, ast::StorageClass::kNone, ast::AttributeList{GroupAndBinding(0, 3)});
GlobalVar("d", st_d, ast::StorageClass::kNone, ast::AttributeList{GroupAndBinding(0, 3)});
if (params.is_valid) {
EXPECT_TRUE(r()->Resolve()) << r()->error();
@ -961,7 +962,7 @@ TEST_F(StorageTextureAccessTest, MissingAccess_Fail) {
auto* st = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d,
ast::TexelFormat::kR32Uint, ast::Access::kUndefined);
Global("a", st, ast::StorageClass::kNone, ast::AttributeList{GroupAndBinding(0, 0)});
GlobalVar("a", st, ast::StorageClass::kNone, ast::AttributeList{GroupAndBinding(0, 0)});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: storage texture missing access control");
@ -974,7 +975,8 @@ TEST_F(StorageTextureAccessTest, RWAccess_Fail) {
auto* st = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d,
ast::TexelFormat::kR32Uint, ast::Access::kReadWrite);
Global("a", st, ast::StorageClass::kNone, nullptr, ast::AttributeList{GroupAndBinding(0, 0)});
GlobalVar("a", st, ast::StorageClass::kNone, nullptr,
ast::AttributeList{GroupAndBinding(0, 0)});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -988,7 +990,8 @@ TEST_F(StorageTextureAccessTest, ReadOnlyAccess_Fail) {
auto* st = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d,
ast::TexelFormat::kR32Uint, ast::Access::kRead);
Global("a", st, ast::StorageClass::kNone, nullptr, ast::AttributeList{GroupAndBinding(0, 0)});
GlobalVar("a", st, ast::StorageClass::kNone, nullptr,
ast::AttributeList{GroupAndBinding(0, 0)});
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),
@ -1002,7 +1005,8 @@ TEST_F(StorageTextureAccessTest, WriteOnlyAccess_Pass) {
auto* st = ty.storage_texture(ast::TextureDimension::k1d, ast::TexelFormat::kR32Uint,
ast::Access::kWrite);
Global("a", st, ast::StorageClass::kNone, nullptr, ast::AttributeList{GroupAndBinding(0, 0)});
GlobalVar("a", st, ast::StorageClass::kNone, nullptr,
ast::AttributeList{GroupAndBinding(0, 0)});
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@ -1025,7 +1029,7 @@ using ValidMatrixTypes = ResolverTestWithParam<Params>;
TEST_P(ValidMatrixTypes, Okay) {
// var a : matNxM<EL_TY>;
auto& params = GetParam();
Global("a", ty.mat(params.elem_ty(*this), params.columns, params.rows),
GlobalVar("a", ty.mat(params.elem_ty(*this), params.columns, params.rows),
ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
@ -1048,7 +1052,7 @@ using InvalidMatrixElementTypes = ResolverTestWithParam<Params>;
TEST_P(InvalidMatrixElementTypes, InvalidElementType) {
// var a : matNxM<EL_TY>;
auto& params = GetParam();
Global("a", ty.mat(Source{{12, 34}}, params.elem_ty(*this), params.columns, params.rows),
GlobalVar("a", ty.mat(Source{{12, 34}}, params.elem_ty(*this), params.columns, params.rows),
ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: matrix element type must be 'f32'");
@ -1082,7 +1086,7 @@ using ValidVectorTypes = ResolverTestWithParam<Params>;
TEST_P(ValidVectorTypes, Okay) {
// var a : vecN<EL_TY>;
auto& params = GetParam();
Global("a", ty.vec(params.elem_ty(*this), params.width), ast::StorageClass::kPrivate);
GlobalVar("a", ty.vec(params.elem_ty(*this), params.width), ast::StorageClass::kPrivate);
EXPECT_TRUE(r()->Resolve()) << r()->error();
}
INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest,
@ -1108,7 +1112,7 @@ using InvalidVectorElementTypes = ResolverTestWithParam<Params>;
TEST_P(InvalidVectorElementTypes, InvalidElementType) {
// var a : vecN<EL_TY>;
auto& params = GetParam();
Global("a", ty.vec(Source{{12, 34}}, params.elem_ty(*this), params.width),
GlobalVar("a", ty.vec(Source{{12, 34}}, params.elem_ty(*this), params.width),
ast::StorageClass::kPrivate);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),

View File

@ -5327,7 +5327,7 @@ TEST_F(UniformityAnalysisTest, MaximumNumberOfPointerParameters) {
// workgroupBarrier();
// }
// }
b.Global("non_uniform_global", ty.i32(), ast::StorageClass::kPrivate);
b.GlobalVar("non_uniform_global", ty.i32(), ast::StorageClass::kPrivate);
ast::StatementList main_body;
ast::ExpressionList args;
for (int i = 0; i < 255; i++) {
@ -6538,7 +6538,7 @@ TEST_F(UniformityAnalysisTest, StressGraphTraversalDepth) {
// workgroupBarrier();
// }
// }
b.Global("v0", ty.i32(), ast::StorageClass::kPrivate, b.Expr(0_i));
b.GlobalVar("v0", ty.i32(), ast::StorageClass::kPrivate, b.Expr(0_i));
ast::StatementList foo_body;
std::string v_last = "v0";
for (int i = 1; i < 100000; i++) {

View File

@ -61,8 +61,8 @@ class FakeExpr final : public Castable<FakeExpr, ast::Expression> {
};
TEST_F(ResolverValidationTest, WorkgroupMemoryUsedInVertexStage) {
Global(Source{{1, 2}}, "wg", ty.vec4<f32>(), ast::StorageClass::kWorkgroup);
Global("dst", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar(Source{{1, 2}}, "wg", ty.vec4<f32>(), ast::StorageClass::kWorkgroup);
GlobalVar("dst", ty.vec4<f32>(), ast::StorageClass::kPrivate);
auto* stmt = Assign(Expr("dst"), Expr(Source{{3, 4}}, "wg"));
Func(Source{{9, 10}}, "f0", {}, ty.vec4<f32>(),
@ -93,8 +93,8 @@ TEST_F(ResolverValidationTest, WorkgroupMemoryUsedInFragmentStage) {
// f1();
//}
Global(Source{{1, 2}}, "wg", ty.vec4<f32>(), ast::StorageClass::kWorkgroup);
Global("dst", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar(Source{{1, 2}}, "wg", ty.vec4<f32>(), ast::StorageClass::kWorkgroup);
GlobalVar("dst", ty.vec4<f32>(), ast::StorageClass::kPrivate);
auto* stmt = Assign(Expr("dst"), Expr(Source{{3, 4}}, "wg"));
Func(Source{{5, 6}}, "f2", {}, ty.void_(), {stmt});
@ -221,7 +221,7 @@ TEST_F(ResolverValidationTest, UsingUndefinedVariableGlobalVariable_Pass) {
// return;
// }
Global("global_var", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
GlobalVar("global_var", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
Func("my_func", {}, ty.void_(),
{
@ -324,7 +324,7 @@ TEST_F(ResolverValidationTest, StorageClass_FunctionVariableI32) {
TEST_F(ResolverValidationTest, StorageClass_SamplerExplicitStorageClass) {
auto* t = ty.sampler(ast::SamplerKind::kSampler);
Global(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle,
GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -338,7 +338,7 @@ TEST_F(ResolverValidationTest, StorageClass_SamplerExplicitStorageClass) {
TEST_F(ResolverValidationTest, StorageClass_TextureExplicitStorageClass) {
auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32());
Global(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle,
GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -351,7 +351,7 @@ TEST_F(ResolverValidationTest, StorageClass_TextureExplicitStorageClass) {
}
TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadChar) {
Global("my_vec", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_vec", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* ident = Expr(Source{{{3, 3}, {3, 7}}}, "xyqz");
@ -363,7 +363,7 @@ TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadChar) {
}
TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_MixedChars) {
Global("my_vec", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_vec", ty.vec4<f32>(), ast::StorageClass::kPrivate);
auto* ident = Expr(Source{{{3, 3}, {3, 7}}}, "rgyw");
@ -376,7 +376,7 @@ TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_MixedChars) {
}
TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadLength) {
Global("my_vec", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_vec", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* ident = Expr(Source{{{3, 3}, {3, 8}}}, "zzzzz");
auto* mem = MemberAccessor("my_vec", ident);
@ -387,7 +387,7 @@ TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadLength) {
}
TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadIndex) {
Global("my_vec", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_vec", ty.vec2<f32>(), ast::StorageClass::kPrivate);
auto* ident = Expr(Source{{3, 3}}, "z");
auto* mem = MemberAccessor("my_vec", ident);

View File

@ -221,7 +221,7 @@ TEST_F(ResolverVariableTest, LocalVar_ShadowsGlobalVar) {
// var a = a;
// }
auto* g = Global("a", ty.i32(), ast::StorageClass::kPrivate);
auto* g = GlobalVar("a", ty.i32(), ast::StorageClass::kPrivate);
auto* v = Var("a", nullptr, Expr("a"));
Func("F", {}, ty.void_(), {Decl(v)});
@ -419,7 +419,7 @@ TEST_F(ResolverVariableTest, LocalLet_InheritsAccessFromOriginatingVariable) {
// }
auto* inner = Structure("Inner", {Member("arr", ty.array<i32, 4>())});
auto* buf = Structure("S", {Member("inner", ty.Of(inner))});
auto* storage = Global("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite,
auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -504,7 +504,7 @@ TEST_F(ResolverVariableTest, LocalLet_ShadowsGlobalVar) {
// let a = a;
// }
auto* g = Global("a", ty.i32(), ast::StorageClass::kPrivate);
auto* g = GlobalVar("a", ty.i32(), ast::StorageClass::kPrivate);
auto* l = Let("a", nullptr, Expr("a"));
Func("F", {}, ty.void_(), {Decl(l)});
@ -627,19 +627,19 @@ TEST_F(ResolverVariableTest, GlobalVar_StorageClass) {
// https://gpuweb.github.io/gpuweb/wgsl/#storage-class
auto* buf = Structure("S", {Member("m", ty.i32())});
auto* private_ = Global("p", ty.i32(), ast::StorageClass::kPrivate);
auto* workgroup = Global("w", ty.i32(), ast::StorageClass::kWorkgroup);
auto* uniform = Global("ub", ty.Of(buf), ast::StorageClass::kUniform,
auto* private_ = GlobalVar("p", ty.i32(), ast::StorageClass::kPrivate);
auto* workgroup = GlobalVar("w", ty.i32(), ast::StorageClass::kWorkgroup);
auto* uniform = GlobalVar("ub", ty.Of(buf), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
});
auto* storage = Global("sb", ty.Of(buf), ast::StorageClass::kStorage,
auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(0),
});
auto* handle = Global("h", ty.depth_texture(ast::TextureDimension::k2d),
auto* handle = GlobalVar("h", ty.depth_texture(ast::TextureDimension::k2d),
ast::AttributeList{
create<ast::BindingAttribute>(2),
create<ast::GroupAttribute>(0),
@ -664,7 +664,8 @@ TEST_F(ResolverVariableTest, GlobalVar_ExplicitStorageClass) {
// https://gpuweb.github.io/gpuweb/wgsl/#storage-class
auto* buf = Structure("S", {Member("m", ty.i32())});
auto* storage = Global("sb", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite,
auto* storage =
GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(0),
@ -704,7 +705,7 @@ TEST_F(ResolverVariableTest, Param_ShadowsGlobalVar) {
// fn F(a : bool) {
// }
auto* g = Global("a", ty.i32(), ast::StorageClass::kPrivate);
auto* g = GlobalVar("a", ty.i32(), ast::StorageClass::kPrivate);
auto* p = Param("a", ty.bool_());
Func("F", {p}, ty.void_(), {});

View File

@ -34,7 +34,7 @@ TEST_F(ResolverVariableValidationTest, VarNoInitializerNoType) {
TEST_F(ResolverVariableValidationTest, GlobalVarNoInitializerNoType) {
// var a;
Global(Source{{12, 34}}, "a", nullptr);
GlobalVar(Source{{12, 34}}, "a", nullptr);
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(), "12:34 error: 'var' declaration requires a type or initializer");
@ -65,7 +65,7 @@ TEST_F(ResolverVariableValidationTest, VarTypeNotStorable) {
TEST_F(ResolverVariableValidationTest, LetTypeNotConstructible) {
// @group(0) @binding(0) var t1 : texture_2d<f32>;
// let t2 : t1;
auto* t1 = Global("t1", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
auto* t1 = GlobalVar("t1", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()),
GroupAndBinding(0, 0));
auto* t2 = Let(Source{{56, 78}}, "t2", nullptr, Expr(t1));
WrapInFunction(t2);
@ -160,7 +160,7 @@ TEST_F(ResolverVariableValidationTest, GlobalVarRedeclaredAsLocal) {
// return 0;
// }
Global("v", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
GlobalVar("v", ty.f32(), ast::StorageClass::kPrivate, Expr(2.1_f));
WrapInFunction(Var(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kNone, Expr(2_f)));
@ -214,7 +214,7 @@ TEST_F(ResolverVariableValidationTest, InferredPtrStorageAccessMismatch) {
// }
auto* inner = Structure("Inner", {Member("arr", ty.array<i32, 4>())});
auto* buf = Structure("S", {Member("inner", ty.Of(inner))});
auto* storage = Global("s", ty.Of(buf), ast::StorageClass::kStorage,
auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -268,7 +268,7 @@ TEST_F(ResolverVariableValidationTest, NonConstructibleType_InferredType) {
// fn foo() {
// var v = s;
// }
Global("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(0, 0));
GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), GroupAndBinding(0, 0));
auto* v = Var(Source{{12, 34}}, "v", nullptr, Expr("s"));
WrapInFunction(v);
@ -278,7 +278,7 @@ TEST_F(ResolverVariableValidationTest, NonConstructibleType_InferredType) {
TEST_F(ResolverVariableValidationTest, InvalidStorageClassForInitializer) {
// var<workgroup> v : f32 = 1.23;
Global(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kWorkgroup, Expr(1.23_f));
GlobalVar(Source{{12, 34}}, "v", ty.f32(), ast::StorageClass::kWorkgroup, Expr(1.23_f));
EXPECT_FALSE(r()->Resolve());
EXPECT_EQ(r()->error(),

View File

@ -144,7 +144,7 @@ void ArrayLengthFromUniform::Run(CloneContext& ctx, const DataMap& inputs, DataM
{ctx.dst->Member(kBufferSizeMemberName,
ctx.dst->ty.array(ctx.dst->ty.vec4(ctx.dst->ty.u32()),
u32((max_buffer_size_index / 4) + 1)))});
buffer_size_ubo = ctx.dst->Global(
buffer_size_ubo = ctx.dst->GlobalVar(
ctx.dst->Sym(), ctx.dst->ty.Of(buffer_size_struct), ast::StorageClass::kUniform,
ast::AttributeList{
ctx.dst->GroupAndBinding(cfg->ubo_binding.group, cfg->ubo_binding.binding)});

View File

@ -196,7 +196,7 @@ struct CanonicalizeEntryPointIO::State {
value = ctx.dst->IndexAccessor(value, 0_i);
}
}
ctx.dst->Global(symbol, ast_type, ast::StorageClass::kInput, std::move(attributes));
ctx.dst->GlobalVar(symbol, ast_type, ast::StorageClass::kInput, std::move(attributes));
return value;
} else if (cfg.shader_style == ShaderStyle::kMsl &&
ast::HasAttribute<ast::BuiltinAttribute>(attributes)) {
@ -463,7 +463,7 @@ struct CanonicalizeEntryPointIO::State {
type = ctx.dst->ty.array(type, 1_u);
lhs = ctx.dst->IndexAccessor(lhs, 0_i);
}
ctx.dst->Global(name, type, ast::StorageClass::kOutput, std::move(attributes));
ctx.dst->GlobalVar(name, type, ast::StorageClass::kOutput, std::move(attributes));
wrapper_body.push_back(ctx.dst->Assign(lhs, outval.value));
}
}

View File

@ -109,7 +109,7 @@ struct CombineSamplers::State {
}
const ast::Type* type = CreateCombinedASTTypeFor(texture_var, sampler_var);
Symbol symbol = ctx.dst->Symbols().New(name);
return ctx.dst->Global(symbol, type, Attributes());
return ctx.dst->GlobalVar(symbol, type, Attributes());
}
/// Creates placeholder global sampler variables.
@ -121,7 +121,7 @@ struct CombineSamplers::State {
? "placeholder_comparison_sampler"
: "placeholder_sampler";
Symbol symbol = ctx.dst->Symbols().New(name);
return ctx.dst->Global(symbol, type, Attributes());
return ctx.dst->GlobalVar(symbol, type, Attributes());
}
/// Creates ast::Type for a given texture and sampler variable pair.

View File

@ -39,7 +39,7 @@ TEST_F(DecomposeStridedArrayTest, ShouldRunNonStridedArray) {
// var<private> arr : array<f32, 4u>
ProgramBuilder b;
b.Global("arr", b.ty.array<f32, 4u>(), ast::StorageClass::kPrivate);
b.GlobalVar("arr", b.ty.array<f32, 4u>(), ast::StorageClass::kPrivate);
EXPECT_FALSE(ShouldRun<DecomposeStridedArray>(Program(std::move(b))));
}
@ -47,7 +47,7 @@ TEST_F(DecomposeStridedArrayTest, ShouldRunDefaultStridedArray) {
// var<private> arr : @stride(4) array<f32, 4u>
ProgramBuilder b;
b.Global("arr", b.ty.array<f32, 4u>(4), ast::StorageClass::kPrivate);
b.GlobalVar("arr", b.ty.array<f32, 4u>(4), ast::StorageClass::kPrivate);
EXPECT_TRUE(ShouldRun<DecomposeStridedArray>(Program(std::move(b))));
}
@ -55,7 +55,7 @@ TEST_F(DecomposeStridedArrayTest, ShouldRunExplicitStridedArray) {
// var<private> arr : @stride(16) array<f32, 4u>
ProgramBuilder b;
b.Global("arr", b.ty.array<f32, 4u>(16), ast::StorageClass::kPrivate);
b.GlobalVar("arr", b.ty.array<f32, 4u>(16), ast::StorageClass::kPrivate);
EXPECT_TRUE(ShouldRun<DecomposeStridedArray>(Program(std::move(b))));
}
@ -78,7 +78,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateDefaultStridedArray) {
// }
ProgramBuilder b;
b.Global("arr", b.ty.array<f32, 4u>(4), ast::StorageClass::kPrivate);
b.GlobalVar("arr", b.ty.array<f32, 4u>(4), ast::StorageClass::kPrivate);
b.Func("f", {}, b.ty.void_(),
{
b.Decl(b.Let("a", b.ty.array<f32, 4u>(4), b.Expr("arr"))),
@ -114,7 +114,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateStridedArray) {
// }
ProgramBuilder b;
b.Global("arr", b.ty.array<f32, 4u>(32), ast::StorageClass::kPrivate);
b.GlobalVar("arr", b.ty.array<f32, 4u>(32), ast::StorageClass::kPrivate);
b.Func("f", {}, b.ty.void_(),
{
b.Decl(b.Let("a", b.ty.array<f32, 4u>(32), b.Expr("arr"))),
@ -158,7 +158,7 @@ TEST_F(DecomposeStridedArrayTest, ReadUniformStridedArray) {
// }
ProgramBuilder b;
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(32))});
b.Global("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
b.Decl(b.Let("a", b.ty.array<f32, 4u>(32), b.MemberAccessor("s", "a"))),
@ -206,7 +206,7 @@ TEST_F(DecomposeStridedArrayTest, ReadUniformDefaultStridedArray) {
// }
ProgramBuilder b;
auto* S = b.Structure("S", {b.Member("a", b.ty.array(b.ty.vec4<f32>(), 4_u, 16))});
b.Global("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.Func(
"f", {}, b.ty.void_(),
{
@ -252,7 +252,7 @@ TEST_F(DecomposeStridedArrayTest, ReadStorageStridedArray) {
// }
ProgramBuilder b;
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(32))});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, b.GroupAndBinding(0, 0));
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
b.Decl(b.Let("a", b.ty.array<f32, 4u>(32), b.MemberAccessor("s", "a"))),
@ -300,7 +300,7 @@ TEST_F(DecomposeStridedArrayTest, ReadStorageDefaultStridedArray) {
// }
ProgramBuilder b;
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(4))});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, b.GroupAndBinding(0, 0));
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
b.Decl(b.Let("a", b.ty.array<f32, 4u>(4), b.MemberAccessor("s", "a"))),
@ -344,7 +344,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageStridedArray) {
// }
ProgramBuilder b;
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(32))});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
@ -398,7 +398,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageDefaultStridedArray) {
// }
ProgramBuilder b;
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(4))});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
@ -450,7 +450,7 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) {
// }
ProgramBuilder b;
auto* S = b.Structure("S", {b.Member("a", b.ty.array<f32, 4u>(32))});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
@ -511,7 +511,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) {
ProgramBuilder b;
b.Alias("ARR", b.ty.array<f32, 4u>(32));
auto* S = b.Structure("S", {b.Member("a", b.ty.type_name("ARR"))});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
@ -581,7 +581,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
b.ty.array(b.ty.type_name("ARR_A"), 3_u, 16), //
4_u, 128));
auto* S = b.Structure("S", {b.Member("a", b.ty.type_name("ARR_B"))});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{

View File

@ -76,7 +76,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.Global("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
b.Decl(b.Let("x", b.ty.mat2x2<f32>(), b.MemberAccessor("s", "m"))),
@ -132,7 +132,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformColumn) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.Global("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.Func(
"f", {}, b.ty.void_(),
{
@ -185,7 +185,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix_DefaultStride) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.Global("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
b.Decl(b.Let("x", b.ty.mat2x2<f32>(), b.MemberAccessor("s", "m"))),
@ -238,7 +238,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
@ -295,7 +295,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GroupAndBinding(0, 0));
b.Func(
"f", {}, b.ty.void_(),
@ -349,7 +349,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
@ -407,7 +407,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
@ -466,7 +466,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
@ -537,7 +537,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadPrivateMatrix) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.Global("s", b.ty.Of(S), ast::StorageClass::kPrivate);
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kPrivate);
b.Func("f", {}, b.ty.void_(),
{
b.Decl(b.Let("x", b.ty.mat2x2<f32>(), b.MemberAccessor("s", "m"))),
@ -590,7 +590,7 @@ TEST_F(DecomposeStridedMatrixTest, WritePrivateMatrix) {
b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute),
}),
});
b.Global("s", b.ty.Of(S), ast::StorageClass::kPrivate);
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kPrivate);
b.Func("f", {}, b.ty.void_(),
{
b.Assign(b.MemberAccessor("s", "m"),

View File

@ -121,7 +121,8 @@ void FirstIndexOffset::Run(CloneContext& ctx, const DataMap& inputs, DataMap& ou
// Create a global to hold the uniform buffer
Symbol buffer_name = ctx.dst->Sym();
ctx.dst->Global(buffer_name, ctx.dst->ty.Of(struct_), ast::StorageClass::kUniform, nullptr,
ctx.dst->GlobalVar(buffer_name, ctx.dst->ty.Of(struct_), ast::StorageClass::kUniform,
nullptr,
ast::AttributeList{
ctx.dst->create<ast::BindingAttribute>(ub_binding),
ctx.dst->create<ast::GroupAttribute>(ub_group),

View File

@ -131,10 +131,10 @@ struct MultiplanarExternalTexture::State {
auto& syms = new_binding_symbols[sem_var];
syms.plane_0 = ctx.Clone(global->symbol);
syms.plane_1 = b.Symbols().New("ext_tex_plane_1");
b.Global(syms.plane_1, b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32()),
b.GlobalVar(syms.plane_1, b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32()),
b.GroupAndBinding(bps.plane_1.group, bps.plane_1.binding));
syms.params = b.Symbols().New("ext_tex_params");
b.Global(syms.params, b.ty.type_name("ExternalTextureParams"),
b.GlobalVar(syms.params, b.ty.type_name("ExternalTextureParams"),
ast::StorageClass::kUniform,
b.GroupAndBinding(bps.params.group, bps.params.binding));

View File

@ -144,7 +144,7 @@ void NumWorkgroupsFromUniform::Run(CloneContext& ctx, const DataMap& inputs, Dat
binding = 0;
}
num_workgroups_ubo = ctx.dst->Global(
num_workgroups_ubo = ctx.dst->GlobalVar(
ctx.dst->Sym(), ctx.dst->ty.Of(num_workgroups_struct), ast::StorageClass::kUniform,
ast::AttributeList{ctx.dst->GroupAndBinding(group, binding)});
}

View File

@ -54,7 +54,7 @@ class State {
Symbol ModuleDiscardVarName() {
if (!module_discard_var_name.IsValid()) {
module_discard_var_name = b.Symbols().New("tint_discard");
ctx.dst->Global(module_discard_var_name, b.ty.bool_(), b.Expr(false),
ctx.dst->GlobalVar(module_discard_var_name, b.ty.bool_(), b.Expr(false),
ast::StorageClass::kPrivate);
}
return module_discard_var_name;

View File

@ -259,7 +259,7 @@ struct State {
});
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
// The decorated variable with struct type
ctx.dst->Global(GetVertexBufferName(i), ctx.dst->ty.Of(struct_type),
ctx.dst->GlobalVar(GetVertexBufferName(i), ctx.dst->ty.Of(struct_type),
ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
ctx.dst->create<ast::BindingAttribute>(i),

View File

@ -250,7 +250,7 @@ TEST_F(AppendVectorTest, Vec3i32_i32) {
// AppendVector(vec_12, 3) -> vec3<i32>(vec_12, 3)
TEST_F(AppendVectorTest, Vec2i32Var_i32) {
Global("vec_12", ty.vec2<i32>(), ast::StorageClass::kPrivate);
GlobalVar("vec_12", ty.vec2<i32>(), ast::StorageClass::kPrivate);
auto* vec_12 = Expr("vec_12");
auto* scalar_3 = Expr(3_i);
WrapInFunction(vec_12, scalar_3);
@ -286,7 +286,7 @@ TEST_F(AppendVectorTest, Vec2i32Var_i32) {
// AppendVector(1, 2, scalar_3) -> vec3<i32>(1, 2, scalar_3)
TEST_F(AppendVectorTest, Vec2i32_i32Var) {
Global("scalar_3", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("scalar_3", ty.i32(), ast::StorageClass::kPrivate);
auto* scalar_1 = Expr(1_i);
auto* scalar_2 = Expr(2_i);
auto* scalar_3 = Expr("scalar_3");
@ -327,8 +327,8 @@ TEST_F(AppendVectorTest, Vec2i32_i32Var) {
// AppendVector(vec_12, scalar_3) -> vec3<i32>(vec_12, scalar_3)
TEST_F(AppendVectorTest, Vec2i32Var_i32Var) {
Global("vec_12", ty.vec2<i32>(), ast::StorageClass::kPrivate);
Global("scalar_3", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("vec_12", ty.vec2<i32>(), ast::StorageClass::kPrivate);
GlobalVar("scalar_3", ty.i32(), ast::StorageClass::kPrivate);
auto* vec_12 = Expr("vec_12");
auto* scalar_3 = Expr("scalar_3");
WrapInFunction(vec_12, scalar_3);
@ -364,8 +364,8 @@ TEST_F(AppendVectorTest, Vec2i32Var_i32Var) {
// AppendVector(vec_12, scalar_3) -> vec3<i32>(vec_12, i32(scalar_3))
TEST_F(AppendVectorTest, Vec2i32Var_f32Var) {
Global("vec_12", ty.vec2<i32>(), ast::StorageClass::kPrivate);
Global("scalar_3", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("vec_12", ty.vec2<i32>(), ast::StorageClass::kPrivate);
GlobalVar("scalar_3", ty.f32(), ast::StorageClass::kPrivate);
auto* vec_12 = Expr("vec_12");
auto* scalar_3 = Expr("scalar_3");
WrapInFunction(vec_12, scalar_3);
@ -405,8 +405,8 @@ TEST_F(AppendVectorTest, Vec2i32Var_f32Var) {
// AppendVector(vec_12, scalar_3) -> vec3<bool>(vec_12, scalar_3)
TEST_F(AppendVectorTest, Vec2boolVar_boolVar) {
Global("vec_12", ty.vec2<bool>(), ast::StorageClass::kPrivate);
Global("scalar_3", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("vec_12", ty.vec2<bool>(), ast::StorageClass::kPrivate);
GlobalVar("scalar_3", ty.bool_(), ast::StorageClass::kPrivate);
auto* vec_12 = Expr("vec_12");
auto* scalar_3 = Expr("scalar_3");
WrapInFunction(vec_12, scalar_3);

View File

@ -41,9 +41,9 @@ TEST_F(FlattenBindingsTest, NoBindings) {
TEST_F(FlattenBindingsTest, AlreadyFlat) {
ProgramBuilder b;
b.Global("a", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.Global("b", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(0, 1));
b.Global("c", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(0, 2));
b.GlobalVar("a", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.GlobalVar("b", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(0, 1));
b.GlobalVar("c", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(0, 2));
b.WrapInFunction();
resolver::Resolver resolver(&b);
@ -57,9 +57,9 @@ TEST_F(FlattenBindingsTest, AlreadyFlat) {
TEST_F(FlattenBindingsTest, NotFlat_SingleNamespace) {
ProgramBuilder b;
b.Global("a", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.Global("b", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(1, 1));
b.Global("c", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(2, 2));
b.GlobalVar("a", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.GlobalVar("b", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(1, 1));
b.GlobalVar("c", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(2, 2));
b.WrapInFunction(b.Expr("a"), b.Expr("b"), b.Expr("c"));
resolver::Resolver resolver(&b);
@ -83,29 +83,30 @@ TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) {
ProgramBuilder b;
const size_t num_buffers = 3;
b.Global("buffer1", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.Global("buffer2", b.ty.i32(), ast::StorageClass::kStorage, b.GroupAndBinding(1, 1));
b.Global("buffer3", b.ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead,
b.GlobalVar("buffer1", b.ty.i32(), ast::StorageClass::kUniform, b.GroupAndBinding(0, 0));
b.GlobalVar("buffer2", b.ty.i32(), ast::StorageClass::kStorage, b.GroupAndBinding(1, 1));
b.GlobalVar("buffer3", b.ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead,
b.GroupAndBinding(2, 2));
const size_t num_samplers = 2;
b.Global("sampler1", b.ty.sampler(ast::SamplerKind::kSampler), b.GroupAndBinding(3, 3));
b.Global("sampler2", b.ty.sampler(ast::SamplerKind::kComparisonSampler),
b.GlobalVar("sampler1", b.ty.sampler(ast::SamplerKind::kSampler), b.GroupAndBinding(3, 3));
b.GlobalVar("sampler2", b.ty.sampler(ast::SamplerKind::kComparisonSampler),
b.GroupAndBinding(4, 4));
const size_t num_textures = 6;
b.Global("texture1", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32()),
b.GlobalVar("texture1", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32()),
b.GroupAndBinding(5, 5));
b.Global("texture2", b.ty.multisampled_texture(ast::TextureDimension::k2d, b.ty.f32()),
b.GlobalVar("texture2", b.ty.multisampled_texture(ast::TextureDimension::k2d, b.ty.f32()),
b.GroupAndBinding(6, 6));
b.Global("texture3",
b.GlobalVar("texture3",
b.ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float,
ast::Access::kWrite),
b.GroupAndBinding(7, 7));
b.Global("texture4", b.ty.depth_texture(ast::TextureDimension::k2d), b.GroupAndBinding(8, 8));
b.Global("texture5", b.ty.depth_multisampled_texture(ast::TextureDimension::k2d),
b.GlobalVar("texture4", b.ty.depth_texture(ast::TextureDimension::k2d),
b.GroupAndBinding(8, 8));
b.GlobalVar("texture5", b.ty.depth_multisampled_texture(ast::TextureDimension::k2d),
b.GroupAndBinding(9, 9));
b.Global("texture6", b.ty.external_texture(), b.GroupAndBinding(10, 10));
b.GlobalVar("texture6", b.ty.external_texture(), b.GroupAndBinding(10, 10));
b.WrapInFunction(b.Assign(b.Phony(), "buffer1"), b.Assign(b.Phony(), "buffer2"),
b.Assign(b.Phony(), "buffer3"), b.Assign(b.Phony(), "sampler1"),

View File

@ -37,7 +37,7 @@ TEST_F(GenerateExternalTextureBindingsTest, None) {
TEST_F(GenerateExternalTextureBindingsTest, One) {
ProgramBuilder b;
b.Global("v0", b.ty.external_texture(), b.GroupAndBinding(0, 0));
b.GlobalVar("v0", b.ty.external_texture(), b.GroupAndBinding(0, 0));
b.WrapInFunction();
tint::Program program(std::move(b));
@ -54,8 +54,8 @@ TEST_F(GenerateExternalTextureBindingsTest, One) {
TEST_F(GenerateExternalTextureBindingsTest, Two_SameGroup) {
ProgramBuilder b;
b.Global("v0", b.ty.external_texture(), b.GroupAndBinding(0, 0));
b.Global("v1", b.ty.external_texture(), b.GroupAndBinding(0, 1));
b.GlobalVar("v0", b.ty.external_texture(), b.GroupAndBinding(0, 0));
b.GlobalVar("v1", b.ty.external_texture(), b.GroupAndBinding(0, 1));
b.WrapInFunction();
tint::Program program(std::move(b));
@ -78,8 +78,8 @@ TEST_F(GenerateExternalTextureBindingsTest, Two_SameGroup) {
TEST_F(GenerateExternalTextureBindingsTest, Two_DifferentGroup) {
ProgramBuilder b;
b.Global("v0", b.ty.external_texture(), b.GroupAndBinding(0, 0));
b.Global("v1", b.ty.external_texture(), b.GroupAndBinding(1, 0));
b.GlobalVar("v0", b.ty.external_texture(), b.GroupAndBinding(0, 0));
b.GlobalVar("v1", b.ty.external_texture(), b.GroupAndBinding(1, 0));
b.WrapInFunction();
tint::Program program(std::move(b));
@ -102,11 +102,11 @@ TEST_F(GenerateExternalTextureBindingsTest, Two_DifferentGroup) {
TEST_F(GenerateExternalTextureBindingsTest, Two_WithOtherBindingsInSameGroup) {
ProgramBuilder b;
b.Global("v0", b.ty.i32(), b.GroupAndBinding(0, 0), kUniform);
b.Global("v1", b.ty.external_texture(), b.GroupAndBinding(0, 1));
b.Global("v2", b.ty.i32(), b.GroupAndBinding(0, 2), kUniform);
b.Global("v3", b.ty.external_texture(), b.GroupAndBinding(0, 3));
b.Global("v4", b.ty.i32(), b.GroupAndBinding(0, 4), kUniform);
b.GlobalVar("v0", b.ty.i32(), b.GroupAndBinding(0, 0), kUniform);
b.GlobalVar("v1", b.ty.external_texture(), b.GroupAndBinding(0, 1));
b.GlobalVar("v2", b.ty.i32(), b.GroupAndBinding(0, 2), kUniform);
b.GlobalVar("v3", b.ty.external_texture(), b.GroupAndBinding(0, 3));
b.GlobalVar("v4", b.ty.i32(), b.GroupAndBinding(0, 4), kUniform);
b.WrapInFunction();
tint::Program program(std::move(b));

View File

@ -22,7 +22,7 @@ namespace {
using GlslGeneratorImplTest_Expression = TestHelper;
TEST_F(GlslGeneratorImplTest_Expression, IndexAccessor) {
Global("ary", ty.array<i32, 10>(), ast::StorageClass::kPrivate);
GlobalVar("ary", ty.array<i32, 10>(), ast::StorageClass::kPrivate);
auto* expr = IndexAccessor("ary", 5_i);
WrapInFunction(expr);

View File

@ -20,8 +20,8 @@ namespace {
using GlslGeneratorImplTest_Assign = TestHelper;
TEST_F(GlslGeneratorImplTest_Assign, Emit_Assign) {
Global("lhs", ty.i32(), ast::StorageClass::kPrivate);
Global("rhs", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("lhs", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("rhs", ty.i32(), ast::StorageClass::kPrivate);
auto* assign = Assign("lhs", "rhs");
WrapInFunction(assign);

View File

@ -43,8 +43,8 @@ TEST_P(GlslBinaryTest, Emit_f32) {
return;
}
Global("left", ty.f32(), ast::StorageClass::kPrivate);
Global("right", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("left", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("right", ty.f32(), ast::StorageClass::kPrivate);
auto* left = Expr("left");
auto* right = Expr("right");
@ -62,8 +62,8 @@ TEST_P(GlslBinaryTest, Emit_f32) {
TEST_P(GlslBinaryTest, Emit_u32) {
auto params = GetParam();
Global("left", ty.u32(), ast::StorageClass::kPrivate);
Global("right", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("left", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("right", ty.u32(), ast::StorageClass::kPrivate);
auto* left = Expr("left");
auto* right = Expr("right");
@ -86,8 +86,8 @@ TEST_P(GlslBinaryTest, Emit_i32) {
return;
}
Global("left", ty.i32(), ast::StorageClass::kPrivate);
Global("right", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("left", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("right", ty.i32(), ast::StorageClass::kPrivate);
auto* left = Expr("left");
auto* right = Expr("right");
@ -153,7 +153,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarVector) {
}
TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* lhs = Expr("mat");
auto* rhs = Expr(1_f);
@ -168,7 +168,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
}
TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* lhs = Expr(1_f);
auto* rhs = Expr("mat");
@ -183,7 +183,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
}
TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* lhs = Expr("mat");
auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
@ -198,7 +198,7 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
}
TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
auto* rhs = Expr("mat");
@ -213,8 +213,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_VectorMatrix) {
}
TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixMatrix) {
Global("lhs", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
Global("rhs", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("lhs", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("rhs", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr("lhs"), Expr("rhs"));
WrapInFunction(expr);
@ -227,8 +227,8 @@ TEST_F(GlslGeneratorImplTest_Binary, Multiply_MatrixMatrix) {
}
TEST_F(GlslGeneratorImplTest_Binary, Logical_And) {
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b"));
WrapInFunction(expr);
@ -246,8 +246,8 @@ if (tint_tmp) {
}
TEST_F(GlslGeneratorImplTest_Binary, ModF32) {
Global("a", ty.f32(), ast::StorageClass::kPrivate);
Global("b", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.f32(), ast::StorageClass::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kModulo, Expr("a"), Expr("b"));
WrapInFunction(expr);
@ -260,8 +260,8 @@ TEST_F(GlslGeneratorImplTest_Binary, ModF32) {
}
TEST_F(GlslGeneratorImplTest_Binary, ModVec3F32) {
Global("a", ty.vec3<f32>(), ast::StorageClass::kPrivate);
Global("b", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kModulo, Expr("a"), Expr("b"));
WrapInFunction(expr);
@ -275,10 +275,10 @@ TEST_F(GlslGeneratorImplTest_Binary, ModVec3F32) {
TEST_F(GlslGeneratorImplTest_Binary, Logical_Multi) {
// (a && b) || (c || d)
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
Global("c", ty.bool_(), ast::StorageClass::kPrivate);
Global("d", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("c", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("d", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr = create<ast::BinaryExpression>(
ast::BinaryOp::kLogicalOr,
@ -307,8 +307,8 @@ if (!tint_tmp) {
}
TEST_F(GlslGeneratorImplTest_Binary, Logical_Or) {
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, Expr("a"), Expr("b"));
WrapInFunction(expr);
@ -334,9 +334,9 @@ TEST_F(GlslGeneratorImplTest_Binary, If_WithLogical) {
// return 3i;
// }
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
Global("c", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("c", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr =
If(create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b")),
@ -371,9 +371,9 @@ if ((tint_tmp)) {
TEST_F(GlslGeneratorImplTest_Binary, Return_WithLogical) {
// return (a && b) || c;
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
Global("c", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("c", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr = Return(create<ast::BinaryExpression>(
ast::BinaryOp::kLogicalOr,
@ -399,10 +399,10 @@ return (tint_tmp);
TEST_F(GlslGeneratorImplTest_Binary, Assign_WithLogical) {
// a = (b || c) && d;
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
Global("c", ty.bool_(), ast::StorageClass::kPrivate);
Global("d", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("c", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("d", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr =
Assign(Expr("a"),
@ -430,9 +430,9 @@ a = (tint_tmp);
TEST_F(GlslGeneratorImplTest_Binary, Decl_WithLogical) {
// var a : bool = (b && c) || d;
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
Global("c", ty.bool_(), ast::StorageClass::kPrivate);
Global("d", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("c", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("d", ty.bool_(), ast::StorageClass::kPrivate);
auto* var =
Var("a", ty.bool_(), ast::StorageClass::kNone,
@ -469,10 +469,10 @@ TEST_F(GlslGeneratorImplTest_Binary, Call_WithLogical) {
Param(Sym(), ty.bool_()),
},
ty.void_(), ast::StatementList{}, ast::AttributeList{});
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
Global("c", ty.bool_(), ast::StorageClass::kPrivate);
Global("d", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("c", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("d", ty.bool_(), ast::StorageClass::kPrivate);
ast::ExpressionList params;
params.push_back(

View File

@ -153,13 +153,13 @@ using GlslBuiltinTest = TestParamHelper<BuiltinData>;
TEST_P(GlslBuiltinTest, Emit) {
auto param = GetParam();
Global("f2", ty.vec2<f32>(), ast::StorageClass::kPrivate);
Global("f3", ty.vec3<f32>(), ast::StorageClass::kPrivate);
Global("u2", ty.vec2<u32>(), ast::StorageClass::kPrivate);
Global("i2", ty.vec2<i32>(), ast::StorageClass::kPrivate);
Global("b2", ty.vec2<bool>(), ast::StorageClass::kPrivate);
Global("m2x2", ty.mat2x2<f32>(), ast::StorageClass::kPrivate);
Global("m3x2", ty.mat3x2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("f2", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("f3", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("u2", ty.vec2<u32>(), ast::StorageClass::kPrivate);
GlobalVar("i2", ty.vec2<i32>(), ast::StorageClass::kPrivate);
GlobalVar("b2", ty.vec2<bool>(), ast::StorageClass::kPrivate);
GlobalVar("m2x2", ty.mat2x2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("m3x2", ty.mat3x2<f32>(), ast::StorageClass::kPrivate);
auto* call = GenerateCall(param.builtin, param.type, this);
ASSERT_NE(nullptr, call) << "Unhandled builtin";
@ -242,8 +242,8 @@ INSTANTIATE_TEST_SUITE_P(
TEST_F(GlslGeneratorImplTest_Builtin, Builtin_Call) {
auto* call = Call("dot", "param1", "param2");
Global("param1", ty.vec3<f32>(), ast::StorageClass::kPrivate);
Global("param2", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("param1", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("param2", ty.vec3<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
@ -584,7 +584,7 @@ void main() {
TEST_F(GlslGeneratorImplTest_Builtin, Pack4x8Snorm) {
auto* call = Call("pack4x8snorm", "p1");
Global("p1", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.vec4<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -602,7 +602,7 @@ void test_function() {
TEST_F(GlslGeneratorImplTest_Builtin, Pack4x8Unorm) {
auto* call = Call("pack4x8unorm", "p1");
Global("p1", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.vec4<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -620,7 +620,7 @@ void test_function() {
TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Snorm) {
auto* call = Call("pack2x16snorm", "p1");
Global("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -638,7 +638,7 @@ void test_function() {
TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Unorm) {
auto* call = Call("pack2x16unorm", "p1");
Global("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -656,7 +656,7 @@ void test_function() {
TEST_F(GlslGeneratorImplTest_Builtin, Pack2x16Float) {
auto* call = Call("pack2x16float", "p1");
Global("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -674,7 +674,7 @@ void test_function() {
TEST_F(GlslGeneratorImplTest_Builtin, Unpack4x8Snorm) {
auto* call = Call("unpack4x8snorm", "p1");
Global("p1", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.u32(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -692,7 +692,7 @@ void test_function() {
TEST_F(GlslGeneratorImplTest_Builtin, Unpack4x8Unorm) {
auto* call = Call("unpack4x8unorm", "p1");
Global("p1", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.u32(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -710,7 +710,7 @@ void test_function() {
TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Snorm) {
auto* call = Call("unpack2x16snorm", "p1");
Global("p1", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.u32(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -728,7 +728,7 @@ void test_function() {
TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Unorm) {
auto* call = Call("unpack2x16unorm", "p1");
Global("p1", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.u32(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -746,7 +746,7 @@ void test_function() {
TEST_F(GlslGeneratorImplTest_Builtin, Unpack2x16Float) {
auto* call = Call("unpack2x16float", "p1");
Global("p1", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.u32(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -803,7 +803,7 @@ void main() {
}
TEST_F(GlslGeneratorImplTest_Builtin, DotI32) {
Global("v", ty.vec3<i32>(), ast::StorageClass::kPrivate);
GlobalVar("v", ty.vec3<i32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(Call("dot", "v", "v")));
GeneratorImpl& gen = SanitizeAndBuild();
@ -831,9 +831,9 @@ void main() {
TEST_F(GlslGeneratorImplTest_Builtin, FMA) {
auto* call = Call("fma", "a", "b", "c");
Global("a", ty.vec3<f32>(), ast::StorageClass::kPrivate);
Global("b", ty.vec3<f32>(), ast::StorageClass::kPrivate);
Global("c", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("c", ty.vec3<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
@ -846,7 +846,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, FMA) {
}
TEST_F(GlslGeneratorImplTest_Builtin, DotU32) {
Global("v", ty.vec3<u32>(), ast::StorageClass::kPrivate);
GlobalVar("v", ty.vec3<u32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(Call("dot", "v", "v")));
GeneratorImpl& gen = SanitizeAndBuild();

View File

@ -42,8 +42,8 @@ TEST_F(GlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) {
Param(Sym(), ty.f32()),
},
ty.f32(), {Return(1.23_f)});
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("param1", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("param2", ty.f32(), ast::StorageClass::kPrivate);
auto* call = Call("my_func", "param1", "param2");
WrapInFunction(call);
@ -62,8 +62,8 @@ TEST_F(GlslGeneratorImplTest_Call, EmitStatement_Call) {
Param(Sym(), ty.f32()),
},
ty.void_(), ast::StatementList{}, ast::AttributeList{});
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("param1", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("param2", ty.f32(), ast::StorageClass::kPrivate);
auto* call = CallStmt(Call("my_func", "param1", "param2"));
WrapInFunction(call);

View File

@ -349,7 +349,7 @@ tint_symbol_2 vert_main2() {
TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())});
auto* ubo = Global("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -403,7 +403,7 @@ void frag_main() {
TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStruct) {
auto* s = Structure("Uniforms", {Member("coord", ty.vec4<f32>())});
Global("uniforms", ty.Of(s), ast::StorageClass::kUniform,
GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -448,7 +448,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage
Member("b", ty.f32()),
});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -498,7 +498,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage
Member("b", ty.f32()),
});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -549,7 +549,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage
Member("b", ty.f32()),
});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -597,7 +597,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf
Member("b", ty.f32()),
});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -641,7 +641,7 @@ void main() {
TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_Uniform) {
auto* s = Structure("S", {Member("x", ty.f32())});
Global("coord", ty.Of(s), ast::StorageClass::kUniform,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -690,7 +690,7 @@ void frag_main() {
TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) {
auto* s = Structure("S", {Member("x", ty.f32())});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -922,7 +922,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module
auto* s = Structure("Data", {Member("d", ty.f32())});
Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),

View File

@ -20,7 +20,7 @@ namespace {
using GlslGeneratorImplTest_Identifier = TestHelper;
TEST_F(GlslGeneratorImplTest_Identifier, EmitIdentifierExpression) {
Global("foo", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("foo", ty.i32(), ast::StorageClass::kPrivate);
auto* i = Expr("foo");
WrapInFunction(i);

View File

@ -20,7 +20,7 @@ namespace {
using GlslGeneratorImplTest_If = TestHelper;
TEST_F(GlslGeneratorImplTest_If, Emit_If) {
Global("cond", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("cond", ty.bool_(), ast::StorageClass::kPrivate);
auto* cond = Expr("cond");
auto* body = Block(Return());
@ -38,8 +38,8 @@ TEST_F(GlslGeneratorImplTest_If, Emit_If) {
}
TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElseIf) {
Global("cond", ty.bool_(), ast::StorageClass::kPrivate);
Global("else_cond", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("cond", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("else_cond", ty.bool_(), ast::StorageClass::kPrivate);
auto* else_cond = Expr("else_cond");
auto* else_body = Block(Return());
@ -65,7 +65,7 @@ TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElseIf) {
}
TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElse) {
Global("cond", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("cond", ty.bool_(), ast::StorageClass::kPrivate);
auto* else_body = Block(Return());
@ -88,8 +88,8 @@ TEST_F(GlslGeneratorImplTest_If, Emit_IfWithElse) {
}
TEST_F(GlslGeneratorImplTest_If, Emit_IfWithMultiple) {
Global("cond", ty.bool_(), ast::StorageClass::kPrivate);
Global("else_cond", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("cond", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("else_cond", ty.bool_(), ast::StorageClass::kPrivate);
auto* else_cond = Expr("else_cond");

View File

@ -256,7 +256,7 @@ INSTANTIATE_TEST_SUITE_P(GlslGeneratorImplTest_Import,
testing::Values(GlslImportData{"clamp", "clamp"}));
TEST_F(GlslGeneratorImplTest_Import, GlslImportData_Determinant) {
Global("var", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("var", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* expr = Call("determinant", "var");
WrapInFunction(expr);

View File

@ -66,8 +66,8 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithContinuing) {
TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) {
Func("a_statement", {}, ty.void_(), {});
Global("lhs", ty.f32(), ast::StorageClass::kPrivate);
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("lhs", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("rhs", ty.f32(), ast::StorageClass::kPrivate);
auto* body = Block(create<ast::DiscardStatement>());
auto* continuing = Block(CallStmt(Call("a_statement")));
@ -112,7 +112,7 @@ TEST_F(GlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
// }
// }
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("rhs", ty.f32(), ast::StorageClass::kPrivate);
auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4_f))), //
Decl(Var("other", ty.f32())), //

View File

@ -91,7 +91,7 @@ class GlslGeneratorImplTest_MemberAccessorBase : public BASE {
auto* s = b.Structure("Data", members);
b.Global("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
b.create<ast::BindingAttribute>(0),
b.create<ast::GroupAttribute>(1),
@ -115,7 +115,7 @@ using GlslGeneratorImplTest_MemberAccessorWithParam =
TEST_F(GlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
auto* s = Structure("Data", {Member("mem", ty.f32())});
Global("str", ty.Of(s), ast::StorageClass::kPrivate);
GlobalVar("str", ty.Of(s), ast::StorageClass::kPrivate);
auto* expr = MemberAccessor("str", "mem");
WrapInFunction(Var("expr", ty.f32(), ast::StorageClass::kNone, expr));

View File

@ -26,7 +26,7 @@ using GlslSanitizerTest = TestHelper;
TEST_F(GlslSanitizerTest, Call_ArrayLength) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -69,7 +69,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
Member(0, "z", ty.f32()),
Member(4, "a", ty.array<f32>(4)),
});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -111,7 +111,7 @@ void main() {
TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),

View File

@ -35,7 +35,7 @@ void TestAlign(ProgramBuilder* ctx) {
ctx->Member("dewey", ctx->ty.f32(), {ctx->MemberAlign(256)}),
ctx->Member("louie", ctx->ty.f32(), {ctx->MemberAlign(256)}),
});
ctx->Global("nephews", ctx->ty.Of(nephews), ast::StorageClass::kStorage,
ctx->GlobalVar("nephews", ctx->ty.Of(nephews), ast::StorageClass::kStorage,
ast::AttributeList{
ctx->create<ast::BindingAttribute>(0),
ctx->create<ast::GroupAttribute>(0),

View File

@ -22,7 +22,7 @@ namespace {
using GlslGeneratorImplTest_Switch = TestHelper;
TEST_F(GlslGeneratorImplTest_Switch, Emit_Switch) {
Global("cond", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("cond", ty.i32(), ast::StorageClass::kPrivate);
auto* def_body = Block(create<ast::BreakStatement>());
auto* def = create<ast::CaseStatement>(ast::CaseSelectorList{}, def_body);

View File

@ -57,7 +57,7 @@ void my_func() {
}
TEST_F(GlslGeneratorImplTest, GenerateSampleIndexES) {
Global("gl_SampleID", ty.i32(),
GlobalVar("gl_SampleID", ty.i32(),
ast::AttributeList{
Builtin(ast::Builtin::kSampleIndex),
Disable(ast::DisabledValidation::kIgnoreStorageClass),
@ -82,7 +82,7 @@ int my_func() {
}
TEST_F(GlslGeneratorImplTest, GenerateSampleIndexDesktop) {
Global("gl_SampleID", ty.i32(),
GlobalVar("gl_SampleID", ty.i32(),
ast::AttributeList{
Builtin(ast::Builtin::kSampleIndex),
Disable(ast::DisabledValidation::kIgnoreStorageClass),

View File

@ -33,7 +33,7 @@ using GlslGeneratorImplTest_Type = TestHelper;
TEST_F(GlslGeneratorImplTest_Type, EmitType_Array) {
auto* arr = ty.array<bool, 4>();
Global("G", arr, ast::StorageClass::kPrivate);
GlobalVar("G", arr, ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -46,7 +46,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Array) {
TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
auto* arr = ty.array(ty.array<bool, 4>(), 5_u);
Global("G", arr, ast::StorageClass::kPrivate);
GlobalVar("G", arr, ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -59,7 +59,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
auto* arr = ty.array(ty.array(ty.array<bool, 4>(), 5_u), 6_u);
Global("G", arr, ast::StorageClass::kPrivate);
GlobalVar("G", arr, ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -72,7 +72,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
TEST_F(GlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
auto* arr = ty.array<bool, 4>();
Global("G", arr, ast::StorageClass::kPrivate);
GlobalVar("G", arr, ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -134,7 +134,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_StructDecl) {
Member("a", ty.i32()),
Member("b", ty.f32()),
});
Global("g", ty.Of(s), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(s), ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -154,7 +154,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct) {
Member("a", ty.i32()),
Member("b", ty.f32()),
});
Global("g", ty.Of(s), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(s), ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -170,7 +170,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) {
Member("double", ty.i32()),
Member("float", ty.f32()),
});
Global("g", ty.Of(s), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(s), ast::StorageClass::kPrivate);
GeneratorImpl& gen = SanitizeAndBuild();
@ -187,7 +187,7 @@ TEST_F(GlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) {
Member("a", ty.i32(), {MemberOffset(0)}),
Member("b", ty.f32(), {MemberOffset(8)}),
});
Global("g", ty.Of(s), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(s), ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -270,7 +270,7 @@ TEST_P(GlslDepthTexturesTest, Emit) {
auto* t = ty.depth_texture(params.dim);
Global("tex", t,
GlobalVar("tex", t,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -297,7 +297,7 @@ using GlslDepthMultisampledTexturesTest = TestHelper;
TEST_F(GlslDepthMultisampledTexturesTest, Emit) {
auto* t = ty.depth_multisampled_texture(ast::TextureDimension::k2d);
Global("tex", t,
GlobalVar("tex", t,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -340,7 +340,7 @@ TEST_P(GlslSampledTexturesTest, Emit) {
}
auto* t = ty.sampled_texture(params.dim, datatype);
Global("tex", t,
GlobalVar("tex", t,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -474,7 +474,7 @@ TEST_P(GlslStorageTexturesTest, Emit) {
auto* t = ty.storage_texture(params.dim, params.imgfmt, ast::Access::kWrite);
Global("tex", t,
GlobalVar("tex", t,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),

View File

@ -20,7 +20,7 @@ namespace {
using GlslUnaryOpTest = TestHelper;
TEST_F(GlslUnaryOpTest, AddressOf) {
Global("expr", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("expr", ty.f32(), ast::StorageClass::kPrivate);
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kAddressOf, Expr("expr"));
WrapInFunction(op);
@ -32,7 +32,7 @@ TEST_F(GlslUnaryOpTest, AddressOf) {
}
TEST_F(GlslUnaryOpTest, Complement) {
Global("expr", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("expr", ty.u32(), ast::StorageClass::kPrivate);
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kComplement, Expr("expr"));
WrapInFunction(op);
@ -44,7 +44,7 @@ TEST_F(GlslUnaryOpTest, Complement) {
}
TEST_F(GlslUnaryOpTest, Indirection) {
Global("G", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("G", ty.f32(), ast::StorageClass::kPrivate);
auto* p =
Let("expr", nullptr, create<ast::UnaryOpExpression>(ast::UnaryOp::kAddressOf, Expr("G")));
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kIndirection, Expr("expr"));
@ -58,7 +58,7 @@ TEST_F(GlslUnaryOpTest, Indirection) {
}
TEST_F(GlslUnaryOpTest, Not) {
Global("expr", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("expr", ty.bool_(), ast::StorageClass::kPrivate);
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kNot, Expr("expr"));
WrapInFunction(op);
@ -70,7 +70,7 @@ TEST_F(GlslUnaryOpTest, Not) {
}
TEST_F(GlslUnaryOpTest, Negation) {
Global("expr", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("expr", ty.i32(), ast::StorageClass::kPrivate);
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kNegation, Expr("expr"));
WrapInFunction(op);

View File

@ -24,7 +24,7 @@ using GlslGeneratorImplTest_UniformBuffer = TestHelper;
TEST_F(GlslGeneratorImplTest_UniformBuffer, Simple) {
auto* simple = Structure("Simple", {Member("member", ty.f32())});
Global("simple", ty.Of(simple), ast::StorageClass::kUniform, GroupAndBinding(0, 0));
GlobalVar("simple", ty.Of(simple), ast::StorageClass::kUniform, GroupAndBinding(0, 0));
GeneratorImpl& gen = Build();
@ -44,7 +44,7 @@ layout(binding = 0) uniform Simple_1 {
TEST_F(GlslGeneratorImplTest_UniformBuffer, Simple_Desktop) {
auto* simple = Structure("Simple", {Member("member", ty.f32())});
Global("simple", ty.Of(simple), ast::StorageClass::kUniform, GroupAndBinding(0, 0));
GlobalVar("simple", ty.Of(simple), ast::StorageClass::kUniform, GroupAndBinding(0, 0));
GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4));

View File

@ -64,7 +64,7 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) {
}
TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) {
Global("a", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate);
WrapInFunction(Expr("a"));
@ -77,8 +77,8 @@ TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) {
}
TEST_F(GlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initializer_Private) {
Global("initializer", ty.f32(), ast::StorageClass::kPrivate);
Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr("initializer"));
GlobalVar("initializer", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate, Expr("initializer"));
WrapInFunction(Expr("a"));

View File

@ -27,7 +27,7 @@ namespace {
using GlslGeneratorImplTest_WorkgroupVar = TestHelper;
TEST_F(GlslGeneratorImplTest_WorkgroupVar, Basic) {
Global("wg", ty.f32(), ast::StorageClass::kWorkgroup);
GlobalVar("wg", ty.f32(), ast::StorageClass::kWorkgroup);
Func("main", {}, ty.void_(), {Assign("wg", 1.2_f)},
{
@ -43,7 +43,7 @@ TEST_F(GlslGeneratorImplTest_WorkgroupVar, Basic) {
TEST_F(GlslGeneratorImplTest_WorkgroupVar, Aliased) {
auto* alias = Alias("F32", ty.f32());
Global("wg", ty.Of(alias), ast::StorageClass::kWorkgroup);
GlobalVar("wg", ty.Of(alias), ast::StorageClass::kWorkgroup);
Func("main", {}, ty.void_(), {Assign("wg", 1.2_f)},
{

View File

@ -22,7 +22,7 @@ namespace {
using HlslGeneratorImplTest_Expression = TestHelper;
TEST_F(HlslGeneratorImplTest_Expression, IndexAccessor) {
Global("ary", ty.array<i32, 10>(), ast::StorageClass::kPrivate);
GlobalVar("ary", ty.array<i32, 10>(), ast::StorageClass::kPrivate);
auto* expr = IndexAccessor("ary", 5_i);
WrapInFunction(expr);

View File

@ -50,8 +50,8 @@ TEST_P(HlslBinaryTest, Emit_f32) {
return;
}
Global("left", ty.f32(), ast::StorageClass::kPrivate);
Global("right", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("left", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("right", ty.f32(), ast::StorageClass::kPrivate);
auto* left = Expr("left");
auto* right = Expr("right");
@ -73,8 +73,8 @@ TEST_P(HlslBinaryTest, Emit_u32) {
return;
}
Global("left", ty.u32(), ast::StorageClass::kPrivate);
Global("right", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("left", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("right", ty.u32(), ast::StorageClass::kPrivate);
auto* left = Expr("left");
auto* right = Expr("right");
@ -101,8 +101,8 @@ TEST_P(HlslBinaryTest, Emit_i32) {
return;
}
Global("left", ty.i32(), ast::StorageClass::kPrivate);
Global("right", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("left", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("right", ty.i32(), ast::StorageClass::kPrivate);
auto* left = Expr("left");
auto* right = Expr("right");
@ -171,7 +171,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarVector) {
}
TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* lhs = Expr("mat");
auto* rhs = Expr(1_f);
@ -186,7 +186,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixScalar) {
}
TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* lhs = Expr(1_f);
auto* rhs = Expr("mat");
@ -201,7 +201,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_ScalarMatrix) {
}
TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* lhs = Expr("mat");
auto* rhs = vec3<f32>(1_f, 1_f, 1_f);
@ -216,7 +216,7 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixVector) {
}
TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix) {
Global("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("mat", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* lhs = vec3<f32>(1_f, 1_f, 1_f);
auto* rhs = Expr("mat");
@ -231,8 +231,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_VectorMatrix) {
}
TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix) {
Global("lhs", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
Global("rhs", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("lhs", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("rhs", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kMultiply, Expr("lhs"), Expr("rhs"));
WrapInFunction(expr);
@ -245,8 +245,8 @@ TEST_F(HlslGeneratorImplTest_Binary, Multiply_MatrixMatrix) {
}
TEST_F(HlslGeneratorImplTest_Binary, Logical_And) {
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b"));
WrapInFunction(expr);
@ -265,10 +265,10 @@ if (tint_tmp) {
TEST_F(HlslGeneratorImplTest_Binary, Logical_Multi) {
// (a && b) || (c || d)
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
Global("c", ty.bool_(), ast::StorageClass::kPrivate);
Global("d", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("c", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("d", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr = create<ast::BinaryExpression>(
ast::BinaryOp::kLogicalOr,
@ -297,8 +297,8 @@ if (!tint_tmp) {
}
TEST_F(HlslGeneratorImplTest_Binary, Logical_Or) {
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, Expr("a"), Expr("b"));
WrapInFunction(expr);
@ -324,9 +324,9 @@ TEST_F(HlslGeneratorImplTest_Binary, If_WithLogical) {
// return 3i;
// }
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
Global("c", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("c", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr =
If(create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b")),
@ -361,9 +361,9 @@ if ((tint_tmp)) {
TEST_F(HlslGeneratorImplTest_Binary, Return_WithLogical) {
// return (a && b) || c;
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
Global("c", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("c", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr = Return(create<ast::BinaryExpression>(
ast::BinaryOp::kLogicalOr,
@ -389,10 +389,10 @@ return (tint_tmp);
TEST_F(HlslGeneratorImplTest_Binary, Assign_WithLogical) {
// a = (b || c) && d;
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
Global("c", ty.bool_(), ast::StorageClass::kPrivate);
Global("d", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("c", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("d", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr =
Assign(Expr("a"),
@ -420,9 +420,9 @@ a = (tint_tmp);
TEST_F(HlslGeneratorImplTest_Binary, Decl_WithLogical) {
// var a : bool = (b && c) || d;
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
Global("c", ty.bool_(), ast::StorageClass::kPrivate);
Global("d", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("c", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("d", ty.bool_(), ast::StorageClass::kPrivate);
auto* var =
Var("a", ty.bool_(), ast::StorageClass::kNone,
@ -459,10 +459,10 @@ TEST_F(HlslGeneratorImplTest_Binary, Call_WithLogical) {
Param(Sym(), ty.bool_()),
},
ty.void_(), ast::StatementList{}, ast::AttributeList{});
Global("a", ty.bool_(), ast::StorageClass::kPrivate);
Global("b", ty.bool_(), ast::StorageClass::kPrivate);
Global("c", ty.bool_(), ast::StorageClass::kPrivate);
Global("d", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("c", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("d", ty.bool_(), ast::StorageClass::kPrivate);
ast::ExpressionList params;
params.push_back(

View File

@ -152,13 +152,13 @@ using HlslBuiltinTest = TestParamHelper<BuiltinData>;
TEST_P(HlslBuiltinTest, Emit) {
auto param = GetParam();
Global("f2", ty.vec2<f32>(), ast::StorageClass::kPrivate);
Global("f3", ty.vec3<f32>(), ast::StorageClass::kPrivate);
Global("u2", ty.vec2<u32>(), ast::StorageClass::kPrivate);
Global("i2", ty.vec2<i32>(), ast::StorageClass::kPrivate);
Global("b2", ty.vec2<bool>(), ast::StorageClass::kPrivate);
Global("m2x2", ty.mat2x2<f32>(), ast::StorageClass::kPrivate);
Global("m3x2", ty.mat3x2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("f2", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("f3", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("u2", ty.vec2<u32>(), ast::StorageClass::kPrivate);
GlobalVar("i2", ty.vec2<i32>(), ast::StorageClass::kPrivate);
GlobalVar("b2", ty.vec2<bool>(), ast::StorageClass::kPrivate);
GlobalVar("m2x2", ty.mat2x2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("m3x2", ty.mat3x2<f32>(), ast::StorageClass::kPrivate);
auto* call = GenerateCall(param.builtin, param.type, this);
ASSERT_NE(nullptr, call) << "Unhandled builtin";
@ -241,8 +241,8 @@ INSTANTIATE_TEST_SUITE_P(
TEST_F(HlslGeneratorImplTest_Builtin, Builtin_Call) {
auto* call = Call("dot", "param1", "param2");
Global("param1", ty.vec3<f32>(), ast::StorageClass::kPrivate);
Global("param2", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("param1", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("param2", ty.vec3<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
@ -466,7 +466,7 @@ void test_function() {
TEST_F(HlslGeneratorImplTest_Builtin, Pack4x8Snorm) {
auto* call = Call("pack4x8snorm", "p1");
Global("p1", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.vec4<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -488,7 +488,7 @@ void test_function() {
TEST_F(HlslGeneratorImplTest_Builtin, Pack4x8Unorm) {
auto* call = Call("pack4x8unorm", "p1");
Global("p1", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.vec4<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -510,7 +510,7 @@ void test_function() {
TEST_F(HlslGeneratorImplTest_Builtin, Pack2x16Snorm) {
auto* call = Call("pack2x16snorm", "p1");
Global("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -532,7 +532,7 @@ void test_function() {
TEST_F(HlslGeneratorImplTest_Builtin, Pack2x16Unorm) {
auto* call = Call("pack2x16unorm", "p1");
Global("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -554,7 +554,7 @@ void test_function() {
TEST_F(HlslGeneratorImplTest_Builtin, Pack2x16Float) {
auto* call = Call("pack2x16float", "p1");
Global("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -576,7 +576,7 @@ void test_function() {
TEST_F(HlslGeneratorImplTest_Builtin, Unpack4x8Snorm) {
auto* call = Call("unpack4x8snorm", "p1");
Global("p1", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.u32(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -599,7 +599,7 @@ void test_function() {
TEST_F(HlslGeneratorImplTest_Builtin, Unpack4x8Unorm) {
auto* call = Call("unpack4x8unorm", "p1");
Global("p1", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.u32(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -622,7 +622,7 @@ void test_function() {
TEST_F(HlslGeneratorImplTest_Builtin, Unpack2x16Snorm) {
auto* call = Call("unpack2x16snorm", "p1");
Global("p1", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.u32(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -645,7 +645,7 @@ void test_function() {
TEST_F(HlslGeneratorImplTest_Builtin, Unpack2x16Unorm) {
auto* call = Call("unpack2x16unorm", "p1");
Global("p1", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.u32(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -668,7 +668,7 @@ void test_function() {
TEST_F(HlslGeneratorImplTest_Builtin, Unpack2x16Float) {
auto* call = Call("unpack2x16float", "p1");
Global("p1", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.u32(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();

View File

@ -42,8 +42,8 @@ TEST_F(HlslGeneratorImplTest_Call, EmitExpression_Call_WithParams) {
Param(Sym(), ty.f32()),
},
ty.f32(), {Return(1.23_f)});
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("param1", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("param2", ty.f32(), ast::StorageClass::kPrivate);
auto* call = Call("my_func", "param1", "param2");
WrapInFunction(call);
@ -62,8 +62,8 @@ TEST_F(HlslGeneratorImplTest_Call, EmitStatement_Call) {
Param(Sym(), ty.f32()),
},
ty.void_(), ast::StatementList{}, ast::AttributeList{});
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("param1", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("param2", ty.f32(), ast::StorageClass::kPrivate);
auto* call = CallStmt(Call("my_func", "param1", "param2"));
WrapInFunction(call);

View File

@ -346,7 +346,7 @@ tint_symbol_1 vert_main2() {
TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) {
auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())});
auto* ubo = Global("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -393,7 +393,7 @@ void frag_main() {
TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStruct) {
auto* s = Structure("Uniforms", {Member("coord", ty.vec4<f32>())});
Global("uniforms", ty.Of(s), ast::StorageClass::kUniform,
GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -431,7 +431,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage
Member("b", ty.f32()),
});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -467,7 +467,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage
Member("b", ty.f32()),
});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -503,7 +503,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage
Member("b", ty.f32()),
});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -537,7 +537,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf
Member("b", ty.f32()),
});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -567,7 +567,7 @@ void frag_main() {
TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_Uniform) {
auto* s = Structure("S", {Member("x", ty.f32())});
Global("coord", ty.Of(s), ast::StorageClass::kUniform,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -613,7 +613,7 @@ void frag_main() {
TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) {
auto* s = Structure("S", {Member("x", ty.f32())});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(1),
@ -863,7 +863,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module
auto* s = Structure("Data", {Member("d", ty.f32())});
Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),

View File

@ -20,7 +20,7 @@ namespace {
using HlslGeneratorImplTest_Identifier = TestHelper;
TEST_F(HlslGeneratorImplTest_Identifier, EmitIdentifierExpression) {
Global("foo", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("foo", ty.i32(), ast::StorageClass::kPrivate);
auto* i = Expr("foo");
WrapInFunction(i);

View File

@ -20,7 +20,7 @@ namespace {
using HlslGeneratorImplTest_If = TestHelper;
TEST_F(HlslGeneratorImplTest_If, Emit_If) {
Global("cond", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("cond", ty.bool_(), ast::StorageClass::kPrivate);
auto* cond = Expr("cond");
auto* body = Block(Return());
@ -38,8 +38,8 @@ TEST_F(HlslGeneratorImplTest_If, Emit_If) {
}
TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElseIf) {
Global("cond", ty.bool_(), ast::StorageClass::kPrivate);
Global("else_cond", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("cond", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("else_cond", ty.bool_(), ast::StorageClass::kPrivate);
auto* else_cond = Expr("else_cond");
auto* else_body = Block(Return());
@ -65,7 +65,7 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElseIf) {
}
TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElse) {
Global("cond", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("cond", ty.bool_(), ast::StorageClass::kPrivate);
auto* else_body = Block(Return());
@ -88,8 +88,8 @@ TEST_F(HlslGeneratorImplTest_If, Emit_IfWithElse) {
}
TEST_F(HlslGeneratorImplTest_If, Emit_IfWithMultiple) {
Global("cond", ty.bool_(), ast::StorageClass::kPrivate);
Global("else_cond", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("cond", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("else_cond", ty.bool_(), ast::StorageClass::kPrivate);
auto* else_cond = Expr("else_cond");

View File

@ -259,7 +259,7 @@ INSTANTIATE_TEST_SUITE_P(HlslGeneratorImplTest_Import,
testing::Values(HlslImportData{"clamp", "clamp"}));
TEST_F(HlslGeneratorImplTest_Import, HlslImportData_Determinant) {
Global("var", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("var", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* expr = Call("determinant", "var");
WrapInFunction(expr);

View File

@ -66,8 +66,8 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithContinuing) {
TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopNestedWithContinuing) {
Func("a_statement", {}, ty.void_(), {});
Global("lhs", ty.f32(), ast::StorageClass::kPrivate);
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("lhs", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("rhs", ty.f32(), ast::StorageClass::kPrivate);
auto* body = Block(create<ast::DiscardStatement>());
auto* continuing = Block(CallStmt(Call("a_statement")));
@ -112,7 +112,7 @@ TEST_F(HlslGeneratorImplTest_Loop, Emit_LoopWithVarUsedInContinuing) {
// }
// }
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("rhs", ty.f32(), ast::StorageClass::kPrivate);
auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4_f))), //
Decl(Var("other", ty.f32())), //

View File

@ -91,7 +91,7 @@ class HlslGeneratorImplTest_MemberAccessorBase : public BASE {
auto* s = b.Structure("Data", members);
b.Global("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
b.create<ast::BindingAttribute>(0),
b.create<ast::GroupAttribute>(1),
@ -115,7 +115,7 @@ using HlslGeneratorImplTest_MemberAccessorWithParam =
TEST_F(HlslGeneratorImplTest_MemberAccessor, EmitExpression_MemberAccessor) {
auto* s = Structure("Data", {Member("mem", ty.f32())});
Global("str", ty.Of(s), ast::StorageClass::kPrivate);
GlobalVar("str", ty.Of(s), ast::StorageClass::kPrivate);
auto* expr = MemberAccessor("str", "mem");
WrapInFunction(Var("expr", ty.f32(), ast::StorageClass::kNone, expr));

View File

@ -26,7 +26,7 @@ using HlslSanitizerTest = TestHelper;
TEST_F(HlslSanitizerTest, Call_ArrayLength) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -64,7 +64,7 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
Member(0, "z", ty.f32()),
Member(4, "a", ty.array<f32>(4)),
});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -100,7 +100,7 @@ void a_func() {
TEST_F(HlslSanitizerTest, Call_ArrayLength_ViaLets) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -140,12 +140,12 @@ void a_func() {
TEST_F(HlslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
});
Global("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(2),
create<ast::GroupAttribute>(2),

View File

@ -22,7 +22,7 @@ namespace {
using HlslGeneratorImplTest_Switch = TestHelper;
TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) {
Global("cond", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("cond", ty.i32(), ast::StorageClass::kPrivate);
auto* s = Switch( //
Expr("cond"), //
Case(Expr(5_i), Block(Break())), //
@ -46,8 +46,8 @@ TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch) {
}
TEST_F(HlslGeneratorImplTest_Switch, Emit_Switch_OnlyDefaultCase) {
Global("cond", ty.i32(), ast::StorageClass::kPrivate);
Global("a", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("cond", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.i32(), ast::StorageClass::kPrivate);
auto* s = Switch( //
Expr("cond"), //
DefaultCase(Block(Assign(Expr("a"), Expr(42_i)))));

View File

@ -33,7 +33,7 @@ using HlslGeneratorImplTest_Type = TestHelper;
TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) {
auto* arr = ty.array<bool, 4>();
Global("G", arr, ast::StorageClass::kPrivate);
GlobalVar("G", arr, ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -46,7 +46,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) {
TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
auto* arr = ty.array(ty.array<bool, 4>(), 5_u);
Global("G", arr, ast::StorageClass::kPrivate);
GlobalVar("G", arr, ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -59,7 +59,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArray) {
TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
auto* arr = ty.array(ty.array(ty.array<bool, 4>(), 5_u), 6_u);
Global("G", arr, ast::StorageClass::kPrivate);
GlobalVar("G", arr, ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -72,7 +72,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_ArrayOfArrayOfArray) {
TEST_F(HlslGeneratorImplTest_Type, EmitType_Array_WithoutName) {
auto* arr = ty.array<bool, 4>();
Global("G", arr, ast::StorageClass::kPrivate);
GlobalVar("G", arr, ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -134,7 +134,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl) {
Member("a", ty.i32()),
Member("b", ty.f32()),
});
Global("g", ty.Of(s), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(s), ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -153,7 +153,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl_OmittedIfStorageBuffer) {
Member("a", ty.i32()),
Member("b", ty.f32()),
});
Global("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -170,7 +170,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct) {
Member("a", ty.i32()),
Member("b", ty.f32()),
});
Global("g", ty.Of(s), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(s), ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -186,7 +186,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_NameCollision) {
Member("double", ty.i32()),
Member("float", ty.f32()),
});
Global("g", ty.Of(s), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(s), ast::StorageClass::kPrivate);
GeneratorImpl& gen = SanitizeAndBuild();
@ -203,7 +203,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_Struct_WithOffsetAttributes) {
Member("a", ty.i32(), {MemberOffset(0)}),
Member("b", ty.f32(), {MemberOffset(8)}),
});
Global("g", ty.Of(s), ast::StorageClass::kPrivate);
GlobalVar("g", ty.Of(s), ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -287,7 +287,7 @@ TEST_P(HlslDepthTexturesTest, Emit) {
auto* t = ty.depth_texture(params.dim);
Global("tex", t,
GlobalVar("tex", t,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -317,7 +317,7 @@ using HlslDepthMultisampledTexturesTest = TestHelper;
TEST_F(HlslDepthMultisampledTexturesTest, Emit) {
auto* t = ty.depth_multisampled_texture(ast::TextureDimension::k2d);
Global("tex", t,
GlobalVar("tex", t,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -360,7 +360,7 @@ TEST_P(HlslSampledTexturesTest, Emit) {
}
auto* t = ty.sampled_texture(params.dim, datatype);
Global("tex", t,
GlobalVar("tex", t,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -495,7 +495,7 @@ TEST_P(HlslStorageTexturesTest, Emit) {
auto* t = ty.storage_texture(params.dim, params.imgfmt, ast::Access::kWrite);
Global("tex", t, ast::AttributeList{GroupAndBinding(2, 1)});
GlobalVar("tex", t, ast::AttributeList{GroupAndBinding(2, 1)});
Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))},
{Stage(ast::PipelineStage::kFragment)});

View File

@ -20,7 +20,7 @@ namespace {
using HlslUnaryOpTest = TestHelper;
TEST_F(HlslUnaryOpTest, AddressOf) {
Global("expr", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("expr", ty.f32(), ast::StorageClass::kPrivate);
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kAddressOf, Expr("expr"));
WrapInFunction(op);
@ -32,7 +32,7 @@ TEST_F(HlslUnaryOpTest, AddressOf) {
}
TEST_F(HlslUnaryOpTest, Complement) {
Global("expr", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("expr", ty.u32(), ast::StorageClass::kPrivate);
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kComplement, Expr("expr"));
WrapInFunction(op);
@ -44,7 +44,7 @@ TEST_F(HlslUnaryOpTest, Complement) {
}
TEST_F(HlslUnaryOpTest, Indirection) {
Global("G", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("G", ty.f32(), ast::StorageClass::kPrivate);
auto* p =
Let("expr", nullptr, create<ast::UnaryOpExpression>(ast::UnaryOp::kAddressOf, Expr("G")));
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kIndirection, Expr("expr"));
@ -58,7 +58,7 @@ TEST_F(HlslUnaryOpTest, Indirection) {
}
TEST_F(HlslUnaryOpTest, Not) {
Global("expr", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("expr", ty.bool_(), ast::StorageClass::kPrivate);
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kNot, Expr("expr"));
WrapInFunction(op);
@ -70,7 +70,7 @@ TEST_F(HlslUnaryOpTest, Not) {
}
TEST_F(HlslUnaryOpTest, Negation) {
Global("expr", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("expr", ty.i32(), ast::StorageClass::kPrivate);
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kNegation, Expr("expr"));
WrapInFunction(op);

View File

@ -63,7 +63,7 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Array) {
}
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) {
Global("a", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate);
WrapInFunction(Expr("a"));
@ -76,8 +76,8 @@ TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Private) {
}
TEST_F(HlslGeneratorImplTest_VariableDecl, Emit_VariableDeclStatement_Initializer_Private) {
Global("initializer", ty.f32(), ast::StorageClass::kPrivate);
Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr("initializer"));
GlobalVar("initializer", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate, Expr("initializer"));
WrapInFunction(Expr("a"));

View File

@ -27,7 +27,7 @@ namespace {
using HlslGeneratorImplTest_WorkgroupVar = TestHelper;
TEST_F(HlslGeneratorImplTest_WorkgroupVar, Basic) {
Global("wg", ty.f32(), ast::StorageClass::kWorkgroup);
GlobalVar("wg", ty.f32(), ast::StorageClass::kWorkgroup);
Func("main", {}, ty.void_(), {Assign("wg", 1.2_f)},
{
@ -43,7 +43,7 @@ TEST_F(HlslGeneratorImplTest_WorkgroupVar, Basic) {
TEST_F(HlslGeneratorImplTest_WorkgroupVar, Aliased) {
auto* alias = Alias("F32", ty.f32());
Global("wg", ty.Of(alias), ast::StorageClass::kWorkgroup);
GlobalVar("wg", ty.Of(alias), ast::StorageClass::kWorkgroup);
Func("main", {}, ty.void_(), {Assign("wg", 1.2_f)},
{

View File

@ -34,7 +34,7 @@ TEST_F(MslGeneratorImplTest, IndexAccessor) {
}
TEST_F(MslGeneratorImplTest, IndexAccessor_OfDref) {
Global("ary", ty.array<i32, 10>(), ast::StorageClass::kPrivate);
GlobalVar("ary", ty.array<i32, 10>(), ast::StorageClass::kPrivate);
auto* p = Let("p", nullptr, AddressOf("ary"));
auto* expr = IndexAccessor(Deref("p"), 5_i);

View File

@ -171,15 +171,15 @@ using MslBuiltinTest = TestParamHelper<BuiltinData>;
TEST_P(MslBuiltinTest, Emit) {
auto param = GetParam();
Global("f2", ty.vec2<f32>(), ast::StorageClass::kPrivate);
Global("f3", ty.vec3<f32>(), ast::StorageClass::kPrivate);
Global("f4", ty.vec4<f32>(), ast::StorageClass::kPrivate);
Global("u1", ty.u32(), ast::StorageClass::kPrivate);
Global("u2", ty.vec2<u32>(), ast::StorageClass::kPrivate);
Global("i2", ty.vec2<i32>(), ast::StorageClass::kPrivate);
Global("b2", ty.vec2<bool>(), ast::StorageClass::kPrivate);
Global("m2x2", ty.mat2x2<f32>(), ast::StorageClass::kPrivate);
Global("m3x2", ty.mat3x2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("f2", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("f3", ty.vec3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("f4", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("u1", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("u2", ty.vec2<u32>(), ast::StorageClass::kPrivate);
GlobalVar("i2", ty.vec2<i32>(), ast::StorageClass::kPrivate);
GlobalVar("b2", ty.vec2<bool>(), ast::StorageClass::kPrivate);
GlobalVar("m2x2", ty.mat2x2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("m3x2", ty.mat3x2<f32>(), ast::StorageClass::kPrivate);
auto* call = GenerateCall(param.builtin, param.type, this);
ASSERT_NE(nullptr, call) << "Unhandled builtin";
@ -273,8 +273,8 @@ INSTANTIATE_TEST_SUITE_P(
BuiltinData{BuiltinType::kUnpack2x16unorm, ParamType::kU32, "unpack_unorm2x16_to_float"}));
TEST_F(MslGeneratorImplTest, Builtin_Call) {
Global("param1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
Global("param2", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("param1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("param2", ty.vec2<f32>(), ast::StorageClass::kPrivate);
auto* call = Call("dot", "param1", "param2");
WrapInFunction(CallStmt(call));
@ -410,7 +410,7 @@ kernel void test_function() {
TEST_F(MslGeneratorImplTest, Pack2x16Float) {
auto* call = Call("pack2x16float", "p1");
Global("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.vec2<f32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -422,7 +422,7 @@ TEST_F(MslGeneratorImplTest, Pack2x16Float) {
TEST_F(MslGeneratorImplTest, Unpack2x16Float) {
auto* call = Call("unpack2x16float", "p1");
Global("p1", ty.u32(), ast::StorageClass::kPrivate);
GlobalVar("p1", ty.u32(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(call));
GeneratorImpl& gen = Build();
@ -433,7 +433,7 @@ TEST_F(MslGeneratorImplTest, Unpack2x16Float) {
}
TEST_F(MslGeneratorImplTest, DotI32) {
Global("v", ty.vec3<i32>(), ast::StorageClass::kPrivate);
GlobalVar("v", ty.vec3<i32>(), ast::StorageClass::kPrivate);
WrapInFunction(CallStmt(Call("dot", "v", "v")));
GeneratorImpl& gen = SanitizeAndBuild();

View File

@ -42,8 +42,8 @@ TEST_F(MslGeneratorImplTest, EmitExpression_Call_WithParams) {
Param(Sym(), ty.f32()),
},
ty.f32(), {Return(1.23_f)});
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("param1", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("param2", ty.f32(), ast::StorageClass::kPrivate);
auto* call = Call("my_func", "param1", "param2");
WrapInFunction(call);
@ -62,8 +62,8 @@ TEST_F(MslGeneratorImplTest, EmitStatement_Call) {
Param(Sym(), ty.f32()),
},
ty.void_(), ast::StatementList{}, ast::AttributeList{});
Global("param1", ty.f32(), ast::StorageClass::kPrivate);
Global("param2", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("param1", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("param2", ty.f32(), ast::StorageClass::kPrivate);
auto* call = Call("my_func", "param1", "param2");
auto* stmt = CallStmt(call);

View File

@ -335,7 +335,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RW_StorageBu
Member("b", ty.f32()),
});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -377,7 +377,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RO_StorageBu
Member("b", ty.f32()),
});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -415,7 +415,7 @@ fragment void frag_main(const device Data* tint_symbol [[buffer(0)]]) {
TEST_F(MslGeneratorImplTest, Emit_Attribute_Called_By_EntryPoint_With_Uniform) {
auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4<f32>())});
auto* ubo = Global("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -469,7 +469,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RW
Member("b", ty.f32()),
});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -524,7 +524,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RO
Member("b", ty.f32()),
});
Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -665,7 +665,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_ModuleV
auto* s = Structure("Data", {Member("d", ty.f32())});
Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),

View File

@ -234,7 +234,7 @@ INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest,
MslImportData{"clamp", "clamp"}));
TEST_F(MslGeneratorImplTest, MslImportData_Determinant) {
Global("var", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
GlobalVar("var", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* expr = Call("determinant", "var");

View File

@ -64,8 +64,8 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithContinuing) {
TEST_F(MslGeneratorImplTest, Emit_LoopNestedWithContinuing) {
Func("a_statement", {}, ty.void_(), {});
Global("lhs", ty.f32(), ast::StorageClass::kPrivate);
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("lhs", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("rhs", ty.f32(), ast::StorageClass::kPrivate);
auto* body = Block(create<ast::DiscardStatement>());
auto* continuing = Block(CallStmt(Call("a_statement")));
@ -107,7 +107,7 @@ TEST_F(MslGeneratorImplTest, Emit_LoopWithVarUsedInContinuing) {
// }
//
Global("rhs", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("rhs", ty.f32(), ast::StorageClass::kPrivate);
auto* body = Block(Decl(Var("lhs", ty.f32(), Expr(2.4_f))), //
Decl(Var("other", ty.f32())), //
@ -184,7 +184,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtInit) {
Func("f", {Param("i", ty.i32())}, ty.void_(), {});
auto f = [&](auto&& expr) { return CallStmt(Call("f", expr)); };
Global("a", ty.atomic<i32>(), ast::StorageClass::kWorkgroup);
GlobalVar("a", ty.atomic<i32>(), ast::StorageClass::kWorkgroup);
auto* multi_stmt = Block(f(1_i), f(2_i));
auto* loop = For(multi_stmt, nullptr, nullptr, //
Block(Return()));
@ -260,7 +260,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtCont) {
Func("f", {Param("i", ty.i32())}, ty.void_(), {});
auto f = [&](auto&& expr) { return CallStmt(Call("f", expr)); };
Global("a", ty.atomic<i32>(), ast::StorageClass::kWorkgroup);
GlobalVar("a", ty.atomic<i32>(), ast::StorageClass::kWorkgroup);
auto* multi_stmt = Block(f(1_i), f(2_i));
auto* loop = For(nullptr, nullptr, multi_stmt, //
Block(Return()));
@ -315,7 +315,7 @@ TEST_F(MslGeneratorImplTest, Emit_ForLoopWithMultiStmtInitCondCont) {
Func("f", {Param("i", ty.i32())}, ty.void_(), {});
auto f = [&](auto&& expr) { return CallStmt(Call("f", expr)); };
Global("a", ty.atomic<i32>(), ast::StorageClass::kWorkgroup);
GlobalVar("a", ty.atomic<i32>(), ast::StorageClass::kWorkgroup);
auto* multi_stmt_a = Block(f(1_i), f(2_i));
auto* multi_stmt_b = Block(f(3_i), f(4_i));
auto* loop = For(multi_stmt_a, Expr(true), multi_stmt_b, //

View File

@ -20,7 +20,7 @@ namespace {
using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor) {
Global("str", ty.Of(Structure("my_str", {Member("mem", ty.f32())})),
GlobalVar("str", ty.Of(Structure("my_str", {Member("mem", ty.f32())})),
ast::StorageClass::kPrivate);
auto* expr = MemberAccessor("str", "mem");
WrapInFunction(expr);
@ -33,7 +33,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor) {
}
TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor_Swizzle_xyz) {
Global("my_vec", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_vec", ty.vec4<f32>(), ast::StorageClass::kPrivate);
auto* expr = MemberAccessor("my_vec", "xyz");
WrapInFunction(expr);
@ -45,7 +45,7 @@ TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor_Swizzle_xyz) {
}
TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor_Swizzle_gbr) {
Global("my_vec", ty.vec4<f32>(), ast::StorageClass::kPrivate);
GlobalVar("my_vec", ty.vec4<f32>(), ast::StorageClass::kPrivate);
auto* expr = MemberAccessor("my_vec", "gbr");
WrapInFunction(expr);

View File

@ -27,7 +27,7 @@ using MslSanitizerTest = TestHelper;
TEST_F(MslSanitizerTest, Call_ArrayLength) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -85,7 +85,7 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) {
Member(0, "z", ty.f32()),
Member(4, "a", ty.array<f32>(4)),
});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -142,7 +142,7 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(30)]]) {
TEST_F(MslSanitizerTest, Call_ArrayLength_ViaLets) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -202,12 +202,12 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(30)]]) {
TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(0),
});
Global("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(2),
create<ast::GroupAttribute>(0),
@ -267,12 +267,12 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(29)]]) {
TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniformMissingBinding) {
auto* s = Structure("my_struct", {Member(0, "a", ty.array<f32>(4))});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(0),
});
Global("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(2),
create<ast::GroupAttribute>(0),

View File

@ -141,7 +141,7 @@ vertex Out vert_main() {
}
TEST_F(MslGeneratorImplTest, WorkgroupMatrix) {
Global("m", ty.mat2x2<f32>(), ast::StorageClass::kWorkgroup);
GlobalVar("m", ty.mat2x2<f32>(), ast::StorageClass::kWorkgroup);
Func("comp_main", {}, ty.void_(), {Decl(Let("x", nullptr, Expr("m")))},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
@ -178,7 +178,7 @@ kernel void comp_main(threadgroup tint_symbol_3* tint_symbol_2 [[threadgroup(0)]
}
TEST_F(MslGeneratorImplTest, WorkgroupMatrixInArray) {
Global("m", ty.array(ty.mat2x2<f32>(), 4_i), ast::StorageClass::kWorkgroup);
GlobalVar("m", ty.array(ty.mat2x2<f32>(), 4_i), ast::StorageClass::kWorkgroup);
Func("comp_main", {}, ty.void_(), {Decl(Let("x", nullptr, Expr("m")))},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
@ -236,7 +236,7 @@ TEST_F(MslGeneratorImplTest, WorkgroupMatrixInStruct) {
Structure("S2", {
Member("s", ty.type_name("S1")),
});
Global("s", ty.type_name("S2"), ast::StorageClass::kWorkgroup);
GlobalVar("s", ty.type_name("S2"), ast::StorageClass::kWorkgroup);
Func("comp_main", {}, ty.void_(), {Decl(Let("x", nullptr, Expr("s")))},
{Stage(ast::PipelineStage::kCompute), WorkgroupSize(1_i)});
@ -283,15 +283,15 @@ kernel void comp_main(threadgroup tint_symbol_4* tint_symbol_3 [[threadgroup(0)]
}
TEST_F(MslGeneratorImplTest, WorkgroupMatrix_Multiples) {
Global("m1", ty.mat2x2<f32>(), ast::StorageClass::kWorkgroup);
Global("m2", ty.mat2x3<f32>(), ast::StorageClass::kWorkgroup);
Global("m3", ty.mat2x4<f32>(), ast::StorageClass::kWorkgroup);
Global("m4", ty.mat3x2<f32>(), ast::StorageClass::kWorkgroup);
Global("m5", ty.mat3x3<f32>(), ast::StorageClass::kWorkgroup);
Global("m6", ty.mat3x4<f32>(), ast::StorageClass::kWorkgroup);
Global("m7", ty.mat4x2<f32>(), ast::StorageClass::kWorkgroup);
Global("m8", ty.mat4x3<f32>(), ast::StorageClass::kWorkgroup);
Global("m9", ty.mat4x4<f32>(), ast::StorageClass::kWorkgroup);
GlobalVar("m1", ty.mat2x2<f32>(), ast::StorageClass::kWorkgroup);
GlobalVar("m2", ty.mat2x3<f32>(), ast::StorageClass::kWorkgroup);
GlobalVar("m3", ty.mat2x4<f32>(), ast::StorageClass::kWorkgroup);
GlobalVar("m4", ty.mat3x2<f32>(), ast::StorageClass::kWorkgroup);
GlobalVar("m5", ty.mat3x3<f32>(), ast::StorageClass::kWorkgroup);
GlobalVar("m6", ty.mat3x4<f32>(), ast::StorageClass::kWorkgroup);
GlobalVar("m7", ty.mat4x2<f32>(), ast::StorageClass::kWorkgroup);
GlobalVar("m8", ty.mat4x3<f32>(), ast::StorageClass::kWorkgroup);
GlobalVar("m9", ty.mat4x4<f32>(), ast::StorageClass::kWorkgroup);
Func("main1", {}, ty.void_(),
{
Decl(Let("a1", nullptr, Expr("m1"))),

View File

@ -77,7 +77,7 @@ using MslGeneratorImplTest = TestHelper;
TEST_F(MslGeneratorImplTest, EmitType_Array) {
auto* arr = ty.array<bool, 4>();
Global("G", arr, ast::StorageClass::kPrivate);
GlobalVar("G", arr, ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -89,7 +89,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Array) {
TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArray) {
auto* a = ty.array<bool, 4>();
auto* b = ty.array(a, 5_u);
Global("G", b, ast::StorageClass::kPrivate);
GlobalVar("G", b, ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -102,7 +102,7 @@ TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArrayOfArray) {
auto* a = ty.array<bool, 4>();
auto* b = ty.array(a, 5_u);
auto* c = ty.array(b, 6_u);
Global("G", c, ast::StorageClass::kPrivate);
GlobalVar("G", c, ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -113,7 +113,7 @@ TEST_F(MslGeneratorImplTest, EmitType_ArrayOfArrayOfArray) {
TEST_F(MslGeneratorImplTest, EmitType_Array_WithoutName) {
auto* arr = ty.array<bool, 4>();
Global("G", arr, ast::StorageClass::kPrivate);
GlobalVar("G", arr, ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -124,7 +124,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Array_WithoutName) {
TEST_F(MslGeneratorImplTest, EmitType_RuntimeArray) {
auto* arr = ty.array<bool, 1>();
Global("G", arr, ast::StorageClass::kPrivate);
GlobalVar("G", arr, ast::StorageClass::kPrivate);
GeneratorImpl& gen = Build();
@ -247,7 +247,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_NonComposites) {
Member("z", ty.f32()),
});
Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -356,7 +356,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_Structures) {
Member("e", ty.f32()),
});
Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -450,7 +450,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayDefaultStride) {
Member("f", array_z),
});
Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -536,7 +536,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayVec3DefaultStride) {
Member("c", ty.i32()),
});
Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -600,7 +600,7 @@ TEST_F(MslGeneratorImplTest, AttemptTintPadSymbolCollision) {
Member("tint_pad_21", ty.f32()),
});
Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -661,7 +661,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_WithAttribute) {
Member("b", ty.f32()),
});
Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
@ -828,7 +828,7 @@ TEST_P(MslStorageTexturesTest, Emit) {
auto params = GetParam();
auto* s = ty.storage_texture(params.dim, ast::TexelFormat::kR32Float, ast::Access::kWrite);
Global("test_var", s,
GlobalVar("test_var", s,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),

View File

@ -20,7 +20,7 @@ namespace {
using MslUnaryOpTest = TestHelper;
TEST_F(MslUnaryOpTest, AddressOf) {
Global("expr", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("expr", ty.f32(), ast::StorageClass::kPrivate);
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kAddressOf, Expr("expr"));
WrapInFunction(op);
@ -32,7 +32,7 @@ TEST_F(MslUnaryOpTest, AddressOf) {
}
TEST_F(MslUnaryOpTest, Complement) {
Global("expr", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("expr", ty.i32(), ast::StorageClass::kPrivate);
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kComplement, Expr("expr"));
WrapInFunction(op);
@ -44,7 +44,7 @@ TEST_F(MslUnaryOpTest, Complement) {
}
TEST_F(MslUnaryOpTest, Indirection) {
Global("G", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("G", ty.f32(), ast::StorageClass::kPrivate);
auto* p =
Let("expr", nullptr, create<ast::UnaryOpExpression>(ast::UnaryOp::kAddressOf, Expr("G")));
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kIndirection, Expr("expr"));
@ -58,7 +58,7 @@ TEST_F(MslUnaryOpTest, Indirection) {
}
TEST_F(MslUnaryOpTest, Not) {
Global("expr", ty.bool_(), ast::StorageClass::kPrivate);
GlobalVar("expr", ty.bool_(), ast::StorageClass::kPrivate);
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kNot, Expr("expr"));
WrapInFunction(op);
@ -70,7 +70,7 @@ TEST_F(MslUnaryOpTest, Not) {
}
TEST_F(MslUnaryOpTest, Negation) {
Global("expr", ty.i32(), ast::StorageClass::kPrivate);
GlobalVar("expr", ty.i32(), ast::StorageClass::kPrivate);
auto* op = create<ast::UnaryOpExpression>(ast::UnaryOp::kNegation, Expr("expr"));
WrapInFunction(op);

View File

@ -111,7 +111,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Matrix) {
}
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) {
Global("a", ty.f32(), ast::StorageClass::kPrivate);
GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate);
WrapInFunction(Expr("a"));
@ -125,7 +125,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Private) {
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) {
GlobalLet("initializer", ty.f32(), Expr(0_f));
Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr("initializer"));
GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate, Expr("initializer"));
WrapInFunction(Expr("a"));
@ -140,7 +140,7 @@ TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Initializer_Private) {
}
TEST_F(MslGeneratorImplTest, Emit_VariableDeclStatement_Workgroup) {
Global("a", ty.f32(), ast::StorageClass::kWorkgroup);
GlobalVar("a", ty.f32(), ast::StorageClass::kWorkgroup);
WrapInFunction(Expr("a"));

View File

@ -23,7 +23,7 @@ namespace {
using BuilderTest = TestHelper;
TEST_F(BuilderTest, Assign_Var) {
auto* v = Global("var", ty.f32(), ast::StorageClass::kPrivate);
auto* v = GlobalVar("var", ty.f32(), ast::StorageClass::kPrivate);
auto* assign = Assign("var", 1_f);
@ -51,7 +51,7 @@ TEST_F(BuilderTest, Assign_Var) {
}
TEST_F(BuilderTest, Assign_Var_OutsideFunction_IsError) {
auto* v = Global("var", ty.f32(), ast::StorageClass::kPrivate);
auto* v = GlobalVar("var", ty.f32(), ast::StorageClass::kPrivate);
auto* assign = Assign("var", Expr(1_f));
@ -70,7 +70,7 @@ TEST_F(BuilderTest, Assign_Var_OutsideFunction_IsError) {
}
TEST_F(BuilderTest, Assign_Var_ZeroConstructor) {
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* v = GlobalVar("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* val = vec3<f32>();
auto* assign = Assign("var", val);
@ -101,7 +101,7 @@ TEST_F(BuilderTest, Assign_Var_ZeroConstructor) {
TEST_F(BuilderTest, Assign_Var_Complex_ConstructorNestedVector) {
auto* init = vec3<f32>(vec2<f32>(1_f, 2_f), 3_f);
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* v = GlobalVar("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* assign = Assign("var", init);
@ -134,7 +134,7 @@ TEST_F(BuilderTest, Assign_Var_Complex_ConstructorNestedVector) {
TEST_F(BuilderTest, Assign_Var_Complex_Constructor) {
auto* init = vec3<f32>(1_f, 2_f, 3_f);
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* v = GlobalVar("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* assign = Assign("var", init);
@ -209,7 +209,7 @@ OpStore %8 %9
}
TEST_F(BuilderTest, Assign_Vector) {
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* v = GlobalVar("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* val = vec3<f32>(1_f, 1_f, 3_f);
auto* assign = Assign("var", val);
@ -243,7 +243,7 @@ TEST_F(BuilderTest, Assign_Vector) {
TEST_F(BuilderTest, Assign_Vector_MemberByName) {
// var.y = 1
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* v = GlobalVar("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* assign = Assign(MemberAccessor("var", "y"), Expr(1_f));
@ -278,7 +278,7 @@ OpStore %9 %10
TEST_F(BuilderTest, Assign_Vector_MemberByIndex) {
// var[1] = 1
auto* v = Global("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* v = GlobalVar("var", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* assign = Assign(IndexAccessor("var", 1_i), Expr(1_f));

View File

@ -704,8 +704,8 @@ OpBranch %7
}
TEST_F(BuilderTest, Binary_LogicalAnd_WithLoads) {
auto* a_var = Global("a", ty.bool_(), ast::StorageClass::kPrivate, Expr(true));
auto* b_var = Global("b", ty.bool_(), ast::StorageClass::kPrivate, Expr(false));
auto* a_var = GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate, Expr(true));
auto* b_var = GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate, Expr(false));
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalAnd, Expr("a"), Expr("b"));
@ -857,8 +857,8 @@ OpBranch %7
}
TEST_F(BuilderTest, Binary_LogicalOr_WithLoads) {
auto* a_var = Global("a", ty.bool_(), ast::StorageClass::kPrivate, Expr(true));
auto* b_var = Global("b", ty.bool_(), ast::StorageClass::kPrivate, Expr(false));
auto* a_var = GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate, Expr(true));
auto* b_var = GlobalVar("b", ty.bool_(), ast::StorageClass::kPrivate, Expr(false));
auto* expr = create<ast::BinaryExpression>(ast::BinaryOp::kLogicalOr, Expr("a"), Expr("b"));

View File

@ -41,7 +41,7 @@ inline std::ostream& operator<<(std::ostream& out, BuiltinData data) {
using BuiltinBoolTest = BuiltinBuilderTestWithParam<BuiltinData>;
TEST_P(BuiltinBoolTest, Call_Bool_Scalar) {
auto param = GetParam();
auto* var = Global("v", ty.bool_(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("v", ty.bool_(), ast::StorageClass::kPrivate);
auto* expr = Call(param.name, "v");
auto* func = Func("a_func", {}, ty.void_(),
{
@ -67,7 +67,7 @@ TEST_P(BuiltinBoolTest, Call_Bool_Scalar) {
TEST_P(BuiltinBoolTest, Call_Bool_Vector) {
auto param = GetParam();
auto* var = Global("v", ty.vec3<bool>(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("v", ty.vec3<bool>(), ast::StorageClass::kPrivate);
auto* expr = Call(param.name, "v");
auto* func = Func("a_func", {}, ty.void_(),
{
@ -102,7 +102,7 @@ INSTANTIATE_TEST_SUITE_P(BuiltinBuilderTest,
using BuiltinIntTest = BuiltinBuilderTestWithParam<BuiltinData>;
TEST_P(BuiltinIntTest, Call_SInt_Scalar) {
auto param = GetParam();
auto* var = Global("v", ty.i32(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate);
auto* expr = Call(param.name, "v");
auto* func = Func("a_func", {}, ty.void_(),
{
@ -132,7 +132,7 @@ OpReturn
TEST_P(BuiltinIntTest, Call_SInt_Vector) {
auto param = GetParam();
auto* var = Global("v", ty.vec3<i32>(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("v", ty.vec3<i32>(), ast::StorageClass::kPrivate);
auto* expr = Call(param.name, "v");
auto* func = Func("a_func", {}, ty.void_(),
{
@ -163,7 +163,7 @@ OpReturn
TEST_P(BuiltinIntTest, Call_UInt_Scalar) {
auto param = GetParam();
auto* var = Global("v", ty.u32(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("v", ty.u32(), ast::StorageClass::kPrivate);
auto* expr = Call(param.name, "v");
auto* func = Func("a_func", {}, ty.void_(),
{
@ -193,7 +193,7 @@ OpReturn
TEST_P(BuiltinIntTest, Call_UInt_Vector) {
auto param = GetParam();
auto* var = Global("v", ty.vec3<u32>(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("v", ty.vec3<u32>(), ast::StorageClass::kPrivate);
auto* expr = Call(param.name, "v");
auto* func = Func("a_func", {}, ty.void_(),
{
@ -227,7 +227,7 @@ INSTANTIATE_TEST_SUITE_P(BuiltinBuilderTest,
BuiltinData{"reverseBits", "OpBitReverse"}));
TEST_F(BuiltinBuilderTest, Call_Dot_F32) {
auto* var = Global("v", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("v", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* expr = Call("dot", "v", "v");
auto* func = Func("a_func", {}, ty.void_(),
{
@ -256,7 +256,7 @@ OpReturn
}
TEST_F(BuiltinBuilderTest, Call_Dot_U32) {
auto* var = Global("v", ty.vec3<u32>(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("v", ty.vec3<u32>(), ast::StorageClass::kPrivate);
auto* expr = Call("dot", "v", "v");
auto* func = Func("a_func", {}, ty.void_(),
{
@ -295,7 +295,7 @@ OpReturn
}
TEST_F(BuiltinBuilderTest, Call_Dot_I32) {
auto* var = Global("v", ty.vec3<i32>(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("v", ty.vec3<i32>(), ast::StorageClass::kPrivate);
auto* expr = Call("dot", "v", "v");
auto* func = Func("a_func", {}, ty.void_(),
{
@ -336,7 +336,7 @@ OpReturn
using BuiltinDeriveTest = BuiltinBuilderTestWithParam<BuiltinData>;
TEST_P(BuiltinDeriveTest, Call_Derivative_Scalar) {
auto param = GetParam();
auto* var = Global("v", ty.f32(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("v", ty.f32(), ast::StorageClass::kPrivate);
auto* expr = Call(param.name, "v");
auto* func =
Func("func", {}, ty.void_(), {CallStmt(expr)}, {Stage(ast::PipelineStage::kFragment)});
@ -364,7 +364,7 @@ OpReturn
TEST_P(BuiltinDeriveTest, Call_Derivative_Vector) {
auto param = GetParam();
auto* var = Global("v", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("v", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* expr = Call(param.name, "v");
auto* func =
Func("func", {}, ty.void_(), {CallStmt(expr)}, {Stage(ast::PipelineStage::kFragment)});
@ -409,9 +409,9 @@ INSTANTIATE_TEST_SUITE_P(BuiltinBuilderTest,
BuiltinData{"fwidthCoarse", "OpFwidthCoarse"}));
TEST_F(BuiltinBuilderTest, Call_Select) {
auto* v3 = Global("v3", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* v3 = GlobalVar("v3", ty.vec3<f32>(), ast::StorageClass::kPrivate);
auto* bool_v3 = Global("bool_v3", ty.vec3<bool>(), ast::StorageClass::kPrivate);
auto* bool_v3 = GlobalVar("bool_v3", ty.vec3<bool>(), ast::StorageClass::kPrivate);
auto* expr = Call("select", "v3", "v3", "bool_v3");
auto* func = Func("a_func", {}, ty.void_(),
{
@ -451,13 +451,13 @@ TEST_F(BuiltinBuilderTest, Call_TextureSampleCompare_Twice) {
auto* s = ty.sampler(ast::SamplerKind::kComparisonSampler);
auto* t = ty.depth_texture(ast::TextureDimension::k2d);
auto* tex = Global("texture", t,
auto* tex = GlobalVar("texture", t,
ast::AttributeList{
create<ast::BindingAttribute>(0),
create<ast::GroupAttribute>(0),
});
auto* sampler = Global("sampler", s,
auto* sampler = GlobalVar("sampler", s,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(0),
@ -506,7 +506,7 @@ TEST_F(BuiltinBuilderTest, Call_TextureSampleCompare_Twice) {
}
TEST_F(BuiltinBuilderTest, Call_GLSLMethod_WithLoad) {
auto* var = Global("ident", ty.f32(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("ident", ty.f32(), ast::StorageClass::kPrivate);
auto* expr = Call("round", "ident");
auto* func = Func("a_func", {}, ty.void_(),
{
@ -1513,7 +1513,7 @@ OpFunctionEnd
}
TEST_F(BuiltinBuilderTest, Call_Determinant) {
auto* var = Global("var", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("var", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
auto* expr = Call("determinant", "var");
auto* func = Func("a_func", {}, ty.void_(),
{
@ -1548,7 +1548,7 @@ OpFunctionEnd
}
TEST_F(BuiltinBuilderTest, Call_Transpose) {
auto* var = Global("var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
auto* var = GlobalVar("var", ty.mat2x3<f32>(), ast::StorageClass::kPrivate);
auto* expr = Call("transpose", "var");
auto* func = Func("a_func", {}, ty.void_(),
{
@ -1585,7 +1585,7 @@ OpFunctionEnd
TEST_F(BuiltinBuilderTest, Call_ArrayLength) {
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -1632,7 +1632,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_OtherMembersInStruct) {
Member("z", ty.f32()),
Member(4, "a", ty.array<f32>(4)),
});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -1676,7 +1676,7 @@ OpReturn
TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets) {
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -1736,7 +1736,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) {
// arrayLength(&*p3);
// }
auto* s = Structure("my_struct", {Member("a", ty.array<f32>(4))});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -1801,7 +1801,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicLoad) {
Member("u", ty.atomic<u32>()),
Member("i", ty.atomic<i32>()),
});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -1865,7 +1865,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicStore) {
Member("u", ty.atomic<u32>()),
Member("i", ty.atomic<i32>()),
});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -1937,7 +1937,7 @@ TEST_P(Builtin_Builtin_AtomicRMW_i32, Test) {
auto* s = Structure("S", {
Member("v", ty.atomic<i32>()),
});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -2010,7 +2010,7 @@ TEST_P(Builtin_Builtin_AtomicRMW_u32, Test) {
auto* s = Structure("S", {
Member("v", ty.atomic<u32>()),
});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -2085,7 +2085,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicExchange) {
Member("u", ty.atomic<u32>()),
Member("i", ty.atomic<i32>()),
});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),
@ -2161,7 +2161,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicCompareExchangeWeak) {
Member("u", ty.atomic<u32>()),
Member("i", ty.atomic<i32>()),
});
Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite,
ast::AttributeList{
create<ast::BindingAttribute>(1),
create<ast::GroupAttribute>(2),

Some files were not shown because too many files have changed in this diff Show More