summaryrefslogtreecommitdiffstats
path: root/src/mesa/tnl/t_vb_light.c
diff options
context:
space:
mode:
authorMathias Fröhlich <mathias.froehlich@web.de>2016-05-22 14:10:19 +0200
committerMathias Fröhlich <mathias.froehlich@web.de>2016-06-16 05:50:53 +0200
commit9a3fcb010c8ecbcbae0b7b299b64165051b03b85 (patch)
treed332fa710bf4c2858cf26b398543ef537c46426e /src/mesa/tnl/t_vb_light.c
parent664aec437088dbee299499f0539adc3fc9a2386f (diff)
tnl: Use bitmask/ffs to iterate enabled lights
Replaces loops that iterate 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/tnl/t_vb_light.c')
-rw-r--r--src/mesa/tnl/t_vb_light.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c
index 029265a4f83..4342b6ed465 100644
--- a/src/mesa/tnl/t_vb_light.c
+++ b/src/mesa/tnl/t_vb_light.c
@@ -33,6 +33,8 @@
#include "math/m_translate.h"
+#include "util/bitscan.h"
+
#include "t_context.h"
#include "t_pipeline.h"
#include "tnl.h"
@@ -394,7 +396,8 @@ static void validate_lighting( struct gl_context *ctx,
tab = _tnl_light_tab;
}
else {
- if (ctx->Light.EnabledList.next == ctx->Light.EnabledList.prev)
+ /* Power of two means only a single active light. */
+ if (_mesa_is_pow_two(ctx->Light._EnabledLights))
tab = _tnl_light_fast_single_tab;
else
tab = _tnl_light_fast_tab;