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:
dan sinclair
2022-08-29 21:22:31 +00:00
committed by Dawn LUCI CQ
parent f9b831c39a
commit be4c9f48aa
64 changed files with 378 additions and 329 deletions

View File

@@ -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;

View File

@@ -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);

View File

@@ -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;

View File

@@ -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{

View File

@@ -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{

View File

@@ -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

View File

@@ -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>

View File

@@ -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;
};

View File

@@ -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)));
}
}