Mesa (master): hud: add GALLIUM_HUD_SCALE

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Feb 24 23:05:39 UTC 2020


Module: Mesa
Branch: master
Commit: 31a781578522d44e6832893270a7902b001a827d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=31a781578522d44e6832893270a7902b001a827d

Author: Jonathan Marek <jonathan at marek.ca>
Date:   Mon Jan 20 21:16:13 2020 -0500

hud: add GALLIUM_HUD_SCALE

Scale hud by an integer factor, for high DPI displays.

Signed-off-by: Jonathan Marek <jonathan at marek.ca>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3931>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3931>

---

 docs/envvars.html                       |  2 ++
 src/gallium/auxiliary/hud/hud_context.c | 19 +++++++++++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/docs/envvars.html b/docs/envvars.html
index 7e2f4733ddd..df4377209eb 100644
--- a/docs/envvars.html
+++ b/docs/envvars.html
@@ -397,6 +397,8 @@ Mesa EGL supports different sets of environment variables.  See the
     <code>GALLIUM_HUD_TOGGLE_SIGNAL</code> to <code>10</code>
     (<code>SIGUSR1</code>).
     Use <code>kill -10 <pid></code> to toggle the hud as desired.</dd>
+<dt><code>GALLIUM_HUD_SCALE</code></dt>
+<dd>Scale hud by an integer factor, for high DPI displays. Default is 1.</dd>
 <dt><code>GALLIUM_HUD_DUMP_DIR</code></dt>
 <dd>specifies a directory for writing the displayed hud values into files.</dd>
 <dt><code>GALLIUM_DRIVER</code></dt>
diff --git a/src/gallium/auxiliary/hud/hud_context.c b/src/gallium/auxiliary/hud/hud_context.c
index 621ef948455..8e600797841 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -55,6 +55,7 @@
 
 /* Control the visibility of all HUD contexts */
 static boolean huds_visible = TRUE;
+static int hud_scale = 1;
 
 
 #ifdef PIPE_OS_UNIX
@@ -84,10 +85,10 @@ hud_draw_colored_prims(struct hud_context *hud, unsigned prim,
    hud->constants.color[1] = g;
    hud->constants.color[2] = b;
    hud->constants.color[3] = a;
-   hud->constants.translate[0] = (float) xoffset;
-   hud->constants.translate[1] = (float) yoffset;
-   hud->constants.scale[0] = 1;
-   hud->constants.scale[1] = yscale;
+   hud->constants.translate[0] = (float) (xoffset * hud_scale);
+   hud->constants.translate[1] = (float) (yoffset * hud_scale);
+   hud->constants.scale[0] = hud_scale;
+   hud->constants.scale[1] = yscale * hud_scale;
    cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
 
    cso_set_vertex_buffers(cso, 0, 1, &hud->color_prims.vbuf);
@@ -556,10 +557,11 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
       hud->constants.color[3] = 0.666f;
       hud->constants.translate[0] = 0;
       hud->constants.translate[1] = 0;
-      hud->constants.scale[0] = 1;
-      hud->constants.scale[1] = 1;
+      hud->constants.scale[0] = hud_scale;
+      hud->constants.scale[1] = hud_scale;
 
       cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
+
       cso_set_vertex_buffers(cso, 0, 1, &hud->bg.vbuf);
       cso_draw_arrays(cso, PIPE_PRIM_QUADS, 0, hud->bg.num_vertices);
    }
@@ -590,8 +592,8 @@ hud_draw_results(struct hud_context *hud, struct pipe_resource *tex)
    hud->constants.color[3] = 1;
    hud->constants.translate[0] = 0;
    hud->constants.translate[1] = 0;
-   hud->constants.scale[0] = 1;
-   hud->constants.scale[1] = 1;
+   hud->constants.scale[0] = hud_scale;
+   hud->constants.scale[1] = hud_scale;
    cso_set_constant_buffer(cso, PIPE_SHADER_VERTEX, 0, &hud->constbuf);
 
    if (hud->whitelines.num_vertices) {
@@ -1819,6 +1821,7 @@ hud_create(struct cso_context *cso, struct hud_context *share)
    struct sigaction action = {{0}};
 #endif
    huds_visible = debug_get_bool_option("GALLIUM_HUD_VISIBLE", TRUE);
+   hud_scale = debug_get_num_option("GALLIUM_HUD_SCALE", 1);
 
    if (!env || !*env)
       return NULL;



More information about the mesa-commit mailing list