[Mesa-dev] gallium/hud: control visibility at startup and runtime.

Marek Olšák maraeo at gmail.com
Tue Nov 3 07:08:00 PST 2015


On Tue, Nov 3, 2015 at 11:43 AM, boombatower <jimmy at boombatower.com> wrote:
> - env GALLIUM_HUD_VISIBLE: control default visibility
> - env GALLIUM_HUD_SIGNAL_TOGGLE: toggle visibility via signal
> ---
>  docs/envvars.html                       |  6 ++++++
>  src/gallium/auxiliary/hud/hud_context.c | 23 +++++++++++++++++++++++
>  2 files changed, 29 insertions(+)
>
> diff --git a/docs/envvars.html b/docs/envvars.html
> index bdfe999..530bbb7 100644
> --- a/docs/envvars.html
> +++ b/docs/envvars.html
> @@ -179,6 +179,12 @@ Mesa EGL supports different sets of environment variables.  See the
>  <li>GALLIUM_HUD - draws various information on the screen, like framerate,
>      cpu load, driver statistics, performance counters, etc.
>      Set GALLIUM_HUD=help and run e.g. glxgears for more info.
> +<li>GALLIUM_HUD_VISIBLE - control default visibility, defaults to true.
> +<li>GALLIUM_HUD_TOGGLE_SIGNAL - toggle visibility via user specified signal.
> +    Especially useful to toggle hud at specific points of application and
> +    disable for unencumbered viewing the rest of the time. For example, set
> +    GALLIUM_HUD_VISIBLE to false and GALLIUM_HUD_SIGNAL_TOGGLE to 10 (SIGUSR1).
> +    Use kill -10 <pid> to toggle the hud as desired.
>  <li>GALLIUM_LOG_FILE - specifies a file for logging all errors, warnings, etc.
>      rather than stderr.
>  <li>GALLIUM_PRINT_OPTIONS - if non-zero, print all the Gallium environment
> diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
> index ffe30b8..f6bfa80 100644
> --- a/src/gallium/auxiliary/hud/hud_context.c
> +++ b/src/gallium/auxiliary/hud/hud_context.c
> @@ -33,6 +33,7 @@
>   * Set GALLIUM_HUD=help for more info.
>   */
>
> +#include <signal.h>
>  #include <stdio.h>
>
>  #include "hud/hud_context.h"
> @@ -51,8 +52,10 @@
>  #include "tgsi/tgsi_text.h"
>  #include "tgsi/tgsi_dump.h"
>
> +static boolean __visible_toggle = false;
>
>  struct hud_context {
> +   boolean visible;
>     struct pipe_context *pipe;
>     struct cso_context *cso;
>     struct u_upload_mgr *uploader;
> @@ -95,6 +98,11 @@ struct hud_context {
>     } text, bg, whitelines;
>  };
>
> +static void
> +signal_visible_handler(int signo)
> +{
> +   __visible_toggle = true;
> +}
>
>  static void
>  hud_draw_colored_prims(struct hud_context *hud, unsigned prim,
> @@ -431,8 +439,15 @@ hud_alloc_vertices(struct hud_context *hud, struct vertex_queue *v,
>  void
>  hud_draw(struct hud_context *hud, struct pipe_resource *tex)
>  {
> +   if (__visible_toggle) {
> +      hud->visible = !hud->visible;
> +      __visible_toggle = false;

Could we either
- not use global variables
or
- not modify global variables from any context functions.

There can be several contexts and therefore several HUDs per process.
This patch doesn't take that into account.

Marek


More information about the mesa-dev mailing list