[Mesa-dev] [PATCH 26/29] mesa: Use bitmask/ffs to iterate the enabled textures.
Mathias.Froehlich at gmx.net
Mathias.Froehlich at gmx.net
Tue May 24 06:49:09 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.
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
---
src/mesa/main/texstate.c | 31 ++++++++++++++++---------------
1 file changed, 16 insertions(+), 15 deletions(-)
diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c
index 3543369..411073a 100644
--- a/src/mesa/main/texstate.c
+++ b/src/mesa/main/texstate.c
@@ -611,7 +611,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 +651,21 @@ 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) {
+ int texIndex = ffs(mask) - 1;
+ struct gl_texture_object *texObj = texUnit->CurrentTex[texIndex];
+ struct gl_sampler_object *sampler = texUnit->Sampler ?
+ texUnit->Sampler : &texObj->Sampler;
+ mask ^= (1u << texIndex);
+
+ 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;
}
}
--
2.5.5
More information about the mesa-dev
mailing list