summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/common/meta.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
commitdc9e604ef16ee19cf7480325100e6edd768dbb16 (patch)
tree40052cf394cb694710869b8003fc04c8ced48837 /src/mesa/drivers/common/meta.c
parentd8a3ac90df67ab1b397b59acdaf4f8e5dc27203a (diff)
mesa: Use bitmask/ffs to iterate enabled clip planes.
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/drivers/common/meta.c')
-rw-r--r--src/mesa/drivers/common/meta.c22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
index 3c86305d77f..be671b4b629 100644
--- a/src/mesa/drivers/common/meta.c
+++ b/src/mesa/drivers/common/meta.c
@@ -85,6 +85,7 @@
#include "drivers/common/meta.h"
#include "main/enums.h"
#include "main/glformats.h"
+#include "util/bitscan.h"
#include "util/ralloc.h"
/** Return offset in bytes of the field within a vertex struct */
@@ -682,12 +683,12 @@ _mesa_meta_begin(struct gl_context *ctx, GLbitfield state)
}
if (state & MESA_META_CLIP) {
+ GLbitfield mask;
save->ClipPlanesEnabled = ctx->Transform.ClipPlanesEnabled;
- if (ctx->Transform.ClipPlanesEnabled) {
- GLuint i;
- for (i = 0; i < ctx->Const.MaxClipPlanes; i++) {
- _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE);
- }
+ mask = ctx->Transform.ClipPlanesEnabled;
+ while (mask) {
+ const int i = u_bit_scan(&mask);
+ _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_FALSE);
}
}
@@ -1090,13 +1091,10 @@ _mesa_meta_end(struct gl_context *ctx)
}
if (state & MESA_META_CLIP) {
- if (save->ClipPlanesEnabled) {
- GLuint i;
- for (i = 0; i < ctx->Const.MaxClipPlanes; i++) {
- if (save->ClipPlanesEnabled & (1 << i)) {
- _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE);
- }
- }
+ GLbitfield mask = save->ClipPlanesEnabled;
+ while (mask) {
+ const int i = u_bit_scan(&mask);
+ _mesa_set_enable(ctx, GL_CLIP_PLANE0 + i, GL_TRUE);
}
}