mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-21 02:39:11 +00:00
tint: Rename ProgramBuilder::Construct() to Call()
Once all ast::Type derived classes are removed, there will be no distinction between a type initializer / conversion and a function call. Bug: tint:1810 Change-Id: Ic10fd1a0364a564d24dbe2499af0f1424641596c Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118980 Auto-Submit: Ben Clayton <bclayton@google.com> Reviewed-by: James Price <jrprice@google.com> Kokoro: Kokoro <noreply+kokoro@google.com> Commit-Queue: Ben Clayton <bclayton@chromium.org>
This commit is contained in:
committed by
Dawn LUCI CQ
parent
c272282e97
commit
01ac21cc9a
@@ -65,7 +65,7 @@ struct BuiltinPolyfill::State {
|
||||
if (width == 1) {
|
||||
return expr;
|
||||
}
|
||||
return b.Construct(T(ty), expr);
|
||||
return b.Call(T(ty), expr);
|
||||
};
|
||||
|
||||
utils::Vector<const ast::Statement*, 4> body;
|
||||
@@ -119,7 +119,7 @@ struct BuiltinPolyfill::State {
|
||||
if (width == 1) {
|
||||
return expr;
|
||||
}
|
||||
return b.Construct(T(ty), expr);
|
||||
return b.Call(T(ty), expr);
|
||||
};
|
||||
|
||||
utils::Vector<const ast::Statement*, 1> body;
|
||||
@@ -183,44 +183,44 @@ struct BuiltinPolyfill::State {
|
||||
auto V = [&](uint32_t value) -> const ast::Expression* {
|
||||
return ScalarOrVector(width, u32(value));
|
||||
};
|
||||
b.Func(name,
|
||||
utils::Vector{
|
||||
b.Param("v", T(ty)),
|
||||
},
|
||||
T(ty),
|
||||
utils::Vector{
|
||||
// var x = U(v);
|
||||
b.Decl(b.Var("x", b.Construct(U(), b.Expr("v")))),
|
||||
// let b16 = select(0, 16, x <= 0x0000ffff);
|
||||
b.Decl(b.Let(
|
||||
"b16", b.Call("select", V(0), V(16), b.LessThanEqual("x", V(0x0000ffff))))),
|
||||
// x = x << b16;
|
||||
b.Assign("x", b.Shl("x", "b16")),
|
||||
// let b8 = select(0, 8, x <= 0x00ffffff);
|
||||
b.Decl(b.Let("b8",
|
||||
b.Call("select", V(0), V(8), b.LessThanEqual("x", V(0x00ffffff))))),
|
||||
// x = x << b8;
|
||||
b.Assign("x", b.Shl("x", "b8")),
|
||||
// let b4 = select(0, 4, x <= 0x0fffffff);
|
||||
b.Decl(b.Let("b4",
|
||||
b.Call("select", V(0), V(4), b.LessThanEqual("x", V(0x0fffffff))))),
|
||||
// x = x << b4;
|
||||
b.Assign("x", b.Shl("x", "b4")),
|
||||
// let b2 = select(0, 2, x <= 0x3fffffff);
|
||||
b.Decl(b.Let("b2",
|
||||
b.Call("select", V(0), V(2), b.LessThanEqual("x", V(0x3fffffff))))),
|
||||
// x = x << b2;
|
||||
b.Assign("x", b.Shl("x", "b2")),
|
||||
// let b1 = select(0, 1, x <= 0x7fffffff);
|
||||
b.Decl(b.Let("b1",
|
||||
b.Call("select", V(0), V(1), b.LessThanEqual("x", V(0x7fffffff))))),
|
||||
// let is_zero = select(0, 1, x == 0);
|
||||
b.Decl(b.Let("is_zero", b.Call("select", V(0), V(1), b.Equal("x", V(0))))),
|
||||
// return R((b16 | b8 | b4 | b2 | b1) + zero);
|
||||
b.Return(b.Construct(
|
||||
T(ty),
|
||||
b.Add(b.Or(b.Or(b.Or(b.Or("b16", "b8"), "b4"), "b2"), "b1"), "is_zero"))),
|
||||
});
|
||||
b.Func(
|
||||
name,
|
||||
utils::Vector{
|
||||
b.Param("v", T(ty)),
|
||||
},
|
||||
T(ty),
|
||||
utils::Vector{
|
||||
// var x = U(v);
|
||||
b.Decl(b.Var("x", b.Call(U(), b.Expr("v")))),
|
||||
// let b16 = select(0, 16, x <= 0x0000ffff);
|
||||
b.Decl(b.Let("b16",
|
||||
b.Call("select", V(0), V(16), b.LessThanEqual("x", V(0x0000ffff))))),
|
||||
// x = x << b16;
|
||||
b.Assign("x", b.Shl("x", "b16")),
|
||||
// let b8 = select(0, 8, x <= 0x00ffffff);
|
||||
b.Decl(
|
||||
b.Let("b8", b.Call("select", V(0), V(8), b.LessThanEqual("x", V(0x00ffffff))))),
|
||||
// x = x << b8;
|
||||
b.Assign("x", b.Shl("x", "b8")),
|
||||
// let b4 = select(0, 4, x <= 0x0fffffff);
|
||||
b.Decl(
|
||||
b.Let("b4", b.Call("select", V(0), V(4), b.LessThanEqual("x", V(0x0fffffff))))),
|
||||
// x = x << b4;
|
||||
b.Assign("x", b.Shl("x", "b4")),
|
||||
// let b2 = select(0, 2, x <= 0x3fffffff);
|
||||
b.Decl(
|
||||
b.Let("b2", b.Call("select", V(0), V(2), b.LessThanEqual("x", V(0x3fffffff))))),
|
||||
// x = x << b2;
|
||||
b.Assign("x", b.Shl("x", "b2")),
|
||||
// let b1 = select(0, 1, x <= 0x7fffffff);
|
||||
b.Decl(
|
||||
b.Let("b1", b.Call("select", V(0), V(1), b.LessThanEqual("x", V(0x7fffffff))))),
|
||||
// let is_zero = select(0, 1, x == 0);
|
||||
b.Decl(b.Let("is_zero", b.Call("select", V(0), V(1), b.Equal("x", V(0))))),
|
||||
// return R((b16 | b8 | b4 | b2 | b1) + zero);
|
||||
b.Return(b.Call(T(ty), b.Add(b.Or(b.Or(b.Or(b.Or("b16", "b8"), "b4"), "b2"), "b1"),
|
||||
"is_zero"))),
|
||||
});
|
||||
return name;
|
||||
}
|
||||
|
||||
@@ -243,9 +243,9 @@ struct BuiltinPolyfill::State {
|
||||
};
|
||||
auto B = [&](const ast::Expression* value) -> const ast::Expression* {
|
||||
if (width == 1) {
|
||||
return b.Construct<bool>(value);
|
||||
return b.Call<bool>(value);
|
||||
}
|
||||
return b.Construct(b.ty.vec<bool>(width), value);
|
||||
return b.Call(b.ty.vec<bool>(width), value);
|
||||
};
|
||||
b.Func(
|
||||
name,
|
||||
@@ -255,7 +255,7 @@ struct BuiltinPolyfill::State {
|
||||
T(ty),
|
||||
utils::Vector{
|
||||
// var x = U(v);
|
||||
b.Decl(b.Var("x", b.Construct(U(), b.Expr("v")))),
|
||||
b.Decl(b.Var("x", b.Call(U(), b.Expr("v")))),
|
||||
// let b16 = select(16, 0, bool(x & 0x0000ffff));
|
||||
b.Decl(b.Let("b16", b.Call("select", V(16), V(0), B(b.And("x", V(0x0000ffff)))))),
|
||||
// x = x >> b16;
|
||||
@@ -277,9 +277,8 @@ struct BuiltinPolyfill::State {
|
||||
// let is_zero = select(0, 1, x == 0);
|
||||
b.Decl(b.Let("is_zero", b.Call("select", V(0), V(1), b.Equal("x", V(0))))),
|
||||
// return R((b16 | b8 | b4 | b2 | b1) + zero);
|
||||
b.Return(b.Construct(
|
||||
T(ty),
|
||||
b.Add(b.Or(b.Or(b.Or(b.Or("b16", "b8"), "b4"), "b2"), "b1"), "is_zero"))),
|
||||
b.Return(b.Call(T(ty), b.Add(b.Or(b.Or(b.Or(b.Or("b16", "b8"), "b4"), "b2"), "b1"),
|
||||
"is_zero"))),
|
||||
});
|
||||
return name;
|
||||
}
|
||||
@@ -297,7 +296,7 @@ struct BuiltinPolyfill::State {
|
||||
if (width == 1) {
|
||||
return value;
|
||||
}
|
||||
return b.Construct(b.ty.vec<u32>(width), value);
|
||||
return b.Call(b.ty.vec<u32>(width), value);
|
||||
};
|
||||
|
||||
utils::Vector<const ast::Statement*, 8> body{
|
||||
@@ -312,7 +311,7 @@ struct BuiltinPolyfill::State {
|
||||
// Here we don't want the shl and shr modulos the rhs, so handle the `rhs >= 32u`
|
||||
// cases using `select`. In order to handle the signed shr `lhs >> rhs` corrently,
|
||||
// use `(lhs >> 31u) >> 1u` if `rhs >= 32u`.
|
||||
body.Push(b.Decl(b.Let("shl_result", b.Call("select", b.Construct(T(ty)),
|
||||
body.Push(b.Decl(b.Let("shl_result", b.Call("select", b.Call(T(ty)),
|
||||
b.Shl("v", vecN_u32(b.Expr("shl"))),
|
||||
b.LessThan("shl", 32_u)))));
|
||||
body.Push(b.Return(b.Call(
|
||||
@@ -361,9 +360,9 @@ struct BuiltinPolyfill::State {
|
||||
};
|
||||
auto B = [&](const ast::Expression* value) -> const ast::Expression* {
|
||||
if (width == 1) {
|
||||
return b.Construct<bool>(value);
|
||||
return b.Call<bool>(value);
|
||||
}
|
||||
return b.Construct(b.ty.vec<bool>(width), value);
|
||||
return b.Call(b.ty.vec<bool>(width), value);
|
||||
};
|
||||
|
||||
const ast::Expression* x = nullptr;
|
||||
@@ -371,9 +370,9 @@ struct BuiltinPolyfill::State {
|
||||
x = b.Expr("v");
|
||||
} else {
|
||||
// If ty is signed, then the value is inverted if the sign is negative
|
||||
x = b.Call("select", //
|
||||
b.Construct(U(), "v"), //
|
||||
b.Construct(U(), b.Complement("v")), //
|
||||
x = b.Call("select", //
|
||||
b.Call(U(), "v"), //
|
||||
b.Call(U(), b.Complement("v")), //
|
||||
b.LessThan("v", ScalarOrVector(width, 0_i)));
|
||||
}
|
||||
|
||||
@@ -408,7 +407,7 @@ struct BuiltinPolyfill::State {
|
||||
// let is_zero = select(0, 0xffffffff, x == 0);
|
||||
b.Decl(b.Let("is_zero", b.Call("select", V(0), V(0xffffffff), b.Equal("x", V(0))))),
|
||||
// return R(b16 | b8 | b4 | b2 | b1 | zero);
|
||||
b.Return(b.Construct(
|
||||
b.Return(b.Call(
|
||||
T(ty), b.Or(b.Or(b.Or(b.Or(b.Or("b16", "b8"), "b4"), "b2"), "b1"), "is_zero"))),
|
||||
});
|
||||
return name;
|
||||
@@ -433,9 +432,9 @@ struct BuiltinPolyfill::State {
|
||||
};
|
||||
auto B = [&](const ast::Expression* value) -> const ast::Expression* {
|
||||
if (width == 1) {
|
||||
return b.Construct<bool>(value);
|
||||
return b.Call<bool>(value);
|
||||
}
|
||||
return b.Construct(b.ty.vec<bool>(width), value);
|
||||
return b.Call(b.ty.vec<bool>(width), value);
|
||||
};
|
||||
b.Func(
|
||||
name,
|
||||
@@ -445,7 +444,7 @@ struct BuiltinPolyfill::State {
|
||||
T(ty),
|
||||
utils::Vector{
|
||||
// var x = U(v);
|
||||
b.Decl(b.Var("x", b.Construct(U(), b.Expr("v")))),
|
||||
b.Decl(b.Var("x", b.Call(U(), b.Expr("v")))),
|
||||
// let b16 = select(16, 0, bool(x & 0x0000ffff));
|
||||
b.Decl(b.Let("b16", b.Call("select", V(16), V(0), B(b.And("x", V(0x0000ffff)))))),
|
||||
// x = x >> b16;
|
||||
@@ -467,7 +466,7 @@ struct BuiltinPolyfill::State {
|
||||
// let is_zero = select(0, 0xffffffff, x == 0);
|
||||
b.Decl(b.Let("is_zero", b.Call("select", V(0), V(0xffffffff), b.Equal("x", V(0))))),
|
||||
// return R(b16 | b8 | b4 | b2 | b1 | is_zero);
|
||||
b.Return(b.Construct(
|
||||
b.Return(b.Call(
|
||||
T(ty), b.Or(b.Or(b.Or(b.Or(b.Or("b16", "b8"), "b4"), "b2"), "b1"), "is_zero"))),
|
||||
});
|
||||
return name;
|
||||
@@ -493,10 +492,10 @@ struct BuiltinPolyfill::State {
|
||||
auto V = [&](auto value) -> const ast::Expression* {
|
||||
const ast::Expression* expr = b.Expr(value);
|
||||
if (!ty->is_unsigned_integer_scalar_or_vector()) {
|
||||
expr = b.Construct<i32>(expr);
|
||||
expr = b.Call<i32>(expr);
|
||||
}
|
||||
if (ty->Is<type::Vector>()) {
|
||||
expr = b.Construct(T(ty), expr);
|
||||
expr = b.Call(T(ty), expr);
|
||||
}
|
||||
return expr;
|
||||
};
|
||||
@@ -552,8 +551,8 @@ struct BuiltinPolyfill::State {
|
||||
|
||||
// return ((select(T(), n << offset, offset < 32u) & mask) | (v & ~(mask)));
|
||||
body.Push(
|
||||
b.Return(b.Or(b.And(b.Call("select", b.Construct(T(ty)),
|
||||
b.Shl("n", U("offset")), b.LessThan("offset", 32_u)),
|
||||
b.Return(b.Or(b.And(b.Call("select", b.Call(T(ty)), b.Shl("n", U("offset")),
|
||||
b.LessThan("offset", 32_u)),
|
||||
V("mask")),
|
||||
b.And("v", V(b.Complement("mask"))))));
|
||||
|
||||
@@ -587,7 +586,7 @@ struct BuiltinPolyfill::State {
|
||||
Symbol saturate(const type::Type* ty) {
|
||||
auto name = b.Symbols().New("tint_saturate");
|
||||
auto body = utils::Vector{
|
||||
b.Return(b.Call("clamp", "v", b.Construct(T(ty), 0_a), b.Construct(T(ty), 1_a))),
|
||||
b.Return(b.Call("clamp", "v", b.Call(T(ty), 0_a), b.Call(T(ty), 1_a))),
|
||||
};
|
||||
b.Func(name,
|
||||
utils::Vector{
|
||||
@@ -630,8 +629,7 @@ struct BuiltinPolyfill::State {
|
||||
Symbol textureSampleBaseClampToEdge_2d_f32() {
|
||||
auto name = b.Symbols().New("tint_textureSampleBaseClampToEdge");
|
||||
auto body = utils::Vector{
|
||||
b.Decl(b.Let("dims",
|
||||
b.Construct(b.ty.vec2<f32>(), b.Call("textureDimensions", "t", 0_a)))),
|
||||
b.Decl(b.Let("dims", b.Call(b.ty.vec2<f32>(), b.Call("textureDimensions", "t", 0_a)))),
|
||||
b.Decl(b.Let("half_texel", b.Div(b.vec2<f32>(0.5_a), "dims"))),
|
||||
b.Decl(
|
||||
b.Let("clamped", b.Call("clamp", "coord", "half_texel", b.Sub(1_a, "half_texel")))),
|
||||
@@ -663,7 +661,7 @@ struct BuiltinPolyfill::State {
|
||||
},
|
||||
T(vec),
|
||||
utils::Vector{
|
||||
b.Return(b.Construct(T(vec), std::move(args))),
|
||||
b.Return(b.Call(T(vec), std::move(args))),
|
||||
});
|
||||
return name;
|
||||
}
|
||||
@@ -705,7 +703,7 @@ struct BuiltinPolyfill::State {
|
||||
auto* lhs_el_ty = type::Type::DeepestElementOf(lhs_ty);
|
||||
const ast::Expression* mask = b.Expr(AInt(lhs_el_ty->Size() * 8 - 1));
|
||||
if (rhs_ty->Is<type::Vector>()) {
|
||||
mask = b.Construct(CreateASTTypeFor(ctx, rhs_ty), mask);
|
||||
mask = b.Call(CreateASTTypeFor(ctx, rhs_ty), mask);
|
||||
}
|
||||
auto* lhs = ctx.Clone(bin_op->lhs);
|
||||
auto* rhs = b.And(ctx.Clone(bin_op->rhs), mask);
|
||||
@@ -808,7 +806,7 @@ struct BuiltinPolyfill::State {
|
||||
if (width == 1) {
|
||||
return b.Expr(value);
|
||||
}
|
||||
return b.Construct(b.ty.vec<T>(width), value);
|
||||
return b.Call(b.ty.vec<T>(width), value);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -370,7 +370,7 @@ struct CanonicalizeEntryPointIO::State {
|
||||
|
||||
// Construct the original structure using the new shader input objects.
|
||||
inner_call_parameters.Push(
|
||||
ctx.dst->Construct(ctx.Clone(param->Declaration()->type), inner_struct_values));
|
||||
ctx.dst->Call(ctx.Clone(param->Declaration()->type), inner_struct_values));
|
||||
}
|
||||
|
||||
/// Process the entry point return type.
|
||||
|
||||
@@ -178,7 +178,7 @@ Transform::ApplyResult ClampFragDepth::Apply(const Program* src, const DataMap&,
|
||||
}
|
||||
utils::Vector params{b.Param("s", ctx.Clone(return_ty))};
|
||||
utils::Vector body{
|
||||
b.Return(b.Construct(ctx.Clone(return_ty), std::move(initializer_args))),
|
||||
b.Return(b.Call(ctx.Clone(return_ty), std::move(initializer_args))),
|
||||
};
|
||||
b.Func(fn_sym, params, ctx.Clone(return_ty), body);
|
||||
return fn_sym;
|
||||
|
||||
@@ -77,7 +77,7 @@ struct OffsetExpr : Offset {
|
||||
auto* type = ctx.src->Sem().GetVal(expr)->Type()->UnwrapRef();
|
||||
auto* res = ctx.Clone(expr);
|
||||
if (!type->Is<type::U32>()) {
|
||||
res = ctx.dst->Construct<u32>(res);
|
||||
res = ctx.dst->Call<u32>(res);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
@@ -545,7 +545,7 @@ struct DecomposeMemoryAccess::State {
|
||||
}
|
||||
b.Func(name, params, CreateASTTypeFor(ctx, el_ty),
|
||||
utils::Vector{
|
||||
b.Return(b.Construct(CreateASTTypeFor(ctx, el_ty), values)),
|
||||
b.Return(b.Call(CreateASTTypeFor(ctx, el_ty), values)),
|
||||
});
|
||||
}
|
||||
return name;
|
||||
|
||||
@@ -150,7 +150,7 @@ Transform::ApplyResult DecomposeStridedArray::Apply(const Program* src,
|
||||
args = ctx.Clone(expr->args);
|
||||
}
|
||||
|
||||
return target.type ? b.Construct(target.type, std::move(args))
|
||||
return target.type ? b.Call(target.type, std::move(args))
|
||||
: b.Call(target.name, std::move(args));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -348,9 +348,9 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageStridedArray) {
|
||||
b.Group(0_a), 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))),
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Call(b.ty.array<f32, 4u>(32))),
|
||||
b.Assign(b.MemberAccessor("s", "a"),
|
||||
b.Construct(b.ty.array<f32, 4u>(32), 1_f, 2_f, 3_f, 4_f)),
|
||||
b.Call(b.ty.array<f32, 4u>(32), 1_f, 2_f, 3_f, 4_f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5_f),
|
||||
},
|
||||
utils::Vector{
|
||||
@@ -402,9 +402,9 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageDefaultStridedArray) {
|
||||
b.Group(0_a), 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))),
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Call(b.ty.array<f32, 4u>(4))),
|
||||
b.Assign(b.MemberAccessor("s", "a"),
|
||||
b.Construct(b.ty.array<f32, 4u>(4), 1_f, 2_f, 3_f, 4_f)),
|
||||
b.Call(b.ty.array<f32, 4u>(4), 1_f, 2_f, 3_f, 4_f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5_f),
|
||||
},
|
||||
utils::Vector{
|
||||
@@ -458,7 +458,7 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) {
|
||||
b.Decl(b.Let("b", b.AddressOf(b.Deref(b.AddressOf(b.Deref("a")))))),
|
||||
b.Decl(b.Let("c", b.Deref("b"))),
|
||||
b.Decl(b.Let("d", b.IndexAccessor(b.Deref("b"), 1_i))),
|
||||
b.Assign(b.Deref("b"), b.Construct(b.ty.array<f32, 4u>(32), 1_f, 2_f, 3_f, 4_f)),
|
||||
b.Assign(b.Deref("b"), b.Call(b.ty.array<f32, 4u>(32), 1_f, 2_f, 3_f, 4_f)),
|
||||
b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), 5_f),
|
||||
},
|
||||
utils::Vector{
|
||||
@@ -517,8 +517,8 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) {
|
||||
utils::Vector{
|
||||
b.Decl(b.Let("a", b.ty("ARR"), b.MemberAccessor("s", "a"))),
|
||||
b.Decl(b.Let("b", b.ty.f32(), b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i))),
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty("ARR"))),
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty("ARR"), 1_f, 2_f, 3_f, 4_f)),
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Call(b.ty("ARR"))),
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Call(b.ty("ARR"), 1_f, 2_f, 3_f, 4_f)),
|
||||
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5_f),
|
||||
},
|
||||
utils::Vector{
|
||||
@@ -603,7 +603,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
|
||||
3_i),
|
||||
2_i),
|
||||
1_i))),
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty("ARR_B"))),
|
||||
b.Assign(b.MemberAccessor("s", "a"), b.Call(b.ty("ARR_B"))),
|
||||
b.Assign(b.IndexAccessor( //
|
||||
b.IndexAccessor( //
|
||||
b.IndexAccessor( //
|
||||
|
||||
@@ -150,7 +150,7 @@ Transform::ApplyResult DecomposeStridedMatrix::Apply(const Program* src,
|
||||
},
|
||||
array(),
|
||||
utils::Vector{
|
||||
b.Return(b.Construct(array(), columns)),
|
||||
b.Return(b.Call(array(), columns)),
|
||||
});
|
||||
return name;
|
||||
});
|
||||
@@ -189,7 +189,7 @@ Transform::ApplyResult DecomposeStridedMatrix::Apply(const Program* src,
|
||||
},
|
||||
matrix(),
|
||||
utils::Vector{
|
||||
b.Return(b.Construct(matrix(), columns)),
|
||||
b.Return(b.Call(matrix(), columns)),
|
||||
});
|
||||
return name;
|
||||
});
|
||||
|
||||
@@ -574,7 +574,7 @@ struct DirectVariableAccess::State {
|
||||
->Type()
|
||||
->UnwrapRef()
|
||||
->IsAnyOf<type::U32, type::AbstractInt>()) {
|
||||
expr = b.Construct(b.ty.u32(), expr);
|
||||
expr = b.Call<u32>(expr);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -937,7 +937,7 @@ struct DirectVariableAccess::State {
|
||||
dyn_idx_args.Push(BuildDynamicIndex(dyn_idx, /* cast_to_u32 */ true));
|
||||
}
|
||||
// Construct the dynamic index array, and push as an argument.
|
||||
new_args.Push(b.Construct(dyn_idx_arr_ty, std::move(dyn_idx_args)));
|
||||
new_args.Push(b.Call(dyn_idx_arr_ty, std::move(dyn_idx_args)));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -320,17 +320,17 @@ struct MultiplanarExternalTexture::State {
|
||||
"modifiedCoords", b.Mul(b.MemberAccessor("params", "coordTransformationMatrix"),
|
||||
b.vec3<f32>("coord", 1_a)))));
|
||||
|
||||
stmts.Push(b.Decl(b.Let(
|
||||
"plane0_dims",
|
||||
b.Construct(b.ty.vec2<f32>(), b.Call("textureDimensions", "plane0", 0_a)))));
|
||||
stmts.Push(b.Decl(
|
||||
b.Let("plane0_dims",
|
||||
b.Call(b.ty.vec2<f32>(), b.Call("textureDimensions", "plane0", 0_a)))));
|
||||
stmts.Push(
|
||||
b.Decl(b.Let("plane0_half_texel", b.Div(b.vec2<f32>(0.5_a), "plane0_dims"))));
|
||||
stmts.Push(b.Decl(
|
||||
b.Let("plane0_clamped", b.Call("clamp", "modifiedCoords", "plane0_half_texel",
|
||||
b.Sub(1_a, "plane0_half_texel")))));
|
||||
stmts.Push(b.Decl(b.Let(
|
||||
"plane1_dims",
|
||||
b.Construct(b.ty.vec2<f32>(), b.Call("textureDimensions", "plane1", 0_a)))));
|
||||
stmts.Push(b.Decl(
|
||||
b.Let("plane1_dims",
|
||||
b.Call(b.ty.vec2<f32>(), b.Call("textureDimensions", "plane1", 0_a)))));
|
||||
stmts.Push(
|
||||
b.Decl(b.Let("plane1_half_texel", b.Div(b.vec2<f32>(0.5_a), "plane1_dims"))));
|
||||
stmts.Push(b.Decl(
|
||||
|
||||
@@ -135,7 +135,7 @@ struct PackedVec3::State {
|
||||
auto* expr = ref->Declaration();
|
||||
ctx.Replace(expr, [this, vec_ty, expr] { //
|
||||
auto* packed = ctx.CloneWithoutTransform(expr);
|
||||
return b.Construct(CreateASTTypeFor(ctx, vec_ty), packed);
|
||||
return b.Call(CreateASTTypeFor(ctx, vec_ty), packed);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ Transform::ApplyResult PadStructs::Apply(const Program* src, const DataMap&, Dat
|
||||
arg++;
|
||||
}
|
||||
}
|
||||
return b.Construct(CreateASTTypeFor(ctx, str), new_args);
|
||||
return b.Call(CreateASTTypeFor(ctx, str), new_args);
|
||||
});
|
||||
|
||||
ctx.Clone();
|
||||
|
||||
@@ -79,7 +79,7 @@ struct Robustness::State {
|
||||
auto idx = [&]() -> const ast::Expression* {
|
||||
auto* i = ctx.Clone(expr->index);
|
||||
if (sem->Index()->Type()->is_signed_integer_scalar()) {
|
||||
return b.Construct(b.ty.u32(), i); // u32(idx)
|
||||
return b.Call<u32>(i); // u32(idx)
|
||||
}
|
||||
return i;
|
||||
};
|
||||
@@ -191,15 +191,15 @@ struct Robustness::State {
|
||||
auto scalar_or_vec = [&](const ast::Expression* scalar,
|
||||
uint32_t width) -> const ast::Expression* {
|
||||
if (width > 1) {
|
||||
return b.Construct(b.ty.vec(nullptr, width), scalar);
|
||||
return b.Call(b.ty.vec(nullptr, width), scalar);
|
||||
}
|
||||
return scalar;
|
||||
};
|
||||
auto cast_to_signed = [&](const ast::Expression* val, uint32_t width) {
|
||||
return b.Construct(scalar_or_vec_ty(b.ty.i32(), width), val);
|
||||
return b.Call(scalar_or_vec_ty(b.ty.i32(), width), val);
|
||||
};
|
||||
auto cast_to_unsigned = [&](const ast::Expression* val, uint32_t width) {
|
||||
return b.Construct(scalar_or_vec_ty(b.ty.u32(), width), val);
|
||||
return b.Call(scalar_or_vec_ty(b.ty.u32(), width), val);
|
||||
};
|
||||
|
||||
// If the level is provided, then we need to clamp this. As the level is
|
||||
|
||||
@@ -706,7 +706,7 @@ struct Std140::State {
|
||||
utils::Transform(*col_members, [&](const ast::StructMember* m) {
|
||||
return b.MemberAccessor(param, m->symbol);
|
||||
});
|
||||
args.Push(b.Construct(mat_ty, std::move(mat_args)));
|
||||
args.Push(b.Call(mat_ty, std::move(mat_args)));
|
||||
} else {
|
||||
// Convert the member
|
||||
args.Push(
|
||||
@@ -714,7 +714,7 @@ struct Std140::State {
|
||||
b.MemberAccessor(param, sym.NameFor(member->Name()))));
|
||||
}
|
||||
}
|
||||
stmts.Push(b.Return(b.Construct(CreateASTTypeFor(ctx, ty), std::move(args))));
|
||||
stmts.Push(b.Return(b.Call(CreateASTTypeFor(ctx, ty), std::move(args))));
|
||||
}, //
|
||||
[&](const type::Matrix* mat) {
|
||||
// Reassemble a std140 matrix from the structure of column vector members.
|
||||
@@ -726,7 +726,7 @@ struct Std140::State {
|
||||
auto mat_args = utils::Transform(std140_mat->columns, [&](Symbol name) {
|
||||
return b.MemberAccessor(param, name);
|
||||
});
|
||||
stmts.Push(b.Return(b.Construct(mat_ty, std::move(mat_args))));
|
||||
stmts.Push(b.Return(b.Call(mat_ty, std::move(mat_args))));
|
||||
} else {
|
||||
TINT_ICE(Transform, b.Diagnostics())
|
||||
<< "failed to find std140 matrix info for: " << src->FriendlyName(ty);
|
||||
@@ -798,7 +798,7 @@ struct Std140::State {
|
||||
|
||||
// Build the arguments
|
||||
auto args = utils::Transform(access.dynamic_indices, [&](const sem::ValueExpression* e) {
|
||||
return b.Construct(b.ty.u32(), ctx.Clone(e->Declaration()));
|
||||
return b.Call<u32>(ctx.Clone(e->Declaration()));
|
||||
});
|
||||
|
||||
// Call the helper
|
||||
@@ -962,7 +962,7 @@ struct Std140::State {
|
||||
// Build the default case (required in WGSL).
|
||||
// This just returns a zero value of the return type, as the index must be out of
|
||||
// bounds.
|
||||
cases.Push(b.DefaultCase(b.Block(b.Return(b.Construct(CreateASTTypeFor(ctx, ret_ty))))));
|
||||
cases.Push(b.DefaultCase(b.Block(b.Return(b.Call(CreateASTTypeFor(ctx, ret_ty))))));
|
||||
|
||||
auto* column_selector = dynamic_index(column_param_idx);
|
||||
auto* stmt = b.Switch(column_selector, std::move(cases));
|
||||
@@ -1035,7 +1035,7 @@ struct Std140::State {
|
||||
}
|
||||
|
||||
// Reconstruct the matrix from the columns
|
||||
expr = b.Construct(CreateASTTypeFor(ctx, chain.std140_mat_ty), std::move(columns));
|
||||
expr = b.Call(CreateASTTypeFor(ctx, chain.std140_mat_ty), std::move(columns));
|
||||
|
||||
// Have the function return the constructed matrix
|
||||
stmts.Push(b.Return(expr));
|
||||
|
||||
@@ -139,11 +139,11 @@ Transform::ApplyResult TruncateInterstageVariables::Apply(const Program* src,
|
||||
|
||||
// Create the mapping function to truncate the shader io.
|
||||
auto mapping_fn_sym = b.Symbols().New("truncate_shader_output");
|
||||
b.Func(
|
||||
mapping_fn_sym, utils::Vector{b.Param("io", ctx.Clone(func_ast->return_type))},
|
||||
b.ty(new_struct_sym),
|
||||
utils::Vector{
|
||||
b.Return(b.Construct(b.ty(new_struct_sym), std::move(initializer_exprs)))});
|
||||
b.Func(mapping_fn_sym,
|
||||
utils::Vector{b.Param("io", ctx.Clone(func_ast->return_type))},
|
||||
b.ty(new_struct_sym),
|
||||
utils::Vector{
|
||||
b.Return(b.Call(b.ty(new_struct_sym), std::move(initializer_exprs)))});
|
||||
return TruncatedStructAndConverter{new_struct_sym, mapping_fn_sym};
|
||||
});
|
||||
|
||||
|
||||
@@ -106,9 +106,9 @@ Transform::ApplyResult VectorizeMatrixConversions::Apply(const Program* src,
|
||||
auto* src_matrix_expr = src_expression_builder();
|
||||
auto* src_column_expr = b.IndexAccessor(src_matrix_expr, b.Expr(tint::AInt(c)));
|
||||
columns.Push(
|
||||
b.Construct(CreateASTTypeFor(ctx, dst_type->ColumnType()), src_column_expr));
|
||||
b.Call(CreateASTTypeFor(ctx, dst_type->ColumnType()), src_column_expr));
|
||||
}
|
||||
return b.Construct(CreateASTTypeFor(ctx, dst_type), columns);
|
||||
return b.Call(CreateASTTypeFor(ctx, dst_type), columns);
|
||||
};
|
||||
|
||||
// Replace the matrix conversion to column vector conversions and a matrix construction.
|
||||
|
||||
@@ -102,7 +102,7 @@ Transform::ApplyResult VectorizeScalarMatrixInitializers::Apply(const Program* s
|
||||
columns.Push(b.vec(CreateASTTypeFor(ctx, mat_type->type()), mat_type->rows(),
|
||||
std::move(row_values)));
|
||||
}
|
||||
return b.Construct(CreateASTTypeFor(ctx, mat_type), columns);
|
||||
return b.Call(CreateASTTypeFor(ctx, mat_type), columns);
|
||||
};
|
||||
|
||||
if (args.Length() == 1) {
|
||||
|
||||
@@ -402,7 +402,7 @@ struct VertexPulling::State {
|
||||
loaded_data_target_type = b.ty.vec(b.ty.f16(), fmt_dt.width);
|
||||
}
|
||||
|
||||
fetch = b.Construct(loaded_data_target_type, fetch);
|
||||
fetch = b.Call(loaded_data_target_type, fetch);
|
||||
}
|
||||
|
||||
// The attribute value may not be of the desired vector width. If it is not, we'll
|
||||
@@ -444,7 +444,7 @@ struct VertexPulling::State {
|
||||
}
|
||||
|
||||
const ast::Type* target_ty = CreateASTTypeFor(ctx, var.type);
|
||||
value = b.Construct(target_ty, values);
|
||||
value = b.Call(target_ty, values);
|
||||
}
|
||||
|
||||
// Assign the value to the WGSL variable
|
||||
@@ -745,7 +745,7 @@ struct VertexPulling::State {
|
||||
expr_list.Push(LoadPrimitive(array_base, primitive_offset, buffer, base_format));
|
||||
}
|
||||
|
||||
return b.Construct(b.create<ast::Vector>(base_type, count), std::move(expr_list));
|
||||
return b.Call(b.create<ast::Vector>(base_type, count), std::move(expr_list));
|
||||
}
|
||||
|
||||
/// Process a non-struct entry point parameter.
|
||||
|
||||
@@ -297,14 +297,14 @@ struct ZeroInitWorkgroupMemory::State {
|
||||
if (!var) {
|
||||
return false;
|
||||
}
|
||||
auto* zero_init = b.Construct(CreateASTTypeFor(ctx, ty));
|
||||
auto* zero_init = b.Call(CreateASTTypeFor(ctx, ty));
|
||||
statements.emplace_back(
|
||||
Statement{b.Assign(var.expr, zero_init), var.num_iterations, var.array_indices});
|
||||
return true;
|
||||
}
|
||||
|
||||
if (auto* atomic = ty->As<type::Atomic>()) {
|
||||
auto* zero_init = b.Construct(CreateASTTypeFor(ctx, atomic->Type()));
|
||||
auto* zero_init = b.Call(CreateASTTypeFor(ctx, atomic->Type()));
|
||||
auto expr = get_expr(1u);
|
||||
if (!expr) {
|
||||
return false;
|
||||
@@ -412,7 +412,7 @@ struct ZeroInitWorkgroupMemory::State {
|
||||
workgroup_size_expr = [this, expr, size = workgroup_size_expr] {
|
||||
auto* e = ctx.Clone(expr);
|
||||
if (ctx.src->TypeOf(expr)->UnwrapRef()->Is<type::I32>()) {
|
||||
e = b.Construct<u32>(e);
|
||||
e = b.Call<u32>(e);
|
||||
}
|
||||
return size ? b.Mul(size(), e) : e;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user