From c11039979c0736877d161c219cd9cd257300bf21 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 8 Dec 2003 13:21:22 +0000 Subject: get tdfx compiling --- src/mesa/drivers/dri/tdfx/tdfx_context.c | 10 +-- src/mesa/drivers/dri/tdfx/tdfx_context.h | 5 -- src/mesa/drivers/dri/tdfx/tdfx_tris.c | 2 +- src/mesa/drivers/dri/tdfx/tdfx_vb.c | 41 +-------- src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h | 143 +++++++------------------------ 5 files changed, 38 insertions(+), 163 deletions(-) (limited to 'src/mesa/drivers') diff --git a/src/mesa/drivers/dri/tdfx/tdfx_context.c b/src/mesa/drivers/dri/tdfx/tdfx_context.c index f3a719146d..2bc7de00e9 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_context.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_context.c @@ -91,7 +91,7 @@ static void tdfxDDInitExtensions( GLcontext *ctx ) -static const struct gl_pipeline_stage *tdfx_pipeline[] = { +static const struct tnl_pipeline_stage *tdfx_pipeline[] = { &_tnl_vertex_transform_stage, &_tnl_normal_transform_stage, &_tnl_lighting_stage, /* REMOVE: fog coord stage */ @@ -346,7 +346,7 @@ tdfxInitContext( __DRIdrawablePrivate *driDrawPriv, tdfxContextPtr fxMesa ) FxI32 result[2]; if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, fxMesa ); + fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)fxMesa ); } #if DEBUG_LOCKING @@ -461,7 +461,7 @@ tdfxDestroyContext( __DRIcontextPrivate *driContextPriv ) tdfxContextPtr fxMesa = (tdfxContextPtr) driContextPriv->driverPrivate; if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, fxMesa ); + fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)fxMesa ); } if ( fxMesa ) { @@ -503,7 +503,7 @@ tdfxUnbindContext( __DRIcontextPrivate *driContextPriv ) tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, driContextPriv ); + fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driContextPriv ); } if ( driContextPriv && (tdfxContextPtr) driContextPriv == fxMesa ) { @@ -521,7 +521,7 @@ tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv, __DRIdrawablePrivate *driReadPriv ) { if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) { - fprintf( stderr, "%s( %p )\n", __FUNCTION__, driContextPriv ); + fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)driContextPriv ); } if ( driContextPriv ) { diff --git a/src/mesa/drivers/dri/tdfx/tdfx_context.h b/src/mesa/drivers/dri/tdfx/tdfx_context.h index 9b0c912769..4bf813061e 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_context.h +++ b/src/mesa/drivers/dri/tdfx/tdfx_context.h @@ -868,11 +868,6 @@ struct tdfx_context { struct tdfx_glide Glide; - - /* Temporaries for translating away float colors: - */ - struct gl_client_array UbyteColor; - /* Fallback rasterization functions */ tdfx_point_func draw_point; diff --git a/src/mesa/drivers/dri/tdfx/tdfx_tris.c b/src/mesa/drivers/dri/tdfx/tdfx_tris.c index bf50d7bca7..131c2f1a0e 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_tris.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_tris.c @@ -216,7 +216,7 @@ static void tdfx_print_vertex( GLcontext *ctx, const tdfxVertex *v ) { tdfxContextPtr imesa = TDFX_CONTEXT( ctx ); - fprintf(stderr, "vertex at %p\n", v); + fprintf(stderr, "vertex at %p\n", (void *)v); if (imesa->vertexFormat == TDFX_LAYOUT_TINY) { fprintf(stderr, "x %f y %f z %f\n", v->v.x, v->v.y, v->v.z); diff --git a/src/mesa/drivers/dri/tdfx/tdfx_vb.c b/src/mesa/drivers/dri/tdfx/tdfx_vb.c index de5b9360e0..3562ead19c 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_vb.c +++ b/src/mesa/drivers/dri/tdfx/tdfx_vb.c @@ -72,40 +72,9 @@ static struct { } setup_tab[TDFX_MAX_SETUP]; -static void import_float_colors( GLcontext *ctx ) -{ - struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - struct gl_client_array *from = VB->ColorPtr[0]; - struct gl_client_array *to = &TDFX_CONTEXT(ctx)->UbyteColor; - GLuint count = VB->Count; - if (!to->Ptr) { - to->Ptr = ALIGN_MALLOC( VB->Size * 4 * sizeof(GLubyte), 32 ); - to->Type = GL_UNSIGNED_BYTE; - } - /* No need to transform the same value 3000 times. - */ - if (!from->StrideB) { - to->StrideB = 0; - count = 1; - } - else - to->StrideB = 4 * sizeof(GLubyte); - - _math_trans_4ub( (GLubyte (*)[4]) to->Ptr, - from->Ptr, - from->StrideB, - from->Type, - from->Size, - 0, - count); - - VB->ColorPtr[0] = to; -} - - -#define GET_COLOR(ptr, idx) (((GLchan (*)[4])((ptr)->Ptr))[idx]) +#define GET_COLOR(ptr, idx) ((ptr)->data[idx]) static void interp_extras( GLcontext *ctx, @@ -270,7 +239,7 @@ void tdfxBuildVertices( GLcontext *ctx, GLuint start, GLuint count, if (!newinputs) return; - if (newinputs & VERT_BIT_CLIP) { + if (newinputs & VERT_BIT_POS) { setup_tab[fxMesa->SetupIndex].emit( ctx, start, count, v, stride ); } else { GLuint ind = 0; @@ -356,10 +325,4 @@ void tdfxFreeVB( GLcontext *ctx ) ALIGN_FREE(fxMesa->verts); fxMesa->verts = 0; } - - if (fxMesa->UbyteColor.Ptr) { - ALIGN_FREE(fxMesa->UbyteColor.Ptr); - fxMesa->UbyteColor.Ptr = 0; - } - } diff --git a/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h b/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h index 9925a10eab..fd693330da 100644 --- a/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h +++ b/src/mesa/drivers/dri/tdfx/tdfx_vbtmp.h @@ -9,7 +9,7 @@ static void TAG(emit)( GLcontext *ctx, tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; GLfloat (*tc0)[4], (*tc1)[4]; - GLubyte (*col)[4]; + GLfloat (*col)[4]; GLuint tc0_stride, tc1_stride, col_stride; GLuint tc0_size, tc1_size; GLfloat (*proj)[4] = VB->NdcPtr->data; @@ -43,13 +43,11 @@ static void TAG(emit)( GLcontext *ctx, } if (IND & TDFX_RGBA_BIT) { - if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE) - import_float_colors( ctx ); - col = VB->ColorPtr[0]->Ptr; - col_stride = VB->ColorPtr[0]->StrideB; + col = VB->ColorPtr[0]->data; + col_stride = VB->ColorPtr[0]->stride; } - if (VB->importable_data) { + { /* May have nonstandard strides: */ if (start) { @@ -59,7 +57,7 @@ static void TAG(emit)( GLcontext *ctx, if (IND & TDFX_TEX1_BIT) tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride); if (IND & TDFX_RGBA_BIT) - STRIDE_4UB(col, start * col_stride); + STRIDE_4F(col, start * col_stride); } for (i=start; i < end; i++, v = (tdfxVertex *)((GLubyte *)v + stride)) { @@ -77,17 +75,12 @@ static void TAG(emit)( GLcontext *ctx, proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride); } if (IND & TDFX_RGBA_BIT) { -#if 0 - *(GLuint *)&v->v.color = *(GLuint *)col; -#else - GLubyte *b = (GLubyte *) &v->v.color; - b[0] = col[0][2]; - b[1] = col[0][1]; - b[2] = col[0][0]; - b[3] = col[0][3]; - -#endif - STRIDE_4UB(col, col_stride); + GLubyte *b = (GLubyte *)&v[4]; + UNCLAMPED_FLOAT_TO_UBYTE(b[0], col[0][2]); + UNCLAMPED_FLOAT_TO_UBYTE(b[1], col[0][1]); + UNCLAMPED_FLOAT_TO_UBYTE(b[2], col[0][0]); + UNCLAMPED_FLOAT_TO_UBYTE(b[3], col[0][3]); + STRIDE_4F(col, col_stride); } if (IND & TDFX_TEX0_BIT) { GLfloat w = v->v.rhw; @@ -121,60 +114,6 @@ static void TAG(emit)( GLcontext *ctx, } } } - else { - for (i=start; i < end; i++, v = (tdfxVertex *)((GLubyte *)v + stride)) { - if (IND & TDFX_XYZ_BIT) { - if (mask[i] == 0) { - v->v.x = s[0] * proj[i][0] + s[12]; - v->v.y = s[5] * proj[i][1] + s[13]; - v->v.z = s[10] * proj[i][2] + s[14]; - v->v.rhw = proj[i][3]; - } else { - v->v.rhw = 1.0; - } - } - if (IND & TDFX_RGBA_BIT) { -#if 0 - *(GLuint *)&v->v.color = *(GLuint *)&col[i]; -#else - GLubyte *b = (GLubyte *) &v->v.color; - b[0] = col[i][2]; - b[1] = col[i][1]; - b[2] = col[i][0]; - b[3] = col[i][3]; - -#endif - } - if (IND & TDFX_TEX0_BIT) { - GLfloat w = v->v.rhw; - if (IND & TDFX_PTEX_BIT) { - v->pv.tu0 = tc0[i][0] * u0scale * w; - v->pv.tv0 = tc0[i][1] * v0scale * w; - v->pv.tq0 = w; - if (tc0_size == 4) - v->pv.tq0 = tc0[i][3] * w; - } - else { - v->v.tu0 = tc0[i][0] * u0scale * w; - v->v.tv0 = tc0[i][1] * v0scale * w; - } - } - if (IND & TDFX_TEX1_BIT) { - GLfloat w = v->v.rhw; - if (IND & TDFX_PTEX_BIT) { - v->pv.tu1 = tc1[i][0] * u1scale * w; - v->pv.tv1 = tc1[i][1] * v1scale * w; - v->pv.tq1 = w; - if (tc1_size == 4) - v->pv.tq1 = tc1[i][3] * w; - } - else { - v->v.tu1 = tc1[i][0] * u1scale * w; - v->v.tv1 = tc1[i][1] * v1scale * w; - } - } - } - } } #else #if (IND & TDFX_XYZ_BIT) @@ -183,7 +122,7 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, { tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLubyte (*col)[4]; + GLfloat (*col)[4]; GLuint col_stride; GLfloat (*proj)[4] = VB->NdcPtr->data; GLuint proj_stride = VB->NdcPtr->stride; @@ -198,20 +137,17 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, ASSERT(fxMesa->SetupIndex == (TDFX_XYZ_BIT|TDFX_RGBA_BIT)); ASSERT(stride == 16); - if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE) - import_float_colors( ctx ); - - col = (GLubyte (*)[4])VB->ColorPtr[0]->Ptr; - col_stride = VB->ColorPtr[0]->StrideB; + col = VB->ColorPtr[0]->data; + col_stride = VB->ColorPtr[0]->stride; ASSERT(VB->ColorPtr[0]->Type == GL_UNSIGNED_BYTE); /* Pack what's left into a 4-dword vertex. Color is in a different * place, and there is no 'w' coordinate. */ - if (VB->importable_data) { + { if (start) { proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride); - STRIDE_4UB(col, start * col_stride); + STRIDE_4F(col, start * col_stride); } for (i=start; i < end; i++, v+=4) { @@ -223,27 +159,11 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride); { GLubyte *b = (GLubyte *)&v[3]; - b[0] = col[0][2]; - b[1] = col[0][1]; - b[2] = col[0][0]; - b[3] = col[0][3]; - STRIDE_4UB(col, col_stride); - } - } - } - else { - for (i=start; i < end; i++, v+=4) { - if (mask[i] == 0) { - v[0] = s[0] * proj[i][0] + s[12]; - v[1] = s[5] * proj[i][1] + s[13]; - v[2] = s[10] * proj[i][2] + s[14]; - } - { - GLubyte *b = (GLubyte *)&v[3]; - b[0] = col[i][2]; - b[1] = col[i][1]; - b[2] = col[i][0]; - b[3] = col[i][3]; + UNCLAMPED_FLOAT_TO_UBYTE(b[0], col[0][2]); + UNCLAMPED_FLOAT_TO_UBYTE(b[1], col[0][1]); + UNCLAMPED_FLOAT_TO_UBYTE(b[2], col[0][0]); + UNCLAMPED_FLOAT_TO_UBYTE(b[3], col[0][3]); + STRIDE_4F(col, col_stride); } } } @@ -254,19 +174,16 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, { tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; - GLubyte (*col)[4]; + GLfloat (*col)[4]; GLuint col_stride; GLfloat *v = (GLfloat *)dest; int i; - if (VB->ColorPtr[0]->Type != GL_UNSIGNED_BYTE) - import_float_colors( ctx ); - - col = VB->ColorPtr[0]->Ptr; - col_stride = VB->ColorPtr[0]->StrideB; + col = VB->ColorPtr[0]->data; + col_stride = VB->ColorPtr[0]->stride; if (start) - STRIDE_4UB(col, col_stride * start); + STRIDE_4F(col, col_stride * start); /* Need to figure out where color is: */ @@ -277,11 +194,11 @@ static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, for (i=start; i < end; i++, STRIDE_F(v, stride)) { GLubyte *b = (GLubyte *)v; - b[0] = col[0][2]; - b[1] = col[0][1]; - b[2] = col[0][0]; - b[3] = col[0][3]; - STRIDE_4UB( col, col_stride ); + UNCLAMPED_FLOAT_TO_UBYTE(b[0], col[0][2]); + UNCLAMPED_FLOAT_TO_UBYTE(b[1], col[0][1]); + UNCLAMPED_FLOAT_TO_UBYTE(b[2], col[0][0]); + UNCLAMPED_FLOAT_TO_UBYTE(b[3], col[0][3]); + STRIDE_4F(col, col_stride); } } #endif -- cgit v1.2.3