[Mesa-dev] [PATCH 6/7] gallium/hud: create files after graphs are created to get final names
Marek Olšák
maraeo at gmail.com
Thu Feb 16 12:52:35 UTC 2017
From: Marek Olšák <marek.olsak at amd.com>
---
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
@@ -932,33 +932,46 @@ static void
hud_graph_destroy(struct hud_graph *graph)
{
FREE(graph->vertices);
if (graph->free_query_data)
graph->free_query_data(graph->query_data);
if (graph->fd)
fclose(graph->fd);
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
const char *hud_dump_dir = getenv("GALLIUM_HUD_DUMP_DIR");
char *dump_file;
if (hud_dump_dir && access(hud_dump_dir, W_OK) == 0) {
dump_file = malloc(strlen(hud_dump_dir) + sizeof("/") + sizeof(gr->name));
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);
}
}
#endif
}
/**
* Read a string from the environment variable.
* The separators "+", ",", ":", and ";" terminate the string.
@@ -1369,20 +1382,28 @@ hud_parse_env_var(struct hud_context *hud, const char *env)
}
if (pane) {
if (pane->num_graphs) {
LIST_ADDTAIL(&pane->head, &hud->pane_list);
}
else {
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
print_help(struct pipe_screen *screen)
{
int i, num_queries, num_cpus = hud_get_num_cpus();
puts("Syntax: GALLIUM_HUD=name1[+name2][...][:value1][,nameI...][;nameJ...]");
puts("");
puts(" Names are identifiers of data sources which will be drawn as graphs");
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
@@ -207,22 +207,20 @@ hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index)
gr->query_new_value = query_cpu_load;
/* Don't use free() as our callback as that messes up Gallium's
* memory debugger. Use simple free_query_data() wrapper.
*/
gr->free_query_data = free_query_data;
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);
}
int
hud_get_num_cpus(void)
{
uint64_t busy, total;
int i = 0;
@@ -278,15 +276,13 @@ hud_api_thread_busy_install(struct hud_pane *pane)
return;
}
gr->query_new_value = query_api_thread_busy_status;
/* Don't use free() as our callback as that messes up Gallium's
* memory debugger. Use simple free_query_data() wrapper.
*/
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
@@ -387,22 +387,20 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq,
if (flags & PIPE_DRIVER_QUERY_FLAG_BATCH) {
if (!batch_query_add(pbq, pipe, query_type, &info->result_index))
goto fail_info;
info->batch = *pbq;
} else {
gr->begin_query = begin_query;
info->query_type = query_type;
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 */
if (pane->max_value < max_value)
hud_pane_set_max_value(pane, max_value);
return;
fail_info:
FREE(info);
fail_gr:
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
@@ -81,14 +81,12 @@ hud_fps_graph_install(struct hud_pane *pane)
return;
}
gr->query_new_value = query_fps;
/* Don't use free() as our callback as that messes up Gallium's
* memory debugger. Use simple free_query_data() wrapper.
*/
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
@@ -102,22 +102,20 @@ void hud_pipe_query_install(struct hud_batch_query_context **pbq,
enum pipe_driver_query_type type,
enum pipe_driver_query_result_type result_type,
unsigned flags);
boolean hud_driver_query_install(struct hud_batch_query_context **pbq,
struct hud_pane *pane,
struct pipe_context *pipe, const char *name);
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
#define NIC_DIRECTION_TX 2
#define NIC_RSSI_DBM 3
void hud_nic_graph_install(struct hud_pane *pane, const char *nic_index,
unsigned int mode);
int hud_get_num_disks(bool displayhelp);
#define DISKSTAT_RD 1
--
2.7.4
More information about the mesa-dev
mailing list