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

Side by Side Diff: src/core/Sk4x_sse.h

Issue 960773005: Think implicit promotion is a good idea? (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 10 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 unified diff | Download patch
« no previous file with comments | « src/core/Sk4x_portable.h ('k') | tests/Sk4xTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // It is important _not_ to put header guards here. 1 // It is important _not_ to put header guards here.
2 // This file will be intentionally included three times. 2 // This file will be intentionally included three times.
3 3
4 // Useful reading: 4 // Useful reading:
5 // https://software.intel.com/sites/landingpage/IntrinsicsGuide/ 5 // https://software.intel.com/sites/landingpage/IntrinsicsGuide/
6 6
7 #if defined(SK4X_PREAMBLE) 7 #if defined(SK4X_PREAMBLE)
8 // Code in this file may assume SSE and SSE2. 8 // Code in this file may assume SSE and SSE2.
9 #include <emmintrin.h> 9 #include <emmintrin.h>
10 10
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 } 68 }
69 69
70 template <typename T> 70 template <typename T>
71 Sk4x<T> Sk4x<T>::ZWCD(const Sk4x<T>& a, const Sk4x<T>& b) { 71 Sk4x<T> Sk4x<T>::ZWCD(const Sk4x<T>& a, const Sk4x<T>& b) {
72 return _mm_movehl_ps(as_4f(b.fVec), as_4f(a.fVec)); 72 return _mm_movehl_ps(as_4f(b.fVec), as_4f(a.fVec));
73 } 73 }
74 74
75 // Now we'll write all Sk4f specific methods. This M() macro will remove some n oise. 75 // Now we'll write all Sk4f specific methods. This M() macro will remove some n oise.
76 #define M(...) template <> inline __VA_ARGS__ Sk4f:: 76 #define M(...) template <> inline __VA_ARGS__ Sk4f::
77 77
78 M() Sk4x(float v) : fVec(_mm_set1_ps(v)) {}
78 M() Sk4x(float a, float b, float c, float d) : fVec(_mm_set_ps(d,c,b,a)) {} 79 M() Sk4x(float a, float b, float c, float d) : fVec(_mm_set_ps(d,c,b,a)) {}
79 80
80 M(Sk4f) Load (const float fs[4]) { return _mm_loadu_ps(fs); } 81 M(Sk4f) Load (const float fs[4]) { return _mm_loadu_ps(fs); }
81 M(Sk4f) LoadAligned(const float fs[4]) { return _mm_load_ps (fs); } 82 M(Sk4f) LoadAligned(const float fs[4]) { return _mm_load_ps (fs); }
82 83
83 M(void) store (float fs[4]) const { _mm_storeu_ps(fs, fVec); } 84 M(void) store (float fs[4]) const { _mm_storeu_ps(fs, fVec); }
84 M(void) storeAligned(float fs[4]) const { _mm_store_ps (fs, fVec); } 85 M(void) storeAligned(float fs[4]) const { _mm_store_ps (fs, fVec); }
85 86
86 template <> 87 template <>
87 M(Sk4i) reinterpret<Sk4i>() const { return as_4i(fVec); } 88 M(Sk4i) reinterpret<Sk4i>() const { return as_4i(fVec); }
(...skipping 17 matching lines...) Expand all
105 M(Sk4i) lessThanEqual (const Sk4f& o) const { return _mm_cmple_ps (fVec, o.fVe c); } 106 M(Sk4i) lessThanEqual (const Sk4f& o) const { return _mm_cmple_ps (fVec, o.fVe c); }
106 M(Sk4i) greaterThanEqual(const Sk4f& o) const { return _mm_cmpge_ps (fVec, o.fVe c); } 107 M(Sk4i) greaterThanEqual(const Sk4f& o) const { return _mm_cmpge_ps (fVec, o.fVe c); }
107 108
108 M(Sk4f) Min(const Sk4f& a, const Sk4f& b) { return _mm_min_ps(a.fVec, b.fVec); } 109 M(Sk4f) Min(const Sk4f& a, const Sk4f& b) { return _mm_min_ps(a.fVec, b.fVec); }
109 M(Sk4f) Max(const Sk4f& a, const Sk4f& b) { return _mm_max_ps(a.fVec, b.fVec); } 110 M(Sk4f) Max(const Sk4f& a, const Sk4f& b) { return _mm_max_ps(a.fVec, b.fVec); }
110 111
111 // Now we'll write all the Sk4i specific methods. Same deal for M(). 112 // Now we'll write all the Sk4i specific methods. Same deal for M().
112 #undef M 113 #undef M
113 #define M(...) template <> inline __VA_ARGS__ Sk4i:: 114 #define M(...) template <> inline __VA_ARGS__ Sk4i::
114 115
116 M() Sk4x(int32_t v) : fVec(_mm_set1_epi32(v)) {}
115 M() Sk4x(int32_t a, int32_t b, int32_t c, int32_t d) : fVec(_mm_set_epi32(d,c,b, a)) {} 117 M() Sk4x(int32_t a, int32_t b, int32_t c, int32_t d) : fVec(_mm_set_epi32(d,c,b, a)) {}
116 118
117 M(Sk4i) Load (const int32_t is[4]) { return _mm_loadu_si128((const __m128i *)is); } 119 M(Sk4i) Load (const int32_t is[4]) { return _mm_loadu_si128((const __m128i *)is); }
118 M(Sk4i) LoadAligned(const int32_t is[4]) { return _mm_load_si128 ((const __m128i *)is); } 120 M(Sk4i) LoadAligned(const int32_t is[4]) { return _mm_load_si128 ((const __m128i *)is); }
119 121
120 M(void) store (int32_t is[4]) const { _mm_storeu_si128((__m128i*)is, fVec) ; } 122 M(void) store (int32_t is[4]) const { _mm_storeu_si128((__m128i*)is, fVec) ; }
121 M(void) storeAligned(int32_t is[4]) const { _mm_store_si128 ((__m128i*)is, fVec) ; } 123 M(void) storeAligned(int32_t is[4]) const { _mm_store_si128 ((__m128i*)is, fVec) ; }
122 124
123 template <> 125 template <>
124 M(Sk4f) reinterpret<Sk4f>() const { return as_4f(fVec); } 126 M(Sk4f) reinterpret<Sk4f>() const { return as_4f(fVec); }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 } 170 }
169 M(Sk4i) Max(const Sk4i& a, const Sk4i& b) { 171 M(Sk4i) Max(const Sk4i& a, const Sk4i& b) {
170 Sk4i less = a.lessThan(b); 172 Sk4i less = a.lessThan(b);
171 return b.bitAnd(less).bitOr(a.andNot(less)); 173 return b.bitAnd(less).bitOr(a.andNot(less));
172 } 174 }
173 #endif 175 #endif
174 176
175 #undef M 177 #undef M
176 178
177 #endif//Method definitions. 179 #endif//Method definitions.
OLDNEW
« no previous file with comments | « src/core/Sk4x_portable.h ('k') | tests/Sk4xTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698