[Mesa-dev] [PATCH 2/6] ddebug: record and dump apitrace call numbers

Marek Olšák maraeo at gmail.com
Thu Jun 30 23:21:48 UTC 2016


From: Marek Olšák <marek.olsak at amd.com>

---
 src/gallium/drivers/ddebug/dd_context.c |  4 +++-
 src/gallium/drivers/ddebug/dd_draw.c    |  4 ++++
 src/gallium/drivers/ddebug/dd_pipe.h    |  1 +
 src/gallium/drivers/ddebug/dd_util.h    | 23 +++++++++++++++++++++++
 4 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/ddebug/dd_context.c b/src/gallium/drivers/ddebug/dd_context.c
index 5fe423b..98475b9 100644
--- a/src/gallium/drivers/ddebug/dd_context.c
+++ b/src/gallium/drivers/ddebug/dd_context.c
@@ -665,9 +665,11 @@ static void
 dd_context_emit_string_marker(struct pipe_context *_pipe,
                               const char *string, int len)
 {
-   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+   struct dd_context *dctx = dd_context(_pipe);
+   struct pipe_context *pipe = dctx->pipe;
 
    pipe->emit_string_marker(pipe, string, len);
+   dd_parse_apitrace_marker(string, len, &dctx->apitrace_call_number);
 }
 
 static void
diff --git a/src/gallium/drivers/ddebug/dd_draw.c b/src/gallium/drivers/ddebug/dd_draw.c
index f0c8887..22337e0 100644
--- a/src/gallium/drivers/ddebug/dd_draw.c
+++ b/src/gallium/drivers/ddebug/dd_draw.c
@@ -99,6 +99,10 @@ dd_get_file_stream(struct dd_context *dctx)
    fprintf(f, "Driver vendor: %s\n", screen->get_vendor(screen));
    fprintf(f, "Device vendor: %s\n", screen->get_device_vendor(screen));
    fprintf(f, "Device name: %s\n\n", screen->get_name(screen));
+
+   if (dctx->apitrace_call_number)
+      fprintf(f, "Last apitrace call: %u\n\n",
+              dctx->apitrace_call_number);
    return f;
 }
 
diff --git a/src/gallium/drivers/ddebug/dd_pipe.h b/src/gallium/drivers/ddebug/dd_pipe.h
index c9bbd56..f94303d 100644
--- a/src/gallium/drivers/ddebug/dd_pipe.h
+++ b/src/gallium/drivers/ddebug/dd_pipe.h
@@ -114,6 +114,7 @@ struct dd_context
    float tess_default_levels[6];
 
    unsigned num_draw_calls;
+   unsigned apitrace_call_number;
 };
 
 
diff --git a/src/gallium/drivers/ddebug/dd_util.h b/src/gallium/drivers/ddebug/dd_util.h
index 093bdff..3649644 100644
--- a/src/gallium/drivers/ddebug/dd_util.h
+++ b/src/gallium/drivers/ddebug/dd_util.h
@@ -71,4 +71,27 @@ dd_get_debug_file(bool verbose)
    return f;
 }
 
+static inline void
+dd_parse_apitrace_marker(const char *string, int len, unsigned *call_number)
+{
+   unsigned num;
+   char *s;
+
+   if (len <= 0)
+      return;
+
+   /* Make it zero-terminated. */
+   s = alloca(len + 1);
+   memcpy(s, string, len);
+   s[len] = 0;
+
+   /* Parse the number. */
+   errno = 0;
+   num = strtol(s, NULL, 10);
+   if (errno)
+      return;
+
+   *call_number = num;
+}
+
 #endif /* DD_UTIL_H */
-- 
2.7.4



More information about the mesa-dev mailing list