diff options
Diffstat (limited to 'src/gallium/tests')
-rw-r--r-- | src/gallium/tests/unit/u_format_test.c | 23 | ||||
-rw-r--r-- | src/gallium/tests/unit/u_half_test.c | 15 |
2 files changed, 31 insertions, 7 deletions
diff --git a/src/gallium/tests/unit/u_format_test.c b/src/gallium/tests/unit/u_format_test.c index b0e44766bd9..2d89e7ed45b 100644 --- a/src/gallium/tests/unit/u_format_test.c +++ b/src/gallium/tests/unit/u_format_test.c @@ -293,9 +293,14 @@ test_format_pack_rgba_float(const struct util_format_description *format_desc, format_desc->block.width, format_desc->block.height); success = TRUE; - for (i = 0; i < format_desc->block.bits/8; ++i) + for (i = 0; i < format_desc->block.bits/8; ++i) { if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i])) success = FALSE; + } + + /* Ignore NaN */ + if (util_is_double_nan(test->unpacked[0][0][0])) + success = TRUE; if (!success) { print_packed(format_desc, "FAILED: ", packed, " obtained\n"); @@ -356,6 +361,10 @@ test_format_unpack_rgba_8unorm(const struct util_format_description *format_desc } } + /* Ignore NaN */ + if (util_is_double_nan(test->unpacked[0][0][0])) + success = TRUE; + if (!success) { print_unpacked_rgba_8unorm(format_desc, "FAILED: ", unpacked, " obtained\n"); print_unpacked_rgba_8unorm(format_desc, " ", expected, " expected\n"); @@ -401,6 +410,18 @@ test_format_pack_rgba_8unorm(const struct util_format_description *format_desc, if ((test->packed[i] & test->mask[i]) != (packed[i] & test->mask[i])) success = FALSE; + /* Ignore NaN */ + if (util_is_double_nan(test->unpacked[0][0][0])) + success = TRUE; + + /* Ignore failure cases due to unorm8 format */ + if (test->unpacked[0][0][0] > 1.0f || test->unpacked[0][0][0] < 0.0f) + success = TRUE; + + /* Multiple of 255 */ + if ((test->unpacked[0][0][0] * 255.0) != (int)(test->unpacked[0][0][0] * 255.0)) + success = TRUE; + if (!success) { print_packed(format_desc, "FAILED: ", packed, " obtained\n"); print_packed(format_desc, " ", test->packed, " expected\n"); diff --git a/src/gallium/tests/unit/u_half_test.c b/src/gallium/tests/unit/u_half_test.c index 00bda7f50a6..a53a043bfde 100644 --- a/src/gallium/tests/unit/u_half_test.c +++ b/src/gallium/tests/unit/u_half_test.c @@ -10,17 +10,19 @@ main(int argc, char **argv) { unsigned i; unsigned roundtrip_fails = 0; + for(i = 0; i < 1 << 16; ++i) { uint16_t h = (uint16_t) i; union fi f; uint16_t rh; - f.ui = util_half_to_floatui(h); - rh = util_floatui_to_half(f.ui); - if(h != rh) - { - printf("Roundtrip failed: %x -> %x = %f -> %x\n", h, f.ui, f.f, rh); - ++roundtrip_fails; + + f.f = util_half_to_float(h); + rh = util_float_to_half(f.f); + + if (h != rh && !(util_is_half_nan(h) && util_is_half_nan(rh))) { + printf("Roundtrip failed: %x -> %x = %f -> %x\n", h, f.ui, f.f, rh); + ++roundtrip_fails; } } @@ -28,5 +30,6 @@ main(int argc, char **argv) printf("Failure! %u/65536 half floats failed a conversion to float and back.\n", roundtrip_fails); else printf("Success!\n"); + return 0; } |