Index: src/opts/SkNx_sse.h |
diff --git a/src/opts/SkNx_sse.h b/src/opts/SkNx_sse.h |
index 9423d0455122cf37d50653ca7db3b254bdf2a3ac..0e9494c2385a2fed149e6dca9a567239ecf71ccb 100644 |
--- a/src/opts/SkNx_sse.h |
+++ b/src/opts/SkNx_sse.h |
@@ -272,6 +272,15 @@ public: |
SkNi operator << (int bits) const { return _mm_slli_epi16(fVec, bits); } |
SkNi operator >> (int bits) const { return _mm_srli_epi16(fVec, bits); } |
+ static SkNi Min(const SkNi& a, const SkNi& b) { |
+ // No unsigned _mm_min_epu16, so we'll shift into a space where we can use the |
+ // signed version, _mm_min_epi16, then shift back. |
+ const uint16_t top = 0x8000; // Keep this separate from _mm_set1_epi16 or MSVC will whine. |
+ const __m128i top_8x = _mm_set1_epi16(top); |
+ return _mm_add_epi8(top_8x, _mm_min_epi16(_mm_sub_epi8(a.fVec, top_8x), |
+ _mm_sub_epi8(b.fVec, top_8x))); |
+ } |
+ |
template <int k> uint16_t kth() const { |
SkASSERT(0 <= k && k < 8); |
return _mm_extract_epi16(fVec, k); |
@@ -306,6 +315,8 @@ public: |
SkNi operator << (int bits) const { SkASSERT(false); return fVec; } |
SkNi operator >> (int bits) const { SkASSERT(false); return fVec; } |
+ static SkNi Min(const SkNi& a, const SkNi& b) { return _mm_min_epu8(a.fVec, b.fVec); } |
+ |
template <int k> uint8_t kth() const { |
SkASSERT(0 <= k && k < 16); |
// SSE4.1 would just `return _mm_extract_epi8(fVec, k)`. We have to read 16-bits instead. |