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

Unified Diff: src/opts/SkNx_avx.h

Issue 1526523003: Unify some SkNx code (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: typo Created 5 years 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/SkColorCubeFilter_opts.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 6236769652677a58610ee15a4d727575a69e0a42..f635181a9265d38994760e84393155aaa1e12c2e 100644
--- a/src/opts/SkNx_avx.h
+++ b/src/opts/SkNx_avx.h
@@ -26,27 +26,10 @@ public:
SkNx(float val) : fVec(_mm256_set1_ps(val)) {}
static SkNx Load(const float vals[8]) { return _mm256_loadu_ps(vals); }
- 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()),
- hi32 = _mm_unpackhi_epi16(fix16, _mm_setzero_si128());
- __m256i fix32 = _mm256_insertf128_si256(_mm256_castsi128_si256(lo32), hi32, 1);
- return _mm256_cvtepi32_ps(fix32);
- }
-
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); }
- void toBytes(uint8_t bytes[8]) const {
- __m256i fix32 = _mm256_cvttps_epi32(fVec);
- __m128i lo32 = _mm256_extractf128_si256(fix32, 0),
- hi32 = _mm256_extractf128_si256(fix32, 1),
- fix16 = _mm_packus_epi32(lo32, hi32),
- fix8 = _mm_packus_epi16(fix16, fix16);
- _mm_storel_epi64((__m128i*)bytes, fix8);
- }
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); }
@@ -87,6 +70,25 @@ public:
__m256 fVec;
};
+template<> inline Sk8b SkNx_cast<uint8_t, float, 8>(const Sk8f& src) {
+ __m256i _32 = _mm256_cvttps_epi32(src.fVec);
+ __m128i lo = _mm256_extractf128_si256(_32, 0),
+ hi = _mm256_extractf128_si256(_32, 1),
+ _16 = _mm_packus_epi32(lo, hi);
+ return _mm_packus_epi16(_16, _16);
+}
+
+template<> inline Sk8f SkNx_cast<float, uint8_t, 8>(const Sk8b& src) {
+ /* TODO lo = _mm_cvtepu8_epi32(src.fVec),
+ * hi = _mm_cvtepu8_epi32(_mm_srli_si128(src.fVec, 4))
+ */
+ __m128i _16 = _mm_unpacklo_epi8(src.fVec, _mm_setzero_si128()),
+ lo = _mm_unpacklo_epi16(_16, _mm_setzero_si128()),
+ hi = _mm_unpackhi_epi16(_16, _mm_setzero_si128());
+ __m256i _32 = _mm256_insertf128_si256(_mm256_castsi128_si256(lo), hi, 1);
+ return _mm256_cvtepi32_ps(_32);
+}
+
} // namespace
#endif//SkNx_avx_DEFINED
« no previous file with comments | « src/opts/SkColorCubeFilter_opts.h ('k') | src/opts/SkNx_neon.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698