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 #include +#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");