Mesa (master): mesa: add ctx->Stencil._Enabled field

Brian Paul brianp at kemper.freedesktop.org
Mon Mar 2 18:51:15 UTC 2009


Module: Mesa
Branch: master
Commit: f352a80aec10c3faf2d84e0b35d59b4edc0395ef
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f352a80aec10c3faf2d84e0b35d59b4edc0395ef

Author: Brian Paul <brianp at vmware.com>
Date:   Mon Mar  2 11:46:49 2009 -0700

mesa: add ctx->Stencil._Enabled field

Only true if stenciling is enabled, and there's a stencil buffer.

---

 src/mesa/main/mtypes.h  |    1 +
 src/mesa/main/state.c   |    2 +-
 src/mesa/main/stencil.c |    6 +++++-
 3 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 1e42de8..f906de8 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -1012,6 +1012,7 @@ struct gl_stencil_attrib
    GLboolean Enabled;		/**< Enabled flag */
    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 _TestTwoSide;
    GLubyte _BackFace;           /**< Current back stencil state (1 or 2) */
    GLenum Function[3];		/**< Stencil function */
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index 0a39279..9ea932e 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -490,7 +490,7 @@ _mesa_update_state_locked( GLcontext *ctx )
    if (new_state & _NEW_LIGHT)
       _mesa_update_lighting( ctx );
 
-   if (new_state & _NEW_STENCIL)
+   if (new_state & (_NEW_STENCIL | _NEW_BUFFERS))
       _mesa_update_stencil( ctx );
 
 #if FEATURE_pixel_transfer
diff --git a/src/mesa/main/stencil.c b/src/mesa/main/stencil.c
index e4a255d..15c98e2 100644
--- a/src/mesa/main/stencil.c
+++ b/src/mesa/main/stencil.c
@@ -536,7 +536,11 @@ _mesa_update_stencil(GLcontext *ctx)
 {
    const GLint face = ctx->Stencil._BackFace;
 
-   ctx->Stencil._TestTwoSide =
+   ctx->Stencil._Enabled = (ctx->Stencil.Enabled &&
+                            ctx->DrawBuffer->Visual.stencilBits > 0);
+
+    ctx->Stencil._TestTwoSide =
+       ctx->Stencil._Enabled &&
        (ctx->Stencil.Function[0] != ctx->Stencil.Function[face] ||
 	ctx->Stencil.FailFunc[0] != ctx->Stencil.FailFunc[face] ||
 	ctx->Stencil.ZPassFunc[0] != ctx->Stencil.ZPassFunc[face] ||




More information about the mesa-commit mailing list