From be4c9f48aaef9f2144a654a847b76a6a0050ec5b Mon Sep 17 00:00:00 2001 From: dan sinclair Date: Mon, 29 Aug 2022 21:22:31 +0000 Subject: [PATCH] Convert @group to an expression This CL updates the group attribute to store an expression instead of a single value. The parser always produces an IntLiteralExpression at the moment. Bug: tint:1633 Change-Id: Ice05c26d652c7f5c21825f745f270e96e3d88e08 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100441 Reviewed-by: Ben Clayton Commit-Queue: Dan Sinclair Kokoro: Kokoro --- src/tint/ast/builtin_texture_helper_test.cc | 4 +- src/tint/ast/group_attribute.cc | 8 ++- src/tint/ast/group_attribute.h | 9 +-- src/tint/ast/group_attribute_test.cc | 5 +- src/tint/ast/variable_test.cc | 4 +- src/tint/inspector/test_inspector_builder.cc | 12 ++-- src/tint/program_builder.h | 14 ++-- src/tint/reader/spirv/parser_impl.cc | 2 +- src/tint/reader/wgsl/parser_impl.cc | 4 +- .../parser_impl_variable_attribute_test.cc | 12 +++- .../resolver/assignment_validation_test.cc | 22 +++--- src/tint/resolver/atomics_test.cc | 2 +- src/tint/resolver/atomics_validation_test.cc | 14 ++-- .../resolver/attribute_validation_test.cc | 21 +++--- src/tint/resolver/builtin_test.cc | 4 +- .../compound_assignment_validation_test.cc | 2 +- .../host_shareable_validation_test.cc | 10 +-- .../increment_decrement_validation_test.cc | 2 +- src/tint/resolver/ptr_ref_test.cc | 4 +- src/tint/resolver/ptr_ref_validation_test.cc | 6 +- src/tint/resolver/resolver.cc | 26 +++++-- src/tint/resolver/resolver_test.cc | 34 ++++----- src/tint/resolver/side_effects_test.cc | 18 ++--- src/tint/resolver/source_variable_test.cc | 6 +- .../storage_class_layout_validation_test.cc | 32 ++++----- .../resolver/storage_class_validation_test.cc | 69 ++++++++++--------- .../resolver/struct_storage_class_use_test.cc | 4 +- src/tint/resolver/type_validation_test.cc | 26 +++---- src/tint/resolver/validation_test.cc | 4 +- src/tint/resolver/variable_test.cc | 10 +-- src/tint/resolver/variable_validation_test.cc | 7 +- .../transform/array_length_from_uniform.cc | 2 +- src/tint/transform/binding_remapper.cc | 2 +- src/tint/transform/combine_samplers.cc | 2 +- .../transform/decompose_strided_array_test.cc | 18 ++--- .../decompose_strided_matrix_test.cc | 16 ++--- src/tint/transform/first_index_offset.cc | 2 +- .../transform/multiplanar_external_texture.cc | 4 +- .../transform/num_workgroups_from_uniform.cc | 2 +- src/tint/transform/vertex_pulling.cc | 2 +- src/tint/writer/flatten_bindings_test.cc | 38 +++++----- ...generate_external_texture_bindings_test.cc | 20 +++--- .../glsl/generator_impl_function_test.cc | 18 ++--- .../generator_impl_member_accessor_test.cc | 2 +- .../glsl/generator_impl_sanitizer_test.cc | 6 +- .../generator_impl_storage_buffer_test.cc | 2 +- .../writer/glsl/generator_impl_type_test.cc | 8 +-- .../generator_impl_uniform_buffer_test.cc | 4 +- .../hlsl/generator_impl_function_test.cc | 18 ++--- .../generator_impl_member_accessor_test.cc | 2 +- .../hlsl/generator_impl_sanitizer_test.cc | 10 +-- .../writer/hlsl/generator_impl_type_test.cc | 10 +-- .../msl/generator_impl_function_test.cc | 12 ++-- .../msl/generator_impl_sanitizer_test.cc | 14 ++-- .../writer/msl/generator_impl_type_test.cc | 14 ++-- src/tint/writer/spirv/builder_builtin_test.cc | 24 +++---- .../writer/spirv/builder_function_test.cc | 2 +- .../spirv/builder_global_variable_test.cc | 18 ++--- src/tint/writer/spirv/builder_type_test.cc | 18 ++--- src/tint/writer/wgsl/generator_impl.cc | 6 +- .../wgsl/generator_impl_function_test.cc | 2 +- .../wgsl/generator_impl_global_decl_test.cc | 4 +- .../writer/wgsl/generator_impl_type_test.cc | 2 +- .../wgsl/generator_impl_variable_test.cc | 6 +- 64 files changed, 378 insertions(+), 329 deletions(-) diff --git a/src/tint/ast/builtin_texture_helper_test.cc b/src/tint/ast/builtin_texture_helper_test.cc index 6e34b6d498..37d4d657ab 100644 --- a/src/tint/ast/builtin_texture_helper_test.cc +++ b/src/tint/ast/builtin_texture_helper_test.cc @@ -142,7 +142,7 @@ const ast::Type* TextureOverloadCase::BuildResultVectorComponentType(ProgramBuil const ast::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b) const { utils::Vector attrs{ - b->create(0u), + b->Group(0_u), b->Binding(0_a), }; switch (texture_kind) { @@ -175,7 +175,7 @@ const ast::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b } const ast::Variable* TextureOverloadCase::BuildSamplerVariable(ProgramBuilder* b) const { - utils::Vector attrs = {b->Group(0u), b->Binding(1_a)}; + utils::Vector attrs = {b->Group(0_a), b->Binding(1_a)}; return b->GlobalVar("sampler", b->ty.sampler(sampler_kind), attrs); } diff --git a/src/tint/ast/group_attribute.cc b/src/tint/ast/group_attribute.cc index 9d011114ca..9f44003a54 100644 --- a/src/tint/ast/group_attribute.cc +++ b/src/tint/ast/group_attribute.cc @@ -22,7 +22,10 @@ TINT_INSTANTIATE_TYPEINFO(tint::ast::GroupAttribute); namespace tint::ast { -GroupAttribute::GroupAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t val) +GroupAttribute::GroupAttribute(ProgramID pid, + NodeID nid, + const Source& src, + const ast::Expression* val) : Base(pid, nid, src), value(val) {} GroupAttribute::~GroupAttribute() = default; @@ -34,7 +37,8 @@ std::string GroupAttribute::Name() const { const GroupAttribute* GroupAttribute::Clone(CloneContext* ctx) const { // Clone arguments outside of create() call to have deterministic ordering auto src = ctx->Clone(source); - return ctx->dst->create(src, value); + auto* value_ = ctx->Clone(value); + return ctx->dst->create(src, value_); } } // namespace tint::ast diff --git a/src/tint/ast/group_attribute.h b/src/tint/ast/group_attribute.h index 66d6ccb409..5110489f51 100644 --- a/src/tint/ast/group_attribute.h +++ b/src/tint/ast/group_attribute.h @@ -18,6 +18,7 @@ #include #include "src/tint/ast/attribute.h" +#include "src/tint/ast/expression.h" namespace tint::ast { @@ -28,8 +29,8 @@ class GroupAttribute final : public Castable { /// @param pid the identifier of the program that owns this node /// @param nid the unique node identifier /// @param src the source of this node - /// @param value the group value - GroupAttribute(ProgramID pid, NodeID nid, const Source& src, uint32_t value); + /// @param value the group value expression + GroupAttribute(ProgramID pid, NodeID nid, const Source& src, const ast::Expression* value); ~GroupAttribute() override; /// @returns the WGSL name for the attribute @@ -41,8 +42,8 @@ class GroupAttribute final : public Castable { /// @return the newly cloned node const GroupAttribute* Clone(CloneContext* ctx) const override; - /// The group value - const uint32_t value; + /// The group value expression + const ast::Expression* const value; }; } // namespace tint::ast diff --git a/src/tint/ast/group_attribute_test.cc b/src/tint/ast/group_attribute_test.cc index 4a6dd1dd28..616ea37aa8 100644 --- a/src/tint/ast/group_attribute_test.cc +++ b/src/tint/ast/group_attribute_test.cc @@ -17,11 +17,12 @@ namespace tint::ast { namespace { +using namespace tint::number_suffixes; // NOLINT using GroupAttributeTest = TestHelper; TEST_F(GroupAttributeTest, Creation) { - auto* d = create(2u); - EXPECT_EQ(2u, d->value); + auto* d = Group(2_a); + EXPECT_TRUE(d->value->Is()); } } // namespace diff --git a/src/tint/ast/variable_test.cc b/src/tint/ast/variable_test.cc index b0096637ce..e67336d26b 100644 --- a/src/tint/ast/variable_test.cc +++ b/src/tint/ast/variable_test.cc @@ -106,7 +106,7 @@ TEST_F(VariableTest, WithAttributes) { } TEST_F(VariableTest, HasBindingPoint_BothProvided) { - auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, Binding(2_a), Group(1)); + auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, Binding(2_a), Group(1_a)); EXPECT_TRUE(var->HasBindingPoint()); } @@ -121,7 +121,7 @@ TEST_F(VariableTest, HasBindingPoint_MissingGroupAttribute) { } TEST_F(VariableTest, HasBindingPoint_MissingBindingAttribute) { - auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, Group(1)); + auto* var = Var("my_var", ty.i32(), StorageClass::kFunction, Group(1_a)); EXPECT_FALSE(var->HasBindingPoint()); } diff --git a/src/tint/inspector/test_inspector_builder.cc b/src/tint/inspector/test_inspector_builder.cc index e57b85f337..342167c769 100644 --- a/src/tint/inspector/test_inspector_builder.cc +++ b/src/tint/inspector/test_inspector_builder.cc @@ -126,7 +126,7 @@ void InspectorBuilder::AddUniformBuffer(const std::string& name, const ast::Type* type, uint32_t group, uint32_t binding) { - GlobalVar(name, type, ast::StorageClass::kUniform, Binding(AInt(binding)), Group(group)); + GlobalVar(name, type, ast::StorageClass::kUniform, Binding(AInt(binding)), Group(AInt(group))); } void InspectorBuilder::AddWorkgroupStorage(const std::string& name, const ast::Type* type) { @@ -139,7 +139,7 @@ void InspectorBuilder::AddStorageBuffer(const std::string& name, uint32_t group, uint32_t binding) { GlobalVar(name, type, ast::StorageClass::kStorage, access, Binding(AInt(binding)), - Group(group)); + Group(AInt(group))); } void InspectorBuilder::MakeStructVariableReferenceBodyFunction( @@ -171,20 +171,20 @@ void InspectorBuilder::MakeStructVariableReferenceBodyFunction( } void InspectorBuilder::AddSampler(const std::string& name, uint32_t group, uint32_t binding) { - GlobalVar(name, sampler_type(), Binding(AInt(binding)), Group(group)); + GlobalVar(name, sampler_type(), Binding(AInt(binding)), Group(AInt(group))); } void InspectorBuilder::AddComparisonSampler(const std::string& name, uint32_t group, uint32_t binding) { - GlobalVar(name, comparison_sampler_type(), Binding(AInt(binding)), Group(group)); + GlobalVar(name, comparison_sampler_type(), Binding(AInt(binding)), Group(AInt(group))); } void InspectorBuilder::AddResource(const std::string& name, const ast::Type* type, uint32_t group, uint32_t binding) { - GlobalVar(name, type, Binding(AInt(binding)), Group(group)); + GlobalVar(name, type, Binding(AInt(binding)), Group(AInt(group))); } void InspectorBuilder::AddGlobalVariable(const std::string& name, const ast::Type* type) { @@ -286,7 +286,7 @@ void InspectorBuilder::AddStorageTexture(const std::string& name, const ast::Type* type, uint32_t group, uint32_t binding) { - GlobalVar(name, type, Binding(AInt(binding)), Group(group)); + GlobalVar(name, type, Binding(AInt(binding)), Group(AInt(group))); } const ast::Function* InspectorBuilder::MakeStorageTextureBodyFunction( diff --git a/src/tint/program_builder.h b/src/tint/program_builder.h index bf9c9edae3..033577b775 100644 --- a/src/tint/program_builder.h +++ b/src/tint/program_builder.h @@ -2290,16 +2290,20 @@ class ProgramBuilder { } /// Creates the ast::GroupAttribute - /// @param value group attribute index + /// @param value group attribute index expresion /// @returns the group attribute pointer - const ast::GroupAttribute* Group(uint32_t value) { return create(value); } + template + const ast::GroupAttribute* Group(EXPR&& value) { + return create(Expr(std::forward(value))); + } /// Creates the ast::GroupAttribute /// @param source the source - /// @param value group attribute index + /// @param value group attribute index expression /// @returns the group attribute pointer - const ast::GroupAttribute* Group(const Source& source, uint32_t value) { - return create(source, value); + template + const ast::GroupAttribute* Group(const Source& source, EXPR&& value) { + return create(source, Expr(std::forward(value))); } /// Creates the ast::BindingAttribute diff --git a/src/tint/reader/spirv/parser_impl.cc b/src/tint/reader/spirv/parser_impl.cc index 58f59dc0e3..85caaf9039 100644 --- a/src/tint/reader/spirv/parser_impl.cc +++ b/src/tint/reader/spirv/parser_impl.cc @@ -1690,7 +1690,7 @@ bool ParserImpl::ConvertDecorationsForVariable(uint32_t id, return Fail() << "malformed DescriptorSet decoration on ID " << id << ": has no operand"; } - decorations->Push(builder_.Group(Source{}, deco[1])); + decorations->Push(builder_.Group(Source{}, AInt(deco[1]))); } if (deco[0] == SpvDecorationBinding) { if (deco.size() == 1) { diff --git a/src/tint/reader/wgsl/parser_impl.cc b/src/tint/reader/wgsl/parser_impl.cc index 0c20c6dc6b..aee4b995d4 100644 --- a/src/tint/reader/wgsl/parser_impl.cc +++ b/src/tint/reader/wgsl/parser_impl.cc @@ -3493,7 +3493,9 @@ Maybe ParserImpl::attribute() { } match(Token::Type::kComma); - return create(t.source(), val.value); + return create( + t.source(), create( + val.value, ast::IntLiteralExpression::Suffix::kNone)); }); } diff --git a/src/tint/reader/wgsl/parser_impl_variable_attribute_test.cc b/src/tint/reader/wgsl/parser_impl_variable_attribute_test.cc index d345ac840a..e48cc85c48 100644 --- a/src/tint/reader/wgsl/parser_impl_variable_attribute_test.cc +++ b/src/tint/reader/wgsl/parser_impl_variable_attribute_test.cc @@ -442,7 +442,11 @@ TEST_F(ParserImplTest, Attribute_group) { ASSERT_TRUE(var_attr->Is()); auto* group = var_attr->As(); - EXPECT_EQ(group->value, 4u); + ASSERT_TRUE(group->value->Is()); + + auto* expr = group->value->As(); + EXPECT_EQ(expr->value, 4); + EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone); } TEST_F(ParserImplTest, Attribute_group_TrailingComma) { @@ -457,7 +461,11 @@ TEST_F(ParserImplTest, Attribute_group_TrailingComma) { ASSERT_TRUE(var_attr->Is()); auto* group = var_attr->As(); - EXPECT_EQ(group->value, 4u); + ASSERT_TRUE(group->value->Is()); + + auto* expr = group->value->As(); + EXPECT_EQ(expr->value, 4); + EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone); } TEST_F(ParserImplTest, Attribute_Group_MissingLeftParen) { diff --git a/src/tint/resolver/assignment_validation_test.cc b/src/tint/resolver/assignment_validation_test.cc index c4f1fe40b2..36ce0cbcc2 100644 --- a/src/tint/resolver/assignment_validation_test.cc +++ b/src/tint/resolver/assignment_validation_test.cc @@ -33,7 +33,7 @@ TEST_F(ResolverAssignmentValidationTest, ReadOnlyBuffer) { Member("m", ty.i32()), }); GlobalVar(Source{{12, 34}}, "a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("a", "m"), 1_i)); @@ -234,8 +234,8 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Handle) { ast::Access::kWrite); }; - GlobalVar("a", make_type(), Binding(0_a), Group(0)); - GlobalVar("b", make_type(), Binding(1_a), Group(0)); + GlobalVar("a", make_type(), Binding(0_a), Group(0_a)); + GlobalVar("b", make_type(), Binding(1_a), Group(0_a)); WrapInFunction(Assign(Source{{56, 78}}, "a", "b")); @@ -252,7 +252,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_Atomic) { Member("a", ty.atomic(ty.i32())), }); GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a"))); @@ -269,7 +269,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignNonConstructible_RuntimeArray) { Member("a", ty.array(ty.f32())), }); GlobalVar(Source{{12, 34}}, "v", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); WrapInFunction(Assign(Source{{56, 78}}, MemberAccessor("v", "a"), MemberAccessor("v", "a"))); @@ -288,7 +288,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_NonConstructibleStruct_Fa auto* s = Structure("S", utils::Vector{ Member("arr", ty.array()), }); - GlobalVar("s", ty.Of(s), ast::StorageClass::kStorage, Group(0), Binding(0_a)); + GlobalVar("s", ty.Of(s), ast::StorageClass::kStorage, Group(0_a), Binding(0_a)); WrapInFunction(Assign(Phony(), Expr(Source{{12, 34}}, "s"))); @@ -310,7 +310,7 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_DynamicArray_Fail) { auto* s = Structure("S", utils::Vector{ Member("arr", ty.array()), }); - GlobalVar("s", ty.Of(s), ast::StorageClass::kStorage, Group(0), Binding(0_a)); + GlobalVar("s", ty.Of(s), ast::StorageClass::kStorage, Group(0_a), Binding(0_a)); WrapInFunction(Assign(Phony(), MemberAccessor(Source{{12, 34}}, "s", "arr"))); @@ -360,11 +360,11 @@ TEST_F(ResolverAssignmentValidationTest, AssignToPhony_Pass) { auto* U = Structure("U", utils::Vector{ Member("i", ty.i32()), }); - GlobalVar("tex", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(0), + GlobalVar("tex", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(0_a), Binding(0_a)); - GlobalVar("smp", ty.sampler(ast::SamplerKind::kSampler), Group(0), Binding(1_a)); - GlobalVar("u", ty.Of(U), ast::StorageClass::kUniform, Group(0), Binding(2_a)); - GlobalVar("s", ty.Of(S), ast::StorageClass::kStorage, Group(0), Binding(3_a)); + GlobalVar("smp", ty.sampler(ast::SamplerKind::kSampler), Group(0_a), Binding(1_a)); + GlobalVar("u", ty.Of(U), ast::StorageClass::kUniform, Group(0_a), Binding(2_a)); + GlobalVar("s", ty.Of(S), ast::StorageClass::kStorage, Group(0_a), Binding(3_a)); GlobalVar("wg", ty.array(), ast::StorageClass::kWorkgroup); WrapInFunction(Assign(Phony(), 1_i), // diff --git a/src/tint/resolver/atomics_test.cc b/src/tint/resolver/atomics_test.cc index 19cc8d538f..a22977e3e7 100644 --- a/src/tint/resolver/atomics_test.cc +++ b/src/tint/resolver/atomics_test.cc @@ -49,7 +49,7 @@ TEST_F(ResolverAtomicTest, GlobalWorkgroupU32) { TEST_F(ResolverAtomicTest, GlobalStorageStruct) { auto* s = Structure("s", utils::Vector{Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))}); auto* g = GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); 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 b3da7b52e8..aa4c1c230e 100644 --- a/src/tint/resolver/atomics_validation_test.cc +++ b/src/tint/resolver/atomics_validation_test.cc @@ -34,14 +34,14 @@ TEST_F(ResolverAtomicValidationTest, StorageClass_WorkGroup) { TEST_F(ResolverAtomicValidationTest, StorageClass_Storage) { GlobalVar("g", ty.atomic(Source{{12, 34}}, ty.i32()), ast::StorageClass::kStorage, - ast::Access::kReadWrite, Group(0), Binding(0_a)); + ast::Access::kReadWrite, Group(0_a), Binding(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); } TEST_F(ResolverAtomicValidationTest, StorageClass_Storage_Struct) { auto* s = Structure("s", utils::Vector{Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))}); - GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Group(0), + GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Group(0_a), Binding(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -210,7 +210,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidStorageClass_Complex) { TEST_F(ResolverAtomicValidationTest, Struct_AccessMode_Read) { auto* s = Structure("s", utils::Vector{Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))}); GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - Group(0), Binding(0_a)); + Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -222,7 +222,7 @@ TEST_F(ResolverAtomicValidationTest, Struct_AccessMode_Read) { TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Struct) { auto* s = Structure("s", utils::Vector{Member("a", ty.atomic(Source{{12, 34}}, ty.i32()))}); GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - Group(0), Binding(0_a)); + Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -240,7 +240,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStruct) { Structure("Inner", utils::Vector{Member("m", ty.atomic(Source{{12, 34}}, ty.i32()))}); auto* Outer = Structure("Outer", utils::Vector{Member("m", ty.Of(Inner))}); GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), ast::StorageClass::kStorage, ast::Access::kRead, - Group(0), Binding(0_a)); + Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -258,7 +258,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_StructOfStructOfArray) { Structure("Inner", utils::Vector{Member(Source{{12, 34}}, "m", ty.atomic(ty.i32()))}); auto* Outer = Structure("Outer", utils::Vector{Member("m", ty.Of(Inner))}); GlobalVar(Source{{56, 78}}, "g", ty.Of(Outer), ast::StorageClass::kStorage, ast::Access::kRead, - Group(0), Binding(0_a)); + Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -300,7 +300,7 @@ TEST_F(ResolverAtomicValidationTest, InvalidAccessMode_Complex) { auto* s1 = Structure("S1", utils::Vector{Member("x", ty.Of(s2))}); auto* s0 = Structure("S0", utils::Vector{Member("x", ty.Of(s1))}); GlobalVar(Source{{56, 78}}, "g", ty.Of(s0), ast::StorageClass::kStorage, ast::Access::kRead, - Group(0), Binding(0_a)); + Group(0_a), Binding(0_a)); 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 f3c2329aa3..fd06200997 100644 --- a/src/tint/resolver/attribute_validation_test.cc +++ b/src/tint/resolver/attribute_validation_test.cc @@ -95,7 +95,7 @@ static utils::Vector createAttributes(const Source& so case AttributeKind::kBuiltin: return {builder.Builtin(source, ast::BuiltinValue::kPosition)}; case AttributeKind::kGroup: - return {builder.Group(source, 1u)}; + return {builder.Group(source, 1_a)}; case AttributeKind::kId: return {builder.create(source, 0u)}; case AttributeKind::kInterpolate: @@ -116,7 +116,7 @@ static utils::Vector createAttributes(const Source& so case AttributeKind::kWorkgroup: return {builder.create(source, builder.Expr(1_i))}; case AttributeKind::kBindingAndGroup: - return {builder.Binding(source, 1_a), builder.Group(source, 1u)}; + return {builder.Binding(source, 1_a), builder.Group(source, 1_a)}; } return {}; } @@ -509,7 +509,7 @@ TEST_F(EntryPointParameterAttributeTest, DuplicateInternalAttribute) { auto* s = Param("s", ty.sampler(ast::SamplerKind::kSampler), utils::Vector{ Binding(0_a), - Group(0u), + Group(0_a), Disable(ast::DisabledValidation::kBindingPointCollision), Disable(ast::DisabledValidation::kEntryPointParameter), }); @@ -734,7 +734,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverAttributeValidationTest, TEST_F(VariableAttributeTest, DuplicateAttribute) { GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler), Binding(Source{{12, 34}}, 2_a), - Group(2u), Binding(Source{{56, 78}}, 3_a)); + Group(2_a), Binding(Source{{56, 78}}, 3_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -1010,7 +1010,7 @@ TEST_F(ResourceAttributeTest, SamplerMissingBinding) { } TEST_F(ResourceAttributeTest, BindingPairMissingBinding) { - GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler), Group(1)); + GlobalVar(Source{{12, 34}}, "G", ty.sampler(ast::SamplerKind::kSampler), Group(1_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -1027,9 +1027,9 @@ TEST_F(ResourceAttributeTest, BindingPairMissingGroup) { TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) { GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), - Binding(1_a), Group(2)); + Binding(1_a), Group(2_a)); GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), - Binding(1_a), Group(2)); + Binding(1_a), Group(2_a)); Func("F", utils::Empty, ty.void_(), utils::Vector{ @@ -1049,9 +1049,9 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByEntryPoint) { TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) { GlobalVar(Source{{12, 34}}, "A", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), - Binding(1_a), Group(2)); + Binding(1_a), Group(2_a)); GlobalVar(Source{{56, 78}}, "B", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), - Binding(1_a), Group(2)); + Binding(1_a), Group(2_a)); Func("F_A", utils::Empty, ty.void_(), utils::Vector{ @@ -1072,7 +1072,8 @@ TEST_F(ResourceAttributeTest, BindingPointUsedTwiceByDifferentEntryPoints) { } TEST_F(ResourceAttributeTest, BindingPointOnNonResource) { - GlobalVar(Source{{12, 34}}, "G", ty.f32(), ast::StorageClass::kPrivate, Binding(1_a), Group(2)); + GlobalVar(Source{{12, 34}}, "G", ty.f32(), ast::StorageClass::kPrivate, Binding(1_a), + Group(2_a)); 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 f08a875c0b..b1d1e35777 100644 --- a/src/tint/resolver/builtin_test.cc +++ b/src/tint/resolver/builtin_test.cc @@ -213,7 +213,7 @@ TEST_F(ResolverBuiltinArrayTest, ArrayLength_Vector) { auto* ary = ty.array(); auto* str = Structure("S", utils::Vector{Member("x", ary)}); GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); auto* call = Call("arrayLength", AddressOf(MemberAccessor("a", "x"))); WrapInFunction(call); @@ -2143,7 +2143,7 @@ class ResolverBuiltinTest_TextureOperation : public ResolverTestWithParamIsAnyOf()) { - GlobalVar(name, type, Binding(0_a), Group(0)); + GlobalVar(name, type, Binding(0_a), Group(0_a)); } else { GlobalVar(name, type, ast::StorageClass::kPrivate); diff --git a/src/tint/resolver/compound_assignment_validation_test.cc b/src/tint/resolver/compound_assignment_validation_test.cc index 962bf51e03..9112fa0304 100644 --- a/src/tint/resolver/compound_assignment_validation_test.cc +++ b/src/tint/resolver/compound_assignment_validation_test.cc @@ -234,7 +234,7 @@ TEST_F(ResolverCompoundAssignmentValidationTest, ReadOnlyBuffer) { // a += 1i; // } GlobalVar(Source{{12, 34}}, "a", ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead, - Group(0), Binding(0_a)); + Group(0_a), Binding(0_a)); WrapInFunction(CompoundAssign(Source{{56, 78}}, "a", 1_i, ast::BinaryOp::kAdd)); EXPECT_FALSE(r()->Resolve()); diff --git a/src/tint/resolver/host_shareable_validation_test.cc b/src/tint/resolver/host_shareable_validation_test.cc index 7893f82a1a..bba156b6ed 100644 --- a/src/tint/resolver/host_shareable_validation_test.cc +++ b/src/tint/resolver/host_shareable_validation_test.cc @@ -29,7 +29,7 @@ TEST_F(ResolverHostShareableValidationTest, BoolMember) { auto* s = Structure("S", utils::Vector{Member(Source{{12, 34}}, "x", ty.bool_())}); GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -44,7 +44,7 @@ TEST_F(ResolverHostShareableValidationTest, BoolVectorMember) { auto* s = Structure("S", utils::Vector{Member(Source{{12, 34}}, "x", ty.vec3())}); GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -60,7 +60,7 @@ TEST_F(ResolverHostShareableValidationTest, Aliases) { auto* s = Structure("S", utils::Vector{Member(Source{{12, 34}}, "x", ty.Of(a1))}); auto* a2 = Alias("a2", ty.Of(s)); GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -79,7 +79,7 @@ TEST_F(ResolverHostShareableValidationTest, NestedStructures) { auto* s = Structure("S", utils::Vector{Member(Source{{7, 8}}, "m", ty.Of(i3))}); GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -118,7 +118,7 @@ TEST_F(ResolverHostShareableValidationTest, NoError) { auto* s = Structure("S", utils::Vector{Member(Source{{7, 8}}, "m", ty.Of(i3))}); GlobalVar(Source{{9, 10}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); 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 d1afaaf09e..7368b6dc00 100644 --- a/src/tint/resolver/increment_decrement_validation_test.cc +++ b/src/tint/resolver/increment_decrement_validation_test.cc @@ -194,7 +194,7 @@ TEST_F(ResolverIncrementDecrementValidationTest, ReadOnlyBuffer) { // a++; // } GlobalVar(Source{{12, 34}}, "a", ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead, - Group(0), Binding(0_a)); + Group(0_a), Binding(0_a)); WrapInFunction(Increment(Source{{56, 78}}, "a")); EXPECT_FALSE(r()->Resolve()); diff --git a/src/tint/resolver/ptr_ref_test.cc b/src/tint/resolver/ptr_ref_test.cc index 892feb8fc0..129263af32 100644 --- a/src/tint/resolver/ptr_ref_test.cc +++ b/src/tint/resolver/ptr_ref_test.cc @@ -64,9 +64,9 @@ TEST_F(ResolverPtrRefTest, DefaultPtrStorageClass) { 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, Binding(0_a), Group(0)); + GlobalVar("ub", ty.Of(buf), ast::StorageClass::kUniform, Binding(0_a), Group(0_a)); auto* storage = - GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, Binding(1_a), Group(0)); + GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, Binding(1_a), Group(0_a)); 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 5b149aad10..f850f2a415 100644 --- a/src/tint/resolver/ptr_ref_validation_test.cc +++ b/src/tint/resolver/ptr_ref_validation_test.cc @@ -54,7 +54,7 @@ TEST_F(ResolverPtrRefValidationTest, AddressOfLet) { TEST_F(ResolverPtrRefValidationTest, AddressOfHandle) { // @group(0) @binding(0) var t: texture_3d; // &t - GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k3d, ty.f32()), Group(0), + GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k3d, ty.f32()), Group(0_a), Binding(0_a)); auto* expr = AddressOf(Expr(Source{{12, 34}}, "t")); WrapInFunction(expr); @@ -94,7 +94,7 @@ TEST_F(ResolverPtrRefValidationTest, AddressOfVectorComponent_IndexAccessor) { TEST_F(ResolverPtrRefValidationTest, IndirectOfAddressOfHandle) { // @group(0) @binding(0) var t: texture_3d; // *&t - GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k3d, ty.f32()), Group(0), + GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k3d, ty.f32()), Group(0_a), Binding(0_a)); auto* expr = Deref(AddressOf(Expr(Source{{12, 34}}, "t"))); WrapInFunction(expr); @@ -144,7 +144,7 @@ TEST_F(ResolverPtrRefValidationTest, InferredPtrAccessMismatch) { auto* inner = Structure("Inner", utils::Vector{Member("arr", ty.array())}); auto* buf = Structure("S", utils::Vector{Member("inner", ty.Of(inner))}); auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i); auto* ptr = diff --git a/src/tint/resolver/resolver.cc b/src/tint/resolver/resolver.cc index c469c3c5dd..527c921cf5 100644 --- a/src/tint/resolver/resolver.cc +++ b/src/tint/resolver/resolver.cc @@ -598,8 +598,17 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) { uint32_t group = 0; { auto* attr = ast::GetAttribute(var->attributes); - // TODO(dsinclair): Materialize when group attribute is an expression - group = attr->value; + auto* materialize = Materialize(Expression(attr->value)); + if (!materialize) { + return nullptr; + } + auto* c = materialize->ConstantValue(); + if (!c) { + // TODO(crbug.com/tint/1633): Add error message about invalid materialization + // when binding can be an expression. + return nullptr; + } + group = c->As(); } binding_point = {group, binding}; } @@ -669,8 +678,17 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index) } { auto* attr = ast::GetAttribute(param->attributes); - // TODO(dsinclair): Materialize the group information - binding_point.group = attr->value; + auto* materialize = Materialize(Expression(attr->value)); + if (!materialize) { + return nullptr; + } + auto* c = materialize->ConstantValue(); + if (!c) { + // TODO(crbug.com/tint/1633): Add error message about invalid materialization when + // binding can be an expression. + return nullptr; + } + binding_point.group = c->As(); } } diff --git a/src/tint/resolver/resolver_test.cc b/src/tint/resolver/resolver_test.cc index 80d727ca75..595973d7f7 100644 --- a/src/tint/resolver/resolver_test.cc +++ b/src/tint/resolver/resolver_test.cc @@ -777,7 +777,7 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables) { auto* s = Structure("S", utils::Vector{Member("m", ty.u32())}); auto* sb_var = GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, - ast::Access::kReadWrite, Binding(0_a), Group(0)); + ast::Access::kReadWrite, Binding(0_a), Group(0_a)); auto* wg_var = GlobalVar("wg_var", ty.f32(), ast::StorageClass::kWorkgroup); auto* priv_var = GlobalVar("priv_var", ty.f32(), ast::StorageClass::kPrivate); @@ -806,7 +806,7 @@ TEST_F(ResolverTest, Function_RegisterInputOutputVariables_SubFunction) { auto* s = Structure("S", utils::Vector{Member("m", ty.u32())}); auto* sb_var = GlobalVar("sb_var", ty.Of(s), ast::StorageClass::kStorage, - ast::Access::kReadWrite, Binding(0_a), Group(0)); + ast::Access::kReadWrite, Binding(0_a), Group(0_a)); auto* wg_var = GlobalVar("wg_var", ty.f32(), ast::StorageClass::kWorkgroup); auto* priv_var = GlobalVar("priv_var", ty.f32(), ast::StorageClass::kPrivate); @@ -1727,7 +1727,7 @@ TEST_F(ResolverTest, StorageClass_SetsIfMissing) { TEST_F(ResolverTest, StorageClass_SetForSampler) { auto* t = ty.sampler(ast::SamplerKind::kSampler); - auto* var = GlobalVar("var", t, Binding(0_a), Group(0)); + auto* var = GlobalVar("var", t, Binding(0_a), Group(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1736,7 +1736,7 @@ TEST_F(ResolverTest, StorageClass_SetForSampler) { TEST_F(ResolverTest, StorageClass_SetForTexture) { auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32()); - auto* var = GlobalVar("var", t, Binding(0_a), Group(0)); + auto* var = GlobalVar("var", t, Binding(0_a), Group(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1758,7 +1758,7 @@ TEST_F(ResolverTest, Access_SetForStorageBuffer) { // var g : S; auto* s = Structure("S", utils::Vector{Member(Source{{12, 34}}, "x", ty.i32())}); auto* var = GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1768,8 +1768,8 @@ 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 = GlobalVar(Sym(), ty.sampler(ast::SamplerKind::kSampler), Group(1), Binding(2_a)); - auto* s2 = GlobalVar(Sym(), ty.sampler(ast::SamplerKind::kSampler), Group(3), Binding(4_a)); + auto* s1 = GlobalVar(Sym(), ty.sampler(ast::SamplerKind::kSampler), Group(1_a), Binding(2_a)); + auto* s2 = GlobalVar(Sym(), ty.sampler(ast::SamplerKind::kSampler), Group(3_a), Binding(4_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -1972,9 +1972,9 @@ TEST_F(ResolverTest, UnaryOp_Negation) { } TEST_F(ResolverTest, TextureSampler_TextureSample) { - GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1), + GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1_a), Binding(1_a)); - GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(1), Binding(2_a)); + GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(1_a), Binding(2_a)); auto* call = CallStmt(Call("textureSample", "t", "s", vec2(1_f, 2_f))); const ast::Function* f = Func("test_function", utils::Empty, ty.void_(), utils::Vector{call}, @@ -1990,9 +1990,9 @@ TEST_F(ResolverTest, TextureSampler_TextureSample) { } TEST_F(ResolverTest, TextureSampler_TextureSampleInFunction) { - GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1), + GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1_a), Binding(1_a)); - GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(1), Binding(2_a)); + GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(1_a), Binding(2_a)); auto* inner_call = CallStmt(Call("textureSample", "t", "s", vec2(1_f, 2_f))); const ast::Function* inner_func = @@ -2016,9 +2016,9 @@ TEST_F(ResolverTest, TextureSampler_TextureSampleInFunction) { } TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondSameVariables) { - GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1), + GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1_a), Binding(1_a)); - GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(1), Binding(2_a)); + GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(1_a), Binding(2_a)); auto* inner_call_1 = CallStmt(Call("textureSample", "t", "s", vec2(1_f, 2_f))); const ast::Function* inner_func_1 = @@ -2051,11 +2051,11 @@ TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondSameVariables) { } TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondDifferentVariables) { - GlobalVar("t1", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1), + GlobalVar("t1", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1_a), Binding(1_a)); - GlobalVar("t2", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1), + GlobalVar("t2", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1_a), Binding(2_a)); - GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(1), Binding(3_a)); + GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(1_a), Binding(3_a)); auto* inner_call_1 = CallStmt(Call("textureSample", "t1", "s", vec2(1_f, 2_f))); const ast::Function* inner_func_1 = @@ -2090,7 +2090,7 @@ TEST_F(ResolverTest, TextureSampler_TextureSampleFunctionDiamondDifferentVariabl } TEST_F(ResolverTest, TextureSampler_TextureDimensions) { - GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1), + GlobalVar("t", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(1_a), Binding(2_a)); auto* call = Call("textureDimensions", "t"); diff --git a/src/tint/resolver/side_effects_test.cc b/src/tint/resolver/side_effects_test.cc index 7b720f3204..17604a9112 100644 --- a/src/tint/resolver/side_effects_test.cc +++ b/src/tint/resolver/side_effects_test.cc @@ -174,26 +174,26 @@ TEST_P(SideEffectsBuiltinTest, Test) { GlobalVar("vb", ty.vec3(), ast::StorageClass::kPrivate); GlobalVar("m", ty.mat3x3(), ast::StorageClass::kPrivate); GlobalVar("arr", ty.array(), ast::StorageClass::kPrivate); - GlobalVar("storage_arr", ty.array(), ast::StorageClass::kStorage, Group(0), + GlobalVar("storage_arr", ty.array(), ast::StorageClass::kStorage, Group(0_a), Binding(AInt(next_binding++))); GlobalVar("a", ty.atomic(ty.i32()), ast::StorageClass::kStorage, ast::Access::kReadWrite, - Group(0), Binding(AInt(next_binding++))); + Group(0_a), Binding(AInt(next_binding++))); if (c.pipeline_stage != ast::PipelineStage::kCompute) { - GlobalVar("t2d", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(0), + GlobalVar("t2d", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(0_a), Binding(AInt(next_binding++))); - GlobalVar("tdepth2d", ty.depth_texture(ast::TextureDimension::k2d), Group(0), + GlobalVar("tdepth2d", ty.depth_texture(ast::TextureDimension::k2d), Group(0_a), Binding(AInt(next_binding++))); GlobalVar("t2d_arr", ty.sampled_texture(ast::TextureDimension::k2dArray, ty.f32()), - Group(0), Binding(AInt(next_binding++))); + Group(0_a), Binding(AInt(next_binding++))); GlobalVar("t2d_multi", ty.multisampled_texture(ast::TextureDimension::k2d, ty.f32()), - Group(0), Binding(AInt(next_binding++))); + Group(0_a), Binding(AInt(next_binding++))); GlobalVar("tstorage2d", ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float, ast::Access::kWrite), - Group(0), Binding(AInt(next_binding++))); - GlobalVar("s2d", ty.sampler(ast::SamplerKind::kSampler), Group(0), + Group(0_a), Binding(AInt(next_binding++))); + GlobalVar("s2d", ty.sampler(ast::SamplerKind::kSampler), Group(0_a), Binding(AInt(next_binding++))); - GlobalVar("scomp", ty.sampler(ast::SamplerKind::kComparisonSampler), Group(0), + GlobalVar("scomp", ty.sampler(ast::SamplerKind::kComparisonSampler), Group(0_a), Binding(AInt(next_binding++))); } diff --git a/src/tint/resolver/source_variable_test.cc b/src/tint/resolver/source_variable_test.cc index 304a554fbf..85d0c31f83 100644 --- a/src/tint/resolver/source_variable_test.cc +++ b/src/tint/resolver/source_variable_test.cc @@ -48,7 +48,7 @@ TEST_F(ResolverSourceVariableTest, GlobalWorkgroupVar) { } TEST_F(ResolverSourceVariableTest, GlobalStorageVar) { - auto* a = GlobalVar("a", ty.f32(), ast::StorageClass::kStorage, Group(0), Binding(0_a)); + auto* a = GlobalVar("a", ty.f32(), ast::StorageClass::kStorage, Group(0_a), Binding(0_a)); auto* expr = Expr(a); WrapInFunction(expr); @@ -59,7 +59,7 @@ TEST_F(ResolverSourceVariableTest, GlobalStorageVar) { } TEST_F(ResolverSourceVariableTest, GlobalUniformVar) { - auto* a = GlobalVar("a", ty.f32(), ast::StorageClass::kUniform, Group(0), Binding(0_a)); + auto* a = GlobalVar("a", ty.f32(), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); auto* expr = Expr(a); WrapInFunction(expr); @@ -71,7 +71,7 @@ TEST_F(ResolverSourceVariableTest, GlobalUniformVar) { TEST_F(ResolverSourceVariableTest, GlobalTextureVar) { auto* a = GlobalVar("a", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), - ast::StorageClass::kNone, Group(0), Binding(0_a)); + ast::StorageClass::kNone, Group(0_a), Binding(0_a)); auto* expr = Expr(a); WrapInFunction(Call("textureDimensions", expr)); diff --git a/src/tint/resolver/storage_class_layout_validation_test.cc b/src/tint/resolver/storage_class_layout_validation_test.cc index c4f73d6b86..8f1b2c1c37 100644 --- a/src/tint/resolver/storage_class_layout_validation_test.cc +++ b/src/tint/resolver/storage_class_layout_validation_test.cc @@ -39,7 +39,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, StorageBuffer_UnalignedMember) Member(Source{{34, 56}}, "b", ty.f32(), utils::Vector{MemberAlign(1_u)}), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage, Group(0), + GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -69,7 +69,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, StorageBuffer_UnalignedMember_S Member(Source{{34, 56}}, "b", ty.f32(), utils::Vector{MemberAlign(4_u)}), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage, Group(0), + GlobalVar(Source{{78, 90}}, "a", ty.type_name("S"), ast::StorageClass::kStorage, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -100,7 +100,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_UnalignedMember_S Member(Source{{56, 78}}, "inner", ty.type_name("Inner")), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0), + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -145,7 +145,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, utils::Vector{MemberAlign(16_u)}), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0), + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -170,7 +170,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_UnalignedMember_A Member(Source{{56, 78}}, "inner", ty.type_name("Inner")), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0), + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -204,7 +204,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_UnalignedMember_A utils::Vector{MemberAlign(16_u)}), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0), + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -236,7 +236,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_MembersOffsetNotM Member(Source{{78, 90}}, "scalar", ty.i32()), }); - GlobalVar(Source{{22, 24}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0), + GlobalVar(Source{{22, 24}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -288,7 +288,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, Member(Source{{78, 90}}, "scalar", ty.i32()), }); - GlobalVar(Source{{22, 24}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0), + GlobalVar(Source{{22, 24}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -336,7 +336,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, Member(Source{{78, 90}}, "scalar", ty.i32(), utils::Vector{MemberAlign(16_u)}), }); - GlobalVar(Source{{22, 34}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0), + GlobalVar(Source{{22, 34}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -358,7 +358,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_Vec3MemberOffset_ }); GlobalVar(Source{{78, 90}}, "a", ty.type_name("ScalarPackedAtEndOfVec3"), - ast::StorageClass::kUniform, Group(0), Binding(0_a)); + ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -383,7 +383,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("scalar", ty.i32()), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0), + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -417,7 +417,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("scalar", ty.i32()), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0), + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -460,7 +460,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("scalar", ty.i32()), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0), + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -479,7 +479,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid // @group(0) @binding(0) // var a : array; GlobalVar(Source{{78, 90}}, "a", ty.array(Source{{34, 56}}, ty.f32(), 4_u), - ast::StorageClass::kUniform, Group(0), Binding(0_a)); + ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ( @@ -500,7 +500,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("inner", ty.array(Source{{34, 56}}, ty.array(ty.f32(), 4_u), 4_u)), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0), + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -533,7 +533,7 @@ TEST_F(ResolverStorageClassLayoutValidationTest, UniformBuffer_InvalidArrayStrid Member("scalar", ty.i32()), }); - GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0), + GlobalVar(Source{{78, 90}}, "a", ty.type_name("Outer"), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); 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 d93e77d53b..8c1a253c4f 100644 --- a/src/tint/resolver/storage_class_validation_test.cc +++ b/src/tint/resolver/storage_class_validation_test.cc @@ -88,7 +88,7 @@ note: while analysing structure member S.m TEST_F(ResolverStorageClassValidationTest, StorageBufferBool) { // var g : bool; GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kStorage, Binding(0_a), - Group(0)); + Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -102,7 +102,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferBoolAlias) { // type a = bool; // var g : a; auto* a = Alias("a", ty.bool_()); - GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kStorage, Binding(0_a), Group(0)); + GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kStorage, Binding(0_a), + Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -118,7 +119,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferF16_TemporallyBan) { // var g : f16; Enable(ast::Extension::kF16); - GlobalVar("g", ty.f16(Source{{56, 78}}), ast::StorageClass::kStorage, Binding(0_a), Group(0)); + GlobalVar("g", ty.f16(Source{{56, 78}}), ast::StorageClass::kStorage, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -134,7 +135,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferF16Alias_TemporallyBan) auto* a = Alias("a", ty.f16()); GlobalVar("g", ty.type_name(Source{{56, 78}}, a->name), ast::StorageClass::kStorage, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -147,7 +148,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferVectorF16_TemporallyBan) // var g : vec4; Enable(ast::Extension::kF16); GlobalVar("g", ty.vec(Source{{56, 78}}, ty.Of(), 4u), ast::StorageClass::kStorage, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -163,7 +164,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferArrayF16_TemporallyBan) auto* s = Structure("S", utils::Vector{Member("a", ty.f16(Source{{56, 78}}))}); auto* a = ty.array(ty.Of(s), 3_u); - GlobalVar("g", a, ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), Group(0)); + GlobalVar("g", a, ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -178,7 +179,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferStructF16_TemporallyBan) auto* s = Structure("S", utils::Vector{Member("x", ty.f16(Source{{12, 34}}))}); GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -196,7 +197,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoErrorStructF16Aliases_ auto* a1 = Alias("a1", ty.Of(s)); auto* a2 = Alias("a2", ty.Of(a1)); GlobalVar("g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -207,7 +208,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoErrorStructF16Aliases_ TEST_F(ResolverStorageClassValidationTest, StorageBufferPointer) { // var g : ptr; GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate), - ast::StorageClass::kStorage, Binding(0_a), Group(0)); + ast::StorageClass::kStorage, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -219,7 +220,8 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferPointer) { TEST_F(ResolverStorageClassValidationTest, StorageBufferIntScalar) { // var g : i32; - GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kStorage, Binding(0_a), Group(0)); + GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kStorage, Binding(0_a), + Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -227,7 +229,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferIntScalar) { TEST_F(ResolverStorageClassValidationTest, StorageBufferVectorF32) { // var g : vec4; GlobalVar(Source{{56, 78}}, "g", ty.vec4(), ast::StorageClass::kStorage, Binding(0_a), - Group(0)); + Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -237,7 +239,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferArrayF32) { auto* s = Structure("S", utils::Vector{Member("a", ty.f32())}); auto* a = ty.array(ty.Of(s), 3_u); GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kStorage, ast::Access::kRead, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -256,7 +258,7 @@ TEST_F(ResolverStorageClassValidationTest, NotStorage_AccessMode) { TEST_F(ResolverStorageClassValidationTest, Storage_ReadAccessMode) { // @group(0) @binding(0) var a : i32; GlobalVar(Source{{56, 78}}, "a", ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead, - Group(0), Binding(0_a)); + Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -264,7 +266,7 @@ TEST_F(ResolverStorageClassValidationTest, Storage_ReadAccessMode) { TEST_F(ResolverStorageClassValidationTest, Storage_ReadWriteAccessMode) { // @group(0) @binding(0) var a : i32; GlobalVar(Source{{56, 78}}, "a", ty.i32(), ast::StorageClass::kStorage, ast::Access::kReadWrite, - Group(0), Binding(0_a)); + Group(0_a), Binding(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -272,7 +274,7 @@ TEST_F(ResolverStorageClassValidationTest, Storage_ReadWriteAccessMode) { TEST_F(ResolverStorageClassValidationTest, Storage_WriteAccessMode) { // @group(0) @binding(0) var a : i32; GlobalVar(Source{{56, 78}}, "a", ty.i32(), ast::StorageClass::kStorage, ast::Access::kWrite, - Group(0), Binding(0_a)); + Group(0_a), Binding(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -285,7 +287,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferStructI32) { // var g : S; auto* s = Structure("S", utils::Vector{Member(Source{{12, 34}}, "x", ty.i32())}); GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()); } @@ -298,7 +300,7 @@ TEST_F(ResolverStorageClassValidationTest, StorageBufferNoErrorStructI32Aliases) auto* a1 = Alias("a1", ty.Of(s)); auto* a2 = Alias("a2", ty.Of(a1)); GlobalVar(Source{{56, 78}}, "g", ty.Of(a2), ast::StorageClass::kStorage, ast::Access::kRead, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()); } @@ -310,7 +312,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBuffer_Struct_Runtime) { auto* s = Structure(Source{{12, 34}}, "S", utils::Vector{Member("m", ty.array())}); GlobalVar(Source{{56, 78}}, "svar", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), - Group(0)); + Group(0_a)); ASSERT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -322,7 +324,7 @@ note: while analysing structure member S.m TEST_F(ResolverStorageClassValidationTest, UniformBufferBool) { // var g : bool; GlobalVar(Source{{56, 78}}, "g", ty.bool_(), ast::StorageClass::kUniform, Binding(0_a), - Group(0)); + Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -336,7 +338,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferBoolAlias) { // type a = bool; // var g : a; auto* a = Alias("a", ty.bool_()); - GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kUniform, Binding(0_a), Group(0)); + GlobalVar(Source{{56, 78}}, "g", ty.Of(a), ast::StorageClass::kUniform, Binding(0_a), + Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -352,7 +355,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferF16_TemporallyBan) { // var g : f16; Enable(ast::Extension::kF16); - GlobalVar("g", ty.f16(Source{{56, 78}}), ast::StorageClass::kUniform, Binding(0_a), Group(0)); + GlobalVar("g", ty.f16(Source{{56, 78}}), ast::StorageClass::kUniform, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -368,7 +371,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferF16Alias_TemporallyBan) auto* a = Alias("a", ty.f16()); GlobalVar("g", ty.type_name(Source{{56, 78}}, a->name), ast::StorageClass::kUniform, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -381,7 +384,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferVectorF16_TemporallyBan) // var g : vec4; Enable(ast::Extension::kF16); GlobalVar("g", ty.vec(Source{{56, 78}}, ty.Of(), 4u), ast::StorageClass::kUniform, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -399,7 +402,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferArrayF16_TemporallyBan) auto* s = Structure( "S", utils::Vector{Member("a", ty.f16(Source{{56, 78}}), utils::Vector{MemberSize(16)})}); auto* a = ty.array(ty.Of(s), 3_u); - GlobalVar("g", a, ast::StorageClass::kUniform, Binding(0_a), Group(0)); + GlobalVar("g", a, ast::StorageClass::kUniform, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -413,7 +416,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferStructF16_TemporallyBan) Enable(ast::Extension::kF16); auto* s = Structure("S", utils::Vector{Member("x", ty.f16(Source{{12, 34}}))}); - GlobalVar("g", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), Group(0)); + GlobalVar("g", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -429,7 +432,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferStructF16Aliases_Tempora auto* s = Structure("S", utils::Vector{Member("x", ty.f16(Source{{12, 34}}))}); auto* a1 = Alias("a1", ty.Of(s)); - GlobalVar("g", ty.Of(a1), ast::StorageClass::kUniform, Binding(0_a), Group(0)); + GlobalVar("g", ty.Of(a1), ast::StorageClass::kUniform, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -440,7 +443,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferStructF16Aliases_Tempora TEST_F(ResolverStorageClassValidationTest, UniformBufferPointer) { // var g : ptr; GlobalVar(Source{{56, 78}}, "g", ty.pointer(ty.f32(), ast::StorageClass::kPrivate), - ast::StorageClass::kUniform, Binding(0_a), Group(0)); + ast::StorageClass::kUniform, Binding(0_a), Group(0_a)); ASSERT_FALSE(r()->Resolve()); @@ -452,7 +455,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferPointer) { TEST_F(ResolverStorageClassValidationTest, UniformBufferIntScalar) { // var g : i32; - GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kUniform, Binding(0_a), Group(0)); + GlobalVar(Source{{56, 78}}, "g", ty.i32(), ast::StorageClass::kUniform, Binding(0_a), + Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -460,7 +464,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferIntScalar) { TEST_F(ResolverStorageClassValidationTest, UniformBufferVectorF32) { // var g : vec4; GlobalVar(Source{{56, 78}}, "g", ty.vec4(), ast::StorageClass::kUniform, Binding(0_a), - Group(0)); + Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -472,7 +476,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferArrayF32) { // var g : array; auto* s = Structure("S", utils::Vector{Member("a", ty.f32(), utils::Vector{MemberSize(16)})}); auto* a = ty.array(ty.Of(s), 3_u); - GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kUniform, Binding(0_a), Group(0)); + GlobalVar(Source{{56, 78}}, "g", a, ast::StorageClass::kUniform, Binding(0_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -481,7 +485,8 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferStructI32) { // struct S { x : i32 }; // var g : S; auto* s = Structure("S", utils::Vector{Member(Source{{12, 34}}, "x", ty.i32())}); - GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), Group(0)); + GlobalVar(Source{{56, 78}}, "g", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), + Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); } @@ -493,7 +498,7 @@ TEST_F(ResolverStorageClassValidationTest, UniformBufferStructI32Aliases) { auto* s = Structure("S", utils::Vector{Member(Source{{12, 34}}, "x", ty.i32())}); auto* a1 = Alias("a1", ty.Of(s)); GlobalVar(Source{{56, 78}}, "g", ty.Of(a1), ast::StorageClass::kUniform, Binding(0_a), - Group(0)); + Group(0_a)); 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 69ea590737..4d709e30f7 100644 --- a/src/tint/resolver/struct_storage_class_use_test.cc +++ b/src/tint/resolver/struct_storage_class_use_test.cc @@ -159,9 +159,9 @@ TEST_F(ResolverStorageClassUseTest, StructReachableViaLocalArray) { TEST_F(ResolverStorageClassUseTest, StructMultipleStorageClassUses) { auto* s = Structure("S", utils::Vector{Member("a", ty.f32())}); - GlobalVar("x", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), Group(0)); + GlobalVar("x", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), Group(0_a)); GlobalVar("y", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(0)); + Group(0_a)); WrapInFunction(Var("g", ty.Of(s))); ASSERT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/type_validation_test.cc b/src/tint/resolver/type_validation_test.cc index 0c76a76cae..39ce5e3bac 100644 --- a/src/tint/resolver/type_validation_test.cc +++ b/src/tint/resolver/type_validation_test.cc @@ -760,7 +760,7 @@ struct DimensionParams { using SampledTextureDimensionTest = ResolverTestWithParam; TEST_P(SampledTextureDimensionTest, All) { auto& params = GetParam(); - GlobalVar(Source{{12, 34}}, "a", ty.sampled_texture(params.dim, ty.i32()), Group(0), + GlobalVar(Source{{12, 34}}, "a", ty.sampled_texture(params.dim, ty.i32()), Group(0_a), Binding(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -778,7 +778,7 @@ INSTANTIATE_TEST_SUITE_P(ResolverTypeValidationTest, using MultisampledTextureDimensionTest = ResolverTestWithParam; TEST_P(MultisampledTextureDimensionTest, All) { auto& params = GetParam(); - GlobalVar("a", ty.multisampled_texture(Source{{12, 34}}, params.dim, ty.i32()), Group(0), + GlobalVar("a", ty.multisampled_texture(Source{{12, 34}}, params.dim, ty.i32()), Group(0_a), Binding(0_a)); if (params.is_valid) { @@ -832,7 +832,7 @@ TEST_P(SampledTextureTypeTest, All) { GlobalVar( "a", ty.sampled_texture(Source{{12, 34}}, ast::TextureDimension::k2d, params.type_func(*this)), - Group(0), Binding(0_a)); + Group(0_a), Binding(0_a)); if (params.is_valid) { EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -851,7 +851,7 @@ TEST_P(MultisampledTextureTypeTest, All) { GlobalVar("a", ty.multisampled_texture(Source{{12, 34}}, ast::TextureDimension::k2d, params.type_func(*this)), - Group(0), Binding(0_a)); + Group(0_a), Binding(0_a)); if (params.is_valid) { EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -890,7 +890,7 @@ TEST_P(StorageTextureDimensionTest, All) { auto* st = ty.storage_texture(Source{{12, 34}}, params.dim, ast::TexelFormat::kR32Uint, ast::Access::kWrite); - GlobalVar("a", st, Group(0), Binding(0_a)); + GlobalVar("a", st, Group(0_a), Binding(0_a)); if (params.is_valid) { EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -940,17 +940,17 @@ TEST_P(StorageTextureFormatTest, All) { auto* st_a = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d, params.format, ast::Access::kWrite); - GlobalVar("a", st_a, Group(0), Binding(0_a)); + GlobalVar("a", st_a, Group(0_a), Binding(0_a)); auto* st_b = ty.storage_texture(ast::TextureDimension::k2d, params.format, ast::Access::kWrite); - GlobalVar("b", st_b, Group(0), Binding(1_a)); + GlobalVar("b", st_b, Group(0_a), Binding(1_a)); auto* st_c = ty.storage_texture(ast::TextureDimension::k2dArray, params.format, ast::Access::kWrite); - GlobalVar("c", st_c, Group(0), Binding(2_a)); + GlobalVar("c", st_c, Group(0_a), Binding(2_a)); auto* st_d = ty.storage_texture(ast::TextureDimension::k3d, params.format, ast::Access::kWrite); - GlobalVar("d", st_d, Group(0), Binding(3_a)); + GlobalVar("d", st_d, Group(0_a), Binding(3_a)); if (params.is_valid) { EXPECT_TRUE(r()->Resolve()) << r()->error(); @@ -974,7 +974,7 @@ TEST_F(StorageTextureAccessTest, MissingAccess_Fail) { auto* st = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d, ast::TexelFormat::kR32Uint, ast::Access::kUndefined); - GlobalVar("a", st, Group(0), Binding(0_a)); + GlobalVar("a", st, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), "12:34 error: storage texture missing access control"); @@ -987,7 +987,7 @@ TEST_F(StorageTextureAccessTest, RWAccess_Fail) { auto* st = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d, ast::TexelFormat::kR32Uint, ast::Access::kReadWrite); - GlobalVar("a", st, Group(0), Binding(0_a)); + GlobalVar("a", st, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -1001,7 +1001,7 @@ TEST_F(StorageTextureAccessTest, ReadOnlyAccess_Fail) { auto* st = ty.storage_texture(Source{{12, 34}}, ast::TextureDimension::k1d, ast::TexelFormat::kR32Uint, ast::Access::kRead); - GlobalVar("a", st, Group(0), Binding(0_a)); + GlobalVar("a", st, Group(0_a), Binding(0_a)); EXPECT_FALSE(r()->Resolve()); EXPECT_EQ(r()->error(), @@ -1015,7 +1015,7 @@ TEST_F(StorageTextureAccessTest, WriteOnlyAccess_Pass) { auto* st = ty.storage_texture(ast::TextureDimension::k1d, ast::TexelFormat::kR32Uint, ast::Access::kWrite); - GlobalVar("a", st, Group(0), Binding(0_a)); + GlobalVar("a", st, Group(0_a), Binding(0_a)); EXPECT_TRUE(r()->Resolve()) << r()->error(); } diff --git a/src/tint/resolver/validation_test.cc b/src/tint/resolver/validation_test.cc index 970e5c9c90..6054cacf4b 100644 --- a/src/tint/resolver/validation_test.cc +++ b/src/tint/resolver/validation_test.cc @@ -329,7 +329,7 @@ TEST_F(ResolverValidationTest, StorageClass_FunctionVariableI32) { TEST_F(ResolverValidationTest, StorageClass_SamplerExplicitStorageClass) { auto* t = ty.sampler(ast::SamplerKind::kSampler); - GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle, Binding(0_a), Group(0)); + GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle, Binding(0_a), Group(0_a)); EXPECT_FALSE(r()->Resolve()); @@ -339,7 +339,7 @@ TEST_F(ResolverValidationTest, StorageClass_SamplerExplicitStorageClass) { TEST_F(ResolverValidationTest, StorageClass_TextureExplicitStorageClass) { auto* t = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32()); - GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle, Binding(0_a), Group(0)); + GlobalVar(Source{{12, 34}}, "var", t, ast::StorageClass::kHandle, Binding(0_a), Group(0_a)); EXPECT_FALSE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/variable_test.cc b/src/tint/resolver/variable_test.cc index 4579581267..52d240ca93 100644 --- a/src/tint/resolver/variable_test.cc +++ b/src/tint/resolver/variable_test.cc @@ -471,7 +471,7 @@ TEST_F(ResolverVariableTest, LocalLet_InheritsAccessFromOriginatingVariable) { auto* inner = Structure("Inner", utils::Vector{Member("arr", ty.array())}); auto* buf = Structure("S", utils::Vector{Member("inner", ty.Of(inner))}); auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, ast::Access::kReadWrite, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 4_i); auto* ptr = Let("p", AddressOf(expr)); @@ -1037,11 +1037,11 @@ TEST_F(ResolverVariableTest, GlobalVar_StorageClass) { 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, Binding(0_a), Group(0)); + GlobalVar("ub", ty.Of(buf), ast::StorageClass::kUniform, Binding(0_a), Group(0_a)); auto* storage = - GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, Binding(1_a), Group(0)); + GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, Binding(1_a), Group(0_a)); auto* handle = - GlobalVar("h", ty.depth_texture(ast::TextureDimension::k2d), Binding(2_a), Group(0)); + GlobalVar("h", ty.depth_texture(ast::TextureDimension::k2d), Binding(2_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); @@ -1063,7 +1063,7 @@ TEST_F(ResolverVariableTest, GlobalVar_ExplicitStorageClass) { auto* buf = Structure("S", utils::Vector{Member("m", ty.i32())}); auto* storage = GlobalVar("sb", ty.Of(buf), ast::StorageClass::kStorage, - ast::Access::kReadWrite, Binding(1_a), Group(0)); + ast::Access::kReadWrite, Binding(1_a), Group(0_a)); ASSERT_TRUE(r()->Resolve()) << r()->error(); diff --git a/src/tint/resolver/variable_validation_test.cc b/src/tint/resolver/variable_validation_test.cc index 6a61465cc2..341690986e 100644 --- a/src/tint/resolver/variable_validation_test.cc +++ b/src/tint/resolver/variable_validation_test.cc @@ -123,7 +123,7 @@ TEST_F(ResolverVariableValidationTest, VarTypeNotConstructible) { TEST_F(ResolverVariableValidationTest, LetTypeNotConstructible) { // @group(0) @binding(0) var t1 : texture_2d; // let t2 : t1; - auto* t1 = GlobalVar("t1", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(0), + auto* t1 = GlobalVar("t1", ty.sampled_texture(ast::TextureDimension::k2d, ty.f32()), Group(0_a), Binding(0_a)); auto* t2 = Let(Source{{56, 78}}, "t2", Expr(t1)); WrapInFunction(t2); @@ -294,7 +294,8 @@ TEST_F(ResolverVariableValidationTest, InferredPtrStorageAccessMismatch) { auto* buf = Structure("S", utils::Vector{ Member("inner", ty.Of(inner)), }); - auto* storage = GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, Binding(0_a), Group(0)); + auto* storage = + GlobalVar("s", ty.Of(buf), ast::StorageClass::kStorage, Binding(0_a), Group(0_a)); auto* expr = IndexAccessor(MemberAccessor(MemberAccessor(storage, "inner"), "arr"), 2_i); auto* ptr = @@ -348,7 +349,7 @@ TEST_F(ResolverVariableValidationTest, NonConstructibleType_InferredType) { // fn foo() { // var v = s; // } - GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(0), Binding(0_a)); + GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(0_a), Binding(0_a)); auto* v = Var(Source{{12, 34}}, "v", Expr("s")); WrapInFunction(v); diff --git a/src/tint/transform/array_length_from_uniform.cc b/src/tint/transform/array_length_from_uniform.cc index 64525a7e03..4f264c4f61 100644 --- a/src/tint/transform/array_length_from_uniform.cc +++ b/src/tint/transform/array_length_from_uniform.cc @@ -148,7 +148,7 @@ void ArrayLengthFromUniform::Run(CloneContext& ctx, const DataMap& inputs, DataM }); buffer_size_ubo = ctx.dst->GlobalVar(ctx.dst->Sym(), ctx.dst->ty.Of(buffer_size_struct), ast::StorageClass::kUniform, - ctx.dst->Group(cfg->ubo_binding.group), + ctx.dst->Group(AInt(cfg->ubo_binding.group)), ctx.dst->Binding(AInt(cfg->ubo_binding.binding))); } return buffer_size_ubo; diff --git a/src/tint/transform/binding_remapper.cc b/src/tint/transform/binding_remapper.cc index 15be81debb..487752ea74 100644 --- a/src/tint/transform/binding_remapper.cc +++ b/src/tint/transform/binding_remapper.cc @@ -106,7 +106,7 @@ void BindingRemapper::Run(CloneContext& ctx, const DataMap& inputs, DataMap&) co auto bp_it = remappings->binding_points.find(from); if (bp_it != remappings->binding_points.end()) { BindingPoint to = bp_it->second; - auto* new_group = ctx.dst->Group(to.group); + auto* new_group = ctx.dst->Group(AInt(to.group)); auto* new_binding = ctx.dst->Binding(AInt(to.binding)); auto* old_group = ast::GetAttribute(var->attributes); diff --git a/src/tint/transform/combine_samplers.cc b/src/tint/transform/combine_samplers.cc index fe66b8ec77..97650ad0f2 100644 --- a/src/tint/transform/combine_samplers.cc +++ b/src/tint/transform/combine_samplers.cc @@ -81,7 +81,7 @@ struct CombineSamplers::State { /// Group 0 and binding 0 are used, with collisions disabled. /// @returns the newly-created attribute list auto Attributes() const { - utils::Vector attributes{ctx.dst->Group(0), + utils::Vector attributes{ctx.dst->Group(0_a), ctx.dst->Binding(0_a)}; attributes.Push(ctx.dst->Disable(ast::DisabledValidation::kBindingPointCollision)); return attributes; diff --git a/src/tint/transform/decompose_strided_array_test.cc b/src/tint/transform/decompose_strided_array_test.cc index 59188a7848..58908fbcf8 100644 --- a/src/tint/transform/decompose_strided_array_test.cc +++ b/src/tint/transform/decompose_strided_array_test.cc @@ -158,7 +158,7 @@ TEST_F(DecomposeStridedArrayTest, ReadUniformStridedArray) { // } ProgramBuilder b; auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(32))}); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ 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", utils::Vector{b.Member("a", b.ty.array(b.ty.vec4(), 4_u, 16))}); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0_a), b.Binding(0_a)); b.Func( "f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -252,7 +252,7 @@ TEST_F(DecomposeStridedArrayTest, ReadStorageStridedArray) { // } ProgramBuilder b; auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(32))}); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, b.Group(0), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ 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", utils::Vector{b.Member("a", b.ty.array(4))}); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, b.Group(0), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ b.Decl(b.Let("a", b.ty.array(4), b.MemberAccessor("s", "a"))), @@ -344,7 +344,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageStridedArray) { // } ProgramBuilder b; auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(32))}); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0), + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -398,7 +398,7 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageDefaultStridedArray) { // } ProgramBuilder b; auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(4))}); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0), + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -450,7 +450,7 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) { // } ProgramBuilder b; auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array(32))}); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0), + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -511,7 +511,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) { ProgramBuilder b; b.Alias("ARR", b.ty.array(32)); auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.type_name("ARR"))}); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0), + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -581,7 +581,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) { b.ty.array(b.ty.type_name("ARR_A"), 3_u, 16), // 4_u, 128)); auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.type_name("ARR_B"))}); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0), + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ diff --git a/src/tint/transform/decompose_strided_matrix_test.cc b/src/tint/transform/decompose_strided_matrix_test.cc index 8668ed28b1..c7a8f59534 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.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ 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.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0_a), b.Binding(0_a)); b.Func( "f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -185,7 +185,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadUniformMatrix_DefaultStride) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0), b.Binding(0_a)); + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ b.Decl(b.Let("x", b.ty.mat2x2(), b.MemberAccessor("s", "m"))), @@ -238,7 +238,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0), + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -295,7 +295,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0), + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func( "f", utils::Empty, b.ty.void_(), @@ -349,7 +349,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0), + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -407,7 +407,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0), + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ @@ -466,7 +466,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) { b.Disable(ast::DisabledValidation::kIgnoreStrideAttribute), }), }); - b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0), + b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0_a), b.Binding(0_a)); b.Func("f", utils::Empty, b.ty.void_(), utils::Vector{ diff --git a/src/tint/transform/first_index_offset.cc b/src/tint/transform/first_index_offset.cc index 0ba5da6b6c..918fd5bb63 100644 --- a/src/tint/transform/first_index_offset.cc +++ b/src/tint/transform/first_index_offset.cc @@ -124,7 +124,7 @@ void FirstIndexOffset::Run(CloneContext& ctx, const DataMap& inputs, DataMap& ou ctx.dst->GlobalVar(buffer_name, ctx.dst->ty.Of(struct_), ast::StorageClass::kUniform, utils::Vector{ ctx.dst->Binding(AInt(ub_binding)), - ctx.dst->Group(ub_group), + ctx.dst->Group(AInt(ub_group)), }); // Fix up all references to the builtins with the offsets diff --git a/src/tint/transform/multiplanar_external_texture.cc b/src/tint/transform/multiplanar_external_texture.cc index 65f5913346..74ce22e166 100644 --- a/src/tint/transform/multiplanar_external_texture.cc +++ b/src/tint/transform/multiplanar_external_texture.cc @@ -131,10 +131,10 @@ struct MultiplanarExternalTexture::State { syms.plane_0 = ctx.Clone(global->symbol); syms.plane_1 = b.Symbols().New("ext_tex_plane_1"); b.GlobalVar(syms.plane_1, b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32()), - b.Group(bps.plane_1.group), b.Binding(AInt(bps.plane_1.binding))); + b.Group(AInt(bps.plane_1.group)), b.Binding(AInt(bps.plane_1.binding))); syms.params = b.Symbols().New("ext_tex_params"); b.GlobalVar(syms.params, b.ty.type_name("ExternalTextureParams"), - ast::StorageClass::kUniform, b.Group(bps.params.group), + ast::StorageClass::kUniform, b.Group(AInt(bps.params.group)), b.Binding(AInt(bps.params.binding))); // Replace the original texture_external binding with a texture_2d diff --git a/src/tint/transform/num_workgroups_from_uniform.cc b/src/tint/transform/num_workgroups_from_uniform.cc index 62983fddcd..b96a2ee14a 100644 --- a/src/tint/transform/num_workgroups_from_uniform.cc +++ b/src/tint/transform/num_workgroups_from_uniform.cc @@ -150,7 +150,7 @@ void NumWorkgroupsFromUniform::Run(CloneContext& ctx, const DataMap& inputs, Dat num_workgroups_ubo = ctx.dst->GlobalVar( ctx.dst->Sym(), ctx.dst->ty.Of(num_workgroups_struct), ast::StorageClass::kUniform, - ctx.dst->Group(group), ctx.dst->Binding(AInt(binding))); + ctx.dst->Group(AInt(group)), ctx.dst->Binding(AInt(binding))); } return num_workgroups_ubo; }; diff --git a/src/tint/transform/vertex_pulling.cc b/src/tint/transform/vertex_pulling.cc index 56b6de7236..40d8d30900 100644 --- a/src/tint/transform/vertex_pulling.cc +++ b/src/tint/transform/vertex_pulling.cc @@ -261,7 +261,7 @@ struct State { // The decorated variable with struct type ctx.dst->GlobalVar(GetVertexBufferName(i), ctx.dst->ty.Of(struct_type), ast::StorageClass::kStorage, ast::Access::kRead, - ctx.dst->Binding(AInt(i)), ctx.dst->Group(cfg.pulling_group)); + ctx.dst->Binding(AInt(i)), ctx.dst->Group(AInt(cfg.pulling_group))); } } diff --git a/src/tint/writer/flatten_bindings_test.cc b/src/tint/writer/flatten_bindings_test.cc index 4cc0c7fca8..64c775f578 100644 --- a/src/tint/writer/flatten_bindings_test.cc +++ b/src/tint/writer/flatten_bindings_test.cc @@ -38,9 +38,9 @@ TEST_F(FlattenBindingsTest, NoBindings) { TEST_F(FlattenBindingsTest, AlreadyFlat) { ProgramBuilder b; - b.GlobalVar("a", b.ty.i32(), ast::StorageClass::kUniform, b.Group(0), b.Binding(0_a)); - b.GlobalVar("b", b.ty.i32(), ast::StorageClass::kUniform, b.Group(0), b.Binding(1_a)); - b.GlobalVar("c", b.ty.i32(), ast::StorageClass::kUniform, b.Group(0), b.Binding(2_a)); + b.GlobalVar("a", b.ty.i32(), ast::StorageClass::kUniform, b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("b", b.ty.i32(), ast::StorageClass::kUniform, b.Group(0_a), b.Binding(1_a)); + b.GlobalVar("c", b.ty.i32(), ast::StorageClass::kUniform, b.Group(0_a), b.Binding(2_a)); Program program(std::move(b)); ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str(); @@ -51,9 +51,9 @@ TEST_F(FlattenBindingsTest, AlreadyFlat) { TEST_F(FlattenBindingsTest, NotFlat_SingleNamespace) { ProgramBuilder b; - b.GlobalVar("a", b.ty.i32(), ast::StorageClass::kUniform, b.Group(0), b.Binding(0_a)); - b.GlobalVar("b", b.ty.i32(), ast::StorageClass::kUniform, b.Group(1), b.Binding(1_a)); - b.GlobalVar("c", b.ty.i32(), ast::StorageClass::kUniform, b.Group(2), b.Binding(2_a)); + b.GlobalVar("a", b.ty.i32(), ast::StorageClass::kUniform, b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("b", b.ty.i32(), ast::StorageClass::kUniform, b.Group(1_a), b.Binding(1_a)); + b.GlobalVar("c", b.ty.i32(), ast::StorageClass::kUniform, b.Group(2_a), b.Binding(2_a)); b.WrapInFunction(b.Expr("a"), b.Expr("b"), b.Expr("c")); Program program(std::move(b)); @@ -84,30 +84,30 @@ TEST_F(FlattenBindingsTest, NotFlat_MultipleNamespaces) { ProgramBuilder b; const size_t num_buffers = 3; - b.GlobalVar("buffer1", b.ty.i32(), ast::StorageClass::kUniform, b.Group(0), b.Binding(0_a)); - b.GlobalVar("buffer2", b.ty.i32(), ast::StorageClass::kStorage, b.Group(1), b.Binding(1_a)); - b.GlobalVar("buffer3", b.ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead, b.Group(2), - b.Binding(2_a)); + b.GlobalVar("buffer1", b.ty.i32(), ast::StorageClass::kUniform, b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("buffer2", b.ty.i32(), ast::StorageClass::kStorage, b.Group(1_a), b.Binding(1_a)); + b.GlobalVar("buffer3", b.ty.i32(), ast::StorageClass::kStorage, ast::Access::kRead, + b.Group(2_a), b.Binding(2_a)); const size_t num_samplers = 2; - b.GlobalVar("sampler1", b.ty.sampler(ast::SamplerKind::kSampler), b.Group(3), b.Binding(3_a)); - b.GlobalVar("sampler2", b.ty.sampler(ast::SamplerKind::kComparisonSampler), b.Group(4), + b.GlobalVar("sampler1", b.ty.sampler(ast::SamplerKind::kSampler), b.Group(3_a), b.Binding(3_a)); + b.GlobalVar("sampler2", b.ty.sampler(ast::SamplerKind::kComparisonSampler), b.Group(4_a), b.Binding(4_a)); const size_t num_textures = 6; b.GlobalVar("texture1", b.ty.sampled_texture(ast::TextureDimension::k2d, b.ty.f32()), - b.Group(5), b.Binding(5_a)); + b.Group(5_a), b.Binding(5_a)); b.GlobalVar("texture2", b.ty.multisampled_texture(ast::TextureDimension::k2d, b.ty.f32()), - b.Group(6), b.Binding(6_a)); + b.Group(6_a), b.Binding(6_a)); b.GlobalVar("texture3", b.ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float, ast::Access::kWrite), - b.Group(7), b.Binding(7_a)); - b.GlobalVar("texture4", b.ty.depth_texture(ast::TextureDimension::k2d), b.Group(8), + b.Group(7_a), b.Binding(7_a)); + b.GlobalVar("texture4", b.ty.depth_texture(ast::TextureDimension::k2d), b.Group(8_a), b.Binding(8_a)); - b.GlobalVar("texture5", b.ty.depth_multisampled_texture(ast::TextureDimension::k2d), b.Group(9), - b.Binding(9_a)); - b.GlobalVar("texture6", b.ty.external_texture(), b.Group(10), b.Binding(10_a)); + b.GlobalVar("texture5", b.ty.depth_multisampled_texture(ast::TextureDimension::k2d), + b.Group(9_a), b.Binding(9_a)); + b.GlobalVar("texture6", b.ty.external_texture(), b.Group(10_a), b.Binding(10_a)); 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 faec018321..718ab43475 100644 --- a/src/tint/writer/generate_external_texture_bindings_test.cc +++ b/src/tint/writer/generate_external_texture_bindings_test.cc @@ -38,7 +38,7 @@ TEST_F(GenerateExternalTextureBindingsTest, None) { TEST_F(GenerateExternalTextureBindingsTest, One) { ProgramBuilder b; - b.GlobalVar("v0", b.ty.external_texture(), b.Group(0), b.Binding(0_a)); + b.GlobalVar("v0", b.ty.external_texture(), b.Group(0_a), b.Binding(0_a)); tint::Program program(std::move(b)); ASSERT_TRUE(program.IsValid()); @@ -54,8 +54,8 @@ TEST_F(GenerateExternalTextureBindingsTest, One) { TEST_F(GenerateExternalTextureBindingsTest, Two_SameGroup) { ProgramBuilder b; - b.GlobalVar("v0", b.ty.external_texture(), b.Group(0), b.Binding(0_a)); - b.GlobalVar("v1", b.ty.external_texture(), b.Group(0), b.Binding(1_a)); + b.GlobalVar("v0", b.ty.external_texture(), b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("v1", b.ty.external_texture(), b.Group(0_a), b.Binding(1_a)); tint::Program program(std::move(b)); ASSERT_TRUE(program.IsValid()); @@ -77,8 +77,8 @@ TEST_F(GenerateExternalTextureBindingsTest, Two_SameGroup) { TEST_F(GenerateExternalTextureBindingsTest, Two_DifferentGroup) { ProgramBuilder b; - b.GlobalVar("v0", b.ty.external_texture(), b.Group(0), b.Binding(0_a)); - b.GlobalVar("v1", b.ty.external_texture(), b.Group(1), b.Binding(0_a)); + b.GlobalVar("v0", b.ty.external_texture(), b.Group(0_a), b.Binding(0_a)); + b.GlobalVar("v1", b.ty.external_texture(), b.Group(1_a), b.Binding(0_a)); tint::Program program(std::move(b)); ASSERT_TRUE(program.IsValid()); @@ -100,11 +100,11 @@ TEST_F(GenerateExternalTextureBindingsTest, Two_DifferentGroup) { TEST_F(GenerateExternalTextureBindingsTest, Two_WithOtherBindingsInSameGroup) { ProgramBuilder b; - b.GlobalVar("v0", b.ty.i32(), b.Group(0), b.Binding(0_a), kUniform); - b.GlobalVar("v1", b.ty.external_texture(), b.Group(0), b.Binding(1_a)); - b.GlobalVar("v2", b.ty.i32(), b.Group(0), b.Binding(2_a), kUniform); - b.GlobalVar("v3", b.ty.external_texture(), b.Group(0), b.Binding(3_a)); - b.GlobalVar("v4", b.ty.i32(), b.Group(0), b.Binding(4_a), kUniform); + b.GlobalVar("v0", b.ty.i32(), b.Group(0_a), b.Binding(0_a), kUniform); + b.GlobalVar("v1", b.ty.external_texture(), b.Group(0_a), b.Binding(1_a)); + b.GlobalVar("v2", b.ty.i32(), b.Group(0_a), b.Binding(2_a), kUniform); + b.GlobalVar("v3", b.ty.external_texture(), b.Group(0_a), b.Binding(3_a)); + b.GlobalVar("v4", b.ty.i32(), b.Group(0_a), b.Binding(4_a), kUniform); tint::Program program(std::move(b)); ASSERT_TRUE(program.IsValid()) << program.Diagnostics().str(); diff --git a/src/tint/writer/glsl/generator_impl_function_test.cc b/src/tint/writer/glsl/generator_impl_function_test.cc index 6b28aec111..24747a91f9 100644 --- a/src/tint/writer/glsl/generator_impl_function_test.cc +++ b/src/tint/writer/glsl/generator_impl_function_test.cc @@ -352,7 +352,7 @@ tint_symbol_2 vert_main2() { TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) { auto* ubo_ty = Structure("UBO", utils::Vector{Member("coord", ty.vec4())}); auto* ubo = - GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, Binding(0_a), Group(1)); + GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, Binding(0_a), Group(1_a)); Func("sub_func", utils::Vector{ @@ -402,7 +402,7 @@ void frag_main() { TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStruct) { auto* s = Structure("Uniforms", utils::Vector{Member("coord", ty.vec4())}); - GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), Group(1)); + GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor(MemberAccessor("uniforms", "coord"), "x")); @@ -443,7 +443,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage }); GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(1)); + Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -490,7 +490,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage }); GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(1)); + Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -538,7 +538,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage }); GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(1)); + Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), utils::Vector{ @@ -583,7 +583,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf }); GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(1)); + Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), utils::Vector{ @@ -623,7 +623,7 @@ void main() { TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_Uniform) { auto* s = Structure("S", utils::Vector{Member("x", ty.f32())}); - GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), Group(1)); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), Group(1_a)); Func("sub_func", utils::Vector{Param("param", ty.f32())}, ty.f32(), utils::Vector{ @@ -669,7 +669,7 @@ void frag_main() { TEST_F(GlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) { auto* s = Structure("S", utils::Vector{Member("x", ty.f32())}); GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(1)); + Group(1_a)); Func("sub_func", utils::Vector{Param("param", ty.f32())}, ty.f32(), utils::Vector{ @@ -895,7 +895,7 @@ TEST_F(GlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())}); GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(0)); + Group(0_a)); { auto* var = Var("v", ty.f32(), MemberAccessor("data", "d")); 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 dd7f0c9e43..1602068541 100644 --- a/src/tint/writer/glsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/glsl/generator_impl_member_accessor_test.cc @@ -92,7 +92,7 @@ class GlslGeneratorImplTest_MemberAccessorBase : public BASE { auto* s = b.Structure("Data", members); b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - b.Group(1), b.Binding(0_a)); + b.Group(1_a), b.Binding(0_a)); } void SetupFunction(utils::VectorRef statements) { diff --git a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc index 5592c05088..f1157f1af7 100644 --- a/src/tint/writer/glsl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/glsl/generator_impl_sanitizer_test.cc @@ -27,7 +27,7 @@ using GlslSanitizerTest = TestHelper; TEST_F(GlslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -66,7 +66,7 @@ TEST_F(GlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { Member(4, "a", ty.array(4)), }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -104,7 +104,7 @@ void main() { TEST_F(GlslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); auto* p = Let("p", AddressOf("b")); auto* p2 = Let("p2", 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 b5cc5f2e67..8c60374da5 100644 --- a/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc +++ b/src/tint/writer/glsl/generator_impl_storage_buffer_test.cc @@ -38,7 +38,7 @@ void TestAlign(ProgramBuilder* ctx) { ctx->Member("louie", ctx->ty.f32(), utils::Vector{ctx->MemberAlign(256_u)}), }); ctx->GlobalVar("nephews", ctx->ty.Of(nephews), ast::StorageClass::kStorage, ctx->Binding(0_a), - ctx->Group(0)); + ctx->Group(0_a)); } TEST_F(GlslGeneratorImplTest_StorageBuffer, Align) { diff --git a/src/tint/writer/glsl/generator_impl_type_test.cc b/src/tint/writer/glsl/generator_impl_type_test.cc index ebfc10584e..15c139810b 100644 --- a/src/tint/writer/glsl/generator_impl_type_test.cc +++ b/src/tint/writer/glsl/generator_impl_type_test.cc @@ -312,7 +312,7 @@ TEST_P(GlslDepthTexturesTest, Emit) { auto* t = ty.depth_texture(params.dim); - GlobalVar("tex", t, Binding(1_a), Group(2)); + GlobalVar("tex", t, Binding(1_a), Group(2_a)); Func("main", utils::Empty, ty.void_(), utils::Vector{ @@ -340,7 +340,7 @@ using GlslDepthMultisampledTexturesTest = TestHelper; TEST_F(GlslDepthMultisampledTexturesTest, Emit) { auto* t = ty.depth_multisampled_texture(ast::TextureDimension::k2d); - GlobalVar("tex", t, Binding(1_a), Group(2)); + GlobalVar("tex", t, Binding(1_a), Group(2_a)); Func("main", utils::Empty, ty.void_(), utils::Vector{ @@ -384,7 +384,7 @@ TEST_P(GlslSampledTexturesTest, Emit) { } auto* t = ty.sampled_texture(params.dim, datatype); - GlobalVar("tex", t, Binding(1_a), Group(2)); + GlobalVar("tex", t, Binding(1_a), Group(2_a)); Func("main", utils::Empty, ty.void_(), utils::Vector{ @@ -519,7 +519,7 @@ TEST_P(GlslStorageTexturesTest, Emit) { auto* t = ty.storage_texture(params.dim, params.imgfmt, ast::Access::kWrite); - GlobalVar("tex", t, Binding(1_a), Group(2)); + GlobalVar("tex", t, Binding(1_a), Group(2_a)); Func("main", utils::Empty, ty.void_(), utils::Vector{ 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 f4ab30133f..555e23795e 100644 --- a/src/tint/writer/glsl/generator_impl_uniform_buffer_test.cc +++ b/src/tint/writer/glsl/generator_impl_uniform_buffer_test.cc @@ -26,7 +26,7 @@ using GlslGeneratorImplTest_UniformBuffer = TestHelper; TEST_F(GlslGeneratorImplTest_UniformBuffer, Simple) { auto* simple = Structure("Simple", utils::Vector{Member("member", ty.f32())}); - GlobalVar("simple", ty.Of(simple), ast::StorageClass::kUniform, Group(0), Binding(0_a)); + GlobalVar("simple", ty.Of(simple), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); GeneratorImpl& gen = Build(); @@ -46,7 +46,7 @@ layout(binding = 0) uniform Simple_1 { TEST_F(GlslGeneratorImplTest_UniformBuffer, Simple_Desktop) { auto* simple = Structure("Simple", utils::Vector{Member("member", ty.f32())}); - GlobalVar("simple", ty.Of(simple), ast::StorageClass::kUniform, Group(0), Binding(0_a)); + GlobalVar("simple", ty.Of(simple), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); GeneratorImpl& gen = Build(Version(Version::Standard::kDesktop, 4, 4)); diff --git a/src/tint/writer/hlsl/generator_impl_function_test.cc b/src/tint/writer/hlsl/generator_impl_function_test.cc index 48a259aeb3..c1124a58d9 100644 --- a/src/tint/writer/hlsl/generator_impl_function_test.cc +++ b/src/tint/writer/hlsl/generator_impl_function_test.cc @@ -361,7 +361,7 @@ tint_symbol_1 vert_main2() { TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_Uniform) { auto* ubo_ty = Structure("UBO", utils::Vector{Member("coord", ty.vec4())}); auto* ubo = - GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, Binding(0_a), Group(1)); + GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, Binding(0_a), Group(1_a)); Func("sub_func", utils::Vector{ @@ -404,7 +404,7 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_UniformStruct) { auto* s = Structure("Uniforms", utils::Vector{Member("coord", ty.vec4())}); - GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), Group(1)); + GlobalVar("uniforms", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor(MemberAccessor("uniforms", "coord"), "x")); @@ -438,7 +438,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RW_Storage }); GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(1)); + Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -471,7 +471,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_RO_Storage }); GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(1)); + Group(1_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -504,7 +504,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_WO_Storage }); GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(1)); + Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), utils::Vector{ @@ -535,7 +535,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_EntryPoint_With_StorageBuf }); GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(1)); + Group(1_a)); Func("frag_main", utils::Empty, ty.void_(), utils::Vector{ @@ -561,7 +561,7 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_Uniform) { auto* s = Structure("S", utils::Vector{Member("x", ty.f32())}); - GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), Group(1)); + GlobalVar("coord", ty.Of(s), ast::StorageClass::kUniform, Binding(0_a), Group(1_a)); Func("sub_func", utils::Vector{ @@ -604,7 +604,7 @@ void frag_main() { TEST_F(HlslGeneratorImplTest_Function, Emit_Attribute_Called_By_EntryPoint_With_StorageBuffer) { auto* s = Structure("S", utils::Vector{Member("x", ty.f32())}); GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(1)); + Group(1_a)); Func("sub_func", utils::Vector{ @@ -847,7 +847,7 @@ TEST_F(HlslGeneratorImplTest_Function, Emit_Multiple_EntryPoint_With_Same_Module auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())}); GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(0)); + Group(0_a)); { auto* var = Var("v", ty.f32(), MemberAccessor("data", "d")); 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 19aa0d835c..9ca2d18dbf 100644 --- a/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc +++ b/src/tint/writer/hlsl/generator_impl_member_accessor_test.cc @@ -91,7 +91,7 @@ class HlslGeneratorImplTest_MemberAccessorBase : public BASE { auto* s = b.Structure("Data", members); b.GlobalVar("data", b.ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - b.Group(1), b.Binding(0_a)); + b.Group(1_a), b.Binding(0_a)); } void SetupFunction(utils::VectorRef statements) { diff --git a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc index c7262ccc6d..b9ebd87710 100644 --- a/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/hlsl/generator_impl_sanitizer_test.cc @@ -27,7 +27,7 @@ using HlslSanitizerTest = TestHelper; TEST_F(HlslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -61,7 +61,7 @@ TEST_F(HlslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { Member(4, "a", ty.array(4)), }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -93,7 +93,7 @@ void a_func() { TEST_F(HlslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); auto* p = Let("p", AddressOf("b")); auto* p2 = Let("p2", AddressOf(MemberAccessor(Deref(p), "a"))); @@ -130,9 +130,9 @@ void a_func() { TEST_F(HlslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(2_a), - Group(2)); + Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ diff --git a/src/tint/writer/hlsl/generator_impl_type_test.cc b/src/tint/writer/hlsl/generator_impl_type_test.cc index 22c26ddf9e..279eb3fd10 100644 --- a/src/tint/writer/hlsl/generator_impl_type_test.cc +++ b/src/tint/writer/hlsl/generator_impl_type_test.cc @@ -178,7 +178,7 @@ TEST_F(HlslGeneratorImplTest_Type, EmitType_StructDecl_OmittedIfStorageBuffer) { Member("b", ty.f32()), }); GlobalVar("g", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(0)); + Group(0_a)); GeneratorImpl& gen = Build(); @@ -308,7 +308,7 @@ TEST_P(HlslDepthTexturesTest, Emit) { auto* t = ty.depth_texture(params.dim); - GlobalVar("tex", t, Binding(1_a), Group(2)); + GlobalVar("tex", t, Binding(1_a), Group(2_a)); Func("main", utils::Empty, ty.void_(), utils::Vector{ @@ -339,7 +339,7 @@ using HlslDepthMultisampledTexturesTest = TestHelper; TEST_F(HlslDepthMultisampledTexturesTest, Emit) { auto* t = ty.depth_multisampled_texture(ast::TextureDimension::k2d); - GlobalVar("tex", t, Binding(1_a), Group(2)); + GlobalVar("tex", t, Binding(1_a), Group(2_a)); Func("main", utils::Empty, ty.void_(), utils::Vector{ @@ -383,7 +383,7 @@ TEST_P(HlslSampledTexturesTest, Emit) { } auto* t = ty.sampled_texture(params.dim, datatype); - GlobalVar("tex", t, Binding(1_a), Group(2)); + GlobalVar("tex", t, Binding(1_a), Group(2_a)); Func("main", utils::Empty, ty.void_(), utils::Vector{ @@ -521,7 +521,7 @@ TEST_P(HlslStorageTexturesTest, Emit) { GlobalVar("tex", t, utils::Vector{ - Group(2), + Group(2_a), Binding(1_a), }); diff --git a/src/tint/writer/msl/generator_impl_function_test.cc b/src/tint/writer/msl/generator_impl_function_test.cc index f5b75c9b3a..fd612b3615 100644 --- a/src/tint/writer/msl/generator_impl_function_test.cc +++ b/src/tint/writer/msl/generator_impl_function_test.cc @@ -342,7 +342,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RW_StorageBu Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Group(0), + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Group(0_a), Binding(0_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -381,7 +381,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_EntryPoint_With_RO_StorageBu Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Group(0), + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Group(0_a), Binding(0_a)); auto* var = Var("v", ty.f32(), MemberAccessor("coord", "b")); @@ -417,7 +417,7 @@ fragment void frag_main(const device Data* tint_symbol [[buffer(0)]]) { TEST_F(MslGeneratorImplTest, Emit_Attribute_Called_By_EntryPoint_With_Uniform) { auto* ubo_ty = Structure("UBO", utils::Vector{Member("coord", ty.vec4())}); auto* ubo = - GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, Group(0), Binding(0_a)); + GlobalVar("ubo", ty.Of(ubo_ty), ast::StorageClass::kUniform, Group(0_a), Binding(0_a)); Func("sub_func", utils::Vector{ @@ -467,7 +467,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RW Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Group(0), + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Group(0_a), Binding(0_a)); Func("sub_func", @@ -519,7 +519,7 @@ TEST_F(MslGeneratorImplTest, Emit_FunctionAttribute_Called_By_EntryPoint_With_RO Member("b", ty.f32()), }); - GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Group(0), + GlobalVar("coord", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Group(0_a), Binding(0_a)); Func("sub_func", @@ -657,7 +657,7 @@ TEST_F(MslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_ModuleV auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())}); - GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Group(0), + GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Group(0_a), Binding(0_a)); { diff --git a/src/tint/writer/msl/generator_impl_sanitizer_test.cc b/src/tint/writer/msl/generator_impl_sanitizer_test.cc index 6b4f927ac4..f96a1c904f 100644 --- a/src/tint/writer/msl/generator_impl_sanitizer_test.cc +++ b/src/tint/writer/msl/generator_impl_sanitizer_test.cc @@ -29,7 +29,7 @@ using MslSanitizerTest = TestHelper; TEST_F(MslSanitizerTest, Call_ArrayLength) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -83,7 +83,7 @@ TEST_F(MslSanitizerTest, Call_ArrayLength_OtherMembersInStruct) { Member(4, "a", ty.array(4)), }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -136,7 +136,7 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(30)]]) { TEST_F(MslSanitizerTest, Call_ArrayLength_ViaLets) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); auto* p = Let("p", AddressOf("b")); auto* p2 = Let("p2", AddressOf(MemberAccessor(Deref(p), "a"))); @@ -193,9 +193,9 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(30)]]) { TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniform) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(0)); + Group(0_a)); GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(2_a), - Group(0)); + Group(0_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -252,9 +252,9 @@ fragment void a_func(const constant tint_symbol* tint_symbol_2 [[buffer(29)]]) { TEST_F(MslSanitizerTest, Call_ArrayLength_ArrayLengthFromUniformMissingBinding) { auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array(4))}); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(0)); + Group(0_a)); GlobalVar("c", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(2_a), - Group(0)); + Group(0_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ diff --git a/src/tint/writer/msl/generator_impl_type_test.cc b/src/tint/writer/msl/generator_impl_type_test.cc index 6ad7832cd3..a6901b4cb1 100644 --- a/src/tint/writer/msl/generator_impl_type_test.cc +++ b/src/tint/writer/msl/generator_impl_type_test.cc @@ -283,7 +283,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_NonComposites) { }); GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); GeneratorImpl& gen = Build(); @@ -390,7 +390,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_Structures) { }); GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); GeneratorImpl& gen = Build(); @@ -481,7 +481,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayDefaultStride) { }); GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); GeneratorImpl& gen = Build(); @@ -564,7 +564,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_Layout_ArrayVec3DefaultStride) { }); GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); GeneratorImpl& gen = Build(); @@ -625,7 +625,7 @@ TEST_F(MslGeneratorImplTest, AttemptTintPadSymbolCollision) { }); GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); GeneratorImpl& gen = Build(); @@ -683,7 +683,7 @@ TEST_F(MslGeneratorImplTest, EmitType_Struct_WithAttribute) { }); GlobalVar("G", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); GeneratorImpl& gen = Build(); @@ -846,7 +846,7 @@ TEST_P(MslStorageTexturesTest, Emit) { auto params = GetParam(); auto* s = ty.storage_texture(params.dim, ast::TexelFormat::kR32Float, ast::Access::kWrite); - GlobalVar("test_var", s, Binding(0_a), Group(0)); + GlobalVar("test_var", s, Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/spirv/builder_builtin_test.cc b/src/tint/writer/spirv/builder_builtin_test.cc index 5dc2401adc..cfb85d9cd6 100644 --- a/src/tint/writer/spirv/builder_builtin_test.cc +++ b/src/tint/writer/spirv/builder_builtin_test.cc @@ -43,8 +43,8 @@ TEST_F(BuiltinBuilderTest, Call_TextureSampleCompare_Twice) { auto* s = ty.sampler(ast::SamplerKind::kComparisonSampler); auto* t = ty.depth_texture(ast::TextureDimension::k2d); - auto* tex = GlobalVar("texture", t, Binding(0_a), Group(0)); - auto* sampler = GlobalVar("sampler", s, Binding(1_a), Group(0)); + auto* tex = GlobalVar("texture", t, Binding(0_a), Group(0_a)); + auto* sampler = GlobalVar("sampler", s, Binding(1_a), Group(0_a)); 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); @@ -278,7 +278,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength) { Member("a", ty.array(4)), }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a"))); Func("a_func", utils::Empty, ty.void_(), @@ -322,7 +322,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_OtherMembersInStruct) { Member(4, "a", ty.array(4)), }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); auto* expr = Call("arrayLength", AddressOf(MemberAccessor("b", "a"))); Func("a_func", utils::Empty, ty.void_(), @@ -365,7 +365,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets) { Member("a", ty.array(4)), }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); auto* p = Let("p", AddressOf("b")); auto* p2 = Let("p2", AddressOf(MemberAccessor(Deref(p), "a"))); @@ -424,7 +424,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength_ViaLets_WithPtrNoise) { Member("a", ty.array(4)), }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, Binding(1_a), - Group(2)); + Group(2_a)); auto* p = Let("p", AddressOf(Deref(AddressOf("b")))); auto* p2 = Let("p2", AddressOf(Deref(p))); @@ -3224,7 +3224,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicLoad) { Member("i", ty.atomic()), }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(1_a), - Group(2)); + Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3287,7 +3287,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicStore) { Member("i", ty.atomic()), }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(1_a), - Group(2)); + Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3358,7 +3358,7 @@ TEST_P(Builtin_Builder_AtomicRMW_i32, Test) { Member("v", ty.atomic()), }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(1_a), - Group(2)); + Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3430,7 +3430,7 @@ TEST_P(Builtin_Builder_AtomicRMW_u32, Test) { Member("v", ty.atomic()), }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(1_a), - Group(2)); + Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3504,7 +3504,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicExchange) { Member("i", ty.atomic()), }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(1_a), - Group(2)); + Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ @@ -3579,7 +3579,7 @@ TEST_F(BuiltinBuilderTest, Call_AtomicCompareExchangeWeak) { Member("i", ty.atomic()), }); GlobalVar("b", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(1_a), - Group(2)); + Group(2_a)); Func("a_func", utils::Empty, ty.void_(), utils::Vector{ diff --git a/src/tint/writer/spirv/builder_function_test.cc b/src/tint/writer/spirv/builder_function_test.cc index 8a0bebfaa4..449f937e9a 100644 --- a/src/tint/writer/spirv/builder_function_test.cc +++ b/src/tint/writer/spirv/builder_function_test.cc @@ -199,7 +199,7 @@ TEST_F(BuilderTest, Emit_Multiple_EntryPoint_With_Same_ModuleVar) { auto* s = Structure("Data", utils::Vector{Member("d", ty.f32())}); GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(0)); + Group(0_a)); { auto* var = Var("v", ty.f32(), 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 996f0b779b..e4a6a48976 100644 --- a/src/tint/writer/spirv/builder_global_variable_test.cc +++ b/src/tint/writer/spirv/builder_global_variable_test.cc @@ -233,7 +233,7 @@ TEST_F(BuilderTest, GlobalConst_Nested_Vec_Constructor) { } TEST_F(BuilderTest, GlobalVar_WithBindingAndGroup) { - auto* v = GlobalVar("var", ty.sampler(ast::SamplerKind::kSampler), Binding(2_a), Group(3)); + auto* v = GlobalVar("var", ty.sampler(ast::SamplerKind::kSampler), Binding(2_a), Group(3_a)); spirv::Builder& b = Build(); @@ -448,7 +448,7 @@ TEST_F(BuilderTest, GlobalVar_DeclReadOnly) { }); GlobalVar("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -486,7 +486,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasDeclReadOnly) { auto* A = Structure("A", utils::Vector{Member("a", ty.i32())}); auto* B = Alias("B", ty.Of(A)); GlobalVar("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -522,7 +522,7 @@ TEST_F(BuilderTest, GlobalVar_TypeAliasAssignReadOnly) { auto* A = Structure("A", utils::Vector{Member("a", ty.i32())}); auto* B = Alias("B", ty.Of(A)); GlobalVar("b", ty.Of(B), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -556,9 +556,9 @@ TEST_F(BuilderTest, GlobalVar_TwoVarDeclReadOnly) { // var c : A auto* A = Structure("A", utils::Vector{Member("a", ty.i32())}); - GlobalVar("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead, Group(0), + GlobalVar("b", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kRead, Group(0_a), Binding(0_a)); - GlobalVar("c", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kReadWrite, Group(1), + GlobalVar("c", ty.Of(A), ast::StorageClass::kStorage, ast::Access::kReadWrite, Group(1_a), Binding(0_a)); spirv::Builder& b = SanitizeAndBuild(); @@ -596,7 +596,7 @@ TEST_F(BuilderTest, GlobalVar_TextureStorageWriteOnly) { auto* type = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint, ast::Access::kWrite); - auto* var_a = GlobalVar("a", type, Binding(0_a), Group(0)); + auto* var_a = GlobalVar("a", type, Binding(0_a), Group(0_a)); spirv::Builder& b = Build(); @@ -623,11 +623,11 @@ TEST_F(BuilderTest, DISABLED_GlobalVar_TextureStorageWithDifferentAccess) { auto* type_a = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint, ast::Access::kReadWrite); - auto* var_a = GlobalVar("a", type_a, Binding(0_a), Group(0)); + auto* var_a = GlobalVar("a", type_a, Binding(0_a), Group(0_a)); auto* type_b = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint, ast::Access::kWrite); - auto* var_b = GlobalVar("b", type_b, Binding(1_a), Group(0)); + auto* var_b = GlobalVar("b", type_b, Binding(1_a), Group(0_a)); spirv::Builder& b = Build(); diff --git a/src/tint/writer/spirv/builder_type_test.cc b/src/tint/writer/spirv/builder_type_test.cc index 51a9cd5a3a..9b6126842f 100644 --- a/src/tint/writer/spirv/builder_type_test.cc +++ b/src/tint/writer/spirv/builder_type_test.cc @@ -29,7 +29,7 @@ TEST_F(BuilderTest_Type, GenerateRuntimeArray) { auto* ary = ty.array(ty.i32()); auto* str = Structure("S", utils::Vector{Member("x", ary)}); GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); spirv::Builder& b = Build(); @@ -46,7 +46,7 @@ TEST_F(BuilderTest_Type, ReturnsGeneratedRuntimeArray) { auto* ary = ty.array(ty.i32()); auto* str = Structure("S", utils::Vector{Member("x", ary)}); GlobalVar("a", ty.Of(str), ast::StorageClass::kStorage, ast::Access::kRead, Binding(0_a), - Group(0)); + Group(0_a)); spirv::Builder& b = Build(); @@ -836,7 +836,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_1d) { auto* s = ty.storage_texture(ast::TextureDimension::k1d, ast::TexelFormat::kR32Float, ast::Access::kWrite); - GlobalVar("test_var", s, Binding(0_a), Group(0)); + GlobalVar("test_var", s, Binding(0_a), Group(0_a)); spirv::Builder& b = Build(); @@ -851,7 +851,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2d) { auto* s = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float, ast::Access::kWrite); - GlobalVar("test_var", s, Binding(0_a), Group(0)); + GlobalVar("test_var", s, Binding(0_a), Group(0_a)); spirv::Builder& b = Build(); @@ -866,7 +866,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_2dArray) { auto* s = ty.storage_texture(ast::TextureDimension::k2dArray, ast::TexelFormat::kR32Float, ast::Access::kWrite); - GlobalVar("test_var", s, Binding(0_a), Group(0)); + GlobalVar("test_var", s, Binding(0_a), Group(0_a)); spirv::Builder& b = Build(); @@ -881,7 +881,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_3d) { auto* s = ty.storage_texture(ast::TextureDimension::k3d, ast::TexelFormat::kR32Float, ast::Access::kWrite); - GlobalVar("test_var", s, Binding(0_a), Group(0)); + GlobalVar("test_var", s, Binding(0_a), Group(0_a)); spirv::Builder& b = Build(); @@ -896,7 +896,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeFloat_Format_r32floa auto* s = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Float, ast::Access::kWrite); - GlobalVar("test_var", s, Binding(0_a), Group(0)); + GlobalVar("test_var", s, Binding(0_a), Group(0_a)); spirv::Builder& b = Build(); @@ -911,7 +911,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeSint_Format_r32sint) auto* s = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Sint, ast::Access::kWrite); - GlobalVar("test_var", s, Binding(0_a), Group(0)); + GlobalVar("test_var", s, Binding(0_a), Group(0_a)); spirv::Builder& b = Build(); @@ -926,7 +926,7 @@ TEST_F(BuilderTest_Type, StorageTexture_Generate_SampledTypeUint_Format_r32uint) auto* s = ty.storage_texture(ast::TextureDimension::k2d, ast::TexelFormat::kR32Uint, ast::Access::kWrite); - GlobalVar("test_var", s, Binding(0_a), Group(0)); + GlobalVar("test_var", s, Binding(0_a), Group(0_a)); spirv::Builder& b = Build(); diff --git a/src/tint/writer/wgsl/generator_impl.cc b/src/tint/writer/wgsl/generator_impl.cc index 7b619cd7b8..755fe6bc9b 100644 --- a/src/tint/writer/wgsl/generator_impl.cc +++ b/src/tint/writer/wgsl/generator_impl.cc @@ -748,7 +748,11 @@ bool GeneratorImpl::EmitAttributes(std::ostream& out, return true; }, [&](const ast::GroupAttribute* group) { - out << "group(" << group->value << ")"; + out << "group("; + if (!EmitExpression(out, group->value)) { + return false; + } + out << ")"; return true; }, [&](const ast::LocationAttribute* location) { diff --git a/src/tint/writer/wgsl/generator_impl_function_test.cc b/src/tint/writer/wgsl/generator_impl_function_test.cc index dc189721ad..3b80e6990b 100644 --- a/src/tint/writer/wgsl/generator_impl_function_test.cc +++ b/src/tint/writer/wgsl/generator_impl_function_test.cc @@ -180,7 +180,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Function_Multiple_EntryPoint_With_Same_Module }); GlobalVar("data", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, Binding(0_a), - Group(0)); + Group(0_a)); { auto* var = Var("v", ty.f32(), 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 6c87cab7e9..06a5e19405 100644 --- a/src/tint/writer/wgsl/generator_impl_global_decl_test.cc +++ b/src/tint/writer/wgsl/generator_impl_global_decl_test.cc @@ -105,7 +105,7 @@ TEST_F(WgslGeneratorImplTest, Emit_GlobalsInterleaved) { } TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) { - GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(0), Binding(0_a)); + GlobalVar("s", ty.sampler(ast::SamplerKind::kSampler), Group(0_a), Binding(0_a)); GeneratorImpl& gen = Build(); @@ -117,7 +117,7 @@ TEST_F(WgslGeneratorImplTest, Emit_Global_Sampler) { TEST_F(WgslGeneratorImplTest, Emit_Global_Texture) { auto* st = ty.sampled_texture(ast::TextureDimension::k1d, ty.f32()); - GlobalVar("t", st, Group(0), Binding(0_a)); + GlobalVar("t", st, Group(0_a), Binding(0_a)); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/wgsl/generator_impl_type_test.cc b/src/tint/writer/wgsl/generator_impl_type_test.cc index 66538e941a..53900572ed 100644 --- a/src/tint/writer/wgsl/generator_impl_type_test.cc +++ b/src/tint/writer/wgsl/generator_impl_type_test.cc @@ -462,7 +462,7 @@ TEST_P(WgslGenerator_StorageTextureTest, EmitType_StorageTexture) { auto param = GetParam(); auto* t = ty.storage_texture(param.dim, param.fmt, param.access); - GlobalVar("g", t, Binding(1_a), Group(2)); + GlobalVar("g", t, Binding(1_a), Group(2_a)); GeneratorImpl& gen = Build(); diff --git a/src/tint/writer/wgsl/generator_impl_variable_test.cc b/src/tint/writer/wgsl/generator_impl_variable_test.cc index 66b2644037..f1ac216a05 100644 --- a/src/tint/writer/wgsl/generator_impl_variable_test.cc +++ b/src/tint/writer/wgsl/generator_impl_variable_test.cc @@ -44,7 +44,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_StorageClass) { TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Read) { auto* s = Structure("S", utils::Vector{Member("a", ty.i32())}); auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kRead, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -56,7 +56,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_Read) { TEST_F(WgslGeneratorImplTest, EmitVariable_Access_ReadWrite) { auto* s = Structure("S", utils::Vector{Member("a", ty.i32())}); auto* v = GlobalVar("a", ty.Of(s), ast::StorageClass::kStorage, ast::Access::kReadWrite, - Binding(0_a), Group(0)); + Binding(0_a), Group(0_a)); GeneratorImpl& gen = Build(); @@ -66,7 +66,7 @@ TEST_F(WgslGeneratorImplTest, EmitVariable_Access_ReadWrite) { } TEST_F(WgslGeneratorImplTest, EmitVariable_Decorated) { - auto* v = GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler), Group(1), Binding(2_a)); + auto* v = GlobalVar("a", ty.sampler(ast::SamplerKind::kSampler), Group(1_a), Binding(2_a)); GeneratorImpl& gen = Build();