mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 02:10:11 +01:00
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>
This commit is contained in:
parent
f3521ce2c4
commit
71892fbe19
3 changed files with 38 additions and 1 deletions
|
|
@ -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++)
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue