[Mesa-dev] [PATCH 7/8] radeonsi: add radeonsi_aux_debug option for aux context debug dumps

Nicolai Hähnle nhaehnle at gmail.com
Wed Apr 24 13:14:35 UTC 2019


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

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.
---
 src/gallium/drivers/radeonsi/si_debug.c         | 17 +++++++++++++++++
 .../drivers/radeonsi/si_debug_options.inc       |  1 +
 src/gallium/drivers/radeonsi/si_pipe.c          | 14 +++++++++++++-
 3 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/radeonsi/si_debug.c b/src/gallium/drivers/radeonsi/si_debug.c
index 07de96057dc..9a4494a98fe 100644
--- a/src/gallium/drivers/radeonsi/si_debug.c
+++ b/src/gallium/drivers/radeonsi/si_debug.c
@@ -475,20 +475,37 @@ void si_auto_log_cs(void *data, struct u_log_context *log)
 	struct si_context *ctx = (struct si_context *)data;
 	si_log_cs(ctx, log, false);
 }
 
 void si_log_hw_flush(struct si_context *sctx)
 {
 	if (!sctx->log)
 		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)
 {
 #define ITEM(x) [RADEON_PRIO_##x] = #x
 	static const char *table[64] = {
 		ITEM(FENCE),
 	        ITEM(TRACE),
 	        ITEM(SO_FILLED_SIZE),
 	        ITEM(QUERY),
diff --git a/src/gallium/drivers/radeonsi/si_debug_options.inc b/src/gallium/drivers/radeonsi/si_debug_options.inc
index 165dba8baf5..f4c3e19ed95 100644
--- a/src/gallium/drivers/radeonsi/si_debug_options.inc
+++ b/src/gallium/drivers/radeonsi/si_debug_options.inc
@@ -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
diff --git a/src/gallium/drivers/radeonsi/si_pipe.c b/src/gallium/drivers/radeonsi/si_pipe.c
index 9f8bd2039ee..10566a9b8d5 100644
--- a/src/gallium/drivers/radeonsi/si_pipe.c
+++ b/src/gallium/drivers/radeonsi/si_pipe.c
@@ -718,20 +718,26 @@ static void si_destroy_screen(struct pipe_screen* pscreen)
 		}
 	}
 	mtx_destroy(&sscreen->shader_parts_mutex);
 	si_destroy_shader_cache(sscreen);
 
 	si_destroy_perfcounters(sscreen);
 	si_gpu_load_kill_thread(sscreen);
 
 	mtx_destroy(&sscreen->gpu_load_mutex);
 	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);
 
 	slab_destroy_parent(&sscreen->pool_transfers);
 
 	disk_cache_destroy(sscreen->disk_shader_cache);
 	sscreen->ws->destroy(sscreen->ws);
 	FREE(sscreen);
 }
 
 static void si_init_gs_info(struct si_screen *sscreen)
@@ -1176,21 +1182,27 @@ struct pipe_screen *radeonsi_screen_create(struct radeon_winsys *ws,
 			sscreen->eqaa_force_color_samples = f;
 		}
 	}
 
 	for (i = 0; i < num_comp_hi_threads; i++)
 		si_init_compiler(sscreen, &sscreen->compiler[i]);
 	for (i = 0; i < num_comp_lo_threads; i++)
 		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);
 
 	if (sscreen->debug_flags & DBG(TEST_DMA_PERF)) {
 		si_test_dma_perf(sscreen);
 	}
 
 	if (sscreen->debug_flags & (DBG(TEST_VMFAULT_CP) |
 				      DBG(TEST_VMFAULT_SDMA) |
-- 
2.20.1



More information about the mesa-dev mailing list