aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/opts
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@chromium.org>2015-12-01 07:10:21 -0800
committerGravatar Commit bot <commit-bot@chromium.org>2015-12-01 07:10:21 -0800
commit9db43ac4ee1a83a4f7b332fe6c00f592b6237349 (patch)
treece3b9eedc76bf142d31325d041295097774fee5c /src/opts
parenteeebdb538d476c1bfc8b63a946094ca1b505ecd1 (diff)
Add Sk4f::ToBytes(uint8_t[16], Sk4f, Sk4f, Sk4f, Sk4f)
This is a big speedup for float -> byte. E.g. gradient_linear_clamp_3color: x86-64 147µs -> 103µs (Broadwell MBP) arm64 2.03ms -> 648µs (Galaxy S6) armv7 1.12ms -> 489µs (Galaxy S6, same device!) BUG=skia: CQ_EXTRA_TRYBOTS=client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-SKNX_NO_SIMD-Trybot;client.skia.android:Test-Android-GCC-Nexus9-CPU-Denver-Arm64-Debug-Trybot Review URL: https://codereview.chromium.org/1483953002
Diffstat (limited to 'src/opts')
-rw-r--r--src/opts/SkNx_neon.h8
-rw-r--r--src/opts/SkNx_sse.h9
2 files changed, 17 insertions, 0 deletions
diff --git a/src/opts/SkNx_neon.h b/src/opts/SkNx_neon.h
index a03f0be674..6fe6137e5f 100644
--- a/src/opts/SkNx_neon.h
+++ b/src/opts/SkNx_neon.h
@@ -165,6 +165,14 @@ public:
vst1_lane_u32((uint32_t*)bytes, (uint32x2_t)fix8, 0);
}
+ static void ToBytes(uint8_t bytes[16],
+ const SkNx& a, const SkNx& b, const SkNx& c, const SkNx& d) {
+ vst1q_u8(bytes, vuzpq_u8(vuzpq_u8((uint8x16_t)vcvtq_u32_f32(a.fVec),
+ (uint8x16_t)vcvtq_u32_f32(b.fVec)).val[0],
+ vuzpq_u8((uint8x16_t)vcvtq_u32_f32(c.fVec),
+ (uint8x16_t)vcvtq_u32_f32(d.fVec)).val[0]).val[0]);
+ }
+
SkNx approxInvert() const {
float32x4_t est0 = vrecpeq_f32(fVec),
est1 = vmulq_f32(vrecpsq_f32(est0, fVec), est0);
diff --git a/src/opts/SkNx_sse.h b/src/opts/SkNx_sse.h
index f0ccd3f7b5..a4f8656536 100644
--- a/src/opts/SkNx_sse.h
+++ b/src/opts/SkNx_sse.h
@@ -132,6 +132,15 @@ public:
*(int*)bytes = _mm_cvtsi128_si32(fix8);
}
+ static void ToBytes(uint8_t bytes[16],
+ const SkNx& a, const SkNx& b, const SkNx& c, const SkNx& d) {
+ _mm_storeu_si128((__m128i*)bytes,
+ _mm_packus_epi16(_mm_packus_epi16(_mm_cvttps_epi32(a.fVec),
+ _mm_cvttps_epi32(b.fVec)),
+ _mm_packus_epi16(_mm_cvttps_epi32(c.fVec),
+ _mm_cvttps_epi32(d.fVec))));
+ }
+
SkNx operator + (const SkNx& o) const { return _mm_add_ps(fVec, o.fVec); }
SkNx operator - (const SkNx& o) const { return _mm_sub_ps(fVec, o.fVec); }
SkNx operator * (const SkNx& o) const { return _mm_mul_ps(fVec, o.fVec); }