[Mesa-dev] [PATCH 17/29] mesa: Use bitmask/ffs to build ff vertex shader keys.
Mathias.Froehlich at gmx.net
Mathias.Froehlich at gmx.net
Tue May 24 06:42:13 UTC 2016
From: Mathias Fröhlich <mathias.froehlich at web.de>
Replaces an iterate and test bit in a bitmask loop by a
loop only iterating over the bits set in the bitmask.
The bitmask used here for iteration is a combination
of different enabled masks present for texture units.
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
---
src/mesa/main/ffvertex_prog.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/mesa/main/ffvertex_prog.c b/src/mesa/main/ffvertex_prog.c
index bcfc999..c6032ce 100644
--- a/src/mesa/main/ffvertex_prog.c
+++ b/src/mesa/main/ffvertex_prog.c
@@ -149,7 +149,6 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key )
{
const struct gl_fragment_program *fp;
GLbitfield mask;
- GLuint i;
memset(key, 0, sizeof(struct state_key));
fp = ctx->FragmentProgram._Current;
@@ -238,8 +237,12 @@ static void make_state_key( struct gl_context *ctx, struct state_key *key )
ctx->Texture._MaxEnabledTexImageUnit != -1)
key->texture_enabled_global = 1;
- for (i = 0; i < MAX_TEXTURE_COORD_UNITS; i++) {
+ mask = ctx->Texture._EnabledCoordUnits | ctx->Texture._TexGenEnabled
+ | ctx->Texture._TexMatEnabled | ctx->Point.CoordReplace;
+ while (mask) {
+ const int i = ffs(mask) - 1;
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
+ mask ^= (1u << i);
if (texUnit->_Current)
key->unit[i].texunit_really_enabled = 1;
--
2.5.5
More information about the mesa-dev
mailing list