gallium: rework flags for pipe_context::dump_debug_state
authorMarek Olšák <marek.olsak@amd.com>
Tue, 19 Jul 2016 19:41:03 +0000 (21:41 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 26 Jul 2016 21:06:46 +0000 (23:06 +0200)
The pipelined hang detection mode will not want to dump everything.
(and it's also time consuming) It will only dump shaders after a draw call
and then dump the status registers separately if a hang is detected.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/ddebug/dd_draw.c
src/gallium/drivers/radeonsi/si_debug.c
src/gallium/include/pipe/p_context.h
src/gallium/include/pipe/p_defines.h

index f8047ccc852df54a388a3cf412275f23809cbfcf..c3fd9685b17e1c85a1bfdac47bbbe1a461e33aa9 100644 (file)
@@ -595,7 +595,11 @@ dd_flush_and_handle_hang(struct dd_context *dctx,
 
       if (f) {
          fprintf(f, "dd: %s.\n", cause);
-         dd_dump_driver_state(dctx, f, PIPE_DEBUG_DEVICE_IS_HUNG);
+         dd_dump_driver_state(dctx, f,
+                              PIPE_DUMP_DEVICE_STATUS_REGISTERS |
+                              PIPE_DUMP_CURRENT_STATES |
+                              PIPE_DUMP_CURRENT_SHADERS |
+                              PIPE_DUMP_LAST_COMMAND_BUFFER);
          dd_close_file_stream(f);
       }
 
@@ -649,7 +653,11 @@ dd_after_draw(struct dd_context *dctx, struct dd_call *call)
       case DD_DETECT_HANGS:
          if (!dscreen->no_flush &&
             dd_flush_and_check_hang(dctx, NULL, 0)) {
-            dd_dump_call(dctx, call, PIPE_DEBUG_DEVICE_IS_HUNG);
+            dd_dump_call(dctx, call,
+                         PIPE_DUMP_DEVICE_STATUS_REGISTERS |
+                         PIPE_DUMP_CURRENT_STATES |
+                         PIPE_DUMP_CURRENT_SHADERS |
+                         PIPE_DUMP_LAST_COMMAND_BUFFER);
 
             /* Terminate the process to prevent future hangs. */
             dd_kill_process();
index 73e0bfeb34479fd6cc7c0b3fe703c9e482215534..35d961d34f5975003465da027dae36a0afef6be9 100644 (file)
@@ -665,24 +665,30 @@ static void si_dump_debug_state(struct pipe_context *ctx, FILE *f,
 {
        struct si_context *sctx = (struct si_context*)ctx;
 
-       if (flags & PIPE_DEBUG_DEVICE_IS_HUNG)
+       if (flags & PIPE_DUMP_DEVICE_STATUS_REGISTERS)
                si_dump_debug_registers(sctx, f);
 
-       si_dump_framebuffer(sctx, f);
-       si_dump_shader(sctx->screen, &sctx->vs_shader, f);
-       si_dump_shader(sctx->screen, &sctx->tcs_shader, f);
-       si_dump_shader(sctx->screen, &sctx->tes_shader, f);
-       si_dump_shader(sctx->screen, &sctx->gs_shader, f);
-       si_dump_shader(sctx->screen, &sctx->ps_shader, f);
+       if (flags & PIPE_DUMP_CURRENT_STATES)
+               si_dump_framebuffer(sctx, f);
 
-       si_dump_bo_list(sctx, &sctx->last_gfx, f);
-       si_dump_last_ib(sctx, f);
+       if (flags & PIPE_DUMP_CURRENT_SHADERS) {
+               si_dump_shader(sctx->screen, &sctx->vs_shader, f);
+               si_dump_shader(sctx->screen, &sctx->tcs_shader, f);
+               si_dump_shader(sctx->screen, &sctx->tes_shader, f);
+               si_dump_shader(sctx->screen, &sctx->gs_shader, f);
+               si_dump_shader(sctx->screen, &sctx->ps_shader, f);
+       }
+
+       if (flags & PIPE_DUMP_LAST_COMMAND_BUFFER) {
+               si_dump_bo_list(sctx, &sctx->last_gfx, f);
+               si_dump_last_ib(sctx, f);
 
-       fprintf(f, "Done.\n");
+               fprintf(f, "Done.\n");
 
-       /* dump only once */
-       radeon_clear_saved_cs(&sctx->last_gfx);
-       r600_resource_reference(&sctx->last_trace_buf, NULL);
+               /* dump only once */
+               radeon_clear_saved_cs(&sctx->last_gfx);
+               r600_resource_reference(&sctx->last_trace_buf, NULL);
+       }
 }
 
 static void si_dump_dma(struct si_context *sctx,
index fe567b67197b6be61f1ca0ec60f4c5fea08e8bfc..f1de189b676a53fd05908e048f70b855de914472 100644 (file)
@@ -690,7 +690,7 @@ struct pipe_context {
     *
     * \param ctx        pipe context
     * \param stream     where the output should be written to
-    * \param flags      a mask of PIPE_DEBUG_* flags
+    * \param flags      a mask of PIPE_DUMP_* flags
     */
    void (*dump_debug_state)(struct pipe_context *ctx, FILE *stream,
                             unsigned flags);
index 8655814dd0cc186a23778d5ad9eec3b43495d2c6..69bd89ece61f7f1fb8a1b993e6d730e9e35da9df 100644 (file)
@@ -355,7 +355,10 @@ enum pipe_flush_flags
 /**
  * Flags for pipe_context::dump_debug_state.
  */
-#define PIPE_DEBUG_DEVICE_IS_HUNG      (1 << 0)
+#define PIPE_DUMP_DEVICE_STATUS_REGISTERS    (1 << 0)
+#define PIPE_DUMP_CURRENT_STATES             (1 << 1)
+#define PIPE_DUMP_CURRENT_SHADERS            (1 << 2)
+#define PIPE_DUMP_LAST_COMMAND_BUFFER        (1 << 3)
 
 /**
  * Create a compute-only context. Use in pipe_screen::context_create.