mesa: Add new ctx->Stencil._WriteEnabled derived state flag.
authorKenneth Graunke <kenneth@whitecape.org>
Tue, 2 Apr 2013 17:22:18 +0000 (10:22 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 4 Apr 2013 22:38:18 +0000 (15:38 -0700)
i965 needs to know whether stencil writes are enabled in several places,
and gets the test wrong sometimes.  While we could create a function to
compute this, it seems generally useful enough to warrant a new piece of
derived state.  Also, all the plumbing is already in place.

NOTE: This is a candidate for stable branches.
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Paul Berry <stereotype441@gmail.com>
src/mesa/main/mtypes.h
src/mesa/main/stencil.c

index ace6938..e731fe3 100644 (file)
@@ -1015,6 +1015,7 @@ struct gl_stencil_attrib
    GLboolean TestTwoSide;      /**< GL_EXT_stencil_two_side */
    GLubyte ActiveFace;         /**< GL_EXT_stencil_two_side (0 or 2) */
    GLboolean _Enabled;          /**< Enabled and stencil buffer present */
+   GLboolean _WriteEnabled;     /**< _Enabled and non-zero writemasks */
    GLboolean _TestTwoSide;
    GLubyte _BackFace;           /**< Current back stencil state (1 or 2) */
    GLenum Function[3];         /**< Stencil function */
index c161808..3308417 100644 (file)
@@ -551,6 +551,11 @@ _mesa_update_stencil(struct gl_context *ctx)
        ctx->Stencil.Ref[0] != ctx->Stencil.Ref[face] ||
        ctx->Stencil.ValueMask[0] != ctx->Stencil.ValueMask[face] ||
        ctx->Stencil.WriteMask[0] != ctx->Stencil.WriteMask[face]);
+
+   ctx->Stencil._WriteEnabled =
+      ctx->Stencil._Enabled &&
+      (ctx->Stencil.WriteMask[0] != 0 ||
+       (ctx->Stencil._TestTwoSide && ctx->Stencil.WriteMask[face] != 0));
 }