diff options
author | Chris Dalton <csmartdalton@google.com> | 2018-04-11 13:18:09 -0600 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2018-04-12 14:29:00 +0000 |
commit | e3fda9310a8996edbbb1d14acc8f5da07f2d2740 (patch) | |
tree | 828825030b2d3d5cbe9c4e40792a2c2f6b9a0df9 /src | |
parent | 74e5937c188fccf57ba88208783ba39fb1aa6881 (diff) |
Implement Sk4f min/max
Bug: skia:
Change-Id: Icf235dea81e9f125c1c8590ec87cb3591393036c
Reviewed-on: https://skia-review.googlesource.com/120281
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/core/SkNx.h | 4 | ||||
-rw-r--r-- | src/opts/SkNx_neon.h | 18 | ||||
-rw-r--r-- | src/opts/SkNx_sse.h | 12 |
3 files changed, 34 insertions, 0 deletions
diff --git a/src/core/SkNx.h b/src/core/SkNx.h index 0b41365e82..11c8f7c665 100644 --- a/src/core/SkNx.h +++ b/src/core/SkNx.h @@ -103,6 +103,8 @@ struct SkNx { Half::Store2(ptr + 2*N/2*sizeof(T), a.fHi, b.fHi); } + AI T min() const { return std::min(fLo.min(), fHi.min()); } + AI T max() const { return std::max(fLo.max(), fHi.max()); } AI bool anyTrue() const { return fLo.anyTrue() || fHi.anyTrue(); } AI bool allTrue() const { return fLo.allTrue() && fHi.allTrue(); } @@ -211,6 +213,8 @@ struct SkNx<1,T> { b.store(ptr + 1*sizeof(T)); } + AI T min() const { return fVal; } + AI T max() const { return fVal; } AI bool anyTrue() const { return fVal != 0; } AI bool allTrue() const { return fVal != 0; } diff --git a/src/opts/SkNx_neon.h b/src/opts/SkNx_neon.h index 232903ab67..9020036076 100644 --- a/src/opts/SkNx_neon.h +++ b/src/opts/SkNx_neon.h @@ -244,6 +244,24 @@ public: return pun.fs[k&3]; } + AI float min() const { + #if defined(__aarch64__) + return vminvq_f32(fVec); + #else + SkNx min = Min(*this, vrev64q_f32(fVec)); + return std::min(min[0], min[2]); + #endif + } + + AI float max() const { + #if defined(__aarch64__) + return vmaxvq_f32(fVec); + #else + SkNx max = Max(*this, vrev64q_f32(fVec)); + return std::max(max[0], max[2]); + #endif + } + AI bool allTrue() const { #if defined(__aarch64__) return 0 != vminvq_u32(vreinterpretq_u32_f32(fVec)); diff --git a/src/opts/SkNx_sse.h b/src/opts/SkNx_sse.h index bd5c58e261..00edc3a51f 100644 --- a/src/opts/SkNx_sse.h +++ b/src/opts/SkNx_sse.h @@ -176,6 +176,18 @@ public: return pun.fs[k&3]; } + AI float min() const { + SkNx min = Min(*this, _mm_shuffle_ps(fVec, fVec, _MM_SHUFFLE(2,3,0,1))); + min = Min(min, _mm_shuffle_ps(min.fVec, min.fVec, _MM_SHUFFLE(0,1,2,3))); + return min[0]; + } + + AI float max() const { + SkNx max = Max(*this, _mm_shuffle_ps(fVec, fVec, _MM_SHUFFLE(2,3,0,1))); + max = Max(max, _mm_shuffle_ps(max.fVec, max.fVec, _MM_SHUFFLE(0,1,2,3))); + return max[0]; + } + AI bool allTrue() const { return 0xffff == _mm_movemask_epi8(_mm_castps_si128(fVec)); } AI bool anyTrue() const { return 0x0000 != _mm_movemask_epi8(_mm_castps_si128(fVec)); } |