From: Dave Airlie <airl...@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 <airl...@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

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to