aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/main/rastpos.c
diff options
context:
space:
mode:
authorMathias Fröhlich <[email protected]>2016-05-22 14:10:19 +0200
committerMathias Fröhlich <[email protected]>2016-06-16 05:50:53 +0200
commitccb1be2fab853c2d82a2159b049d5975d7fc199d (patch)
tree466a122f8689bad80efb7c5d6c980ea88dca313d /src/mesa/main/rastpos.c
parentb60c7302357c2ceb0297d5ef2f748c9b686dbad5 (diff)
mesa: 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 <[email protected]> Signed-off-by: Mathias Fröhlich <[email protected]>
Diffstat (limited to 'src/mesa/main/rastpos.c')
-rw-r--r--src/mesa/main/rastpos.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index b468219e688..8f971f5b8d4 100644
--- a/src/mesa/main/rastpos.c
+++ b/src/mesa/main/rastpos.c
@@ -37,7 +37,7 @@
#include "state.h"
#include "main/dispatch.h"
#include "main/viewport.h"
-#include "util/simple_list.h"
+#include "util/bitscan.h"
@@ -125,7 +125,7 @@ shade_rastpos(struct gl_context *ctx,
GLfloat Rspec[4])
{
/*const*/ GLfloat (*base)[3] = ctx->Light._BaseColor;
- const struct gl_light *light;
+ GLbitfield mask;
GLfloat diffuseColor[4], specularColor[4]; /* for RGB mode only */
COPY_3V(diffuseColor, base[0]);
@@ -133,7 +133,10 @@ shade_rastpos(struct gl_context *ctx,
ctx->Light.Material.Attrib[MAT_ATTRIB_FRONT_DIFFUSE][3], 0.0F, 1.0F );
ASSIGN_4V(specularColor, 0.0, 0.0, 0.0, 1.0);
- foreach (light, &ctx->Light.EnabledList) {
+ mask = ctx->Light._EnabledLights;
+ while (mask) {
+ const int i = u_bit_scan(&mask);
+ struct gl_light *light = &ctx->Light.Light[i];
GLfloat attenuation = 1.0;
GLfloat VP[3]; /* vector from vertex to light pos */
GLfloat n_dot_VP;