Minor r200 vertex program cleanups. Remove disabled leftovers from r300 vertex progra...
[mesa.git] / src / mesa / drivers / dri / i810 / i810tris.c
index 364b571152b08a3f31e9163a11fbae3c8501454c..3e09427bb94f631c1fa6efcdf2ac55744a143de2 100644 (file)
@@ -75,7 +75,7 @@ do {                                                                  \
 } while (0)
 #endif
 
-static void __inline__ i810_draw_triangle( i810ContextPtr imesa,
+static __inline__ void i810_draw_triangle( i810ContextPtr imesa,
                                           i810VertexPtr v0,
                                           i810VertexPtr v1,
                                           i810VertexPtr v2 )
@@ -90,7 +90,7 @@ static void __inline__ i810_draw_triangle( i810ContextPtr imesa,
 }
 
 
-static void __inline__ i810_draw_quad( i810ContextPtr imesa,
+static __inline__ void i810_draw_quad( i810ContextPtr imesa,
                                       i810VertexPtr v0,
                                       i810VertexPtr v1,
                                       i810VertexPtr v2,
@@ -199,10 +199,10 @@ do {                                              \
 
 
 static struct {
-   points_func         points;
-   line_func           line;
-   triangle_func       triangle;
-   quad_func           quad;
+   tnl_points_func             points;
+   tnl_line_func               line;
+   tnl_triangle_func   triangle;
+   tnl_quad_func               quad;
 } rast_tab[I810_MAX_TRIFUNC];
 
 
@@ -224,24 +224,6 @@ static struct {
 #define VERTEX            i810Vertex
 #define TAB               rast_tab
 
-/* Only used to pull back colors into vertices (ie, we know color is
- * floating point).
- */
-#define I810_COLOR( dst, src )                 \
-do {                                           \
-   dst[0] = src[2];                            \
-   dst[1] = src[1];                            \
-   dst[2] = src[0];                            \
-   dst[3] = src[3];                            \
-} while (0)
-
-#define I810_SPEC( dst, src )                  \
-do {                                           \
-   dst[0] = src[2];                            \
-   dst[1] = src[1];                            \
-   dst[2] = src[0];                            \
-} while (0)
-
 
 #define DEPTH_SCALE (1.0/0xffff)
 #define UNFILLED_TRI unfilled_tri
@@ -250,15 +232,38 @@ do {                                              \
 #define VERT_Y(_v) _v->v.y
 #define VERT_Z(_v) _v->v.z
 #define AREA_IS_CCW( a ) (a > 0)
-#define GET_VERTEX(e) (imesa->verts + (e<<imesa->vertex_stride_shift))
+#define GET_VERTEX(e) (imesa->verts + (e * imesa->vertex_size * sizeof(int)))
+
+#define VERT_SET_RGBA( v, c )                                          \
+do {                                                           \
+   i810_color_t *color = (i810_color_t *)&((v)->ui[coloroffset]);      \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->red, (c)[0]);               \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->green, (c)[1]);             \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->blue, (c)[2]);              \
+   UNCLAMPED_FLOAT_TO_UBYTE(color->alpha, (c)[3]);             \
+} while (0)
 
-#define VERT_SET_RGBA( v, c )    I810_COLOR( v->ub4[coloroffset], c )
 #define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
+
+#define VERT_SET_SPEC( v0, c )                                 \
+do {                                                           \
+   if (havespec) {                                             \
+      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.red, (c)[0]);    \
+      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.green, (c)[1]);  \
+      UNCLAMPED_FLOAT_TO_UBYTE(v0->v.specular.blue, (c)[2]);   \
+   }                                                           \
+} while (0)
+#define VERT_COPY_SPEC( v0, v1 )                       \
+do {                                                   \
+   if (havespec) {                                     \
+      v0->v.specular.red   = v1->v.specular.red;       \
+      v0->v.specular.green = v1->v.specular.green;     \
+      v0->v.specular.blue  = v1->v.specular.blue;      \
+   }                                                   \
+} while (0)
+
 #define VERT_SAVE_RGBA( idx )    color[idx] = v[idx]->ui[coloroffset]
 #define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
-
-#define VERT_SET_SPEC( v, c )    if (havespec) I810_SPEC( v->ub4[5], c )
-#define VERT_COPY_SPEC( v0, v1 ) if (havespec) COPY_3V(v0->ub4[5], v1->ub4[5])
 #define VERT_SAVE_SPEC( idx )    if (havespec) spec[idx] = v[idx]->ui[5]
 #define VERT_RESTORE_SPEC( idx ) if (havespec) v[idx]->ui[5] = spec[idx]
 
@@ -440,7 +445,7 @@ i810_fallback_point( i810ContextPtr imesa,
 /**********************************************************************/
 
 #define IND 0
-#define V(x) (i810Vertex *)(vertptr + ((x)<<vertshift))
+#define V(x) (i810Vertex *)(vertptr + ((x)*vertsize*sizeof(int)))
 #define RENDER_POINTS( start, count )  \
    for ( ; start < count ; start++) POINT( V(ELT(start)) );
 #define RENDER_LINE( v0, v1 )         LINE( V(v0), V(v1) )
@@ -451,7 +456,7 @@ i810_fallback_point( i810ContextPtr imesa,
 #define LOCAL_VARS                                             \
     i810ContextPtr imesa = I810_CONTEXT(ctx);                  \
     GLubyte *vertptr = (GLubyte *)imesa->verts;                        \
-    const GLuint vertshift = imesa->vertex_stride_shift;               \
+    const GLuint vertsize = imesa->vertex_size;        \
     const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts;      \
     (void) elt;
 #define RESET_STIPPLE
@@ -509,7 +514,6 @@ static void i810FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
    GLuint vertsize = imesa->vertex_size;
    GLuint *vb = i810AllocDmaLow( imesa, (n-2) * 3 * 4 * vertsize );
    GLubyte *vertptr = (GLubyte *)imesa->verts;
-   const GLuint vertshift = imesa->vertex_stride_shift;
    const GLuint *start = (const GLuint *)V(elts[0]);
    int i,j;