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

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

hud: check GALLIUM_HUD_DUMP_DIR value only once

Minor cleanup but will allow another change in the next commit.

Reviewed-by: Emma Anholt <[email protected]>
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 | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/src/gallium/auxiliary/hud/hud_context.c 
b/src/gallium/auxiliary/hud/hud_context.c
index 58a3edb6a51..dfb70af6be8 100644
--- a/src/gallium/auxiliary/hud/hud_context.c
+++ b/src/gallium/auxiliary/hud/hud_context.c
@@ -1055,11 +1055,9 @@ static void strcat_without_spaces(char *dst, const char 
*src)
  * is a HUD variable such as "fps", or "cpu"
  */
 static void
-hud_graph_set_dump_file(struct hud_graph *gr)
+hud_graph_set_dump_file(struct hud_graph *gr, const char *hud_dump_dir)
 {
-   const char *hud_dump_dir = getenv("GALLIUM_HUD_DUMP_DIR");
-
-   if (hud_dump_dir && access(hud_dump_dir, W_OK) == 0) {
+   if (hud_dump_dir) {
       char *dump_file = malloc(strlen(hud_dump_dir) + sizeof(PATH_SEP)
                                + sizeof(gr->name));
       if (dump_file) {
@@ -1522,11 +1520,14 @@ hud_parse_env_var(struct hud_context *hud, struct 
pipe_screen *screen,
       }
    }
 
-   LIST_FOR_EACH_ENTRY(pane, &hud->pane_list, head) {
-      struct hud_graph *gr;
+   const char *hud_dump_dir = getenv("GALLIUM_HUD_DUMP_DIR");
+   if (hud_dump_dir && access(hud_dump_dir, W_OK) == 0) {
+      LIST_FOR_EACH_ENTRY(pane, &hud->pane_list, head) {
+         struct hud_graph *gr;
 
-      LIST_FOR_EACH_ENTRY(gr, &pane->graph_list, head) {
-         hud_graph_set_dump_file(gr);
+         LIST_FOR_EACH_ENTRY(gr, &pane->graph_list, head) {
+            hud_graph_set_dump_file(gr, hud_dump_dir);
+         }
       }
    }
 }

Reply via email to