mesa: refactor, new print_shader_info()
authorBrian Paul <brianp@vmware.com>
Fri, 23 Oct 2009 22:31:48 +0000 (16:31 -0600)
committerBrian Paul <brianp@vmware.com>
Sat, 24 Oct 2009 00:31:03 +0000 (18:31 -0600)
src/mesa/shader/shader_api.c

index f473bd1173b8518e048a62dd65f005748fc826d4..30fa58ea5213fe63b5c3f21a2efaae0996efd920 100644 (file)
@@ -1498,6 +1498,41 @@ _mesa_link_program(GLcontext *ctx, GLuint program)
 }
 
 
+/**
+ * Print basic shader info (for debug).
+ */
+static void
+print_shader_info(const struct gl_shader_program *shProg)
+{
+   GLuint i;
+
+   _mesa_printf("Mesa: glUseProgram(%u)\n", shProg->Name);
+   for (i = 0; i < shProg->NumShaders; i++) {
+      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]->SourceChecksum);
+   }
+   if (shProg->VertexProgram)
+      _mesa_printf("  vert prog %u\n", shProg->VertexProgram->Base.Id);
+   if (shProg->FragmentProgram)
+      _mesa_printf("  frag prog %u\n", shProg->FragmentProgram->Base.Id);
+}
+
+
 /**
  * Called via ctx->Driver.UseProgram()
  */
@@ -1527,31 +1562,7 @@ _mesa_use_program(GLcontext *ctx, GLuint program)
 
       /* debug code */
       if (ctx->Shader.Flags & GLSL_USE_PROG) {
-         GLuint i;
-         _mesa_printf("Mesa: glUseProgram(%u)\n", shProg->Name);
-         for (i = 0; i < shProg->NumShaders; i++) {
-            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]->SourceChecksum);
-         }
-         if (shProg->VertexProgram)
-            _mesa_printf("  vert prog %u\n", shProg->VertexProgram->Base.Id);
-         if (shProg->FragmentProgram)
-            _mesa_printf("  frag prog %u\n", shProg->FragmentProgram->Base.Id);
+         print_shader_info(shProg);
       }
    }
    else {