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_sse_DEFINED | 8 #ifndef SkNx_sse_DEFINED |
9 #define SkNx_sse_DEFINED | 9 #define SkNx_sse_DEFINED |
10 | 10 |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 } | 170 } |
171 | 171 |
172 SkNf(float a, float b, float c, float d) : fVec(_mm_setr_ps(a,b,c,d)) {} | 172 SkNf(float a, float b, float c, float d) : fVec(_mm_setr_ps(a,b,c,d)) {} |
173 | 173 |
174 void store(float vals[4]) const { _mm_storeu_ps(vals, fVec); } | 174 void store(float vals[4]) const { _mm_storeu_ps(vals, fVec); } |
175 void toBytes(uint8_t bytes[4]) const { | 175 void toBytes(uint8_t bytes[4]) const { |
176 __m128i fix8_32 = _mm_cvttps_epi32(fVec), | 176 __m128i fix8_32 = _mm_cvttps_epi32(fVec), |
177 fix8_16 = _mm_packus_epi16(fix8_32, fix8_32), | 177 fix8_16 = _mm_packus_epi16(fix8_32, fix8_32), |
178 fix8 = _mm_packus_epi16(fix8_16, fix8_16); | 178 fix8 = _mm_packus_epi16(fix8_16, fix8_16); |
179 *(int*)bytes = _mm_cvtsi128_si32(fix8); | 179 *(int*)bytes = _mm_cvtsi128_si32(fix8); |
180 // TODO: use _mm_shuffle_epi8 w/SSSE3? | |
181 } | 180 } |
182 | 181 |
183 SkNi<4, int> castTrunc() const { return _mm_cvttps_epi32(fVec); } | 182 SkNi<4, int> castTrunc() const { return _mm_cvttps_epi32(fVec); } |
184 | 183 |
185 SkNf operator + (const SkNf& o) const { return _mm_add_ps(fVec, o.fVec); } | 184 SkNf operator + (const SkNf& o) const { return _mm_add_ps(fVec, o.fVec); } |
186 SkNf operator - (const SkNf& o) const { return _mm_sub_ps(fVec, o.fVec); } | 185 SkNf operator - (const SkNf& o) const { return _mm_sub_ps(fVec, o.fVec); } |
187 SkNf operator * (const SkNf& o) const { return _mm_mul_ps(fVec, o.fVec); } | 186 SkNf operator * (const SkNf& o) const { return _mm_mul_ps(fVec, o.fVec); } |
188 SkNf operator / (const SkNf& o) const { return _mm_div_ps(fVec, o.fVec); } | 187 SkNf operator / (const SkNf& o) const { return _mm_div_ps(fVec, o.fVec); } |
189 | 188 |
190 SkNf operator == (const SkNf& o) const { return _mm_cmpeq_ps (fVec, o.fVec);
} | 189 SkNf operator == (const SkNf& o) const { return _mm_cmpeq_ps (fVec, o.fVec);
} |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
330 return _mm_or_si128(_mm_and_si128 (fVec, t.fVec), | 329 return _mm_or_si128(_mm_and_si128 (fVec, t.fVec), |
331 _mm_andnot_si128(fVec, e.fVec)); | 330 _mm_andnot_si128(fVec, e.fVec)); |
332 } | 331 } |
333 | 332 |
334 __m128i fVec; | 333 __m128i fVec; |
335 }; | 334 }; |
336 | 335 |
337 } // namespace | 336 } // namespace |
338 | 337 |
339 #endif//SkNx_sse_DEFINED | 338 #endif//SkNx_sse_DEFINED |
OLD | NEW |