Mesa (main): v3d: handle debug options with debug_named_value

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Jul 23 15:40:20 UTC 2021


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

Author: Juan A. Suarez Romero <jasuarez at igalia.com>
Date:   Fri Jul 23 14:16:10 2021 +0200

v3d: handle debug options with debug_named_value

Switch from using debug_control structure to debug_named_value
structure.

The main nice feature is that it provides a "help" option, so using
"V3D_DEBUG=help" will print all the debug options with a brief
description.

Useful to avoid going to https://docs.mesa3d.org/envvars.html everytime
we need to know the available options.

v1:
 - Modify a couple of debug option documentation (Alejandro)

Reviewed-by: Alejandro Piñeiro <apinheiro at igalia.com>
Signed-off-by: Juan A. Suarez Romero <jasuarez at igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12036>

---

 src/broadcom/common/v3d_debug.c | 77 +++++++++++++++++++++++------------------
 1 file changed, 44 insertions(+), 33 deletions(-)

diff --git a/src/broadcom/common/v3d_debug.c b/src/broadcom/common/v3d_debug.c
index 64a2426b9c1..120905d34bb 100644
--- a/src/broadcom/common/v3d_debug.c
+++ b/src/broadcom/common/v3d_debug.c
@@ -34,33 +34,53 @@
 
 #include "common/v3d_debug.h"
 #include "util/macros.h"
-#include "util/debug.h"
+#include "util/u_debug.h"
 #include "c11/threads.h"
 
 uint32_t V3D_DEBUG = 0;
 
-static const struct debug_control debug_control[] = {
-        { "cl",          V3D_DEBUG_CL},
-        { "clif",        V3D_DEBUG_CLIF},
-        { "qpu",         V3D_DEBUG_QPU},
-        { "vir",         V3D_DEBUG_VIR},
-        { "nir",         V3D_DEBUG_NIR},
-        { "tgsi",        V3D_DEBUG_TGSI},
-        { "shaderdb",    V3D_DEBUG_SHADERDB},
-        { "surface",     V3D_DEBUG_SURFACE},
-        { "perf",        V3D_DEBUG_PERF},
-        { "norast",      V3D_DEBUG_NORAST},
-        { "fs",          V3D_DEBUG_FS},
-        { "gs",          V3D_DEBUG_GS},
-        { "vs",          V3D_DEBUG_VS},
-        { "cs",          V3D_DEBUG_CS},
-        { "always_flush", V3D_DEBUG_ALWAYS_FLUSH},
-        { "precompile",  V3D_DEBUG_PRECOMPILE},
-        { "ra",          V3D_DEBUG_RA},
-        { "dump_spirv",  V3D_DEBUG_DUMP_SPIRV},
-        { NULL,    0 }
+static const struct debug_named_value debug_control[] = {
+        { "cl",          V3D_DEBUG_CL,
+          "Dump command list during creation" },
+        { "clif",        V3D_DEBUG_CLIF,
+          "Dump command list (CLIF format) during creation", },
+        { "qpu",         V3D_DEBUG_QPU,
+          "Dump generated QPU instructions" },
+        { "vir",         V3D_DEBUG_VIR,
+          "Dump VIR during program compile" },
+        { "nir",         V3D_DEBUG_NIR,
+          "Dump NIR during program compile" },
+        { "tgsi",        V3D_DEBUG_TGSI,
+          "Dump TGSI during program compile" },
+        { "shaderdb",    V3D_DEBUG_SHADERDB,
+          "Dump program compile information for shader-db analysis" },
+        { "surface",     V3D_DEBUG_SURFACE,
+          "Print resource layout information" },
+        { "perf",        V3D_DEBUG_PERF,
+          "Print during runtime performance-related events" },
+        { "norast",      V3D_DEBUG_NORAST,
+          "Skip actual hardware execution of commands" },
+        { "fs",          V3D_DEBUG_FS,
+          "Dump fragment shaders" },
+        { "gs",          V3D_DEBUG_GS,
+          "Dump geometry shaders" },
+        { "vs",          V3D_DEBUG_VS,
+          "Dump vertex shaders" },
+        { "cs",          V3D_DEBUG_CS,
+          "Dump computer shaders" },
+        { "always_flush", V3D_DEBUG_ALWAYS_FLUSH,
+          "Flush after each draw call" },
+        { "precompile",  V3D_DEBUG_PRECOMPILE,
+          "Precompiles shader variant at shader state creation time" },
+        { "ra",          V3D_DEBUG_RA,
+          "Dump register allocation failures" },
+        { "dump_spirv",  V3D_DEBUG_DUMP_SPIRV,
+          "Dump SPIR-V code" },
+        { NULL }
 };
 
+DEBUG_GET_ONCE_FLAGS_OPTION(v3d_debug, "V3D_DEBUG", debug_control, 0)
+
 uint32_t
 v3d_debug_flag_for_shader_stage(gl_shader_stage stage)
 {
@@ -76,20 +96,11 @@ v3d_debug_flag_for_shader_stage(gl_shader_stage stage)
         return flags[stage];
 }
 
-static void
-v3d_process_debug_variable_once(void)
-{
-        V3D_DEBUG = parse_debug_string(getenv("V3D_DEBUG"), debug_control);
-
-        if (V3D_DEBUG & V3D_DEBUG_SHADERDB)
-                V3D_DEBUG |= V3D_DEBUG_NORAST;
-}
-
 void
 v3d_process_debug_variable(void)
 {
-        static once_flag v3d_process_debug_variable_flag = ONCE_FLAG_INIT;
+        V3D_DEBUG = debug_get_option_v3d_debug();
 
-        call_once(&v3d_process_debug_variable_flag,
-                  v3d_process_debug_variable_once);
+        if (V3D_DEBUG & V3D_DEBUG_SHADERDB)
+                V3D_DEBUG |= V3D_DEBUG_NORAST;
 }



More information about the mesa-commit mailing list