tint: Replace all ProgramBuilder float literals with '_f' suffix

Unsuffixed float literals are currently treated as f32,
but will shortly become AbstractFloat. To keep tests behaving
identically to how they are currently, change all float literals
to explicitly use the f32 '_f' suffix.

Bug: tint:1504
Change-Id: I2a00725ee1b34a6efbe15ac4ba438c00c4416dd8
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/89402
Reviewed-by: Dan Sinclair <dsinclair@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
Kokoro: Kokoro <noreply+kokoro@google.com>
This commit is contained in:
Ben Clayton
2022-05-10 17:30:15 +00:00
committed by Dawn LUCI CQ
parent a439e7b89c
commit 0a3cda9911
87 changed files with 800 additions and 780 deletions

View File

@@ -374,7 +374,7 @@ struct CanonicalizeEntryPointIO::State {
void AddVertexPointSize() {
// Create a new output value and assign it a literal 1.0 value.
AddOutput("vertex_point_size", ctx.dst->create<sem::F32>(),
{ctx.dst->Builtin(ast::Builtin::kPointSize)}, ctx.dst->Expr(1.f));
{ctx.dst->Builtin(ast::Builtin::kPointSize)}, ctx.dst->Expr(1_f));
}
/// Create an expression for gl_Position.[component]
@@ -580,7 +580,7 @@ struct CanonicalizeEntryPointIO::State {
ctx.dst->create<ast::UnaryOpExpression>(ast::UnaryOp::kNegation, GLPosition("y"));
wrapper_body.push_back(ctx.dst->Assign(pos_y, negate_pos_y));
auto* two_z = ctx.dst->Mul(ctx.dst->Expr(2.0f), GLPosition("z"));
auto* two_z = ctx.dst->Mul(ctx.dst->Expr(2_f), GLPosition("z"));
auto* fixed_z = ctx.dst->Sub(two_z, GLPosition("w"));
wrapper_body.push_back(ctx.dst->Assign(GLPosition("z"), fixed_z));
}

View File

