st/mesa: add missing case for PIPE_FORMAT_B8G8R8A8_UNORM
[mesa.git] / src / mesa / tnl / t_vb_cliptmp.h
index 8d253c713e496517b0ed7465e3fcc5506536623d..618b8b31304f0e2351d0fa03636d941a1db925f7 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Mesa 3-D graphics library
- * Version:  6.5.1
+ * Version:  6.5.2
  *
  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
  *
@@ -125,8 +125,9 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
    GLfloat t0 = 0;
    GLfloat t1 = 0;
    GLuint p;
+   const GLuint v0_orig = v0;
 
-   if (mask & 0x3f) {
+   if (mask & CLIP_FRUSTUM_BITS) {
       LINE_CLIP( CLIP_RIGHT_BIT,  -1,  0,  0, 1 );
       LINE_CLIP( CLIP_LEFT_BIT,    1,  0,  0, 1 );
       LINE_CLIP( CLIP_TOP_BIT,     0, -1,  0, 1 );
@@ -153,22 +154,28 @@ TAG(clip_line)( GLcontext *ctx, GLuint v0, GLuint v1, GLubyte mask )
       v0 = newvert;
       newvert++;
    }
-   else
+   else {
       ASSERT(t0 == 0.0);
+   }
 
+   /* Note: we need to use vertex v0_orig when computing the new
+    * interpolated/clipped vertex position, not the current v0 which
+    * may have got set when we clipped the other end of the line!
+    */
    if (VB->ClipMask[v1]) {
-      INTERP_4F( t1, coord[newvert], coord[v1], coord[v0] );
-      interp( ctx, t1, newvert, v1, v0, GL_FALSE );
+      INTERP_4F( t1, coord[newvert], coord[v1], coord[v0_orig] );
+      interp( ctx, t1, newvert, v1, v0_orig, GL_FALSE );
 
-      if (ctx->_TriangleCaps & DD_FLATSHADE)
+      if (ctx->Light.ShadeModel == GL_FLAT)
         tnl->Driver.Render.CopyPV( ctx, newvert, v1 );
 
       v1 = newvert;
 
       newvert++;
    }
-   else
+   else {
       ASSERT(t1 == 0.0);
+   }
 
    tnl->Driver.Render.ClippedLine( ctx, v0, v1 );
 }
@@ -192,7 +199,24 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
 
    ASSIGN_3V(inlist, v2, v0, v1 ); /* pv rotated to slot zero */
 
-   if (mask & 0x3f) {
+   if (0) {
+      /* print pre-clip vertex coords */
+      GLuint i, j;
+      _mesa_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]));
+      }
+   }
+
+
+   if (mask & CLIP_FRUSTUM_BITS) {
       POLY_CLIP( CLIP_RIGHT_BIT,  -1,  0,  0, 1 );
       POLY_CLIP( CLIP_LEFT_BIT,    1,  0,  0, 1 );
       POLY_CLIP( CLIP_TOP_BIT,     0, -1,  0, 1 );
@@ -213,13 +237,25 @@ TAG(clip_tri)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLubyte mask )
       }
    }
 
-   if (ctx->_TriangleCaps & DD_FLATSHADE) {
+   if (ctx->Light.ShadeModel == GL_FLAT) {
       if (pv != inlist[0]) {
         ASSERT( inlist[0] >= VB->Count );
         tnl->Driver.Render.CopyPV( ctx, inlist[0], pv );
       }
    }
 
+   if (0) {
+      /* print post-clip vertex coords */
+      GLuint i, j;
+      _mesa_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]);
+      }
+   }
+
    tnl->Driver.Render.ClippedPolygon( ctx, inlist, n );
 }
 
@@ -243,7 +279,7 @@ TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3,
 
    ASSIGN_4V(inlist, v3, v0, v1, v2 ); /* pv rotated to slot zero */
 
-   if (mask & 0x3f) {
+   if (mask & CLIP_FRUSTUM_BITS) {
       POLY_CLIP( CLIP_RIGHT_BIT,  -1,  0,  0, 1 );
       POLY_CLIP( CLIP_LEFT_BIT,    1,  0,  0, 1 );
       POLY_CLIP( CLIP_TOP_BIT,     0, -1,  0, 1 );
@@ -264,7 +300,7 @@ TAG(clip_quad)( GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3,
       }
    }
 
-   if (ctx->_TriangleCaps & DD_FLATSHADE) {
+   if (ctx->Light.ShadeModel == GL_FLAT) {
       if (pv != inlist[0]) {
         ASSERT( inlist[0] >= VB->Count );
         tnl->Driver.Render.CopyPV( ctx, inlist[0], pv );