[Mesa-dev] [PATCH 22/25] ddebug: dump context and before/after times of draws

Nicolai Hähnle nhaehnle at gmail.com
Sun Oct 22 19:08:05 UTC 2017


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

---
 src/gallium/drivers/ddebug/dd_draw.c | 8 ++++++++
 src/gallium/drivers/ddebug/dd_pipe.h | 2 ++
 2 files changed, 10 insertions(+)

diff --git a/src/gallium/drivers/ddebug/dd_draw.c b/src/gallium/drivers/ddebug/dd_draw.c
index a856d0142a1..182d6f297a1 100644
--- a/src/gallium/drivers/ddebug/dd_draw.c
+++ b/src/gallium/drivers/ddebug/dd_draw.c
@@ -783,20 +783,25 @@ dd_free_record(struct pipe_screen *screen, struct dd_draw_record *record)
    screen->fence_reference(screen, &record->prev_bottom_of_pipe, NULL);
    screen->fence_reference(screen, &record->top_of_pipe, NULL);
    screen->fence_reference(screen, &record->bottom_of_pipe, NULL);
    util_queue_fence_destroy(&record->driver_finished);
    FREE(record);
 }
 
 static void
 dd_write_record(FILE *f, struct dd_draw_record *record)
 {
+   PRINT_NAMED(ptr, "pipe", record->dctx->pipe);
+   PRINT_NAMED(ns, "time before (API call)", record->time_before);
+   PRINT_NAMED(ns, "time after (driver done)", record->time_after);
+   fprintf(f, "\n");
+
    dd_dump_call(f, &record->draw_state.base, &record->call);
 
    if (record->log_page) {
       fprintf(f,"\n\n**************************************************"
                 "***************************\n");
       fprintf(f, "Context Log:\n\n");
       u_log_page_print(record->log_page, f);
    }
 }
 
@@ -1006,20 +1011,22 @@ dd_context_flush(struct pipe_context *_pipe,
    pipe->flush(pipe, fence, flags);
 }
 
 static void
 dd_before_draw(struct dd_context *dctx, struct dd_draw_record *record)
 {
    struct dd_screen *dscreen = dd_screen(dctx->base.screen);
    struct pipe_context *pipe = dctx->pipe;
    struct pipe_screen *screen = dscreen->screen;
 
+   record->time_before = os_time_get_nano();
+
    if (dscreen->timeout_ms > 0) {
       if (dscreen->flush_always && dctx->num_draw_calls >= dscreen->skip_count) {
          pipe->flush(pipe, &record->prev_bottom_of_pipe, 0);
          screen->fence_reference(screen, &record->top_of_pipe, record->prev_bottom_of_pipe);
       } else {
          pipe->flush(pipe, &record->prev_bottom_of_pipe,
                      PIPE_FLUSH_DEFERRED | PIPE_FLUSH_BOTTOM_OF_PIPE);
          pipe->flush(pipe, &record->top_of_pipe,
                      PIPE_FLUSH_DEFERRED | PIPE_FLUSH_TOP_OF_PIPE);
       }
@@ -1033,20 +1040,21 @@ dd_before_draw(struct dd_context *dctx, struct dd_draw_record *record)
 }
 
 static void
 dd_after_draw_async(void *data)
 {
    struct dd_draw_record *record = (struct dd_draw_record *)data;
    struct dd_context *dctx = record->dctx;
    struct dd_screen *dscreen = dd_screen(dctx->base.screen);
 
    record->log_page = u_log_new_page(&dctx->log);
+   record->time_after = os_time_get_nano();
 
    if (!util_queue_fence_is_signalled(&record->driver_finished))
       util_queue_fence_signal(&record->driver_finished);
 
    if (dscreen->dump_mode == DD_DUMP_APITRACE_CALL &&
        dscreen->apitrace_dump_call > dctx->draw_state.apitrace_call_number) {
       dd_thread_join(dctx);
       /* No need to continue. */
       exit(0);
    }
diff --git a/src/gallium/drivers/ddebug/dd_pipe.h b/src/gallium/drivers/ddebug/dd_pipe.h
index d1965be9a14..607ebbb2b96 100644
--- a/src/gallium/drivers/ddebug/dd_pipe.h
+++ b/src/gallium/drivers/ddebug/dd_pipe.h
@@ -217,20 +217,22 @@ struct dd_draw_state_copy
    struct dd_state velems;
    struct dd_state rs;
    struct dd_state dsa;
    struct dd_state blend;
 };
 
 struct dd_draw_record {
    struct list_head list;
    struct dd_context *dctx;
 
+   int64_t time_before;
+   int64_t time_after;
    unsigned draw_call;
 
    struct pipe_fence_handle *prev_bottom_of_pipe;
    struct pipe_fence_handle *top_of_pipe;
    struct pipe_fence_handle *bottom_of_pipe;
 
    struct dd_call call;
    struct dd_draw_state_copy draw_state;
 
    struct util_queue_fence driver_finished;
-- 
2.11.0



More information about the mesa-dev mailing list