Mesa (gallium-0.2): mesa: fix generation of fixed function state when no vp exists

Alan Hourihane alanh at kemper.freedesktop.org
Thu Nov 13 05:16:53 PST 2008


Module: Mesa
Branch: gallium-0.2
Commit: 16340f8d4dfbde9cea01637ea225053194b8c640
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=16340f8d4dfbde9cea01637ea225053194b8c640

Author: Alan Hourihane <alanh at tungstengraphics.com>
Date:   Thu Nov 13 13:16:03 2008 +0000

mesa: fix generation of fixed function state when no vp exists

---

 src/mesa/main/state.c |   84 ++++++++++++++++++++++++-------------------------
 1 files changed, 41 insertions(+), 43 deletions(-)

diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 5e073a1..0d452fd 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -206,56 +206,54 @@ update_program(GLcontext *ctx)
 
    _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current, NULL);
 
-   if (shProg && shProg->LinkStatus) {
+   if (shProg && shProg->LinkStatus && shProg->FragmentProgram) {
       /* Use shader programs */
-      /* XXX this isn't quite right, since we may have either a vertex
-       * _or_ fragment shader (not always both).
-       */
-      _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
-                               shProg->VertexProgram);
       _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
                                shProg->FragmentProgram);
    }
+   else if (ctx->FragmentProgram._Enabled) {
+      /* use user-defined vertex program */
+      _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
+                               ctx->FragmentProgram.Current);
+   }
+   else if (ctx->FragmentProgram._MaintainTexEnvProgram) {
+      /* Use fragment program generated from fixed-function state.
+       */
+      _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 {
-      if (ctx->FragmentProgram._Enabled) {
-         /* use user-defined vertex program */
-         _mesa_reference_fragprog(ctx, &ctx->FragmentProgram._Current,
-                                  ctx->FragmentProgram.Current);
-      }
-      else if (ctx->FragmentProgram._MaintainTexEnvProgram) {
-         /* Use fragment program generated from fixed-function state.
-          */
-         _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);
-      }
+      /* 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.
+   /* Examine vertex program after fragment program as
+    * _mesa_get_fixed_func_vertex_program() needs to know active
+    * fragprog inputs.
+    */
+   if (shProg && shProg->LinkStatus && shProg->VertexProgram) {
+      /* Use shader programs */
+      _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current,
+                            shProg->VertexProgram);
+   }
+   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.
        */
-      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);
-      }
+      _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);
    }
 
    /* XXX: get rid of _Active flag.



More information about the mesa-commit mailing list