Mesa (main): freedreno/cffdump: Fix 64-bit reg decode in script mode.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 15 22:46:48 UTC 2021


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

Author: Emma Anholt <emma at anholt.net>
Date:   Thu Nov  4 16:03:13 2021 -0700

freedreno/cffdump: Fix 64-bit reg decode in script mode.

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

---

 src/freedreno/decode/rnnutil.c | 2 +-
 src/freedreno/decode/rnnutil.h | 7 +++----
 src/freedreno/decode/script.c  | 9 ++++++---
 3 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/src/freedreno/decode/rnnutil.c b/src/freedreno/decode/rnnutil.c
index 5178f676e7a..d280389eafc 100644
--- a/src/freedreno/decode/rnnutil.c
+++ b/src/freedreno/decode/rnnutil.c
@@ -201,7 +201,7 @@ rnn_regoff(struct rnn *rnn, uint32_t offset)
 }
 
 enum rnnttype
-rnn_decodelem(struct rnn *rnn, struct rnntypeinfo *info, uint32_t regval,
+rnn_decodelem(struct rnn *rnn, struct rnntypeinfo *info, uint64_t regval,
               union rnndecval *val)
 {
    val->u = regval;
diff --git a/src/freedreno/decode/rnnutil.h b/src/freedreno/decode/rnnutil.h
index b6c65b306a4..b2883235da6 100644
--- a/src/freedreno/decode/rnnutil.h
+++ b/src/freedreno/decode/rnnutil.h
@@ -44,9 +44,8 @@ struct rnn {
 };
 
 union rnndecval {
-   uint32_t u;
-   int32_t i;
-   float f;
+   uint64_t u;
+   int64_t i;
 };
 
 void _rnn_init(struct rnn *rnn, int nocolor);
@@ -61,6 +60,6 @@ const char *rnn_enumname(struct rnn *rnn, const char *name, uint32_t val);
 struct rnndelem *rnn_regelem(struct rnn *rnn, const char *name);
 struct rnndelem *rnn_regoff(struct rnn *rnn, uint32_t offset);
 enum rnnttype rnn_decodelem(struct rnn *rnn, struct rnntypeinfo *info,
-                            uint32_t regval, union rnndecval *val);
+                            uint64_t regval, union rnndecval *val);
 
 #endif /* RNNUTIL_H_ */
diff --git a/src/freedreno/decode/script.c b/src/freedreno/decode/script.c
index c32c37aad09..52962dfef9f 100644
--- a/src/freedreno/decode/script.c
+++ b/src/freedreno/decode/script.c
@@ -35,6 +35,7 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include "util/u_math.h"
 
 #include "cffdec.h"
 #include "rnnutil.h"
@@ -181,7 +182,7 @@ static int l_rnn_etype_reg(lua_State *L, struct rnn *rnn, struct rnndelem *elem,
                            uint64_t offset);
 
 static int
-pushdecval(struct lua_State *L, struct rnn *rnn, uint32_t regval,
+pushdecval(struct lua_State *L, struct rnn *rnn, uint64_t regval,
            struct rnntypeinfo *info)
 {
    union rnndecval val;
@@ -198,7 +199,7 @@ pushdecval(struct lua_State *L, struct rnn *rnn, uint32_t regval,
       lua_pushunsigned(L, val.u);
       return 1;
    case RNN_TTYPE_FLOAT:
-      lua_pushnumber(L, val.f);
+      lua_pushnumber(L, uif(val.u));
       return 1;
    case RNN_TTYPE_BOOLEAN:
       lua_pushboolean(L, val.u);
@@ -214,7 +215,7 @@ l_rnn_etype(lua_State *L, struct rnn *rnn, struct rnndelem *elem,
             uint64_t offset)
 {
    int ret;
-   uint32_t regval;
+   uint64_t regval;
    DBG("elem=%p (%d), offset=%lu", elem, elem->type, offset);
    switch (elem->type) {
    case RNN_ETYPE_REG:
@@ -222,6 +223,8 @@ l_rnn_etype(lua_State *L, struct rnn *rnn, struct rnndelem *elem,
        * the raw value:
        */
       regval = rnn_val(rnn, offset);
+      if (elem->width == 64)
+         regval |= (uint64_t)rnn_val(rnn, offset + 1) << 32;
       regval <<= elem->typeinfo.shr;
       ret = pushdecval(L, rnn, regval, &elem->typeinfo);
       if (ret)



More information about the mesa-commit mailing list