aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main
diff options
context:
space:
mode:
authorMarek Olšák <[email protected]>2013-07-30 22:29:23 +0200
committerMarek Olšák <[email protected]>2013-07-30 23:31:26 +0200
commitab789393443629027dca16e0aad501d6c1c32cb0 (patch)
tree758ba9fef2469a829fef633309f0bfe458f70569 /src/mesa/main
parent7f2f804c75f6c7451c3630cb48e4675686bd68a7 (diff)
mesa: add MESA_GLSL debug flag to dump shaders on compile error
Reviewed-by: Kenneth Graunke <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r--src/mesa/main/mtypes.h1
-rw-r--r--src/mesa/main/shaderapi.c19
2 files changed, 15 insertions, 5 deletions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index aba7d845b88..4042e9a7066 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2402,6 +2402,7 @@ struct gl_shader_program
#define GLSL_NOP_FRAG 0x40 /**< Force no-op fragment shaders */
#define GLSL_USE_PROG 0x80 /**< Log glUseProgram calls */
#define GLSL_REPORT_ERRORS 0x100 /**< Print compilation errors */
+#define GLSL_DUMP_ON_ERROR 0x200 /**< Dump shaders to stderr on compile error */
/**
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 4cc0357b1a4..c349b0cb5bc 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -71,7 +71,9 @@ get_shader_flags(void)
const char *env = _mesa_getenv("MESA_GLSL");
if (env) {
- if (strstr(env, "dump"))
+ if (strstr(env, "dump_on_error"))
+ flags |= GLSL_DUMP_ON_ERROR;
+ else if (strstr(env, "dump"))
flags |= GLSL_DUMP;
if (strstr(env, "log"))
flags |= GLSL_LOG;
@@ -783,10 +785,17 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj)
}
- if (sh->CompileStatus == GL_FALSE &&
- (ctx->Shader.Flags & GLSL_REPORT_ERRORS)) {
- _mesa_debug(ctx, "Error compiling shader %u:\n%s\n",
- sh->Name, sh->InfoLog);
+ if (!sh->CompileStatus) {
+ if (ctx->Shader.Flags & GLSL_DUMP_ON_ERROR) {
+ fprintf(stderr, "GLSL source for %s shader %d:\n",
+ _mesa_glsl_shader_target_name(sh->Type), sh->Name);
+ fprintf(stderr, "%s\n", sh->Source);
+ }
+
+ if (ctx->Shader.Flags & GLSL_REPORT_ERRORS) {
+ _mesa_debug(ctx, "Error compiling shader %u:\n%s\n",
+ sh->Name, sh->InfoLog);
+ }
}
}