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

Unified Diff: tests/Float16Test.cpp

Issue 2276533002: f16<->f32 ftz is an optional thing for speed. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 4 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/core/SkHalf.h ('k') | no next file » | 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 3e057587c9243b4f84c2cdefe9e6e345731c895d..99835686fad361289061ac40f06c1978992fe2af 100644
--- a/tests/Float16Test.cpp
+++ b/tests/Float16Test.cpp
@@ -70,10 +70,13 @@ DEF_TEST(SkHalfToFloat_finite_ftz, r) {
continue;
}
- // _finite_ftz() flushes denorms to zero. 0.0f will compare == with both +0.0f and -0.0f.
- float expected = is_denorm(h) ? 0.0f : SkHalfToFloat(h);
+ // _finite_ftz() may flush denorms to zero. 0.0f will compare == with both +0.0f and -0.0f.
+ float expected = SkHalfToFloat(h),
+ alternate = is_denorm(h) ? 0.0f : expected;
- REPORTER_ASSERT(r, SkHalfToFloat_finite_ftz(h)[0] == expected);
+ float actual = SkHalfToFloat_finite_ftz(h)[0];
+
+ REPORTER_ASSERT(r, actual == expected || actual == alternate);
}
}
@@ -94,13 +97,15 @@ DEF_TEST(SkFloatToHalf_finite_ftz, r) {
continue;
}
+ uint16_t alternate = expected;
if (is_denorm(expected)) {
- // _finite_ftz() flushes denorms to zero, and happens to keep the sign bit.
- expected = signbit(f) ? 0x8000 : 0x0000;
+ // _finite_ftz() may flush denorms to zero, and happens to keep the sign bit.
+ alternate = signbit(f) ? 0x8000 : 0x0000;
}
uint16_t actual = SkFloatToHalf_finite_ftz(Sk4f{f})[0];
- // _finite_ftz() truncates instead of rounding, so it may be one too small.
- REPORTER_ASSERT(r, actual == expected || actual == expected - 1);
+ // _finite_ftz() may truncate instead of rounding, so it may be one too small.
+ REPORTER_ASSERT(r, actual == expected || actual == expected - 1 ||
+ actual == alternate || actual == alternate - 1);
}
}
« no previous file with comments | « src/core/SkHalf.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698