[Mesa-dev] [PATCH 1/2] gallium/ddebug: add GALLIUM_DDEBUG_SKIP option

Nicolai Hähnle nhaehnle at gmail.com
Wed Dec 9 17:11:07 PST 2015


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

When we know that hangs occur only very late in a reproducible run (e.g.
apitrace), we can save a lot of debugging time by skipping the flush and hang
detection for earlier draw calls.
---
 src/gallium/drivers/ddebug/dd_draw.c   | 39 +++++++++++++++++++++-------------
 src/gallium/drivers/ddebug/dd_pipe.h   |  3 +++
 src/gallium/drivers/ddebug/dd_screen.c |  9 ++++++++
 3 files changed, 36 insertions(+), 15 deletions(-)

diff --git a/src/gallium/drivers/ddebug/dd_draw.c b/src/gallium/drivers/ddebug/dd_draw.c
index b443c5b..0778099 100644
--- a/src/gallium/drivers/ddebug/dd_draw.c
+++ b/src/gallium/drivers/ddebug/dd_draw.c
@@ -588,8 +588,11 @@ dd_context_flush(struct pipe_context *_pipe,
 static void
 dd_before_draw(struct dd_context *dctx)
 {
-   if (dd_screen(dctx->base.screen)->mode == DD_DETECT_HANGS &&
-       !dd_screen(dctx->base.screen)->no_flush)
+   struct dd_screen *dscreen = dd_screen(dctx->base.screen);
+
+   if (dscreen->mode == DD_DETECT_HANGS &&
+       !dscreen->no_flush &&
+       dctx->num_draw_calls >= dscreen->skip_count)
       dd_flush_and_handle_hang(dctx, NULL, 0,
                                "GPU hang most likely caused by internal "
                                "driver commands");
@@ -598,22 +601,28 @@ dd_before_draw(struct dd_context *dctx)
 static void
 dd_after_draw(struct dd_context *dctx, struct dd_call *call)
 {
-   switch (dd_screen(dctx->base.screen)->mode) {
-   case DD_DETECT_HANGS:
-      if (!dd_screen(dctx->base.screen)->no_flush &&
-          dd_flush_and_check_hang(dctx, NULL, 0)) {
-         dd_dump_call(dctx, call, PIPE_DEBUG_DEVICE_IS_HUNG);
+   struct dd_screen *dscreen = dd_screen(dctx->base.screen);
 
-         /* Terminate the process to prevent future hangs. */
-         dd_kill_process();
+   if (dctx->num_draw_calls >= dscreen->skip_count) {
+      switch (dscreen->mode) {
+      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);
+
+            /* Terminate the process to prevent future hangs. */
+            dd_kill_process();
+         }
+         break;
+      case DD_DUMP_ALL_CALLS:
+         dd_dump_call(dctx, call, 0);
+         break;
+      default:
+         assert(0);
       }
-      break;
-   case DD_DUMP_ALL_CALLS:
-      dd_dump_call(dctx, call, 0);
-      break;
-   default:
-      assert(0);
    }
+
+   ++dctx->num_draw_calls;
 }
 
 static void
diff --git a/src/gallium/drivers/ddebug/dd_pipe.h b/src/gallium/drivers/ddebug/dd_pipe.h
index 34f5920..a045518 100644
--- a/src/gallium/drivers/ddebug/dd_pipe.h
+++ b/src/gallium/drivers/ddebug/dd_pipe.h
@@ -45,6 +45,7 @@ struct dd_screen
    unsigned timeout_ms;
    enum dd_mode mode;
    bool no_flush;
+   unsigned skip_count;
 };
 
 struct dd_query
@@ -110,6 +111,8 @@ struct dd_context
    struct pipe_scissor_state scissors[PIPE_MAX_VIEWPORTS];
    struct pipe_viewport_state viewports[PIPE_MAX_VIEWPORTS];
    float tess_default_levels[6];
+
+   unsigned num_draw_calls;
 };
 
 
diff --git a/src/gallium/drivers/ddebug/dd_screen.c b/src/gallium/drivers/ddebug/dd_screen.c
index a776580..2716845 100644
--- a/src/gallium/drivers/ddebug/dd_screen.c
+++ b/src/gallium/drivers/ddebug/dd_screen.c
@@ -290,6 +290,9 @@ ddebug_screen_create(struct pipe_screen *screen)
       puts("    $HOME/"DD_DIR"/ when a hang is detected.");
       puts("    If 'noflush' is specified, only detect hangs in pipe->flush.");
       puts("");
+      puts("  GALLIUM_DDEBUG_SKIP=[count]");
+      puts("    Skip flush and hang detection for the given initial number of draw calls.");
+      puts("");
       exit(0);
    }
 
@@ -349,5 +352,11 @@ ddebug_screen_create(struct pipe_screen *screen)
       assert(0);
    }
 
+   dscreen->skip_count = debug_get_num_option("GALLIUM_DDEBUG_SKIP", 0);
+   if (dscreen->skip_count > 0) {
+      fprintf(stderr, "Gallium debugger skipping the first %u draw calls.\n",
+              dscreen->skip_count);
+   }
+
    return &dscreen->base;
 }
-- 
2.5.0



More information about the mesa-dev mailing list