#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 */
}
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);
}
}
}
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);
}
}
#include "matrix.h"
#include "mtypes.h"
#include "math/m_matrix.h"
+#include "util/bitscan.h"
/**
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 );
}
}
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;
}
}
GLuint newvert = VB->Count;
GLfloat t0 = 0;
GLfloat t1 = 0;
- GLuint p;
const GLuint v0_orig = v0;
if (mask & CLIP_FRUSTUM_BITS) {
}
if (mask & CLIP_USER_BIT) {
- for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
- if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
- const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
- const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
- const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
- const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
- LINE_CLIP( CLIP_USER_BIT, a, b, c, d );
- }
+ GLbitfield enabled = ctx->Transform.ClipPlanesEnabled;
+ while (enabled) {
+ const int p = u_bit_scan(&enabled);
+ const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
+ const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
+ const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
+ const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
+ LINE_CLIP( CLIP_USER_BIT, a, b, c, d );
}
}
GLuint pv = v2;
GLuint vlist[2][MAX_CLIPPED_VERTICES];
GLuint *inlist = vlist[0], *outlist = vlist[1];
- GLuint p;
GLuint n = 3;
ASSIGN_3V(inlist, v2, v0, v1 ); /* pv rotated to slot zero */
}
if (mask & CLIP_USER_BIT) {
- for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
- if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
- const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
- const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
- const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
- const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
- POLY_CLIP( CLIP_USER_BIT, a, b, c, d );
- }
+ GLbitfield enabled = ctx->Transform.ClipPlanesEnabled;
+ while (enabled) {
+ const int p = u_bit_scan(&enabled);
+ const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
+ const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
+ const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
+ const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
+ POLY_CLIP( CLIP_USER_BIT, a, b, c, d );
}
}
GLuint pv = v3;
GLuint vlist[2][MAX_CLIPPED_VERTICES];
GLuint *inlist = vlist[0], *outlist = vlist[1];
- GLuint p;
GLuint n = 4;
ASSIGN_4V(inlist, v3, v0, v1, v2 ); /* pv rotated to slot zero */
}
if (mask & CLIP_USER_BIT) {
- for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
- if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
- const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
- const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
- const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
- const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
- POLY_CLIP( CLIP_USER_BIT, a, b, c, d );
- }
+ GLbitfield enabled = ctx->Transform.ClipPlanesEnabled;
+ while (enabled) {
+ const int p = u_bit_scan(&enabled);
+ const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
+ const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
+ const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
+ const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
+ POLY_CLIP( CLIP_USER_BIT, a, b, c, d );
}
}
#include "program/prog_statevars.h"
#include "program/prog_execute.h"
#include "swrast/s_context.h"
+#include "util/bitscan.h"
#include "tnl/tnl.h"
#include "tnl/t_context.h"
GLubyte *clipormask,
GLubyte *clipandmask )
{
- GLuint p;
-
- for (p = 0; p < ctx->Const.MaxClipPlanes; p++) {
- if (ctx->Transform.ClipPlanesEnabled & (1 << p)) {
- GLuint nr, i;
- const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
- const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
- const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
- const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
- GLfloat *coord = (GLfloat *)clip->data;
- GLuint stride = clip->stride;
- GLuint count = clip->count;
-
- for (nr = 0, i = 0 ; i < count ; i++) {
- GLfloat dp = (coord[0] * a +
- coord[1] * b +
- coord[2] * c +
- coord[3] * d);
-
- if (dp < 0) {
- nr++;
- clipmask[i] |= CLIP_USER_BIT;
- }
-
- STRIDE_F(coord, stride);
- }
+ GLbitfield mask = ctx->Transform.ClipPlanesEnabled;
+ while (mask) {
+ const int p = u_bit_scan(&mask);
+ GLuint nr, i;
+ const GLfloat a = ctx->Transform._ClipUserPlane[p][0];
+ const GLfloat b = ctx->Transform._ClipUserPlane[p][1];
+ const GLfloat c = ctx->Transform._ClipUserPlane[p][2];
+ const GLfloat d = ctx->Transform._ClipUserPlane[p][3];
+ GLfloat *coord = (GLfloat *)clip->data;
+ GLuint stride = clip->stride;
+ GLuint count = clip->count;
+
+ for (nr = 0, i = 0 ; i < count ; i++) {
+ GLfloat dp = (coord[0] * a +
+ coord[1] * b +
+ coord[2] * c +
+ coord[3] * d);
+
+ if (dp < 0) {
+ nr++;
+ clipmask[i] |= CLIP_USER_BIT;
+ }
+
+ STRIDE_F(coord, stride);
+ }
- if (nr > 0) {
- *clipormask |= CLIP_USER_BIT;
- if (nr == count) {
- *clipandmask |= CLIP_USER_BIT;
- return;
- }
- }
+ if (nr > 0) {
+ *clipormask |= CLIP_USER_BIT;
+ if (nr == count) {
+ *clipandmask |= CLIP_USER_BIT;
+ return;
+ }
}
}
}
#include "main/imports.h"
#include "main/mtypes.h"
#include "math/m_xform.h"
+#include "util/bitscan.h"
#include "t_pipeline.h"
#include "math/m_xform.h"
+#include "util/bitscan.h"
+
#include "t_context.h"
#include "t_pipeline.h"
GLubyte *clipormask, \
GLubyte *clipandmask ) \
{ \
- GLuint p; \
- \
- for (p = 0; p < ctx->Const.MaxClipPlanes; p++) \
- if (ctx->Transform.ClipPlanesEnabled & (1 << p)) { \
- GLuint nr, i; \
- const GLfloat a = ctx->Transform._ClipUserPlane[p][0]; \
- const GLfloat b = ctx->Transform._ClipUserPlane[p][1]; \
- const GLfloat c = ctx->Transform._ClipUserPlane[p][2]; \
- const GLfloat d = ctx->Transform._ClipUserPlane[p][3]; \
- GLfloat *coord = (GLfloat *)clip->data; \
- GLuint stride = clip->stride; \
- GLuint count = clip->count; \
+ GLbitfield mask = ctx->Transform.ClipPlanesEnabled; \
+ while (mask) { \
+ const int p = u_bit_scan(&mask); \
+ GLuint nr, i; \
+ const GLfloat a = ctx->Transform._ClipUserPlane[p][0]; \
+ const GLfloat b = ctx->Transform._ClipUserPlane[p][1]; \
+ const GLfloat c = ctx->Transform._ClipUserPlane[p][2]; \
+ const GLfloat d = ctx->Transform._ClipUserPlane[p][3]; \
+ GLfloat *coord = (GLfloat *)clip->data; \
+ GLuint stride = clip->stride; \
+ GLuint count = clip->count; \
\
- for (nr = 0, i = 0 ; i < count ; i++) { \
- GLfloat dp = coord[0] * a + coord[1] * b; \
- if (SZ > 2) dp += coord[2] * c; \
- if (SZ > 3) dp += coord[3] * d; else dp += d; \
+ for (nr = 0, i = 0 ; i < count ; i++) { \
+ GLfloat dp = coord[0] * a + coord[1] * b; \
+ if (SZ > 2) dp += coord[2] * c; \
+ if (SZ > 3) dp += coord[3] * d; else dp += d; \
\
- if (dp < 0) { \
- nr++; \
- clipmask[i] |= CLIP_USER_BIT; \
- } \
+ if (dp < 0) { \
+ nr++; \
+ clipmask[i] |= CLIP_USER_BIT; \
+ } \
\
- STRIDE_F(coord, stride); \
- } \
+ STRIDE_F(coord, stride); \
+ } \
\
- if (nr > 0) { \
- *clipormask |= CLIP_USER_BIT; \
- if (nr == count) { \
- *clipandmask |= CLIP_USER_BIT; \
- return; \
- } \
- } \
+ if (nr > 0) { \
+ *clipormask |= CLIP_USER_BIT; \
+ if (nr == count) { \
+ *clipandmask |= CLIP_USER_BIT; \
+ return; \
+ } \
} \
+ } \
}