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

Side by Side Diff: tests/SkNxTest.cpp

Issue 1059743002: Use switch operator[](int) to kth<int>() so we can use vget_lane. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 5 years, 8 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/opts/SkNx_sse.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 #include "SkNx.h" 8 #include "SkNx.h"
9 #include "Test.h" 9 #include "Test.h"
10 10
11 template <int N, typename T> 11 template <int N, typename T>
12 static void test_Nf(skiatest::Reporter* r) { 12 static void test_Nf(skiatest::Reporter* r) {
13 13
14 auto assert_nearly_eq = [&](double eps, const SkNf<N,T>& v, T a, T b, T c, T d) { 14 auto assert_nearly_eq = [&](double eps, const SkNf<N,T>& v, T a, T b, T c, T d) {
15 auto close = [=](T a, T b) { return fabs(a-b) <= eps; }; 15 auto close = [=](T a, T b) { return fabs(a-b) <= eps; };
16 T vals[4]; 16 T vals[4];
17 v.store(vals); 17 v.store(vals);
18 REPORTER_ASSERT(r, close(vals[0], a) && close(vals[1], b)); 18 bool ok = close(vals[0], a) && close(vals[1], b)
19 REPORTER_ASSERT(r, close( v[0], a) && close( v[1], b)); 19 && close(v.template kth<0>(), a) && close(v.template kth<1>(), b) ;
20 20 REPORTER_ASSERT(r, ok);
21 if (N == 4) { 21 if (N == 4) {
22 REPORTER_ASSERT(r, close(vals[2], c) && close(vals[3], d)); 22 ok = close(vals[2], c) && close(vals[3], d)
23 REPORTER_ASSERT(r, close( v[2], c) && close( v[3], d)); 23 && close(v.template kth<2>(), c) && close(v.template kth<3>(), d);
24 REPORTER_ASSERT(r, ok);
24 } 25 }
25 }; 26 };
26 auto assert_eq = [&](const SkNf<N,T>& v, T a, T b, T c, T d) { 27 auto assert_eq = [&](const SkNf<N,T>& v, T a, T b, T c, T d) {
27 return assert_nearly_eq(0, v, a,b,c,d); 28 return assert_nearly_eq(0, v, a,b,c,d);
28 }; 29 };
29 30
30 T vals[] = {3, 4, 5, 6}; 31 T vals[] = {3, 4, 5, 6};
31 SkNf<N,T> a = SkNf<N,T>::Load(vals), 32 SkNf<N,T> a = SkNf<N,T>::Load(vals),
32 b(a), 33 b(a),
33 c = a; 34 c = a;
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 REPORTER_ASSERT(r, !(a >= fours).allTrue()); 70 REPORTER_ASSERT(r, !(a >= fours).allTrue());
70 } 71 }
71 72
72 DEF_TEST(SkNf, r) { 73 DEF_TEST(SkNf, r) {
73 test_Nf<2, float>(r); 74 test_Nf<2, float>(r);
74 test_Nf<2, double>(r); 75 test_Nf<2, double>(r);
75 76
76 test_Nf<4, float>(r); 77 test_Nf<4, float>(r);
77 test_Nf<4, double>(r); 78 test_Nf<4, double>(r);
78 } 79 }
OLDNEW
« no previous file with comments | « src/opts/SkNx_sse.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698