From 01208e7e42ae6c56b4fdb2618ff72e91708a2206 Mon Sep 17 00:00:00 2001 From: Ben Clayton Date: Sat, 25 Jun 2022 08:12:59 +0000 Subject: [PATCH] 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 Reviewed-by: David Neto Kokoro: Kokoro --- src/tint/ast/builtin_texture_helper_test.cc | 13 +- src/tint/ast/module_test.cc | 2 +- src/tint/inspector/test_inspector_builder.cc | 64 +++--- src/tint/program_builder.h | 12 +- src/tint/program_test.cc | 2 +- src/tint/resolver/array_accessor_test.cc | 24 +-- .../resolver/assignment_validation_test.cc | 65 +++--- src/tint/resolver/atomics_test.cc | 14 +- src/tint/resolver/atomics_validation_test.cc | 50 ++--- .../resolver/attribute_validation_test.cc | 130 ++++++------ src/tint/resolver/builtin_test.cc | 64 +++--- src/tint/resolver/builtin_validation_test.cc | 2 +- src/tint/resolver/builtins_validation_test.cc | 2 +- src/tint/resolver/call_validation_test.cc | 4 +- .../compound_assignment_validation_test.cc | 6 +- src/tint/resolver/dependency_graph_test.cc | 76 +++---- src/tint/resolver/function_validation_test.cc | 4 +- .../host_shareable_validation_test.cc | 50 ++--- .../increment_decrement_validation_test.cc | 6 +- src/tint/resolver/inferred_type_test.cc | 2 +- src/tint/resolver/materialize_test.cc | 2 +- src/tint/resolver/ptr_ref_test.cc | 24 +-- src/tint/resolver/ptr_ref_validation_test.cc | 16 +- src/tint/resolver/resolver_test.cc | 166 ++++++++-------- src/tint/resolver/resolver_test_helper.h | 2 +- src/tint/resolver/side_effects_test.cc | 8 +- src/tint/resolver/source_variable_test.cc | 18 +- .../storage_class_layout_validation_test.cc | 64 +++--- .../resolver/storage_class_validation_test.cc | 188 +++++++++--------- .../resolver/struct_storage_class_use_test.cc | 28 +-- .../type_constructor_validation_test.cc | 6 +- src/tint/resolver/type_validation_test.cc | 124 ++++++------ src/tint/resolver/uniformity_test.cc | 4 +- src/tint/resolver/validation_test.cc | 38 ++-- src/tint/resolver/variable_test.cc | 61 +++--- src/tint/resolver/variable_validation_test.cc | 22 +- .../transform/array_length_from_uniform.cc | 2 +- .../transform/canonicalize_entry_point_io.cc | 4 +- src/tint/transform/combine_samplers.cc | 4 +- .../transform/decompose_strided_array_test.cc | 38 ++-- .../decompose_strided_matrix_test.cc | 30 +-- src/tint/transform/first_index_offset.cc | 11 +- .../transform/multiplanar_external_texture.cc | 10 +- .../transform/num_workgroups_from_uniform.cc | 2 +- .../transform/unwind_discard_functions.cc | 4 +- src/tint/transform/vertex_pulling.cc | 12 +- src/tint/writer/append_vector_test.cc | 16 +- src/tint/writer/flatten_bindings_test.cc | 51 ++--- ...generate_external_texture_bindings_test.cc | 20 +- .../generator_impl_array_accessor_test.cc | 2 +- .../writer/glsl/generator_impl_assign_test.cc | 4 +- .../writer/glsl/generator_impl_binary_test.cc | 82 ++++---- .../glsl/generator_impl_builtin_test.cc | 48 ++--- .../writer/glsl/generator_impl_call_test.cc | 8 +- .../glsl/generator_impl_function_test.cc | 90 ++++----- .../glsl/generator_impl_identifier_test.cc | 2 +- .../writer/glsl/generator_impl_if_test.cc | 12 +- .../writer/glsl/generator_impl_import_test.cc | 2 +- .../writer/glsl/generator_impl_loop_test.cc | 6 +- .../generator_impl_member_accessor_test.cc | 12 +- .../glsl/generator_impl_sanitizer_test.cc | 30 +-- .../generator_impl_storage_buffer_test.cc | 10 +- .../writer/glsl/generator_impl_switch_test.cc | 2 +- src/tint/writer/glsl/generator_impl_test.cc | 24 +-- .../writer/glsl/generator_impl_type_test.cc | 56 +++--- .../glsl/generator_impl_unary_op_test.cc | 10 +- .../generator_impl_uniform_buffer_test.cc | 4 +- ...rator_impl_variable_decl_statement_test.cc | 6 +- .../glsl/generator_impl_workgroup_var_test.cc | 4 +- .../generator_impl_array_accessor_test.cc | 2 +- .../writer/hlsl/generator_impl_binary_test.cc | 74 +++---- .../hlsl/generator_impl_builtin_test.cc | 38 ++-- .../writer/hlsl/generator_impl_call_test.cc | 8 +- .../hlsl/generator_impl_function_test.cc | 90 ++++----- .../hlsl/generator_impl_identifier_test.cc | 2 +- .../writer/hlsl/generator_impl_if_test.cc | 12 +- .../writer/hlsl/generator_impl_import_test.cc | 2 +- .../writer/hlsl/generator_impl_loop_test.cc | 6 +- .../generator_impl_member_accessor_test.cc | 12 +- .../hlsl/generator_impl_sanitizer_test.cc | 50 ++--- .../writer/hlsl/generator_impl_switch_test.cc | 6 +- .../writer/hlsl/generator_impl_type_test.cc | 58 +++--- .../hlsl/generator_impl_unary_op_test.cc | 10 +- ...rator_impl_variable_decl_statement_test.cc | 6 +- .../hlsl/generator_impl_workgroup_var_test.cc | 4 +- .../msl/generator_impl_array_accessor_test.cc | 2 +- .../writer/msl/generator_impl_builtin_test.cc | 28 +-- .../writer/msl/generator_impl_call_test.cc | 8 +- .../msl/generator_impl_function_test.cc | 60 +++--- .../writer/msl/generator_impl_import_test.cc | 2 +- .../writer/msl/generator_impl_loop_test.cc | 12 +- .../generator_impl_member_accessor_test.cc | 8 +- .../msl/generator_impl_sanitizer_test.cc | 70 +++---- src/tint/writer/msl/generator_impl_test.cc | 24 +-- .../writer/msl/generator_impl_type_test.cc | 80 ++++---- .../msl/generator_impl_unary_op_test.cc | 10 +- ...rator_impl_variable_decl_statement_test.cc | 6 +- src/tint/writer/spirv/builder_assign_test.cc | 16 +- .../spirv/builder_binary_expression_test.cc | 8 +- src/tint/writer/spirv/builder_builtin_test.cc | 152 +++++++------- .../builder_constructor_expression_test.cc | 46 ++--- .../writer/spirv/builder_function_test.cc | 12 +- .../spirv/builder_global_variable_test.cc | 100 +++++----- .../spirv/builder_ident_expression_test.cc | 4 +- src/tint/writer/spirv/builder_if_test.cc | 10 +- src/tint/writer/spirv/builder_loop_test.cc | 4 +- src/tint/writer/spirv/builder_switch_test.cc | 24 +-- src/tint/writer/spirv/builder_type_test.cc | 96 ++++----- .../generator_impl_array_accessor_test.cc | 4 +- .../writer/wgsl/generator_impl_assign_test.cc | 4 +- .../writer/wgsl/generator_impl_binary_test.cc | 4 +- .../writer/wgsl/generator_impl_call_test.cc | 8 +- .../wgsl/generator_impl_function_test.cc | 10 +- .../wgsl/generator_impl_global_decl_test.cc | 26 +-- .../wgsl/generator_impl_identifier_test.cc | 2 +- .../writer/wgsl/generator_impl_if_test.cc | 12 +- .../writer/wgsl/generator_impl_loop_test.cc | 6 +- .../generator_impl_member_accessor_test.cc | 4 +- .../writer/wgsl/generator_impl_switch_test.cc | 2 +- .../writer/wgsl/generator_impl_type_test.cc | 10 +- .../wgsl/generator_impl_unary_op_test.cc | 10 +- .../wgsl/generator_impl_variable_test.cc | 47 ++--- 122 files changed, 1655 insertions(+), 1637 deletions(-) diff --git a/src/tint/ast/builtin_texture_helper_test.cc b/src/tint/ast/builtin_texture_helper_test.cc index 21cbd931d0..3d23808e88 100644 --- a/src/tint/ast/builtin_texture_helper_test.cc +++ b/src/tint/ast/builtin_texture_helper_test.cc @@ -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(0), b->create(1), }; - return b->Global("sampler", b->ty.sampler(sampler_kind), attrs); + return b->GlobalVar("sampler", b->ty.sampler(sampler_kind), attrs); } std::vector TextureOverloadCase::ValidCases() { diff --git a/src/tint/ast/module_test.cc b/src/tint/ast/module_test.cc index 4a2884bd50..70967695d2 100644 --- a/src/tint/ast/module_test.cc +++ b/src/tint/ast/module_test.cc @@ -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)); }(); diff --git a/src/tint/inspector/test_inspector_builder.cc b/src/tint/inspector/test_inspector_builder.cc index 949ee75639..f97f474140 100644 --- a/src/tint/inspector/test_inspector_builder.cc +++ b/src/tint/inspector/test_inspector_builder.cc @@ -121,15 +121,15 @@ void InspectorBuilder::AddUniformBuffer(const std::string& name, const ast::Type* type, uint32_t group, uint32_t binding) { - Global(name, type, ast::StorageClass::kUniform, - ast::AttributeList{ - create(binding), - create(group), - }); + GlobalVar(name, type, ast::StorageClass::kUniform, + ast::AttributeList{ + create(binding), + create(group), + }); } 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,11 +137,11 @@ void InspectorBuilder::AddStorageBuffer(const std::string& name, ast::Access access, uint32_t group, uint32_t binding) { - Global(name, type, ast::StorageClass::kStorage, access, - ast::AttributeList{ - create(binding), - create(group), - }); + GlobalVar(name, type, ast::StorageClass::kStorage, access, + ast::AttributeList{ + create(binding), + create(group), + }); } void InspectorBuilder::MakeStructVariableReferenceBodyFunction( @@ -173,36 +173,36 @@ void InspectorBuilder::MakeStructVariableReferenceBodyFunction( } void InspectorBuilder::AddSampler(const std::string& name, uint32_t group, uint32_t binding) { - Global(name, sampler_type(), - ast::AttributeList{ - create(binding), - create(group), - }); + GlobalVar(name, sampler_type(), + ast::AttributeList{ + create(binding), + create(group), + }); } void InspectorBuilder::AddComparisonSampler(const std::string& name, uint32_t group, uint32_t binding) { - Global(name, comparison_sampler_type(), - ast::AttributeList{ - create(binding), - create(group), - }); + GlobalVar(name, comparison_sampler_type(), + ast::AttributeList{ + create(binding), + create(group), + }); } void InspectorBuilder::AddResource(const std::string& name, const ast::Type* type, uint32_t group, uint32_t binding) { - Global(name, type, - ast::AttributeList{ - create(binding), - create(group), - }); + GlobalVar(name, type, + ast::AttributeList{ + create(binding), + create(group), + }); } 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,11 +305,11 @@ void InspectorBuilder::AddStorageTexture(const std::string& name, const ast::Type* type, uint32_t group, uint32_t binding) { - Global(name, type, - ast::AttributeList{ - create(binding), - create(group), - }); + GlobalVar(name, type, + ast::AttributeList{ + create(binding), + create(group), + }); } const ast::Function* InspectorBuilder::MakeStorageTextureBodyFunction( diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h index e0c62a4f68..027a0e53e4 100644 --- a/src/tint/program_builder.h +++ b/src/tint/program_builder.h @@ -128,7 +128,7 @@ class ProgramBuilder { traits::EnableIfIsNotType>, 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 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 > - 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), type, std::forward(optional)...); AST().AddGlobalVariable(var); return var; @@ -1449,10 +1449,10 @@ class ProgramBuilder { /// @returns a new `ast::Var`, which is automatically registered as a global variable with the /// ast::Module. template - const ast::Var* Global(const Source& source, - NAME&& name, - const ast::Type* type, - OPTIONAL&&... optional) { + const ast::Var* GlobalVar(const Source& source, + NAME&& name, + const ast::Type* type, + OPTIONAL&&... optional) { auto* var = Var(source, std::forward(name), type, std::forward(optional)...); AST().AddGlobalVariable(var); diff --git a/src/tint/program_test.cc b/src/tint/program_test.cc index 3bdf11ac92..ae6aabe29e 100644 --- a/src/tint/program_test.cc +++ b/src/tint/program_test.cc @@ -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()); diff --git a/src/tint/resolver/array_accessor_test.cc b/src/tint/resolver/array_accessor_test.cc index 31799df9fd..c0b417c81b 100644 --- a/src/tint/resolver/array_accessor_test.cc +++ b/src/tint/resolver/array_accessor_test.cc @@ -27,7 +27,7 @@ namespace { using ResolverIndexAccessorTest = ResolverTest; TEST_F(ResolverIndexAccessorTest, Matrix_Dynamic_F32) { - Global("my_var", ty.mat2x3(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.mat2x3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.mat2x3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.mat4x4(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.mat2x3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.mat2x3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.vec3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.vec3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.vec3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.array(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.array(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.array(), 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()); - 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); diff --git a/src/tint/resolver/assignment_validation_test.cc b/src/tint/resolver/assignment_validation_test.cc index 4459eaf577..29e02d5af9 100644 --- a/src/tint/resolver/assignment_validation_test.cc +++ b/src/tint/resolver/assignment_validation_test.cc @@ -30,11 +30,11 @@ TEST_F(ResolverAssignmentValidationTest, ReadOnlyBuffer) { // @group(0) @binding(0) // var a : S; auto* s = Structure("S", {Member("m", ty.i32())}); - Global(Source{{12, 34}}, "a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{12, 34}}, "a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("a", "m"), 1_i)); @@ -235,16 +235,16 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) { ast::Access::kWrite); }; - Global("a", make_type(), ast::StorageClass::kNone, - ast::AttributeList{ - create(0), - create(0), - }); - Global("b", make_type(), ast::StorageClass::kNone, - ast::AttributeList{ - create(1), - create(0), - }); + GlobalVar("a", make_type(), ast::StorageClass::kNone, + ast::AttributeList{ + create(0), + create(0), + }); + GlobalVar("b", make_type(), ast::StorageClass::kNone, + ast::AttributeList{ + create(1), + create(0), + }); WrapInFunction(Assign(Source{{56, 78}}, "a", "b")); @@ -258,11 +258,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a"))); @@ -276,11 +276,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a"))); @@ -297,7 +297,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_NonConstructibleStruct_Fa // _ = s; // } auto* s = Structure("S", {Member("arr", ty.array())}); - 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())}); - 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()), }); 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(), 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(), ast::StorageClass::kWorkgroup); WrapInFunction(Assign(Phony(), 1_i), // Assign(Phony(), 2_u), // diff --git a/src/tint/resolver/atomics_test.cc b/src/tint/resolver/atomics_test.cc index c0fe5ce299..0e86599eb3 100644 --- a/src/tint/resolver/atomics_test.cc +++ b/src/tint/resolver/atomics_test.cc @@ -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()); @@ -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()); @@ -46,11 +46,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + auto* g = GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); EXPECT_TRUE(r()->Resolve()) << r()->error(); ASSERT_TRUE(TypeOf(g)->Is()); diff --git a/src/tint/resolver/atomics_validation_test.cc b/src/tint/resolver/atomics_validation_test.cc index adc830e40d..5ec4e01291 100644 --- a/src/tint/resolver/atomics_validation_test.cc +++ b/src/tint/resolver/atomics_validation_test.cc @@ -27,35 +27,35 @@ 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, - ast::Access::kReadWrite, GroupAndBinding(0, 0)); + GlobalVar("g", ty.atomic(Source{{12, 34}}, ty.i32()), ast::StorageClass::kStorage, + ast::Access::kReadWrite, GroupAndBinding(0, 0)); EXPECT_TRUE(r()->Resolve()) << r()->error(); } 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, - GroupAndBinding(0, 0)); + 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 v: array; auto* s = Structure("S", {Member("m", ty.atomic())}); - 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,8 +207,8 @@ 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, - GroupAndBinding(0, 0)); + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + GroupAndBinding(0, 0)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -219,8 +219,8 @@ 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, - GroupAndBinding(0, 0)); + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + GroupAndBinding(0, 0)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -236,8 +236,8 @@ 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, - GroupAndBinding(0, 0)); + GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), ast::StorageClass::kStorage, ast::Access::kRead, + GroupAndBinding(0, 0)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -253,8 +253,8 @@ 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, - GroupAndBinding(0, 0)); + GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), ast::StorageClass::kStorage, ast::Access::kRead, + GroupAndBinding(0, 0)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -295,8 +295,8 @@ 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, - GroupAndBinding(0, 0)); + GlobalVar(Source{{56, 78}}, "g", ty.Of(s0), ast::StorageClass::kStorage, ast::Access::kRead, + GroupAndBinding(0, 0)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), diff --git a/src/tint/resolver/attribute_validation_test.cc b/src/tint/resolver/attribute_validation_test.cc index 0da6c2b964..e593f4948f 100644 --- a/src/tint/resolver/attribute_validation_test.cc +++ b/src/tint/resolver/attribute_validation_test.cc @@ -707,11 +707,11 @@ TEST_P(VariableAttributeTest, IsValid) { auto& params = GetParam(); if (IsBindingAttribute(params.kind)) { - Global("a", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr, - createAttributes(Source{{12, 34}}, *this, params.kind)); + 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, - createAttributes(Source{{12, 34}}, *this, params.kind)); + GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate, nullptr, + createAttributes(Source{{12, 34}}, *this, params.kind)); } WrapInFunction(); @@ -743,12 +743,12 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest, TestParams{AttributeKind::kBindingAndGroup, true})); TEST_F(VariableAttributeTest, DuplicateAttribute) { - Global("a", ty.sampler(ast::SamplerKind::kSampler), - ast::AttributeList{ - create(Source{{12, 34}}, 2), - create(2), - create(Source{{56, 78}}, 3), - }); + GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler), + ast::AttributeList{ + create(Source{{12, 34}}, 2), + create(2), + create(Source{{56, 78}}, 3), + }); WrapInFunction(); @@ -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(); @@ -806,10 +805,10 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest, TEST_F(ConstantAttributeTest, DuplicateAttribute) { GlobalLet("a", ty.f32(), Expr(1.23_f), - ast::AttributeList{ - create(Source{{12, 34}}, 0), - create(Source{{56, 78}}, 1), - }); + ast::AttributeList{ + create(Source{{12, 34}}, 0), + create(Source{{56, 78}}, 1), + }); WrapInFunction(); @@ -853,10 +852,10 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest, TEST_F(OverrideAttributeTest, DuplicateAttribute) { GlobalLet("a", ty.f32(), Expr(1.23_f), - ast::AttributeList{ - create(Source{{12, 34}}, 0), - create(Source{{56, 78}}, 1), - }); + ast::AttributeList{ + create(Source{{12, 34}}, 0), + create(Source{{56, 78}}, 1), + }); 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(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,8 +1013,8 @@ TEST_F(ResourceAttributeTest, StorageBufferMissingBinding) { } TEST_F(ResourceAttributeTest, TextureMissingBinding) { - Global(Source{{12, 34}}, "G", ty.depth_texture(ast::TextureDimension::k2d), - ast::StorageClass::kNone); + GlobalVar(Source{{12, 34}}, "G", ty.depth_texture(ast::TextureDimension::k2d), + ast::StorageClass::kNone); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -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,10 +1031,11 @@ TEST_F(ResourceAttributeTest, SamplerMissingBinding) { } TEST_F(ResourceAttributeTest, BindingPairMissingBinding) { - Global(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, - ast::AttributeList{ - create(1), - }); + GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler), + ast::StorageClass::kNone, + ast::AttributeList{ + create(1), + }); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -1042,10 +1043,11 @@ TEST_F(ResourceAttributeTest, BindingPairMissingBinding) { } TEST_F(ResourceAttributeTest, BindingPairMissingGroup) { - Global(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, - ast::AttributeList{ - create(1), - }); + GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler), + ast::StorageClass::kNone, + ast::AttributeList{ + create(1), + }); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -1053,18 +1055,18 @@ TEST_F(ResourceAttributeTest, BindingPairMissingGroup) { } TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) { - Global(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), - ast::StorageClass::kNone, - ast::AttributeList{ - create(1), - create(2), - }); - Global(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), - ast::StorageClass::kNone, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), + ast::StorageClass::kNone, + ast::AttributeList{ + create(1), + create(2), + }); + GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), + ast::StorageClass::kNone, + ast::AttributeList{ + create(1), + create(2), + }); Func("F", {}, ty.void_(), { @@ -1085,18 +1087,18 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) { } TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) { - Global(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), - ast::StorageClass::kNone, - ast::AttributeList{ - create(1), - create(2), - }); - Global(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), - ast::StorageClass::kNone, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), + ast::StorageClass::kNone, + ast::AttributeList{ + create(1), + create(2), + }); + GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), + ast::StorageClass::kNone, + ast::AttributeList{ + create(1), + create(2), + }); Func("F_A", {}, ty.void_(), { @@ -1119,11 +1121,11 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) { } TEST_F(ResourceAttributeTest, BindingPointOnNonResource) { - Global(Source{{12, 34}}, "G", ty.f32(), ast::StorageClass::kPrivate, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar(Source{{12, 34}}, "G", ty.f32(), ast::StorageClass::kPrivate, + ast::AttributeList{ + create(1), + create(2), + }); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), diff --git a/src/tint/resolver/builtin_test.cc b/src/tint/resolver/builtin_test.cc index ef9f1bd5e4..5bb6810a99 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -52,7 +52,7 @@ using ResolverBuiltinDerivativeTest = ResolverTestWithParam; 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(), ast::StorageClass::kPrivate); + GlobalVar("ident", ty.vec4(), ast::StorageClass::kPrivate); auto* expr = Call(name, "ident"); Func("func", {}, ty.void_(), {Ignore(expr)}, @@ -110,7 +110,7 @@ using ResolverBuiltinTest_BoolMethod = ResolverTestWithParam; 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.vec3(), ast::StorageClass::kPrivate); auto* expr = Call(name, "my_var"); WrapInFunction(expr); @@ -185,14 +185,14 @@ class ResolverBuiltinTest_TextureOperation : public ResolverTestWithParamIsAnyOf()) { - Global(name, type, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(name, type, + ast::AttributeList{ + create(0), + create(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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.vec2(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.vec3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.vec4(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_var", ty.vec3(), ast::StorageClass::kPrivate); - Global("bool_var", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("bool_var", ty.vec3(), ast::StorageClass::kPrivate); auto* expr = Call("select", "my_var", "my_var", "bool_var"); WrapInFunction(expr); @@ -616,11 +616,11 @@ using ResolverBuiltinDataTest = ResolverTest; TEST_F(ResolverBuiltinDataTest, ArrayLength_Vector) { auto* ary = ty.array(); auto* str = Structure("S", {Member("x", ary)}); - Global("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); auto* call = Call("arrayLength", AddressOf(MemberAccessor("a", "x"))); WrapInFunction(call); @@ -632,7 +632,7 @@ TEST_F(ResolverBuiltinDataTest, ArrayLength_Vector) { } TEST_F(ResolverBuiltinDataTest, ArrayLength_Error_ArraySized) { - Global("arr", ty.array(), ast::StorageClass::kPrivate); + GlobalVar("arr", ty.array(), 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(), ast::StorageClass::kWorkgroup); + GlobalVar("v", ty.vec4(), ast::StorageClass::kWorkgroup); auto* call = Call("frexp", vec2(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(), ast::StorageClass::kWorkgroup); + GlobalVar("whole", ty.vec4(), ast::StorageClass::kWorkgroup); auto* call = Call("modf", vec2(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(), ast::StorageClass::kPrivate); + GlobalVar("var", ty.mat2x2(), 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(), ast::StorageClass::kPrivate); + GlobalVar("var", ty.mat3x3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("var", ty.mat4x4(), 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(), ast::StorageClass::kPrivate); + GlobalVar("var", ty.mat2x3(), 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); diff --git a/src/tint/resolver/builtin_validation_test.cc b/src/tint/resolver/builtin_validation_test.cc index 428b8fa69c..61b9e1c6ea 100644 --- a/src/tint/resolver/builtin_validation_test.cc +++ b/src/tint/resolver/builtin_validation_test.cc @@ -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( diff --git a/src/tint/resolver/builtins_validation_test.cc b/src/tint/resolver/builtins_validation_test.cc index 6f0cf85610..15fd2b683a 100644 --- a/src/tint/resolver/builtins_validation_test.cc +++ b/src/tint/resolver/builtins_validation_test.cc @@ -92,7 +92,7 @@ using ResolverBuiltinsStageTest = ResolverTestWithParam; TEST_P(ResolverBuiltinsStageTest, All_input) { const Params& params = GetParam(); - auto* p = Global("p", ty.vec4(), ast::StorageClass::kPrivate); + auto* p = GlobalVar("p", ty.vec4(), ast::StorageClass::kPrivate); auto* input = Param("input", params.type(*this), {Builtin(Source{{12, 34}}, params.builtin)}); switch (params.stage) { case ast::PipelineStage::kVertex: diff --git a/src/tint/resolver/call_validation_test.cc b/src/tint/resolver/call_validation_test.cc index 850e2c670e..9625be77c2 100644 --- a/src/tint/resolver/call_validation_test.cc +++ b/src/tint/resolver/call_validation_test.cc @@ -219,7 +219,7 @@ TEST_F(ResolverCallValidationTest, LetPointerPrivate) { // var c: i32 = foo(p); // } Func("foo", {Param("p", ty.pointer(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()); diff --git a/src/tint/resolver/compound_assignment_validation_test.cc b/src/tint/resolver/compound_assignment_validation_test.cc index b453c3b5d8..5edcdaad2b 100644 --- a/src/tint/resolver/compound_assignment_validation_test.cc +++ b/src/tint/resolver/compound_assignment_validation_test.cc @@ -233,8 +233,8 @@ TEST_F(ResolverCompoundAssignmentValidationTest, ReadOnlyBuffer) { // { // a += 1i; // } - Global(Source{{12, 34}}, "a", ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead, - GroupAndBinding(0, 0)); + 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)); EXPECT_FALSE(r()->Resolve()); @@ -264,7 +264,7 @@ TEST_F(ResolverCompoundAssignmentValidationTest, LhsLiteral) { TEST_F(ResolverCompoundAssignmentValidationTest, LhsAtomic) { // var a : atomic; // 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()); diff --git a/src/tint/resolver/dependency_graph_test.cc b/src/tint/resolver/dependency_graph_test.cc index e1bd423fc1..4ee1ddaf06 100644 --- a/src/tint/resolver/dependency_graph_test.cc +++ b/src/tint/resolver/dependency_graph_test.cc @@ -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 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 X : i32 = Y; // 3: var 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, - ast::Access::kRead)); // - Global(Sym(), ty.sampler(ast::SamplerKind::kSampler)); + 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)); // + 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))); diff --git a/src/tint/resolver/function_validation_test.cc b/src/tint/resolver/function_validation_test.cc index de1bea72fd..4f801c3762 100644 --- a/src/tint/resolver/function_validation_test.cc +++ b/src/tint/resolver/function_validation_test.cc @@ -39,7 +39,7 @@ TEST_F(ResolverFunctionValidationTest, DuplicateParameterName) { TEST_F(ResolverFunctionValidationTest, ParameterMayShadowGlobal) { // var 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 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"))}); diff --git a/src/tint/resolver/host_shareable_validation_test.cc b/src/tint/resolver/host_shareable_validation_test.cc index 85ccd859cb..5e59b443ad 100644 --- a/src/tint/resolver/host_shareable_validation_test.cc +++ b/src/tint/resolver/host_shareable_validation_test.cc @@ -26,11 +26,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_FALSE(r()->Resolve()); @@ -44,11 +44,11 @@ TEST_F(ResolverHostShareableValidationTest, BoolMember) { TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) { auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.vec3())}); - Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_FALSE(r()->Resolve()); @@ -63,11 +63,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_FALSE(r()->Resolve()); @@ -85,11 +85,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_FALSE(r()->Resolve()); @@ -123,11 +123,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); WrapInFunction(); ASSERT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/increment_decrement_validation_test.cc b/src/tint/resolver/increment_decrement_validation_test.cc index b8e3aa16d9..5061e49323 100644 --- a/src/tint/resolver/increment_decrement_validation_test.cc +++ b/src/tint/resolver/increment_decrement_validation_test.cc @@ -127,7 +127,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, Vector) { TEST_F(ResolverIncrementDecrementValidationTest, Atomic) { // var a : atomic; // 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,8 +187,8 @@ TEST_F(ResolverIncrementDecrementValidationTest, ReadOnlyBuffer) { // { // a++; // } - Global(Source{{12, 34}}, "a", ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead, - GroupAndBinding(0, 0)); + GlobalVar(Source{{12, 34}}, "a", ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead, + GroupAndBinding(0, 0)); WrapInFunction(Increment(Source{{56, 78}}, "a")); EXPECT_FALSE(r()->Resolve()); diff --git a/src/tint/resolver/inferred_type_test.cc b/src/tint/resolver/inferred_type_test.cc index 6ea95da3fc..14392888cd 100644 --- a/src/tint/resolver/inferred_type_test.cc +++ b/src/tint/resolver/inferred_type_test.cc @@ -96,7 +96,7 @@ TEST_P(ResolverInferredTypeParamTest, GlobalVar_Pass) { // var a = ; 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(); diff --git a/src/tint/resolver/materialize_test.cc b/src/tint/resolver/materialize_test.cc index 5f4a41f50f..c659d67aa2 100644 --- a/src/tint/resolver/materialize_test.cc +++ b/src/tint/resolver/materialize_test.cc @@ -726,7 +726,7 @@ TEST_P(MaterializeAbstractNumericToDefaultType, Test) { {WorkgroupSize(abstract_expr()), Stage(ast::PipelineStage::kCompute)}); break; case Method::kIndex: - Global("arr", ty.array(), ast::StorageClass::kPrivate); + GlobalVar("arr", ty.array(), ast::StorageClass::kPrivate); WrapInFunction(IndexAccessor("arr", abstract_expr())); break; } diff --git a/src/tint/resolver/ptr_ref_test.cc b/src/tint/resolver/ptr_ref_test.cc index 69b7e54051..c02ab5dda3 100644 --- a/src/tint/resolver/ptr_ref_test.cc +++ b/src/tint/resolver/ptr_ref_test.cc @@ -59,18 +59,18 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); - auto* storage = Global("sb", ty.Of(buf), ast::StorageClass::kStorage, - ast::AttributeList{ - create(1), - create(0), - }); + 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(0), + create(0), + }); + auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, + ast::AttributeList{ + create(1), + create(0), + }); auto* function_ptr = Let("f_ptr", ty.pointer(ty.i32(), ast::StorageClass::kFunction), AddressOf(function)); diff --git a/src/tint/resolver/ptr_ref_validation_test.cc b/src/tint/resolver/ptr_ref_validation_test.cc index b011dd0382..d2f8d01e20 100644 --- a/src/tint/resolver/ptr_ref_validation_test.cc +++ b/src/tint/resolver/ptr_ref_validation_test.cc @@ -54,7 +54,8 @@ TEST_F(ResolverPtrRefValidationTest, AddressOfLet) { TEST_F(ResolverPtrRefValidationTest, AddressOfHandle) { // @group(0) @binding(0) var t: texture_3d; // &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; // *&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,11 +143,11 @@ TEST_F(ResolverPtrRefValidationTest, InferredPtrAccessMismatch) { // } auto* inner = Structure("Inner", {Member("arr", ty.array())}); auto* buf = Structure("S", {Member("inner", ty.Of(inner))}); - auto* storage = Global("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(0), - create(0), - }); + auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i); auto* ptr = diff --git a/src/tint/resolver/resolver_test.cc b/src/tint/resolver/resolver_test.cc index b1f5da8ae8..d896b900d4 100644 --- a/src/tint/resolver/resolver_test.cc +++ b/src/tint/resolver/resolver_test.cc @@ -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 a : array; - 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 a : array; - 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 a : array; 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 a : array; 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(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, - ast::AttributeList{ - create(0), - create(0), - }); - auto* wg_var = Global("wg_var", ty.f32(), ast::StorageClass::kWorkgroup); - auto* priv_var = Global("priv_var", ty.f32(), ast::StorageClass::kPrivate); + auto* sb_var = + GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); + 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, - ast::AttributeList{ - create(0), - create(0), - }); - auto* wg_var = Global("wg_var", ty.f32(), ast::StorageClass::kWorkgroup); - auto* priv_var = Global("priv_var", ty.f32(), ast::StorageClass::kPrivate); + auto* sb_var = + GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); + 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(), ast::StorageClass::kPrivate); + GlobalVar("my_vec", ty.vec4(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_vec", ty.vec3(), 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())}); 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(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(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(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(f32, lhs_mat_rows); auto* result_type = create(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(), ast::StorageClass::kPrivate); + GlobalVar("ident", ty.vec4(), ast::StorageClass::kPrivate); } else if (op == ast::UnaryOp::kNegation || op == ast::UnaryOp::kComplement) { - Global("ident", ty.vec4(), ast::StorageClass::kPrivate); + GlobalVar("ident", ty.vec4(), ast::StorageClass::kPrivate); } else { - Global("ident", ty.vec4(), ast::StorageClass::kPrivate); + GlobalVar("ident", ty.vec4(), ast::StorageClass::kPrivate); } auto* der = create(op, Expr("ident")); WrapInFunction(der); @@ -1733,11 +1735,11 @@ TEST_F(ResolverTest, StorageClass_SetsIfMissing) { TEST_F(ResolverTest, StorageClass_SetForSampler) { auto* t = ty.sampler(ast::SamplerKind::kSampler); - auto* var = Global("var", t, - ast::AttributeList{ - create(0), - create(0), - }); + auto* var = GlobalVar("var", t, + ast::AttributeList{ + create(0), + create(0), + }); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1746,11 +1748,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + auto* var = GlobalVar("var", t, + ast::AttributeList{ + create(0), + create(0), + }); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1771,11 +1773,11 @@ TEST_F(ResolverTest, Access_SetForStorageBuffer) { // struct S { x : i32 }; // var 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, - ast::AttributeList{ - create(0), - create(0), - }); + auto* var = GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, + ast::AttributeList{ + create(0), + create(0), + }); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -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(1), create(2)}); - auto* s2 = Global( + auto* s2 = GlobalVar( Sym(), ty.sampler(ast::SamplerKind::kSampler), ast::AttributeList{create(3), create(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(), ast::StorageClass::kPrivate); + GlobalVar("ident", ty.vec4(), ast::StorageClass::kPrivate); auto* der = create(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(), ast::StorageClass::kPrivate); + GlobalVar("ident", ty.vec4(), ast::StorageClass::kPrivate); auto* der = create(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::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(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(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(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(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())}); diff --git a/src/tint/resolver/resolver_test_helper.h b/src/tint/resolver/resolver_test_helper.h index a0d71e55fe..f56d82254e 100644 --- a/src/tint/resolver/resolver_test_helper.h +++ b/src/tint/resolver/resolver_test_helper.h @@ -519,7 +519,7 @@ struct DataType> { /// @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::AST(b), ast::StorageClass::kPrivate); + b.GlobalVar(sym, DataType::AST(b), ast::StorageClass::kPrivate); return b.AddressOf(sym); } /// @returns the WGSL name for the type diff --git a/src/tint/resolver/side_effects_test.cc b/src/tint/resolver/side_effects_test.cc index 5f11afdefe..689c7b831b 100644 --- a/src/tint/resolver/side_effects_test.cc +++ b/src/tint/resolver/side_effects_test.cc @@ -29,7 +29,7 @@ struct SideEffectsTest : ResolverTest { template void MakeSideEffectFunc(const char* name) { auto global = Sym(); - Global(global, ty.Of(), ast::StorageClass::kPrivate); + GlobalVar(global, ty.Of(), ast::StorageClass::kPrivate); auto local = Sym(); Func(name, {}, ty.Of(), { @@ -42,7 +42,7 @@ struct SideEffectsTest : ResolverTest { template 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::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); diff --git a/src/tint/resolver/source_variable_test.cc b/src/tint/resolver/source_variable_test.cc index ef2320efa2..6e6cd4307d 100644 --- a/src/tint/resolver/source_variable_test.cc +++ b/src/tint/resolver/source_variable_test.cc @@ -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,8 +70,8 @@ TEST_F(ResolverSourceVariableTest, GlobalUniformVar) { } TEST_F(ResolverSourceVariableTest, GlobalTextureVar) { - auto* a = Global("a", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), - ast::StorageClass::kNone, GroupAndBinding(0, 0)); + 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); diff --git a/src/tint/resolver/storage_class_layout_validation_test.cc b/src/tint/resolver/storage_class_layout_validation_test.cc index db379a062b..770361a66c 100644 --- a/src/tint/resolver/storage_class_layout_validation_test.cc +++ b/src/tint/resolver/storage_class_layout_validation_test.cc @@ -37,8 +37,8 @@ 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, - GroupAndBinding(0, 0)); + GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage, + GroupAndBinding(0, 0)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -65,8 +65,8 @@ 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, - GroupAndBinding(0, 0)); + GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage, + GroupAndBinding(0, 0)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -93,8 +93,8 @@ 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, - GroupAndBinding(0, 0)); + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, + GroupAndBinding(0, 0)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -134,8 +134,8 @@ 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, - GroupAndBinding(0, 0)); + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, + GroupAndBinding(0, 0)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -159,8 +159,8 @@ 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, - GroupAndBinding(0, 0)); + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, + GroupAndBinding(0, 0)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -192,8 +192,8 @@ 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, - GroupAndBinding(0, 0)); + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, + GroupAndBinding(0, 0)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -222,8 +222,8 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_MembersOffsetNotM Member(Source{{78, 90}}, "scalar", ty.i32()), }); - Global(Source{{22, 24}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, - GroupAndBinding(0, 0)); + GlobalVar(Source{{22, 24}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, + GroupAndBinding(0, 0)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -274,8 +274,8 @@ TEST_F(ResolverStorageClassLayoutValidationTest, Member(Source{{78, 90}}, "scalar", ty.i32()), }); - Global(Source{{22, 24}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, - GroupAndBinding(0, 0)); + GlobalVar(Source{{22, 24}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, + GroupAndBinding(0, 0)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -320,8 +320,8 @@ TEST_F(ResolverStorageClassLayoutValidationTest, Member(Source{{78, 90}}, "scalar", ty.i32(), {MemberAlign(16)}), }); - Global(Source{{22, 34}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, - GroupAndBinding(0, 0)); + GlobalVar(Source{{22, 34}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, + GroupAndBinding(0, 0)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -341,8 +341,8 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_Vec3MemberOffset_ Member("s", ty.f32()), }); - Global(Source{{78, 90}}, "a", ty.type_name("ScalarPackedAtEndOfVec3"), - ast::StorageClass::kUniform, GroupAndBinding(0, 0)); + GlobalVar(Source{{78, 90}}, "a", ty.type_name("ScalarPackedAtEndOfVec3"), + ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -367,8 +367,8 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("scalar", ty.i32()), }); - Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, - GroupAndBinding(0, 0)); + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, + GroupAndBinding(0, 0)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -401,8 +401,8 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("scalar", ty.i32()), }); - Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, - GroupAndBinding(0, 0)); + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, + GroupAndBinding(0, 0)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -444,8 +444,8 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("scalar", ty.i32()), }); - Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, - GroupAndBinding(0, 0)); + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, + GroupAndBinding(0, 0)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -462,8 +462,8 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStride_TopLevelArray) { // @group(0) @binding(0) // var a : array; - Global(Source{{78, 90}}, "a", ty.array(Source{{34, 56}}, ty.f32(), 4_u), - ast::StorageClass::kUniform, GroupAndBinding(0, 0)); + GlobalVar(Source{{78, 90}}, "a", ty.array(Source{{34, 56}}, ty.f32(), 4_u), + ast::StorageClass::kUniform, GroupAndBinding(0, 0)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -484,8 +484,8 @@ 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, - GroupAndBinding(0, 0)); + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, + GroupAndBinding(0, 0)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -517,8 +517,8 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("scalar", ty.i32()), }); - Global(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, - GroupAndBinding(0, 0)); + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, + GroupAndBinding(0, 0)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } diff --git a/src/tint/resolver/storage_class_validation_test.cc b/src/tint/resolver/storage_class_validation_test.cc index e16112782b..1f5f0245c7 100644 --- a/src/tint/resolver/storage_class_validation_test.cc +++ b/src/tint/resolver/storage_class_validation_test.cc @@ -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 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,11 +85,11 @@ note: while analysing structure member S.m TEST_F(ResolverStorageClassValidationTest, StorageBufferBool) { // var g : bool; - Global(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kStorage, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kStorage, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_FALSE(r()->Resolve()); @@ -101,12 +101,12 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferBool) { TEST_F(ResolverStorageClassValidationTest, StorageBufferPointer) { // var g : ptr; - Global(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate), - ast::StorageClass::kStorage, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate), + ast::StorageClass::kStorage, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_FALSE(r()->Resolve()); @@ -118,22 +118,22 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferPointer) { TEST_F(ResolverStorageClassValidationTest, StorageBufferIntScalar) { // var g : i32; - Global(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kStorage, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kStorage, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverStorageClassValidationTest, StorageBufferVector) { // var g : vec4; - Global(Source{{56, 78}}, "g", ty.vec4(), ast::StorageClass::kStorage, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.vec4(), ast::StorageClass::kStorage, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -142,11 +142,11 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferArray) { // var g : array; 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -155,11 +155,11 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferBoolAlias) { // type a = bool; // var g : a; auto* a = Alias("a", ty.bool_()); - Global(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kStorage, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kStorage, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_FALSE(r()->Resolve()); @@ -171,7 +171,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferBoolAlias) { TEST_F(ResolverStorageClassValidationTest, NotStorage_AccessMode) { // var 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,11 +184,11 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoError_Basic) { // struct S { x : i32 }; // var 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_TRUE(r()->Resolve()); } @@ -200,11 +200,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_TRUE(r()->Resolve()); } @@ -215,11 +215,11 @@ TEST_F(ResolverStorageClassValidationTest, UniformBuffer_Struct_Runtime) { auto* s = Structure(Source{{12, 34}}, "S", {Member("m", ty.array())}); - Global(Source{{56, 78}}, "svar", ty.Of(s), ast::StorageClass::kUniform, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "svar", ty.Of(s), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -230,11 +230,11 @@ note: while analysing structure member S.m TEST_F(ResolverStorageClassValidationTest, UniformBufferBool) { // var g : bool; - Global(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kUniform, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_FALSE(r()->Resolve()); @@ -246,12 +246,12 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferBool) { TEST_F(ResolverStorageClassValidationTest, UniformBufferPointer) { // var g : ptr; - Global(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate), - ast::StorageClass::kUniform, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate), + ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_FALSE(r()->Resolve()); @@ -263,22 +263,22 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferPointer) { TEST_F(ResolverStorageClassValidationTest, UniformBufferIntScalar) { // var g : i32; - Global(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kUniform, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverStorageClassValidationTest, UniformBufferVector) { // var g : vec4; - Global(Source{{56, 78}}, "g", ty.vec4(), ast::StorageClass::kUniform, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.vec4(), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -290,11 +290,11 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferArray) { // var g : array; 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -303,11 +303,11 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferBoolAlias) { // type a = bool; // var g : a; auto* a = Alias("a", ty.bool_()); - Global(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kUniform, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_FALSE(r()->Resolve()); @@ -321,11 +321,11 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Basic) { // struct S { x : i32 }; // var g : S; auto* s = Structure("S", {Member(Source{{12, 34}}, "x", ty.i32())}); - Global(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kUniform, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -336,11 +336,11 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferNoError_Aliases) { // var 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{56, 78}}, "g", ty.Of(a1), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(0), + }); ASSERT_TRUE(r()->Resolve()) << r()->error(); } diff --git a/src/tint/resolver/struct_storage_class_use_test.cc b/src/tint/resolver/struct_storage_class_use_test.cc index 72ed546fcc..c524f71236 100644 --- a/src/tint/resolver/struct_storage_class_use_test.cc +++ b/src/tint/resolver/struct_storage_class_use_test.cc @@ -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,16 +159,16 @@ TEST_F(ResolverStorageClassUseTest, StructReachableViaLocalArray) { TEST_F(ResolverStorageClassUseTest, StructMultipleStorageClassUses) { auto* s = Structure("S", {Member("a", ty.f32())}); - Global("x", ty.Of(s), ast::StorageClass::kUniform, - ast::AttributeList{ - create(0), - create(0), - }); - Global("y", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(0), - }); + GlobalVar("x", ty.Of(s), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(0), + }); + GlobalVar("y", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(0), + }); WrapInFunction(Var("g", ty.Of(s))); ASSERT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/type_constructor_validation_test.cc b/src/tint/resolver/type_constructor_validation_test.cc index 5d891fce95..05ee96434d 100644 --- a/src/tint/resolver/type_constructor_validation_test.cc +++ b/src/tint/resolver/type_constructor_validation_test.cc @@ -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(), "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()); - 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("my_vec2", "my_f32"); WrapInFunction(tc); diff --git a/src/tint/resolver/type_validation_test.cc b/src/tint/resolver/type_validation_test.cc index b5cc185bac..fbf74cf9af 100644 --- a/src/tint/resolver/type_validation_test.cc +++ b/src/tint/resolver/type_validation_test.cc @@ -82,7 +82,7 @@ TEST_F(ResolverTypeValidationTest, GlobalOverrideNoConstructor_Pass) { TEST_F(ResolverTypeValidationTest, GlobalVariableWithStorageClass_Pass) { // var 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 a : array; - 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 a : array; - 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 a : array; - 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 a : array; 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 a : array; 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 a : array; - 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 a : array; - 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 a : array; - 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 a : array; - 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 a : array; 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 a : array; 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 a : array; 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 a : array; - 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,8 +278,8 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FloatLiteral) { TEST_F(ResolverTypeValidationTest, ArraySize_IVecLiteral) { // var a : array(10, 10)>; - Global("a", ty.array(ty.f32(), Construct(Source{{12, 34}}, ty.vec2(), 10_i, 10_i)), - ast::StorageClass::kPrivate); + GlobalVar("a", ty.array(ty.f32(), Construct(Source{{12, 34}}, ty.vec2(), 10_i, 10_i)), + 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 " @@ -290,7 +290,7 @@ TEST_F(ResolverTypeValidationTest, ArraySize_FloatLet) { // let size = 10.0; // var a : array; 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(100, 100); // var a : array; GlobalLet("size", nullptr, Construct(ty.vec2(), 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 a : array; - 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 a : @stride(8) array; - 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 a : array; 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 size : i32 = 10i; // var a : array; - 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 a : array; auto* foo = Structure("Foo", {Member("rt", ty.array())}); - 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(), ast::StorageClass::kPrivate); + GlobalVar(Source{{56, 78}}, "g", ty.array(), 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 a : i32; // var 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 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 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 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 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,8 +748,8 @@ struct DimensionParams { using SampledTextureDimensionTest = ResolverTestWithParam; TEST_P(SampledTextureDimensionTest, All) { auto& params = GetParam(); - Global(Source{{12, 34}}, "a", ty.sampled_texture(params.dim, ty.i32()), - ast::StorageClass::kNone, nullptr, ast::AttributeList{GroupAndBinding(0, 0)}); + 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,8 +766,8 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest, using MultisampledTextureDimensionTest = ResolverTestWithParam; TEST_P(MultisampledTextureDimensionTest, All) { auto& params = GetParam(); - Global("a", ty.multisampled_texture(Source{{12, 34}}, params.dim, ty.i32()), - ast::StorageClass::kNone, nullptr, ast::AttributeList{GroupAndBinding(0, 0)}); + 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) { EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -816,7 +817,7 @@ static constexpr TypeParams type_cases[] = { using SampledTextureTypeTest = ResolverTestWithParam; 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,10 +836,10 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest, using MultisampledTextureTypeTest = ResolverTestWithParam; TEST_P(MultisampledTextureTypeTest, All) { auto& params = GetParam(); - Global("a", - ty.multisampled_texture(Source{{12, 34}}, ast::TextureDimension::k2d, - params.type_func(*this)), - ast::StorageClass::kNone, nullptr, ast::AttributeList{GroupAndBinding(0, 0)}); + GlobalVar("a", + ty.multisampled_texture(Source{{12, 34}}, ast::TextureDimension::k2d, + params.type_func(*this)), + ast::StorageClass::kNone, nullptr, ast::AttributeList{GroupAndBinding(0, 0)}); if (params.is_valid) { EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -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,8 +1029,8 @@ using ValidMatrixTypes = ResolverTestWithParam; TEST_P(ValidMatrixTypes, Okay) { // var a : matNxM; auto& params = GetParam(); - Global("a", ty.mat(params.elem_ty(*this), params.columns, params.rows), - ast::StorageClass::kPrivate); + GlobalVar("a", ty.mat(params.elem_ty(*this), params.columns, params.rows), + ast::StorageClass::kPrivate); EXPECT_TRUE(r()->Resolve()) << r()->error(); } INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest, @@ -1048,8 +1052,8 @@ using InvalidMatrixElementTypes = ResolverTestWithParam; TEST_P(InvalidMatrixElementTypes, InvalidElementType) { // var a : matNxM; auto& params = GetParam(); - Global("a", ty.mat(Source{{12, 34}}, params.elem_ty(*this), params.columns, params.rows), - ast::StorageClass::kPrivate); + 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; TEST_P(ValidVectorTypes, Okay) { // var a : vecN; 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,8 +1112,8 @@ using InvalidVectorElementTypes = ResolverTestWithParam; TEST_P(InvalidVectorElementTypes, InvalidElementType) { // var a : vecN; auto& params = GetParam(); - Global("a", ty.vec(Source{{12, 34}}, params.elem_ty(*this), params.width), - ast::StorageClass::kPrivate); + GlobalVar("a", ty.vec(Source{{12, 34}}, params.elem_ty(*this), params.width), + ast::StorageClass::kPrivate); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: vector element type must be 'bool', 'f32', 'i32' or 'u32'"); diff --git a/src/tint/resolver/uniformity_test.cc b/src/tint/resolver/uniformity_test.cc index 002f841beb..cc2f5200eb 100644 --- a/src/tint/resolver/uniformity_test.cc +++ b/src/tint/resolver/uniformity_test.cc @@ -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++) { diff --git a/src/tint/resolver/validation_test.cc b/src/tint/resolver/validation_test.cc index 9177d6b5fc..18ef8c74ef 100644 --- a/src/tint/resolver/validation_test.cc +++ b/src/tint/resolver/validation_test.cc @@ -61,8 +61,8 @@ class FakeExpr final : public Castable { }; TEST_F(ResolverValidationTest, WorkgroupMemoryUsedInVertexStage) { - Global(Source{{1, 2}}, "wg", ty.vec4(), ast::StorageClass::kWorkgroup); - Global("dst", ty.vec4(), ast::StorageClass::kPrivate); + GlobalVar(Source{{1, 2}}, "wg", ty.vec4(), ast::StorageClass::kWorkgroup); + GlobalVar("dst", ty.vec4(), ast::StorageClass::kPrivate); auto* stmt = Assign(Expr("dst"), Expr(Source{{3, 4}}, "wg")); Func(Source{{9, 10}}, "f0", {}, ty.vec4(), @@ -93,8 +93,8 @@ TEST_F(ResolverValidationTest, WorkgroupMemoryUsedInFragmentStage) { // f1(); //} - Global(Source{{1, 2}}, "wg", ty.vec4(), ast::StorageClass::kWorkgroup); - Global("dst", ty.vec4(), ast::StorageClass::kPrivate); + GlobalVar(Source{{1, 2}}, "wg", ty.vec4(), ast::StorageClass::kWorkgroup); + GlobalVar("dst", ty.vec4(), 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,11 +324,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle, + ast::AttributeList{ + create(0), + create(0), + }); EXPECT_FALSE(r()->Resolve()); @@ -338,11 +338,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle, + ast::AttributeList{ + create(0), + create(0), + }); EXPECT_FALSE(r()->Resolve()) << r()->error(); @@ -351,7 +351,7 @@ TEST_F(ResolverValidationTest, StorageClass_TextureExplicitStorageClass) { } TEST_F(ResolverValidationTest, Expr_MemberAccessor_VectorSwizzle_BadChar) { - Global("my_vec", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("my_vec", ty.vec3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_vec", ty.vec4(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_vec", ty.vec3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_vec", ty.vec2(), ast::StorageClass::kPrivate); auto* ident = Expr(Source{{3, 3}}, "z"); auto* mem = MemberAccessor("my_vec", ident); diff --git a/src/tint/resolver/variable_test.cc b/src/tint/resolver/variable_test.cc index f860adea0e..ad3742ca29 100644 --- a/src/tint/resolver/variable_test.cc +++ b/src/tint/resolver/variable_test.cc @@ -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,11 +419,11 @@ TEST_F(ResolverVariableTest, LocalLet_InheritsAccessFromOriginatingVariable) { // } auto* inner = Structure("Inner", {Member("arr", ty.array())}); auto* buf = Structure("S", {Member("inner", ty.Of(inner))}); - auto* storage = Global("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(0), - create(0), - }); + auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 4_i); auto* ptr = Let("p", nullptr, AddressOf(expr)); @@ -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,23 +627,23 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); - auto* storage = Global("sb", ty.Of(buf), ast::StorageClass::kStorage, - ast::AttributeList{ - create(1), - create(0), - }); - auto* handle = Global("h", ty.depth_texture(ast::TextureDimension::k2d), - ast::AttributeList{ - create(2), - create(0), - }); + 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(0), + create(0), + }); + auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, + ast::AttributeList{ + create(1), + create(0), + }); + auto* handle = GlobalVar("h", ty.depth_texture(ast::TextureDimension::k2d), + ast::AttributeList{ + create(2), + create(0), + }); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -664,11 +664,12 @@ 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, - ast::AttributeList{ - create(1), - create(0), - }); + auto* storage = + GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(1), + create(0), + }); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -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_(), {}); diff --git a/src/tint/resolver/variable_validation_test.cc b/src/tint/resolver/variable_validation_test.cc index ea90160cd0..60ecaaab49 100644 --- a/src/tint/resolver/variable_validation_test.cc +++ b/src/tint/resolver/variable_validation_test.cc @@ -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,8 +65,8 @@ TEST_F(ResolverVariableValidationTest, VarTypeNotStorable) { TEST_F(ResolverVariableValidationTest, LetTypeNotConstructible) { // @group(0) @binding(0) var t1 : texture_2d; // let t2 : t1; - auto* t1 = Global("t1", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), - GroupAndBinding(0, 0)); + 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,11 +214,11 @@ TEST_F(ResolverVariableValidationTest, InferredPtrStorageAccessMismatch) { // } auto* inner = Structure("Inner", {Member("arr", ty.array())}); auto* buf = Structure("S", {Member("inner", ty.Of(inner))}); - auto* storage = Global("s", ty.Of(buf), ast::StorageClass::kStorage, - ast::AttributeList{ - create(0), - create(0), - }); + auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, + ast::AttributeList{ + create(0), + create(0), + }); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i); auto* ptr = @@ -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 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(), diff --git a/src/tint/transform/array_length_from_uniform.cc b/src/tint/transform/array_length_from_uniform.cc index 86c45345d8..81471ad514 100644 --- a/src/tint/transform/array_length_from_uniform.cc +++ b/src/tint/transform/array_length_from_uniform.cc @@ -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)}); diff --git a/src/tint/transform/canonicalize_entry_point_io.cc b/src/tint/transform/canonicalize_entry_point_io.cc index 104429b3bd..a324bcceba 100644 --- a/src/tint/transform/canonicalize_entry_point_io.cc +++ b/src/tint/transform/canonicalize_entry_point_io.cc @@ -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(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)); } } diff --git a/src/tint/transform/combine_samplers.cc b/src/tint/transform/combine_samplers.cc index cd8395c782..22680a31d4 100644 --- a/src/tint/transform/combine_samplers.cc +++ b/src/tint/transform/combine_samplers.cc @@ -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. diff --git a/src/tint/transform/decompose_strided_array_test.cc b/src/tint/transform/decompose_strided_array_test.cc index ffc66956e1..65b394a050 100644 --- a/src/tint/transform/decompose_strided_array_test.cc +++ b/src/tint/transform/decompose_strided_array_test.cc @@ -39,7 +39,7 @@ TEST_F(DecomposeStridedArrayTest, ShouldRunNonStridedArray) { // var arr : array ProgramBuilder b; - b.Global("arr", b.ty.array(), ast::StorageClass::kPrivate); + b.GlobalVar("arr", b.ty.array(), ast::StorageClass::kPrivate); EXPECT_FALSE(ShouldRun(Program(std::move(b)))); } @@ -47,7 +47,7 @@ TEST_F(DecomposeStridedArrayTest, ShouldRunDefaultStridedArray) { // var arr : @stride(4) array ProgramBuilder b; - b.Global("arr", b.ty.array(4), ast::StorageClass::kPrivate); + b.GlobalVar("arr", b.ty.array(4), ast::StorageClass::kPrivate); EXPECT_TRUE(ShouldRun(Program(std::move(b)))); } @@ -55,7 +55,7 @@ TEST_F(DecomposeStridedArrayTest, ShouldRunExplicitStridedArray) { // var arr : @stride(16) array ProgramBuilder b; - b.Global("arr", b.ty.array(16), ast::StorageClass::kPrivate); + b.GlobalVar("arr", b.ty.array(16), ast::StorageClass::kPrivate); EXPECT_TRUE(ShouldRun(Program(std::move(b)))); } @@ -78,7 +78,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateDefaultStridedArray) { // } ProgramBuilder b; - b.Global("arr", b.ty.array(4), ast::StorageClass::kPrivate); + b.GlobalVar("arr", b.ty.array(4), ast::StorageClass::kPrivate); b.Func("f", {}, b.ty.void_(), { b.Decl(b.Let("a", b.ty.array(4), b.Expr("arr"))), @@ -114,7 +114,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateStridedArray) { // } ProgramBuilder b; - b.Global("arr", b.ty.array(32), ast::StorageClass::kPrivate); + b.GlobalVar("arr", b.ty.array(32), ast::StorageClass::kPrivate); b.Func("f", {}, b.ty.void_(), { b.Decl(b.Let("a", b.ty.array(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(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(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(), 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(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(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(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(4), b.MemberAccessor("s", "a"))), @@ -344,8 +344,8 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageStridedArray) { // } ProgramBuilder b; auto* S = b.Structure("S", {b.Member("a", b.ty.array(32))}); - b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, - b.GroupAndBinding(0, 0)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, + b.GroupAndBinding(0, 0)); b.Func("f", {}, b.ty.void_(), { b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array(32))), @@ -398,8 +398,8 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageDefaultStridedArray) { // } ProgramBuilder b; auto* S = b.Structure("S", {b.Member("a", b.ty.array(4))}); - b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, - b.GroupAndBinding(0, 0)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, + b.GroupAndBinding(0, 0)); b.Func("f", {}, b.ty.void_(), { b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array(4))), @@ -450,8 +450,8 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) { // } ProgramBuilder b; auto* S = b.Structure("S", {b.Member("a", b.ty.array(32))}); - b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, - b.GroupAndBinding(0, 0)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, + b.GroupAndBinding(0, 0)); b.Func("f", {}, b.ty.void_(), { b.Decl(b.Let("a", nullptr, b.AddressOf(b.MemberAccessor("s", "a")))), @@ -511,8 +511,8 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) { ProgramBuilder b; b.Alias("ARR", b.ty.array(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.GroupAndBinding(0, 0)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, + b.GroupAndBinding(0, 0)); b.Func("f", {}, b.ty.void_(), { b.Decl(b.Let("a", b.ty.type_name("ARR"), b.MemberAccessor("s", "a"))), @@ -581,8 +581,8 @@ 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.GroupAndBinding(0, 0)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, + b.GroupAndBinding(0, 0)); b.Func("f", {}, b.ty.void_(), { b.Decl(b.Let("a", b.ty.type_name("ARR_B"), b.MemberAccessor("s", "a"))), diff --git a/src/tint/transform/decompose_strided_matrix_test.cc b/src/tint/transform/decompose_strided_matrix_test.cc index 06169d763d..a2bf26d776 100644 --- a/src/tint/transform/decompose_strided_matrix_test.cc +++ b/src/tint/transform/decompose_strided_matrix_test.cc @@ -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(), 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(), b.MemberAccessor("s", "m"))), @@ -238,8 +238,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, - b.GroupAndBinding(0, 0)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, + b.GroupAndBinding(0, 0)); b.Func("f", {}, b.ty.void_(), { b.Decl(b.Let("x", b.ty.mat2x2(), b.MemberAccessor("s", "m"))), @@ -295,8 +295,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, - b.GroupAndBinding(0, 0)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, + b.GroupAndBinding(0, 0)); b.Func( "f", {}, b.ty.void_(), { @@ -349,8 +349,8 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, - b.GroupAndBinding(0, 0)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, + b.GroupAndBinding(0, 0)); b.Func("f", {}, b.ty.void_(), { b.Assign(b.MemberAccessor("s", "m"), @@ -407,8 +407,8 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, - b.GroupAndBinding(0, 0)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, + b.GroupAndBinding(0, 0)); b.Func("f", {}, b.ty.void_(), { b.Assign(b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i), b.vec2(1_f, 2_f)), @@ -466,8 +466,8 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, - b.GroupAndBinding(0, 0)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, + b.GroupAndBinding(0, 0)); b.Func("f", {}, b.ty.void_(), { b.Decl(b.Let("a", nullptr, b.AddressOf(b.MemberAccessor("s", "m")))), @@ -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(), 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"), diff --git a/src/tint/transform/first_index_offset.cc b/src/tint/transform/first_index_offset.cc index 9d89b83acd..01f9771e14 100644 --- a/src/tint/transform/first_index_offset.cc +++ b/src/tint/transform/first_index_offset.cc @@ -121,11 +121,12 @@ 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, - ast::AttributeList{ - ctx.dst->create(ub_binding), - ctx.dst->create(ub_group), - }); + ctx.dst->GlobalVar(buffer_name, ctx.dst->ty.Of(struct_), ast::StorageClass::kUniform, + nullptr, + ast::AttributeList{ + ctx.dst->create(ub_binding), + ctx.dst->create(ub_group), + }); // Fix up all references to the builtins with the offsets ctx.ReplaceAll([=, &ctx](const ast::Expression* expr) -> const ast::Expression* { diff --git a/src/tint/transform/multiplanar_external_texture.cc b/src/tint/transform/multiplanar_external_texture.cc index cf5a5a61ee..c3aba9babf 100644 --- a/src/tint/transform/multiplanar_external_texture.cc +++ b/src/tint/transform/multiplanar_external_texture.cc @@ -131,12 +131,12 @@ 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.GroupAndBinding(bps.plane_1.group, bps.plane_1.binding)); + 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"), - ast::StorageClass::kUniform, - b.GroupAndBinding(bps.params.group, bps.params.binding)); + b.GlobalVar(syms.params, b.ty.type_name("ExternalTextureParams"), + ast::StorageClass::kUniform, + b.GroupAndBinding(bps.params.group, bps.params.binding)); // Replace the original texture_external binding with a texture_2d // binding. diff --git a/src/tint/transform/num_workgroups_from_uniform.cc b/src/tint/transform/num_workgroups_from_uniform.cc index bba1580c62..6b93e73387 100644 --- a/src/tint/transform/num_workgroups_from_uniform.cc +++ b/src/tint/transform/num_workgroups_from_uniform.cc @@ -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)}); } diff --git a/src/tint/transform/unwind_discard_functions.cc b/src/tint/transform/unwind_discard_functions.cc index a7877e19b2..d41ef6c3aa 100644 --- a/src/tint/transform/unwind_discard_functions.cc +++ b/src/tint/transform/unwind_discard_functions.cc @@ -54,8 +54,8 @@ 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), - ast::StorageClass::kPrivate); + ctx.dst->GlobalVar(module_discard_var_name, b.ty.bool_(), b.Expr(false), + ast::StorageClass::kPrivate); } return module_discard_var_name; } diff --git a/src/tint/transform/vertex_pulling.cc b/src/tint/transform/vertex_pulling.cc index a1627e2ab3..50b8f285ab 100644 --- a/src/tint/transform/vertex_pulling.cc +++ b/src/tint/transform/vertex_pulling.cc @@ -259,12 +259,12 @@ 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), - ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - ctx.dst->create(i), - ctx.dst->create(cfg.pulling_group), - }); + ctx.dst->GlobalVar(GetVertexBufferName(i), ctx.dst->ty.Of(struct_type), + ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + ctx.dst->create(i), + ctx.dst->create(cfg.pulling_group), + }); } } diff --git a/src/tint/writer/append_vector_test.cc b/src/tint/writer/append_vector_test.cc index 8169039210..22310033d9 100644 --- a/src/tint/writer/append_vector_test.cc +++ b/src/tint/writer/append_vector_test.cc @@ -250,7 +250,7 @@ TEST_F(AppendVectorTest, Vec3i32_i32) { // AppendVector(vec_12, 3) -> vec3(vec_12, 3) TEST_F(AppendVectorTest, Vec2i32Var_i32) { - Global("vec_12", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("vec_12", ty.vec2(), 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(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(vec_12, scalar_3) TEST_F(AppendVectorTest, Vec2i32Var_i32Var) { - Global("vec_12", ty.vec2(), ast::StorageClass::kPrivate); - Global("scalar_3", ty.i32(), ast::StorageClass::kPrivate); + GlobalVar("vec_12", ty.vec2(), 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(vec_12, i32(scalar_3)) TEST_F(AppendVectorTest, Vec2i32Var_f32Var) { - Global("vec_12", ty.vec2(), ast::StorageClass::kPrivate); - Global("scalar_3", ty.f32(), ast::StorageClass::kPrivate); + GlobalVar("vec_12", ty.vec2(), 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(vec_12, scalar_3) TEST_F(AppendVectorTest, Vec2boolVar_boolVar) { - Global("vec_12", ty.vec2(), ast::StorageClass::kPrivate); - Global("scalar_3", ty.bool_(), ast::StorageClass::kPrivate); + GlobalVar("vec_12", ty.vec2(), 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); diff --git a/src/tint/writer/flatten_bindings_test.cc b/src/tint/writer/flatten_bindings_test.cc index 1c516c92e5..ae01abd507 100644 --- a/src/tint/writer/flatten_bindings_test.cc +++ b/src/tint/writer/flatten_bindings_test.cc @@ -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.GroupAndBinding(2, 2)); + 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.GroupAndBinding(4, 4)); + 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.GroupAndBinding(5, 5)); - b.Global("texture2", b.ty.multisampled_texture(ast::TextureDimension::k2d, b.ty.f32()), - b.GroupAndBinding(6, 6)); - b.Global("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.GroupAndBinding(9, 9)); - b.Global("texture6", b.ty.external_texture(), b.GroupAndBinding(10, 10)); + b.GlobalVar("texture1", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32()), + b.GroupAndBinding(5, 5)); + b.GlobalVar("texture2", b.ty.multisampled_texture(ast::TextureDimension::k2d, b.ty.f32()), + b.GroupAndBinding(6, 6)); + b.GlobalVar("texture3", + b.ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float, + ast::Access::kWrite), + b.GroupAndBinding(7, 7)); + 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.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"), diff --git a/src/tint/writer/generate_external_texture_bindings_test.cc b/src/tint/writer/generate_external_texture_bindings_test.cc index d0918c322d..292b2ea667 100644 --- a/src/tint/writer/generate_external_texture_bindings_test.cc +++ b/src/tint/writer/generate_external_texture_bindings_test.cc @@ -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)); diff --git a/src/tint/writer/glsl/generator_impl_array_accessor_test.cc b/src/tint/writer/glsl/generator_impl_array_accessor_test.cc index d28e5607d8..bbf90fe8a1 100644 --- a/src/tint/writer/glsl/generator_impl_array_accessor_test.cc +++ b/src/tint/writer/glsl/generator_impl_array_accessor_test.cc @@ -22,7 +22,7 @@ namespace { using GlslGeneratorImplTest_Expression = TestHelper; TEST_F(GlslGeneratorImplTest_Expression, IndexAccessor) { - Global("ary", ty.array(), ast::StorageClass::kPrivate); + GlobalVar("ary", ty.array(), ast::StorageClass::kPrivate); auto* expr = IndexAccessor("ary", 5_i); WrapInFunction(expr); diff --git a/src/tint/writer/glsl/generator_impl_assign_test.cc b/src/tint/writer/glsl/generator_impl_assign_test.cc index fbd9f6262c..84b6b30c69 100644 --- a/src/tint/writer/glsl/generator_impl_assign_test.cc +++ b/src/tint/writer/glsl/generator_impl_assign_test.cc @@ -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); diff --git a/src/tint/writer/glsl/generator_impl_binary_test.cc b/src/tint/writer/glsl/generator_impl_binary_test.cc index 0d019a98f8..b52925575d 100644 --- a/src/tint/writer/glsl/generator_impl_binary_test.cc +++ b/src/tint/writer/glsl/generator_impl_binary_test.cc @@ -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(), ast::StorageClass::kPrivate); + GlobalVar("mat", ty.mat3x3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("mat", ty.mat3x3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("mat", ty.mat3x3(), ast::StorageClass::kPrivate); auto* lhs = Expr("mat"); auto* rhs = vec3(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(), ast::StorageClass::kPrivate); + GlobalVar("mat", ty.mat3x3(), ast::StorageClass::kPrivate); auto* lhs = vec3(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(), ast::StorageClass::kPrivate); - Global("rhs", ty.mat3x3(), ast::StorageClass::kPrivate); + GlobalVar("lhs", ty.mat3x3(), ast::StorageClass::kPrivate); + GlobalVar("rhs", ty.mat3x3(), ast::StorageClass::kPrivate); auto* expr = create(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::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::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(), ast::StorageClass::kPrivate); - Global("b", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("a", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("b", ty.vec3(), ast::StorageClass::kPrivate); auto* expr = create(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::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::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::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::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( diff --git a/src/tint/writer/glsl/generator_impl_builtin_test.cc b/src/tint/writer/glsl/generator_impl_builtin_test.cc index f7572b2356..c753293016 100644 --- a/src/tint/writer/glsl/generator_impl_builtin_test.cc +++ b/src/tint/writer/glsl/generator_impl_builtin_test.cc @@ -153,13 +153,13 @@ using GlslBuiltinTest = TestParamHelper; TEST_P(GlslBuiltinTest, Emit) { auto param = GetParam(); - Global("f2", ty.vec2(), ast::StorageClass::kPrivate); - Global("f3", ty.vec3(), ast::StorageClass::kPrivate); - Global("u2", ty.vec2(), ast::StorageClass::kPrivate); - Global("i2", ty.vec2(), ast::StorageClass::kPrivate); - Global("b2", ty.vec2(), ast::StorageClass::kPrivate); - Global("m2x2", ty.mat2x2(), ast::StorageClass::kPrivate); - Global("m3x2", ty.mat3x2(), ast::StorageClass::kPrivate); + GlobalVar("f2", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("f3", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("u2", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("i2", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("b2", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("m2x2", ty.mat2x2(), ast::StorageClass::kPrivate); + GlobalVar("m3x2", ty.mat3x2(), 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(), ast::StorageClass::kPrivate); - Global("param2", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("param1", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("param2", ty.vec3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("p1", ty.vec4(), 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(), ast::StorageClass::kPrivate); + GlobalVar("p1", ty.vec4(), 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(), ast::StorageClass::kPrivate); + GlobalVar("p1", ty.vec2(), 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(), ast::StorageClass::kPrivate); + GlobalVar("p1", ty.vec2(), 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(), ast::StorageClass::kPrivate); + GlobalVar("p1", ty.vec2(), 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(), ast::StorageClass::kPrivate); + GlobalVar("v", ty.vec3(), 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(), ast::StorageClass::kPrivate); - Global("b", ty.vec3(), ast::StorageClass::kPrivate); - Global("c", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("a", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("b", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("c", ty.vec3(), ast::StorageClass::kPrivate); WrapInFunction(CallStmt(call)); @@ -846,7 +846,7 @@ TEST_F(GlslGeneratorImplTest_Builtin, FMA) { } TEST_F(GlslGeneratorImplTest_Builtin, DotU32) { - Global("v", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("v", ty.vec3(), ast::StorageClass::kPrivate); WrapInFunction(CallStmt(Call("dot", "v", "v"))); GeneratorImpl& gen = SanitizeAndBuild(); diff --git a/src/tint/writer/glsl/generator_impl_call_test.cc b/src/tint/writer/glsl/generator_impl_call_test.cc index c8a1de26e9..d1866eafa5 100644 --- a/src/tint/writer/glsl/generator_impl_call_test.cc +++ b/src/tint/writer/glsl/generator_impl_call_test.cc @@ -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); diff --git a/src/tint/writer/glsl/generator_impl_function_test.cc b/src/tint/writer/glsl/generator_impl_function_test.cc index 4f1d027d57..e43ad53568 100644 --- a/src/tint/writer/glsl/generator_impl_function_test.cc +++ b/src/tint/writer/glsl/generator_impl_function_test.cc @@ -349,11 +349,11 @@ tint_symbol_2 vert_main2() { TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) { auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4())}); - auto* ubo = Global("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, - ast::AttributeList{ - create(0), - create(1), - }); + auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(1), + }); Func("sub_func", { @@ -403,11 +403,11 @@ void frag_main() { TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStruct) { auto* s = Structure("Uniforms", {Member("coord", ty.vec4())}); - Global("uniforms", ty.Of(s), ast::StorageClass::kUniform, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(1), + }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor(MemberAccessor("uniforms", "coord"), "x")); @@ -448,11 +448,11 @@ 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, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(1), + }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); @@ -498,11 +498,11 @@ 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, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(1), + }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); @@ -549,11 +549,11 @@ 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, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite, + ast::AttributeList{ + create(0), + create(1), + }); Func("frag_main", {}, ty.void_(), { @@ -597,11 +597,11 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf Member("b", ty.f32()), }); - Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(1), + }); Func("frag_main", {}, ty.void_(), { @@ -641,11 +641,11 @@ 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, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(1), + }); Func("sub_func", {Param("param", ty.f32())}, ty.f32(), { @@ -690,11 +690,11 @@ 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, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(1), + }); Func("sub_func", {Param("param", ty.f32())}, ty.f32(), { @@ -922,11 +922,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); { auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("data", "d")); diff --git a/src/tint/writer/glsl/generator_impl_identifier_test.cc b/src/tint/writer/glsl/generator_impl_identifier_test.cc index 396c261f20..ff9bc88c72 100644 --- a/src/tint/writer/glsl/generator_impl_identifier_test.cc +++ b/src/tint/writer/glsl/generator_impl_identifier_test.cc @@ -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); diff --git a/src/tint/writer/glsl/generator_impl_if_test.cc b/src/tint/writer/glsl/generator_impl_if_test.cc index 4b0b7bbe7a..82dc307abc 100644 --- a/src/tint/writer/glsl/generator_impl_if_test.cc +++ b/src/tint/writer/glsl/generator_impl_if_test.cc @@ -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"); diff --git a/src/tint/writer/glsl/generator_impl_import_test.cc b/src/tint/writer/glsl/generator_impl_import_test.cc index 2843f98b2e..9e988f1362 100644 --- a/src/tint/writer/glsl/generator_impl_import_test.cc +++ b/src/tint/writer/glsl/generator_impl_import_test.cc @@ -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(), ast::StorageClass::kPrivate); + GlobalVar("var", ty.mat3x3(), ast::StorageClass::kPrivate); auto* expr = Call("determinant", "var"); WrapInFunction(expr); diff --git a/src/tint/writer/glsl/generator_impl_loop_test.cc b/src/tint/writer/glsl/generator_impl_loop_test.cc index ec9219a9a4..9da50f0a91 100644 --- a/src/tint/writer/glsl/generator_impl_loop_test.cc +++ b/src/tint/writer/glsl/generator_impl_loop_test.cc @@ -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()); 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())), // diff --git a/src/tint/writer/glsl/generator_impl_member_accessor_test.cc b/src/tint/writer/glsl/generator_impl_member_accessor_test.cc index fcfa9df5e1..11e0e38c22 100644 --- a/src/tint/writer/glsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/glsl/generator_impl_member_accessor_test.cc @@ -91,11 +91,11 @@ class GlslGeneratorImplTest_MemberAccessorBase : public BASE { auto* s = b.Structure("Data", members); - b.Global("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - b.create(0), - b.create(1), - }); + b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + b.create(0), + b.create(1), + }); } void SetupFunction(ast::StatementList statements) { @@ -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)); diff --git a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc index 0187da07b8..13f2762296 100644 --- a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc @@ -26,11 +26,11 @@ using GlslSanitizerTest = TestHelper; TEST_F(GlslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); Func("a_func", {}, ty.void_(), { @@ -69,11 +69,11 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { Member(0, "z", ty.f32()), Member(4, "a", ty.array(4)), }); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); Func("a_func", {}, ty.void_(), { @@ -111,11 +111,11 @@ void main() { TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); auto* p = Let("p", nullptr, AddressOf("b")); auto* p2 = Let("p2", nullptr, AddressOf(MemberAccessor(Deref(p), "a"))); diff --git a/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc b/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc index a12fbbcd9d..e2a6f97c65 100644 --- a/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc +++ b/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc @@ -35,11 +35,11 @@ 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, - ast::AttributeList{ - ctx->create(0), - ctx->create(0), - }); + ctx->GlobalVar("nephews", ctx->ty.Of(nephews), ast::StorageClass::kStorage, + ast::AttributeList{ + ctx->create(0), + ctx->create(0), + }); } TEST_F(GlslGeneratorImplTest_StorageBuffer, Align) { diff --git a/src/tint/writer/glsl/generator_impl_switch_test.cc b/src/tint/writer/glsl/generator_impl_switch_test.cc index 1cc42fb639..c8957be2ff 100644 --- a/src/tint/writer/glsl/generator_impl_switch_test.cc +++ b/src/tint/writer/glsl/generator_impl_switch_test.cc @@ -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()); auto* def = create(ast::CaseSelectorList{}, def_body); diff --git a/src/tint/writer/glsl/generator_impl_test.cc b/src/tint/writer/glsl/generator_impl_test.cc index 70e5c0b75d..3dbf601258 100644 --- a/src/tint/writer/glsl/generator_impl_test.cc +++ b/src/tint/writer/glsl/generator_impl_test.cc @@ -57,12 +57,12 @@ void my_func() { } TEST_F(GlslGeneratorImplTest, GenerateSampleIndexES) { - Global("gl_SampleID", ty.i32(), - ast::AttributeList{ - Builtin(ast::Builtin::kSampleIndex), - Disable(ast::DisabledValidation::kIgnoreStorageClass), - }, - ast::StorageClass::kInput); + GlobalVar("gl_SampleID", ty.i32(), + ast::AttributeList{ + Builtin(ast::Builtin::kSampleIndex), + Disable(ast::DisabledValidation::kIgnoreStorageClass), + }, + ast::StorageClass::kInput); Func("my_func", {}, ty.i32(), { Return(Expr("gl_SampleID")), @@ -82,12 +82,12 @@ int my_func() { } TEST_F(GlslGeneratorImplTest, GenerateSampleIndexDesktop) { - Global("gl_SampleID", ty.i32(), - ast::AttributeList{ - Builtin(ast::Builtin::kSampleIndex), - Disable(ast::DisabledValidation::kIgnoreStorageClass), - }, - ast::StorageClass::kInput); + GlobalVar("gl_SampleID", ty.i32(), + ast::AttributeList{ + Builtin(ast::Builtin::kSampleIndex), + Disable(ast::DisabledValidation::kIgnoreStorageClass), + }, + ast::StorageClass::kInput); Func("my_func", {}, ty.i32(), { Return(Expr("gl_SampleID")), diff --git a/src/tint/writer/glsl/generator_impl_type_test.cc b/src/tint/writer/glsl/generator_impl_type_test.cc index b7daee263a..42423688b6 100644 --- a/src/tint/writer/glsl/generator_impl_type_test.cc +++ b/src/tint/writer/glsl/generator_impl_type_test.cc @@ -33,7 +33,7 @@ using GlslGeneratorImplTest_Type = TestHelper; TEST_F(GlslGeneratorImplTest_Type, EmitType_Array) { auto* arr = ty.array(); - 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(), 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(), 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(); - 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,11 +270,11 @@ TEST_P(GlslDepthTexturesTest, Emit) { auto* t = ty.depth_texture(params.dim); - Global("tex", t, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("tex", t, + ast::AttributeList{ + create(1), + create(2), + }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, {Stage(ast::PipelineStage::kFragment)}); @@ -297,11 +297,11 @@ using GlslDepthMultisampledTexturesTest = TestHelper; TEST_F(GlslDepthMultisampledTexturesTest, Emit) { auto* t = ty.depth_multisampled_texture(ast::TextureDimension::k2d); - Global("tex", t, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("tex", t, + ast::AttributeList{ + create(1), + create(2), + }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, {Stage(ast::PipelineStage::kFragment)}); @@ -340,11 +340,11 @@ TEST_P(GlslSampledTexturesTest, Emit) { } auto* t = ty.sampled_texture(params.dim, datatype); - Global("tex", t, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("tex", t, + ast::AttributeList{ + create(1), + create(2), + }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, {Stage(ast::PipelineStage::kFragment)}); @@ -474,11 +474,11 @@ TEST_P(GlslStorageTexturesTest, Emit) { auto* t = ty.storage_texture(params.dim, params.imgfmt, ast::Access::kWrite); - Global("tex", t, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("tex", t, + ast::AttributeList{ + create(1), + create(2), + }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, {Stage(ast::PipelineStage::kFragment)}); diff --git a/src/tint/writer/glsl/generator_impl_unary_op_test.cc b/src/tint/writer/glsl/generator_impl_unary_op_test.cc index 0e318fcf8c..22012c800c 100644 --- a/src/tint/writer/glsl/generator_impl_unary_op_test.cc +++ b/src/tint/writer/glsl/generator_impl_unary_op_test.cc @@ -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::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::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::UnaryOp::kAddressOf, Expr("G"))); auto* op = create(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::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::UnaryOp::kNegation, Expr("expr")); WrapInFunction(op); diff --git a/src/tint/writer/glsl/generator_impl_uniform_buffer_test.cc b/src/tint/writer/glsl/generator_impl_uniform_buffer_test.cc index 8709b3dadc..8e653b5712 100644 --- a/src/tint/writer/glsl/generator_impl_uniform_buffer_test.cc +++ b/src/tint/writer/glsl/generator_impl_uniform_buffer_test.cc @@ -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)); diff --git a/src/tint/writer/glsl/generator_impl_variable_decl_statement_test.cc b/src/tint/writer/glsl/generator_impl_variable_decl_statement_test.cc index 5d95bc66cd..f8983cbd93 100644 --- a/src/tint/writer/glsl/generator_impl_variable_decl_statement_test.cc +++ b/src/tint/writer/glsl/generator_impl_variable_decl_statement_test.cc @@ -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")); diff --git a/src/tint/writer/glsl/generator_impl_workgroup_var_test.cc b/src/tint/writer/glsl/generator_impl_workgroup_var_test.cc index faa675dcde..1d96441e7e 100644 --- a/src/tint/writer/glsl/generator_impl_workgroup_var_test.cc +++ b/src/tint/writer/glsl/generator_impl_workgroup_var_test.cc @@ -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)}, { diff --git a/src/tint/writer/hlsl/generator_impl_array_accessor_test.cc b/src/tint/writer/hlsl/generator_impl_array_accessor_test.cc index bbdeb10fd1..dfa3d67087 100644 --- a/src/tint/writer/hlsl/generator_impl_array_accessor_test.cc +++ b/src/tint/writer/hlsl/generator_impl_array_accessor_test.cc @@ -22,7 +22,7 @@ namespace { using HlslGeneratorImplTest_Expression = TestHelper; TEST_F(HlslGeneratorImplTest_Expression, IndexAccessor) { - Global("ary", ty.array(), ast::StorageClass::kPrivate); + GlobalVar("ary", ty.array(), ast::StorageClass::kPrivate); auto* expr = IndexAccessor("ary", 5_i); WrapInFunction(expr); diff --git a/src/tint/writer/hlsl/generator_impl_binary_test.cc b/src/tint/writer/hlsl/generator_impl_binary_test.cc index 58255368bb..b5e47f79a4 100644 --- a/src/tint/writer/hlsl/generator_impl_binary_test.cc +++ b/src/tint/writer/hlsl/generator_impl_binary_test.cc @@ -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(), ast::StorageClass::kPrivate); + GlobalVar("mat", ty.mat3x3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("mat", ty.mat3x3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("mat", ty.mat3x3(), ast::StorageClass::kPrivate); auto* lhs = Expr("mat"); auto* rhs = vec3(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(), ast::StorageClass::kPrivate); + GlobalVar("mat", ty.mat3x3(), ast::StorageClass::kPrivate); auto* lhs = vec3(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(), ast::StorageClass::kPrivate); - Global("rhs", ty.mat3x3(), ast::StorageClass::kPrivate); + GlobalVar("lhs", ty.mat3x3(), ast::StorageClass::kPrivate); + GlobalVar("rhs", ty.mat3x3(), ast::StorageClass::kPrivate); auto* expr = create(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::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::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::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::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::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( diff --git a/src/tint/writer/hlsl/generator_impl_builtin_test.cc b/src/tint/writer/hlsl/generator_impl_builtin_test.cc index c497e515ad..d008ab8fac 100644 --- a/src/tint/writer/hlsl/generator_impl_builtin_test.cc +++ b/src/tint/writer/hlsl/generator_impl_builtin_test.cc @@ -152,13 +152,13 @@ using HlslBuiltinTest = TestParamHelper; TEST_P(HlslBuiltinTest, Emit) { auto param = GetParam(); - Global("f2", ty.vec2(), ast::StorageClass::kPrivate); - Global("f3", ty.vec3(), ast::StorageClass::kPrivate); - Global("u2", ty.vec2(), ast::StorageClass::kPrivate); - Global("i2", ty.vec2(), ast::StorageClass::kPrivate); - Global("b2", ty.vec2(), ast::StorageClass::kPrivate); - Global("m2x2", ty.mat2x2(), ast::StorageClass::kPrivate); - Global("m3x2", ty.mat3x2(), ast::StorageClass::kPrivate); + GlobalVar("f2", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("f3", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("u2", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("i2", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("b2", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("m2x2", ty.mat2x2(), ast::StorageClass::kPrivate); + GlobalVar("m3x2", ty.mat3x2(), 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(), ast::StorageClass::kPrivate); - Global("param2", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("param1", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("param2", ty.vec3(), 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(), ast::StorageClass::kPrivate); + GlobalVar("p1", ty.vec4(), 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(), ast::StorageClass::kPrivate); + GlobalVar("p1", ty.vec4(), 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(), ast::StorageClass::kPrivate); + GlobalVar("p1", ty.vec2(), 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(), ast::StorageClass::kPrivate); + GlobalVar("p1", ty.vec2(), 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(), ast::StorageClass::kPrivate); + GlobalVar("p1", ty.vec2(), 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(); diff --git a/src/tint/writer/hlsl/generator_impl_call_test.cc b/src/tint/writer/hlsl/generator_impl_call_test.cc index b72b0eb740..fc41a818f9 100644 --- a/src/tint/writer/hlsl/generator_impl_call_test.cc +++ b/src/tint/writer/hlsl/generator_impl_call_test.cc @@ -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); diff --git a/src/tint/writer/hlsl/generator_impl_function_test.cc b/src/tint/writer/hlsl/generator_impl_function_test.cc index d86820d90e..17b4ed4ead 100644 --- a/src/tint/writer/hlsl/generator_impl_function_test.cc +++ b/src/tint/writer/hlsl/generator_impl_function_test.cc @@ -346,11 +346,11 @@ tint_symbol_1 vert_main2() { TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) { auto* ubo_ty = Structure("UBO", {Member("coord", ty.vec4())}); - auto* ubo = Global("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, - ast::AttributeList{ - create(0), - create(1), - }); + auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(1), + }); Func("sub_func", { @@ -393,11 +393,11 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStruct) { auto* s = Structure("Uniforms", {Member("coord", ty.vec4())}); - Global("uniforms", ty.Of(s), ast::StorageClass::kUniform, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(1), + }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor(MemberAccessor("uniforms", "coord"), "x")); @@ -431,11 +431,11 @@ 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, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(1), + }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); @@ -467,11 +467,11 @@ 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, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(1), + }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); @@ -503,11 +503,11 @@ 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, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite, + ast::AttributeList{ + create(0), + create(1), + }); Func("frag_main", {}, ty.void_(), { @@ -537,11 +537,11 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf Member("b", ty.f32()), }); - Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(1), + }); Func("frag_main", {}, ty.void_(), { @@ -567,11 +567,11 @@ 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, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(1), + }); Func("sub_func", { @@ -613,11 +613,11 @@ 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, - ast::AttributeList{ - create(0), - create(1), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(1), + }); Func("sub_func", { @@ -863,11 +863,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); { auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("data", "d")); diff --git a/src/tint/writer/hlsl/generator_impl_identifier_test.cc b/src/tint/writer/hlsl/generator_impl_identifier_test.cc index d982e1e7df..d4b645f6bd 100644 --- a/src/tint/writer/hlsl/generator_impl_identifier_test.cc +++ b/src/tint/writer/hlsl/generator_impl_identifier_test.cc @@ -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); diff --git a/src/tint/writer/hlsl/generator_impl_if_test.cc b/src/tint/writer/hlsl/generator_impl_if_test.cc index 1668d71cb8..3195a06ca7 100644 --- a/src/tint/writer/hlsl/generator_impl_if_test.cc +++ b/src/tint/writer/hlsl/generator_impl_if_test.cc @@ -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"); diff --git a/src/tint/writer/hlsl/generator_impl_import_test.cc b/src/tint/writer/hlsl/generator_impl_import_test.cc index f7d544e49c..d6fdeac1d0 100644 --- a/src/tint/writer/hlsl/generator_impl_import_test.cc +++ b/src/tint/writer/hlsl/generator_impl_import_test.cc @@ -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(), ast::StorageClass::kPrivate); + GlobalVar("var", ty.mat3x3(), ast::StorageClass::kPrivate); auto* expr = Call("determinant", "var"); WrapInFunction(expr); diff --git a/src/tint/writer/hlsl/generator_impl_loop_test.cc b/src/tint/writer/hlsl/generator_impl_loop_test.cc index 29d182264d..9f288f6334 100644 --- a/src/tint/writer/hlsl/generator_impl_loop_test.cc +++ b/src/tint/writer/hlsl/generator_impl_loop_test.cc @@ -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()); 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())), // diff --git a/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc b/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc index ffa64fd158..3114174536 100644 --- a/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc @@ -91,11 +91,11 @@ class HlslGeneratorImplTest_MemberAccessorBase : public BASE { auto* s = b.Structure("Data", members); - b.Global("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - b.create(0), - b.create(1), - }); + b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + b.create(0), + b.create(1), + }); } void SetupFunction(ast::StatementList statements) { @@ -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)); diff --git a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc index 923b7126b2..a9f6617144 100644 --- a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc @@ -26,11 +26,11 @@ using HlslSanitizerTest = TestHelper; TEST_F(HlslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); Func("a_func", {}, ty.void_(), { @@ -64,11 +64,11 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { Member(0, "z", ty.f32()), Member(4, "a", ty.array(4)), }); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); Func("a_func", {}, ty.void_(), { @@ -100,11 +100,11 @@ void a_func() { TEST_F(HlslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); auto* p = Let("p", nullptr, AddressOf("b")); auto* p2 = Let("p2", nullptr, AddressOf(MemberAccessor(Deref(p), "a"))); @@ -140,16 +140,16 @@ void a_func() { TEST_F(HlslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); - Global("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(2), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); + GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(2), + create(2), + }); Func("a_func", {}, ty.void_(), { diff --git a/src/tint/writer/hlsl/generator_impl_switch_test.cc b/src/tint/writer/hlsl/generator_impl_switch_test.cc index 3ef1a7be88..7d89672118 100644 --- a/src/tint/writer/hlsl/generator_impl_switch_test.cc +++ b/src/tint/writer/hlsl/generator_impl_switch_test.cc @@ -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))))); diff --git a/src/tint/writer/hlsl/generator_impl_type_test.cc b/src/tint/writer/hlsl/generator_impl_type_test.cc index b99f06eddc..43825a980d 100644 --- a/src/tint/writer/hlsl/generator_impl_type_test.cc +++ b/src/tint/writer/hlsl/generator_impl_type_test.cc @@ -33,7 +33,7 @@ using HlslGeneratorImplTest_Type = TestHelper; TEST_F(HlslGeneratorImplTest_Type, EmitType_Array) { auto* arr = ty.array(); - 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(), 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(), 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(); - 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,11 +153,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); GeneratorImpl& gen = Build(); @@ -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,11 +287,11 @@ TEST_P(HlslDepthTexturesTest, Emit) { auto* t = ty.depth_texture(params.dim); - Global("tex", t, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("tex", t, + ast::AttributeList{ + create(1), + create(2), + }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, {Stage(ast::PipelineStage::kFragment)}); @@ -317,11 +317,11 @@ using HlslDepthMultisampledTexturesTest = TestHelper; TEST_F(HlslDepthMultisampledTexturesTest, Emit) { auto* t = ty.depth_multisampled_texture(ast::TextureDimension::k2d); - Global("tex", t, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("tex", t, + ast::AttributeList{ + create(1), + create(2), + }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, {Stage(ast::PipelineStage::kFragment)}); @@ -360,11 +360,11 @@ TEST_P(HlslSampledTexturesTest, Emit) { } auto* t = ty.sampled_texture(params.dim, datatype); - Global("tex", t, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("tex", t, + ast::AttributeList{ + create(1), + create(2), + }); Func("main", {}, ty.void_(), {CallStmt(Call("textureDimensions", "tex"))}, {Stage(ast::PipelineStage::kFragment)}); @@ -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)}); diff --git a/src/tint/writer/hlsl/generator_impl_unary_op_test.cc b/src/tint/writer/hlsl/generator_impl_unary_op_test.cc index c9abf1f250..74320ea7d1 100644 --- a/src/tint/writer/hlsl/generator_impl_unary_op_test.cc +++ b/src/tint/writer/hlsl/generator_impl_unary_op_test.cc @@ -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::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::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::UnaryOp::kAddressOf, Expr("G"))); auto* op = create(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::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::UnaryOp::kNegation, Expr("expr")); WrapInFunction(op); diff --git a/src/tint/writer/hlsl/generator_impl_variable_decl_statement_test.cc b/src/tint/writer/hlsl/generator_impl_variable_decl_statement_test.cc index 5ed85f3a74..3a857b7961 100644 --- a/src/tint/writer/hlsl/generator_impl_variable_decl_statement_test.cc +++ b/src/tint/writer/hlsl/generator_impl_variable_decl_statement_test.cc @@ -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")); diff --git a/src/tint/writer/hlsl/generator_impl_workgroup_var_test.cc b/src/tint/writer/hlsl/generator_impl_workgroup_var_test.cc index 826a545b68..5de44b1a06 100644 --- a/src/tint/writer/hlsl/generator_impl_workgroup_var_test.cc +++ b/src/tint/writer/hlsl/generator_impl_workgroup_var_test.cc @@ -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)}, { diff --git a/src/tint/writer/msl/generator_impl_array_accessor_test.cc b/src/tint/writer/msl/generator_impl_array_accessor_test.cc index 7475b6768a..bfa76dc4e8 100644 --- a/src/tint/writer/msl/generator_impl_array_accessor_test.cc +++ b/src/tint/writer/msl/generator_impl_array_accessor_test.cc @@ -34,7 +34,7 @@ TEST_F(MslGeneratorImplTest, IndexAccessor) { } TEST_F(MslGeneratorImplTest, IndexAccessor_OfDref) { - Global("ary", ty.array(), ast::StorageClass::kPrivate); + GlobalVar("ary", ty.array(), ast::StorageClass::kPrivate); auto* p = Let("p", nullptr, AddressOf("ary")); auto* expr = IndexAccessor(Deref("p"), 5_i); diff --git a/src/tint/writer/msl/generator_impl_builtin_test.cc b/src/tint/writer/msl/generator_impl_builtin_test.cc index bfe5548ba3..9f00be720c 100644 --- a/src/tint/writer/msl/generator_impl_builtin_test.cc +++ b/src/tint/writer/msl/generator_impl_builtin_test.cc @@ -171,15 +171,15 @@ using MslBuiltinTest = TestParamHelper; TEST_P(MslBuiltinTest, Emit) { auto param = GetParam(); - Global("f2", ty.vec2(), ast::StorageClass::kPrivate); - Global("f3", ty.vec3(), ast::StorageClass::kPrivate); - Global("f4", ty.vec4(), ast::StorageClass::kPrivate); - Global("u1", ty.u32(), ast::StorageClass::kPrivate); - Global("u2", ty.vec2(), ast::StorageClass::kPrivate); - Global("i2", ty.vec2(), ast::StorageClass::kPrivate); - Global("b2", ty.vec2(), ast::StorageClass::kPrivate); - Global("m2x2", ty.mat2x2(), ast::StorageClass::kPrivate); - Global("m3x2", ty.mat3x2(), ast::StorageClass::kPrivate); + GlobalVar("f2", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("f3", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("f4", ty.vec4(), ast::StorageClass::kPrivate); + GlobalVar("u1", ty.u32(), ast::StorageClass::kPrivate); + GlobalVar("u2", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("i2", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("b2", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("m2x2", ty.mat2x2(), ast::StorageClass::kPrivate); + GlobalVar("m3x2", ty.mat3x2(), 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(), ast::StorageClass::kPrivate); - Global("param2", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("param1", ty.vec2(), ast::StorageClass::kPrivate); + GlobalVar("param2", ty.vec2(), 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(), ast::StorageClass::kPrivate); + GlobalVar("p1", ty.vec2(), 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(), ast::StorageClass::kPrivate); + GlobalVar("v", ty.vec3(), ast::StorageClass::kPrivate); WrapInFunction(CallStmt(Call("dot", "v", "v"))); GeneratorImpl& gen = SanitizeAndBuild(); diff --git a/src/tint/writer/msl/generator_impl_call_test.cc b/src/tint/writer/msl/generator_impl_call_test.cc index 93c9b83036..c7f3a02fd8 100644 --- a/src/tint/writer/msl/generator_impl_call_test.cc +++ b/src/tint/writer/msl/generator_impl_call_test.cc @@ -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); diff --git a/src/tint/writer/msl/generator_impl_function_test.cc b/src/tint/writer/msl/generator_impl_function_test.cc index 4ef8b12a12..e3bfd7fa23 100644 --- a/src/tint/writer/msl/generator_impl_function_test.cc +++ b/src/tint/writer/msl/generator_impl_function_test.cc @@ -335,11 +335,11 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RW_StorageBu Member("b", ty.f32()), }); - Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); @@ -377,11 +377,11 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RO_StorageBu Member("b", ty.f32()), }); - Global("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("coord", "b")); @@ -415,11 +415,11 @@ 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())}); - auto* ubo = Global("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, - ast::AttributeList{ - create(0), - create(0), - }); + auto* ubo = GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, + ast::AttributeList{ + create(0), + create(0), + }); Func("sub_func", { @@ -469,11 +469,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); Func("sub_func", { @@ -524,11 +524,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); Func("sub_func", { @@ -665,11 +665,11 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); { auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("data", "d")); diff --git a/src/tint/writer/msl/generator_impl_import_test.cc b/src/tint/writer/msl/generator_impl_import_test.cc index de9353ea44..7b79569b17 100644 --- a/src/tint/writer/msl/generator_impl_import_test.cc +++ b/src/tint/writer/msl/generator_impl_import_test.cc @@ -234,7 +234,7 @@ INSTANTIATE_TEST_SUITE_P(MslGeneratorImplTest, MslImportData{"clamp", "clamp"})); TEST_F(MslGeneratorImplTest, MslImportData_Determinant) { - Global("var", ty.mat3x3(), ast::StorageClass::kPrivate); + GlobalVar("var", ty.mat3x3(), ast::StorageClass::kPrivate); auto* expr = Call("determinant", "var"); diff --git a/src/tint/writer/msl/generator_impl_loop_test.cc b/src/tint/writer/msl/generator_impl_loop_test.cc index 85f1debe03..50b69d0d7b 100644 --- a/src/tint/writer/msl/generator_impl_loop_test.cc +++ b/src/tint/writer/msl/generator_impl_loop_test.cc @@ -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()); 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(), ast::StorageClass::kWorkgroup); + GlobalVar("a", ty.atomic(), 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(), ast::StorageClass::kWorkgroup); + GlobalVar("a", ty.atomic(), 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(), ast::StorageClass::kWorkgroup); + GlobalVar("a", ty.atomic(), 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, // diff --git a/src/tint/writer/msl/generator_impl_member_accessor_test.cc b/src/tint/writer/msl/generator_impl_member_accessor_test.cc index c9f3da074a..96824a1752 100644 --- a/src/tint/writer/msl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/msl/generator_impl_member_accessor_test.cc @@ -20,8 +20,8 @@ namespace { using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitExpression_MemberAccessor) { - Global("str", ty.Of(Structure("my_str", {Member("mem", ty.f32())})), - ast::StorageClass::kPrivate); + 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(), ast::StorageClass::kPrivate); + GlobalVar("my_vec", ty.vec4(), 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(), ast::StorageClass::kPrivate); + GlobalVar("my_vec", ty.vec4(), ast::StorageClass::kPrivate); auto* expr = MemberAccessor("my_vec", "gbr"); WrapInFunction(expr); diff --git a/src/tint/writer/msl/generator_impl_sanitizer_test.cc b/src/tint/writer/msl/generator_impl_sanitizer_test.cc index 9b9f30b6e5..96e947322b 100644 --- a/src/tint/writer/msl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/msl/generator_impl_sanitizer_test.cc @@ -27,11 +27,11 @@ using MslSanitizerTest = TestHelper; TEST_F(MslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", {Member(0, "a", ty.array(4))}); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); Func("a_func", {}, ty.void_(), { @@ -85,11 +85,11 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { Member(0, "z", ty.f32()), Member(4, "a", ty.array(4)), }); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); Func("a_func", {}, ty.void_(), { @@ -142,11 +142,11 @@ 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(4))}); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); auto* p = Let("p", nullptr, AddressOf("b")); auto* p2 = Let("p2", nullptr, AddressOf(MemberAccessor(Deref(p), "a"))); @@ -202,16 +202,16 @@ 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(4))}); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(0), - }); - Global("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(2), - create(0), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(0), + }); + GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(2), + create(0), + }); Func("a_func", {}, ty.void_(), { @@ -267,16 +267,16 @@ 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(4))}); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(0), - }); - Global("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(2), - create(0), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(0), + }); + GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(2), + create(0), + }); Func("a_func", {}, ty.void_(), { diff --git a/src/tint/writer/msl/generator_impl_test.cc b/src/tint/writer/msl/generator_impl_test.cc index 914b6938f5..aec9bfbcc8 100644 --- a/src/tint/writer/msl/generator_impl_test.cc +++ b/src/tint/writer/msl/generator_impl_test.cc @@ -141,7 +141,7 @@ vertex Out vert_main() { } TEST_F(MslGeneratorImplTest, WorkgroupMatrix) { - Global("m", ty.mat2x2(), ast::StorageClass::kWorkgroup); + GlobalVar("m", ty.mat2x2(), 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(), 4_i), ast::StorageClass::kWorkgroup); + GlobalVar("m", ty.array(ty.mat2x2(), 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(), ast::StorageClass::kWorkgroup); - Global("m2", ty.mat2x3(), ast::StorageClass::kWorkgroup); - Global("m3", ty.mat2x4(), ast::StorageClass::kWorkgroup); - Global("m4", ty.mat3x2(), ast::StorageClass::kWorkgroup); - Global("m5", ty.mat3x3(), ast::StorageClass::kWorkgroup); - Global("m6", ty.mat3x4(), ast::StorageClass::kWorkgroup); - Global("m7", ty.mat4x2(), ast::StorageClass::kWorkgroup); - Global("m8", ty.mat4x3(), ast::StorageClass::kWorkgroup); - Global("m9", ty.mat4x4(), ast::StorageClass::kWorkgroup); + GlobalVar("m1", ty.mat2x2(), ast::StorageClass::kWorkgroup); + GlobalVar("m2", ty.mat2x3(), ast::StorageClass::kWorkgroup); + GlobalVar("m3", ty.mat2x4(), ast::StorageClass::kWorkgroup); + GlobalVar("m4", ty.mat3x2(), ast::StorageClass::kWorkgroup); + GlobalVar("m5", ty.mat3x3(), ast::StorageClass::kWorkgroup); + GlobalVar("m6", ty.mat3x4(), ast::StorageClass::kWorkgroup); + GlobalVar("m7", ty.mat4x2(), ast::StorageClass::kWorkgroup); + GlobalVar("m8", ty.mat4x3(), ast::StorageClass::kWorkgroup); + GlobalVar("m9", ty.mat4x4(), ast::StorageClass::kWorkgroup); Func("main1", {}, ty.void_(), { Decl(Let("a1", nullptr, Expr("m1"))), diff --git a/src/tint/writer/msl/generator_impl_type_test.cc b/src/tint/writer/msl/generator_impl_type_test.cc index b8ab89da7b..38a6ef7167 100644 --- a/src/tint/writer/msl/generator_impl_type_test.cc +++ b/src/tint/writer/msl/generator_impl_type_test.cc @@ -77,7 +77,7 @@ using MslGeneratorImplTest = TestHelper; TEST_F(MslGeneratorImplTest, EmitType_Array) { auto* arr = ty.array(); - 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(); 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(); 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(); - 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(); - Global("G", arr, ast::StorageClass::kPrivate); + GlobalVar("G", arr, ast::StorageClass::kPrivate); GeneratorImpl& gen = Build(); @@ -247,11 +247,11 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_NonComposites) { Member("z", ty.f32()), }); - Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); GeneratorImpl& gen = Build(); @@ -356,11 +356,11 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_Structures) { Member("e", ty.f32()), }); - Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); GeneratorImpl& gen = Build(); @@ -450,11 +450,11 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayDefaultStride) { Member("f", array_z), }); - Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); GeneratorImpl& gen = Build(); @@ -536,11 +536,11 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayVec3DefaultStride) { Member("c", ty.i32()), }); - Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); GeneratorImpl& gen = Build(); @@ -600,11 +600,11 @@ TEST_F(MslGeneratorImplTest, AttemptTintPadSymbolCollision) { Member("tint_pad_21", ty.f32()), }); - Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); GeneratorImpl& gen = Build(); @@ -661,11 +661,11 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_WithAttribute) { Member("b", ty.f32()), }); - Global("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); GeneratorImpl& gen = Build(); @@ -828,11 +828,11 @@ TEST_P(MslStorageTexturesTest, Emit) { auto params = GetParam(); auto* s = ty.storage_texture(params.dim, ast::TexelFormat::kR32Float, ast::Access::kWrite); - Global("test_var", s, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("test_var", s, + ast::AttributeList{ + create(0), + create(0), + }); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/msl/generator_impl_unary_op_test.cc b/src/tint/writer/msl/generator_impl_unary_op_test.cc index a1aecd9e64..843e2a4ac7 100644 --- a/src/tint/writer/msl/generator_impl_unary_op_test.cc +++ b/src/tint/writer/msl/generator_impl_unary_op_test.cc @@ -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::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::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::UnaryOp::kAddressOf, Expr("G"))); auto* op = create(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::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::UnaryOp::kNegation, Expr("expr")); WrapInFunction(op); diff --git a/src/tint/writer/msl/generator_impl_variable_decl_statement_test.cc b/src/tint/writer/msl/generator_impl_variable_decl_statement_test.cc index 5e932ba746..311d33c984 100644 --- a/src/tint/writer/msl/generator_impl_variable_decl_statement_test.cc +++ b/src/tint/writer/msl/generator_impl_variable_decl_statement_test.cc @@ -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")); diff --git a/src/tint/writer/spirv/builder_assign_test.cc b/src/tint/writer/spirv/builder_assign_test.cc index 71c958c50d..526ede8818 100644 --- a/src/tint/writer/spirv/builder_assign_test.cc +++ b/src/tint/writer/spirv/builder_assign_test.cc @@ -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(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("var", ty.vec3(), ast::StorageClass::kPrivate); auto* val = vec3(); 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(vec2(1_f, 2_f), 3_f); - auto* v = Global("var", ty.vec3(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("var", ty.vec3(), 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(1_f, 2_f, 3_f); - auto* v = Global("var", ty.vec3(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("var", ty.vec3(), 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(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("var", ty.vec3(), ast::StorageClass::kPrivate); auto* val = vec3(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(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("var", ty.vec3(), 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(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("var", ty.vec3(), ast::StorageClass::kPrivate); auto* assign = Assign(IndexAccessor("var", 1_i), Expr(1_f)); diff --git a/src/tint/writer/spirv/builder_binary_expression_test.cc b/src/tint/writer/spirv/builder_binary_expression_test.cc index 608cd1e320..443e78606f 100644 --- a/src/tint/writer/spirv/builder_binary_expression_test.cc +++ b/src/tint/writer/spirv/builder_binary_expression_test.cc @@ -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::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::BinaryOp::kLogicalOr, Expr("a"), Expr("b")); diff --git a/src/tint/writer/spirv/builder_builtin_test.cc b/src/tint/writer/spirv/builder_builtin_test.cc index 4f6dca8c98..36c152e370 100644 --- a/src/tint/writer/spirv/builder_builtin_test.cc +++ b/src/tint/writer/spirv/builder_builtin_test.cc @@ -41,7 +41,7 @@ inline std::ostream& operator<<(std::ostream& out, BuiltinData data) { using BuiltinBoolTest = BuiltinBuilderTestWithParam; 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(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), 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; 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(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), 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(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), 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(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), 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(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), 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(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), ast::StorageClass::kPrivate); auto* expr = Call("dot", "v", "v"); auto* func = Func("a_func", {}, ty.void_(), { @@ -336,7 +336,7 @@ OpReturn using BuiltinDeriveTest = BuiltinBuilderTestWithParam; 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(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("v", ty.vec3(), 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(), ast::StorageClass::kPrivate); + auto* v3 = GlobalVar("v3", ty.vec3(), ast::StorageClass::kPrivate); - auto* bool_v3 = Global("bool_v3", ty.vec3(), ast::StorageClass::kPrivate); + auto* bool_v3 = GlobalVar("bool_v3", ty.vec3(), ast::StorageClass::kPrivate); auto* expr = Call("select", "v3", "v3", "bool_v3"); auto* func = Func("a_func", {}, ty.void_(), { @@ -451,17 +451,17 @@ 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, - ast::AttributeList{ - create(0), - create(0), - }); + auto* tex = GlobalVar("texture", t, + ast::AttributeList{ + create(0), + create(0), + }); - auto* sampler = Global("sampler", s, - ast::AttributeList{ - create(1), - create(0), - }); + auto* sampler = GlobalVar("sampler", s, + ast::AttributeList{ + create(1), + create(0), + }); auto* expr1 = Call("textureSampleCompare", "texture", "sampler", vec2(1_f, 2_f), 2_f); auto* expr2 = Call("textureSampleCompare", "texture", "sampler", vec2(1_f, 2_f), 2_f); @@ -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(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("var", ty.mat3x3(), 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(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("var", ty.mat2x3(), ast::StorageClass::kPrivate); auto* expr = Call("transpose", "var"); auto* func = Func("a_func", {}, ty.void_(), { @@ -1585,11 +1585,11 @@ OpFunctionEnd TEST_F(BuiltinBuilderTest, Call_ArrayLength) { auto* s = Structure("my_struct", {Member("a", ty.array(4))}); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a"))); Func("a_func", {}, ty.void_(), @@ -1632,11 +1632,11 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_OtherMembersInStruct) { Member("z", ty.f32()), Member(4, "a", ty.array(4)), }); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a"))); Func("a_func", {}, ty.void_(), @@ -1676,11 +1676,11 @@ OpReturn TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", {Member("a", ty.array(4))}); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); auto* p = Let("p", nullptr, AddressOf("b")); auto* p2 = Let("p2", nullptr, AddressOf(MemberAccessor(Deref(p), "a"))); @@ -1736,11 +1736,11 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) { // arrayLength(&*p3); // } auto* s = Structure("my_struct", {Member("a", ty.array(4))}); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(1), + create(2), + }); auto* p = Let("p", nullptr, AddressOf(Deref(AddressOf("b")))); auto* p2 = Let("p2", nullptr, AddressOf(Deref(p))); @@ -1801,11 +1801,11 @@ TEST_F(BuiltinBuilderTest, Call_AtomicLoad) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(1), + create(2), + }); Func("a_func", {}, ty.void_(), ast::StatementList{ @@ -1865,11 +1865,11 @@ TEST_F(BuiltinBuilderTest, Call_AtomicStore) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(1), + create(2), + }); Func("a_func", {}, ty.void_(), ast::StatementList{ @@ -1937,11 +1937,11 @@ TEST_P(Builtin_Builtin_AtomicRMW_i32, Test) { auto* s = Structure("S", { Member("v", ty.atomic()), }); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(1), + create(2), + }); Func("a_func", {}, ty.void_(), ast::StatementList{ @@ -2010,11 +2010,11 @@ TEST_P(Builtin_Builtin_AtomicRMW_u32, Test) { auto* s = Structure("S", { Member("v", ty.atomic()), }); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(1), + create(2), + }); Func("a_func", {}, ty.void_(), ast::StatementList{ @@ -2085,11 +2085,11 @@ TEST_F(BuiltinBuilderTest, Call_AtomicExchange) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(1), + create(2), + }); Func("a_func", {}, ty.void_(), ast::StatementList{ @@ -2161,11 +2161,11 @@ TEST_F(BuiltinBuilderTest, Call_AtomicCompareExchangeWeak) { Member("u", ty.atomic()), Member("i", ty.atomic()), }); - Global("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(1), + create(2), + }); Func("a_func", {}, ty.void_(), ast::StatementList{ diff --git a/src/tint/writer/spirv/builder_constructor_expression_test.cc b/src/tint/writer/spirv/builder_constructor_expression_test.cc index bd8969e2f8..9f083476af 100644 --- a/src/tint/writer/spirv/builder_constructor_expression_test.cc +++ b/src/tint/writer/spirv/builder_constructor_expression_test.cc @@ -24,7 +24,7 @@ using SpvBuilderConstructorTest = TestHelper; TEST_F(SpvBuilderConstructorTest, Const) { auto* c = Expr(42.2_f); - auto* g = Global("g", ty.f32(), c, ast::StorageClass::kPrivate); + auto* g = GlobalVar("g", ty.f32(), c, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -1105,7 +1105,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_U32_With_F32) { TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec2_With_F32) { auto* cast = vec2(2_f); - auto* g = Global("g", ty.vec2(), cast, ast::StorageClass::kPrivate); + auto* g = GlobalVar("g", ty.vec2(), cast, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -1175,7 +1175,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec4) { TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_F32) { auto* cast = vec3(2_f); - auto* g = Global("g", ty.vec3(), cast, ast::StorageClass::kPrivate); + auto* g = GlobalVar("g", ty.vec3(), cast, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -1191,7 +1191,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_F32) { TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_F32_Vec2) { auto* cast = vec3(2_f, vec2(2_f, 2_f)); - auto* g = Global("g", ty.vec3(), cast, ast::StorageClass::kPrivate); + auto* g = GlobalVar("g", ty.vec3(), cast, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -1214,7 +1214,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_F32_Vec2) { TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_Vec2_F32) { auto* cast = vec3(vec2(2_f, 2_f), 2_f); - auto* g = Global("g", ty.vec3(), cast, ast::StorageClass::kPrivate); + auto* g = GlobalVar("g", ty.vec3(), cast, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -1237,7 +1237,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec3_With_Vec2_F32) { TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32) { auto* cast = vec4(2_f); - auto* g = Global("g", ty.vec4(), cast, ast::StorageClass::kPrivate); + auto* g = GlobalVar("g", ty.vec4(), cast, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -1253,7 +1253,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32) { TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_F32_Vec2) { auto* cast = vec4(2_f, 2_f, vec2(2_f, 2_f)); - auto* g = Global("g", ty.vec4(), cast, ast::StorageClass::kPrivate); + auto* g = GlobalVar("g", ty.vec4(), cast, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -1276,7 +1276,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_F32_Vec2) { TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_Vec2_F32) { auto* cast = vec4(2_f, vec2(2_f, 2_f), 2_f); - auto* g = Global("g", ty.vec4(), cast, ast::StorageClass::kPrivate); + auto* g = GlobalVar("g", ty.vec4(), cast, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -1299,7 +1299,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_Vec2_F32) { TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec2_F32_F32) { auto* cast = vec4(vec2(2_f, 2_f), 2_f, 2_f); - auto* g = Global("g", ty.vec4(), cast, ast::StorageClass::kPrivate); + auto* g = GlobalVar("g", ty.vec4(), cast, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -1322,7 +1322,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec2_F32_F32) { TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec2_Vec2) { auto* cast = vec4(vec2(2_f, 2_f), vec2(2_f, 2_f)); - auto* g = Global("g", ty.vec4(), cast, ast::StorageClass::kPrivate); + auto* g = GlobalVar("g", ty.vec4(), cast, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -1347,7 +1347,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec2_Vec2) { TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_Vec3) { auto* cast = vec4(2_f, vec3(2_f, 2_f, 2_f)); - auto* g = Global("g", ty.vec4(), cast, ast::StorageClass::kPrivate); + auto* g = GlobalVar("g", ty.vec4(), cast, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -1372,7 +1372,7 @@ TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_F32_Vec3) { TEST_F(SpvBuilderConstructorTest, Type_ModuleScope_Vec4_With_Vec3_F32) { auto* cast = vec4(vec3(2_f, 2_f, 2_f), 2_f); - auto* g = Global("g", ty.vec4(), cast, ast::StorageClass::kPrivate); + auto* g = GlobalVar("g", ty.vec4(), cast, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -1990,7 +1990,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_U32_To_F32) { } TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_I32) { - auto* var = Global("i", ty.vec3(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), ast::StorageClass::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -2016,7 +2016,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_I32) { } TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F32_to_I32) { - auto* var = Global("i", ty.vec3(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), ast::StorageClass::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -2042,7 +2042,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F32_to_I32) { } TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_U32) { - auto* var = Global("i", ty.vec3(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), ast::StorageClass::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -2068,7 +2068,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_U32) { } TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F32_to_U32) { - auto* var = Global("i", ty.vec3(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), ast::StorageClass::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -2094,7 +2094,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_F32_to_U32) { } TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_F32) { - auto* var = Global("i", ty.vec3(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), ast::StorageClass::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -2120,7 +2120,7 @@ TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_I32_to_F32) { } TEST_F(SpvBuilderConstructorTest, Type_Convert_Vectors_U32_to_F32) { - auto* var = Global("i", ty.vec3(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("i", ty.vec3(), ast::StorageClass::kPrivate); auto* cast = vec3("i"); WrapInFunction(cast); @@ -2208,9 +2208,9 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_VectorWithAllConstConstruct TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Vector_WithIdent) { // vec3(a, b, c) -> false - Global("a", ty.f32(), ast::StorageClass::kPrivate); - Global("b", ty.f32(), ast::StorageClass::kPrivate); - Global("c", ty.f32(), ast::StorageClass::kPrivate); + GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate); + GlobalVar("b", ty.f32(), ast::StorageClass::kPrivate); + GlobalVar("c", ty.f32(), ast::StorageClass::kPrivate); auto* t = vec3("a", "b", "c"); WrapInFunction(t); @@ -2280,8 +2280,8 @@ TEST_F(SpvBuilderConstructorTest, IsConstructorConst_Struct_WithIdentSubExpressi Member("b", ty.vec3()), }); - Global("a", ty.f32(), ast::StorageClass::kPrivate); - Global("b", ty.vec3(), ast::StorageClass::kPrivate); + GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate); + GlobalVar("b", ty.vec3(), ast::StorageClass::kPrivate); auto* t = Construct(ty.Of(s), "a", "b"); WrapInFunction(t); diff --git a/src/tint/writer/spirv/builder_function_test.cc b/src/tint/writer/spirv/builder_function_test.cc index b2744ef358..b374a6c9df 100644 --- a/src/tint/writer/spirv/builder_function_test.cc +++ b/src/tint/writer/spirv/builder_function_test.cc @@ -61,7 +61,7 @@ OpFunctionEnd } TEST_F(BuilderTest, Function_Terminator_ReturnValue) { - Global("a", ty.f32(), ast::StorageClass::kPrivate); + GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate); Func("a_func", {}, ty.f32(), {Return("a")}, {}); @@ -198,11 +198,11 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { auto* s = Structure("Data", {Member("d", ty.f32())}); - Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); { auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("data", "d")); diff --git a/src/tint/writer/spirv/builder_global_variable_test.cc b/src/tint/writer/spirv/builder_global_variable_test.cc index 577c9cf5d3..ca37315a0d 100644 --- a/src/tint/writer/spirv/builder_global_variable_test.cc +++ b/src/tint/writer/spirv/builder_global_variable_test.cc @@ -25,7 +25,7 @@ namespace { using BuilderTest = TestHelper; TEST_F(BuilderTest, GlobalVar_WithStorageClass) { - auto* v = Global("var", ty.f32(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("var", ty.f32(), ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -42,7 +42,7 @@ TEST_F(BuilderTest, GlobalVar_WithStorageClass) { TEST_F(BuilderTest, GlobalVar_WithConstructor) { auto* init = vec3(1_f, 1_f, 3_f); - auto* v = Global("var", ty.vec3(), ast::StorageClass::kPrivate, init); + auto* v = GlobalVar("var", ty.vec3(), ast::StorageClass::kPrivate, init); spirv::Builder& b = Build(); @@ -121,11 +121,11 @@ TEST_F(BuilderTest, GlobalVar_Complex_ConstructorNestedVector) { TEST_F(BuilderTest, GlobalVar_WithBindingAndGroup) { auto* v = - Global("var", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr, - ast::AttributeList{ - create(2), - create(3), - }); + GlobalVar("var", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr, + ast::AttributeList{ + create(2), + create(3), + }); spirv::Builder& b = Build(); @@ -365,11 +365,11 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { Member("b", ty.i32()), }); - Global("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); spirv::Builder& b = SanitizeAndBuild(); @@ -406,11 +406,11 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) { auto* A = Structure("A", {Member("a", ty.i32())}); auto* B = Alias("B", ty.Of(A)); - Global("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); spirv::Builder& b = SanitizeAndBuild(); @@ -445,11 +445,11 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) { auto* A = Structure("A", {Member("a", ty.i32())}); auto* B = Alias("B", ty.Of(A)); - Global("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); spirv::Builder& b = SanitizeAndBuild(); @@ -483,16 +483,16 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) { // var c : A auto* A = Structure("A", {Member("a", ty.i32())}); - Global("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); - Global("c", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(1), - create(0), - }); + GlobalVar("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); + GlobalVar("c", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(1), + create(0), + }); spirv::Builder& b = SanitizeAndBuild(); @@ -529,11 +529,11 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) { auto* type = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint, ast::Access::kWrite); - auto* var_a = Global("a", type, - ast::AttributeList{ - create(0), - create(0), - }); + auto* var_a = GlobalVar("a", type, + ast::AttributeList{ + create(0), + create(0), + }); spirv::Builder& b = Build(); @@ -560,19 +560,19 @@ TEST_F(BuilderTest, DISABLED_GlobalVar_TextureStorageWithDifferentAccess) { auto* type_a = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint, ast::Access::kReadWrite); - auto* var_a = Global("a", type_a, ast::StorageClass::kNone, - ast::AttributeList{ - create(0), - create(0), - }); + auto* var_a = GlobalVar("a", type_a, ast::StorageClass::kNone, + ast::AttributeList{ + create(0), + create(0), + }); auto* type_b = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint, ast::Access::kWrite); - auto* var_b = Global("b", type_b, ast::StorageClass::kNone, - ast::AttributeList{ - create(1), - create(0), - }); + auto* var_b = GlobalVar("b", type_b, ast::StorageClass::kNone, + ast::AttributeList{ + create(1), + create(0), + }); spirv::Builder& b = Build(); @@ -599,16 +599,16 @@ OpDecorate %5 DescriptorSet 0 TEST_F(BuilderTest, GlobalVar_WorkgroupWithZeroInit) { auto* type_scalar = ty.i32(); - auto* var_scalar = Global("a", type_scalar, ast::StorageClass::kWorkgroup); + auto* var_scalar = GlobalVar("a", type_scalar, ast::StorageClass::kWorkgroup); auto* type_array = ty.array(); - auto* var_array = Global("b", type_array, ast::StorageClass::kWorkgroup); + auto* var_array = GlobalVar("b", type_array, ast::StorageClass::kWorkgroup); auto* type_struct = Structure("C", { Member("a", ty.i32()), Member("b", ty.i32()), }); - auto* var_struct = Global("c", ty.Of(type_struct), ast::StorageClass::kWorkgroup); + auto* var_struct = GlobalVar("c", ty.Of(type_struct), ast::StorageClass::kWorkgroup); program = std::make_unique(std::move(*this)); diff --git a/src/tint/writer/spirv/builder_ident_expression_test.cc b/src/tint/writer/spirv/builder_ident_expression_test.cc index 591af2fad7..37d0fd118b 100644 --- a/src/tint/writer/spirv/builder_ident_expression_test.cc +++ b/src/tint/writer/spirv/builder_ident_expression_test.cc @@ -46,7 +46,7 @@ TEST_F(BuilderTest, IdentifierExpression_GlobalConst) { } TEST_F(BuilderTest, IdentifierExpression_GlobalVar) { - auto* v = Global("var", ty.f32(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("var", ty.f32(), ast::StorageClass::kPrivate); auto* expr = Expr("var"); WrapInFunction(expr); @@ -114,7 +114,7 @@ TEST_F(BuilderTest, IdentifierExpression_FunctionVar) { } TEST_F(BuilderTest, IdentifierExpression_Load) { - auto* var = Global("var", ty.i32(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("var", ty.i32(), ast::StorageClass::kPrivate); auto* expr = Add("var", "var"); WrapInFunction(expr); diff --git a/src/tint/writer/spirv/builder_if_test.cc b/src/tint/writer/spirv/builder_if_test.cc index 8c7c8eef0f..391be43938 100644 --- a/src/tint/writer/spirv/builder_if_test.cc +++ b/src/tint/writer/spirv/builder_if_test.cc @@ -68,7 +68,7 @@ TEST_F(BuilderTest, If_WithStatements) { // v = 2; // } - auto* var = Global("v", ty.i32(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate); auto* body = Block(Assign("v", 2_i)); auto* expr = If(true, body); WrapInFunction(expr); @@ -104,7 +104,7 @@ TEST_F(BuilderTest, If_WithElse) { // v = 3i; // } - auto* var = Global("v", ty.i32(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate); auto* body = Block(Assign("v", 2_i)); auto* else_body = Block(Assign("v", 3_i)); @@ -146,7 +146,7 @@ TEST_F(BuilderTest, If_WithElseIf) { // v = 3i; // } - auto* var = Global("v", ty.i32(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate); auto* body = Block(Assign("v", 2_i)); auto* else_body = Block(Assign("v", 3_i)); @@ -197,7 +197,7 @@ TEST_F(BuilderTest, If_WithMultiple) { // v = 5i; // } - auto* var = Global("v", ty.i32(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate); auto* body = Block(Assign("v", 2_i)); auto* elseif_1_body = Block(Assign("v", 3_i)); auto* elseif_2_body = Block(Assign("v", 4_i)); @@ -559,7 +559,7 @@ TEST_F(BuilderTest, If_WithLoad_Bug327) { // if (a) { // } - auto* var = Global("a", ty.bool_(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("a", ty.bool_(), ast::StorageClass::kPrivate); auto* fn = Func("f", {}, ty.void_(), {If("a", Block())}); spirv::Builder& b = Build(); diff --git a/src/tint/writer/spirv/builder_loop_test.cc b/src/tint/writer/spirv/builder_loop_test.cc index b4c2baa5e5..ae9e408f9d 100644 --- a/src/tint/writer/spirv/builder_loop_test.cc +++ b/src/tint/writer/spirv/builder_loop_test.cc @@ -54,7 +54,7 @@ TEST_F(BuilderTest, Loop_WithoutContinuing) { // break; // } - auto* var = Global("v", ty.i32(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate); auto* body = Block(Assign("v", 2_i), // Break()); @@ -96,7 +96,7 @@ TEST_F(BuilderTest, Loop_WithContinuing) { // } // } - auto* var = Global("v", ty.i32(), ast::StorageClass::kPrivate); + auto* var = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate); auto* body = Block(Assign("v", 2_i), // Break()); auto* continuing = Block(Assign("v", 3_i)); diff --git a/src/tint/writer/spirv/builder_switch_test.cc b/src/tint/writer/spirv/builder_switch_test.cc index 7ddd1bdac8..3c905b6a54 100644 --- a/src/tint/writer/spirv/builder_switch_test.cc +++ b/src/tint/writer/spirv/builder_switch_test.cc @@ -57,8 +57,8 @@ TEST_F(BuilderTest, Switch_WithCase) { // default: {} // } - auto* v = Global("v", ty.i32(), ast::StorageClass::kPrivate); - auto* a = Global("a", ty.i32(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate); + auto* a = GlobalVar("a", ty.i32(), ast::StorageClass::kPrivate); auto* func = Func("a_func", {}, ty.void_(), { @@ -114,8 +114,8 @@ TEST_F(BuilderTest, Switch_WithCase_Unsigned) { // default: {} // } - auto* v = Global("v", ty.i32(), ast::StorageClass::kPrivate); - auto* a = Global("a", ty.u32(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate); + auto* a = GlobalVar("a", ty.u32(), ast::StorageClass::kPrivate); auto* func = Func("a_func", {}, ty.void_(), { @@ -171,8 +171,8 @@ TEST_F(BuilderTest, Switch_WithDefault) { // v = 1i; // } - auto* v = Global("v", ty.i32(), ast::StorageClass::kPrivate); - auto* a = Global("a", ty.i32(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate); + auto* a = GlobalVar("a", ty.i32(), ast::StorageClass::kPrivate); auto* func = Func("a_func", {}, ty.void_(), { @@ -221,8 +221,8 @@ TEST_F(BuilderTest, Switch_WithCaseAndDefault) { // v = 3i; // } - auto* v = Global("v", ty.i32(), ast::StorageClass::kPrivate); - auto* a = Global("a", ty.i32(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate); + auto* a = GlobalVar("a", ty.i32(), ast::StorageClass::kPrivate); auto* func = Func("a_func", {}, ty.void_(), { @@ -284,8 +284,8 @@ TEST_F(BuilderTest, Switch_CaseWithFallthrough) { // v = 3i; // } - auto* v = Global("v", ty.i32(), ast::StorageClass::kPrivate); - auto* a = Global("a", ty.i32(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate); + auto* a = GlobalVar("a", ty.i32(), ast::StorageClass::kPrivate); auto* func = Func("a_func", {}, ty.void_(), { @@ -346,8 +346,8 @@ TEST_F(BuilderTest, Switch_WithNestedBreak) { // default: {} // } - auto* v = Global("v", ty.i32(), ast::StorageClass::kPrivate); - auto* a = Global("a", ty.i32(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("v", ty.i32(), ast::StorageClass::kPrivate); + auto* a = GlobalVar("a", ty.i32(), ast::StorageClass::kPrivate); auto* func = Func("a_func", {}, ty.void_(), { diff --git a/src/tint/writer/spirv/builder_type_test.cc b/src/tint/writer/spirv/builder_type_test.cc index 8dc048e998..44d6374b84 100644 --- a/src/tint/writer/spirv/builder_type_test.cc +++ b/src/tint/writer/spirv/builder_type_test.cc @@ -28,11 +28,11 @@ using BuilderTest_Type = TestHelper; TEST_F(BuilderTest_Type, GenerateRuntimeArray) { auto* ary = ty.array(ty.i32()); auto* str = Structure("S", {Member("x", ary)}); - Global("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); spirv::Builder& b = Build(); @@ -48,11 +48,11 @@ TEST_F(BuilderTest_Type, GenerateRuntimeArray) { TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) { auto* ary = ty.array(ty.i32()); auto* str = Structure("S", {Member("x", ary)}); - Global("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); spirv::Builder& b = Build(); @@ -67,7 +67,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) { TEST_F(BuilderTest_Type, GenerateArray) { auto* ary = ty.array(ty.i32(), 4_u); - Global("a", ary, ast::StorageClass::kPrivate); + GlobalVar("a", ary, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -84,7 +84,7 @@ TEST_F(BuilderTest_Type, GenerateArray) { TEST_F(BuilderTest_Type, GenerateArray_WithStride) { auto* ary = ty.array(ty.i32(), 4_u, 16u); - Global("a", ary, ast::StorageClass::kPrivate); + GlobalVar("a", ary, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -104,7 +104,7 @@ TEST_F(BuilderTest_Type, GenerateArray_WithStride) { TEST_F(BuilderTest_Type, ReturnsGeneratedArray) { auto* ary = ty.array(ty.i32(), 4_u); - Global("a", ary, ast::StorageClass::kPrivate); + GlobalVar("a", ary, ast::StorageClass::kPrivate); spirv::Builder& b = Build(); @@ -781,11 +781,11 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) { auto* s = ty.storage_texture(ast::TextureDimension::k1d, ast::TexelFormat::kR32Float, ast::Access::kWrite); - Global("test_var", s, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("test_var", s, + ast::AttributeList{ + create(0), + create(0), + }); spirv::Builder& b = Build(); @@ -800,11 +800,11 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) { auto* s = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float, ast::Access::kWrite); - Global("test_var", s, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("test_var", s, + ast::AttributeList{ + create(0), + create(0), + }); spirv::Builder& b = Build(); @@ -819,11 +819,11 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) { auto* s = ty.storage_texture(ast::TextureDimension::k2dArray, ast::TexelFormat::kR32Float, ast::Access::kWrite); - Global("test_var", s, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("test_var", s, + ast::AttributeList{ + create(0), + create(0), + }); spirv::Builder& b = Build(); @@ -838,11 +838,11 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) { auto* s = ty.storage_texture(ast::TextureDimension::k3d, ast::TexelFormat::kR32Float, ast::Access::kWrite); - Global("test_var", s, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("test_var", s, + ast::AttributeList{ + create(0), + create(0), + }); spirv::Builder& b = Build(); @@ -857,11 +857,11 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32floa auto* s = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float, ast::Access::kWrite); - Global("test_var", s, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("test_var", s, + ast::AttributeList{ + create(0), + create(0), + }); spirv::Builder& b = Build(); @@ -876,11 +876,11 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint) auto* s = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Sint, ast::Access::kWrite); - Global("test_var", s, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("test_var", s, + ast::AttributeList{ + create(0), + create(0), + }); spirv::Builder& b = Build(); @@ -895,11 +895,11 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeUint_Format_r32uint) auto* s = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint, ast::Access::kWrite); - Global("test_var", s, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("test_var", s, + ast::AttributeList{ + create(0), + create(0), + }); spirv::Builder& b = Build(); diff --git a/src/tint/writer/wgsl/generator_impl_array_accessor_test.cc b/src/tint/writer/wgsl/generator_impl_array_accessor_test.cc index 2b4e8b4334..d5f7f9fcb5 100644 --- a/src/tint/writer/wgsl/generator_impl_array_accessor_test.cc +++ b/src/tint/writer/wgsl/generator_impl_array_accessor_test.cc @@ -22,7 +22,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, IndexAccessor) { - Global("ary", ty.array(), ast::StorageClass::kPrivate); + GlobalVar("ary", ty.array(), ast::StorageClass::kPrivate); auto* expr = IndexAccessor("ary", 5_i); WrapInFunction(expr); @@ -34,7 +34,7 @@ TEST_F(WgslGeneratorImplTest, IndexAccessor) { } TEST_F(WgslGeneratorImplTest, IndexAccessor_OfDref) { - Global("ary", ty.array(), ast::StorageClass::kPrivate); + GlobalVar("ary", ty.array(), ast::StorageClass::kPrivate); auto* p = Let("p", nullptr, AddressOf("ary")); auto* expr = IndexAccessor(Deref("p"), 5_i); diff --git a/src/tint/writer/wgsl/generator_impl_assign_test.cc b/src/tint/writer/wgsl/generator_impl_assign_test.cc index 8d5e75efa1..e390d2f300 100644 --- a/src/tint/writer/wgsl/generator_impl_assign_test.cc +++ b/src/tint/writer/wgsl/generator_impl_assign_test.cc @@ -20,8 +20,8 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Assign) { - auto* lhs = Global("lhs", ty.i32(), ast::StorageClass::kPrivate); - auto* rhs = Global("rhs", ty.i32(), ast::StorageClass::kPrivate); + auto* lhs = GlobalVar("lhs", ty.i32(), ast::StorageClass::kPrivate); + auto* rhs = GlobalVar("rhs", ty.i32(), ast::StorageClass::kPrivate); auto* assign = Assign(lhs, rhs); WrapInFunction(assign); diff --git a/src/tint/writer/wgsl/generator_impl_binary_test.cc b/src/tint/writer/wgsl/generator_impl_binary_test.cc index acc4180755..682c001722 100644 --- a/src/tint/writer/wgsl/generator_impl_binary_test.cc +++ b/src/tint/writer/wgsl/generator_impl_binary_test.cc @@ -37,8 +37,8 @@ TEST_P(WgslBinaryTest, Emit) { } }; - Global("left", op_ty(), ast::StorageClass::kPrivate); - Global("right", op_ty(), ast::StorageClass::kPrivate); + GlobalVar("left", op_ty(), ast::StorageClass::kPrivate); + GlobalVar("right", op_ty(), ast::StorageClass::kPrivate); auto* left = Expr("left"); auto* right = Expr("right"); diff --git a/src/tint/writer/wgsl/generator_impl_call_test.cc b/src/tint/writer/wgsl/generator_impl_call_test.cc index 6a7e077436..24f7e4b195 100644 --- a/src/tint/writer/wgsl/generator_impl_call_test.cc +++ b/src/tint/writer/wgsl/generator_impl_call_test.cc @@ -42,8 +42,8 @@ TEST_F(WgslGeneratorImplTest, 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(WgslGeneratorImplTest, 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); diff --git a/src/tint/writer/wgsl/generator_impl_function_test.cc b/src/tint/writer/wgsl/generator_impl_function_test.cc index 53d0edae98..f21e71bc15 100644 --- a/src/tint/writer/wgsl/generator_impl_function_test.cc +++ b/src/tint/writer/wgsl/generator_impl_function_test.cc @@ -160,11 +160,11 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_Module auto* s = Structure("Data", {Member("d", ty.f32())}); - Global("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); { auto* var = Var("v", ty.f32(), ast::StorageClass::kNone, MemberAccessor("data", "d")); diff --git a/src/tint/writer/wgsl/generator_impl_global_decl_test.cc b/src/tint/writer/wgsl/generator_impl_global_decl_test.cc index 8f6d4f0ee9..dfad2a957c 100644 --- a/src/tint/writer/wgsl/generator_impl_global_decl_test.cc +++ b/src/tint/writer/wgsl/generator_impl_global_decl_test.cc @@ -28,7 +28,7 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalDeclAfterFunction) { auto* func_var = Var("a", ty.f32()); WrapInFunction(func_var); - Global("a", ty.f32(), ast::StorageClass::kPrivate); + GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate); GeneratorImpl& gen = Build(); @@ -45,7 +45,7 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalDeclAfterFunction) { } TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) { - Global("a0", ty.f32(), ast::StorageClass::kPrivate); + GlobalVar("a0", ty.f32(), ast::StorageClass::kPrivate); auto* s0 = Structure("S0", {Member("a", ty.i32())}); @@ -55,7 +55,7 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) { }, {}); - Global("a1", ty.f32(), ast::StorageClass::kPrivate); + GlobalVar("a1", ty.f32(), ast::StorageClass::kPrivate); auto* s1 = Structure("S1", {Member("a", ty.i32())}); @@ -101,11 +101,11 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) { } TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) { - Global("s", ty.sampler(ast::SamplerKind::kSampler), - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), + ast::AttributeList{ + create(0), + create(0), + }); GeneratorImpl& gen = Build(); @@ -117,11 +117,11 @@ TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) { TEST_F(WgslGeneratorImplTest, Emit_Global_Texture) { auto* st = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32()); - Global("t", st, - ast::AttributeList{ - create(0), - create(0), - }); + GlobalVar("t", st, + ast::AttributeList{ + create(0), + create(0), + }); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/wgsl/generator_impl_identifier_test.cc b/src/tint/writer/wgsl/generator_impl_identifier_test.cc index c6bccf671a..2e20d4c71a 100644 --- a/src/tint/writer/wgsl/generator_impl_identifier_test.cc +++ b/src/tint/writer/wgsl/generator_impl_identifier_test.cc @@ -20,7 +20,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitIdentifierExpression_Single) { - Global("glsl", ty.f32(), ast::StorageClass::kPrivate); + GlobalVar("glsl", ty.f32(), ast::StorageClass::kPrivate); auto* i = Expr("glsl"); WrapInFunction(i); diff --git a/src/tint/writer/wgsl/generator_impl_if_test.cc b/src/tint/writer/wgsl/generator_impl_if_test.cc index 18c0ffddc4..88f6aba053 100644 --- a/src/tint/writer/wgsl/generator_impl_if_test.cc +++ b/src/tint/writer/wgsl/generator_impl_if_test.cc @@ -20,7 +20,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_If) { - Global("cond", ty.bool_(), ast::StorageClass::kPrivate); + GlobalVar("cond", ty.bool_(), ast::StorageClass::kPrivate); auto* cond = Expr("cond"); auto* body = Block(Return()); @@ -39,8 +39,8 @@ TEST_F(WgslGeneratorImplTest, Emit_If) { } TEST_F(WgslGeneratorImplTest, 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()); @@ -64,7 +64,7 @@ TEST_F(WgslGeneratorImplTest, Emit_IfWithElseIf) { } TEST_F(WgslGeneratorImplTest, Emit_IfWithElse) { - Global("cond", ty.bool_(), ast::StorageClass::kPrivate); + GlobalVar("cond", ty.bool_(), ast::StorageClass::kPrivate); auto* else_body = Block(Return()); @@ -87,8 +87,8 @@ TEST_F(WgslGeneratorImplTest, Emit_IfWithElse) { } TEST_F(WgslGeneratorImplTest, 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"); diff --git a/src/tint/writer/wgsl/generator_impl_loop_test.cc b/src/tint/writer/wgsl/generator_impl_loop_test.cc index 3dbae60855..3570957dd3 100644 --- a/src/tint/writer/wgsl/generator_impl_loop_test.cc +++ b/src/tint/writer/wgsl/generator_impl_loop_test.cc @@ -68,7 +68,7 @@ TEST_F(WgslGeneratorImplTest, Emit_ForLoopWithMultiStmtInit) { // for({ignore(1i); ignore(2i);}; ; ) { // return; // } - Global("a", ty.atomic(), ast::StorageClass::kWorkgroup); + GlobalVar("a", ty.atomic(), ast::StorageClass::kWorkgroup); auto* multi_stmt = Block(Ignore(1_i), Ignore(2_i)); auto* f = For(multi_stmt, nullptr, nullptr, Block(Return())); WrapInFunction(f); @@ -132,7 +132,7 @@ TEST_F(WgslGeneratorImplTest, Emit_ForLoopWithMultiStmtCont) { // return; // } - Global("a", ty.atomic(), ast::StorageClass::kWorkgroup); + GlobalVar("a", ty.atomic(), ast::StorageClass::kWorkgroup); auto* multi_stmt = Block(Ignore(1_i), Ignore(2_i)); auto* f = For(nullptr, nullptr, multi_stmt, Block(Return())); WrapInFunction(f); @@ -175,7 +175,7 @@ TEST_F(WgslGeneratorImplTest, Emit_ForLoopWithMultiStmtInitCondCont) { // for({ ignore(1i); ignore(2i); }; true; { ignore(3i); ignore(4i); }) { // return; // } - Global("a", ty.atomic(), ast::StorageClass::kWorkgroup); + GlobalVar("a", ty.atomic(), ast::StorageClass::kWorkgroup); auto* multi_stmt_a = Block(Ignore(1_i), Ignore(2_i)); auto* multi_stmt_b = Block(Ignore(3_i), Ignore(4_i)); auto* f = For(multi_stmt_a, Expr(true), multi_stmt_b, Block(Return())); diff --git a/src/tint/writer/wgsl/generator_impl_member_accessor_test.cc b/src/tint/writer/wgsl/generator_impl_member_accessor_test.cc index d8bd3495f1..34760bacea 100644 --- a/src/tint/writer/wgsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/wgsl/generator_impl_member_accessor_test.cc @@ -21,7 +21,7 @@ using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, 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(expr); @@ -35,7 +35,7 @@ TEST_F(WgslGeneratorImplTest, EmitExpression_MemberAccessor) { TEST_F(WgslGeneratorImplTest, EmitExpression_MemberAccessor_OfDref) { 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* p = Let("p", nullptr, AddressOf("str")); auto* expr = MemberAccessor(Deref("p"), "mem"); diff --git a/src/tint/writer/wgsl/generator_impl_switch_test.cc b/src/tint/writer/wgsl/generator_impl_switch_test.cc index 11424f0f83..141a5d7af9 100644 --- a/src/tint/writer/wgsl/generator_impl_switch_test.cc +++ b/src/tint/writer/wgsl/generator_impl_switch_test.cc @@ -22,7 +22,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, Emit_Switch) { - Global("cond", ty.i32(), ast::StorageClass::kPrivate); + GlobalVar("cond", ty.i32(), ast::StorageClass::kPrivate); auto* def_body = Block(create()); auto* def = create(ast::CaseSelectorList{}, def_body); diff --git a/src/tint/writer/wgsl/generator_impl_type_test.cc b/src/tint/writer/wgsl/generator_impl_type_test.cc index 0973ffadad..108e0d5196 100644 --- a/src/tint/writer/wgsl/generator_impl_type_test.cc +++ b/src/tint/writer/wgsl/generator_impl_type_test.cc @@ -420,11 +420,11 @@ TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) { auto param = GetParam(); auto* t = ty.storage_texture(param.dim, param.fmt, param.access); - Global("g", t, - ast::AttributeList{ - create(1), - create(2), - }); + GlobalVar("g", t, + ast::AttributeList{ + create(1), + create(2), + }); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/wgsl/generator_impl_unary_op_test.cc b/src/tint/writer/wgsl/generator_impl_unary_op_test.cc index 2c46b44621..b741dc80f0 100644 --- a/src/tint/writer/wgsl/generator_impl_unary_op_test.cc +++ b/src/tint/writer/wgsl/generator_impl_unary_op_test.cc @@ -20,7 +20,7 @@ namespace { using WgslUnaryOpTest = TestHelper; TEST_F(WgslUnaryOpTest, AddressOf) { - Global("expr", ty.f32(), ast::StorageClass::kPrivate); + GlobalVar("expr", ty.f32(), ast::StorageClass::kPrivate); auto* op = create(ast::UnaryOp::kAddressOf, Expr("expr")); WrapInFunction(op); @@ -32,7 +32,7 @@ TEST_F(WgslUnaryOpTest, AddressOf) { } TEST_F(WgslUnaryOpTest, Complement) { - Global("expr", ty.u32(), ast::StorageClass::kPrivate); + GlobalVar("expr", ty.u32(), ast::StorageClass::kPrivate); auto* op = create(ast::UnaryOp::kComplement, Expr("expr")); WrapInFunction(op); @@ -44,7 +44,7 @@ TEST_F(WgslUnaryOpTest, Complement) { } TEST_F(WgslUnaryOpTest, Indirection) { - Global("G", ty.f32(), ast::StorageClass::kPrivate); + GlobalVar("G", ty.f32(), ast::StorageClass::kPrivate); auto* p = Let("expr", nullptr, create(ast::UnaryOp::kAddressOf, Expr("G"))); auto* op = create(ast::UnaryOp::kIndirection, Expr("expr")); @@ -58,7 +58,7 @@ TEST_F(WgslUnaryOpTest, Indirection) { } TEST_F(WgslUnaryOpTest, Not) { - Global("expr", ty.bool_(), ast::StorageClass::kPrivate); + GlobalVar("expr", ty.bool_(), ast::StorageClass::kPrivate); auto* op = create(ast::UnaryOp::kNot, Expr("expr")); WrapInFunction(op); @@ -70,7 +70,7 @@ TEST_F(WgslUnaryOpTest, Not) { } TEST_F(WgslUnaryOpTest, Negation) { - Global("expr", ty.i32(), ast::StorageClass::kPrivate); + GlobalVar("expr", ty.i32(), ast::StorageClass::kPrivate); auto* op = create(ast::UnaryOp::kNegation, Expr("expr")); WrapInFunction(op); diff --git a/src/tint/writer/wgsl/generator_impl_variable_test.cc b/src/tint/writer/wgsl/generator_impl_variable_test.cc index 83af7c25ea..9a8775d9e6 100644 --- a/src/tint/writer/wgsl/generator_impl_variable_test.cc +++ b/src/tint/writer/wgsl/generator_impl_variable_test.cc @@ -22,7 +22,7 @@ namespace { using WgslGeneratorImplTest = TestHelper; TEST_F(WgslGeneratorImplTest, EmitVariable) { - auto* v = Global("a", ty.f32(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate); GeneratorImpl& gen = Build(); @@ -32,7 +32,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable) { } TEST_F(WgslGeneratorImplTest, EmitVariable_StorageClass) { - auto* v = Global("a", ty.f32(), ast::StorageClass::kPrivate); + auto* v = GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate); GeneratorImpl& gen = Build(); @@ -43,11 +43,11 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_StorageClass) { TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Read) { auto* s = Structure("S", {Member("a", ty.i32())}); - auto* v = Global("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - ast::AttributeList{ - create(0), - create(0), - }); + auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, + ast::AttributeList{ + create(0), + create(0), + }); GeneratorImpl& gen = Build(); @@ -58,11 +58,11 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Read) { TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Write) { auto* s = Structure("S", {Member("a", ty.i32())}); - auto* v = Global("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite, - ast::AttributeList{ - create(0), - create(0), - }); + auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kWrite, + ast::AttributeList{ + create(0), + create(0), + }); GeneratorImpl& gen = Build(); @@ -73,11 +73,11 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Write) { TEST_F(WgslGeneratorImplTest, EmitVariable_Access_ReadWrite) { auto* s = Structure("S", {Member("a", ty.i32())}); - auto* v = Global("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - ast::AttributeList{ - create(0), - create(0), - }); + auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, + ast::AttributeList{ + create(0), + create(0), + }); GeneratorImpl& gen = Build(); @@ -87,11 +87,12 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_ReadWrite) { } TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) { - auto* v = Global("a", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr, - ast::AttributeList{ - create(1), - create(2), - }); + auto* v = + GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler), ast::StorageClass::kNone, nullptr, + ast::AttributeList{ + create(1), + create(2), + }); GeneratorImpl& gen = Build(); @@ -101,7 +102,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) { } TEST_F(WgslGeneratorImplTest, EmitVariable_Constructor) { - auto* v = Global("a", ty.f32(), ast::StorageClass::kPrivate, Expr(1_f)); + auto* v = GlobalVar("a", ty.f32(), ast::StorageClass::kPrivate, Expr(1_f)); GeneratorImpl& gen = Build();