radeonsi: add radeonsi_aux_debug option for aux context debug dumps
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 14 Mar 2019 08:51:43 +0000 (09:51 +0100)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 25 Apr 2019 10:35:27 +0000 (12:35 +0200)
Enabling this option will create ddebug-style dumps for the aux context,
except that instead of intercepting the pipe_context layer
we just dump the IB contents on flush.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/drivers/radeonsi/si_debug.c
src/gallium/drivers/radeonsi/si_debug_options.h
src/gallium/drivers/radeonsi/si_pipe.c

index 07de96057dc7783e9a4c3acdd3bd4cfd53a3c1a1..9a4494a98fe3fbbee0ab5deece430e2dea6d192b 100644 (file)
@@ -482,6 +482,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)
index 165dba8baf5936b378e4694f8a3299ae74a5813a..f4c3e19ed9574d75e6ab871cba1daa5893ada056 100644 (file)
@@ -1,4 +1,5 @@
 OPT_BOOL(clear_db_cache_before_clear, false, "Clear DB cache before fast depth clear")
 OPT_BOOL(enable_nir, false, "Enable NIR")
+OPT_BOOL(aux_debug, false, "Generate ddebug_dumps for the auxiliary context")
 
 #undef OPT_BOOL
index 938e2342aaf2e6a24c9b57f77f35c6bb0da5a95a..07642246ab65e0081bc65fcc60003e2604087f47 100644 (file)
@@ -705,6 +705,14 @@ static void si_destroy_screen(struct pipe_screen* pscreen)
                return;
 
        mtx_destroy(&sscreen->aux_context_lock);
+
+       struct u_log_context *aux_log = ((struct si_context *)sscreen->aux_context)->log;
+       if (aux_log) {
+               sscreen->aux_context->set_log_context(sscreen->aux_context, NULL);
+               u_log_context_destroy(aux_log);
+               FREE(aux_log);
+       }
+
        sscreen->aux_context->destroy(sscreen->aux_context);
 
        util_queue_destroy(&sscreen->shader_compiler_queue);
@@ -1190,7 +1198,13 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws,
                si_init_compiler(sscreen, &sscreen->compiler_lowp[i]);
 
        /* Create the auxiliary context. This must be done last. */
-       sscreen->aux_context = si_create_context(&sscreen->b, 0);
+       sscreen->aux_context = si_create_context(
+               &sscreen->b, sscreen->options.aux_debug ? PIPE_CONTEXT_DEBUG : 0);
+       if (sscreen->options.aux_debug) {
+               struct u_log_context *log = CALLOC_STRUCT(u_log_context);
+               u_log_context_init(log);
+               sscreen->aux_context->set_log_context(sscreen->aux_context, log);
+       }
 
        if (sscreen->debug_flags & DBG(TEST_DMA))
                si_test_dma(sscreen);