mesa: replace _mesa_update_stencil() with helper functions
authorMarek Olšák <marek.olsak@amd.com>
Fri, 9 Jun 2017 18:37:34 +0000 (20:37 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 21 Jun 2017 23:48:30 +0000 (01:48 +0200)
The idea is to remove the dependency on _mesa_update_state_locked,
so that st/mesa can skip it for stencil state updates, and then stop
setting _NEW_STENCIL in mesa/main if the driver is st/mesa.

The main motivation is to stop invoking _mesa_update_state_locked for
certain state groups.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
26 files changed:
src/mesa/drivers/common/driverfuncs.c
src/mesa/drivers/dri/i915/i915_state.c
src/mesa/drivers/dri/i915/intel_pixel.c
src/mesa/drivers/dri/i915/intel_pixel_copy.c
src/mesa/drivers/dri/i965/brw_cc.c
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/drivers/dri/i965/brw_context.h
src/mesa/drivers/dri/i965/brw_draw.c
src/mesa/drivers/dri/i965/brw_wm.c
src/mesa/drivers/dri/i965/gen7_misc_state.c
src/mesa/drivers/dri/i965/gen8_depth_state.c
src/mesa/drivers/dri/i965/genX_state_upload.c
src/mesa/drivers/dri/i965/intel_pixel.c
src/mesa/drivers/dri/i965/intel_pixel_copy.c
src/mesa/drivers/dri/nouveau/nv04_state_raster.c
src/mesa/drivers/dri/nouveau/nv10_state_raster.c
src/mesa/drivers/dri/radeon/radeon_common.c
src/mesa/main/mtypes.h
src/mesa/main/state.c
src/mesa/main/stencil.c
src/mesa/main/stencil.h
src/mesa/state_tracker/st_atom_depth.c
src/mesa/swrast/s_context.c
src/mesa/swrast/s_span.c
src/mesa/swrast/s_triangle.c
src/mesa/swrast_setup/ss_triangle.c

index db0a107fe89f13cb60eb1bea45818bb338534891..5008ae8feafb3070797dc11d5e35a4de3e5c27c9 100644 (file)
@@ -250,7 +250,7 @@ _mesa_init_driver_state(struct gl_context *ctx)
    ctx->Driver.Enable(ctx, GL_LINE_SMOOTH, ctx->Line.SmoothFlag);
    ctx->Driver.Enable(ctx, GL_POLYGON_STIPPLE, ctx->Polygon.StippleFlag);
    ctx->Driver.Enable(ctx, GL_SCISSOR_TEST, ctx->Scissor.EnableFlags);
-   ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil._Enabled);
+   ctx->Driver.Enable(ctx, GL_STENCIL_TEST, ctx->Stencil.Enabled);
    ctx->Driver.Enable(ctx, GL_TEXTURE_1D, GL_FALSE);
    ctx->Driver.Enable(ctx, GL_TEXTURE_2D, GL_FALSE);
    ctx->Driver.Enable(ctx, GL_TEXTURE_RECTANGLE_NV, GL_FALSE);
index 715db1fffa3da49fa4df8c87bc794a37d0def5c1..232fc9dce192c80bf2646ccf6404ac1a2402a6a7 100644 (file)
@@ -127,7 +127,7 @@ i915_update_stencil(struct gl_context * ctx)
                  S5_STENCIL_PASS_Z_PASS_SHIFT));
 
    /* Set back state if different from front. */
