Mesa (master): i915: Make stencil test for no-stencil handling match depth test.

Eric Anholt anholt at kemper.freedesktop.org
Mon Jul 18 18:43:59 UTC 2011


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

Author: Eric Anholt <eric at anholt.net>
Date:   Tue Jul 12 10:57:51 2011 -0700

i915: Make stencil test for no-stencil handling match depth test.

i915_update_draw_buffers() already handles the fallback bit for
missing stencil region, so here we just need to handle whether the GL
thinks we have stencil data or not (and disable the test if so).

---

 src/mesa/drivers/dri/i915/i915_state.c |   32 +++++++++++---------------------
 src/mesa/drivers/dri/i915/i915_vtbl.c  |    3 +--
 2 files changed, 12 insertions(+), 23 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/i915_state.c b/src/mesa/drivers/dri/i915/i915_state.c
index 73dda65..b876717 100644
--- a/src/mesa/drivers/dri/i915/i915_state.c
+++ b/src/mesa/drivers/dri/i915/i915_state.c
@@ -843,27 +843,17 @@ i915Enable(struct gl_context * ctx, GLenum cap, GLboolean state)
       break;
 
    case GL_STENCIL_TEST:
-      {
-         GLboolean hw_stencil = GL_FALSE;
-         if (ctx->DrawBuffer) {
-            struct intel_renderbuffer *irbStencil
-               = intel_get_renderbuffer(ctx->DrawBuffer, BUFFER_STENCIL);
-            hw_stencil = (irbStencil && irbStencil->region);
-         }
-         if (hw_stencil) {
-	    dw = i915->state.Ctx[I915_CTXREG_LIS5];
-            if (state)
-               dw |= (S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE);
-            else
-               dw &= ~(S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE);
-	    if (dw != i915->state.Ctx[I915_CTXREG_LIS5]) {
-	       i915->state.Ctx[I915_CTXREG_LIS5] = dw;
-	       I915_STATECHANGE(i915, I915_UPLOAD_CTX);
-	    }
-         }
-         else {
-            FALLBACK(&i915->intel, I915_FALLBACK_STENCIL, state);
-         }
+      if (!ctx->DrawBuffer || !ctx->DrawBuffer->Visual.stencilBits)
+	 state = false;
+
+      dw = i915->state.Ctx[I915_CTXREG_LIS5];
+      if (state)
+	 dw |= (S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE);
+      else
+	 dw &= ~(S5_STENCIL_TEST_ENABLE | S5_STENCIL_WRITE_ENABLE);
+      if (dw != i915->state.Ctx[I915_CTXREG_LIS5]) {
+	 i915->state.Ctx[I915_CTXREG_LIS5] = dw;
+	 I915_STATECHANGE(i915, I915_UPLOAD_CTX);
       }
       break;
 
diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c
index 95c56bc..bd0664b 100644
--- a/src/mesa/drivers/dri/i915/i915_vtbl.c
+++ b/src/mesa/drivers/dri/i915/i915_vtbl.c
@@ -799,8 +799,7 @@ i915_update_draw_buffer(struct intel_context *intel)
     * Update depth and stencil test state
     */
    ctx->Driver.Enable(ctx, GL_DEPTH_TEST, ctx->Depth.Test);
-   ctx->Driver.Enable(ctx, GL_STENCIL_TEST,
-		      (ctx->Stencil.Enabled && fb->Visual.stencilBits > 0));
+   ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
 
    intel->vtbl.set_draw_region(intel, colorRegions, depthRegion,
                                fb->_NumColorDrawBuffers);




More information about the mesa-commit mailing list