diff options
author | Mathias Fröhlich <[email protected]> | 2016-05-22 14:10:19 +0200 |
---|---|---|
committer | Mathias Fröhlich <[email protected]> | 2016-06-16 05:50:54 +0200 |
commit | dc9e604ef16ee19cf7480325100e6edd768dbb16 (patch) | |
tree | 40052cf394cb694710869b8003fc04c8ced48837 /src/mesa/main/matrix.c | |
parent | d8a3ac90df67ab1b397b59acdaf4f8e5dc27203a (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/matrix.c')
-rw-r--r-- | src/mesa/main/matrix.c | 19 |
1 files changed, 10 insertions, 9 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 ); } } |