From 50b223547814cefc0e7130e199fabc4dbedf97ce Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Thu, 30 Jun 2016 00:40:01 +0200 Subject: ddebug: record and dump apitrace call numbers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Reviewed-by: Bas Nieuwenhuizen Reviewed-by: Nicolai Hähnle --- 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(-) (limited to 'src/gallium/drivers/ddebug') diff --git a/src/gallium/drivers/ddebug/dd_context.c b/src/gallium/drivers/ddebug/dd_context.c index 5fe423b1778..98475b9fe99 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 f0c88879643..22337e02a87 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 c9bbd569abe..f94303de7e1 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 093bdff4a92..3649644d28e 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 */ -- cgit v1.2.3