[Mesa-dev] [PATCH 1/1] gallium/hud: use double values for all graphs

Marek Olšák maraeo at gmail.com
Mon Jun 19 19:38:13 UTC 2017


On Sat, Jun 17, 2017 at 4:57 PM, Christoph Haag
<haagch+mesadev at frickel.club> wrote:
> This specifically helps the fps graph. It calculates the fps like this:
>     (uint64_t)info->frames * 1000000 / (double)(now - info->last_time);
> The timings when query_new_value() are called will vary, so fps values of
> e.g. 59.9 fps will be truncated to 59 fps.
>
> Rounding the value before casting to integer improves the fps graph, but
> it may be useful to inspect fps variations more closely by increasing the
> width and height of the graphs.
>
> Signed-off-by: Christoph Haag <haagch+mesadev at frickel.club>
> ---
>  src/gallium/auxiliary/hud/hud_context.c | 6 +++---
>  src/gallium/auxiliary/hud/hud_fps.c     | 4 ++--
>  src/gallium/auxiliary/hud/hud_private.h | 4 ++--
>  3 files changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
> index cb7ed44659..22968aef10 100644
> --- a/src/gallium/auxiliary/hud/hud_context.c
> +++ b/src/gallium/auxiliary/hud/hud_context.c
> @@ -250,7 +250,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[] =
> @@ -905,13 +905,13 @@ 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);
> +      fprintf(gr->fd, "%f\n", value);
>
>     if (gr->index == gr->pane->max_num_vertices) {
>        gr->vertices[0] = 0;
> diff --git a/src/gallium/auxiliary/hud/hud_fps.c b/src/gallium/auxiliary/hud/hud_fps.c
> index a360bc2ed0..8aa7a665a3 100644
> --- a/src/gallium/auxiliary/hud/hud_fps.c
> +++ b/src/gallium/auxiliary/hud/hud_fps.c
> @@ -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 /

The added parentheses are unnecessary.

The patch is OK with me.

Marek


More information about the mesa-dev mailing list