pull-in changes from DRI/Mesa-4.0.4
[mesa.git] / src / mesa / drivers / common / t_dd_vb.c
index 668211843034d4f9f313d23d1cc94567384a584f..3ba8fb3d8be8877f19539400adf25084cd1d111e 100644 (file)
@@ -1,4 +1,3 @@
-/* $Id: t_dd_vb.c,v 1.10 2001/04/29 08:41:09 keithw Exp $ */
 
 /*
  * Mesa 3-D graphics library
 #define LOCALVARS
 #endif
 
+#ifndef CHECK_HW_DIVIDE
+#define CHECK_HW_DIVIDE 1
+#endif
+
 /* These don't need to be duplicated, but there's currently nowhere
  * really convenient to put them.  Need to build some actual .o files in
  * this directory?
@@ -103,10 +106,9 @@ void TAG(translate_vertex)(GLcontext *ctx,
       dst->color[3] = src->tv.color.alpha;
    }
    else {
-      GLfloat oow = (HAVE_HW_DIVIDE) ? 1.0 / src->v.w : src->v.w;
-
       if (HAVE_HW_VIEWPORT) {
-        if (HAVE_HW_DIVIDE) {
+        if (HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
+           GLfloat oow = 1.0 / src->v.w;
            dst->win[0] = s[0]  * src->v.x * oow + s[12];
            dst->win[1] = s[5]  * src->v.y * oow + s[13];
            dst->win[2] = s[10] * src->v.z * oow + s[14];
@@ -115,13 +117,13 @@ void TAG(translate_vertex)(GLcontext *ctx,
            dst->win[0] = s[0]  * src->v.x + s[12];
            dst->win[1] = s[5]  * src->v.y + s[13];
            dst->win[2] = s[10] * src->v.z + s[14];
-           dst->win[3] = oow;
+           dst->win[3] = src->v.w;
         }
       } else {
         dst->win[0] = UNVIEWPORT_X( src->v.x );
         dst->win[1] = UNVIEWPORT_Y( src->v.y );
         dst->win[2] = UNVIEWPORT_Z( src->v.z );
-        dst->win[3] = oow;
+        dst->win[3] = src->v.w;
       }
 
       dst->color[0] = src->v.color.red;
@@ -192,22 +194,78 @@ void TAG(print_vertex)( GLcontext *ctx, const VERTEX *v )
    LOCALVARS
    GLuint format = GET_VERTEX_FORMAT();
 
-   if (format == TINY_VERTEX_FORMAT) {
-      fprintf(stderr, "x %f y %f z %f\n", v->v.x, v->v.y, v->v.z);
-      fprintf(stderr, "r %d g %d b %d a %d\n",
+   fprintf(stderr, "(%x) ", format);
+
+   switch (format) {
+#if HAVE_TINY_VERTICES
+   case TINY_VERTEX_FORMAT:
+      fprintf(stderr, "xyz %.4f,%.4f,%.4f rgba %x:%x:%x:%x\n",
+             v->v.x, v->v.y, v->v.z,
              v->tv.color.red,
              v->tv.color.green,
              v->tv.color.blue,
              v->tv.color.alpha);
-   }
-   else {
-      fprintf(stderr, "x %f y %f z %f oow %f\n",
-             v->v.x, v->v.y, v->v.z, v->v.w);
-      fprintf(stderr, "r %d g %d b %d a %d\n",
+      break;
+#endif
+#if HAVE_NOTEX_VERTICES
+   case NOTEX_VERTEX_FORMAT:
+      fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x spec %x:%x:%x:%x\n",
+             v->v.x, v->v.y, v->v.z, v->v.w,
+             v->v.color.red,
+             v->v.color.green,
+             v->v.color.blue,
+             v->v.color.alpha,
+             v->v.specular.red,
+             v->v.specular.green,
+             v->v.specular.blue,
+             v->v.specular.alpha);
+      break;
+#endif
+#if HAVE_TEX0_VERTICES
+   case TEX0_VERTEX_FORMAT:
+      fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x st %.4f,%.4f\n",
+             v->v.x, v->v.y, v->v.z, v->v.w,
              v->v.color.red,
              v->v.color.green,
              v->v.color.blue,
-             v->v.color.alpha);
+             v->v.color.alpha,
+             v->v.u0,
+             v->v.v0);
+      break;
+#endif
+#if HAVE_TEX1_VERTICES
+   case TEX1_VERTEX_FORMAT:
+      fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x st %.4f,%.4f st %.4f,%.4f\n",
+             v->v.x, v->v.y, v->v.z, v->v.w,
+             v->v.color.red,
+             v->v.color.green,
+             v->v.color.blue,
+             v->v.color.alpha,
+             v->v.u0,
+             v->v.v0,
+             v->v.u1,
+             v->v.u2);
+      break;
+#endif
+#if HAVE_PTEX_VERTICES
+   case PROJ_TEX1_VERTEX_FORMAT:
+      fprintf(stderr, "xyzw %.4f,%.4f,%.4f,%.4f rgba %x:%x:%x:%x stq %.4f,%.4f,%.4f stq %.4f,%.4f,%.4f\n",
+             v->v.x, v->v.y, v->v.z, v->v.w,
+             v->v.color.red,
+             v->v.color.green,
+             v->v.color.blue,
+             v->v.color.alpha,
+             v->pv.u0,
+             v->pv.v0,
+             v->pv.q0,
+             v->pv.u1,
+             v->pv.v1,
+             v->pv.q1);
+      break;
+#endif      
+   default:
+      fprintf(stderr, "???\n");
+      break;
    }
 
    fprintf(stderr, "\n");
@@ -274,7 +332,7 @@ IMPORT_QUALIFIER void TAG(import_float_spec_colors)( GLcontext *ctx )
 #define INTERP_QUALIFIER static
 #endif
 
-#define GET_COLOR(ptr, idx) (((GLfloat (*)[4])((ptr)->Ptr))[idx])
+#define GET_COLOR(ptr, idx) (((GLchan (*)[4])((ptr)->Ptr))[idx])
 
 
 INTERP_QUALIFIER void TAG(interp_extras)( GLcontext *ctx,
@@ -286,21 +344,21 @@ INTERP_QUALIFIER void TAG(interp_extras)( GLcontext *ctx,
    struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
    if (VB->ColorPtr[1]) {
-      INTERP_4F( t,
-                GET_COLOR(VB->ColorPtr[1], dst),
-                GET_COLOR(VB->ColorPtr[1], out),
-                GET_COLOR(VB->ColorPtr[1], in) );
+      INTERP_4CHAN( t,
+                   GET_COLOR(VB->ColorPtr[1], dst),
+                   GET_COLOR(VB->ColorPtr[1], out),
+                   GET_COLOR(VB->ColorPtr[1], in) );
 
       if (VB->SecondaryColorPtr[1]) {
-        INTERP_3F( t,
-                   GET_COLOR(VB->SecondaryColorPtr[1], dst),
-                   GET_COLOR(VB->SecondaryColorPtr[1], out),
-                   GET_COLOR(VB->SecondaryColorPtr[1], in) );
+        INTERP_3CHAN( t,
+                      GET_COLOR(VB->SecondaryColorPtr[1], dst),
+                      GET_COLOR(VB->SecondaryColorPtr[1], out),
+                      GET_COLOR(VB->SecondaryColorPtr[1], in) );
       }
    }
 
    if (VB->EdgeFlag) {
-      VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary || 1;
+      VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
    }
 
    INTERP_VERTEX(ctx, t, dst, out, in, force_boundary);
@@ -310,16 +368,16 @@ INTERP_QUALIFIER void TAG(copy_pv_extras)( GLcontext *ctx,
                                           GLuint dst, GLuint src )
 {
    LOCALVARS
-   struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+      struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
 
    if (VB->ColorPtr[1]) {
-        COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst), 
-                  GET_COLOR(VB->ColorPtr[1], src) );
+      COPY_CHAN4( GET_COLOR(VB->ColorPtr[1], dst), 
+                 GET_COLOR(VB->ColorPtr[1], src) );
 
-        if (VB->SecondaryColorPtr[1]) {
-           COPY_4FV( GET_COLOR(VB->SecondaryColorPtr[1], dst), 
-                     GET_COLOR(VB->SecondaryColorPtr[1], src) );
-        }
+      if (VB->SecondaryColorPtr[1]) {
+        COPY_CHAN4( GET_COLOR(VB->SecondaryColorPtr[1], dst), 
+                    GET_COLOR(VB->SecondaryColorPtr[1], src) );
+      }
    }
 
    COPY_PV_VERTEX(ctx, dst, src);