diff --git a/docs/shading.rst b/docs/shading.rst index 36d94202f2b..01c8bc99a00 100644 --- a/docs/shading.rst +++ b/docs/shading.rst @@ -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 diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 6d5ca9a4411..a7a22d754b4 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -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 */ /** diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c index 2aca40b1fb1..a299efc2759 100644 --- a/src/mesa/main/shaderapi.c +++ b/src/mesa/main/shaderapi.c @@ -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);