Mesa (master): mesa: Simplify calling Driver. ProgramStringNotify after previous refactors

Ian Romanick idr at kemper.freedesktop.org
Fri Oct 7 16:41:06 PDT 2011


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

Author: Ian Romanick <ian.d.romanick at intel.com>
Date:   Sat Aug 20 16:07:10 2011 -0700

mesa: Simplify calling Driver.ProgramStringNotify after previous refactors

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
Reviewed-by: Brian Paul <brianp at vmware.com>
Reviewed-by: Kenneth Graunke <kenneth at whitecape.org>
Reviewed-by: Marek Olšák <maraeo at gmail.com>

---

 src/mesa/program/ir_to_mesa.cpp            |   33 +++++++--------------
 src/mesa/state_tracker/st_glsl_to_tgsi.cpp |   44 +++++++---------------------
 2 files changed, 22 insertions(+), 55 deletions(-)

diff --git a/src/mesa/program/ir_to_mesa.cpp b/src/mesa/program/ir_to_mesa.cpp
index b9b7b1a..5be44bc 100644
--- a/src/mesa/program/ir_to_mesa.cpp
+++ b/src/mesa/program/ir_to_mesa.cpp
@@ -3288,31 +3288,20 @@ _mesa_ir_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
       linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
 
       if (linked_prog) {
-         bool ok = true;
+	 static const GLenum targets[] = {
+	    GL_VERTEX_PROGRAM_ARB,
+	    GL_FRAGMENT_PROGRAM_ARB,
+	    GL_GEOMETRY_PROGRAM_NV
+	 };
 
-         switch (prog->_LinkedShaders[i]->Type) {
-         case GL_VERTEX_SHADER:
+	 if (i == MESA_SHADER_VERTEX) {
             ((struct gl_vertex_program *)linked_prog)->UsesClipDistance
                = prog->Vert.UsesClipDistance;
-            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
-				    linked_prog);
-            ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
-                                                 linked_prog);
-            break;
-         case GL_FRAGMENT_SHADER:
-            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
-				    linked_prog);
-            ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
-                                                 linked_prog);
-            break;
-         case GL_GEOMETRY_SHADER:
-            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
-				    linked_prog);
-            ok = ctx->Driver.ProgramStringNotify(ctx, GL_GEOMETRY_PROGRAM_NV,
-                                                 linked_prog);
-            break;
-         }
-         if (!ok) {
+	 }
+
+	 _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+				 linked_prog);
+         if (!ctx->Driver.ProgramStringNotify(ctx, targets[i], linked_prog)) {
             return GL_FALSE;
          }
       }
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 80a5930..fe65ae5 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -5180,39 +5180,17 @@ st_link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
       linked_prog = get_mesa_program(ctx, prog, prog->_LinkedShaders[i]);
 
       if (linked_prog) {
-         bool ok = true;
-
-         switch (prog->_LinkedShaders[i]->Type) {
-         case GL_VERTEX_SHADER:
-            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
-                                    linked_prog);
-            ok = ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB,
-                                                 linked_prog);
-            if (!ok) {
-               _mesa_reference_vertprog(ctx, &prog->VertexProgram, NULL);
-            }
-            break;
-         case GL_FRAGMENT_SHADER:
-            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
-				    linked_prog);
-            ok = ctx->Driver.ProgramStringNotify(ctx, GL_FRAGMENT_PROGRAM_ARB,
-                                                 linked_prog);
-            if (!ok) {
-               _mesa_reference_fragprog(ctx, &prog->FragmentProgram, NULL);
-            }
-            break;
-         case GL_GEOMETRY_SHADER:
-            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
-				    linked_prog);
-            ok = ctx->Driver.ProgramStringNotify(ctx, GL_GEOMETRY_PROGRAM_NV,
-                                                 linked_prog);
-            if (!ok) {
-               _mesa_reference_geomprog(ctx, &prog->GeometryProgram, NULL);
-            }
-            break;
-         }
-         if (!ok) {
-            _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program, NULL);
+	 static const GLenum targets[] = {
+	    GL_VERTEX_PROGRAM_ARB,
+	    GL_FRAGMENT_PROGRAM_ARB,
+	    GL_GEOMETRY_PROGRAM_NV
+	 };
+
+	 _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+				 linked_prog);
+         if (!ctx->Driver.ProgramStringNotify(ctx, targets[i], linked_prog)) {
+	    _mesa_reference_program(ctx, &prog->_LinkedShaders[i]->Program,
+				    NULL);
             _mesa_reference_program(ctx, &linked_prog, NULL);
             return GL_FALSE;
          }



More information about the mesa-commit mailing list