[Mesa-dev] [PATCH 5/5] mesa: Convert to use GLbitfield64 directly.

Mathias Fröhlich Mathias.Froehlich at gmx.net
Mon Dec 26 01:29:44 PST 2011


Signed-off-by: Mathias Froehlich <Mathias.Froehlich at web.de>
---
 src/mesa/swrast_setup/ss_context.c |   30 +++++++++++++-----------------
 src/mesa/swrast_setup/ss_context.h |    2 +-
 src/mesa/tnl/t_context.c           |   20 +++++++++-----------
 src/mesa/tnl/t_context.h           |   14 +-------------
 4 files changed, 24 insertions(+), 42 deletions(-)

diff --git a/src/mesa/swrast_setup/ss_context.c 
b/src/mesa/swrast_setup/ss_context.c
index 5da2e1e..9c013a4 100644
--- a/src/mesa/swrast_setup/ss_context.c
+++ b/src/mesa/swrast_setup/ss_context.c
@@ -118,38 +118,35 @@ setup_vertex_format(struct gl_context *ctx)
                       && CHAN_TYPE != GL_FLOAT;
 
    if (intColors != swsetup->intColors ||
-       !RENDERINPUTS_EQUAL(tnl->render_inputs_bitset,
-                           swsetup->last_index_bitset)) {
-      DECLARE_RENDERINPUTS(index_bitset);
+       tnl->render_inputs_bitset != swsetup->last_index_bitset) {
+      GLbitfield64 index_bitset = tnl->render_inputs_bitset;
       struct tnl_attr_map map[_TNL_ATTRIB_MAX];
       unsigned int i, e = 0;
 
       swsetup->intColors = intColors;
 
-      RENDERINPUTS_COPY( index_bitset, tnl->render_inputs_bitset );
-
       EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_4F_VIEWPORT, attrib[FRAG_ATTRIB_WPOS] 
);
 
-      if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR0 )) {
+      if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_COLOR0)) {
          if (swsetup->intColors)
             EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4CHAN_4F_RGBA, color );
          else
             EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4F, 
attrib[FRAG_ATTRIB_COL0]);
       }
 
-      if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_COLOR1 )) {
+      if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_COLOR1)) {
          EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_4F, attrib[FRAG_ATTRIB_COL1]);
       }
 
-      if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_FOG )) {
+      if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_FOG)) {
          const GLint emit = ctx->FragmentProgram._Current ? EMIT_4F : 
EMIT_1F;
          EMIT_ATTR( _TNL_ATTRIB_FOG, emit, attrib[FRAG_ATTRIB_FOGC]);
       }
 
-      if (RENDERINPUTS_TEST_RANGE(index_bitset, _TNL_FIRST_TEX, 
_TNL_LAST_TEX))
+      if (index_bitset & BITFIELD64_RANGE(_TNL_ATTRIB_TEX0, _TNL_NUM_TEX))
       {
          for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
-            if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_TEX(i) )) {
+            if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_TEX(i))) {
                EMIT_ATTR( _TNL_ATTRIB_TEX(i), EMIT_4F,
                           attrib[FRAG_ATTRIB_TEX0 + i] );
             }
@@ -157,24 +154,23 @@ setup_vertex_format(struct gl_context *ctx)
       }
 
       /* shader varying vars */
-      if (RENDERINPUTS_TEST_RANGE( index_bitset,
-                                   _TNL_FIRST_GENERIC, _TNL_LAST_GENERIC )) {
+      if (index_bitset & BITFIELD64_RANGE(_TNL_ATTRIB_GENERIC0, 
_TNL_NUM_GENERIC)) {
          for (i = 0; i < ctx->Const.MaxVarying; i++) {
-            if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_GENERIC(i) )) {
+            if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_GENERIC(i))) {
                EMIT_ATTR( _TNL_ATTRIB_GENERIC(i), VARYING_EMIT_STYLE,
                           attrib[FRAG_ATTRIB_VAR0 + i] );
             }
          }
       }
 
-      if (RENDERINPUTS_TEST( index_bitset, _TNL_ATTRIB_POINTSIZE ))
+      if (index_bitset & BITFIELD64_BIT(_TNL_ATTRIB_POINTSIZE))
          EMIT_ATTR( _TNL_ATTRIB_POINTSIZE, EMIT_1F, pointSize );
 
       _tnl_install_attrs( ctx, map, e,
                           ctx->Viewport._WindowMap.m,
                           sizeof(SWvertex) );
 
-      RENDERINPUTS_COPY( swsetup->last_index_bitset, index_bitset );
+      swsetup->last_index_bitset = index_bitset;
    }
 }
 
@@ -195,7 +191,7 @@ _swsetup_RenderStart( struct gl_context *ctx )
    }
 
    if (swsetup->NewState & _NEW_PROGRAM) {
-      RENDERINPUTS_ZERO( swsetup->last_index_bitset );
+      swsetup->last_index_bitset = 0;
    }
 
    swsetup->NewState = 0;
@@ -259,7 +255,7 @@ _swsetup_Wakeup( struct gl_context *ctx )
    _swsetup_InvalidateState( ctx, ~0 );
 
    swsetup->verts = (SWvertex *)tnl->clipspace.vertex_buf;
