[Mesa-dev] [PATCH 2/2] gallium/hud: add PIPE_DRIVER_QUERY_TYPE_MICROSECONDS for HUD

Marek Olšák maraeo at gmail.com
Tue Jul 7 11:34:12 PDT 2015


For the series:

Reviewed-by: Marek Olšák <marek.olsak at amd.com>

Marek

On Tue, Jul 7, 2015 at 5:37 PM, Brian Paul <brianp at vmware.com> wrote:
> This allows drivers to report queries in units of microseconds and
> have the HUD display "us" (microseconds), "ms" (milliseconds) or "s"
> (seconds) on the graph.
> ---
>  src/gallium/auxiliary/hud/hud_context.c | 25 ++++++++++++++++++++-----
>  src/gallium/include/pipe/p_defines.h    | 11 ++++++-----
>  2 files changed, 26 insertions(+), 10 deletions(-)
>
> diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
> index 9f42da9..cb55220 100644
> --- a/src/gallium/auxiliary/hud/hud_context.c
> +++ b/src/gallium/auxiliary/hud/hud_context.c
> @@ -238,8 +238,9 @@ number_to_human_readable(uint64_t num, enum pipe_driver_query_type type,
>        {"", " KB", " MB", " GB", " TB", " PB", " EB"};
>     static const char *metric_units[] =
>        {"", " k", " M", " G", " T", " P", " E"};
> -   const char **units =
> -      (type == PIPE_DRIVER_QUERY_TYPE_BYTES) ? byte_units : metric_units;
> +   static const char *time_units[] =
> +      {" us", " ms", " s"};  /* based on microseconds */
> +   const char *suffix;
>     double divisor = (type == PIPE_DRIVER_QUERY_TYPE_BYTES) ? 1024 : 1000;
>     int unit = 0;
>     double d = num;
> @@ -249,12 +250,26 @@ number_to_human_readable(uint64_t num, enum pipe_driver_query_type type,
>        unit++;
>     }
>
> +   switch (type) {
> +   case PIPE_DRIVER_QUERY_TYPE_MICROSECONDS:
> +      assert(unit < ARRAY_SIZE(time_units));
> +      suffix = time_units[unit];
> +      break;
> +   case PIPE_DRIVER_QUERY_TYPE_BYTES:
> +      assert(unit < ARRAY_SIZE(byte_units));
> +      suffix = byte_units[unit];
> +      break;
> +   default:
> +      assert(unit < ARRAY_SIZE(metric_units));
> +      suffix = metric_units[unit];
> +   }
> +
>     if (d >= 100 || d == (int)d)
> -      sprintf(out, "%.0f%s", d, units[unit]);
> +      sprintf(out, "%.0f%s", d, suffix);
>     else if (d >= 10 || d*10 == (int)(d*10))
> -      sprintf(out, "%.1f%s", d, units[unit]);
> +      sprintf(out, "%.1f%s", d, suffix);
>     else
> -      sprintf(out, "%.2f%s", d, units[unit]);
> +      sprintf(out, "%.2f%s", d, suffix);
>  }
>
>  static void
> diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
> index 153897a..b0cd23d 100644
> --- a/src/gallium/include/pipe/p_defines.h
> +++ b/src/gallium/include/pipe/p_defines.h
> @@ -788,11 +788,12 @@ union pipe_color_union
>
>  enum pipe_driver_query_type
>  {
> -   PIPE_DRIVER_QUERY_TYPE_UINT64     = 0,
> -   PIPE_DRIVER_QUERY_TYPE_UINT       = 1,
> -   PIPE_DRIVER_QUERY_TYPE_FLOAT      = 2,
> -   PIPE_DRIVER_QUERY_TYPE_PERCENTAGE = 3,
> -   PIPE_DRIVER_QUERY_TYPE_BYTES      = 4,
> +   PIPE_DRIVER_QUERY_TYPE_UINT64       = 0,
> +   PIPE_DRIVER_QUERY_TYPE_UINT         = 1,
> +   PIPE_DRIVER_QUERY_TYPE_FLOAT        = 2,
> +   PIPE_DRIVER_QUERY_TYPE_PERCENTAGE   = 3,
> +   PIPE_DRIVER_QUERY_TYPE_BYTES        = 4,
> +   PIPE_DRIVER_QUERY_TYPE_MICROSECONDS = 5,
>  };
>
>  enum pipe_driver_query_group_type
> --
> 1.9.1
>
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list