summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorDave Airlie <airliedfreedesktop.org>2004-02-12 11:20:29 +0000
committerDave Airlie <airliedfreedesktop.org>2004-02-12 11:20:29 +0000
commitda8337ed5e52741321ee5171ce0b0c43f09036c9 (patch)
treec3b76187188481acc786fb9b2826b29cd51077ba /src/mesa/drivers
parent9a78c29f7a48221e5211d918a53270a5edf9edaa (diff)
fix up specular color/fog and triangle vertex retrieval
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_native_vbtmp.h47
-rw-r--r--src/mesa/drivers/dri/mach64/mach64_tris.c21
2 files changed, 37 insertions, 31 deletions
diff --git a/src/mesa/drivers/dri/mach64/mach64_native_vbtmp.h b/src/mesa/drivers/dri/mach64/mach64_native_vbtmp.h
index c7cb7984096..b924bcc86d5 100644
--- a/src/mesa/drivers/dri/mach64/mach64_native_vbtmp.h
+++ b/src/mesa/drivers/dri/mach64/mach64_native_vbtmp.h
@@ -123,8 +123,13 @@ static void TAG(emit)( GLcontext *ctx,
#endif
#if DO_SPEC
- spec = VB->SecondaryColorPtr[0]->data;
- spec_stride = VB->SecondaryColorPtr[0]->stride;
+ if (VB->SecondaryColorPtr[0]) {
+ spec = VB->SecondaryColorPtr[0]->data;
+ spec_stride = VB->SecondaryColorPtr[0]->stride;
+ } else {
+ spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
+ spec_stride = 0;
+ }
#endif
#if DO_FOG
@@ -148,17 +153,16 @@ static void TAG(emit)( GLcontext *ctx,
if (start) {
#if DO_TEX1
- tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride);
+ STRIDE_4F(tc1, start * tc1_stride);
#endif
#if DO_TEX0
- tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride);
+ STRIDE_4F(tc0, start * tc0_stride);
#endif
#if DO_SPEC
STRIDE_4F(spec, start * spec_stride);
#endif
#if DO_FOG
- /* STRIDE_F(fog, start * fog_stride); */
- fog = (GLfloat (*)[4])((GLubyte *)fog + start * fog_stride);
+ STRIDE_4F(fog, start * fog_stride);
#endif
#if DO_RGBA
STRIDE_4F(col, start * col_stride);
@@ -207,7 +211,7 @@ static void TAG(emit)( GLcontext *ctx,
#if DO_PTEX
}
#endif /* DO_PTEX */
- tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride);
+ STRIDE_4F(tc1, tc1_stride);
#else /* !DO_TEX1 */
p += 3;
#endif /* !DO_TEX1 */
@@ -239,20 +243,22 @@ static void TAG(emit)( GLcontext *ctx,
#if DO_PTEX
}
#endif /* DO_PTEX */
- tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
+ STRIDE_4F(tc0, tc0_stride);
#else /* !DO_TEX0 */
p += 3;
#endif /* !DO_TEX0 */
#if DO_SPEC
- ((GLubyte *)p)[0] = spec[0][2]; /* VERTEX_?_SPEC_B */
- ((GLubyte *)p)[1] = spec[0][1]; /* VERTEX_?_SPEC_G */
- ((GLubyte *)p)[2] = spec[0][0]; /* VERTEX_?_SPEC_R */
+ UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[0], spec[0][2]); /* VERTEX_?_SPEC_B */
+ UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[1], spec[0][1]); /* VERTEX_?_SPEC_G */
+ UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[2], spec[0][0]); /* VERTEX_?_SPEC_R */
+
STRIDE_4F(spec, spec_stride);
#endif
#if DO_FOG
- ((GLubyte *)p)[3] = fog[0][0] * 255.0; /* VERTEX_?_SPEC_A */
- fog = (GLfloat (*)[4])((GLubyte *)fog + fog_stride);
+ UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[3], fog[0][0]); /* VERTEX_?_SPEC_A */
+ /* ((GLubyte *)p)[3] = fog[0][0] * 255.0; */
+ STRIDE_4F(fog, fog_stride);
#endif
p++;
@@ -349,14 +355,15 @@ static void TAG(interp)( GLcontext *ctx,
LOCALVARS
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
GLubyte *ddverts = GET_VERTEX_STORE();
- GLuint shift = GET_VERTEX_STRIDE_SHIFT();
+ /* GLuint shift = GET_VERTEX_STRIDE_SHIFT();*/
+ GLuint size = GET_VERTEX_SIZE();
const GLfloat *dstclip = VB->ClipPtr->data[edst];
GLfloat w;
const GLfloat *s = GET_VIEWPORT_MAT();
- CARD32 *dst = (CARD32 *)(ddverts + (edst << shift));
- CARD32 *in = (CARD32 *)(ddverts + (ein << shift));
- CARD32 *out = (CARD32 *)(ddverts + (eout << shift));
+ CARD32 *dst = (CARD32 *)(ddverts + (edst * size));
+ CARD32 *in = (CARD32 *)(ddverts + (ein * size));
+ CARD32 *out = (CARD32 *)(ddverts + (eout * size));
(void)s;
@@ -511,9 +518,9 @@ static void TAG(interp)( GLcontext *ctx,
(VIEWPORT_X( dstclip[0] * w ) << 16) | /* VERTEX_?_X */
(VIEWPORT_Y( dstclip[1] * w ) & 0xffff) ); /* VERTEX_?_Y */
- assert( dst + 1 - (CARD32 *)(ddverts + (edst << shift)) == 10 );
- assert( in + 2 - (CARD32 *)(ddverts + (ein << shift)) == 10 );
- assert( out + 2 - (CARD32 *)(ddverts + (eout << shift)) == 10 );
+ assert( dst + 1 - (CARD32 *)(ddverts + (edst * size)) == 10 );
+ assert( in + 2 - (CARD32 *)(ddverts + (ein * size)) == 10 );
+ assert( out + 2 - (CARD32 *)(ddverts + (eout * size)) == 10 );
if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) {
fprintf( stderr, "%s: dst vert: %.2f %.2f %.2f %x\n",
diff --git a/src/mesa/drivers/dri/mach64/mach64_tris.c b/src/mesa/drivers/dri/mach64/mach64_tris.c
index 9692b3cae02..64f69d24776 100644
--- a/src/mesa/drivers/dri/mach64/mach64_tris.c
+++ b/src/mesa/drivers/dri/mach64/mach64_tris.c
@@ -1265,21 +1265,21 @@ static struct {
#define VERT_SET_Z(_v,val) LE32_OUT( &(_v)->ui[zoffset], (GLuint)(val) )
#define VERT_Z_ADD(_v,val) LE32_OUT( &(_v)->ui[zoffset], LE32_IN( &(_v)->ui[zoffset] ) + (GLuint)(val) )
#define AREA_IS_CCW( a ) ((a) < 0)
-#define GET_VERTEX(e) (mmesa->verts + ((e)<<mmesa->vertex_stride_shift))
+#define GET_VERTEX(e) (mmesa->verts + ((e) * mmesa->vertex_size * sizeof(int)))
#define MACH64_COLOR( dst, src ) \
do { \
- dst[0] = src[2]; \
- dst[1] = src[1]; \
- dst[2] = src[0]; \
- dst[3] = src[3]; \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[0], src[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[1], src[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[2], src[0]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[3], src[3]); \
} while (0)
#define MACH64_SPEC( dst, src ) \
do { \
- dst[0] = src[2]; \
- dst[1] = src[1]; \
- dst[2] = src[0]; \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[0], src[2]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[1], src[1]); \
+ UNCLAMPED_FLOAT_TO_UBYTE(dst[2], src[0]); \
} while (0)
#define VERT_SET_RGBA( v, c ) MACH64_COLOR( v->ub4[coloroffset], c )
@@ -1508,7 +1508,7 @@ mach64_fallback_point( mach64ContextPtr mmesa,
/* Render unclipped begin/end objects */
/**********************************************************************/
-#define VERT(x) (mach64Vertex *)(mach64verts + ((x) << shift))
+#define VERT(x) (mach64Vertex *)(mach64verts + ((x) * vertsize * sizeof(int)))
#define RENDER_POINTS( start, count ) \
for ( ; start < count ; start++) \
mach64_draw_point( mmesa, VERT(start) )
@@ -1525,7 +1525,7 @@ mach64_fallback_point( mach64ContextPtr mmesa,
#undef LOCAL_VARS
#define LOCAL_VARS \
mach64ContextPtr mmesa = MACH64_CONTEXT(ctx); \
- const GLuint shift = mmesa->vertex_stride_shift; \
+ const GLuint vertsize = mmesa->vertex_size; \
const char *mach64verts = (char *)mmesa->verts; \
const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
(void) elt;
@@ -1590,7 +1590,6 @@ static void mach64FastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
unsigned vbsiz = (vertsize + (vertsize > 7 ? 2 : 1)) * n + (n-2);
CARD32 *vb, *vbchk;
GLubyte *mach64verts = (GLubyte *)mmesa->verts;
- const GLuint shift = mmesa->vertex_stride_shift;
mach64VertexPtr v0, v1, v2;
int i;