[Mesa-dev] [PATCH 10/11] mesa: remove DD_TRI_LIGHT_TWOSIDE flag

Brian Paul brianp at vmware.com
Tue Apr 16 18:14:55 PDT 2013


v2: use conditional operator instead of bit shifting
---
 src/mesa/drivers/dri/i915/intel_tris.c     |    3 +++
 src/mesa/drivers/dri/r200/r200_swtcl.c     |   12 +++++++-----
 src/mesa/drivers/dri/radeon/radeon_swtcl.c |   11 +++++++----
 src/mesa/main/debug.c                      |   12 ------------
 src/mesa/main/debug.h                      |    1 -
 src/mesa/main/enable.c                     |    4 ----
 src/mesa/main/light.c                      |    4 ----
 src/mesa/main/mtypes.h                     |   10 ----------
 src/mesa/main/state.c                      |   27 ---------------------------
 src/mesa/tnl/t_vertex.c                    |   12 ++++++------
 10 files changed, 23 insertions(+), 73 deletions(-)

diff --git a/src/mesa/drivers/dri/i915/intel_tris.c b/src/mesa/drivers/dri/i915/intel_tris.c
index 9a9c56f..07c73f5 100644
--- a/src/mesa/drivers/dri/i915/intel_tris.c
+++ b/src/mesa/drivers/dri/i915/intel_tris.c
@@ -943,6 +943,7 @@ intelFastRenderClippedPoly(struct gl_context * ctx, const GLuint * elts, GLuint
 /**********************************************************************/
 
 
+#define DD_TRI_LIGHT_TWOSIDE (1 << 1)
 #define DD_TRI_UNFILLED (1 << 2)
 #define DD_TRI_STIPPLE  (1 << 4)
 #define DD_TRI_OFFSET   (1 << 5)
@@ -958,6 +959,8 @@ intelChooseRenderState(struct gl_context * ctx)
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct intel_context *intel = intel_context(ctx);
    GLuint flags = ctx->_TriangleCaps |
+      ((ctx->Light.Enabled &&
+        ctx->Light.Model.TwoSide) ? DD_TRI_LIGHT_TWOSIDE : 0) |
       ((ctx->Polygon.FrontMode != GL_FILL ||
         ctx->Polygon.BackMode != GL_FILL) ? DD_TRI_UNFILLED : 0) |
       (ctx->Polygon.StippleFlag ? DD_TRI_STIPPLE : 0) |
diff --git a/src/mesa/drivers/dri/r200/r200_swtcl.c b/src/mesa/drivers/dri/r200/r200_swtcl.c
index c9860f5..9fdb16d 100644
--- a/src/mesa/drivers/dri/r200/r200_swtcl.c
+++ b/src/mesa/drivers/dri/r200/r200_swtcl.c
@@ -241,6 +241,7 @@ void r200ChooseVertexState( struct gl_context *ctx )
    GLuint vap;
    GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
                          ctx->Polygon.BackMode != GL_FILL);
