to_foo() -> to_Foo()

This tweak makes these conversion functions' names
match the names of the types, e.g. to_F32() makes F32.

Change-Id: I4d71c9bd17d835d09375e3343ee4316082b02889
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/319763
Reviewed-by: Mike Klein <mtklein@google.com>
Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
Mike Klein 2020-09-25 14:47:44 -05:00 committed by Skia Commit-Bot
parent 4e48490717
commit cac130ffc1
4 changed files with 25 additions and 25 deletions

View File

@ -861,7 +861,7 @@ namespace skvm {
// See http://www.machinedlearnings.com/2011/06/fast-approximate-logarithm-exponential.html.
F32 Builder::approx_log2(F32 x) {
// e - 127 is a fair approximation of log2(x) in its own right...
F32 e = mul(to_f32(bit_cast(x)), splat(1.0f / (1<<23)));
F32 e = mul(to_F32(bit_cast(x)), splat(1.0f / (1<<23)));
// ... but using the mantissa to refine its error is _much_ better.
F32 m = bit_cast(bit_or(bit_and(bit_cast(x), 0x007fffff),
@ -1053,12 +1053,12 @@ namespace skvm {
return {this, this->push(Op::select_q14, cond.id, t.id, f.id)};
}
Q14 Builder::to_q14(I32 x) { return {this, this->push(Op:: to_q14, x.id) }; }
I32 Builder::to_i32(Q14 x) { return {this, this->push(Op::from_q14, x.id) }; }
Q14 Builder::to_Q14(I32 x) { return {this, this->push(Op:: to_q14, x.id) }; }
I32 Builder::to_I32(Q14 x) { return {this, this->push(Op::from_q14, x.id) }; }
// TODO: open question in general whether float -> q14 should round() or trunc().
Q14 Builder::to_q14(F32 x) { return to_q14(trunc(x * 16384.0f)); }
F32 Builder::to_f32(Q14 x) { return to_f32(to_i32(x)) * (1/16384.0f); }
Q14 Builder::to_Q14(F32 x) { return to_Q14(trunc(x * 16384.0f)); }
F32 Builder::to_F32(Q14 x) { return to_F32(to_I32(x)) * (1/16384.0f); }
Q14 Builder::unsigned_avg(Q14 x, Q14 y) {
return {this, this->push(Op::uavg_q14, x.id, y.id)};
@ -1205,7 +1205,7 @@ namespace skvm {
if (float X; this->allImm(x.id,&X)) { return splat(floorf(X)); }
return {this, this->push(Op::floor, x.id)};
}
F32 Builder::to_f32(I32 x) {
F32 Builder::to_F32(I32 x) {
if (int X; this->allImm(x.id,&X)) { return splat((float)X); }
return {this, this->push(Op::to_f32, x.id)};
}
@ -1229,7 +1229,7 @@ namespace skvm {
F32 Builder::from_unorm(int bits, I32 x) {
F32 limit = splat(1 / ((1<<bits)-1.0f));
return mul(to_f32(x), limit);
return mul(to_F32(x), limit);
}
I32 Builder::to_unorm(int bits, F32 x) {
F32 limit = splat((1<<bits)-1.0f);

View File

@ -761,7 +761,7 @@ namespace skvm {
I32 gt (I32 x, I32 y); I32 gt (I32a x, I32a y) { return gt (_(x), _(y)); }
I32 gte(I32 x, I32 y); I32 gte(I32a x, I32a y) { return gte(_(x), _(y)); }
F32 to_f32(I32 x);
F32 to_F32(I32 x);
F32 bit_cast(I32 x) { return {x.builder, x.id}; }
// Bitwise operations.
@ -819,8 +819,8 @@ namespace skvm {
Q14 unsigned_avg(Q14 x, Q14 y); // (x+y+1)>>1
Q14 unsigned_avg(Q14a x, Q14a y) { return unsigned_avg(_(x), _(y)); }
Q14 to_q14(F32); F32 to_f32(Q14); // Converts values, e.g. 0x4000 <-> 1.0f
Q14 to_q14(I32); I32 to_i32(Q14); // Preserves bits, e.g. 0x4000 <-> 0x00004000
Q14 to_Q14(F32); F32 to_F32(Q14); // Converts values, e.g. 0x4000 <-> 1.0f
Q14 to_Q14(I32); I32 to_I32(Q14); // Preserves bits, e.g. 0x4000 <-> 0x00004000
// Common idioms used in several places, worth centralizing for consistency.
F32 from_unorm(int bits, I32); // E.g. from_unorm(8, x) -> x * (1/255.0f)
@ -1163,14 +1163,14 @@ namespace skvm {
static inline I32 round(F32 x) { return x-> round(x); }
static inline I32 bit_cast(F32 x) { return x-> bit_cast(x); }
static inline F32 bit_cast(I32 x) { return x-> bit_cast(x); }
static inline F32 to_f32(I32 x) { return x-> to_f32(x); }
static inline F32 to_F32(I32 x) { return x-> to_F32(x); }
static inline I32 to_half(F32 x) { return x-> to_half(x); }
static inline F32 from_half(I32 x) { return x->from_half(x); }
static inline F32 to_f32(Q14 x) { return x->to_f32(x); }
static inline I32 to_i32(Q14 x) { return x->to_i32(x); }
static inline Q14 to_q14(F32 x) { return x->to_q14(x); }
static inline Q14 to_q14(I32 x) { return x->to_q14(x); }
static inline F32 to_F32(Q14 x) { return x->to_F32(x); }
static inline I32 to_I32(Q14 x) { return x->to_I32(x); }
static inline Q14 to_Q14(F32 x) { return x->to_Q14(x); }
static inline Q14 to_Q14(I32 x) { return x->to_Q14(x); }
static inline F32 lerp(F32 lo, F32a hi, F32a t) { return lo->lerp(lo,hi,t); }
static inline F32 lerp(float lo, F32 hi, F32a t) { return hi->lerp(lo,hi,t); }

View File

@ -120,8 +120,8 @@ namespace {
skvm::I32 dx = p.uniform32(uniforms->base, offsetof(BlitterUniforms, right))
- p.index(),
dy = p.uniform32(uniforms->base, offsetof(BlitterUniforms, y));
skvm::Coord device = {to_f32(dx) + 0.5f,
to_f32(dy) + 0.5f},
skvm::Coord device = {to_F32(dx) + 0.5f,
to_F32(dy) + 0.5f},
local = device;
skvm::Color paint = {
@ -194,8 +194,8 @@ namespace {
skvm::I32 dx = p->uniform32(uniforms->base, offsetof(BlitterUniforms, right))
- p->index(),
dy = p->uniform32(uniforms->base, offsetof(BlitterUniforms, y));
skvm::Coord device = {to_f32(dx) + 0.5f,
to_f32(dy) + 0.5f},
skvm::Coord device = {to_F32(dx) + 0.5f,
to_F32(dy) + 0.5f},
local = device;
skvm::Color paint = {
@ -449,7 +449,7 @@ namespace {
// we can bake it in without hurting the cache hit rate.
float scale = rate * ( 2/128.0f),
bias = rate * (-63/128.0f);
skvm::F32 dither = to_f32(M) * scale + bias;
skvm::F32 dither = to_F32(M) * scale + bias;
c.r += dither;
c.g += dither;
c.b += dither;

View File

@ -652,7 +652,7 @@ DEF_TEST(SkVM_mad, r) {
{
skvm::Arg arg = b.varying<int>();
skvm::F32 x = b.to_f32(b.load32(arg)),
skvm::F32 x = b.to_F32(b.load32(arg)),
y = b.mad(x,x,x), // x is needed in the future, so r[x] != r[y].
z = b.mad(y,y,x), // y is needed in the future, but r[z] = r[x] is ok.
w = b.mad(z,z,y), // w can alias z but not y.
@ -678,7 +678,7 @@ DEF_TEST(SkVM_fms, r) {
{
skvm::Arg arg = b.varying<int>();
skvm::F32 x = b.to_f32(b.load32(arg)),
skvm::F32 x = b.to_F32(b.load32(arg)),
v = b.sub(b.mul(x, b.splat(2.0f)),
b.splat(1.0f));
b.store32(arg, b.trunc(v));
@ -700,7 +700,7 @@ DEF_TEST(SkVM_fnma, r) {
{
skvm::Arg arg = b.varying<int>();
skvm::F32 x = b.to_f32(b.load32(arg)),
skvm::F32 x = b.to_F32(b.load32(arg)),
v = b.sub(b.splat(1.0f),
b.mul(x, b.splat(2.0f)));
b.store32(arg, b.trunc(v));
@ -2489,8 +2489,8 @@ DEF_TEST(SkVM_Q14, r) {
skvm::Arg dst = b.varying<uint16_t>(),
src = b.varying<uint16_t>();
skvm::Q14 x = to_q14(b.load16(src));
store16(dst, to_i32(test.fn(x)));
skvm::Q14 x = to_Q14(b.load16(src));
store16(dst, to_I32(test.fn(x)));
}
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program){