Mesa (main): freedreno: Reuse u_math.h instead of open coding uif().

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Oct 1 23:38:26 UTC 2021


Module: Mesa
Branch: main
Commit: 7438ea55c427d9f50bc6df877cda4163abdae406
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7438ea55c427d9f50bc6df877cda4163abdae406

Author: Eric Anholt <eric at anholt.net>
Date:   Mon Aug 17 16:11:44 2020 -0700

freedreno: Reuse u_math.h instead of open coding uif().

Plus the old version had a comment with what conversion was being done
swapped!

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6360>

---

 src/freedreno/decode/pgmdump2.c |  4 ++--
 src/freedreno/decode/util.h     | 17 +++--------------
 2 files changed, 5 insertions(+), 16 deletions(-)

diff --git a/src/freedreno/decode/pgmdump2.c b/src/freedreno/decode/pgmdump2.c
index 227fd22c131..94d6c3401ee 100644
--- a/src/freedreno/decode/pgmdump2.c
+++ b/src/freedreno/decode/pgmdump2.c
@@ -101,7 +101,7 @@ struct state {
 #define F(s, field)                                                            \
    do {                                                                        \
       OFF(s->field);                                                           \
-      printf("%s%12s:\t%f (0x%0x)\n", tab(state->lvl), #field, d2f(s->field),  \
+      printf("%s%12s:\t%f (0x%0x)\n", tab(state->lvl), #field, uif(s->field),  \
              s->field);                                                        \
    } while (0)
 
@@ -161,7 +161,7 @@ dump_unknown(struct state *state, void *buf, unsigned start, unsigned n)
          uint8_t c = *(ascii++);
          printf("%c", (isascii(c) && !iscntrl(c)) ? c : '.');
       }
-      printf("|\t%f", d2f(d));
+      printf("|\t%f", uif(d));
 
       /* TODO maybe scan for first non-null and non-ascii char starting from
        * end of shader binary to (roughly) establish the start of the string
diff --git a/src/freedreno/decode/util.h b/src/freedreno/decode/util.h
index 21655c80902..fbc5a78c36b 100644
--- a/src/freedreno/decode/util.h
+++ b/src/freedreno/decode/util.h
@@ -28,6 +28,8 @@
 #include <stdint.h>
 #include <stdio.h>
 
+#include "util/u_math.h"
+
 /* old-style program binary XOR'd ascii w/ 0xff */
 #ifndef ASCII_XOR
 #define ASCII_XOR 0
@@ -40,19 +42,6 @@ tab(int lvl)
    return &TAB[strlen(TAB) - lvl];
 }
 
-/* convert float to dword */
-static inline float
-d2f(uint32_t d)
-{
-   union {
-      float f;
-      uint32_t d;
-   } u = {
-      .d = d,
-   };
-   return u.f;
-}
-
 static inline void
 dump_hex(const void *buf, int sz)
 {
@@ -101,7 +90,7 @@ dump_float(const void *buf, int sz)
       d |= *(ptr++) << 16;
       d |= (uint32_t)*(ptr++) << 24;
 
-      printf("%8f", d2f(d));
+      printf("%8f", uif(d));
 
       if ((i % 8) == 7) {
          printf("\n");



More information about the mesa-commit mailing list