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

Unified Diff: tests/Float16Test.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 | « src/opts/SkNx_sse.h ('k') | tests/SkNxTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/Float16Test.cpp
diff --git a/tests/Float16Test.cpp b/tests/Float16Test.cpp
index cc5efedae66faae78932767cae07d0ec5ebf146e..209165252279a3709e3d1bd71f36a4567e8e2426 100644
--- a/tests/Float16Test.cpp
+++ b/tests/Float16Test.cpp
@@ -61,26 +61,26 @@ static uint32_t u(float f) {
return x;
}
-DEF_TEST(HalfToFloat_01, r) {
- for (uint16_t h = 0; h < 0x8000; h++) {
+DEF_TEST(HalfToFloat_finite, r) {
+ for (uint32_t h = 0; h <= 0xffff; h++) {
float f = SkHalfToFloat(h);
- if (f >= 0 && f <= 1) {
- float got = SkHalfToFloat_01(h)[0];
+ if (isfinite(f)) {
+ float got = SkHalfToFloat_finite(h)[0];
if (got != f) {
SkDebugf("0x%04x -> 0x%08x (%g), want 0x%08x (%g)\n",
h,
u(got), got,
u(f), f);
}
- REPORTER_ASSERT(r, SkHalfToFloat_01(h)[0] == f);
- REPORTER_ASSERT(r, SkFloatToHalf_01(SkHalfToFloat_01(h)) == h);
+ REPORTER_ASSERT(r, SkHalfToFloat_finite(h)[0] == f);
+ REPORTER_ASSERT(r, SkFloatToHalf_finite(SkHalfToFloat_finite(h)) == h);
}
}
}
-DEF_TEST(FloatToHalf_01, r) {
+DEF_TEST(FloatToHalf_finite, r) {
#if 0
- for (uint32_t bits = 0; bits < 0x80000000; bits++) {
+ for (uint64_t bits = 0; bits <= 0xffffffff; bits++) {
#else
SkRandom rand;
for (int i = 0; i < 1000000; i++) {
@@ -88,14 +88,14 @@ DEF_TEST(FloatToHalf_01, r) {
#endif
float f;
memcpy(&f, &bits, 4);
- if (f >= 0 && f <= 1) {
- uint16_t h1 = (uint16_t)SkFloatToHalf_01(Sk4f(f,0,0,0)),
+ if (isfinite(f) && isfinite(SkHalfToFloat(SkFloatToHalf(f)))) {
+ uint16_t h1 = (uint16_t)SkFloatToHalf_finite(Sk4f(f,0,0,0)),
h2 = SkFloatToHalf(f);
bool ok = (h1 == h2 || h1 == h2-1);
REPORTER_ASSERT(r, ok);
if (!ok) {
- SkDebugf("%08x (%d) -> %04x (%d), want %04x (%d)\n",
- bits, bits>>23, h1, h1>>10, h2, h2>>10);
+ SkDebugf("%08x (%g) -> %04x, want %04x (%g)\n",
+ bits, f, h1, h2, SkHalfToFloat(h2));
break;
}
}
« no previous file with comments | « src/opts/SkNx_sse.h ('k') | tests/SkNxTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698