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

Author: Rob Clark <[email protected]>
Date:   Tue Oct 25 13:19:25 2022 -0700

freedreno/cffdec: Add helper to parse CP_INDIRECT_BUFFER

Signed-off-by: Rob Clark <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19551>

---

 src/freedreno/decode/cffdec.c | 35 +++++++++++++++++++++++++----------
 src/freedreno/decode/cffdec.h |  2 ++
 2 files changed, 27 insertions(+), 10 deletions(-)

diff --git a/src/freedreno/decode/cffdec.c b/src/freedreno/decode/cffdec.c
index 69749904e06..db18b46aa37 100644
--- a/src/freedreno/decode/cffdec.c
+++ b/src/freedreno/decode/cffdec.c
@@ -2232,6 +2232,29 @@ cp_nop(uint32_t *dwords, uint32_t sizedwords, int level)
    printf("\n");
 }
 
+uint32_t *
+parse_cp_indirect(uint32_t *dwords, uint32_t sizedwords,
+                  uint64_t *ibaddr, uint32_t *ibsize)
+{
+   if (is_64b()) {
+      assert(sizedwords == 3);
+
+      /* a5xx+.. high 32b of gpu addr, then size: */
+      *ibaddr = dwords[0];
+      *ibaddr |= ((uint64_t)dwords[1]) << 32;
+      *ibsize = dwords[2];
+
+      return dwords + 3;
+   } else {
+      assert(sizedwords == 2);
+
+      *ibaddr = dwords[0];
+      *ibsize = dwords[1];
+
+      return dwords + 2;
+   }
+}
+
 static void
 cp_indirect(uint32_t *dwords, uint32_t sizedwords, int level)
 {
@@ -2240,15 +2263,7 @@ cp_indirect(uint32_t *dwords, uint32_t sizedwords, int 
level)
    uint32_t ibsize;
    uint32_t *ptr = NULL;
 
-   if (is_64b()) {
-      /* a5xx+.. high 32b of gpu addr, then size: */
-      ibaddr = dwords[0];
-      ibaddr |= ((uint64_t)dwords[1]) << 32;
-      ibsize = dwords[2];
-   } else {
-      ibaddr = dwords[0];
-      ibsize = dwords[1];
-   }
+   dwords = parse_cp_indirect(dwords, sizedwords, &ibaddr, &ibsize);
 
    if (!quiet(3)) {
       if (is_64b()) {
@@ -2279,7 +2294,7 @@ cp_indirect(uint32_t *dwords, uint32_t sizedwords, int 
level)
        * executed but never returns.  Account for this by checking if
        * the IB returned:
        */
-      highlight_gpuaddr(gpuaddr(&dwords[is_64b() ? 3 : 2]));
+      highlight_gpuaddr(gpuaddr(dwords));
 
       ib++;
       ibs[ib].base = ibaddr;
diff --git a/src/freedreno/decode/cffdec.h b/src/freedreno/decode/cffdec.h
index 055462a793b..d825b78ae82 100644
--- a/src/freedreno/decode/cffdec.h
+++ b/src/freedreno/decode/cffdec.h
@@ -116,6 +116,8 @@ bool reg_written(uint32_t regbase);
 uint32_t reg_lastval(uint32_t regbase);
 uint32_t reg_val(uint32_t regbase);
 void reg_set(uint32_t regbase, uint32_t val);
+uint32_t * parse_cp_indirect(uint32_t *dwords, uint32_t sizedwords,
+                             uint64_t *ibaddr, uint32_t *ibsize);
 void reset_regs(void);
 void cffdec_init(const struct cffdec_options *options);
 void dump_register_val(struct regacc *r, int level);

Reply via email to