mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 18:59:21 +00:00
Convert @binding to an expression
This CL updates the binding attribute to store an expression instead of a single value. The parser always produces an IntLiteralExpression at the moment. Bug: tint:1633 Change-Id: I14b2a61b5bcdea66e9e24df7afbb55fb60be785e Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/100440 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:
committed by
Dawn LUCI CQ
parent
cbe8b36256
commit
f9b831c39a
@@ -146,9 +146,10 @@ void ArrayLengthFromUniform::Run(CloneContext& ctx, const DataMap& inputs, DataM
|
||||
ctx.dst->ty.array(ctx.dst->ty.vec4(ctx.dst->ty.u32()),
|
||||
u32((max_buffer_size_index / 4) + 1))),
|
||||
});
|
||||
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->Binding(cfg->ubo_binding.binding));
|
||||
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->Binding(AInt(cfg->ubo_binding.binding)));
|
||||
}
|
||||
return buffer_size_ubo;
|
||||
};
|
||||
|
||||
@@ -106,8 +106,8 @@ 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->create<ast::GroupAttribute>(to.group);
|
||||
auto* new_binding = ctx.dst->create<ast::BindingAttribute>(to.binding);
|
||||
auto* new_group = ctx.dst->Group(to.group);
|
||||
auto* new_binding = ctx.dst->Binding(AInt(to.binding));
|
||||
|
||||
auto* old_group = ast::GetAttribute<ast::GroupAttribute>(var->attributes);
|
||||
auto* old_binding = ast::GetAttribute<ast::BindingAttribute>(var->attributes);
|
||||
|
||||
@@ -39,6 +39,8 @@ bool IsGlobal(const tint::sem::VariablePair& pair) {
|
||||
|
||||
namespace tint::transform {
|
||||
|
||||
using namespace tint::number_suffixes; // NOLINT
|
||||
|
||||
CombineSamplers::BindingInfo::BindingInfo(const BindingMap& map,
|
||||
const sem::BindingPoint& placeholder)
|
||||
: binding_map(map), placeholder_binding_point(placeholder) {}
|
||||
@@ -79,7 +81,8 @@ 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), ctx.dst->Binding(0)};
|
||||
utils::Vector<const ast::Attribute*, 3> attributes{ctx.dst->Group(0),
|
||||
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));
|
||||
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0), 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));
|
||||
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0), 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));
|
||||
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, b.Group(0), 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));
|
||||
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, b.Group(0), 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"))),
|
||||
@@ -345,7 +345,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.Binding(0));
|
||||
b.Binding(0_a));
|
||||
b.Func("f", utils::Empty, b.ty.void_(),
|
||||
utils::Vector{
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4u>(32))),
|
||||
@@ -399,7 +399,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.Binding(0));
|
||||
b.Binding(0_a));
|
||||
b.Func("f", utils::Empty, b.ty.void_(),
|
||||
utils::Vector{
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4u>(4))),
|
||||
@@ -451,7 +451,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.Binding(0));
|
||||
b.Binding(0_a));
|
||||
b.Func("f", utils::Empty, b.ty.void_(),
|
||||
utils::Vector{
|
||||
b.Decl(b.Let("a", b.AddressOf(b.MemberAccessor("s", "a")))),
|
||||
@@ -512,7 +512,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) {
|
||||
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.Binding(0));
|
||||
b.Binding(0_a));
|
||||
b.Func("f", utils::Empty, b.ty.void_(),
|
||||
utils::Vector{
|
||||
b.Decl(b.Let("a", b.ty.type_name("ARR"), b.MemberAccessor("s", "a"))),
|
||||
@@ -582,7 +582,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
|
||||
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.Binding(0));
|
||||
b.Binding(0_a));
|
||||
b.Func("f", utils::Empty, b.ty.void_(),
|
||||
utils::Vector{
|
||||
b.Decl(b.Let("a", b.ty.type_name("ARR_B"), b.MemberAccessor("s", "a"))),
|
||||
|
||||
@@ -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));
|
||||
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0), 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));
|
||||
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0), 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));
|
||||
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kUniform, b.Group(0), 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"))),
|
||||
@@ -239,7 +239,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageMatrix) {
|
||||
}),
|
||||
});
|
||||
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0),
|
||||
b.Binding(0));
|
||||
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"))),
|
||||
@@ -296,7 +296,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadStorageColumn) {
|
||||
}),
|
||||
});
|
||||
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0),
|
||||
b.Binding(0));
|
||||
b.Binding(0_a));
|
||||
b.Func(
|
||||
"f", utils::Empty, b.ty.void_(),
|
||||
utils::Vector{
|
||||
@@ -350,7 +350,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) {
|
||||
}),
|
||||
});
|
||||
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0),
|
||||
b.Binding(0));
|
||||
b.Binding(0_a));
|
||||
b.Func("f", utils::Empty, b.ty.void_(),
|
||||
utils::Vector{
|
||||
b.Assign(b.MemberAccessor("s", "m"),
|
||||
@@ -408,7 +408,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) {
|
||||
}),
|
||||
});
|
||||
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0),
|
||||
b.Binding(0));
|
||||
b.Binding(0_a));
|
||||
b.Func("f", utils::Empty, b.ty.void_(),
|
||||
utils::Vector{
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i), b.vec2<f32>(1_f, 2_f)),
|
||||
@@ -467,7 +467,7 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) {
|
||||
}),
|
||||
});
|
||||
b.GlobalVar("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite, b.Group(0),
|
||||
b.Binding(0));
|
||||
b.Binding(0_a));
|
||||
b.Func("f", utils::Empty, b.ty.void_(),
|
||||
utils::Vector{
|
||||
b.Decl(b.Let("a", b.AddressOf(b.MemberAccessor("s", "m")))),
|
||||
|
||||
@@ -123,8 +123,8 @@ void FirstIndexOffset::Run(CloneContext& ctx, const DataMap& inputs, DataMap& ou
|
||||
Symbol buffer_name = ctx.dst->Sym();
|
||||
ctx.dst->GlobalVar(buffer_name, ctx.dst->ty.Of(struct_), ast::StorageClass::kUniform,
|
||||
utils::Vector{
|
||||
ctx.dst->create<ast::BindingAttribute>(ub_binding),
|
||||
ctx.dst->create<ast::GroupAttribute>(ub_group),
|
||||
ctx.dst->Binding(AInt(ub_binding)),
|
||||
ctx.dst->Group(ub_group),
|
||||
});
|
||||
|
||||
// Fix up all references to the builtins with the offsets
|
||||
|
||||
@@ -131,11 +131,11 @@ 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(bps.plane_1.binding));
|
||||
b.Group(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),
|
||||
b.Binding(bps.params.binding));
|
||||
b.Binding(AInt(bps.params.binding)));
|
||||
|
||||
// Replace the original texture_external binding with a texture_2d<f32>
|
||||
// binding.
|
||||
|
||||
@@ -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(binding));
|
||||
ctx.dst->Group(group), ctx.dst->Binding(AInt(binding)));
|
||||
}
|
||||
return num_workgroups_ubo;
|
||||
};
|
||||
|
||||
@@ -260,8 +260,8 @@ struct State {
|
||||
for (uint32_t i = 0; i < cfg.vertex_state.size(); ++i) {
|
||||
// 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(i),
|
||||
ctx.dst->Group(cfg.pulling_group));
|
||||
ast::StorageClass::kStorage, ast::Access::kRead,
|
||||
ctx.dst->Binding(AInt(i)), ctx.dst->Group(cfg.pulling_group));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user