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 // 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 |
(...skipping 28 matching lines...) Expand all Loading... |
39 M(Sk2f) subtract(const Sk2f& o) const { return _mm_sub_ps(fVec, o.fVec); } | 39 M(Sk2f) subtract(const Sk2f& o) const { return _mm_sub_ps(fVec, o.fVec); } |
40 M(Sk2f) multiply(const Sk2f& o) const { return _mm_mul_ps(fVec, o.fVec); } | 40 M(Sk2f) multiply(const Sk2f& o) const { return _mm_mul_ps(fVec, o.fVec); } |
41 M(Sk2f) divide(const Sk2f& o) const { return _mm_div_ps(fVec, o.fVec); } | 41 M(Sk2f) divide(const Sk2f& o) const { return _mm_div_ps(fVec, o.fVec); } |
42 | 42 |
43 M(Sk2f) Min(const Sk2f& a, const Sk2f& b) { return _mm_min_ps(a.fVec, b.fVec); } | 43 M(Sk2f) Min(const Sk2f& a, const Sk2f& b) { return _mm_min_ps(a.fVec, b.fVec); } |
44 M(Sk2f) Max(const Sk2f& a, const Sk2f& b) { return _mm_max_ps(a.fVec, b.fVec); } | 44 M(Sk2f) Max(const Sk2f& a, const Sk2f& b) { return _mm_max_ps(a.fVec, b.fVec); } |
45 | 45 |
46 M(Sk2f) rsqrt() const { return _mm_rsqrt_ps(fVec); } | 46 M(Sk2f) rsqrt() const { return _mm_rsqrt_ps(fVec); } |
47 M(Sk2f) sqrt() const { return _mm_sqrt_ps (fVec); } | 47 M(Sk2f) sqrt() const { return _mm_sqrt_ps (fVec); } |
48 | 48 |
| 49 M(Sk2f) invert() const { return Sk2f(1.0f) / *this; } |
| 50 M(Sk2f) approxInvert() const { return _mm_rcp_ps(fVec); } |
| 51 |
49 #undef M | 52 #undef M |
50 | 53 |
51 #define M(...) template <> inline __VA_ARGS__ Sk2x<double>:: | 54 #define M(...) template <> inline __VA_ARGS__ Sk2x<double>:: |
52 | 55 |
53 M() Sk2x() {} | 56 M() Sk2x() {} |
54 M() Sk2x(double val) { fVec = _mm_set1_pd(val); } | 57 M() Sk2x(double val) { fVec = _mm_set1_pd(val); } |
55 M() Sk2x(double a, double b) { fVec = _mm_set_pd(b, a); } | 58 M() Sk2x(double a, double b) { fVec = _mm_set_pd(b, a); } |
56 M(Sk2d&) operator=(const Sk2d& o) { fVec = o.fVec; return *this; } | 59 M(Sk2d&) operator=(const Sk2d& o) { fVec = o.fVec; return *this; } |
57 | 60 |
58 M(Sk2d) Load(const double vals[2]) { return _mm_loadu_pd(vals); } | 61 M(Sk2d) Load(const double vals[2]) { return _mm_loadu_pd(vals); } |
59 M(void) store(double vals[2]) const { _mm_storeu_pd(vals, fVec); } | 62 M(void) store(double vals[2]) const { _mm_storeu_pd(vals, fVec); } |
60 | 63 |
61 M(Sk2d) add(const Sk2d& o) const { return _mm_add_pd(fVec, o.fVec); } | 64 M(Sk2d) add(const Sk2d& o) const { return _mm_add_pd(fVec, o.fVec); } |
62 M(Sk2d) subtract(const Sk2d& o) const { return _mm_sub_pd(fVec, o.fVec); } | 65 M(Sk2d) subtract(const Sk2d& o) const { return _mm_sub_pd(fVec, o.fVec); } |
63 M(Sk2d) multiply(const Sk2d& o) const { return _mm_mul_pd(fVec, o.fVec); } | 66 M(Sk2d) multiply(const Sk2d& o) const { return _mm_mul_pd(fVec, o.fVec); } |
64 M(Sk2d) divide(const Sk2d& o) const { return _mm_div_pd(fVec, o.fVec); } | 67 M(Sk2d) divide(const Sk2d& o) const { return _mm_div_pd(fVec, o.fVec); } |
65 | 68 |
66 M(Sk2d) Min(const Sk2d& a, const Sk2d& b) { return _mm_min_pd(a.fVec, b.fVec); } | 69 M(Sk2d) Min(const Sk2d& a, const Sk2d& b) { return _mm_min_pd(a.fVec, b.fVec); } |
67 M(Sk2d) Max(const Sk2d& a, const Sk2d& b) { return _mm_max_pd(a.fVec, b.fVec); } | 70 M(Sk2d) Max(const Sk2d& a, const Sk2d& b) { return _mm_max_pd(a.fVec, b.fVec); } |
68 | 71 |
69 // There is no _mm_rsqrt_pd, so we do Sk2d::rsqrt() in floats. | 72 // There is no _mm_rsqrt_pd, so we do Sk2d::rsqrt() in floats. |
70 M(Sk2d) rsqrt() const { return _mm_cvtps_pd(_mm_rsqrt_ps(_mm_cvtpd_ps(fVec))); } | 73 M(Sk2d) rsqrt() const { return _mm_cvtps_pd(_mm_rsqrt_ps(_mm_cvtpd_ps(fVec))); } |
71 M(Sk2d) sqrt() const { return _mm_sqrt_pd(fVec); } | 74 M(Sk2d) sqrt() const { return _mm_sqrt_pd(fVec); } |
72 | 75 |
| 76 // No _mm_rcp_pd, so do Sk2d::approxInvert() in floats. |
| 77 M(Sk2d) invert() const { return Sk2d(1.0) / *this; } |
| 78 M(Sk2d) approxInvert() const { return _mm_cvtps_pd(_mm_rcp_ps(_mm_cvtpd_ps(fVec)
)); } |
| 79 |
73 #undef M | 80 #undef M |
74 | 81 |
75 #endif | 82 #endif |
OLD | NEW |