mesa: Use bitmask/ffs to iterate the enabled textures.

Replaces an iterate and test bit in a bitmask loop by a
loop only iterating over the bits set in the bitmask.

v2: Use _mesa_bit_scan{,64} instead of open coding.
v3: Use u_bit_scan{,64} instead of _mesa_bit_scan{,64}.

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
This commit is contained in:
Mathias Fröhlich 2016-05-22 14:10:19 +02:00
parent 11a5b776c2
commit 34f741b080

View file

@ -38,6 +38,7 @@
#include "teximage.h" #include "teximage.h"
#include "texstate.h" #include "texstate.h"
#include "mtypes.h" #include "mtypes.h"
#include "util/bitscan.h"
#include "util/bitset.h" #include "util/bitset.h"
@ -611,7 +612,7 @@ update_ff_texture_state(struct gl_context *ctx,
for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) { for (unit = 0; unit < ctx->Const.MaxTextureUnits; unit++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit];
GLuint texIndex; GLbitfield mask;
bool complete; bool complete;
if (texUnit->Enabled == 0x0) if (texUnit->Enabled == 0x0)
@ -651,8 +652,9 @@ update_ff_texture_state(struct gl_context *ctx,
* undefined." * undefined."
*/ */
complete = false; complete = false;
for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) { mask = texUnit->Enabled;
if (texUnit->Enabled & (1 << texIndex)) { while (mask) {
const int texIndex = u_bit_scan(&mask);
struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex]; struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex];
struct gl_sampler_object *sampler = texUnit->Sampler ? struct gl_sampler_object *sampler = texUnit->Sampler ?
texUnit->Sampler : &texObj->Sampler; texUnit->Sampler : &texObj->Sampler;
@ -666,7 +668,6 @@ update_ff_texture_state(struct gl_context *ctx,
break; break;
} }
} }
}
if (!complete) if (!complete)
continue; continue;