diff options
author | Mathias Fröhlich <[email protected]> | 2016-05-22 14:10:19 +0200 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2016-06-16 05:50:55 +0200 |
commit | 34f741b0809a0d7bb5dbc262bbc3ff2eb743090f (patch) | |
tree | e532656b4f82b18cabdaede7935046bdb25fc932 /src/mesa/main | |
parent | 11a5b776c20a9f9dd7fd822d56e3a8a979278151 (diff) |
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 <[email protected]>
Signed-off-by: Mathias Fröhlich <[email protected]>
Diffstat (limited to 'src/mesa/main')
-rw-r--r-- | src/mesa/main/texstate.c | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 354336934a2..94caf2a9ca8 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -38,6 +38,7 @@ #include "teximage.h" #include "texstate.h" #include "mtypes.h" +#include "util/bitscan.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++) { struct gl_texture_unit *texUnit = &ctx->Texture.Unit[unit]; - GLuint texIndex; + GLbitfield mask; bool complete; if (texUnit->Enabled == 0x0) @@ -651,20 +652,20 @@ update_ff_texture_state(struct gl_context *ctx, * undefined." */ complete = false; - for (texIndex = 0; texIndex < NUM_TEXTURE_TARGETS; texIndex++) { - if (texUnit->Enabled & (1 << texIndex)) { - struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex]; - struct gl_sampler_object *sampler = texUnit->Sampler ? - texUnit->Sampler : &texObj->Sampler; - - if (!_mesa_is_texture_complete(texObj, sampler)) { - _mesa_test_texobj_completeness(ctx, texObj); - } - if (_mesa_is_texture_complete(texObj, sampler)) { - _mesa_reference_texobj(&texUnit->_Current, texObj); - complete = true; - break; - } + mask = texUnit->Enabled; + while (mask) { + const int texIndex = u_bit_scan(&mask); + struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex]; + struct gl_sampler_object *sampler = texUnit->Sampler ? + texUnit->Sampler : &texObj->Sampler; + + if (!_mesa_is_texture_complete(texObj, sampler)) { + _mesa_test_texobj_completeness(ctx, texObj); + } + if (_mesa_is_texture_complete(texObj, sampler)) { + _mesa_reference_texobj(&texUnit->_Current, texObj); + complete = true; + break; } } |