summaryrefslogtreecommitdiffstats
path: root/src/mesa/tnl/t_vb_light.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:54 +0200
commitd8a3ac90df67ab1b397b59acdaf4f8e5dc27203a (patch)
tree7142c8d577265a862f90651d5621f9e7ed49b5b3 /src/mesa/tnl/t_vb_light.c
parentd4eb2f9cda1fa08949f8e28ef414bbb41e150459 (diff)
mesa: Use bitmask/ffs to iterate color material attributes.
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]>
Diffstat (limited to 'src/mesa/tnl/t_vb_light.c')
-rw-r--r--src/mesa/tnl/t_vb_light.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/mesa/tnl/t_vb_light.c b/src/mesa/tnl/t_vb_light.c
index 4342b6ed465..8d13712e218 100644
--- a/src/mesa/tnl/t_vb_light.c
+++ b/src/mesa/tnl/t_vb_light.c
@@ -233,10 +233,12 @@ prepare_materials(struct gl_context *ctx,
* with the color pointer for each one.
*/
if (ctx->Light.ColorMaterialEnabled) {
- const GLuint bitmask = ctx->Light._ColorMaterialBitmask;
- for (i = 0 ; i < MAT_ATTRIB_MAX ; i++)
- if (bitmask & (1<<i))
- VB->AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] = VB->AttribPtr[_TNL_ATTRIB_COLOR0];
+ GLbitfield bitmask = ctx->Light._ColorMaterialBitmask;
+ while (bitmask) {
+ const int i = u_bit_scan(&bitmask);
+ VB->AttribPtr[_TNL_ATTRIB_MAT_FRONT_AMBIENT + i] =
+ VB->AttribPtr[_TNL_ATTRIB_COLOR0];
+ }
}
/* Now, for each material attribute that's tracking vertex color, save