From c8d84801b76aa0bfb04f5adcfb83335ee54b01e6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Marek=20Ol=C5=A1=C3=A1k?= Date: Thu, 16 Feb 2017 13:29:16 +0100 Subject: [PATCH] gallium/hud: create files after graphs are created to get final names MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Reviewed-by: Nicolai Hähnle Reviewed-by: Edmondo Tommasina --- src/gallium/auxiliary/hud/hud_context.c | 25 +++++++++++++++++++++++-- src/gallium/auxiliary/hud/hud_cpu.c | 4 ---- src/gallium/auxiliary/hud/hud_driver_query.c | 2 -- src/gallium/auxiliary/hud/hud_fps.c | 2 -- src/gallium/auxiliary/hud/hud_private.h | 2 -- 5 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c index 9de260c..aaa52d5 100644 --- a/src/gallium/auxiliary/hud/hud_context.c +++ b/src/gallium/auxiliary/hud/hud_context.c @@ -939,7 +939,20 @@ hud_graph_destroy(struct hud_graph *graph) FREE(graph); } -void +static void strcat_without_spaces(char *dst, const char *src) +{ + dst += strlen(dst); + while (*src) { + if (*src == ' ') + *dst++ = '_'; + else + *dst++ = *src; + src++; + } + *dst = 0; +} + +static void hud_graph_set_dump_file(struct hud_graph *gr) { #ifndef PIPE_OS_WINDOWS @@ -951,7 +964,7 @@ hud_graph_set_dump_file(struct hud_graph *gr) if (dump_file) { strcpy(dump_file, hud_dump_dir); strcat(dump_file, "/"); - strcat(dump_file, gr->name); + strcat_without_spaces(dump_file, gr->name); gr->fd = fopen(dump_file, "w+"); free(dump_file); } @@ -1376,6 +1389,14 @@ hud_parse_env_var(struct hud_context *hud, const char *env) FREE(pane); } } + + LIST_FOR_EACH_ENTRY(pane, &hud->pane_list, head) { + struct hud_graph *gr; + + LIST_FOR_EACH_ENTRY(gr, &pane->graph_list, head) { + hud_graph_set_dump_file(gr); + } + } } static void diff --git a/src/gallium/auxiliary/hud/hud_cpu.c b/src/gallium/auxiliary/hud/hud_cpu.c index a8d97b8..1cba353 100644 --- a/src/gallium/auxiliary/hud/hud_cpu.c +++ b/src/gallium/auxiliary/hud/hud_cpu.c @@ -214,8 +214,6 @@ hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index) info = gr->query_data; info->cpu_index = cpu_index; - hud_graph_set_dump_file(gr); - hud_pane_add_graph(pane, gr); hud_pane_set_max_value(pane, 100); } @@ -285,8 +283,6 @@ hud_api_thread_busy_install(struct hud_pane *pane) */ gr->free_query_data = free_query_data; - hud_graph_set_dump_file(gr); - hud_pane_add_graph(pane, gr); hud_pane_set_max_value(pane, 100); } diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c b/src/gallium/auxiliary/hud/hud_driver_query.c index 6a97dbd..76104b5 100644 --- a/src/gallium/auxiliary/hud/hud_driver_query.c +++ b/src/gallium/auxiliary/hud/hud_driver_query.c @@ -394,8 +394,6 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq, info->result_index = result_index; } - hud_graph_set_dump_file(gr); - hud_pane_add_graph(pane, gr); pane->type = type; /* must be set before updating the max_value */ diff --git a/src/gallium/auxiliary/hud/hud_fps.c b/src/gallium/auxiliary/hud/hud_fps.c index ddf30e4..a360bc2 100644 --- a/src/gallium/auxiliary/hud/hud_fps.c +++ b/src/gallium/auxiliary/hud/hud_fps.c @@ -88,7 +88,5 @@ hud_fps_graph_install(struct hud_pane *pane) */ gr->free_query_data = free_query_data; - hud_graph_set_dump_file(gr); - hud_pane_add_graph(pane, gr); } diff --git a/src/gallium/auxiliary/hud/hud_private.h b/src/gallium/auxiliary/hud/hud_private.h index 1d06e03..bbc5ec7 100644 --- a/src/gallium/auxiliary/hud/hud_private.h +++ b/src/gallium/auxiliary/hud/hud_private.h @@ -109,8 +109,6 @@ void hud_batch_query_begin(struct hud_batch_query_context *bq); void hud_batch_query_update(struct hud_batch_query_context *bq); void hud_batch_query_cleanup(struct hud_batch_query_context **pbq); -void hud_graph_set_dump_file(struct hud_graph *gr); - #if HAVE_GALLIUM_EXTRA_HUD int hud_get_num_nics(bool displayhelp); #define NIC_DIRECTION_RX 1 -- 2.7.4