amd/common: use generated register header
[mesa.git] / src / gallium / drivers / radeonsi / si_debug.c
index 07de96057dc7783e9a4c3acdd3bd4cfd53a3c1a1..165e95c4ce59edc5fe7c8c4643eb682663d646ac 100644 (file)
@@ -25,7 +25,6 @@
 #include "si_pipe.h"
 #include "si_compute.h"
 #include "sid.h"
-#include "gfx9d.h"
 #include "sid_tables.h"
 #include "driver_ddebug/dd_util.h"
 #include "util/u_dump.h"
@@ -314,7 +313,7 @@ static void si_dump_debug_registers(struct si_context *sctx, FILE *f)
        si_dump_mmapped_reg(sctx, f, R_00803C_GRBM_STATUS_SE3);
        si_dump_mmapped_reg(sctx, f, R_00D034_SDMA0_STATUS_REG);
        si_dump_mmapped_reg(sctx, f, R_00D834_SDMA1_STATUS_REG);
-       if (sctx->chip_class <= VI) {
+       if (sctx->chip_class <= GFX8) {
                si_dump_mmapped_reg(sctx, f, R_000E50_SRBM_STATUS);
                si_dump_mmapped_reg(sctx, f, R_000E4C_SRBM_STATUS2);
                si_dump_mmapped_reg(sctx, f, R_000E54_SRBM_STATUS3);
@@ -337,6 +336,7 @@ struct si_log_chunk_cs {
        struct si_saved_cs *cs;
        bool dump_bo_list;
        unsigned gfx_begin, gfx_end;
+       unsigned compute_begin, compute_end;
 };
 
 static void si_log_chunk_type_cs_destroy(void *data)
@@ -394,6 +394,7 @@ static void si_log_chunk_type_cs_print(void *data, FILE *f)
        struct si_context *ctx = chunk->ctx;
        struct si_saved_cs *scs = chunk->cs;
        int last_trace_id = -1;
+       int last_compute_trace_id = -1;
 
        /* We are expecting that the ddebug pipe has already
         * waited for the context, so this buffer should be idle.
@@ -403,8 +404,10 @@ static void si_log_chunk_type_cs_print(void *data, FILE *f)
                                              NULL,
                                              PIPE_TRANSFER_UNSYNCHRONIZED |
                                              PIPE_TRANSFER_READ);
-       if (map)
+       if (map) {
                last_trace_id = map[0];
+               last_compute_trace_id = map[1];
+       }
 
        if (chunk->gfx_end != chunk->gfx_begin) {
                if (chunk->gfx_begin == 0) {
@@ -432,6 +435,21 @@ static void si_log_chunk_type_cs_print(void *data, FILE *f)
                }
        }
 
+       if (chunk->compute_end != chunk->compute_begin) {
+               assert(ctx->prim_discard_compute_cs);
+
+               if (scs->flushed) {
+                       ac_parse_ib(f, scs->compute.ib + chunk->compute_begin,
+                                   chunk->compute_end - chunk->compute_begin,
+                                   &last_compute_trace_id, map ? 1 : 0, "Compute IB", ctx->chip_class,
+                                   NULL, NULL);
+               } else {
+                       si_parse_current_ib(f, ctx->prim_discard_compute_cs, chunk->compute_begin,
+                                           chunk->compute_end, &last_compute_trace_id,
+                                           map ? 1 : 0, "Compute IB", ctx->chip_class);
+               }
+       }
+
        if (chunk->dump_bo_list) {
                fprintf(f, "Flushing. Time: ");
                util_dump_ns(f, scs->time_flush);
@@ -452,9 +470,14 @@ static void si_log_cs(struct si_context *ctx, struct u_log_context *log,
 
        struct si_saved_cs *scs = ctx->current_saved_cs;
        unsigned gfx_cur = ctx->gfx_cs->prev_dw + ctx->gfx_cs->current.cdw;
+       unsigned compute_cur = 0;
+
+       if (ctx->prim_discard_compute_cs)
+               compute_cur = ctx->prim_discard_compute_cs->prev_dw + ctx->prim_discard_compute_cs->current.cdw;
 
        if (!dump_bo_list &&
-           gfx_cur == scs->gfx_last_dw)
+           gfx_cur == scs->gfx_last_dw &&
+           compute_cur == scs->compute_last_dw)
                return;
 
        struct si_log_chunk_cs *chunk = calloc(1, sizeof(*chunk));
@@ -467,6 +490,10 @@ static void si_log_cs(struct si_context *ctx, struct u_log_context *log,
        chunk->gfx_end = gfx_cur;
        scs->gfx_last_dw = gfx_cur;
 
+       chunk->compute_begin = scs->compute_last_dw;
+       chunk->compute_end = compute_cur;
+       scs->compute_last_dw = compute_cur;
+
        u_log_chunk(log, &si_log_chunk_type_cs, chunk);
 }
 
@@ -482,6 +509,23 @@ void si_log_hw_flush(struct si_context *sctx)
                return;
 
        si_log_cs(sctx, sctx->log, true);
+
+       if (&sctx->b == sctx->screen->aux_context) {
+               /* The aux context isn't captured by the ddebug wrapper,
+                * so we dump it on a flush-by-flush basis here.
+                */
+               FILE *f = dd_get_debug_file(false);
+               if (!f) {
+                       fprintf(stderr, "radeonsi: error opening aux context dump file.\n");
+               } else {
+                       dd_write_header(f, &sctx->screen->b, 0);
+
+                       fprintf(f, "Aux context dump:\n\n");
+                       u_log_new_page_print(sctx->log, f);
+
+                       fclose(f);
+               }
+       }
 }
 
 static const char *priority_to_string(enum radeon_bo_priority priority)