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

Unified Diff: src/opts/SkNx_sse.h

Issue 1133933004: add Min to SkNi, specialized for u8 and u16 on SSE and NEON (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fixes Created 5 years, 7 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
« no previous file with comments | « src/opts/SkNx_neon.h ('k') | tests/SkNxTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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.
« no previous file with comments | « src/opts/SkNx_neon.h ('k') | tests/SkNxTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698