diff options
author | José Fonseca <[email protected]> | 2010-03-06 12:47:49 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2010-03-06 12:47:49 +0000 |
commit | 6718f0325827b1d2dde47a48332c6c0471048abe (patch) | |
tree | 5cbdf5c19c0f97ba3b19287ff5a9147b1b579575 /progs | |
parent | 709dffcd128fd3e01694545ef832297d0ae5ef7e (diff) |
progs/gallium/unit: Skip test cases which cannot be represented in 4ub.
Diffstat (limited to 'progs')
-rw-r--r-- | progs/gallium/unit/u_format_test.c | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/progs/gallium/unit/u_format_test.c b/progs/gallium/unit/u_format_test.c index bdbe443554e..af939347c3a 100644 --- a/progs/gallium/unit/u_format_test.c +++ b/progs/gallium/unit/u_format_test.c @@ -626,13 +626,27 @@ test_format_pack_4f(const struct util_format_test_case *test) } -static void +static boolean convert_4f_to_4ub(uint8_t *dst, const double *src) { unsigned i; + boolean accurate = TRUE; - for (i = 0; i < 4; ++i) - dst[i] = CLAMP(src[i], 0.0, 1.0) * 255.0; + for (i = 0; i < 4; ++i) { + if (src[i] < 0.0) { + accurate = FALSE; + dst[i] = 0; + } + else if (src[i] > 1.0) { + accurate = FALSE; + dst[i] = 255; + } + else { + dst[i] = src[i] * 255.0; + } + } + + return accurate; } @@ -670,7 +684,12 @@ test_format_pack_4ub(const struct util_format_test_case *test) unsigned i; boolean success; - convert_4f_to_4ub(unpacked, test->unpacked); + if (!convert_4f_to_4ub(unpacked, test->unpacked)) { + /* + * Skip test cases which cannot be represented by four unorm bytes. + */ + return TRUE; + } memset(packed, 0, sizeof packed); |