+   GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
 
    /* We must ensure that we don't do _tnl_need_projected_coords while in a
     * rasterization fallback.  As this function will be called again when we
@@ -256,8 +257,7 @@ void r200ChooseVertexState( struct gl_context *ctx )
     * bigger one.
     */
    if ((0 == (tnl->render_inputs_bitset & BITFIELD64_RANGE(_TNL_ATTRIB_TEX0, _TNL_NUM_TEX)))
-       || (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
-      || unfilled) {
+       || twosided || unfilled) {
       rmesa->swtcl.needproj = GL_TRUE;
       vte |= R200_VTX_XY_FMT | R200_VTX_Z_FMT;
       vte &= ~R200_VTX_W0_FMT;
@@ -573,15 +573,17 @@ void r200ChooseRenderState( struct gl_context *ctx )
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    r200ContextPtr rmesa = R200_CONTEXT(ctx);
    GLuint index = 0;
-   GLuint flags = ctx->_TriangleCaps;
    GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
                          ctx->Polygon.BackMode != GL_FILL);
+   GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
 
    if (!rmesa->radeon.TclFallback || rmesa->radeon.Fallback)
       return;
 
-   if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R200_TWOSIDE_BIT;
-   if (unfilled)                     index |= R200_UNFILLED_BIT;
+   if (twosided)
+      index |= R200_TWOSIDE_BIT;
+   if (unfilled)
+      index |= R200_UNFILLED_BIT;
 
    if (index != rmesa->radeon.swtcl.RenderIndex) {
       tnl->Driver.Render.Points = rast_tab[index].points;
diff --git a/src/mesa/drivers/dri/radeon/radeon_swtcl.c b/src/mesa/drivers/dri/radeon/radeon_swtcl.c
index ed452df..1e80162 100644
--- a/src/mesa/drivers/dri/radeon/radeon_swtcl.c
+++ b/src/mesa/drivers/dri/radeon/radeon_swtcl.c
@@ -275,6 +275,7 @@ void radeonChooseVertexState( struct gl_context *ctx )
    GLuint se_coord_fmt = rmesa->hw.set.cmd[SET_SE_COORDFMT];
    GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
                          ctx->Polygon.BackMode != GL_FILL);
+   GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
    
    se_coord_fmt &= ~(RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
 		     RADEON_VTX_Z_PRE_MULT_1_OVER_W0 |
@@ -294,7 +295,7 @@ void radeonChooseVertexState( struct gl_context *ctx )
    if ((0 == (tnl->render_inputs_bitset & 
         (BITFIELD64_RANGE(_TNL_ATTRIB_TEX0, _TNL_NUM_TEX)
          | BITFIELD64_BIT(_TNL_ATTRIB_COLOR1))))
-       || (ctx->_TriangleCaps & DD_TRI_LIGHT_TWOSIDE)
+       || twosided
        || unfilled) {
       rmesa->swtcl.needproj = GL_TRUE;
       se_coord_fmt |= (RADEON_VTX_XY_PRE_MULT_1_OVER_W0 |
@@ -696,15 +697,17 @@ void radeonChooseRenderState( struct gl_context *ctx )
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
    GLuint index = 0;
-   GLuint flags = ctx->_TriangleCaps;
    GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
                          ctx->Polygon.BackMode != GL_FILL);
+   GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
 
    if (!rmesa->radeon.TclFallback || rmesa->radeon.Fallback) 
       return;
 
-   if (flags & DD_TRI_LIGHT_TWOSIDE) index |= RADEON_TWOSIDE_BIT;
-   if (unfilled)                     index |= RADEON_UNFILLED_BIT;
+   if (twosided)
+      index |= RADEON_TWOSIDE_BIT;
+   if (unfilled)
+      index |= RADEON_UNFILLED_BIT;
 
    if (index != rmesa->radeon.swtcl.RenderIndex) {
       tnl->Driver.Render.Points = rast_tab[index].points;
diff --git a/src/mesa/main/debug.c b/src/mesa/main/debug.c
index e8d850d..5dda766 100644
--- a/src/mesa/main/debug.c
+++ b/src/mesa/main/debug.c
@@ -96,18 +96,6 @@ _mesa_print_state( const char *msg, GLuint state )
 
 
 
-void
-_mesa_print_tri_caps( const char *name, GLuint flags )
-{
-   _mesa_debug(NULL,
-	   "%s: (0x%x) %s\n",
-	   name,
-	   flags,
-	   (flags & DD_TRI_LIGHT_TWOSIDE)   ? "tri-light-twoside, " : ""
-      );
-}
-
-
 /**
  * Print information about this Mesa version and build options.
  */
diff --git a/src/mesa/main/debug.h b/src/mesa/main/debug.h
index 6bc5365..4fbfaff 100644
--- a/src/mesa/main/debug.h
+++ b/src/mesa/main/debug.h
@@ -42,7 +42,6 @@
 struct gl_context;
 struct gl_texture_image;
 
-extern void _mesa_print_tri_caps( const char *name, GLuint flags );
 extern void _mesa_print_enable_flags( const char *msg, GLuint flags );
 extern void _mesa_print_state( const char *msg, GLuint state );
 extern void _mesa_print_info( void );
diff --git a/src/mesa/main/enable.c b/src/mesa/main/enable.c
index 22a75c8..fb2a196 100644
--- a/src/mesa/main/enable.c
+++ b/src/mesa/main/enable.c
@@ -419,10 +419,6 @@ _mesa_set_enable(struct gl_context *ctx, GLenum cap, GLboolean state)
             return;
          FLUSH_VERTICES(ctx, _NEW_LIGHT);
          ctx->Light.Enabled = state;
-         if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
-            ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
-         else
-            ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
          break;
       case GL_LINE_SMOOTH:
          if (!_mesa_is_desktop_gl(ctx) && ctx->API != API_OPENGLES)
diff --git a/src/mesa/main/light.c b/src/mesa/main/light.c
index c694beb..41773d8 100644
--- a/src/mesa/main/light.c
+++ b/src/mesa/main/light.c
@@ -474,10 +474,6 @@ _mesa_LightModelfv( GLenum pname, const GLfloat *params )
 	    return;
 	 FLUSH_VERTICES(ctx, _NEW_LIGHT);
 	 ctx->Light.Model.TwoSide = newbool;
-         if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
-            ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
-         else
-            ctx->_TriangleCaps &= ~DD_TRI_LIGHT_TWOSIDE;
          break;
       case GL_LIGHT_MODEL_COLOR_CONTROL:
          if (ctx->API != API_OPENGL_COMPAT)
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index d6c2b35..68afc24 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3162,16 +3162,6 @@ struct gl_matrix_stack
 
 
 /**
- * \name A bunch of flags that we think might be useful to drivers.
- * 
- * Set in the __struct gl_contextRec::_TriangleCaps bitfield.
- */
-/*@{*/
-#define DD_TRI_LIGHT_TWOSIDE        (1 << 1)
-/*@}*/
-
-
-/**
  * Composite state flags
  */
 /*@{*/
diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c
index da7f713..01a7f95 100644
--- a/src/mesa/main/state.c
+++ b/src/mesa/main/state.c
@@ -315,27 +315,6 @@ update_twoside(struct gl_context *ctx)
 
 
 /**
- * Update the ctx->_TriangleCaps bitfield.
- * XXX that bitfield should really go away someday!
- * This function must be called after other update_*() functions since
- * there are dependencies on some other derived values.
- */
-#if 0
-static void
-update_tricaps(struct gl_context *ctx, GLbitfield new_state)
-{
-   ctx->_TriangleCaps = 0;
-
-   /*
-    * Lighting and shading
-    */
-   if (ctx->Light.Enabled && ctx->Light.Model.TwoSide)
-      ctx->_TriangleCaps |= DD_TRI_LIGHT_TWOSIDE;
-}
-#endif
-
-
-/**
  * Compute derived GL state.
  * If __struct gl_contextRec::NewState is non-zero then this function \b must
  * be called before rendering anything.
@@ -411,12 +390,6 @@ _mesa_update_state_locked( struct gl_context *ctx )
    if (new_state & (_NEW_MULTISAMPLE | _NEW_BUFFERS))
       update_multisample( ctx );
 
-#if 0
-   if (new_state & (_NEW_POINT | _NEW_LINE | _NEW_POLYGON | _NEW_LIGHT
-                    | _NEW_STENCIL | _MESA_NEW_SEPARATE_SPECULAR))
-      update_tricaps( ctx, new_state );
-#endif
-
    /* ctx->_NeedEyeCoords is now up to date.
     *
     * If the truth value of this variable has changed, update for the
diff --git a/src/mesa/tnl/t_vertex.c b/src/mesa/tnl/t_vertex.c
index a42f460..c7a745e 100644
--- a/src/mesa/tnl/t_vertex.c
+++ b/src/mesa/tnl/t_vertex.c
@@ -158,9 +158,9 @@ static void choose_interp_func( struct gl_context *ctx,
    struct tnl_clipspace *vtx = GET_VERTEX_STATE(ctx);
    GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
                          ctx->Polygon.BackMode != GL_FILL);
-   if (vtx->need_extras && 
-       ((ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE) ||
-         unfilled))) {
+   GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
+
+   if (vtx->need_extras && (twosided || unfilled)) {
       vtx->interp = _tnl_generic_interp_extras;
    } else {
       vtx->interp = _tnl_generic_interp;
@@ -176,9 +176,9 @@ static void choose_copy_pv_func(  struct gl_context *ctx, GLuint edst, GLuint es
    GLboolean unfilled = (ctx->Polygon.FrontMode != GL_FILL ||
                          ctx->Polygon.BackMode != GL_FILL);
 
-   if (vtx->need_extras && 
-       ((ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE) ||
-         unfilled))) {
+   GLboolean twosided = ctx->Light.Enabled && ctx->Light.Model.TwoSide;
+
+   if (vtx->need_extras && (twosided || unfilled)) {
       vtx->copy_pv = _tnl_generic_copy_pv_extras;
    } else {
       vtx->copy_pv = _tnl_generic_copy_pv;
-- 
1.7.3.4



More information about the mesa-dev mailing list