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

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

Issue 1028523003: Revert of Specialize Sk2d for ARM64 (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Created 5 years, 9 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/SkUtilsArm.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 // It is important _not_ to put header guards here. 8 // It is important _not_ to put header guards here.
9 // This file will be intentionally included three times. 9 // This file will be intentionally included three times.
10 10
11 #include "SkTypes.h" // Keep this before any #ifdef for skbug.com/3362 11 #include "SkTypes.h" // Keep this before any #ifdef for skbug.com/3362
12 12
13 #if defined(SK2X_PREAMBLE) 13 #if defined(SK2X_PREAMBLE)
14 #include <arm_neon.h> 14 #include <arm_neon.h>
15 #include <math.h> 15 #include <math.h>
16 template <typename T> struct SkScalarToSIMD; 16 template <typename T> struct SkScalarToSIMD;
17 template <> struct SkScalarToSIMD< float> { typedef float32x2_t Type; }; 17 template <> struct SkScalarToSIMD< float> { typedef float32x2_t Type; };
18 #if defined(SK_CPU_ARM64) 18 template <> struct SkScalarToSIMD<double> { typedef double Type[2]; };
19 template <> struct SkScalarToSIMD<double> { typedef float64x2_t Type; };
20 #else
21 template <> struct SkScalarToSIMD<double> { typedef double Type[2]; };
22 #endif
23 19
24 20
25 #elif defined(SK2X_PRIVATE) 21 #elif defined(SK2X_PRIVATE)
26 typename SkScalarToSIMD<T>::Type fVec; 22 typename SkScalarToSIMD<T>::Type fVec;
27 /*implicit*/ Sk2x(const typename SkScalarToSIMD<T>::Type vec) { fVec = vec; } 23 /*implicit*/ Sk2x(const typename SkScalarToSIMD<T>::Type vec) { fVec = vec; }
28 24
29 #else 25 #else
30 26
31 #define M(...) template <> inline __VA_ARGS__ Sk2x<float>:: 27 #define M(...) template <> inline __VA_ARGS__ Sk2x<float>::
32 28
(...skipping 24 matching lines...) Expand all
57 float32x2_t est1 = this->rsqrt().fVec, 53 float32x2_t est1 = this->rsqrt().fVec,
58 // An extra step of Newton's method to refine the estimate of 1/sqrt(this). 54 // An extra step of Newton's method to refine the estimate of 1/sqrt(this).
59 est2 = vmul_f32(vrsqrts_f32(fVec, vmul_f32(est1, est1)), est1); 55 est2 = vmul_f32(vrsqrts_f32(fVec, vmul_f32(est1, est1)), est1);
60 return vmul_f32(fVec, est2); 56 return vmul_f32(fVec, est2);
61 } 57 }
62 58
63 #undef M 59 #undef M
64 60
65 #define M(...) template <> inline __VA_ARGS__ Sk2x<double>:: 61 #define M(...) template <> inline __VA_ARGS__ Sk2x<double>::
66 62
67 #if defined(SK_CPU_ARM64) 63 // TODO: #ifdef SK_CPU_ARM64 use float64x2_t for Sk2d.
68 M() Sk2x() {}
69 M() Sk2x(double val) { fVec = vdupq_n_f64(val); }
70 M() Sk2x(double a, double b) {
71 fVec = vsetq_lane_f64(a, fVec, 0);
72 fVec = vsetq_lane_f64(b, fVec, 1);
73 }
74 M(Sk2d&) operator=(const Sk2d& o) { fVec = o.fVec; return *this; }
75 64
76 M(Sk2d) Load(const double vals[2]) { return vld1q_f64(vals); } 65 M() Sk2x() {}
77 M(void) store(double vals[2]) const { vst1q_f64(vals, fVec); } 66 M() Sk2x(double val) { fVec[0] = fVec[1] = val; }
67 M() Sk2x(double a, double b) { fVec[0] = a; fVec[1] = b; }
68 M(Sk2d&) operator=(const Sk2d& o) {
69 fVec[0] = o.fVec[0];
70 fVec[1] = o.fVec[1];
71 return *this;
72 }
78 73
79 M(Sk2d) add(const Sk2d& o) const { return vaddq_f64(fVec, o.fVec); } 74 M(Sk2d) Load(const double vals[2]) { return Sk2d(vals[0], vals[1]); }
80 M(Sk2d) subtract(const Sk2d& o) const { return vsubq_f64(fVec, o.fVec); } 75 M(void) store(double vals[2]) const { vals[0] = fVec[0]; vals[1] = fVec[1]; }
81 M(Sk2d) multiply(const Sk2d& o) const { return vmulq_f64(fVec, o.fVec); }
82 76
83 M(Sk2d) Min(const Sk2d& a, const Sk2d& b) { return vminq_f64(a.fVec, b.fVec) ; } 77 M(Sk2d) add(const Sk2d& o) const { return Sk2d(fVec[0] + o.fVec[0], fVec[1] + o.fVec[1]); }
84 M(Sk2d) Max(const Sk2d& a, const Sk2d& b) { return vmaxq_f64(a.fVec, b.fVec) ; } 78 M(Sk2d) subtract(const Sk2d& o) const { return Sk2d(fVec[0] - o.fVec[0], fVec[1] - o.fVec[1]); }
79 M(Sk2d) multiply(const Sk2d& o) const { return Sk2d(fVec[0] * o.fVec[0], fVec[1] * o.fVec[1]); }
85 80
86 M(Sk2d) rsqrt() const { 81 M(Sk2d) Min(const Sk2d& a, const Sk2d& b) {
87 float64x2_t est0 = vrsqrteq_f64(fVec), 82 return Sk2d(SkTMin(a.fVec[0], b.fVec[0]), SkTMin(a.fVec[1], b.fVec[1]));
88 est1 = vmulq_f64(vrsqrtsq_f64(fVec, vmulq_f64(est0, est0)), est0); 83 }
89 return est1; 84 M(Sk2d) Max(const Sk2d& a, const Sk2d& b) {
90 } 85 return Sk2d(SkTMax(a.fVec[0], b.fVec[0]), SkTMax(a.fVec[1], b.fVec[1]));
91 M(Sk2d) sqrt() const { 86 }
92 float64x2_t est1 = this->rsqrt().fVec,
93 // Two extra steps of Newton's method to refine the estimate of 1/sqrt(t his).
94 est2 = vmulq_f64(vrsqrtsq_f64(fVec, vmulq_f64(est1, est1)), est1),
95 est3 = vmulq_f64(vrsqrtsq_f64(fVec, vmulq_f64(est2, est2)), est2);
96 return vmulq_f64(fVec, est3);
97 }
98 87
99 #else // Scalar implementation for 32-bit chips, which don't have float64x2_t. 88 M(Sk2d) rsqrt() const { return Sk2d(1.0/::sqrt(fVec[0]), 1.0/::sqrt(fVec[1])); }
100 M() Sk2x() {} 89 M(Sk2d) sqrt() const { return Sk2d( ::sqrt(fVec[0]), ::sqrt(fVec[1])); }
101 M() Sk2x(double val) { fVec[0] = fVec[1] = val; }
102 M() Sk2x(double a, double b) { fVec[0] = a; fVec[1] = b; }
103 M(Sk2d&) operator=(const Sk2d& o) {
104 fVec[0] = o.fVec[0];
105 fVec[1] = o.fVec[1];
106 return *this;
107 }
108
109 M(Sk2d) Load(const double vals[2]) { return Sk2d(vals[0], vals[1]); }
110 M(void) store(double vals[2]) const { vals[0] = fVec[0]; vals[1] = fVec[1]; }
111
112 M(Sk2d) add(const Sk2d& o) const { return Sk2d(fVec[0] + o.fVec[0], fVe c[1] + o.fVec[1]); }
113 M(Sk2d) subtract(const Sk2d& o) const { return Sk2d(fVec[0] - o.fVec[0], fVe c[1] - o.fVec[1]); }
114 M(Sk2d) multiply(const Sk2d& o) const { return Sk2d(fVec[0] * o.fVec[0], fVe c[1] * o.fVec[1]); }
115
116 M(Sk2d) Min(const Sk2d& a, const Sk2d& b) {
117 return Sk2d(SkTMin(a.fVec[0], b.fVec[0]), SkTMin(a.fVec[1], b.fVec[1]));
118 }
119 M(Sk2d) Max(const Sk2d& a, const Sk2d& b) {
120 return Sk2d(SkTMax(a.fVec[0], b.fVec[0]), SkTMax(a.fVec[1], b.fVec[1]));
121 }
122
123 M(Sk2d) rsqrt() const { return Sk2d(1.0/::sqrt(fVec[0]), 1.0/::sqrt(fVec[1]) ); }
124 M(Sk2d) sqrt() const { return Sk2d( ::sqrt(fVec[0]), ::sqrt(fVec[1]) ); }
125 #endif
126 90
127 #undef M 91 #undef M
128 92
129 #endif 93 #endif
OLDNEW
« no previous file with comments | « src/core/SkUtilsArm.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698