gallium/hud: use double values for all graphs
The fps graph for example calculates the fps as double with small variations based on when query_new_value() is called, which causes many values to be truncated on the cast to uint64_t. The HUD internally stores the values as double, so just use double everywhere instead of fixing this with rounding. Using doubles also allows the hud to show small variations instead of being clamped to discrete values. v2: Don't print decimals in the dump file when not necessary Signed-off-by: Christoph Haag <haagch+mesadev@frickel.club> Signed-off-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
committed by
Marek Olšák
parent
7e426ef6ec
commit
98514e9959
@@ -204,7 +204,7 @@ hud_draw_string(struct hud_context *hud, unsigned x, unsigned y,
|
||||
}
|
||||
|
||||
static void
|
||||
number_to_human_readable(uint64_t num, enum pipe_driver_query_type type,
|
||||
number_to_human_readable(double num, enum pipe_driver_query_type type,
|
||||
char *out)
|
||||
{
|
||||
static const char *byte_units[] =
|
||||
@@ -861,13 +861,19 @@ hud_pane_add_graph(struct hud_pane *pane, struct hud_graph *gr)
|
||||
}
|
||||
|
||||
void
|
||||
hud_graph_add_value(struct hud_graph *gr, uint64_t value)
|
||||
hud_graph_add_value(struct hud_graph *gr, double value)
|
||||
{
|
||||
gr->current_value = value;
|
||||
value = value > gr->pane->ceiling ? gr->pane->ceiling : value;
|
||||
|
||||
if (gr->fd)
|
||||
fprintf(gr->fd, "%" PRIu64 "\n", value);
|
||||
if (gr->fd) {
|
||||
if (fabs(value - lround(value)) > FLT_EPSILON) {
|
||||
fprintf(gr->fd, "%f\n", value);
|
||||
}
|
||||
else {
|
||||
fprintf(gr->fd, "%" PRIu64 "\n", (uint64_t) lround(value));
|
||||
}
|
||||
}
|
||||
|
||||
if (gr->index == gr->pane->max_num_vertices) {
|
||||
gr->vertices[0] = 0;
|
||||
|
||||
@@ -47,12 +47,12 @@ query_fps(struct hud_graph *gr)
|
||||
|
||||
if (info->last_time) {
|
||||
if (info->last_time + gr->pane->period <= now) {
|
||||
double fps = (uint64_t)info->frames * 1000000 /
|
||||
double fps = ((uint64_t)info->frames) * 1000000 /
|
||||
(double)(now - info->last_time);
|
||||
info->frames = 0;
|
||||
info->last_time = now;
|
||||
|
||||
hud_graph_add_value(gr, (uint64_t) fps);
|
||||
hud_graph_add_value(gr, fps);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -104,7 +104,7 @@ struct hud_graph {
|
||||
/* mutable variables */
|
||||
unsigned num_vertices;
|
||||
unsigned index; /* vertex index being updated */
|
||||
uint64_t current_value;
|
||||
double current_value;
|
||||
FILE *fd;
|
||||
};
|
||||
|
||||
@@ -139,7 +139,7 @@ struct hud_pane {
|
||||
/* core */
|
||||
void hud_pane_add_graph(struct hud_pane *pane, struct hud_graph *gr);
|
||||
void hud_pane_set_max_value(struct hud_pane *pane, uint64_t value);
|
||||
void hud_graph_add_value(struct hud_graph *gr, uint64_t value);
|
||||
void hud_graph_add_value(struct hud_graph *gr, double value);
|
||||
|
||||
/* graphs/queries */
|
||||
struct hud_batch_query_context;
|
||||
|
||||
Reference in New Issue
Block a user