summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Groß <grmat@sub.red>2018-05-15 23:09:05 +0200
committerMarek Olšák <marek.olsak@amd.com>2018-05-15 19:30:12 -0400
commit71892fbe194d543fbed88ee0c68c2402f6e47a65 (patch)
tree8cb4d6f680d95d8d367370888f1f6b1fc6748b4d
parentf3521ce2c440bd50020a3ff81e6d9fa17c01009c (diff)
gallium/hud: add frametime graph (v2)
Thanks for your comment. This version has an additional boolean in the fps_info struct to distinguish between fps and frame time calculation. The struct is initialised in the respecting install functions for this purpose. Signed-off-by: Marek Olšák <marek.olsak@amd.com>
-rw-r--r--src/gallium/auxiliary/hud/hud_context.c4
-rw-r--r--src/gallium/auxiliary/hud/hud_fps.c34
-rw-r--r--src/gallium/auxiliary/hud/hud_private.h1
3 files changed, 38 insertions, 1 deletions
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index 6ed9ccffdbc..61db98b4b03 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -1247,6 +1247,9 @@ hud_parse_env_var(struct hud_context *hud, struct pipe_screen *screen,
if (strcmp(name, "fps") == 0) {
hud_fps_graph_install(pane);
}
+ else if (strcmp(name, "frametime") == 0) {
+ hud_frametime_graph_install(pane);
+ }
else if (strcmp(name, "cpu") == 0) {
hud_cpu_graph_install(pane, ALL_CPUS);
}
@@ -1557,6 +1560,7 @@ print_help(struct pipe_screen *screen)
puts("");
puts(" Available names:");
puts(" fps");
+ puts(" frametime");
puts(" cpu");
for (i = 0; i < num_cpus; i++)
diff --git a/src/gallium/auxiliary/hud/hud_fps.c b/src/gallium/auxiliary/hud/hud_fps.c
index c8438d0f5e3..29110f5575e 100644
--- a/src/gallium/auxiliary/hud/hud_fps.c
+++ b/src/gallium/auxiliary/hud/hud_fps.c
@@ -33,6 +33,7 @@
#include "util/u_memory.h"
struct fps_info {
+ boolean frametime;
int frames;
uint64_t last_time;
};
@@ -46,7 +47,12 @@ query_fps(struct hud_graph *gr, struct pipe_context *pipe)
info->frames++;
if (info->last_time) {
- if (info->last_time + gr->pane->period <= now) {
+ if (info->frametime) {
+ double frametime = ((double)now - (double)info->last_time) / 1000.0;
+ hud_graph_add_value(gr, frametime);
+ info->last_time = now;
+ }
+ else if (info->last_time + gr->pane->period <= now) {
double fps = ((uint64_t)info->frames) * 1000000 /
(double)(now - info->last_time);
info->frames = 0;
@@ -80,6 +86,8 @@ hud_fps_graph_install(struct hud_pane *pane)
FREE(gr);
return;
}
+ struct fps_info *info = gr->query_data;
+ info->frametime = false;
gr->query_new_value = query_fps;
@@ -90,3 +98,27 @@ hud_fps_graph_install(struct hud_pane *pane)
hud_pane_add_graph(pane, gr);
}
+
+void
+hud_frametime_graph_install(struct hud_pane *pane)
+{
+ struct hud_graph *gr = CALLOC_STRUCT(hud_graph);
+
+ if (!gr)
+ return;
+
+ strcpy(gr->name, "frametime (ms)");
+ gr->query_data = CALLOC_STRUCT(fps_info);
+ if (!gr->query_data) {
+ FREE(gr);
+ return;
+ }
+ struct fps_info *info = gr->query_data;
+ info->frametime = true;
+
+ gr->query_new_value = query_fps;
+
+ gr->free_query_data = free_query_data;
+
+ 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 b64e29e93e5..deed329a8af 100644
--- a/src/gallium/auxiliary/hud/hud_private.h
+++ b/src/gallium/auxiliary/hud/hud_private.h
@@ -157,6 +157,7 @@ struct hud_batch_query_context;
int hud_get_num_cpus(void);
void hud_fps_graph_install(struct hud_pane *pane);
+void hud_frametime_graph_install(struct hud_pane *pane);
void hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index);
void hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main);
void hud_thread_counter_install(struct hud_pane *pane, const char *name,