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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tests/Float16Test.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/SkNxTest.cpp
diff --git a/tests/SkNxTest.cpp b/tests/SkNxTest.cpp
index 5509814c07ee1b6ff27037ef6cd65a12a2fb44ee..51d937dd4dc29b25da65630981cc3417f43ad2eb 100644
--- a/tests/SkNxTest.cpp
+++ b/tests/SkNxTest.cpp
@@ -288,3 +288,22 @@ DEF_TEST(SkNx_u16_float, r) {
REPORTER_ASSERT(r, !memcmp(s16, d16, sizeof(s16)));
}
}
+
+// The SSE2 implementation of SkNx_cast<uint16_t>(Sk4i) is non-trivial, so worth a test.
+DEF_TEST(SkNx_int_u16, r) {
+ // These are pretty hard to get wrong.
+ for (int i = 0; i <= 0x7fff; i++) {
+ uint16_t expected = (uint16_t)i;
+ uint16_t actual = SkNx_cast<uint16_t>(Sk4i(i))[0];
+
+ REPORTER_ASSERT(r, expected == actual);
+ }
+
+ // A naive implementation with _mm_packs_epi32 would succeed up to 0x7fff but fail here:
+ for (int i = 0x8000; (1) && i <= 0xffff; i++) {
+ uint16_t expected = (uint16_t)i;
+ uint16_t actual = SkNx_cast<uint16_t>(Sk4i(i))[0];
+
+ REPORTER_ASSERT(r, expected == actual);
+ }
+}
« 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