gallium: Make sure we return is_unorm/is_snorm for compressed formats.
[mesa.git] / src / gallium / tests / unit / u_half_test.c
index 00bda7f50a6cd0c9b7cbfc688aac2111f3a3697b..a53a043bfdeca4f3c0328ab7e02365b4f60a5507 100644 (file)
@@ -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;
 }