Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(991)

Unified Diff: src/core/SkHalf.h

Issue 2159993003: Improve naive SkColorXform to half floats (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix NO_SIMD bot Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/core/SkHalf.h
diff --git a/src/core/SkHalf.h b/src/core/SkHalf.h
index 2f2ed66c6a64016ee0ae512f92c2876298f2988e..5a95ab9a1ce253569081c7dad0d3f691720c3cc8 100644
--- a/src/core/SkHalf.h
+++ b/src/core/SkHalf.h
@@ -65,14 +65,12 @@ static inline Sk4f SkHalfToFloat_finite(uint64_t hs) {
#endif
}
-static inline uint64_t SkFloatToHalf_finite(const Sk4f& fs) {
- uint64_t r;
+static inline Sk4h SkFloatToVectorHalf_finite(const Sk4f& fs) {
#if !defined(SKNX_NO_SIMD) && defined(SK_CPU_ARM64)
float32x4_t vec = fs.fVec;
asm ("fcvtn %[vec].4h, %[vec].4s \n" // vcvt_f16_f32(vec)
- "fmov %[r], %d[vec] \n" // vst1_f16(&r, ...)
- : [r] "=r" (r) // =r: write-only 64-bit general register
- , [vec] "+w" (vec)); // +w: read-write NEON register
+ : [vec] "+w" (vec)); // +w: read-write NEON register
+ return vreinterpret_u16_f32(vget_low_f32(vec));
mtklein 2016/07/19 12:45:46 Duh, nice.
#else
Sk4i bits = Sk4i::Load(&fs),
sign = bits & 0x80000000, // Save the sign bit for later...
@@ -91,8 +89,14 @@ static inline uint64_t SkFloatToHalf_finite(const Sk4f& fs) {
Sk4i denorm = Sk4i::Load(&plus_K) ^ K;
Sk4i merged = (sign >> 16) | will_be_denorm.thenElse(denorm, norm);
- SkNx_cast<uint16_t>(merged).store(&r);
+ return SkNx_cast<uint16_t>(merged);
#endif
+}
+
+static inline uint64_t SkFloatToHalf_finite(const Sk4f& fs) {
mtklein 2016/07/19 12:45:45 Let's port over the other uses and call your new s
msarett 2016/07/19 15:24:49 Done.
+ uint64_t r;
+ Sk4h v = SkFloatToVectorHalf_finite(fs);
+ v.store(&r);
return r;
}

Powered by Google App Engine
This is Rietveld 408576698