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);
}
puts("");
puts(" Available names:");
puts(" fps");
+ puts(" frametime");
puts(" cpu");
for (i = 0; i < num_cpus; i++)
#include "util/u_memory.h"
struct fps_info {
+ boolean frametime;
int frames;
uint64_t last_time;
};
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;
FREE(gr);
return;
}
+ struct fps_info *info = gr->query_data;
+ info->frametime = false;
gr->query_new_value = query_fps;
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);
+}
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,