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

Side by Side Diff: tests/SkNxTest.cpp

Issue 1707673002: fast sk4f <-> sk4i SSE methods (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: ffff Created 4 years, 10 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 "Sk4px.h" 8 #include "Sk4px.h"
9 #include "SkNx.h" 9 #include "SkNx.h"
10 #include "SkRandom.h" 10 #include "SkRandom.h"
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
230 REPORTER_ASSERT(r, f2[0] == 20); 230 REPORTER_ASSERT(r, f2[0] == 20);
231 REPORTER_ASSERT(r, f2[1] == 10); 231 REPORTER_ASSERT(r, f2[1] == 10);
232 232
233 f4 = SkNx_shuffle<0,1,1,0>(f2); 233 f4 = SkNx_shuffle<0,1,1,0>(f2);
234 REPORTER_ASSERT(r, f4[0] == 20); 234 REPORTER_ASSERT(r, f4[0] == 20);
235 REPORTER_ASSERT(r, f4[1] == 10); 235 REPORTER_ASSERT(r, f4[1] == 10);
236 REPORTER_ASSERT(r, f4[2] == 10); 236 REPORTER_ASSERT(r, f4[2] == 10);
237 REPORTER_ASSERT(r, f4[3] == 20); 237 REPORTER_ASSERT(r, f4[3] == 20);
238 } 238 }
239 239
240 DEF_TEST(SkNx_int_float, r) {
241 Sk4f f(-2.3f, 1.0f, 0.45f, 0.6f);
242
243 Sk4i i = SkNx_cast<int>(f);
244 REPORTER_ASSERT(r, i[0] == -2);
245 REPORTER_ASSERT(r, i[1] == 1);
246 REPORTER_ASSERT(r, i[2] == 0);
247 REPORTER_ASSERT(r, i[3] == 0);
248
249 f = SkNx_cast<float>(i);
250 REPORTER_ASSERT(r, f[0] == -2.0f);
251 REPORTER_ASSERT(r, f[1] == 1.0f);
252 REPORTER_ASSERT(r, f[2] == 0.0f);
253 REPORTER_ASSERT(r, f[3] == 0.0f);
254 }
255
240 #include "SkRandom.h" 256 #include "SkRandom.h"
241 257
242 DEF_TEST(SkNx_u16_float, r) { 258 DEF_TEST(SkNx_u16_float, r) {
243 { 259 {
244 // u16 --> float 260 // u16 --> float
245 auto h4 = Sk4h(15, 17, 257, 65535); 261 auto h4 = Sk4h(15, 17, 257, 65535);
246 auto f4 = SkNx_cast<float>(h4); 262 auto f4 = SkNx_cast<float>(h4);
247 REPORTER_ASSERT(r, f4.kth<0>() == 15.0f); 263 REPORTER_ASSERT(r, f4.kth<0>() == 15.0f);
248 REPORTER_ASSERT(r, f4.kth<1>() == 17.0f); 264 REPORTER_ASSERT(r, f4.kth<1>() == 17.0f);
249 REPORTER_ASSERT(r, f4.kth<2>() == 257.0f); 265 REPORTER_ASSERT(r, f4.kth<2>() == 257.0f);
(...skipping 18 matching lines...) Expand all
268 (uint16_t)rand.nextU16(), (uint16_t)rand.nextU16(), 284 (uint16_t)rand.nextU16(), (uint16_t)rand.nextU16(),
269 }; 285 };
270 auto u4_0 = Sk4h::Load(s16); 286 auto u4_0 = Sk4h::Load(s16);
271 auto f4 = SkNx_cast<float>(u4_0); 287 auto f4 = SkNx_cast<float>(u4_0);
272 auto u4_1 = SkNx_cast<uint16_t>(f4); 288 auto u4_1 = SkNx_cast<uint16_t>(f4);
273 uint16_t d16[4]; 289 uint16_t d16[4];
274 u4_1.store(d16); 290 u4_1.store(d16);
275 REPORTER_ASSERT(r, !memcmp(s16, d16, sizeof(s16))); 291 REPORTER_ASSERT(r, !memcmp(s16, d16, sizeof(s16)));
276 } 292 }
277 } 293 }
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