mesa: Simplify calling Driver.ProgramStringNotify after previous refactors
authorIan Romanick <ian.d.romanick@intel.com>
Sat, 20 Aug 2011 23:07:10 +0000 (16:07 -0700)
committerIan Romanick <ian.d.romanick@intel.com>
Fri, 7 Oct 2011 23:39:51 +0000 (16:39 -0700)
Signed-off-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Marek Olšák <maraeo@gmail.com>
src/mesa/program/ir_to_mesa.cpp
src/mesa/state_tracker/st_glsl_to_tgsi.cpp

index b9b7b1adbe9ebf653459f481aed5c181f529ff52..5be44bc514d4b49eefa6710f978fa69c2c24ac0a 100644 (file)
@@ -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;
          }
       }
index 80a593071b44fdd100a1908aa8c1b2f65cc8d11d..fe65ae53941cfc099e705208e436f06f2d07ace2 100644 (file)
@@ -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;
          }