[Mesa-dev] [PATCH 29/31] mesa: Use bitmask/ffs to iterate the active_samplers bitmask.
Mathias.Froehlich at gmx.net
Mathias.Froehlich at gmx.net
Tue Jun 7 05:30:53 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.
v2: Use _mesa_bit_scan{,64} instead of open coding.
Reviewed-by: Brian Paul <brianp at vmware.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
---
src/mesa/main/uniform_query.cpp | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 997b0cb..461ebba 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -843,9 +843,10 @@ _mesa_uniform(struct gl_context *ctx, struct gl_shader_program *shProg,
* been modified.
*/
bool changed = false;
- for (unsigned j = 0; j < ARRAY_SIZE(prog->SamplerUnits); j++) {
- if ((sh->active_samplers & (1U << j)) != 0
- && (prog->SamplerUnits[j] != sh->SamplerUnits[j])) {
+ GLbitfield mask = sh->active_samplers;
+ while (mask) {
+ const int j = _mesa_bit_scan(&mask);
+ if (prog->SamplerUnits[j] != sh->SamplerUnits[j]) {
changed = true;
break;
}
--
2.5.5
More information about the mesa-dev
mailing list