diff options
author | Keith Whitwell <[email protected]> | 2001-07-12 22:09:21 +0000 |
---|---|---|
committer | Keith Whitwell <[email protected]> | 2001-07-12 22:09:21 +0000 |
commit | 1182ffeec39bf419928ba862c225e80a439fee7a (patch) | |
tree | af9e3f9019e3c59cb73d770eb60e94c5c77bdd25 /src/mesa/swrast_setup/ss_vbtmp.h | |
parent | fae7b778b81b686ef419f971064b5fe12fb4ead3 (diff) |
Rename some of the tnl->Driver.* functions to tnl->Driver.Render.*, to make it
clear that these are owned by t_vb_render.c.
Make swrast_setup opaque - it now hooks itself directly into
tnl->Driver.Render.*. Add a _swsetup_Wakeup() call that does this.
Update X11 (tested), osmesa and FX drivers for this change.
FX compiles but is probably broken as the changes there are large. It was the
only remaining driver that used the internal _swsetup_ functions for
interp and copy_pv. This usage has been replaced with code from the DRI
tdfx driver.
Diffstat (limited to 'src/mesa/swrast_setup/ss_vbtmp.h')
-rw-r--r-- | src/mesa/swrast_setup/ss_vbtmp.h | 238 |
1 files changed, 174 insertions, 64 deletions
diff --git a/src/mesa/swrast_setup/ss_vbtmp.h b/src/mesa/swrast_setup/ss_vbtmp.h index 9ef51a3c205..4a83cf23019 100644 --- a/src/mesa/swrast_setup/ss_vbtmp.h +++ b/src/mesa/swrast_setup/ss_vbtmp.h @@ -1,4 +1,4 @@ -/* $Id: ss_vbtmp.h,v 1.15 2001/04/30 09:04:00 keithw Exp $ */ +/* $Id: ss_vbtmp.h,v 1.16 2001/07/12 22:09:21 keithw Exp $ */ /* * Mesa 3-D graphics library @@ -28,19 +28,23 @@ */ -static void TAG(rs)(GLcontext *ctx, GLuint start, GLuint end, GLuint newinputs ) +static void TAG(emit)(GLcontext *ctx, GLuint start, GLuint end, + GLuint newinputs ) { TNLcontext *tnl = TNL_CONTEXT(ctx); struct vertex_buffer *VB = &tnl->vb; SWvertex *v; - GLfloat (*proj)[4]; /* projected clip coordinates */ - GLfloat (*tc[MAX_TEXTURE_UNITS])[4]; - GLfloat (*color)[4]; - GLfloat (*spec)[4]; + GLfloat *proj; /* projected clip coordinates */ + GLfloat *tc[MAX_TEXTURE_UNITS]; + GLfloat *color; + GLfloat *spec; GLuint *index; GLfloat *fog; GLfloat *pointSize; GLuint tsz[MAX_TEXTURE_UNITS]; + GLuint tstride[MAX_TEXTURE_UNITS]; + GLuint proj_stride, color_stride, spec_stride, index_stride; + GLuint fog_stride, pointSize_stride; GLuint i; GLfloat *m = ctx->Viewport._WindowMap.m; const GLfloat sx = m[0]; @@ -51,94 +55,200 @@ static void TAG(rs)(GLcontext *ctx, GLuint start, GLuint end, GLuint newinputs ) const GLfloat tz = m[14]; GLuint maxtex = 0; - /* Only the most basic optimization for cva: - */ - if (!newinputs) - return; - - /* TODO: Get import_client_data to pad vectors out to 4 cleanly. - * - * NOTE: This has the effect of converting any remaining ubyte - * colors to floats... As they're already there 90% of the - * time, this isn't a bad thing. - */ - if (VB->importable_data) - VB->import_data( ctx, VB->importable_data & newinputs, - (VB->ClipOrMask - ? VEC_NOT_WRITEABLE|VEC_BAD_STRIDE - : VEC_BAD_STRIDE)); - if (IND & TEX0) { - tc[0] = VB->TexCoordPtr[0]->data; + tc[0] = (GLfloat *)VB->TexCoordPtr[0]->data; tsz[0] = VB->TexCoordPtr[0]->size; + tstride[0] = VB->TexCoordPtr[0]->stride; } if (IND & MULTITEX) { for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++) { if (VB->TexCoordPtr[i]) { maxtex = i+1; - tc[i] = VB->TexCoordPtr[i]->data; + tc[i] = (GLfloat *)VB->TexCoordPtr[i]->data; tsz[i] = VB->TexCoordPtr[i]->size; + tstride[i] = VB->TexCoordPtr[i]->stride; } else tc[i] = 0; } } - /* Tie up some dangling pointers for flat/twoside code in ss_tritmp.h - */ - if ((ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) == 0) { - VB->SecondaryColorPtr[0] = VB->ColorPtr[0]; - VB->SecondaryColorPtr[1] = VB->ColorPtr[1]; - } - + proj = VB->ProjectedClipPtr->data[0]; + proj_stride = VB->ProjectedClipPtr->stride; - proj = VB->ProjectedClipPtr->data; - if (IND & FOG) + if (IND & FOG) { fog = VB->FogCoordPtr->data; - if (IND & COLOR) - color = (GLfloat (*)[4])VB->ColorPtr[0]->Ptr; - if (IND & SPEC) - spec = (GLfloat (*)[4])VB->SecondaryColorPtr[0]->Ptr; - if (IND & INDEX) + fog_stride = VB->FogCoordPtr->stride; + } + if (IND & COLOR) { + color = VB->ColorPtr[0]->Ptr; + color_stride = VB->ColorPtr[0]->StrideB; + } + if (IND & SPEC) { + spec = VB->SecondaryColorPtr[0]->Ptr; + spec_stride = VB->SecondaryColorPtr[0]->StrideB; + } + if (IND & INDEX) { index = VB->IndexPtr[0]->data; - if (IND & POINT) + index_stride = VB->IndexPtr[0]->stride; + } + if (IND & POINT) { pointSize = VB->PointSizePtr->data; + pointSize_stride = VB->PointSizePtr->stride; + } v = &(SWSETUP_CONTEXT(ctx)->verts[start]); for (i=start; i < end; i++, v++) { if (VB->ClipMask[i] == 0) { - v->win[0] = sx * proj[i][0] + tx; - v->win[1] = sy * proj[i][1] + ty; - v->win[2] = sz * proj[i][2] + tz; - v->win[3] = proj[i][3]; - - if (IND & TEX0) - COPY_CLEAN_4V( v->texcoord[0], tsz[0], tc[0][i] ); - - if (IND & MULTITEX) { - GLuint u; - for (u = 0 ; u < maxtex ; u++) - if (tc[u]) - COPY_CLEAN_4V( v->texcoord[u], tsz[u], tc[u][i] ); - } + v->win[0] = sx * proj[0] + tx; + v->win[1] = sy * proj[1] + ty; + v->win[2] = sz * proj[2] + tz; + v->win[3] = proj[3]; + } + STRIDE_F(proj, proj_stride); + + if (IND & TEX0) { + COPY_CLEAN_4V( v->texcoord[0], tsz[0], tc[0] ); + STRIDE_F(tc[0], tstride[0]); + } + + if (IND & MULTITEX) { + GLuint u; + for (u = 0 ; u < maxtex ; u++) + if (tc[u]) { + COPY_CLEAN_4V( v->texcoord[u], tsz[u], tc[u] ); + STRIDE_F(tc[u], tstride[u]); + } + } - if (IND & COLOR) - UNCLAMPED_FLOAT_TO_RGBA_CHAN(v->color, color[i]); + if (IND & COLOR) { + UNCLAMPED_FLOAT_TO_RGBA_CHAN(v->color, color); + STRIDE_F(color, color_stride); +/* COPY_CHAN4(v->color, color); */ +/* STRIDE_CHAN(color, color_stride); */ + } - if (IND & SPEC) - UNCLAMPED_FLOAT_TO_RGBA_CHAN(v->specular, spec[i]); + if (IND & SPEC) { + UNCLAMPED_FLOAT_TO_RGB_CHAN(v->specular, spec); + STRIDE_F(spec, spec_stride); +/* COPY_CHAN4(v->specular, spec); */ +/* STRIDE_CHAN(spec, spec_stride); */ + } - if (IND & FOG) - v->fog = fog[i]; + if (IND & FOG) { + v->fog = fog[0]; + STRIDE_F(fog, fog_stride); + } - if (IND & INDEX) - v->index = index[i]; + if (IND & INDEX) { + v->index = index[0]; + STRIDE_UI(index, index_stride); + } - if (IND & POINT) - v->pointSize = pointSize[i]; + if (IND & POINT) { + v->pointSize = pointSize[0]; + STRIDE_F(pointSize, pointSize_stride); } + + } +} + + + +static void TAG(interp)( GLcontext *ctx, + GLfloat t, + GLuint edst, GLuint eout, GLuint ein, + GLboolean force_boundary ) +{ + SScontext *swsetup = SWSETUP_CONTEXT(ctx); + struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; + GLfloat *m = ctx->Viewport._WindowMap.m; + GLfloat *clip = VB->ClipPtr->data[edst]; + + SWvertex *dst = &swsetup->verts[edst]; + SWvertex *in = &swsetup->verts[ein]; + SWvertex *out = &swsetup->verts[eout]; + + /* Avoid division by zero by rearranging order of clip planes? + */ + if (clip[3] != 0.0) { + GLfloat oow = 1.0F / clip[3]; + dst->win[0] = m[0] * clip[0] * oow + m[12]; + dst->win[1] = m[5] * clip[1] * oow + m[13]; + dst->win[2] = m[10] * clip[2] * oow + m[14]; + dst->win[3] = oow; } + +/* fprintf(stderr, "%s edst %d win %f %f %f %f\n", */ +/* __FUNCTION__, edst, */ +/* dst->win[0], dst->win[1], dst->win[2], dst->win[3]); */ + + if (IND & TEX0) { + INTERP_4F( t, dst->texcoord[0], out->texcoord[0], in->texcoord[0] ); + } + + if (IND & MULTITEX) { + GLuint u; + GLuint maxtex = ctx->Const.MaxTextureUnits; + for (u = 0 ; u < maxtex ; u++) + if (VB->TexCoordPtr[u]) { + INTERP_4F( t, dst->texcoord[u], out->texcoord[u], in->texcoord[u] ); + } + } + + if (IND & COLOR) { + INTERP_CHAN( t, dst->color[0], out->color[0], in->color[0] ); + INTERP_CHAN( t, dst->color[1], out->color[1], in->color[1] ); + INTERP_CHAN( t, dst->color[2], out->color[2], in->color[2] ); + INTERP_CHAN( t, dst->color[3], out->color[3], in->color[3] ); + } + + if (IND & SPEC) { + INTERP_CHAN( t, dst->specular[0], out->specular[0], in->specular[0] ); + INTERP_CHAN( t, dst->specular[1], out->specular[1], in->specular[1] ); + INTERP_CHAN( t, dst->specular[2], out->specular[2], in->specular[2] ); + } + + if (IND & FOG) { + INTERP_F( t, dst->fog, out->fog, in->fog ); + } + + if (IND & INDEX) { + INTERP_UI( t, dst->index, out->index, in->index ); + } + + if (IND & POINT) { + INTERP_F( t, dst->pointSize, out->pointSize, in->pointSize ); + } +} + + +static void TAG(copy_pv)( GLcontext *ctx, GLuint edst, GLuint esrc ) +{ + SScontext *swsetup = SWSETUP_CONTEXT(ctx); + SWvertex *dst = &swsetup->verts[edst]; + SWvertex *src = &swsetup->verts[esrc]; + + if (IND & COLOR) { + COPY_CHAN4( dst->color, src->color ); + } + + if (IND & SPEC) { + COPY_3V( dst->specular, src->specular ); + } + + if (IND & INDEX) { + dst->index = src->index; + } +} + + +static void TAG(init)( void ) +{ + setup_tab[IND] = TAG(emit); + interp_tab[IND] = TAG(interp); + copy_pv_tab[IND] = TAG(copy_pv); } #undef TAG |