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_neon_DEFINED | 8 #ifndef SkNx_neon_DEFINED |
9 #define SkNx_neon_DEFINED | 9 #define SkNx_neon_DEFINED |
10 | 10 |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 private: | 180 private: |
181 float64x2_t fVec; | 181 float64x2_t fVec; |
182 }; | 182 }; |
183 #endif//defined(SK_CPU_ARM64) | 183 #endif//defined(SK_CPU_ARM64) |
184 | 184 |
185 template <> | 185 template <> |
186 class SkNf<4, float> { | 186 class SkNf<4, float> { |
187 typedef SkNi<4, int32_t> Ni; | 187 typedef SkNi<4, int32_t> Ni; |
188 public: | 188 public: |
189 SkNf(float32x4_t vec) : fVec(vec) {} | 189 SkNf(float32x4_t vec) : fVec(vec) {} |
| 190 float32x4_t vec() const { return fVec; } |
190 | 191 |
191 SkNf() {} | 192 SkNf() {} |
192 explicit SkNf(float val) : fVec(vdupq_n_f32(val)) {} | 193 explicit SkNf(float val) : fVec(vdupq_n_f32(val)) {} |
193 static SkNf Load(const float vals[4]) { return vld1q_f32(vals); } | 194 static SkNf Load(const float vals[4]) { return vld1q_f32(vals); } |
194 SkNf(float a, float b, float c, float d) { fVec = (float32x4_t) { a, b, c, d
}; } | 195 SkNf(float a, float b, float c, float d) { fVec = (float32x4_t) { a, b, c, d
}; } |
195 | 196 |
196 void store(float vals[4]) const { vst1q_f32(vals, fVec); } | 197 void store(float vals[4]) const { vst1q_f32(vals, fVec); } |
197 | 198 |
198 SkNf approxInvert() const { | 199 SkNf approxInvert() const { |
199 float32x4_t est0 = vrecpeq_f32(fVec), | 200 float32x4_t est0 = vrecpeq_f32(fVec), |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 est2 = vmulq_f32(vrsqrtsq_f32(fVec, vmulq_f32(est1, est1)),
est1); | 245 est2 = vmulq_f32(vrsqrtsq_f32(fVec, vmulq_f32(est1, est1)),
est1); |
245 return vmulq_f32(fVec, est2); | 246 return vmulq_f32(fVec, est2); |
246 #endif | 247 #endif |
247 } | 248 } |
248 | 249 |
249 template <int k> float kth() const { | 250 template <int k> float kth() const { |
250 SkASSERT(0 <= k && k < 4); | 251 SkASSERT(0 <= k && k < 4); |
251 return vgetq_lane_f32(fVec, k&3); | 252 return vgetq_lane_f32(fVec, k&3); |
252 } | 253 } |
253 | 254 |
254 protected: | 255 private: |
255 float32x4_t fVec; | 256 float32x4_t fVec; |
256 }; | 257 }; |
257 | 258 |
258 #endif//SkNx_neon_DEFINED | 259 #endif//SkNx_neon_DEFINED |
OLD | NEW |