mesa/st: introduce PIPE_CAP_NO_CLIP_ON_COPY_TEX
[mesa.git] / src / mesa / tnl / t_vb_cliptmp.h
index 618b8b31304f0e2351d0fa03636d941a1db925f7..9f2d5161d99a98f52ede59da4b1eec4c7e45da13 100644 (file)
@@ -1,6 +1,5 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.2
  *
  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
  *
  * Authors:
- *    Keith Whitwell <keith@tungstengraphics.com>
+ *    Keith Whitwell <keithw@vmware.com>
  */
 
 
@@ -41,12 +41,12 @@ do {                                                                        \
         GLuint idx = inlist[i];                                        \
         GLfloat dp = CLIP_DOTPROD(idx, A, B, C, D );                   \
                                                                        \
-        if (!IS_NEGATIVE(dpPrev)) {                                    \
+        if (dpPrev >= 0.0f) {                                          \
            outlist[outcount++] = idxPrev;                              \
         }                                                              \
                                                                        \
         if (DIFFERENT_SIGNS(dp, dpPrev)) {                             \
-           if (IS_NEGATIVE(dp)) {                                      \
+           if (dp < 0.0f) {                                            \
               /* Going out of bounds.  Avoid division by zero as we    \
                * know dp != dpPrev from DIFFERENT_SIGNS, above.        \
                */                                                      \
@@ -85,15 +85,15 @@ do {                                                                        \
    if (mask & PLANE_BIT) {                                             \
       const GLfloat dp0 = CLIP_DOTPROD( v0, A, B, C, D );              \
       const GLfloat dp1 = CLIP_DOTPROD( v1, A, B, C, D );              \
-      const GLboolean neg_dp0 = IS_NEGATIVE(dp0);                      \
-      const GLboolean neg_dp1 = IS_NEGATIVE(dp1);                      \
+      const GLboolean neg_dp0 = dp0 < 0.0f;                            \
+      const GLboolean neg_dp1 = dp1 < 0.0f;                            \
                                                                        \
       /* For regular clipping, we know from the clipmask that one      \
        * (or both) of these must be negative (otherwise we wouldn't    \
        * be here).                                                     \
        * For userclip, there is only a single bit for all active       \
        * planes, so we can end up here when there is nothing to do,    \
-       * hence the second IS_NEGATIVE() test:                          \
+       * hence the second < 0.0f test:                                 \
        */                                                              \
       if (neg_dp0 && neg_dp1)                                          \
          return; /* both vertices outside clip plane: discard */       \
@@ -114,8 +114,8 @@ do {                                                                        \
 
 /* Clip a line against the viewport and user clip planes.
  */
-static INLINE void
-TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
+static inline void
+TAG(clip_line)( struct gl_context *ctx, GLuint v0, GLuint v1, GLubyte mask )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
@@ -124,7 +124,6 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
    GLuint newvert = VB->Count;
    GLfloat t0 = 0;
    GLfloat t1 = 0;
-   GLuint p;
    const GLuint v0_orig = v0;
 
    if (mask & CLIP_FRUSTUM_BITS) {
@@ -137,14 +136,14 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
    }
 
    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 );
       }
    }
 
@@ -155,7 +154,7 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
       newvert++;
    }
    else {
-      ASSERT(t0 == 0.0);
+      assert(t0 == 0.0);
    }
 
    /* Note: we need to use vertex v0_orig when computing the new
@@ -174,7 +173,7 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
       newvert++;
    }
    else {
-      ASSERT(t1 == 0.0);
+      assert(t1 == 0.0);
    }
 
    tnl->Driver.Render.ClippedLine( ctx, v0, v1 );
@@ -183,8 +182,8 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
 
 /* Clip a triangle against the viewport and user clip planes.
  */
-static INLINE void
-TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
+static inline void
+TAG(clip_tri)( struct gl_context *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
    struct vertex_buffer *VB = &tnl->vb;
@@ -194,7 +193,6 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
    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 */
@@ -202,16 +200,16 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
    if (0) {
       /* print pre-clip vertex coords */
       GLuint i, j;
-      _mesa_printf("pre clip:\n");
+      printf("pre clip:\n");
       for (i = 0; i < n; i++) {
          j = inlist[i];
-         _mesa_printf("  %u: %u: %f, %f, %f, %f\n",
-                      i, j,
-                      coord[j][0], coord[j][1], coord[j][2], coord[j][3]);
-         assert(!IS_INF_OR_NAN(coord[j][0]));
-         assert(!IS_INF_OR_NAN(coord[j][1]));
-         assert(!IS_INF_OR_NAN(coord[j][2]));
-         assert(!IS_INF_OR_NAN(coord[j][3]));
+         printf("  %u: %u: %f, %f, %f, %f\n",
+               i, j,
+               coord[j][0], coord[j][1], coord[j][2], coord[j][3]);
+         assert(!util_is_inf_or_nan(coord[j][0]));
+         assert(!util_is_inf_or_nan(coord[j][1]));
+         assert(!util_is_inf_or_nan(coord[j][2]));
+         assert(!util_is_inf_or_nan(coord[j][3]));
       }
    }
 
@@ -226,20 +224,20 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
    }
 
    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 );
       }
    }
 
    if (ctx->Light.ShadeModel == GL_FLAT) {
       if (pv != inlist[0]) {
-        ASSERT( inlist[0] >= VB->Count );
+        assert( inlist[0] >= VB->Count );
         tnl->Driver.Render.CopyPV( ctx, inlist[0], pv );
       }
    }
@@ -247,12 +245,12 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
    if (0) {
       /* print post-clip vertex coords */
       GLuint i, j;
-      _mesa_printf("post clip:\n");
+      printf("post clip:\n");
       for (i = 0; i < n; i++) {
          j = inlist[i];
-         _mesa_printf("  %u: %u: %f, %f, %f, %f\n",
-                      i, j,
-                      coord[j][0], coord[j][1], coord[j][2], coord[j][3]);
+         printf("  %u: %u: %f, %f, %f, %f\n",
+               i, j,
+               coord[j][0], coord[j][1], coord[j][2], coord[j][3]);
       }
    }
 
@@ -262,8 +260,8 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
 
 /* Clip a quad against the viewport and user clip planes.
  */
-static INLINE void
-TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3,
+static inline void
+TAG(clip_quad)( struct gl_context *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3,
                 GLubyte mask )
 {
    TNLcontext *tnl = TNL_CONTEXT(ctx);
@@ -274,7 +272,6 @@ TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3,
    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 */
@@ -289,20 +286,20 @@ TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3,
    }
 
    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 );
       }
    }
 
    if (ctx->Light.ShadeModel == GL_FLAT) {
       if (pv != inlist[0]) {
-        ASSERT( inlist[0] >= VB->Count );
+        assert( inlist[0] >= VB->Count );
         tnl->Driver.Render.CopyPV( ctx, inlist[0], pv );
       }
    }