remove "half" term from SkVM
fp16 is a more precise name, given that there are things like bfloat16, and this may free up the word "half" for the same sort of more nebulous format as we use it in SkSL. Change-Id: I55c39f3670f2c300b9306c92a86c4ec7a2e7b5d7 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/339577 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Mike Klein <mtklein@google.com>
This commit is contained in:
parent
356cef301b
commit
42d67a67f5
@ -287,8 +287,8 @@ namespace skvm {
|
||||
case Op::ceil: write(o, V{id}, "=", op, V{x}); break;
|
||||
case Op::floor: write(o, V{id}, "=", op, V{x}); break;
|
||||
case Op::to_f32: write(o, V{id}, "=", op, V{x}); break;
|
||||
case Op::to_half: write(o, V{id}, "=", op, V{x}); break;
|
||||
case Op::from_half: write(o, V{id}, "=", op, V{x}); break;
|
||||
case Op::to_fp16: write(o, V{id}, "=", op, V{x}); break;
|
||||
case Op::from_fp16: write(o, V{id}, "=", op, V{x}); break;
|
||||
case Op::trunc: write(o, V{id}, "=", op, V{x}); break;
|
||||
case Op::round: write(o, V{id}, "=", op, V{x}); break;
|
||||
}
|
||||
@ -397,8 +397,8 @@ namespace skvm {
|
||||
case Op::ceil: write(o, R{d}, "=", op, R{x}); break;
|
||||
case Op::floor: write(o, R{d}, "=", op, R{x}); break;
|
||||
case Op::to_f32: write(o, R{d}, "=", op, R{x}); break;
|
||||
case Op::to_half: write(o, R{d}, "=", op, R{x}); break;
|
||||
case Op::from_half: write(o, R{d}, "=", op, R{x}); break;
|
||||
case Op::to_fp16: write(o, R{d}, "=", op, R{x}); break;
|
||||
case Op::from_fp16: write(o, R{d}, "=", op, R{x}); break;
|
||||
case Op::trunc: write(o, R{d}, "=", op, R{x}); break;
|
||||
case Op::round: write(o, R{d}, "=", op, R{x}); break;
|
||||
}
|
||||
@ -1061,13 +1061,13 @@ namespace skvm {
|
||||
return {this, this->push(Op::round, x.id)};
|
||||
}
|
||||
|
||||
I32 Builder::to_half(F32 x) {
|
||||
I32 Builder::to_fp16(F32 x) {
|
||||
if (float X; this->allImm(x.id,&X)) { return splat((int)SkFloatToHalf(X)); }
|
||||
return {this, this->push(Op::to_half, x.id)};
|
||||
return {this, this->push(Op::to_fp16, x.id)};
|
||||
}
|
||||
F32 Builder::from_half(I32 x) {
|
||||
F32 Builder::from_fp16(I32 x) {
|
||||
if (int X; this->allImm(x.id,&X)) { return splat(SkHalfToFloat(X)); }
|
||||
return {this, this->push(Op::from_half, x.id)};
|
||||
return {this, this->push(Op::from_fp16, x.id)};
|
||||
}
|
||||
|
||||
F32 Builder::from_unorm(int bits, I32 x) {
|
||||
@ -1132,7 +1132,7 @@ namespace skvm {
|
||||
I32 channel = extract(x, shift, (1<<bits)-1);
|
||||
switch (f.encoding) {
|
||||
case PixelFormat::UNORM: return from_unorm(bits, channel);
|
||||
case PixelFormat::FLOAT: return from_half ( channel);
|
||||
case PixelFormat::FLOAT: return from_fp16 ( channel);
|
||||
}
|
||||
SkUNREACHABLE;
|
||||
};
|
||||
@ -1254,7 +1254,7 @@ namespace skvm {
|
||||
I32 encoded;
|
||||
switch (f.encoding) {
|
||||
case PixelFormat::UNORM: encoded = to_unorm(bits, channel); break;
|
||||
case PixelFormat::FLOAT: encoded = to_half ( channel); break;
|
||||
case PixelFormat::FLOAT: encoded = to_fp16 ( channel); break;
|
||||
}
|
||||
packed = pack(packed, encoded, shift);
|
||||
};
|
||||
@ -3704,12 +3704,12 @@ namespace skvm {
|
||||
else { a->vcvtps2dq(dst(), any(x)); }
|
||||
break;
|
||||
|
||||
case Op::to_half:
|
||||
case Op::to_fp16:
|
||||
a->vcvtps2ph(dst(x), r(x), A::CURRENT); // f32 ymm -> f16 xmm
|
||||
a->vpmovzxwd(dst(), dst()); // f16 xmm -> f16 ymm
|
||||
break;
|
||||
|
||||
case Op::from_half:
|
||||
case Op::from_fp16:
|
||||
a->vpackusdw(dst(x), r(x), r(x)); // f16 ymm -> f16 xmm
|
||||
a->vpermq (dst(), dst(), 0xd8); // swap middle two 64-bit lanes
|
||||
a->vcvtph2ps(dst(), dst()); // f16 xmm -> f32 ymm
|
||||
@ -3720,8 +3720,8 @@ namespace skvm {
|
||||
case Op::store128:
|
||||
case Op::load64:
|
||||
case Op::load128:
|
||||
case Op::to_half:
|
||||
case Op::from_half:
|
||||
case Op::to_fp16:
|
||||
case Op::from_fp16:
|
||||
return false; // TODO
|
||||
|
||||
case Op::assert_true: {
|
||||
|
@ -438,7 +438,7 @@ namespace skvm {
|
||||
M(fma_f32) M(fms_f32) M(fnma_f32) \
|
||||
M(sqrt_f32) \
|
||||
M(shl_i32) M(shr_i32) M(sra_i32) \
|
||||
M(ceil) M(floor) M(trunc) M(round) M(to_half) M(from_half) \
|
||||
M(ceil) M(floor) M(trunc) M(round) M(to_fp16) M(from_fp16) \
|
||||
M(to_f32) \
|
||||
M(neq_f32) M(eq_f32) M(eq_i32) \
|
||||
M(gte_f32) M(gt_f32) M(gt_i32) \
|
||||
@ -715,8 +715,8 @@ namespace skvm {
|
||||
I32 round(F32 x); // Round to int using current rounding mode (as if lrintf()).
|
||||
I32 bit_cast(F32 x) { return {x.builder, x.id}; }
|
||||
|
||||
I32 to_half(F32 x);
|
||||
F32 from_half(I32 x);
|
||||
I32 to_fp16(F32 x);
|
||||
F32 from_fp16(I32 x);
|
||||
|
||||
F32 norm(F32 x, F32 y) {
|
||||
return sqrt(add(mul(x,x),
|
||||
@ -1050,8 +1050,8 @@ namespace skvm {
|
||||
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 I32 to_half(F32 x) { return x-> to_half(x); }
|
||||
static inline F32 from_half(I32 x) { return x->from_half(x); }
|
||||
static inline I32 to_fp16(F32 x) { return x-> to_fp16(x); }
|
||||
static inline F32 from_fp16(I32 x) { return x->from_fp16(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); }
|
||||
|
@ -259,10 +259,10 @@ namespace SK_OPTS_NS {
|
||||
CASE(Op::trunc): r[d].i32 = skvx::cast<int> ( r[x].f32 ); break;
|
||||
CASE(Op::round): r[d].i32 = skvx::cast<int> (skvx::lrint(r[x].f32)); break;
|
||||
|
||||
CASE(Op::to_half):
|
||||
CASE(Op::to_fp16):
|
||||
r[d].i32 = skvx::cast<int>(skvx::to_half(r[x].f32));
|
||||
break;
|
||||
CASE(Op::from_half):
|
||||
CASE(Op::from_fp16):
|
||||
r[d].f32 = skvx::from_half(skvx::cast<uint16_t>(r[x].i32));
|
||||
break;
|
||||
|
||||
|
@ -2273,7 +2273,7 @@ DEF_TEST(SkVM_halfs, r) {
|
||||
skvm::Builder b;
|
||||
skvm::Arg src = b.varying<uint16_t>(),
|
||||
dst = b.varying<float>();
|
||||
b.storeF(dst, b.from_half(b.load16(src)));
|
||||
b.storeF(dst, b.from_fp16(b.load16(src)));
|
||||
|
||||
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program){
|
||||
float dst[8];
|
||||
@ -2287,7 +2287,7 @@ DEF_TEST(SkVM_halfs, r) {
|
||||
skvm::Builder b;
|
||||
skvm::Arg src = b.varying<float>(),
|
||||
dst = b.varying<uint16_t>();
|
||||
b.store16(dst, b.to_half(b.loadF(src)));
|
||||
b.store16(dst, b.to_fp16(b.loadF(src)));
|
||||
|
||||
test_jit_and_interpreter(b.done(), [&](const skvm::Program& program){
|
||||
uint16_t dst[8];
|
||||
|
Loading…
Reference in New Issue
Block a user