Mesa (master): mesa: Dump ARB_vp/fp source and IR when MESA_GLSL=dump.

Kenneth Graunke kwg at kemper.freedesktop.org
Tue May 13 22:31:34 UTC 2014


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

Author: Kenneth Graunke <kenneth at whitecape.org>
Date:   Sun May 11 20:22:48 2014 -0700

mesa: Dump ARB_vp/fp source and IR when MESA_GLSL=dump.

As far as I can tell, Mesa hasn't had a convenient way to dump ARB_vp/fp
source until now.  Using MESA_GLSL=dump is convenient, since it means
you can use a single environment variable to dump a program's shaders,
no matter which language they're written in.

Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Ian Romanick <ian.d.romanick at intel.com>

---

 src/mesa/main/arbprogram.c |   27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/arbprogram.c b/src/mesa/main/arbprogram.c
index 247b492..fe8cd6b 100644
--- a/src/mesa/main/arbprogram.c
+++ b/src/mesa/main/arbprogram.c
@@ -38,6 +38,7 @@
 #include "main/arbprogram.h"
 #include "program/arbprogparse.h"
 #include "program/program.h"
+#include "program/prog_print.h"
 
 
 /**
@@ -308,6 +309,7 @@ _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
                        const GLvoid *string)
 {
    struct gl_program *base;
+   bool failed;
    GET_CURRENT_CONTEXT(ctx);
 
    FLUSH_VERTICES(ctx, _NEW_PROGRAM);
@@ -341,13 +343,36 @@ _mesa_ProgramStringARB(GLenum target, GLenum format, GLsizei len,
       return;
    }
 
-   if (ctx->Program.ErrorPos == -1) {
+   failed = ctx->Program.ErrorPos != -1;
+
+   if (!failed) {
       /* finally, give the program to the driver for translation/checking */
       if (!ctx->Driver.ProgramStringNotify(ctx, target, base)) {
+         failed = true;
          _mesa_error(ctx, GL_INVALID_OPERATION,
                      "glProgramStringARB(rejected by driver");
       }
    }
+
+   if (ctx->_Shader->Flags & GLSL_DUMP) {
+      const char *shader_type =
+         target == GL_FRAGMENT_PROGRAM_ARB ? "fragment" : "vertex";
+
+      fprintf(stderr, "ARB_%s_program source for program %d:\n",
+              shader_type, base->Id);
+      fprintf(stderr, "%s\n", (const char *) string);
+
+      if (failed) {
+         fprintf(stderr, "ARB_%s_program %d failed to compile.\n",
+                 shader_type, base->Id);
+      } else {
+         fprintf(stderr, "Mesa IR for ARB_%s_program %d:\n",
+                 shader_type, base->Id);
+         _mesa_print_program(base);
+         fprintf(stderr, "\n");
+      }
+      fflush(stderr);
+   }
 }
 
 




More information about the mesa-commit mailing list