Module: Mesa
Branch: main
Commit: 87f4d794278205c331c12bbfea587b55e2642c76
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=87f4d794278205c331c12bbfea587b55e2642c76

Author: Pierre-Eric Pelloux-Prayer <[email protected]>
Date:   Fri Dec 16 14:43:10 2022 +0100

hud,dri: emulate LIBGL_SHOW_FPS using hud

LIBGL_SHOW_FPS=1 is now almost equivalent to using:

   GALLIUM_HUD=stdout,fps
   GALLIUM_HUD_VISIBLE=false
   GALLIUM_HUD_PERIOD=$LIBGL_SHOW_FPS

so we can drop LIBGL_SHOW_FPS handling in dri and move it to hud.

Reviewed-by: Marek Olšák <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20494>

---

 src/gallium/auxiliary/hud/hud_context.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/gallium/auxiliary/hud/hud_context.c 
b/src/gallium/auxiliary/hud/hud_context.c
index 52e3876c70d..d947e65dbda 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -1202,7 +1202,7 @@ has_pipeline_stats_query(struct pipe_screen *screen)
 
 static void
 hud_parse_env_var(struct hud_context *hud, struct pipe_screen *screen,
-                  const char *env)
+                  const char *env, unsigned period_ms)
 {
    unsigned num, i;
    char name_a[256], s[256];
@@ -1210,7 +1210,7 @@ hud_parse_env_var(struct hud_context *hud, struct 
pipe_screen *screen,
    struct hud_pane *pane = NULL;
    unsigned x = 10, y = 10, y_simple = 10;
    unsigned width = 251, height = 100;
-   unsigned period = 500 * 1000;  /* default period (1/2 second) */
+   unsigned period = period_ms * 1000;
    uint64_t ceiling = UINT64_MAX;
    unsigned column_width = 251;
    boolean dyn_ceiling = false;
@@ -1903,7 +1903,18 @@ hud_create(struct cso_context *cso, struct hud_context 
*share,
    struct pipe_screen *screen = cso_get_pipe_context(cso)->screen;
    struct hud_context *hud;
    unsigned i;
-   const char *env = debug_get_option("GALLIUM_HUD", NULL);
+   unsigned default_period_ms = 500;/* default period (1/2 second) */
+   const char *show_fps = getenv("LIBGL_SHOW_FPS");
+   bool emulate_libgl_show_fps = false;
+   if (show_fps) {
+      default_period_ms = atoi(show_fps) * 1000;
+      if (default_period_ms)
+         emulate_libgl_show_fps = true;
+      else
+         default_period_ms = 500;
+   }
+   const char *env = debug_get_option("GALLIUM_HUD",
+      emulate_libgl_show_fps ? "stdout,fps" : NULL);
 #if DETECT_OS_UNIX
    unsigned signo = debug_get_num_option("GALLIUM_HUD_TOGGLE_SIGNAL", 0);
    static boolean sig_handled = FALSE;
@@ -1911,7 +1922,7 @@ hud_create(struct cso_context *cso, struct hud_context 
*share,
 
    memset(&action, 0, sizeof(action));
 #endif
-   huds_visible = debug_get_bool_option("GALLIUM_HUD_VISIBLE", TRUE);
+   huds_visible = debug_get_bool_option("GALLIUM_HUD_VISIBLE", 
!emulate_libgl_show_fps);
    hud_scale = debug_get_num_option("GALLIUM_HUD_SCALE", 1);
    hud_rotate = debug_get_num_option("GALLIUM_HUD_ROTATION", 0) % 360;
    if (hud_rotate < 0) {
@@ -2019,7 +2030,7 @@ hud_create(struct cso_context *cso, struct hud_context 
*share,
    if (draw_ctx == 0)
       hud_set_draw_context(hud, cso, st, st_invalidate_state);
 
-   hud_parse_env_var(hud, screen, env);
+   hud_parse_env_var(hud, screen, env, default_period_ms);
    return hud;
 }
 

Reply via email to