-   if (ctx->Stencil._TestTwoSide) {
+   if (_mesa_stencil_is_two_sided(ctx)) {
       set_ctx_bits(I915_CTXREG_BF_STENCIL_OPS,
                    BFO_STENCIL_REF_MASK |
                    BFO_STENCIL_TEST_MASK |
index feb1a3f97e8a778edba94d38efb53115f992c656..b536c9b56d50f0732b3fc050b9454e862c085ac3 100644 (file)
@@ -28,6 +28,7 @@
 #include "main/accum.h"
 #include "main/enums.h"
 #include "main/state.h"
+#include "main/stencil.h"
 #include "main/bufferobj.h"
 #include "main/context.h"
 #include "swrast/swrast.h"
@@ -110,7 +111,7 @@ intel_check_blit_fragment_ops(struct gl_context * ctx, bool src_alpha_is_one)
       return false;
    }
 
-   if (ctx->Stencil._Enabled) {
+   if (_mesa_stencil_is_enabled(ctx)) {
       DBG("fallback due to image stencil\n");
       return false;
    }
index 213cdbd0f534da394e14c2f5e6f67117effc4fa4..e447511f587166dd3cee084ab7386bbae6dcc1dc 100644 (file)
@@ -28,6 +28,7 @@
 #include "main/glheader.h"
 #include "main/image.h"
 #include "main/state.h"
+#include "main/stencil.h"
 #include "main/mtypes.h"
 #include "main/condrender.h"
 #include "main/fbobject.h"
@@ -111,7 +112,7 @@ do_blit_copypixels(struct gl_context * ctx,
       return false;
    }
 
-   if (ctx->Stencil._Enabled) {
+   if (_mesa_stencil_is_enabled(ctx)) {
       perf_debug("glCopyPixels(): Unsupported stencil test state\n");
       return false;
    }
index 78d3bc86d13998cc44a8fcfdaef62e6ac8a3bc9d..f0aa7b89704fba3e7843b66ee5fa08204872d20c 100644 (file)
@@ -72,7 +72,7 @@ static void upload_cc_unit(struct brw_context *brw)
    memset(cc, 0, sizeof(*cc));
 
    /* _NEW_STENCIL | _NEW_BUFFERS */
-   if (ctx->Stencil._Enabled) {
+   if (brw->stencil_enabled) {
       const unsigned back = ctx->Stencil._BackFace;
 
       cc->cc0.stencil_enable = 1;
@@ -88,7 +88,7 @@ static void upload_cc_unit(struct brw_context *brw)
       cc->cc1.stencil_write_mask = ctx->Stencil.WriteMask[0];
       cc->cc1.stencil_test_mask = ctx->Stencil.ValueMask[0];
 
-      if (ctx->Stencil._TestTwoSide) {
+      if (brw->stencil_two_sided) {
         cc->cc0.bf_stencil_enable = 1;
         cc->cc0.bf_stencil_func =
            intel_translate_compare_func(ctx->Stencil.Function[back]);
@@ -106,7 +106,7 @@ static void upload_cc_unit(struct brw_context *brw)
       /* Not really sure about this:
        */
       if (ctx->Stencil.WriteMask[0] ||
-         (ctx->Stencil._TestTwoSide && ctx->Stencil.WriteMask[back]))
+         (brw->stencil_two_sided && ctx->Stencil.WriteMask[back]))
         cc->cc0.stencil_write_enable = 1;
    }
 
index 05b0d8d04ec0ee1e1cfb2fa960cfe7f7389c6fb9..ec87817c5173e1847f7f0dded324c5573c1e9e0b 100644 (file)
@@ -43,6 +43,7 @@
 #include "main/vtxfmt.h"
 #include "main/texobj.h"
 #include "main/framebuffer.h"
+#include "main/stencil.h"
 
 #include "vbo/vbo_context.h"
 
@@ -201,6 +202,13 @@ intel_update_state(struct gl_context * ctx)
 
    _mesa_unlock_context_textures(ctx);
 
+   if (new_state & (_NEW_STENCIL | _NEW_BUFFERS)) {
+      brw->stencil_enabled = _mesa_stencil_is_enabled(ctx);
+      brw->stencil_two_sided = _mesa_stencil_is_two_sided(ctx);
+      brw->stencil_write_enabled =
+         _mesa_stencil_is_write_enabled(ctx, brw->stencil_two_sided);
+   }
+
    intel_prepare_render(brw);
 
    /* Resolve the depth buffer's HiZ buffer. */
index f4b5b8335fe76437ad6bf628625ba991b5080c24..2eea3030115d2ac04a795c746918247ac5580b05 100644 (file)
@@ -774,6 +774,11 @@ struct brw_context
     */
    bool needs_unlit_centroid_workaround;
 
+   /** Derived stencil states. */
+   bool stencil_enabled;
+   bool stencil_two_sided;
+   bool stencil_write_enabled;
+
    struct isl_device isl_dev;
 
    struct blorp_context blorp;
index d1309ac483701d4c714a6cf5b90ed3915f8f1d35..821f1e24e94bb4759848665060ec5473cc77ac3b 100644 (file)
@@ -391,7 +391,7 @@ brw_postdraw_set_buffers_need_resolve(struct brw_context *brw)
    }
 
    if (ctx->Extensions.ARB_stencil_texturing &&
-       stencil_irb && ctx->Stencil._WriteEnabled) {
+       stencil_irb && brw->stencil_write_enabled) {
       brw_render_cache_set_add_bo(brw, stencil_irb->mt->bo);
    }
 
index 0f075a11f756c1d4be5a8cc2fa78530d78b4b0d6..a93f4c503792706a10dc1deeba7b9a41b20e6e18 100644 (file)
@@ -474,7 +474,7 @@ brw_wm_populate_key(struct brw_context *brw, struct brw_wm_prog_key *key)
          lookup |= BRW_WM_IZ_DEPTH_WRITE_ENABLE_BIT;
 
       /* _NEW_STENCIL | _NEW_BUFFERS */
-      if (ctx->Stencil._Enabled) {
+      if (brw->stencil_enabled) {
          lookup |= BRW_WM_IZ_STENCIL_TEST_ENABLE_BIT;
 
          if (ctx->Stencil.WriteMask[0] ||
index d417f7c29940d8384ef6b0f08bc7976e396c4234..6c69fa8ba59bfd5d81d0f0dc078bfe81abf2bf85 100644 (file)
@@ -108,7 +108,7 @@ gen7_emit_depth_stencil_hiz(struct brw_context *brw,
    OUT_BATCH((depth_mt ? depth_mt->pitch - 1 : 0) |
              (depthbuffer_format << 18) |
              ((hiz ? 1 : 0) << 22) |
-             ((stencil_mt != NULL && ctx->Stencil._WriteEnabled) << 27) |
+             ((stencil_mt != NULL && brw->stencil_write_enabled) << 27) |
              (brw_depth_writes_enabled(brw) << 28) |
              (surftype << 29));
 
index c961c8d7aedf2ca0f665d97172d5a5b0eab795ea..29f16b7960bafb8cba3cff303e3bd31258bfdcfb 100644 (file)
@@ -219,7 +219,7 @@ gen8_emit_depth_stencil_hiz(struct brw_context *brw,
 
    emit_depth_packets(brw, depth_mt, brw_depthbuffer_format(brw), surftype,
                       brw_depth_writes_enabled(brw),
-                      stencil_mt, ctx->Stencil._WriteEnabled,
+                      stencil_mt, brw->stencil_write_enabled,
                       hiz, width, height, depth, lod, min_array_element);
 }
 
@@ -287,7 +287,7 @@ pma_fix_enable(const struct brw_context *brw)
     * !3DSTATE_DEPTH_BUFFER::Stencil Buffer Enable ||
     * !3DSTATE_STENCIL_BUFFER::Stencil Buffer Enable
     */
-   const bool stencil_writes_enabled = ctx->Stencil._WriteEnabled;
+   const bool stencil_writes_enabled = brw->stencil_write_enabled;
 
    /* 3DSTATE_PS_EXTRA::Pixel Shader Computed Depth Mode != PSCDEPTH_OFF */
    const bool ps_computes_depth =
@@ -340,7 +340,7 @@ gen8_write_pma_stall_bits(struct brw_context *brw, uint32_t pma_stall_bits)
     * Flush is also necessary.
     */
    const uint32_t render_cache_flush =
-      ctx->Stencil._WriteEnabled ? PIPE_CONTROL_RENDER_TARGET_FLUSH : 0;
+      brw->stencil_write_enabled ? PIPE_CONTROL_RENDER_TARGET_FLUSH : 0;
    brw_emit_pipe_control_flush(brw,
                                PIPE_CONTROL_CS_STALL |
                                PIPE_CONTROL_DEPTH_CACHE_FLUSH |
index 064880b8209747053d9867cb0614c97c89ed9200..8c6d3ff012e84c5bfaa8b5ed274803756b4a1b2f 100644 (file)
@@ -1182,7 +1182,7 @@ genX(upload_depth_stencil_state)(struct brw_context *brw)
          wmds.DepthTestFunction = intel_translate_compare_func(depth->Func);
       }
 
-      if (stencil->_Enabled) {
+      if (brw->stencil_enabled) {
          wmds.StencilTestEnable = true;
          wmds.StencilWriteMask = stencil->WriteMask[0] & 0xff;
          wmds.StencilTestMask = stencil->ValueMask[0] & 0xff;
@@ -1196,9 +1196,9 @@ genX(upload_depth_stencil_state)(struct brw_context *brw)
          wmds.StencilPassDepthFailOp =
             intel_translate_stencil_op(stencil->ZFailFunc[0]);
 
-         wmds.StencilBufferWriteEnable = stencil->_WriteEnabled;
+         wmds.StencilBufferWriteEnable = brw->stencil_write_enabled;
 
-         if (stencil->_TestTwoSide) {
+         if (brw->stencil_two_sided) {
             wmds.DoubleSidedStencilEnable = true;
             wmds.BackfaceStencilWriteMask = stencil->WriteMask[b] & 0xff;
             wmds.BackfaceStencilTestMask = stencil->ValueMask[b] & 0xff;
index d4f86fdffe07c6e6600566f459964c44afc17f43..e2babf83c471ef2ff6e50e86905009f98eb7e021 100644 (file)
@@ -26,6 +26,7 @@
 #include "main/accum.h"
 #include "main/enums.h"
 #include "main/state.h"
+#include "main/stencil.h"
 #include "main/bufferobj.h"
 #include "main/context.h"
 #include "swrast/swrast.h"
@@ -107,7 +108,7 @@ intel_check_blit_fragment_ops(struct gl_context * ctx, bool src_alpha_is_one)
       return false;
    }
 
-   if (ctx->Stencil._Enabled) {
+   if (_mesa_stencil_is_enabled(ctx)) {
       DBG("fallback due to image stencil\n");
       return false;
    }
index 05c35bd61b338cb94dd5ec1d486891f8e2ebd880..986707c9d80f3a1cc33986499e0b6f213a1c2acc 100644 (file)
@@ -25,6 +25,7 @@
 
 #include "main/image.h"
 #include "main/state.h"
+#include "main/stencil.h"
 #include "main/mtypes.h"
 #include "main/condrender.h"
 #include "main/fbobject.h"
@@ -115,7 +116,7 @@ do_blit_copypixels(struct gl_context * ctx,
       return false;
    }
 
-   if (ctx->Stencil._Enabled) {
+   if (brw->stencil_enabled) {
       perf_debug("glCopyPixels(): Unsupported stencil test state\n");
       return false;
    }
index fbcc840f8913f921f6056076e7e2f4c61bbe0a2e..69664fb40ad2fefd9a21a8259ccda15384722c40 100644 (file)
@@ -175,7 +175,7 @@ nv04_emit_control(struct gl_context *ctx, int emit)
        if (ctx->Stencil.WriteMask[0])
                nv04->ctrl[0] |= NV04_MULTITEX_TRIANGLE_CONTROL0_STENCIL_WRITE;
 
-       if (ctx->Stencil._Enabled)
+       if (_mesa_stencil_is_enabled(ctx))
                nv04->ctrl[1] |= NV04_MULTITEX_TRIANGLE_CONTROL1_STENCIL_ENABLE;
 
        nv04->ctrl[1] |= get_comparison_op(ctx->Stencil.Function[0]) << 4 |
index ffde87ab27be4b4096fe329b04a7668378f18f7f..d537f7bc22901e8a1321dc8710c0ffd39a085520 100644 (file)
@@ -145,7 +145,7 @@ nv10_emit_stencil_func(struct gl_context *ctx, int emit)
        struct nouveau_pushbuf *push = context_push(ctx);
 
        BEGIN_NV04(push, NV10_3D(STENCIL_ENABLE), 1);
-       PUSH_DATAb(push, ctx->Stencil._Enabled);
+       PUSH_DATAb(push, _mesa_stencil_is_enabled(ctx));
 
        BEGIN_NV04(push, NV10_3D(STENCIL_FUNC_FUNC), 3);
        PUSH_DATA (push, nvgl_comparison_op(ctx->Stencil.Function[0]));
index ee4d5f80418df68d08236cc2e93437832c0bfc93..6e4b4c48808bcef5e36f083b058e6a836c3e9048 100644 (file)
@@ -306,7 +306,6 @@ void radeon_draw_buffer(struct gl_context *ctx, struct gl_framebuffer *fb)
        if (ctx->Driver.Enable) {
                ctx->Driver.Enable(ctx, GL_DEPTH_TEST,
                                   (ctx->Depth.Test && fb->Visual.depthBits > 0));
-               /* Need to update the derived ctx->Stencil._Enabled first */
                ctx->Driver.Enable(ctx, GL_STENCIL_TEST,
                                   (ctx->Stencil.Enabled && fb->Visual.stencilBits > 0));
        } else {
index 65f638b89e692b788d8b3a3b9fc85b178f658dbf..8872c38a02b8f7078bf97e3bd3f537a834d04cef 100644 (file)
@@ -856,9 +856,6 @@ 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 _WriteEnabled;     /**< _Enabled and non-zero writemasks */
-   GLboolean _TestTwoSide;
    GLubyte _BackFace;           /**< Current back stencil state (1 or 2) */
    GLenum Function[3];         /**< Stencil function */
    GLenum FailFunc[3];         /**< Fail function */
index b7e165fab6209bb2edee68925df5b071f97b7b1c..d1d0c2cd998daa3b740c97a8835fd75ad530af96 100644 (file)
@@ -379,9 +379,6 @@ _mesa_update_state_locked( struct gl_context *ctx )
    if (new_state & (_NEW_LIGHT | _NEW_PROGRAM))
       update_twoside( ctx );
 
-   if (new_state & (_NEW_STENCIL | _NEW_BUFFERS))
-      _mesa_update_stencil( ctx );
-
    if (new_state & _NEW_PIXEL)
       _mesa_update_pixel( ctx );
 
index 4bd7b8803efa2c8759b0a23448915eb948bde939..612ad38dcc1472ea2862b008fffed0e919ad56df 100644 (file)
@@ -606,34 +606,6 @@ _mesa_StencilMaskSeparate(GLenum face, GLuint mask)
 }
 
 
-/**
- * Update derived stencil state.
- */
-void
-_mesa_update_stencil(struct gl_context *ctx)
-{
-   const GLint face = ctx->Stencil._BackFace;
-
-   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] ||
-       ctx->Stencil.ZFailFunc[0] != ctx->Stencil.ZFailFunc[face] ||
-       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));
-}
-
-
 /**
  * Initialize the context stipple state.
  *
index ccb864691893b477006c41e36f70b54c4971d780..dc371ec36cd8a7e4f9a9f4d22c655fcd0e973721 100644 (file)
@@ -86,11 +86,6 @@ _mesa_StencilMaskSeparate_no_error(GLenum face, GLuint mask);
 extern void GLAPIENTRY
 _mesa_StencilMaskSeparate(GLenum face, GLuint mask);
 
-
-extern void
-_mesa_update_stencil(struct gl_context *ctx);
-
-
 extern void 
 _mesa_init_stencil( struct gl_context * ctx );
 
@@ -108,4 +103,35 @@ _mesa_get_stencil_ref(struct gl_context const *ctx, int face)
    return CLAMP(ref, 0, stencilMax);
 }
 
+static inline bool
+_mesa_stencil_is_enabled(const struct gl_context *ctx)
+{
+   return ctx->Stencil.Enabled &&
+          ctx->DrawBuffer->Visual.stencilBits > 0;
+}
+
+static inline bool
+_mesa_stencil_is_two_sided(const struct gl_context *ctx)
+{
+   const int face = ctx->Stencil._BackFace;
+
+   return _mesa_stencil_is_enabled(ctx) &&
+          (ctx->Stencil.Function[0] != ctx->Stencil.Function[face] ||
+           ctx->Stencil.FailFunc[0] != ctx->Stencil.FailFunc[face] ||
+           ctx->Stencil.ZPassFunc[0] != ctx->Stencil.ZPassFunc[face] ||
+           ctx->Stencil.ZFailFunc[0] != ctx->Stencil.ZFailFunc[face] ||
+           ctx->Stencil.Ref[0] != ctx->Stencil.Ref[face] ||
+           ctx->Stencil.ValueMask[0] != ctx->Stencil.ValueMask[face] ||
+           ctx->Stencil.WriteMask[0] != ctx->Stencil.WriteMask[face]);
+}
+
+static inline bool
+_mesa_stencil_is_write_enabled(const struct gl_context *ctx, bool is_two_sided)
+{
+   return _mesa_stencil_is_enabled(ctx) &&
+          (ctx->Stencil.WriteMask[0] != 0 ||
+           (is_two_sided &&
+            ctx->Stencil.WriteMask[ctx->Stencil._BackFace] != 0));
+}
+
 #endif
index 432de4bde3d002e600fd2b115aec3a5937039ebb..3b2beaf6ed76abf5467916a90b6149cd7d2c39dc 100644 (file)
@@ -128,7 +128,7 @@ st_update_depth_stencil_alpha(struct st_context *st)
       dsa->stencil[0].writemask = ctx->Stencil.WriteMask[0] & 0xff;
       sr.ref_value[0] = _mesa_get_stencil_ref(ctx, 0);
 
-      if (ctx->Stencil._TestTwoSide) {
+      if (_mesa_stencil_is_two_sided(ctx)) {
          const GLuint back = ctx->Stencil._BackFace;
          dsa->stencil[1].enabled = 1;
          dsa->stencil[1].func = st_compare_func_to_pipe(ctx->Stencil.Function[back]);
index 9cb03b38c01cb96090331f455d655acd7acbca60..71389c698f242398587a26611b2a95d1508ad2f5 100644 (file)
@@ -29,6 +29,7 @@
 #include "main/bufferobj.h"
 #include "main/mtypes.h"
 #include "main/samplerobj.h"
+#include "main/stencil.h"
 #include "main/teximage.h"
 #include "program/prog_parameter.h"
 #include "program/prog_statevars.h"
@@ -61,7 +62,7 @@ _swrast_update_rasterflags( struct gl_context *ctx )
    if (ctx->Depth.Test)                   rasterMask |= DEPTH_BIT;
    if (swrast->_FogEnabled)               rasterMask |= FOG_BIT;
    if (ctx->Scissor.EnableFlags)          rasterMask |= CLIP_BIT;
-   if (ctx->Stencil._Enabled)             rasterMask |= STENCIL_BIT;
+   if (_mesa_stencil_is_enabled(ctx))     rasterMask |= STENCIL_BIT;
    for (i = 0; i < ctx->Const.MaxDrawBuffers; i++) {
       if (!ctx->Color.ColorMask[i][0] ||
           !ctx->Color.ColorMask[i][1] ||
index 49fc580fb1df3d21ccd0ece7e1e7288111a4e8ed..81835636a57d8743757eb311799ffe3e3df9e849 100644 (file)
@@ -39,6 +39,7 @@
 #include "main/imports.h"
 #include "main/image.h"
 #include "main/samplerobj.h"
+#include "main/stencil.h"
 #include "main/teximage.h"
 
 #include "s_atifragshader.h"
@@ -1213,14 +1214,14 @@ _swrast_write_rgba_span( struct gl_context *ctx, SWspan *span)
    }
 
    /* Stencil and Z testing */
-   if (ctx->Stencil._Enabled || ctx->Depth.Test) {
+   if (_mesa_stencil_is_enabled(ctx) || ctx->Depth.Test) {
       if (!(span->arrayMask & SPAN_Z))
          _swrast_span_interpolate_z(ctx, span);
 
       if (ctx->Transform.DepthClamp)
         _swrast_depth_clamp_span(ctx, span);
 
-      if (ctx->Stencil._Enabled) {
+      if (_mesa_stencil_is_enabled(ctx)) {
          /* Combined Z/stencil tests */
          if (!_swrast_stencil_and_ztest_span(ctx, span)) {
             /* all fragments failed test */
index 876a74b086304e4d3e8040ffbd43340d1e56b199..9e4f81e0e0ab5c59614cb4d33dea6af6b7abbe42 100644 (file)
@@ -36,6 +36,7 @@
 #include "main/mtypes.h"
 #include "main/state.h"
 #include "main/samplerobj.h"
+#include "main/stencil.h"
 #include "main/teximage.h"
 #include "program/prog_instruction.h"
 
@@ -1023,7 +1024,7 @@ _swrast_choose_triangle( struct gl_context *ctx )
           ctx->Depth.Test &&
           ctx->Depth.Mask == GL_FALSE &&
           ctx->Depth.Func == GL_LESS &&
-          !ctx->Stencil._Enabled &&
+          !_mesa_stencil_is_enabled(ctx) &&
           depthRb &&
           depthRb->Format == MESA_FORMAT_Z_UNORM16) {
          if (ctx->Color.ColorMask[0][0] == 0 &&
index b92c20be2b751c8f2ba3af682e13d51181c83fec..8f034d8aaf0c12402211af689ddd7d691cd2f825 100644 (file)
@@ -29,6 +29,7 @@
 #include "main/glheader.h"
 #include "main/macros.h"
 #include "main/mtypes.h"
+#include "main/stencil.h"
 
 #include "tnl/t_context.h"
 
@@ -255,7 +256,7 @@ void _swsetup_choose_trifuncs( struct gl_context *ctx )
     */
    if (ctx->Polygon.FrontMode != GL_FILL ||
        ctx->Polygon.BackMode != GL_FILL ||
-       (ctx->Stencil.Enabled && ctx->Stencil._TestTwoSide))
+       (ctx->Stencil.Enabled && _mesa_stencil_is_two_sided(ctx)))
       ind |= SS_UNFILLED_BIT;
 
    tnl->Driver.Render.Triangle = tri_tab[ind];