mesa: Add a context flag indicating whether two-sided lighting should happen.
authorEric Anholt <eric@anholt.net>
Thu, 8 Sep 2011 22:14:33 +0000 (15:14 -0700)
committerEric Anholt <eric@anholt.net>
Wed, 21 Sep 2011 16:46:38 +0000 (09:46 -0700)
The 965 driver was ignoring the VERTEX_PROGRAM_TWO_SIDE flag and only
looking at fixed-function state.

src/mesa/main/mtypes.h
src/mesa/main/state.c

index 57373a0bbbd023cdc35e4a2722a7aaf682ce2d95..42831d773be1e0767324d7e249333d2f4067b7f2 100644 (file)
@@ -1927,6 +1927,8 @@ struct gl_vertex_program_state
    GLboolean _Enabled;           /**< Enabled and _valid_ user program? */
    GLboolean PointSizeEnabled;   /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
    GLboolean TwoSideEnabled;     /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
+   /** Computed two sided lighting for fixed function/programs. */
+   GLboolean _TwoSideEnabled;
    struct gl_vertex_program *Current;  /**< User-bound vertex program */
 
    /** Currently enabled and valid vertex program (including internal
index 9d9c952dcef65880af766d88fc5481ae7bbfc26d..fc25515a00c860119d247f348d35ca4866164ff0 100644 (file)
@@ -447,7 +447,20 @@ update_clamp_read_color(struct gl_context *ctx)
       ctx->Color._ClampReadColor = ctx->Color.ClampReadColor;
 }
 
-
+/**
+ * Update the ctx->VertexProgram._TwoSideEnabled flag.
+ */
+static void
+update_twoside(struct gl_context *ctx)
+{
+   if (ctx->Shader.CurrentVertexProgram ||
+       ctx->VertexProgram.Current) {
+      ctx->VertexProgram._TwoSideEnabled = ctx->VertexProgram.TwoSideEnabled;
+   } else {
+      ctx->VertexProgram._TwoSideEnabled = (ctx->Light.Enabled &&
+                                           ctx->Light.Model.TwoSide);
+   }
+}
 
 
 /*
@@ -603,6 +616,9 @@ _mesa_update_state_locked( struct gl_context *ctx )
    if (new_state & _NEW_LIGHT)
       _mesa_update_lighting( ctx );
 
+   if (new_state & (_NEW_LIGHT | _NEW_PROGRAM))
+      update_twoside( ctx );
+
    if (new_state & (_NEW_LIGHT | _NEW_BUFFERS))
       update_clamp_vertex_color(ctx);