| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #ifndef SkNx_avx_DEFINED | 8 #ifndef SkNx_avx_DEFINED |
| 9 #define SkNx_avx_DEFINED | 9 #define SkNx_avx_DEFINED |
| 10 | 10 |
| 11 // This file may assume <= AVX, but must check SK_CPU_SSE_LEVEL for anything mor
e recent. | 11 // This file may assume <= AVX, but must check SK_CPU_SSE_LEVEL for anything mor
e recent. |
| 12 | 12 |
| 13 // All the SSE specializations are still good ideas. We'll just add Sk8f. | 13 // All the SSE specializations are still good ideas. We'll just add Sk8f. |
| 14 #include "SkNx_sse.h" | 14 #include "SkNx_sse.h" |
| 15 | 15 |
| 16 // SkNx_sse.h defines SKNX_IS_FAST. | 16 // SkNx_sse.h defines SKNX_IS_FAST. |
| 17 | 17 |
| 18 namespace { // See SkNx.h | 18 namespace { // See SkNx.h |
| 19 | 19 |
| 20 template <> | 20 template <> |
| 21 class SkNx<8, float> { | 21 class SkNx<8, float> { |
| 22 public: | 22 public: |
| 23 SkNx(const __m256& vec) : fVec(vec) {} | 23 SkNx(const __m256& vec) : fVec(vec) {} |
| 24 | 24 |
| 25 SkNx() {} | 25 SkNx() {} |
| 26 SkNx(float val) : fVec(_mm256_set1_ps(val)) {} | 26 SkNx(float val) : fVec(_mm256_set1_ps(val)) {} |
| 27 static SkNx Load(const float vals[8]) { return _mm256_loadu_ps(vals); } | 27 static SkNx Load(const void* ptr) { return _mm256_loadu_ps((const float*)ptr
); } |
| 28 | 28 |
| 29 SkNx(float a, float b, float c, float d, | 29 SkNx(float a, float b, float c, float d, |
| 30 float e, float f, float g, float h) : fVec(_mm256_setr_ps(a,b,c,d,e,f,g
,h)) {} | 30 float e, float f, float g, float h) : fVec(_mm256_setr_ps(a,b,c,d,e,f,g
,h)) {} |
| 31 | 31 |
| 32 void store(float vals[8]) const { _mm256_storeu_ps(vals, fVec); } | 32 void store(void* ptr) const { _mm256_storeu_ps((float*)ptr, fVec); } |
| 33 | 33 |
| 34 SkNx operator + (const SkNx& o) const { return _mm256_add_ps(fVec, o.fVec);
} | 34 SkNx operator + (const SkNx& o) const { return _mm256_add_ps(fVec, o.fVec);
} |
| 35 SkNx operator - (const SkNx& o) const { return _mm256_sub_ps(fVec, o.fVec);
} | 35 SkNx operator - (const SkNx& o) const { return _mm256_sub_ps(fVec, o.fVec);
} |
| 36 SkNx operator * (const SkNx& o) const { return _mm256_mul_ps(fVec, o.fVec);
} | 36 SkNx operator * (const SkNx& o) const { return _mm256_mul_ps(fVec, o.fVec);
} |
| 37 SkNx operator / (const SkNx& o) const { return _mm256_div_ps(fVec, o.fVec);
} | 37 SkNx operator / (const SkNx& o) const { return _mm256_div_ps(fVec, o.fVec);
} |
| 38 | 38 |
| 39 SkNx operator == (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec,
_CMP_EQ_OQ); } | 39 SkNx operator == (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec,
_CMP_EQ_OQ); } |
| 40 SkNx operator != (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec,
_CMP_NEQ_OQ); } | 40 SkNx operator != (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec,
_CMP_NEQ_OQ); } |
| 41 SkNx operator < (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec,
_CMP_LT_OQ); } | 41 SkNx operator < (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec,
_CMP_LT_OQ); } |
| 42 SkNx operator > (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec,
_CMP_GT_OQ); } | 42 SkNx operator > (const SkNx& o) const { return _mm256_cmp_ps(fVec, o.fVec,
_CMP_GT_OQ); } |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 __m128i _16 = _mm_unpacklo_epi8(src.fVec, _mm_setzero_si128()), | 85 __m128i _16 = _mm_unpacklo_epi8(src.fVec, _mm_setzero_si128()), |
| 86 lo = _mm_unpacklo_epi16(_16, _mm_setzero_si128()), | 86 lo = _mm_unpacklo_epi16(_16, _mm_setzero_si128()), |
| 87 hi = _mm_unpackhi_epi16(_16, _mm_setzero_si128()); | 87 hi = _mm_unpackhi_epi16(_16, _mm_setzero_si128()); |
| 88 __m256i _32 = _mm256_insertf128_si256(_mm256_castsi128_si256(lo), hi, 1); | 88 __m256i _32 = _mm256_insertf128_si256(_mm256_castsi128_si256(lo), hi, 1); |
| 89 return _mm256_cvtepi32_ps(_32); | 89 return _mm256_cvtepi32_ps(_32); |
| 90 } | 90 } |
| 91 | 91 |
| 92 } // namespace | 92 } // namespace |
| 93 | 93 |
| 94 #endif//SkNx_avx_DEFINED | 94 #endif//SkNx_avx_DEFINED |
| OLD | NEW |