aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/hud/hud_fps.c
diff options
context:
space:
mode:
authorMatthias Groß <[email protected]>2018-05-15 23:09:05 +0200
committerMarek Olšák <[email protected]>2018-05-15 19:30:12 -0400
commit71892fbe194d543fbed88ee0c68c2402f6e47a65 (patch)
tree8cb4d6f680d95d8d367370888f1f6b1fc6748b4d /src/gallium/auxiliary/hud/hud_fps.c
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 <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary/hud/hud_fps.c')
-rw-r--r--src/gallium/auxiliary/hud/hud_fps.c34
1 files changed, 33 insertions, 1 deletions
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);
+}