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

Unified Diff: src/opts/SkNx_avx.h

Issue 1464623002: Add SkNx_cast(). (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: derp, is stands for _ints_ Created 5 years, 1 month 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/core/SkNx.h ('k') | src/opts/SkNx_neon.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/opts/SkNx_avx.h
diff --git a/src/opts/SkNx_avx.h b/src/opts/SkNx_avx.h
index 86caac20b659bafe61e97cc7522d1f3d97c67207..9697303e37bcc9000c293fd8cb86387556fa7f4b 100644
--- a/src/opts/SkNx_avx.h
+++ b/src/opts/SkNx_avx.h
@@ -16,15 +16,15 @@
namespace { // See SkNx.h
template <>
-class SkNf<8> {
+class SkNx<8, float> {
public:
- SkNf(const __m256& vec) : fVec(vec) {}
+ SkNx(const __m256& vec) : fVec(vec) {}
- SkNf() {}
- SkNf(float val) : fVec(_mm256_set1_ps(val)) {}
- static SkNf Load(const float vals[8]) { return _mm256_loadu_ps(vals); }
+ SkNx() {}
+ SkNx(float val) : fVec(_mm256_set1_ps(val)) {}
+ static SkNx Load(const float vals[8]) { return _mm256_loadu_ps(vals); }
- static SkNf FromBytes(const uint8_t bytes[8]) {
+ static SkNx FromBytes(const uint8_t bytes[8]) {
__m128i fix8 = _mm_loadl_epi64((const __m128i*)bytes),
fix16 = _mm_unpacklo_epi8 (fix8 , _mm_setzero_si128()),
lo32 = _mm_unpacklo_epi16(fix16, _mm_setzero_si128()),
@@ -33,7 +33,7 @@ public:
return _mm256_cvtepi32_ps(fix32);
}
- SkNf(float a, float b, float c, float d,
+ SkNx(float a, float b, float c, float d,
float e, float f, float g, float h) : fVec(_mm256_setr_ps(a,b,c,d,e,f,g,h)) {}
void store(float vals[8]) const { _mm256_storeu_ps(vals, fVec); }
@@ -46,28 +46,28 @@ public:
_mm_storel_epi64((__m128i*)bytes, fix8);
}
- SkNf operator + (const SkNf& o) const { return _mm256_add_ps(fVec, o.fVec); }
- SkNf operator - (const SkNf& o) const { return _mm256_sub_ps(fVec, o.fVec); }
- SkNf operator * (const SkNf& o) const { return _mm256_mul_ps(fVec, o.fVec); }
- SkNf operator / (const SkNf& o) const { return _mm256_div_ps(fVec, o.fVec); }
+ SkNx operator + (const SkNx& o) const { return _mm256_add_ps(fVec, o.fVec); }
+ SkNx operator - (const SkNx& o) const { return _mm256_sub_ps(fVec, o.fVec); }
+ SkNx operator * (const SkNx& o) const { return _mm256_mul_ps(fVec, o.fVec); }
+ SkNx operator / (const SkNx& o) const { return _mm256_div_ps(fVec, o.fVec); }
- SkNf operator == (const SkNf& o) const { return _mm256_cmp_ps(fVec, o.fVec, _CMP_EQ_OQ); }
- SkNf operator != (const SkNf& o) const { return _mm256_cmp_ps(fVec, o.fVec, _CMP_NEQ_OQ); }
- SkNf operator < (const SkNf& o) const { return _mm256_cmp_ps(fVec, o.fVec, _CMP_LT_OQ); }
- SkNf operator > (const SkNf& o) const { return _mm256_cmp_ps(fVec, o.fVec, _CMP_GT_OQ); }
- SkNf operator <= (const SkNf& o) const { return _mm256_cmp_ps(fVec, o.fVec, _CMP_LE_OQ); }
- SkNf operator >= (const SkNf& o) const { return _mm256_cmp_ps(fVec, o.fVec, _CMP_GE_OQ); }
+ SkNx operator == (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec, _CMP_EQ_OQ); }
+ SkNx operator != (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec, _CMP_NEQ_OQ); }
+ SkNx operator < (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec, _CMP_LT_OQ); }
+ SkNx operator > (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec, _CMP_GT_OQ); }
+ SkNx operator <= (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec, _CMP_LE_OQ); }
+ SkNx operator >= (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec, _CMP_GE_OQ); }
- static SkNf Min(const SkNf& l, const SkNf& r) { return _mm256_min_ps(l.fVec, r.fVec); }
- static SkNf Max(const SkNf& l, const SkNf& r) { return _mm256_max_ps(l.fVec, r.fVec); }
+ static SkNx Min(const SkNx& l, const SkNx& r) { return _mm256_min_ps(l.fVec, r.fVec); }
+ static SkNx Max(const SkNx& l, const SkNx& r) { return _mm256_max_ps(l.fVec, r.fVec); }
- SkNf sqrt() const { return _mm256_sqrt_ps (fVec); }
- SkNf rsqrt0() const { return _mm256_rsqrt_ps(fVec); }
- SkNf rsqrt1() const { return this->rsqrt0(); }
- SkNf rsqrt2() const { return this->rsqrt1(); }
+ SkNx sqrt() const { return _mm256_sqrt_ps (fVec); }
+ SkNx rsqrt0() const { return _mm256_rsqrt_ps(fVec); }
+ SkNx rsqrt1() const { return this->rsqrt0(); }
+ SkNx rsqrt2() const { return this->rsqrt1(); }
- SkNf invert() const { return SkNf(1) / *this; }
- SkNf approxInvert() const { return _mm256_rcp_ps(fVec); }
+ SkNx invert() const { return SkNx(1) / *this; }
+ SkNx approxInvert() const { return _mm256_rcp_ps(fVec); }
template <int k> float kth() const {
SkASSERT(0 <= k && k < 8);
@@ -78,7 +78,7 @@ public:
bool allTrue() const { return 0xff == _mm256_movemask_ps(fVec); }
bool anyTrue() const { return 0x00 != _mm256_movemask_ps(fVec); }
- SkNf thenElse(const SkNf& t, const SkNf& e) const {
+ SkNx thenElse(const SkNx& t, const SkNx& e) const {
return _mm256_blendv_ps(e.fVec, t.fVec, fVec);
}
« no previous file with comments | « src/core/SkNx.h ('k') | src/opts/SkNx_neon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698