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

Unified Diff: src/opts/SkNx_sse.h

Issue 1196713004: Implement four more xfermodes with Sk4px. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: manually cast for missing 64-bit vreinterprets Created 5 years, 6 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') | src/opts/SkXfermode_opts_SSE2.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 12a4719d0ce4860b555f397fff0f7260021433a5..9b4de700ee67aa4f81da20da09f7d42ed9af9c3a 100644
--- a/src/opts/SkNx_sse.h
+++ b/src/opts/SkNx_sse.h
@@ -12,46 +12,9 @@
namespace { // See SkNx.h
-template <>
-class SkNb<2, 4> {
-public:
- SkNb(const __m128i& vec) : fVec(vec) {}
-
- SkNb() {}
- bool allTrue() const { return 0xff == (_mm_movemask_epi8(fVec) & 0xff); }
- bool anyTrue() const { return 0x00 != (_mm_movemask_epi8(fVec) & 0xff); }
-
- __m128i fVec;
-};
-
-template <>
-class SkNb<4, 4> {
-public:
- SkNb(const __m128i& vec) : fVec(vec) {}
-
- SkNb() {}
- bool allTrue() const { return 0xffff == _mm_movemask_epi8(fVec); }
- bool anyTrue() const { return 0x0000 != _mm_movemask_epi8(fVec); }
-
- __m128i fVec;
-};
-
-template <>
-class SkNb<2, 8> {
-public:
- SkNb(const __m128i& vec) : fVec(vec) {}
-
- SkNb() {}
- bool allTrue() const { return 0xffff == _mm_movemask_epi8(fVec); }
- bool anyTrue() const { return 0x0000 != _mm_movemask_epi8(fVec); }
-
- __m128i fVec;
-};
-
template <>
class SkNf<2, float> {
- typedef SkNb<2, 4> Nb;
public:
SkNf(const __m128& vec) : fVec(vec) {}
@@ -69,12 +32,12 @@ public:
SkNf operator * (const SkNf& o) const { return _mm_mul_ps(fVec, o.fVec); }
SkNf operator / (const SkNf& o) const { return _mm_div_ps(fVec, o.fVec); }
- Nb operator == (const SkNf& o) const { return _mm_castps_si128(_mm_cmpeq_ps (fVec, o.fVec)); }
- Nb operator != (const SkNf& o) const { return _mm_castps_si128(_mm_cmpneq_ps(fVec, o.fVec)); }
- Nb operator < (const SkNf& o) const { return _mm_castps_si128(_mm_cmplt_ps (fVec, o.fVec)); }
- Nb operator > (const SkNf& o) const { return _mm_castps_si128(_mm_cmpgt_ps (fVec, o.fVec)); }
- Nb operator <= (const SkNf& o) const { return _mm_castps_si128(_mm_cmple_ps (fVec, o.fVec)); }
- Nb operator >= (const SkNf& o) const { return _mm_castps_si128(_mm_cmpge_ps (fVec, o.fVec)); }
+ SkNf operator == (const SkNf& o) const { return _mm_cmpeq_ps (fVec, o.fVec); }
+ SkNf operator != (const SkNf& o) const { return _mm_cmpneq_ps(fVec, o.fVec); }
+ SkNf operator < (const SkNf& o) const { return _mm_cmplt_ps (fVec, o.fVec); }
+ SkNf operator > (const SkNf& o) const { return _mm_cmpgt_ps (fVec, o.fVec); }
+ SkNf operator <= (const SkNf& o) const { return _mm_cmple_ps (fVec, o.fVec); }
+ SkNf operator >= (const SkNf& o) const { return _mm_cmpge_ps (fVec, o.fVec); }
static SkNf Min(const SkNf& l, const SkNf& r) { return _mm_min_ps(l.fVec, r.fVec); }
static SkNf Max(const SkNf& l, const SkNf& r) { return _mm_max_ps(l.fVec, r.fVec); }
@@ -93,12 +56,14 @@ public:
return pun.fs[k&1];
}
+ bool allTrue() const { return 0xff == (_mm_movemask_epi8(_mm_castps_si128(fVec)) & 0xff); }
+ bool anyTrue() const { return 0x00 != (_mm_movemask_epi8(_mm_castps_si128(fVec)) & 0xff); }
+
__m128 fVec;
};
template <>
class SkNf<2, double> {
- typedef SkNb<2, 8> Nb;
public:
SkNf(const __m128d& vec) : fVec(vec) {}
@@ -114,12 +79,12 @@ public:
SkNf operator * (const SkNf& o) const { return _mm_mul_pd(fVec, o.fVec); }
SkNf operator / (const SkNf& o) const { return _mm_div_pd(fVec, o.fVec); }
- Nb operator == (const SkNf& o) const { return _mm_castpd_si128(_mm_cmpeq_pd (fVec, o.fVec)); }
- Nb operator != (const SkNf& o) const { return _mm_castpd_si128(_mm_cmpneq_pd(fVec, o.fVec)); }
- Nb operator < (const SkNf& o) const { return _mm_castpd_si128(_mm_cmplt_pd (fVec, o.fVec)); }
- Nb operator > (const SkNf& o) const { return _mm_castpd_si128(_mm_cmpgt_pd (fVec, o.fVec)); }
- Nb operator <= (const SkNf& o) const { return _mm_castpd_si128(_mm_cmple_pd (fVec, o.fVec)); }
- Nb operator >= (const SkNf& o) const { return _mm_castpd_si128(_mm_cmpge_pd (fVec, o.fVec)); }
+ SkNf operator == (const SkNf& o) const { return _mm_cmpeq_pd (fVec, o.fVec); }
+ SkNf operator != (const SkNf& o) const { return _mm_cmpneq_pd(fVec, o.fVec); }
+ SkNf operator < (const SkNf& o) const { return _mm_cmplt_pd (fVec, o.fVec); }
+ SkNf operator > (const SkNf& o) const { return _mm_cmpgt_pd (fVec, o.fVec); }
+ SkNf operator <= (const SkNf& o) const { return _mm_cmple_pd (fVec, o.fVec); }
+ SkNf operator >= (const SkNf& o) const { return _mm_cmpge_pd (fVec, o.fVec); }
static SkNf Min(const SkNf& l, const SkNf& r) { return _mm_min_pd(l.fVec, r.fVec); }
static SkNf Max(const SkNf& l, const SkNf& r) { return _mm_max_pd(l.fVec, r.fVec); }
@@ -138,6 +103,9 @@ public:
return pun.ds[k&1];
}
+ bool allTrue() const { return 0xffff == _mm_movemask_epi8(_mm_castpd_si128(fVec)); }
+ bool anyTrue() const { return 0x0000 != _mm_movemask_epi8(_mm_castpd_si128(fVec)); }
+
__m128d fVec;
};
@@ -181,7 +149,6 @@ public:
template <>
class SkNf<4, float> {
- typedef SkNb<4, 4> Nb;
public:
SkNf(const __m128& vec) : fVec(vec) {}
@@ -199,12 +166,12 @@ public:
SkNf operator * (const SkNf& o) const { return _mm_mul_ps(fVec, o.fVec); }
SkNf operator / (const SkNf& o) const { return _mm_div_ps(fVec, o.fVec); }
- Nb operator == (const SkNf& o) const { return _mm_castps_si128(_mm_cmpeq_ps (fVec, o.fVec)); }
- Nb operator != (const SkNf& o) const { return _mm_castps_si128(_mm_cmpneq_ps(fVec, o.fVec)); }
- Nb operator < (const SkNf& o) const { return _mm_castps_si128(_mm_cmplt_ps (fVec, o.fVec)); }
- Nb operator > (const SkNf& o) const { return _mm_castps_si128(_mm_cmpgt_ps (fVec, o.fVec)); }
- Nb operator <= (const SkNf& o) const { return _mm_castps_si128(_mm_cmple_ps (fVec, o.fVec)); }
- Nb operator >= (const SkNf& o) const { return _mm_castps_si128(_mm_cmpge_ps (fVec, o.fVec)); }
+ SkNf operator == (const SkNf& o) const { return _mm_cmpeq_ps (fVec, o.fVec); }
+ SkNf operator != (const SkNf& o) const { return _mm_cmpneq_ps(fVec, o.fVec); }
+ SkNf operator < (const SkNf& o) const { return _mm_cmplt_ps (fVec, o.fVec); }
+ SkNf operator > (const SkNf& o) const { return _mm_cmpgt_ps (fVec, o.fVec); }
+ SkNf operator <= (const SkNf& o) const { return _mm_cmple_ps (fVec, o.fVec); }
+ SkNf operator >= (const SkNf& o) const { return _mm_cmpge_ps (fVec, o.fVec); }
static SkNf Min(const SkNf& l, const SkNf& r) { return _mm_min_ps(l.fVec, r.fVec); }
static SkNf Max(const SkNf& l, const SkNf& r) { return _mm_max_ps(l.fVec, r.fVec); }
@@ -223,6 +190,9 @@ public:
return pun.fs[k&3];
}
+ bool allTrue() const { return 0xffff == _mm_movemask_epi8(_mm_castps_si128(fVec)); }
+ bool anyTrue() const { return 0x0000 != _mm_movemask_epi8(_mm_castps_si128(fVec)); }
+
__m128 fVec;
};
@@ -312,6 +282,11 @@ public:
SkNi operator - (const SkNi& o) const { return _mm_sub_epi8(fVec, o.fVec); }
static SkNi Min(const SkNi& a, const SkNi& b) { return _mm_min_epu8(a.fVec, b.fVec); }
+ SkNi operator < (const SkNi& o) const {
+ // There's no unsigned _mm_cmplt_epu8, so we flip the sign bits then use a signed compare.
+ auto flip = _mm_set1_epi8(char(0x80));
+ return _mm_cmplt_epi8(_mm_xor_si128(flip, fVec), _mm_xor_si128(flip, o.fVec));
+ }
template <int k> uint8_t kth() const {
SkASSERT(0 <= k && k < 16);
@@ -320,6 +295,11 @@ public:
return k % 2 == 0 ? pair : (pair >> 8);
}
+ SkNi thenElse(const SkNi& t, const SkNi& e) const {
+ return _mm_or_si128(_mm_and_si128 (fVec, t.fVec),
+ _mm_andnot_si128(fVec, e.fVec));
+ }
+
__m128i fVec;
};
« no previous file with comments | « src/opts/SkNx_neon.h ('k') | src/opts/SkXfermode_opts_SSE2.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698