nir: print 8 and 16 bit constants correctly
authorKarol Herbst <kherbst@redhat.com>
Sat, 21 Apr 2018 23:31:22 +0000 (01:31 +0200)
committerKarol Herbst <kherbst@redhat.com>
Thu, 26 Apr 2018 09:16:15 +0000 (11:16 +0200)
Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
src/compiler/nir/nir_print.c

index 21f1309765162be95272122dadfe27dfb7d052c5..97b2d6164cd73bbcf7233d8371f4ae73dafa2854 100644 (file)
@@ -27,6 +27,7 @@
 
 #include "nir.h"
 #include "compiler/shader_enums.h"
+#include "util/half_float.h"
 #include <stdio.h>
 #include <stdlib.h>
 #include <inttypes.h> /* for PRIx64 macro */
@@ -846,11 +847,22 @@ print_load_const_instr(nir_load_const_instr *instr, print_state *state)
        * and then print the float in a comment for readability.
        */
 
-      if (instr->def.bit_size == 64)
+      switch (instr->def.bit_size) {
+      case 64:
          fprintf(fp, "0x%16" PRIx64 " /* %f */", instr->value.u64[i],
                  instr->value.f64[i]);
-      else
+         break;
+      case 32:
          fprintf(fp, "0x%08x /* %f */", instr->value.u32[i], instr->value.f32[i]);
+         break;
+      case 16:
+         fprintf(fp, "0x%04x /* %f */", instr->value.u16[i],
+                 _mesa_half_to_float(instr->value.u16[i]));
+         break;
+      case 8:
+         fprintf(fp, "0x%02x", instr->value.u8[i]);
+         break;
+      }
    }
 
    fprintf(fp, ")");