summaryrefslogtreecommitdiffstats
path: root/src/mesa/main
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/main
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/main')
-rw-r--r--src/mesa/main/matrix.c19
-rw-r--r--src/mesa/main/rastpos.c21
2 files changed, 20 insertions, 20 deletions
diff --git a/src/mesa/main/matrix.c b/src/mesa/main/matrix.c
index 5ff5ac5bfe1..293d50c3359 100644
--- a/src/mesa/main/matrix.c
+++ b/src/mesa/main/matrix.c
@@ -43,6 +43,7 @@
#include "matrix.h"
#include "mtypes.h"
#include "math/m_matrix.h"
+#include "util/bitscan.h"
/**
@@ -554,20 +555,20 @@ _mesa_MultTransposeMatrixd( const GLdouble *m )
static void
update_projection( struct gl_context *ctx )
{
+ GLbitfield mask;
+
_math_matrix_analyse( ctx->ProjectionMatrixStack.Top );
/* Recompute clip plane positions in clipspace. This is also done
* in _mesa_ClipPlane().
*/
- if (ctx->Transform.ClipPlanesEnabled) {
- GLuint p;
- for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
- if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
- _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
- ctx->Transform.EyeUserPlane[p],
- ctx->ProjectionMatrixStack.Top->inv );
- }
- }
+ mask = ctx->Transform.ClipPlanesEnabled;
+ while (mask) {
+ const int p = u_bit_scan(&mask);
+
+ _mesa_transform_vector( ctx->Transform._ClipUserPlane[p],
+ ctx->Transform.EyeUserPlane[p],
+ ctx->ProjectionMatrixStack.Top->inv );
}
}
diff --git a/src/mesa/main/rastpos.c b/src/mesa/main/rastpos.c
index 8f971f5b8d4..4fddad16f1b 100644
--- a/src/mesa/main/rastpos.c
+++ b/src/mesa/main/rastpos.c
@@ -91,17 +91,16 @@ viewclip_point_z( const GLfloat v[] )
static GLuint
userclip_point( struct gl_context *ctx, const GLfloat v[] )
{
- GLuint p;
-
- for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
- if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
- GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0]
- + v[1] * ctx->Transform._ClipUserPlane[p][1]
- + v[2] * ctx->Transform._ClipUserPlane[p][2]
- + v[3] * ctx->Transform._ClipUserPlane[p][3];
- if (dot < 0.0F) {
- return 0;
- }
+ GLbitfield mask = ctx->Transform.ClipPlanesEnabled;
+ while (mask) {
+ const int p = u_bit_scan(&mask);
+ GLfloat dot = v[0] * ctx->Transform._ClipUserPlane[p][0]
+ + v[1] * ctx->Transform._ClipUserPlane[p][1]
+ + v[2] * ctx->Transform._ClipUserPlane[p][2]
+ + v[3] * ctx->Transform._ClipUserPlane[p][3];
+
+ if (dot < 0.0F) {
+ return 0;
}
}