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

Side by Side Diff: tests/SkNxTest.cpp

Issue 1133933004: add Min to SkNi, specialized for u8 and u16 on SSE and NEON (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: fixes Created 5 years, 7 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 "SkRandom.h"
9 #include "Test.h" 10 #include "Test.h"
10 11
11 template <int N, typename T> 12 template <int N, typename T>
12 static void test_Nf(skiatest::Reporter* r) { 13 static void test_Nf(skiatest::Reporter* r) {
13 14
14 auto assert_nearly_eq = [&](double eps, const SkNf<N,T>& v, T a, T b, T c, T d) { 15 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; }; 16 auto close = [=](T a, T b) { return fabs(a-b) <= eps; };
16 T vals[4]; 17 T vals[4];
17 v.store(vals); 18 v.store(vals);
18 bool ok = close(vals[0], a) && close(vals[1], b) 19 bool ok = close(vals[0], a) && close(vals[1], b)
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 124
124 DEF_TEST(SkNi, r) { 125 DEF_TEST(SkNi, r) {
125 test_Ni<2, uint16_t>(r); 126 test_Ni<2, uint16_t>(r);
126 test_Ni<4, uint16_t>(r); 127 test_Ni<4, uint16_t>(r);
127 test_Ni<8, uint16_t>(r); 128 test_Ni<8, uint16_t>(r);
128 129
129 test_Ni<2, int>(r); 130 test_Ni<2, int>(r);
130 test_Ni<4, int>(r); 131 test_Ni<4, int>(r);
131 test_Ni<8, int>(r); 132 test_Ni<8, int>(r);
132 } 133 }
134
135 DEF_TEST(SkNi_min, r) {
136 // Exhaustively check the 8x8 bit space.
137 for (int a = 0; a < (1<<8); a++) {
138 for (int b = 0; b < (1<<8); b++) {
139 REPORTER_ASSERT(r, Sk16b::Min(Sk16b(a), Sk16b(b)).kth<0>() == SkTMin(a, b));
140 }}
141
142 // Exhausting the 16x16 bit space is kind of slow, so only do that in releas e builds.
143 #ifdef SK_DEBUG
144 SkRandom rand;
145 for (int i = 0; i < (1<<16); i++) {
146 uint16_t a = rand.nextU() >> 16,
147 b = rand.nextU() >> 16;
148 REPORTER_ASSERT(r, Sk8h::Min(Sk8h(a), Sk8h(b)).kth<0>() == SkTMin(a, b)) ;
149 }
150 #else
151 for (int a = 0; a < (1<<16); a++) {
152 for (int b = 0; b < (1<<16); b++) {
153 REPORTER_ASSERT(r, Sk8h::Min(Sk8h(a), Sk8h(b)).kth<0>() == SkTMin(a, b)) ;
154 }}
155 #endif
156 }
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