mesa: add GLSL_SOURCE
authorMike Blumenkrantz <michael.blumenkrantz@gmail.com>
Mon, 22 Aug 2022 14:48:45 +0000 (10:48 -0400)
committerMarge Bot <emma+marge@anholt.net>
Fri, 2 Sep 2022 19:15:44 +0000 (19:15 +0000)
many times I just want to dump glsl and not a trillion lines of IR

Reviewed-by: Emma Anholt <emma@anholt.net>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18280>

docs/shading.rst
src/mesa/main/mtypes.h
src/mesa/main/shaderapi.c

index 36d9420..01c8bc9 100644 (file)
@@ -13,7 +13,8 @@ The **MESA_GLSL** environment variable can be set to a comma-separated
 list of keywords to control some aspects of the GLSL compiler and shader
 execution. These are generally used for debugging.
 
--  **dump** - print GLSL shader code to stdout at link time
+-  **dump** - print GLSL shader code, IR, and NIR to stdout at link time
+-  **source** - print GLSL shader code to stdout at link time
 -  **log** - log all GLSL shaders to files. The filenames will be
    "shader_X.vert" or "shader_X.frag" where X the shader ID.
 -  **cache_info** - print debug information about shader cache
index 6d5ca9a..a7a22d7 100644 (file)
@@ -2296,6 +2296,7 @@ struct gl_ati_fragment_shader_state
 #define GLSL_DUMP_ON_ERROR 0x80 /**< Dump shaders to stderr on compile error */
 #define GLSL_CACHE_INFO 0x100 /**< Print debug information about shader cache */
 #define GLSL_CACHE_FALLBACK 0x200 /**< Force shader cache fallback paths */
+#define GLSL_SOURCE 0x400 /**< Only dump GLSL */
 
 
 /**
index 2aca40b..a299efc 100644 (file)
@@ -135,6 +135,8 @@ _mesa_get_shader_flags(void)
          flags |= GLSL_DUMP;
       if (strstr(env, "log"))
          flags |= GLSL_LOG;
+      if (strstr(env, "source"))
+         flags |= GLSL_SOURCE;
 #endif
       if (strstr(env, "cache_fb"))
          flags |= GLSL_CACHE_FALLBACK;
@@ -1216,7 +1218,7 @@ _mesa_compile_shader(struct gl_context *ctx, struct gl_shader *sh)
        */
       sh->CompileStatus = COMPILE_FAILURE;
    } else {
-      if (ctx->_Shader->Flags & GLSL_DUMP) {
+      if (ctx->_Shader->Flags & (GLSL_DUMP | GLSL_SOURCE)) {
          _mesa_log("GLSL source for %s shader %d:\n",
                  _mesa_shader_stage_to_string(sh->Stage), sh->Name);
          _mesa_log_direct(sh->Source);