From dc9e604ef16ee19cf7480325100e6edd768dbb16 Mon Sep 17 00:00:00 2001 From: Mathias Fröhlich Date: Sun, 22 May 2016 14:10:19 +0200 Subject: mesa: Use bitmask/ffs to iterate enabled clip planes. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Mathias Fröhlich --- src/mesa/main/rastpos.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) (limited to 'src/mesa/main/rastpos.c') 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; } } -- cgit v1.2.3