Mesa (glsl2): ir_to_mesa: Print shader source and compiled IR under MESA_GLSL=dump.

Eric Anholt anholt at kemper.freedesktop.org
Thu Aug 5 04:06:09 UTC 2010


Module: Mesa
Branch: glsl2
Commit: 455290e4281bf53ce2fe248a2adf5163563c44c8
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=455290e4281bf53ce2fe248a2adf5163563c44c8

Author: Eric Anholt <eric at anholt.net>
Date:   Wed Aug  4 19:43:41 2010 -0700

ir_to_mesa: Print shader source and compiled IR under MESA_GLSL=dump.

While the Mesa IR dumping includes some corresponding GLSL IR for
correlating Mesa IR to GLSL IR, it doesn't completely express it.
This printing includes things like variable declarations and control
flow structure that is hard to read otherwise.

---

 src/mesa/program/ir_to_mesa.cpp |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index 1cec4aa..2fd07ca 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -2545,7 +2545,14 @@ get_mesa_program(GLcontext *ctx, struct gl_shader_program *shader_program,
 
    set_branchtargets(&v, mesa_instructions, num_instructions);
    if (ctx->Shader.Flags & GLSL_DUMP) {
-      printf("Mesa %s program:\n", target_string);
+      printf("\n");
+      printf("GLSL IR for linked %s program %d:\n", target_string,
+	     shader_program->Name);
+      _mesa_print_ir(shader->ir, NULL);
+      printf("\n");
+      printf("\n");
+      printf("Mesa IR for linked %s program %d:\n", target_string,
+	     shader_program->Name);
       print_program(mesa_instructions, mesa_instruction_annotation,
 		    num_instructions);
    }
@@ -2635,6 +2642,15 @@ _mesa_glsl_compile_shader(GLcontext *ctx, struct gl_shader *shader)
       _mesa_write_shader_to_file(shader);
    }
 
+   if (ctx->Shader.Flags & GLSL_DUMP) {
+      printf("GLSL source for shader %d:\n", shader->Name);
+      printf("%s\n", shader->Source);
+
+      printf("GLSL IR for shader %d:\n", shader->Name);
+      _mesa_print_ir(shader->ir, NULL);
+      printf("\n\n");
+   }
+
    /* Retain any live IR, but trash the rest. */
    reparent_ir(shader->ir, shader);
 




More information about the mesa-commit mailing list