ddebug: record and dump apitrace call numbers
authorMarek Olšák <marek.olsak@amd.com>
Wed, 29 Jun 2016 22:40:01 +0000 (00:40 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 4 Jul 2016 22:47:12 +0000 (00:47 +0200)
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/ddebug/dd_context.c
src/gallium/drivers/ddebug/dd_draw.c
src/gallium/drivers/ddebug/dd_pipe.h
src/gallium/drivers/ddebug/dd_util.h

index 5fe423b1778cb8462571a61d86b85513b5c2c03b..98475b9fe99060436aa32c27a51c4869d5e63444 100644 (file)
@@ -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
index f0c8887964308134ac9a56a2122e29d7cbe084ac..22337e02a87df2ab128c5a4bd262dc7dce9d9cc4 100644 (file)
@@ -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;
 }
 
index c9bbd569abe97d78aad8ab7765ab8067d9e66dbf..f94303de7e13fbae7a97cc4ce888bfcfa3ef937d 100644 (file)
@@ -114,6 +114,7 @@ struct dd_context
    float tess_default_levels[6];
 
    unsigned num_draw_calls;
+   unsigned apitrace_call_number;
 };
 
 
index 093bdff4a92a8778b2cd7ec595cca83893511239..3649644d28e6574b47c1c4b62855292fb5843411 100644 (file)
@@ -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 */