@@ -350,8 +350,8 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageStridedArray) {
{
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4u>(32))),
b.Assign(b.MemberAccessor("s", "a"),
b.Construct(b.ty.array<f32, 4u>(32), 1.0f, 2.0f, 3.0f, 4.0f)),
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
b.Construct(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),
},
{
b.Stage(ast::PipelineStage::kCompute),
@@ -404,8 +404,8 @@ TEST_F(DecomposeStridedArrayTest, WriteStorageDefaultStridedArray) {
{
b.Assign(b.MemberAccessor("s", "a"), b.Construct(b.ty.array<f32, 4u>(4))),
b.Assign(b.MemberAccessor("s", "a"),
b.Construct(b.ty.array<f32, 4u>(4), 1.0f, 2.0f, 3.0f, 4.0f)),
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
b.Construct(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),
},
{
b.Stage(ast::PipelineStage::kCompute),
@@ -458,8 +458,8 @@ TEST_F(DecomposeStridedArrayTest, ReadWriteViaPointerLets) {
b.Decl(b.Let("b", nullptr, b.AddressOf(b.Deref(b.AddressOf(b.Deref("a")))))),
b.Decl(b.Let("c", nullptr, b.Deref("b"))),
b.Decl(b.Let("d", nullptr, b.IndexAccessor(b.Deref("b"), 1_i))),
b.Assign(b.Deref("b"), b.Construct(b.ty.array<f32, 4u>(32), 1.0f, 2.0f, 3.0f, 4.0f)),
b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), 5.0f),
b.Assign(b.Deref("b"), b.Construct(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),
},
{
b.Stage(ast::PipelineStage::kCompute),
@@ -519,8 +519,8 @@ TEST_F(DecomposeStridedArrayTest, PrivateAliasedStridedArray) {
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.type_name("ARR"))),
b.Assign(b.MemberAccessor("s", "a"),
b.Construct(b.ty.type_name("ARR"), 1.0f, 2.0f, 3.0f, 4.0f)),
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5.0f),
b.Construct(b.ty.type_name("ARR"), 1_f, 2_f, 3_f, 4_f)),
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "a"), 1_i), 5_f),
},
{
b.Stage(ast::PipelineStage::kCompute),
@@ -612,7 +612,7 @@ TEST_F(DecomposeStridedArrayTest, PrivateNestedStridedArray) {
3_i),
2_i),
1_i),
5.0f),
5_f),
},
{
b.Stage(ast::PipelineStage::kCompute),

View File

@@ -354,7 +354,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageMatrix) {
b.Func("f", {}, b.ty.void_(),
{
b.Assign(b.MemberAccessor("s", "m"),
b.mat2x2<f32>(b.vec2<f32>(1.0f, 2.0f), b.vec2<f32>(3.0f, 4.0f))),
b.mat2x2<f32>(b.vec2<f32>(1_f, 2_f), b.vec2<f32>(3_f, 4_f))),
},
{
b.Stage(ast::PipelineStage::kCompute),
@@ -411,7 +411,7 @@ TEST_F(DecomposeStridedMatrixTest, WriteStorageColumn) {
b.GroupAndBinding(0, 0));
b.Func("f", {}, b.ty.void_(),
{
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i), b.vec2<f32>(1.0f, 2.0f)),
b.Assign(b.IndexAccessor(b.MemberAccessor("s", "m"), 1_i), b.vec2<f32>(1_f, 2_f)),
},
{
b.Stage(ast::PipelineStage::kCompute),
@@ -468,21 +468,20 @@ TEST_F(DecomposeStridedMatrixTest, ReadWriteViaPointerLets) {
});
b.Global("s", b.ty.Of(S), ast::StorageClass::kStorage, ast::Access::kReadWrite,
b.GroupAndBinding(0, 0));
b.Func(
"f", {}, b.ty.void_(),
{
b.Decl(b.Let("a", nullptr, b.AddressOf(b.MemberAccessor("s", "m")))),
b.Decl(b.Let("b", nullptr, b.AddressOf(b.Deref(b.AddressOf(b.Deref("a")))))),
b.Decl(b.Let("x", nullptr, b.Deref("b"))),
b.Decl(b.Let("y", nullptr, b.IndexAccessor(b.Deref("b"), 1_i))),
b.Decl(b.Let("z", nullptr, b.IndexAccessor("x", 1_i))),
b.Assign(b.Deref("b"), b.mat2x2<f32>(b.vec2<f32>(1.0f, 2.0f), b.vec2<f32>(3.0f, 4.0f))),
b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), b.vec2<f32>(5.0f, 6.0f)),
},
{
b.Stage(ast::PipelineStage::kCompute),
b.WorkgroupSize(1_i),
});
b.Func("f", {}, b.ty.void_(),
{
b.Decl(b.Let("a", nullptr, b.AddressOf(b.MemberAccessor("s", "m")))),
b.Decl(b.Let("b", nullptr, b.AddressOf(b.Deref(b.AddressOf(b.Deref("a")))))),
b.Decl(b.Let("x", nullptr, b.Deref("b"))),
b.Decl(b.Let("y", nullptr, b.IndexAccessor(b.Deref("b"), 1_i))),
b.Decl(b.Let("z", nullptr, b.IndexAccessor("x", 1_i))),
b.Assign(b.Deref("b"), b.mat2x2<f32>(b.vec2<f32>(1_f, 2_f), b.vec2<f32>(3_f, 4_f))),
b.Assign(b.IndexAccessor(b.Deref("b"), 1_i), b.vec2<f32>(5_f, 6_f)),
},
{
b.Stage(ast::PipelineStage::kCompute),
b.WorkgroupSize(1_i),
});
auto* expect = R"(
struct S {
@@ -595,7 +594,7 @@ TEST_F(DecomposeStridedMatrixTest, WritePrivateMatrix) {
b.Func("f", {}, b.ty.void_(),
{
b.Assign(b.MemberAccessor("s", "m"),
b.mat2x2<f32>(b.vec2<f32>(1.0f, 2.0f), b.vec2<f32>(3.0f, 4.0f))),
b.mat2x2<f32>(b.vec2<f32>(1_f, 2_f), b.vec2<f32>(3_f, 4_f))),
},
{
b.Stage(ast::PipelineStage::kCompute),

View File

@@ -304,11 +304,11 @@ struct MultiplanarExternalTexture::State {
const ast::CallExpression* plane_1_call = nullptr;
if (call_type == sem::BuiltinType::kTextureSampleLevel) {
// textureSampleLevel(plane0, smp, coord.xy, 0.0);
single_plane_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0.0f);
single_plane_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0_f);
// textureSampleLevel(plane0, smp, coord.xy, 0.0);
plane_0_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0.0f);
plane_0_call = b.Call("textureSampleLevel", "plane0", "smp", "coord", 0_f);
// textureSampleLevel(plane1, smp, coord.xy, 0.0);
plane_1_call = b.Call("textureSampleLevel", "plane1", "smp", "coord", 0.0f);
plane_1_call = b.Call("textureSampleLevel", "plane1", "smp", "coord", 0_f);
} else if (call_type == sem::BuiltinType::kTextureLoad) {
// textureLoad(plane0, coords.xy, 0);
single_plane_call = b.Call("textureLoad", "plane0", "coord", 0_i);
@@ -334,7 +334,7 @@ struct MultiplanarExternalTexture::State {
// params.yuvToRgbConversionMatrix;
b.Assign("color",
b.Mul(b.vec4<f32>(b.MemberAccessor(plane_0_call, "r"),
b.MemberAccessor(plane_1_call, "rg"), 1.0f),
b.MemberAccessor(plane_1_call, "rg"), 1_f),
b.MemberAccessor("params", "yuvToRgbConversionMatrix")))))),
// color = gammaConversion(color, gammaDecodeParams);
b.Assign("color", b.Call("gammaCorrection", "color",
@@ -344,8 +344,8 @@ struct MultiplanarExternalTexture::State {
// color = gammaConversion(color, gammaEncodeParams);
b.Assign("color", b.Call("gammaCorrection", "color",
b.MemberAccessor("params", "gammaEncodeParams"))),
// return vec4<f32>(color, 1.0f);
b.Return(b.vec4<f32>("color", 1.0f))};
// return vec4<f32>(color, 1.f);
b.Return(b.vec4<f32>("color", 1_f))};
}
/// Creates the textureSampleExternal function if needed and returns a call

View File

@@ -361,19 +361,19 @@ struct State {
case BaseType::kI32:
ty = ctx.dst->ty.i32();
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
values.emplace_back(ctx.dst->Expr(i32((i == 3) ? 1 : 0)));
values.emplace_back(ctx.dst->Expr((i == 3) ? 1_i : 0_i));
}
break;
case BaseType::kU32:
ty = ctx.dst->ty.u32();
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
values.emplace_back(ctx.dst->Expr(u32((i == 3) ? 1u : 0u)));
values.emplace_back(ctx.dst->Expr((i == 3) ? 1_u : 0_u));
}
break;
case BaseType::kF32:
ty = ctx.dst->ty.f32();
for (uint32_t i = fmt_dt.width; i < var_dt.width; i++) {
values.emplace_back(ctx.dst->Expr((i == 3) ? 1.f : 0.f));
values.emplace_back(ctx.dst->Expr((i == 3) ? 1_f : 0_f));
}
break;
default: