diff options
author | Mathias Fröhlich <mathias.froehlich@web.de> | 2016-05-22 14:10:19 +0200 |
---|---|---|
committer | Mathias Fröhlich <mathias.froehlich@web.de> | 2016-06-16 05:50:54 +0200 |
commit | f69a4005132e6e343ed210f288f752587c97f2f4 (patch) | |
tree | 0d20723f85d84b7e6aa2dea89a061f3a763fe975 /src/mesa/drivers/dri/nouveau/nouveau_state.c | |
parent | 9a3fcb010c8ecbcbae0b7b299b64165051b03b85 (diff) | |
download | external_mesa3d-f69a4005132e6e343ed210f288f752587c97f2f4.zip external_mesa3d-f69a4005132e6e343ed210f288f752587c97f2f4.tar.gz external_mesa3d-f69a4005132e6e343ed210f288f752587c97f2f4.tar.bz2 |
nouveau: Use bitmask/ffs to iterate enabled lights
Replaces a loop that iterates all lights and test
which of them is enabled by a loop only iterating over
the bits set in the enabled 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>
Diffstat (limited to 'src/mesa/drivers/dri/nouveau/nouveau_state.c')
-rw-r--r-- | src/mesa/drivers/dri/nouveau/nouveau_state.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_state.c b/src/mesa/drivers/dri/nouveau/nouveau_state.c index 3aad10e..6189997 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_state.c +++ b/src/mesa/drivers/dri/nouveau/nouveau_state.c @@ -31,6 +31,7 @@ #include "swrast/swrast.h" #include "tnl/tnl.h" +#include "util/bitscan.h" static void nouveau_alpha_func(struct gl_context *ctx, GLenum func, GLfloat ref) @@ -122,7 +123,7 @@ nouveau_draw_buffers(struct gl_context *ctx, GLsizei n, const GLenum *buffers) static void nouveau_enable(struct gl_context *ctx, GLenum cap, GLboolean state) { - int i; + GLbitfield mask; switch (cap) { case GL_ALPHA_TEST: @@ -187,9 +188,10 @@ nouveau_enable(struct gl_context *ctx, GLenum cap, GLboolean state) context_dirty(ctx, LIGHT_MODEL); context_dirty(ctx, LIGHT_ENABLE); - for (i = 0; i < MAX_LIGHTS; i++) { - if (ctx->Light.Light[i].Enabled) - context_dirty_i(ctx, LIGHT_SOURCE, i); + mask = ctx->Light._EnabledLights; + while (mask) { + const int i = u_bit_scan(&mask); + context_dirty_i(ctx, LIGHT_SOURCE, i); } context_dirty(ctx, MATERIAL_FRONT_AMBIENT); |