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

Side by Side Diff: tests/SkNxTest.cpp

Issue 2145663003: Expand _01 half<->float limitation to _finite. Simplify. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: drop _mm_packus_epi32 for now. Created 4 years, 5 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 | « tests/Float16Test.cpp ('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 270 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 (uint16_t)rand.nextU16(), (uint16_t)rand.nextU16(), 281 (uint16_t)rand.nextU16(), (uint16_t)rand.nextU16(),
282 }; 282 };
283 auto u4_0 = Sk4h::Load(s16); 283 auto u4_0 = Sk4h::Load(s16);
284 auto f4 = SkNx_cast<float>(u4_0); 284 auto f4 = SkNx_cast<float>(u4_0);
285 auto u4_1 = SkNx_cast<uint16_t>(f4); 285 auto u4_1 = SkNx_cast<uint16_t>(f4);
286 uint16_t d16[4]; 286 uint16_t d16[4];
287 u4_1.store(d16); 287 u4_1.store(d16);
288 REPORTER_ASSERT(r, !memcmp(s16, d16, sizeof(s16))); 288 REPORTER_ASSERT(r, !memcmp(s16, d16, sizeof(s16)));
289 } 289 }
290 } 290 }
291
292 // The SSE2 implementation of SkNx_cast<uint16_t>(Sk4i) is non-trivial, so worth a test.
293 DEF_TEST(SkNx_int_u16, r) {
294 // These are pretty hard to get wrong.
295 for (int i = 0; i <= 0x7fff; i++) {
296 uint16_t expected = (uint16_t)i;
297 uint16_t actual = SkNx_cast<uint16_t>(Sk4i(i))[0];
298
299 REPORTER_ASSERT(r, expected == actual);
300 }
301
302 // A naive implementation with _mm_packs_epi32 would succeed up to 0x7fff bu t fail here:
303 for (int i = 0x8000; (1) && i <= 0xffff; i++) {
304 uint16_t expected = (uint16_t)i;
305 uint16_t actual = SkNx_cast<uint16_t>(Sk4i(i))[0];
306
307 REPORTER_ASSERT(r, expected == actual);
308 }
309 }
OLDNEW
« no previous file with comments | « tests/Float16Test.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698