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 <bclayton@google.com> Commit-Queue: Dan Sinclair <dsinclair@chromium.org> Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
parent
f9b831c39a
commit
be4c9f48aa
|
@ -142,7 +142,7 @@ const ast::Type* TextureOverloadCase::BuildResultVectorComponentType(ProgramBuil
|
|||
|
||||
const ast::Variable* TextureOverloadCase::BuildTextureVariable(ProgramBuilder* b) const {
|
||||
utils::Vector attrs{
|
||||
b->create<ast::GroupAttribute>(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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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<GroupAttribute>(src, value);
|
||||
auto* value_ = ctx->Clone(value);
|
||||
return ctx->dst->create<GroupAttribute>(src, value_);
|
||||
}
|
||||
|
||||
} // namespace tint::ast
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
#include <string>
|
||||
|
||||
#include "src/tint/ast/attribute.h"
|
||||
#include "src/tint/ast/expression.h"
|
||||
|
||||
namespace tint::ast {
|
||||
|
||||
|
@ -28,8 +29,8 @@ class GroupAttribute final : public Castable<GroupAttribute, Attribute> {
|
|||
/// @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<GroupAttribute, Attribute> {
|
|||
/// @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
|
||||
|
|
|
@ -17,11 +17,12 @@
|
|||
namespace tint::ast {
|
||||
namespace {
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
using GroupAttributeTest = TestHelper;
|
||||
|
||||
TEST_F(GroupAttributeTest, Creation) {
|
||||
auto* d = create<GroupAttribute>(2u);
|
||||
EXPECT_EQ(2u, d->value);
|
||||
auto* d = Group(2_a);
|
||||
EXPECT_TRUE(d->value->Is<IntLiteralExpression>());
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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<ast::GroupAttribute>(value); }
|
||||
template <typename EXPR>
|
||||
const ast::GroupAttribute* Group(EXPR&& value) {
|
||||
return create<ast::GroupAttribute>(Expr(std::forward<EXPR>(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<ast::GroupAttribute>(source, value);
|
||||
template <typename EXPR>
|
||||
const ast::GroupAttribute* Group(const Source& source, EXPR&& value) {
|
||||
return create<ast::GroupAttribute>(source, Expr(std::forward<EXPR>(value)));
|
||||
}
|
||||
|
||||
/// Creates the ast::BindingAttribute
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -3493,7 +3493,9 @@ Maybe<const ast::Attribute*> ParserImpl::attribute() {
|
|||
}
|
||||
match(Token::Type::kComma);
|
||||
|
||||
return create<ast::GroupAttribute>(t.source(), val.value);
|
||||
return create<ast::GroupAttribute>(
|
||||
t.source(), create<ast::IntLiteralExpression>(
|
||||
val.value, ast::IntLiteralExpression::Suffix::kNone));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -442,7 +442,11 @@ TEST_F(ParserImplTest, Attribute_group) {
|
|||
ASSERT_TRUE(var_attr->Is<ast::GroupAttribute>());
|
||||
|
||||
auto* group = var_attr->As<ast::GroupAttribute>();
|
||||
EXPECT_EQ(group->value, 4u);
|
||||
ASSERT_TRUE(group->value->Is<ast::IntLiteralExpression>());
|
||||
|
||||
auto* expr = group->value->As<ast::IntLiteralExpression>();
|
||||
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<ast::GroupAttribute>());
|
||||
|
||||
auto* group = var_attr->As<ast::GroupAttribute>();
|
||||
EXPECT_EQ(group->value, 4u);
|
||||
ASSERT_TRUE(group->value->Is<ast::IntLiteralExpression>());
|
||||
|
||||
auto* expr = group->value->As<ast::IntLiteralExpression>();
|
||||
EXPECT_EQ(expr->value, 4);
|
||||
EXPECT_EQ(expr->suffix, ast::IntLiteralExpression::Suffix::kNone);
|
||||
}
|
||||
|
||||
TEST_F(ParserImplTest, Attribute_Group_MissingLeftParen) {
|
||||
|
|
|
@ -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<i32>()),
|
||||
});
|
||||
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<i32>()),
|
||||
});
|
||||
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<f32, 10>(), ast::StorageClass::kWorkgroup);
|
||||
|
||||
WrapInFunction(Assign(Phony(), 1_i), //
|
||||
|
|
|
@ -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<sem::Reference>());
|
||||
|
|
|
@ -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(),
|
||||
|
|
|
@ -95,7 +95,7 @@ static utils::Vector<const ast::Attribute*, 2> 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<ast::IdAttribute>(source, 0u)};
|
||||
case AttributeKind::kInterpolate:
|
||||
|
@ -116,7 +116,7 @@ static utils::Vector<const ast::Attribute*, 2> createAttributes(const Source& so
|
|||
case AttributeKind::kWorkgroup:
|
||||
return {builder.create<ast::WorkgroupAttribute>(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(),
|
||||
|
|
|
@ -213,7 +213,7 @@ TEST_F(ResolverBuiltinArrayTest, ArrayLength_Vector) {
|
|||
auto* ary = ty.array<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));
|
||||
|
||||
auto* call = Call("arrayLength", AddressOf(MemberAccessor("a", "x")));
|
||||
WrapInFunction(call);
|
||||
|
@ -2143,7 +2143,7 @@ class ResolverBuiltinTest_TextureOperation : public ResolverTestWithParam<Textur
|
|||
|
||||
void add_call_param(std::string name, const ast::Type* type, ExpressionList* call_params) {
|
||||
if (type->IsAnyOf<ast::Texture, ast::Sampler>()) {
|
||||
GlobalVar(name, type, Binding(0_a), Group(0));
|
||||
GlobalVar(name, type, Binding(0_a), Group(0_a));
|
||||
|
||||
} else {
|
||||
GlobalVar(name, type, ast::StorageClass::kPrivate);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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<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());
|
||||
|
||||
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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));
|
||||
|
|
|
@ -54,7 +54,7 @@ TEST_F(ResolverPtrRefValidationTest, AddressOfLet) {
|
|||
TEST_F(ResolverPtrRefValidationTest, AddressOfHandle) {
|
||||
// @group(0) @binding(0) var t: texture_3d<f32>;
|
||||
// &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<f32>;
|
||||
// *&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<i32, 4>())});
|
||||
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 =
|
||||
|
|
|
@ -598,8 +598,17 @@ sem::Variable* Resolver::Var(const ast::Var* var, bool is_global) {
|
|||
uint32_t group = 0;
|
||||
{
|
||||
auto* attr = ast::GetAttribute<ast::GroupAttribute>(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<uint32_t>();
|
||||
}
|
||||
binding_point = {group, binding};
|
||||
}
|
||||
|
@ -669,8 +678,17 @@ sem::Parameter* Resolver::Parameter(const ast::Parameter* param, uint32_t index)
|
|||
}
|
||||
{
|
||||
auto* attr = ast::GetAttribute<ast::GroupAttribute>(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<uint32_t>();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<storage> 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<f32>(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<f32>(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<f32>(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<f32>(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");
|
||||
|
|
|
@ -174,26 +174,26 @@ TEST_P(SideEffectsBuiltinTest, Test) {
|
|||
GlobalVar("vb", ty.vec3<bool>(), ast::StorageClass::kPrivate);
|
||||
GlobalVar("m", ty.mat3x3<f32>(), ast::StorageClass::kPrivate);
|
||||
GlobalVar("arr", ty.array<f32, 10>(), ast::StorageClass::kPrivate);
|
||||
GlobalVar("storage_arr", ty.array<f32>(), ast::StorageClass::kStorage, Group(0),
|
||||
GlobalVar("storage_arr", ty.array<f32>(), 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++)));
|
||||
}
|
||||
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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<uniform> a : array<f32, 4u>;
|
||||
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();
|
||||
|
|
|
@ -88,7 +88,7 @@ note: while analysing structure member S.m
|
|||
TEST_F(ResolverStorageClassValidationTest, StorageBufferBool) {
|
||||
// var<storage> 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<storage, read> 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<storage> 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<storage> g : vec4<f16>;
|
||||
Enable(ast::Extension::kF16);
|
||||
GlobalVar("g", ty.vec(Source{{56, 78}}, ty.Of<f16>(), 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<storage> g : ptr<private, f32>;
|
||||
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<storage> 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<storage> g : vec4<f32>;
|
||||
GlobalVar(Source{{56, 78}}, "g", ty.vec4<f32>(), 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<storage, read> 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<storage, read_write> 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<storage, read_write> 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<storage, read> 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<i32>())});
|
||||
|
||||
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<uniform> 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<uniform> 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<uniform> 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<uniform> g : vec4<f16>;
|
||||
Enable(ast::Extension::kF16);
|
||||
GlobalVar("g", ty.vec(Source{{56, 78}}, ty.Of<f16>(), 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<uniform> g : ptr<private, f32>;
|
||||
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<uniform> 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<uniform> g : vec4<f32>;
|
||||
GlobalVar(Source{{56, 78}}, "g", ty.vec4<f32>(), 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<uniform> g : array<S, 3u>;
|
||||
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<uniform> 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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -760,7 +760,7 @@ struct DimensionParams {
|
|||
using SampledTextureDimensionTest = ResolverTestWithParam<DimensionParams>;
|
||||
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<DimensionParams>;
|
||||
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();
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -471,7 +471,7 @@ TEST_F(ResolverVariableTest, LocalLet_InheritsAccessFromOriginatingVariable) {
|
|||
auto* inner = Structure("Inner", utils::Vector{Member("arr", ty.array<i32, 4>())});
|
||||
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();
|
||||
|
||||
|
|
|
@ -123,7 +123,7 @@ TEST_F(ResolverVariableValidationTest, VarTypeNotConstructible) {
|
|||
TEST_F(ResolverVariableValidationTest, LetTypeNotConstructible) {
|
||||
// @group(0) @binding(0) var t1 : texture_2d<f32>;
|
||||
// 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);
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<ast::GroupAttribute>(var->attributes);
|
||||
|
|
|
@ -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<const ast::Attribute*, 3> attributes{ctx.dst->Group(0),
|
||||
utils::Vector<const ast::Attribute*, 3> attributes{ctx.dst->Group(0_a),
|
||||
ctx.dst->Binding(0_a)};
|
||||
attributes.Push(ctx.dst->Disable(ast::DisabledValidation::kBindingPointCollision));
|
||||
return attributes;
|
||||
|
|
|
@ -158,7 +158,7 @@ TEST_F(DecomposeStridedArrayTest, ReadUniformStridedArray) {
|
|||
// }
|
||||
ProgramBuilder b;
|
||||
auto* S = b.Structure("S", utils::Vector{b.Member("a", b.ty.array<f32, 4u>(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<f32, 4u>(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<f32>(), 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<f32, 4u>(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<f32, 4u>(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<f32, 4u>(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<f32, 4u>(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<f32, 4u>(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<f32, 4u>(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<f32, 4u>(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<f32, 4u>(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{
|
||||
|
|
|
@ -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<f32>(), 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<f32>(), 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{
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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<f32>
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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"),
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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<f32>())});
|
||||
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<f32>())});
|
||||
|
||||
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"));
|
||||
|
|
|
@ -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<const ast::Statement*> statements) {
|
||||
|
|
|
@ -27,7 +27,7 @@ using GlslSanitizerTest = TestHelper;
|
|||
TEST_F(GlslSanitizerTest, Call_ArrayLength) {
|
||||
auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array<f32>(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<f32>(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<f32>(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")));
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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{
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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<f32>())});
|
||||
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<f32>())});
|
||||
|
||||
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"));
|
||||
|
|
|
@ -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<const ast::Statement*> statements) {
|
||||
|
|
|
@ -27,7 +27,7 @@ using HlslSanitizerTest = TestHelper;
|
|||
TEST_F(HlslSanitizerTest, Call_ArrayLength) {
|
||||
auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array<f32>(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<f32>(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<f32>(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<f32>(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{
|
||||
|
|
|
@ -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),
|
||||
});
|
||||
|
||||
|
|
|
@ -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<f32>())});
|
||||
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));
|
||||
|
||||
{
|
||||
|
|
|
@ -29,7 +29,7 @@ using MslSanitizerTest = TestHelper;
|
|||
TEST_F(MslSanitizerTest, Call_ArrayLength) {
|
||||
auto* s = Structure("my_struct", utils::Vector{Member(0, "a", ty.array<f32>(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<f32>(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<f32>(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<f32>(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<f32>(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{
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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<f32>(1_f, 2_f), 2_f);
|
||||
auto* expr2 = Call("textureSampleCompare", "texture", "sampler", vec2<f32>(1_f, 2_f), 2_f);
|
||||
|
@ -278,7 +278,7 @@ TEST_F(BuiltinBuilderTest, Call_ArrayLength) {
|
|||
Member("a", ty.array<f32>(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<f32>(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<f32>(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<f32>(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<i32>()),
|
||||
});
|
||||
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<i32>()),
|
||||
});
|
||||
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<i32>()),
|
||||
});
|
||||
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<u32>()),
|
||||
});
|
||||
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<i32>()),
|
||||
});
|
||||
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<i32>()),
|
||||
});
|
||||
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{
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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<storage, read_write> 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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
Loading…
Reference in New Issue