Mesa (master): mesa: add GLSL_REPORT_ERRORS debug flag

Brian Paul brianp at kemper.freedesktop.org
Sat May 19 14:39:13 UTC 2012


Module: Mesa
Branch: master
Commit: 0161691f3518db310411c5f02c05aa639050f129
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=0161691f3518db310411c5f02c05aa639050f129

Author: Brian Paul <brianp at vmware.com>
Date:   Thu May 17 07:44:32 2012 -0600

mesa: add GLSL_REPORT_ERRORS debug flag

If the MESA_GLSL env var contains "errors", GLSL compilation and
link errors will be reported to stderr.

Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/mesa/main/mtypes.h    |    1 +
 src/mesa/main/shaderapi.c |   14 ++++++++++++++
 2 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index aa1a8ef..eefe5e7 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2355,6 +2355,7 @@ struct gl_shader_program
 #define GLSL_NOP_VERT 0x20  /**< Force no-op vertex shaders */
 #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 */
 
 
 /**
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 3e03239..6927368 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -83,6 +83,8 @@ get_shader_flags(void)
          flags |= GLSL_UNIFORMS;
       if (strstr(env, "useprog"))
          flags |= GLSL_USE_PROG;
+      if (strstr(env, "errors"))
+         flags |= GLSL_REPORT_ERRORS;
    }
 
    return flags;
@@ -673,6 +675,12 @@ compile_shader(struct gl_context *ctx, GLuint shaderObj)
     * compilation was successful.
     */
    _mesa_glsl_compile_shader(ctx, sh);
+
+   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);
+   }
 }
 
 
@@ -703,6 +711,12 @@ link_program(struct gl_context *ctx, GLuint program)
 
    _mesa_glsl_link_shader(ctx, shProg);
 
+   if (shProg->LinkStatus == GL_FALSE && 
+       (ctx->Shader.Flags & GLSL_REPORT_ERRORS)) {
+      _mesa_debug(ctx, "Error linking program %u:\n%s\n",
+                  shProg->Name, shProg->InfoLog);
+   }
+
    /* debug code */
    if (0) {
       GLuint i;




More information about the mesa-commit mailing list