Mesa (master): radeonsi: dump shader binary buffer contents

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jun 13 00:40:13 UTC 2019


Module: Mesa
Branch: master
Commit: 66da60f4dae01b770be38f10b5781a47c61b3b7d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=66da60f4dae01b770be38f10b5781a47c61b3b7d

Author: Nicolai Hähnle <nicolai.haehnle at amd.com>
Date:   Thu Dec  6 12:35:36 2018 +0100

radeonsi: dump shader binary buffer contents

Help identify bugs related to corruption of shaders in memory,
or errors in shader upload / rtld.

Reviewed-by: Marek Olšák <marek.olsak at amd.com>

---

 src/gallium/drivers/radeonsi/si_debug.c         | 18 ++++++++++++++++++
 src/gallium/drivers/radeonsi/si_debug_options.h |  1 +
 2 files changed, 19 insertions(+)

diff --git a/src/gallium/drivers/radeonsi/si_debug.c b/src/gallium/drivers/radeonsi/si_debug.c
index 165e95c4ce5..9df3175aa3c 100644
--- a/src/gallium/drivers/radeonsi/si_debug.c
+++ b/src/gallium/drivers/radeonsi/si_debug.c
@@ -104,6 +104,24 @@ static void si_dump_shader(struct si_screen *sscreen,
 		fwrite(shader->shader_log, shader->shader_log_size, 1, f);
 	else
 		si_shader_dump(sscreen, shader, NULL, processor, f, false);
+
+	if (shader->bo && sscreen->options.dump_shader_binary) {
+		unsigned size = shader->bo->b.b.width0;
+		fprintf(f, "BO: VA=%"PRIx64" Size=%u\n", shader->bo->gpu_address, size);
+
+		const char *mapped = sscreen->ws->buffer_map(shader->bo->buf, NULL,
+						       PIPE_TRANSFER_UNSYNCHRONIZED |
+						       PIPE_TRANSFER_READ |
+						       RADEON_TRANSFER_TEMPORARY);
+
+		for (unsigned i = 0; i < size; i += 4) {
+			fprintf(f, " %4x: %08x\n", i, *(uint32_t*)(mapped + i));
+		}
+
+		sscreen->ws->buffer_unmap(shader->bo->buf);
+
+		fprintf(f, "\n");
+	}
 }
 
 struct si_log_chunk_shader {
diff --git a/src/gallium/drivers/radeonsi/si_debug_options.h b/src/gallium/drivers/radeonsi/si_debug_options.h
index d5fe8499bb9..64a1d2a5985 100644
--- a/src/gallium/drivers/radeonsi/si_debug_options.h
+++ b/src/gallium/drivers/radeonsi/si_debug_options.h
@@ -2,6 +2,7 @@ OPT_BOOL(clear_db_cache_before_clear, false, "Clear DB cache before fast depth c
 OPT_BOOL(enable_nir, false, "Enable NIR")
 OPT_BOOL(aux_debug, false, "Generate ddebug_dumps for the auxiliary context")
 OPT_BOOL(sync_compile, false, "Always compile synchronously (will cause stalls)")
+OPT_BOOL(dump_shader_binary, false, "Dump shader binary as part of ddebug_dumps")
 OPT_BOOL(vs_fetch_always_opencode, false, "Always open code vertex fetches (less efficient, purely for testing)")
 OPT_BOOL(prim_restart_tri_strips_only, false, "Only enable primitive restart for triangle strips")
 




More information about the mesa-commit mailing list