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 | 22e5d4a1ee02089258d1fc67dfe7fa02a1dfcf22 (patch) | |
tree | 66e6b080fd80f14d7dfa5323e666a89ad69829fa | |
parent | 34f741b0809a0d7bb5dbc262bbc3ff2eb743090f (diff) |
mesa: Use bitmask/ffs to iterate the active_samplers bitmask.
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]>
-rw-r--r-- | src/mesa/main/uniform_query.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp index eea611b7954..127f097fe1f 100644 --- a/src/mesa/main/uniform_query.cpp +++ b/src/mesa/main/uniform_query.cpp @@ -36,6 +36,7 @@ #include "compiler/glsl/glsl_parser_extras.h" #include "compiler/glsl/program.h" #include "program/hash_table.h" +#include "util/bitscan.h" extern "C" void GLAPIENTRY @@ -843,9 +844,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 = u_bit_scan(&mask); + if (prog->SamplerUnits[j] != sh->SamplerUnits[j]) { changed = true; break; } |