Mesa (master): gallium/hud: dump hud_driver_query values to files

Marek Olšák mareko at kemper.freedesktop.org
Sat Dec 31 23:30:14 UTC 2016


Module: Mesa
Branch: master
Commit: 22cd9040da75cac6e1c61b821e1ac6906ac4a8ac
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=22cd9040da75cac6e1c61b821e1ac6906ac4a8ac

Author: Edmondo Tommasina <edmondo.tommasina at gmail.com>
Date:   Wed Dec 21 22:58:09 2016 +0100

gallium/hud: dump hud_driver_query values to files

Dump values for every selected data source in GALLIUM_HUD.

Every data source has its own file and the filename is
equal to the data source identifier.

Set GALLIUM_HUD_DUMP_DIR to dump values to files in this directory.

No values are dumped if the environment variable is not set, the
directory doesn't exist or the user doesn't have write access.

Signed-off-by: Marek Olšák <marek.olsak at amd.com>

---

 src/gallium/auxiliary/hud/hud_context.c      |  6 ++++++
 src/gallium/auxiliary/hud/hud_driver_query.c | 12 ++++++++++++
 src/gallium/auxiliary/hud/hud_private.h      |  1 +
 3 files changed, 19 insertions(+)

diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index ceb157a..edd831a 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -33,6 +33,7 @@
  * Set GALLIUM_HUD=help for more info.
  */
 
+#include <inttypes.h>
 #include <signal.h>
 #include <stdio.h>
 
@@ -829,6 +830,9 @@ hud_graph_add_value(struct hud_graph *gr, uint64_t value)
    gr->current_value = value;
    value = value > gr->pane->ceiling ? gr->pane->ceiling : value;
 
+   if (gr->fd)
+      fprintf(gr->fd, "%" PRIu64 "\n", value);
+
    if (gr->index == gr->pane->max_num_vertices) {
       gr->vertices[0] = 0;
       gr->vertices[1] = gr->vertices[(gr->index-1)*2+1];
@@ -856,6 +860,8 @@ 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);
 }
 
diff --git a/src/gallium/auxiliary/hud/hud_driver_query.c b/src/gallium/auxiliary/hud/hud_driver_query.c
index 40ea120..23fda01 100644
--- a/src/gallium/auxiliary/hud/hud_driver_query.c
+++ b/src/gallium/auxiliary/hud/hud_driver_query.c
@@ -351,6 +351,8 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq,
 {
    struct hud_graph *gr;
    struct query_info *info;
+   const char *hud_dump_dir = getenv("GALLIUM_HUD_DUMP_DIR");
+   char *dump_file;
 
    gr = CALLOC_STRUCT(hud_graph);
    if (!gr)
@@ -378,6 +380,16 @@ hud_pipe_query_install(struct hud_batch_query_context **pbq,
       info->result_index = result_index;
    }
 
+   if (hud_dump_dir && access(hud_dump_dir, W_OK) == 0) {
+      dump_file = malloc(strlen(hud_dump_dir) + sizeof(gr->name));
+      if (dump_file) {
+         strcpy(dump_file, hud_dump_dir);
+         strcat(dump_file, gr->name);
+         gr->fd = fopen(dump_file, "w+");
+         free(dump_file);
+      }
+   }
+
    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_private.h b/src/gallium/auxiliary/hud/hud_private.h
index c6d0dbf..fa1cd8b 100644
--- a/src/gallium/auxiliary/hud/hud_private.h
+++ b/src/gallium/auxiliary/hud/hud_private.h
@@ -48,6 +48,7 @@ struct hud_graph {
    unsigned num_vertices;
    unsigned index; /* vertex index being updated */
    uint64_t current_value;
+   FILE *fd;
 };
 
 struct hud_pane {




More information about the mesa-commit mailing list