-   RENDERINPUTS_ZERO( swsetup->last_index_bitset );
+   swsetup->last_index_bitset = 0;
 }
 
 
diff --git a/src/mesa/swrast_setup/ss_context.h 
b/src/mesa/swrast_setup/ss_context.h
index 56551ab..ecc1f5f 100644
--- a/src/mesa/swrast_setup/ss_context.h
+++ b/src/mesa/swrast_setup/ss_context.h
@@ -35,7 +35,7 @@
 typedef struct {
    GLuint NewState;
    GLenum render_prim;
-   DECLARE_RENDERINPUTS(last_index_bitset);
+   GLbitfield64 last_index_bitset;
    SWvertex *verts;
    GLboolean intColors;
 } SScontext;
diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c
index a6da8ca..1ded44c 100644
--- a/src/mesa/tnl/t_context.c
+++ b/src/mesa/tnl/t_context.c
@@ -121,20 +121,19 @@ _tnl_InvalidateState( struct gl_context *ctx, GLuint 
new_state )
    /* Calculate tnl->render_inputs.  This bitmask indicates which vertex
     * attributes need to be emitted to the rasterizer.
     */
-   RENDERINPUTS_ZERO( tnl->render_inputs_bitset );
-   RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POS );
+   tnl->render_inputs_bitset = BITFIELD64_BIT(_TNL_ATTRIB_POS);
 
    if (!fp || (fp->Base.InputsRead & FRAG_BIT_COL0)) {
-     RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR0 );
+     tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_COLOR0);
    }
 
    if (_mesa_need_secondary_color(ctx))
-     RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_COLOR1 );
+     tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_COLOR1);
 
    for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
      if (ctx->Texture._EnabledCoordUnits & (1 << i) ||
 	 (fp && fp->Base.InputsRead & FRAG_BIT_TEX(i))) {
-       RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_TEX(i) );
+       tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_TEX(i));
      }
    }
 
@@ -142,27 +141,26 @@ _tnl_InvalidateState( struct gl_context *ctx, GLuint 
new_state )
        || (fp != NULL && (fp->Base.InputsRead & FRAG_BIT_FOGC) != 0)) {
       /* Either fixed-function fog or a fragment program needs fog coord.
        */
-      RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_FOG );
+      tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_FOG);
    }
 
    if (ctx->Polygon.FrontMode != GL_FILL || 
        ctx->Polygon.BackMode != GL_FILL)
-      RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_EDGEFLAG );
+      tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_EDGEFLAG);
 
    if (ctx->RenderMode == GL_FEEDBACK)
-      RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_TEX0 );
+      tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_TEX0);
 
    if (ctx->Point._Attenuated ||
        (ctx->VertexProgram._Enabled && ctx->VertexProgram.PointSizeEnabled))
-      RENDERINPUTS_SET( tnl->render_inputs_bitset, _TNL_ATTRIB_POINTSIZE );
+      tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_POINTSIZE);
 
    /* check for varying vars which are written by the vertex program */
    if (vp) {
       GLuint i;
       for (i = 0; i < MAX_VARYING; i++) {
 	 if (vp->Base.OutputsWritten & BITFIELD64_BIT(VERT_RESULT_VAR0 + i)) {
-            RENDERINPUTS_SET(tnl->render_inputs_bitset,
-                             _TNL_ATTRIB_GENERIC(i));
+            tnl->render_inputs_bitset |= 
BITFIELD64_BIT(_TNL_ATTRIB_GENERIC(i));
          }
       }
    }
diff --git a/src/mesa/tnl/t_context.h b/src/mesa/tnl/t_context.h
index cdeeb1b..18ed153 100644
--- a/src/mesa/tnl/t_context.h
+++ b/src/mesa/tnl/t_context.h
@@ -482,18 +482,6 @@ struct tnl_device_driver
 };
 
 
-#define DECLARE_RENDERINPUTS(name) GLbitfield64 name
-#define RENDERINPUTS_COPY(x, y) do { (x) = (y); } while (0)
-#define RENDERINPUTS_EQUAL(x, y) ((x) == (y))
-#define RENDERINPUTS_ZERO(x) do { (x) = 0; } while (0)
-#define RENDERINPUTS_ONES(x) do { (x) = ~(GLbitfield64)0; } while (0)
-#define RENDERINPUTS_TEST(x, b) (((x) & BITFIELD64_BIT(b)) != 0)
-#define RENDERINPUTS_SET(x, b) ((x) |= BITFIELD64_BIT(b))
-#define RENDERINPUTS_CLEAR(x, b) ((x) &= ~BITFIELD64_BIT(b))
-#define RENDERINPUTS_TEST_RANGE(x, b, e) \
-   (((x) & BITFIELD64_RANGE((b), (e) - (b) + 1)) != 0)
-
-
 /**
  * Context state for T&L context.
  */
@@ -519,7 +507,7 @@ typedef struct
    GLboolean AllowPixelFog;
    GLboolean _DoVertexFog;  /* eval fog function at each vertex? */
 
-   DECLARE_RENDERINPUTS(render_inputs_bitset);
+   GLbitfield64 render_inputs_bitset;
 
    GLvector4f tmp_inputs[VERT_ATTRIB_MAX];
 
-- 
1.7.4.4



More information about the mesa-dev mailing list