[Mesa-dev] [PATCH 1/2] r600: add simple ib dumping under a env var
Dave Airlie
airlied at gmail.com
Tue Mar 13 02:32:48 UTC 2018
From: Dave Airlie <airlied at redhat.com>
I've used this a lot when developing, and keep rebasing it around a lot,
seems like it could be useful to have upstream.
R600_DUMP witll make lots of /tmp/rad_dump_<id>.txt for every command
submitted to the hw.
Signed-off-by: Dave Airlie <airlied at redhat.com>
---
src/gallium/drivers/r600/eg_debug.c | 16 ++++++++++++++++
src/gallium/drivers/r600/r600_hw_context.c | 4 ++++
src/gallium/drivers/r600/r600_pipe.h | 2 ++
3 files changed, 22 insertions(+)
diff --git a/src/gallium/drivers/r600/eg_debug.c b/src/gallium/drivers/r600/eg_debug.c
index ceb7c16..990bd56 100644
--- a/src/gallium/drivers/r600/eg_debug.c
+++ b/src/gallium/drivers/r600/eg_debug.c
@@ -359,3 +359,19 @@ void eg_dump_debug_state(struct pipe_context *ctx, FILE *f,
radeon_clear_saved_cs(&rctx->last_gfx);
r600_resource_reference(&rctx->last_trace_buf, NULL);
}
+
+void eg_dump_ib_to_file(struct r600_context *rctx,
+ struct radeon_winsys_cs *cs)
+{
+ static int ib_dump_id = 0;
+ char name[128];
+ FILE *fl;
+ ib_dump_id++;
+
+ snprintf(name, 127, "/tmp/rad_dump_%d.txt", ib_dump_id);
+ fl = fopen(name, "w+");
+ eg_parse_ib(fl, cs->current.buf, cs->current.cdw,
+ -1, "IB", rctx->b.chip_class,
+ NULL, NULL);
+ fclose(fl);
+}
diff --git a/src/gallium/drivers/r600/r600_hw_context.c b/src/gallium/drivers/r600/r600_hw_context.c
index 3ce1825..3031cdd 100644
--- a/src/gallium/drivers/r600/r600_hw_context.c
+++ b/src/gallium/drivers/r600/r600_hw_context.c
@@ -293,6 +293,10 @@ void r600_context_gfx_flush(void *context, unsigned flags,
r600_resource_reference(&ctx->last_trace_buf, ctx->trace_buf);
r600_resource_reference(&ctx->trace_buf, NULL);
}
+
+ if (getenv("R600_DUMP"))
+ eg_dump_ib_to_file(ctx, cs);
+
/* Flush the CS. */
ws->cs_flush(cs, flags, &ctx->b.last_gfx_fence);
if (fence)
diff --git a/src/gallium/drivers/r600/r600_pipe.h b/src/gallium/drivers/r600/r600_pipe.h
index 6d09093..87978ee 100644
--- a/src/gallium/drivers/r600/r600_pipe.h
+++ b/src/gallium/drivers/r600/r600_pipe.h
@@ -1077,4 +1077,6 @@ void r600_update_compressed_resource_state(struct r600_context *rctx, bool compu
void eg_setup_buffer_constants(struct r600_context *rctx, int shader_type);
void r600_update_driver_const_buffers(struct r600_context *rctx, bool compute_only);
+void eg_dump_ib_to_file(struct r600_context *rctx,
+ struct radeon_winsys_cs *cs);
#endif
--
2.9.5
More information about the mesa-dev
mailing list