gallium/hud: create files after graphs are created to get final names
authorMarek Olšák <marek.olsak@amd.com>
Thu, 16 Feb 2017 12:29:16 +0000 (13:29 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Sat, 18 Feb 2017 00:22:08 +0000 (01:22 +0100)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
src/gallium/auxiliary/hud/hud_context.c
src/gallium/auxiliary/hud/hud_cpu.c
src/gallium/auxiliary/hud/hud_driver_query.c
src/gallium/auxiliary/hud/hud_fps.c
src/gallium/auxiliary/hud/hud_private.h

index 9de260c6cbb0047689dd5bbb26ab2414d9e2614b..aaa52d5b173baf442b46d881af86127f956ab7fc 100644 (file)
@@ -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
index a8d97b81f356d43c2e69b8775924ab2c5b0654a9..1cba353603d9d2efa607b70809689394fec6da15 100644 (file)
@@ -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);
 }
index 6a97dbd88126f2f1fbe924f1b44d5bc627407221..76104b5b497a46387cd31c709dc9b6fb6578329d 100644 (file)
@@ -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 */
 
index ddf30e415d240540cec151a53adc1ba74be76713..a360bc2ed04613b3617800d57d530dc291e86217 100644 (file)
@@ -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);
 }
index 1d06e03dbe507dc772f58968956c3d045b0fd3e9..bbc5ec70c8a63f2dd8850e6d61a92fac03456c7f 100644 (file)
@@ -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