mesa: get fixed-function program generation working again
authorKeith Whitwell <keith@tungstengraphics.com>
Fri, 12 Sep 2008 09:04:56 +0000 (10:04 +0100)
committerKeith Whitwell <keith@tungstengraphics.com>
Fri, 12 Sep 2008 09:04:56 +0000 (10:04 +0100)
src/mesa/main/state.c
src/mesa/main/texenvprogram.c

index 5827f2211c0a4afabc335b6fae2042c2b90577eb..e340cd668660282f15eeee9eb9a29594a4b09949 100644 (file)
@@ -219,23 +219,6 @@ update_program(GLcontext *ctx)
                                shProg->FragmentProgram);
    }
    else {
-      if (ctx->VertexProgram._Enabled) {
-         /* use user-defined vertex program */
-         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
-                                  ctx->VertexProgram.Current);
-      }
-      else if (ctx->VertexProgram._MaintainTnlProgram) {
-         /* Use vertex program generated from fixed-function state.
-          * The _Current pointer will get set in
-          * _tnl_UpdateFixedFunctionProgram() later if appropriate.
-          */
-         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
-      }
-      else {
-         /* no vertex program */
-         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
-      }
-
       if (ctx->FragmentProgram._Enabled) {
          /* use user-defined vertex program */
          _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
@@ -243,15 +226,38 @@ update_program(GLcontext *ctx)
       }
       else if (ctx->FragmentProgram._MaintainTexEnvProgram) {
          /* Use fragment program generated from fixed-function state.
-          * The _Current pointer will get set in _mesa_UpdateTexEnvProgram()
-          * later if appropriate.
           */
-         _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
+         _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
+                                  _mesa_get_fixed_func_fragment_program(ctx));
+         _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._TexEnvProgram,
+                                  ctx->FragmentProgram._Current);
       }
       else {
          /* no fragment program */
          _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
       }
+
+      /* Examine vertex program after fragment program as
+       * _mesa_get_fixed_func_vertex_program() needs to know active
+       * fragprog inputs.
+       */
+      if (ctx->VertexProgram._Enabled) {
+         /* use user-defined vertex program */
+         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
+                                  ctx->VertexProgram.Current);
+      }
+      else if (ctx->VertexProgram._MaintainTnlProgram) {
+         /* Use vertex program generated from fixed-function state.
+          */
+         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
+                                  _mesa_get_fixed_func_vertex_program(ctx));
+         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram,
+                                  ctx->VertexProgram._Current);
+      }
+      else {
+         /* no vertex program */
+         _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL);
+      }
    }
 
    if (ctx->VertexProgram._Current)
@@ -260,12 +266,28 @@ update_program(GLcontext *ctx)
       assert(ctx->FragmentProgram._Current->Base.Parameters);
 
 
+   /* XXX: get rid of _Active flag.
+    */
+#if 1
    ctx->FragmentProgram._Active = ctx->FragmentProgram._Enabled;
    if (ctx->FragmentProgram._MaintainTexEnvProgram &&
        !ctx->FragmentProgram._Enabled) {
       if (ctx->FragmentProgram._UseTexEnvProgram)
         ctx->FragmentProgram._Active = GL_TRUE;
    }
+#endif
+
+   /* Let the driver know what's happening:
+    */
+   if (ctx->FragmentProgram._Current != prevFP && ctx->Driver.BindProgram) {
+      ctx->Driver.BindProgram(ctx, GL_FRAGMENT_PROGRAM_ARB,
+                              (struct gl_program *) ctx->FragmentProgram._Current);
+   }
+   
+   if (ctx->VertexProgram._Current != prevVP && ctx->Driver.BindProgram) {
+      ctx->Driver.BindProgram(ctx, GL_VERTEX_PROGRAM_ARB,
+                              (struct gl_program *) ctx->VertexProgram._Current);
+   }
 }
 
 
index 713ff3d256424a64b17987e90fa6969e5b5ca5e6..25e280bc3f32c69b6988b9e92692af4da2ed904b 100644 (file)
@@ -1190,6 +1190,9 @@ _mesa_get_fixed_func_fragment_program(GLcontext *ctx)
  * If _MaintainTexEnvProgram is set we'll generate a fragment program that
  * implements the current texture env/combine mode.
  * This function generates that program and puts it into effect.
+ *
+ * XXX: remove this function.  currently only called by some drivers,
+ * not by mesa core.  We now handle this properly from inside mesa.
  */
 void
 _mesa_UpdateTexEnvProgram( GLcontext *ctx )