mesa: added MESA_GLSL=useprog debug flag
authorBrian Paul <brianp@vmware.com>
Thu, 15 Oct 2009 21:25:52 +0000 (15:25 -0600)
committerBrian Paul <brianp@vmware.com>
Fri, 16 Oct 2009 19:07:43 +0000 (13:07 -0600)
This logs glUseProgram() calls to stderr.

src/mesa/main/mtypes.h
src/mesa/shader/shader_api.c

index 988bfe1e228cf883cd30bb5c3fe6de7f1c7c1f0f..b77dcdb7309309f042a27bebb333c96b281471f8 100644 (file)
@@ -2046,6 +2046,7 @@ struct gl_shader_program
 #define GLSL_UNIFORMS 0x10  /**< Print glUniform calls */
 #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 */
 
 
 /**
index 6de97984e6d8d827e7ecde265efdffcad2a47478..f473bd1173b8518e048a62dd65f005748fc826d4 100644 (file)
@@ -390,6 +390,8 @@ get_shader_flags(void)
          flags |= GLSL_OPT;
       if (_mesa_strstr(env, "uniform"))
          flags |= GLSL_UNIFORMS;
+      if (_mesa_strstr(env, "useprog"))
+         flags |= GLSL_USE_PROG;
    }
 
    return flags;
@@ -1524,19 +1526,32 @@ _mesa_use_program(GLcontext *ctx, GLuint program)
       }
 
       /* debug code */
-      if (0) {
+      if (ctx->Shader.Flags & GLSL_USE_PROG) {
          GLuint i;
-         _mesa_printf("Use Shader Program %u\n", shProg->Name);
+         _mesa_printf("Mesa: glUseProgram(%u)\n", shProg->Name);
          for (i = 0; i < shProg->NumShaders; i++) {
-            _mesa_printf(" shader %u, type 0x%x, checksum %u\n",
+            const char *s;
+            switch (shProg->Shaders[i]->Type) {
+            case GL_VERTEX_SHADER:
+               s = "vertex";
+               break;
+            case GL_FRAGMENT_SHADER:
+               s = "fragment";
+               break;
+            case GL_GEOMETRY_SHADER:
+               s = "geometry";
+               break;
+            default:
+               s = "";
+            }
+            _mesa_printf("  %s shader %u, checksum %u\n", s, 
                          shProg->Shaders[i]->Name,
-                         shProg->Shaders[i]->Type,
                          shProg->Shaders[i]->SourceChecksum);
          }
          if (shProg->VertexProgram)
-            printf(" vert prog %u\n", shProg->VertexProgram->Base.Id);
+            _mesa_printf("  vert prog %u\n", shProg->VertexProgram->Base.Id);
          if (shProg->FragmentProgram)
-            printf(" frag prog %u\n", shProg->FragmentProgram->Base.Id);
+            _mesa_printf("  frag prog %u\n", shProg->FragmentProgram->Base.Id);
       }
    }
    else {