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

Side by Side Diff: src/opts/SkNx_sse.h

Issue 1483953002: Add Sk4f::ToBytes(uint8_t[16], Sk4f, Sk4f, Sk4f, Sk4f) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix neon 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 unified diff | Download patch
« no previous file with comments | « src/opts/SkNx_neon.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 SkNx(float a, float b, float c, float d) : fVec(_mm_setr_ps(a,b,c,d)) {} 125 SkNx(float a, float b, float c, float d) : fVec(_mm_setr_ps(a,b,c,d)) {}
126 126
127 void store(float vals[4]) const { _mm_storeu_ps(vals, fVec); } 127 void store(float vals[4]) const { _mm_storeu_ps(vals, fVec); }
128 void toBytes(uint8_t bytes[4]) const { 128 void toBytes(uint8_t bytes[4]) const {
129 __m128i fix8_32 = _mm_cvttps_epi32(fVec), 129 __m128i fix8_32 = _mm_cvttps_epi32(fVec),
130 fix8_16 = _mm_packus_epi16(fix8_32, fix8_32), 130 fix8_16 = _mm_packus_epi16(fix8_32, fix8_32),
131 fix8 = _mm_packus_epi16(fix8_16, fix8_16); 131 fix8 = _mm_packus_epi16(fix8_16, fix8_16);
132 *(int*)bytes = _mm_cvtsi128_si32(fix8); 132 *(int*)bytes = _mm_cvtsi128_si32(fix8);
133 } 133 }
134 134
135 static void ToBytes(uint8_t bytes[16],
136 const SkNx& a, const SkNx& b, const SkNx& c, const SkNx& d) {
137 _mm_storeu_si128((__m128i*)bytes,
138 _mm_packus_epi16(_mm_packus_epi16(_mm_cvttps_epi32(a.fV ec),
139 _mm_cvttps_epi32(b.fV ec)),
140 _mm_packus_epi16(_mm_cvttps_epi32(c.fV ec),
141 _mm_cvttps_epi32(d.fV ec))));
142 }
143
135 SkNx operator + (const SkNx& o) const { return _mm_add_ps(fVec, o.fVec); } 144 SkNx operator + (const SkNx& o) const { return _mm_add_ps(fVec, o.fVec); }
136 SkNx operator - (const SkNx& o) const { return _mm_sub_ps(fVec, o.fVec); } 145 SkNx operator - (const SkNx& o) const { return _mm_sub_ps(fVec, o.fVec); }
137 SkNx operator * (const SkNx& o) const { return _mm_mul_ps(fVec, o.fVec); } 146 SkNx operator * (const SkNx& o) const { return _mm_mul_ps(fVec, o.fVec); }
138 SkNx operator / (const SkNx& o) const { return _mm_div_ps(fVec, o.fVec); } 147 SkNx operator / (const SkNx& o) const { return _mm_div_ps(fVec, o.fVec); }
139 148
140 SkNx operator == (const SkNx& o) const { return _mm_cmpeq_ps (fVec, o.fVec); } 149 SkNx operator == (const SkNx& o) const { return _mm_cmpeq_ps (fVec, o.fVec); }
141 SkNx operator != (const SkNx& o) const { return _mm_cmpneq_ps(fVec, o.fVec); } 150 SkNx operator != (const SkNx& o) const { return _mm_cmpneq_ps(fVec, o.fVec); }
142 SkNx operator < (const SkNx& o) const { return _mm_cmplt_ps (fVec, o.fVec); } 151 SkNx operator < (const SkNx& o) const { return _mm_cmplt_ps (fVec, o.fVec); }
143 SkNx operator > (const SkNx& o) const { return _mm_cmpgt_ps (fVec, o.fVec); } 152 SkNx operator > (const SkNx& o) const { return _mm_cmpgt_ps (fVec, o.fVec); }
144 SkNx operator <= (const SkNx& o) const { return _mm_cmple_ps (fVec, o.fVec); } 153 SkNx operator <= (const SkNx& o) const { return _mm_cmple_ps (fVec, o.fVec); }
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 295
287 296
288 template<> 297 template<>
289 inline SkNx<4, int> SkNx_cast<int, float, 4>(const SkNx<4, float>& src) { 298 inline SkNx<4, int> SkNx_cast<int, float, 4>(const SkNx<4, float>& src) {
290 return _mm_cvttps_epi32(src.fVec); 299 return _mm_cvttps_epi32(src.fVec);
291 } 300 }
292 301
293 } // namespace 302 } // namespace
294 303
295 #endif//SkNx_sse_DEFINED 304 #endif//SkNx_sse_DEFINED
OLDNEW
« no previous file with comments | « src/opts/SkNx_neon.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698