<div dir="ltr"><div>Pushed, thanks!</div><div><br></div><div>Marek<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 15, 2018 at 5:09 PM, Matthias Groß <span dir="ltr"><<a href="mailto:grmat@sub.red" target="_blank">grmat@sub.red</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Thanks for your comment. This version has an additional boolean in the<br>
fps_info struct to distinguish between fps and frame time calculation.<br>
The struct is initialised in the respecting install functions for this<br>
purpose.<br>
---<br>
src/gallium/auxiliary/hud/hud_<wbr>context.c | 4 +++<br>
src/gallium/auxiliary/hud/hud_<wbr>fps.c | 34 ++++++++++++++++++++++++-<br>
src/gallium/auxiliary/hud/hud_<wbr>private.h | 1 +<br>
3 files changed, 38 insertions(+), 1 deletion(-)<br>
<br>
diff --git a/src/gallium/auxiliary/hud/<wbr>hud_context.c b/src/gallium/auxiliary/hud/<wbr>hud_context.c<br>
index 6ed9ccffdb..61db98b4b0 100644<br>
--- a/src/gallium/auxiliary/hud/<wbr>hud_context.c<br>
+++ b/src/gallium/auxiliary/hud/<wbr>hud_context.c<br>
@@ -1247,6 +1247,9 @@ hud_parse_env_var(struct hud_context *hud, struct pipe_screen *screen,<br>
if (strcmp(name, "fps") == 0) {<br>
hud_fps_graph_install(pane);<br>
}<br>
+ else if (strcmp(name, "frametime") == 0) {<br>
+ hud_frametime_graph_install(<wbr>pane);<br>
+ }<br>
else if (strcmp(name, "cpu") == 0) {<br>
hud_cpu_graph_install(pane, ALL_CPUS);<br>
}<br>
@@ -1557,6 +1560,7 @@ print_help(struct pipe_screen *screen)<br>
puts("");<br>
puts(" Available names:");<br>
puts(" fps");<br>
+ puts(" frametime");<br>
puts(" cpu");<br>
<br>
for (i = 0; i < num_cpus; i++)<br>
diff --git a/src/gallium/auxiliary/hud/<wbr>hud_fps.c b/src/gallium/auxiliary/hud/<wbr>hud_fps.c<br>
index c8438d0f5e..29110f5575 100644<br>
--- a/src/gallium/auxiliary/hud/<wbr>hud_fps.c<br>
+++ b/src/gallium/auxiliary/hud/<wbr>hud_fps.c<br>
@@ -33,6 +33,7 @@<br>
#include "util/u_memory.h"<br>
<br>
struct fps_info {<br>
+ boolean frametime;<br>
int frames;<br>
uint64_t last_time;<br>
};<br>
@@ -46,7 +47,12 @@ query_fps(struct hud_graph *gr, struct pipe_context *pipe)<br>
info->frames++;<br>
<br>
if (info->last_time) {<br>
- if (info->last_time + gr->pane->period <= now) {<br>
+ if (info->frametime) {<br>
+ double frametime = ((double)now - (double)info->last_time) / 1000.0;<br>
+ hud_graph_add_value(gr, frametime);<br>
+ info->last_time = now;<br>
+ }<br>
+ else if (info->last_time + gr->pane->period <= now) {<br>
double fps = ((uint64_t)info->frames) * 1000000 /<br>
(double)(now - info->last_time);<br>
info->frames = 0;<br>
@@ -80,6 +86,8 @@ hud_fps_graph_install(struct hud_pane *pane)<br>
FREE(gr);<br>
return;<br>
}<br>
+ struct fps_info *info = gr->query_data;<br>
+ info->frametime = false;<br>
<br>
gr->query_new_value = query_fps;<br>
<br>
@@ -90,3 +98,27 @@ hud_fps_graph_install(struct hud_pane *pane)<br>
<br>
hud_pane_add_graph(pane, gr);<br>
}<br>
+<br>
+void<br>
+hud_frametime_graph_install(<wbr>struct hud_pane *pane)<br>
+{<br>
+ struct hud_graph *gr = CALLOC_STRUCT(hud_graph);<br>
+<br>
+ if (!gr)<br>
+ return;<br>
+<br>
+ strcpy(gr->name, "frametime (ms)");<br>
+ gr->query_data = CALLOC_STRUCT(fps_info);<br>
+ if (!gr->query_data) {<br>
+ FREE(gr);<br>
+ return;<br>
+ }<br>
+ struct fps_info *info = gr->query_data;<br>
+ info->frametime = true;<br>
+<br>
+ gr->query_new_value = query_fps;<br>
+<br>
+ gr->free_query_data = free_query_data;<br>
+<br>
+ hud_pane_add_graph(pane, gr);<br>
+}<br>
diff --git a/src/gallium/auxiliary/hud/<wbr>hud_private.h b/src/gallium/auxiliary/hud/<wbr>hud_private.h<br>
index b64e29e93e..deed329a8a 100644<br>
--- a/src/gallium/auxiliary/hud/<wbr>hud_private.h<br>
+++ b/src/gallium/auxiliary/hud/<wbr>hud_private.h<br>
@@ -157,6 +157,7 @@ struct hud_batch_query_context;<br>
int hud_get_num_cpus(void);<br>
<br>
void hud_fps_graph_install(struct hud_pane *pane);<br>
+void hud_frametime_graph_install(<wbr>struct hud_pane *pane);<br>
void hud_cpu_graph_install(struct hud_pane *pane, unsigned cpu_index);<br>
void hud_thread_busy_install(struct hud_pane *pane, const char *name, bool main);<br>
void hud_thread_counter_install(<wbr>struct hud_pane *pane, const char *name,<br>
<span class="HOEnZb"><font color="#888888">-- <br>
2.17.0<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>