[Mesa-dev] [PATCH 01/29] mesa: Add gl_point_attrib::CoordReplaceBits bitfield.

Mathias.Froehlich at gmx.net Mathias.Froehlich at gmx.net
Tue May 24 06:41:57 UTC 2016


From: Mathias Fröhlich <mathias.froehlich at web.de>

The aim is to replace the CoordReplace array by
a bitfield. Until all drivers are converted,
establish the bitfield in paralell to the
CoordReplace array.

Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
---
 src/mesa/main/attrib.c        |  2 +-
 src/mesa/main/ffvertex_prog.c |  2 +-
 src/mesa/main/mtypes.h        |  1 +
 src/mesa/main/points.c        |  1 +
 src/mesa/main/texenv.c        | 34 ++++++++++++++++++++++------------
 5 files changed, 26 insertions(+), 14 deletions(-)

diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c
index 61f7036..6f39cb0 100644
--- a/src/mesa/main/attrib.c
+++ b/src/mesa/main/attrib.c
@@ -1247,7 +1247,7 @@ _mesa_PopAttrib(void)
                   GLuint u;
                   for (u = 0; u < ctx->Const.MaxTextureUnits; u++) {
                      _mesa_TexEnvi(GL_POINT_SPRITE_NV, GL_COORD_REPLACE_NV,
-                                   (GLint) point->CoordReplace[u]);
+                                   !!(point->CoordReplaceBits & (1u << u)));
                   }
                   _mesa_set_enable(ctx, GL_POINT_SPRITE_NV,point->PointSprite);
                   if (ctx->Extensions.NV_point_sprite)
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index d72bc71..adf71dc 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -243,7 +243,7 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key )
 	 key->unit[i].texunit_really_enabled = 1;
 
       if (ctx->Point.PointSprite)
-	 if (ctx->Point.CoordReplace[i])
+	 if (ctx->Point.CoordReplaceBits & (1u << i))
 	    key->unit[i].coord_replace = 1;
 
       if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i))
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index f6c6d97..e714239 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -757,6 +757,7 @@ struct gl_point_attrib
    GLboolean _Attenuated;	/**< True if Params != [1, 0, 0] */
    GLboolean PointSprite;	/**< GL_NV/ARB_point_sprite */
    GLboolean CoordReplace[MAX_TEXTURE_COORD_UNITS]; /**< GL_ARB_point_sprite*/
+   GLbitfield CoordReplaceBits; /**< GL_ARB_point_sprite*/
    GLenum SpriteRMode;		/**< GL_NV_point_sprite (only!) */
    GLenum SpriteOrigin;		/**< GL_ARB_point_sprite */
 };
diff --git a/src/mesa/main/points.c b/src/mesa/main/points.c
index c2f2b63..3fbd5d3 100644
--- a/src/mesa/main/points.c
+++ b/src/mesa/main/points.c
@@ -256,4 +256,5 @@ _mesa_init_point(struct gl_context *ctx)
    for (i = 0; i < ARRAY_SIZE(ctx->Point.CoordReplace); i++) {
       ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB/NV_point_sprite */
    }
+   ctx->Point.CoordReplaceBits = 0; /* GL_ARB/NV_point_sprite */
 }
diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c
index 93c6806..0556b75 100644
--- a/src/mesa/main/texenv.c
+++ b/src/mesa/main/texenv.c
@@ -460,20 +460,24 @@ _mesa_TexEnvfv( GLenum target, GLenum pname, const GLfloat *param )
 	 return;
       }
       if (pname == GL_COORD_REPLACE_NV) {
-         if (iparam0 == GL_TRUE || iparam0 == GL_FALSE) {
-            /* It's kind of weird to set point state via glTexEnv,
-             * but that's what the spec calls for.
-             */
-            const GLboolean state = (GLboolean) iparam0;
-            if (ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] == state)
+         /* It's kind of weird to set point state via glTexEnv,
+          * but that's what the spec calls for.
+          */
+         if (iparam0 == GL_TRUE) {
+            if (ctx->Point.CoordReplaceBits & (1u << ctx->Texture.CurrentUnit))
                return;
-            FLUSH_VERTICES(ctx, _NEW_POINT);
-            ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = state;
-         }
-         else {
+            ctx->Point.CoordReplaceBits |= (1u << ctx->Texture.CurrentUnit);
+            ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = GL_TRUE;
+         } else if (iparam0 == GL_FALSE) {
+            if (~(ctx->Point.CoordReplaceBits) & (1u << ctx->Texture.CurrentUnit))
+               return;
+            ctx->Point.CoordReplaceBits &= (1u << ctx->Texture.CurrentUnit);
+            ctx->Point.CoordReplace[ctx->Texture.CurrentUnit] = GL_FALSE;
+         } else {
             _mesa_error( ctx, GL_INVALID_VALUE, "glTexEnv(param=0x%x)", iparam0);
             return;
          }
+         FLUSH_VERTICES(ctx, _NEW_POINT);
       }
       else {
          _mesa_error( ctx, GL_INVALID_ENUM, "glTexEnv(pname=0x%x)", pname );
@@ -675,7 +679,10 @@ _mesa_GetTexEnvfv( GLenum target, GLenum pname, GLfloat *params )
          return;
       }
       if (pname == GL_COORD_REPLACE_NV) {
-         *params = (GLfloat) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit];
+         if (ctx->Point.CoordReplaceBits & (1u << ctx->Texture.CurrentUnit))
+            *params = 1.0f;
+         else
+            *params = 0.0f;
       }
       else {
          _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnvfv(pname)" );
@@ -736,7 +743,10 @@ _mesa_GetTexEnviv( GLenum target, GLenum pname, GLint *params )
          return;
       }
       if (pname == GL_COORD_REPLACE_NV) {
-         *params = (GLint) ctx->Point.CoordReplace[ctx->Texture.CurrentUnit];
+         if (ctx->Point.CoordReplaceBits & (1u << ctx->Texture.CurrentUnit))
+            *params = GL_TRUE;
+         else
+            *params = GL_FALSE;
       }
       else {
          _mesa_error( ctx, GL_INVALID_ENUM, "glGetTexEnviv(pname)" );
-- 
2.5.5



More information about the mesa-dev mailing list