mesa: Use bitmask/ffs to iterate the enabled textures.
[mesa.git] / src / mesa / main / ffvertex_prog.c
index ca725545f01a9cb1b5483fefb8e63831b9f6e1de..f4ae69090ae1c214b25b04408f804b7dcc3df486 100644 (file)
@@ -150,7 +150,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,7 +237,10 @@ 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 = u_bit_scan(&mask);
       struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i];
 
       if (texUnit->_Current)