X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmesa%2Fdrivers%2Fglide%2Ffxvbtmp.h;h=f7893c1573fb2943292834cbdce36e9516d2a642;hb=99ae9e8d7d57ae37629754edd5b1e3716611827f;hp=e53cf981f50bdb70cf7abc42b0f8b9ecedfc2a03;hpb=05a4b37707d2c598ea68c05d07a3d65bcbf5a076;p=mesa.git diff --git a/src/mesa/drivers/glide/fxvbtmp.h b/src/mesa/drivers/glide/fxvbtmp.h index e53cf981f50..f7893c1573f 100644 --- a/src/mesa/drivers/glide/fxvbtmp.h +++ b/src/mesa/drivers/glide/fxvbtmp.h @@ -1,5 +1,3 @@ -/* $Id: fxvbtmp.h,v 1.12 2002/10/29 20:28:57 brianp Exp $ */ - /* * Mesa 3-D graphics library * Version: 4.1 @@ -26,9 +24,14 @@ /* Authors: * Keith Whitwell + * Daniel Borca */ +#define VIEWPORT_X(dst,x) dst = s[0] * x + s[12] +#define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13] +#define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14] + static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end, void *dest ) @@ -38,110 +41,167 @@ static void TAG(emit)( GLcontext *ctx, GLuint tmu0_source = fxMesa->tmu_source[0]; GLuint tmu1_source = fxMesa->tmu_source[1]; GLfloat (*tc0)[4], (*tc1)[4]; - GLubyte (*col)[4]; - GLuint tc0_stride, tc1_stride, col_stride; - GLuint tc0_size, tc1_size; + GLfloat (*col)[4], (*spec)[4]; + GLuint tc0_stride, tc1_stride, col_stride, spec_stride; + GLuint tc0_size, tc1_size, col_size; GLfloat (*proj)[4] = VB->NdcPtr->data; GLuint proj_stride = VB->NdcPtr->stride; + GLfloat (*psize)[4]; + GLuint psize_stride; + GLfloat (*fog)[4]; + GLuint fog_stride; GrVertex *v = (GrVertex *)dest; GLfloat u0scale,v0scale,u1scale,v1scale; + const GLubyte *mask = VB->ClipMask; const GLfloat *const s = ctx->Viewport._WindowMap.m; int i; + if (IND & SETUP_PSIZ) { + psize = VB->PointSizePtr->data; + psize_stride = VB->PointSizePtr->stride; + } if (IND & SETUP_TMU0) { - tc0 = VB->TexCoordPtr[tmu0_source]->data; - tc0_stride = VB->TexCoordPtr[tmu0_source]->stride; + tc0 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->data; + tc0_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->stride; u0scale = fxMesa->s0scale; v0scale = fxMesa->t0scale; if (IND & SETUP_PTEX) - tc0_size = VB->TexCoordPtr[tmu0_source]->size; + tc0_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu0_source]->size; } if (IND & SETUP_TMU1) { - tc1 = VB->TexCoordPtr[tmu1_source]->data; - tc1_stride = VB->TexCoordPtr[tmu1_source]->stride; + tc1 = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->data; + tc1_stride = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->stride; u1scale = fxMesa->s1scale; /* wrong if tmu1_source == 0, possible? */ v1scale = fxMesa->t1scale; if (IND & SETUP_PTEX) - tc1_size = VB->TexCoordPtr[tmu1_source]->size; + tc1_size = VB->AttribPtr[_TNL_ATTRIB_TEX0 + tmu1_source]->size; } if (IND & SETUP_RGBA) { - 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->AttribPtr[_TNL_ATTRIB_COLOR0]->data; + col_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->stride; + col_size = VB->AttribPtr[_TNL_ATTRIB_COLOR0]->size; + } + + if (IND & SETUP_SPEC) { + spec = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->data; + spec_stride = VB->AttribPtr[_TNL_ATTRIB_COLOR1]->stride; + } + + if (IND & SETUP_FOGC) { + fog = VB->AttribPtr[_TNL_ATTRIB_FOG]->data; + fog_stride = VB->AttribPtr[_TNL_ATTRIB_FOG]->stride; } if (start) { proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride); + if (IND & SETUP_PSIZ) + psize = (GLfloat (*)[4])((GLubyte *)psize + start * psize_stride); if (IND & SETUP_TMU0) tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + start * tc0_stride); if (IND & SETUP_TMU1) tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride); if (IND & SETUP_RGBA) - STRIDE_4UB(col, start * col_stride); + STRIDE_4F(col, start * col_stride); + if (IND & SETUP_SPEC) + STRIDE_4F(spec, start * spec_stride); + if (IND & SETUP_FOGC) + fog = (GLfloat (*)[4])((GLubyte *)fog + start * fog_stride); } for (i=start; i < end; i++, v++) { + if (IND & SETUP_PSIZ) { + v->psize = psize[0][0]; + psize = (GLfloat (*)[4])((GLubyte *)psize + psize_stride); + } + if (IND & SETUP_XYZW) { - /* unclipped */ - v->x = s[0] * proj[0][0] + s[12]; - v->y = s[5] * proj[0][1] + s[13]; - v->ooz = s[10] * proj[0][2] + s[14]; - v->oow = proj[0][3]; - - if (IND & SETUP_SNAP) { + if (mask[i] == 0) { + /* unclipped */ + VIEWPORT_X(v->x, proj[0][0]); + VIEWPORT_Y(v->y, proj[0][1]); + VIEWPORT_Z(v->ooz, proj[0][2]); + v->oow = proj[0][3]; + + if (IND & SETUP_SNAP) { #if defined(USE_IEEE) - const float snapper = (3L << 18); - v->x += snapper; - v->x -= snapper; - v->y += snapper; - v->y -= snapper; + const float snapper = (3L << 18); + v->x += snapper; + v->x -= snapper; + v->y += snapper; + v->y -= snapper; #else - v->x = ((int) (v->x * 16.0f)) * (1.0f / 16.0f); - v->y = ((int) (v->y * 16.0f)) * (1.0f / 16.0f); + v->x = ((int) (v->x * 16.0f)) * (1.0f / 16.0f); + v->y = ((int) (v->y * 16.0f)) * (1.0f / 16.0f); #endif - } + } + } else { + /* clipped */ + v->oow = 1.0; + } proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride); } if (IND & SETUP_RGBA) { - v->r = (GLfloat) col[0][0]; - v->g = (GLfloat) col[0][1]; - v->b = (GLfloat) col[0][2]; - v->a = (GLfloat) col[0][3]; - STRIDE_4UB(col, col_stride); +#if FX_PACKEDCOLOR + UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[2], col[0][0]); + UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[1], col[0][1]); + UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[0], col[0][2]); + if (col_size == 4) { + UNCLAMPED_FLOAT_TO_UBYTE(v->pargb[3], col[0][3]); + } else { + v->pargb[3] = 255; + } +#else /* !FX_PACKEDCOLOR */ + CNORM(v->r, col[0][0]); + CNORM(v->g, col[0][1]); + CNORM(v->b, col[0][2]); + if (col_size == 4) { + CNORM(v->a, col[0][3]); + } else { + v->a = 255.0f; + } +#endif /* !FX_PACKEDCOLOR */ + STRIDE_4F(col, col_stride); + } + if (IND & SETUP_SPEC) { +#if FX_PACKEDCOLOR + UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[2], spec[0][0]); + UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[1], spec[0][1]); + UNCLAMPED_FLOAT_TO_UBYTE(v->pspec[0], spec[0][2]); +#else /* !FX_PACKEDCOLOR */ + CNORM(v->r1, spec[0][0]); + CNORM(v->g1, spec[0][1]); + CNORM(v->b1, spec[0][2]); +#endif /* !FX_PACKEDCOLOR */ + STRIDE_4F(spec, spec_stride); + } + if (IND & SETUP_FOGC) { + v->fog = CLAMP(fog[0][0], 0.0f, 1.0f); + fog = (GLfloat (*)[4])((GLubyte *)fog + fog_stride); } if (IND & SETUP_TMU0) { GLfloat w = v->oow; + v->tmuvtx[0].sow = tc0[0][0] * u0scale * w; + v->tmuvtx[0].tow = tc0[0][1] * v0scale * w; if (IND & SETUP_PTEX) { - v->tmuvtx[0].sow = tc0[0][0] * u0scale * w; - v->tmuvtx[0].tow = tc0[0][1] * v0scale * w; v->tmuvtx[0].oow = w; if (tc0_size == 4) - v->tmuvtx[0].oow = tc0[0][3] * w; - } - else { - v->tmuvtx[0].sow = tc0[0][0] * u0scale * w; - v->tmuvtx[0].tow = tc0[0][1] * v0scale * w; + v->tmuvtx[0].oow *= tc0[0][3]; } tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride); } if (IND & SETUP_TMU1) { GLfloat w = v->oow; + v->tmuvtx[1].sow = tc1[0][0] * u1scale * w; + v->tmuvtx[1].tow = tc1[0][1] * v1scale * w; if (IND & SETUP_PTEX) { - v->tmuvtx[1].sow = tc1[0][0] * u1scale * w; - v->tmuvtx[1].tow = tc1[0][1] * v1scale * w; v->tmuvtx[1].oow = w; if (tc1_size == 4) - v->tmuvtx[1].oow = tc1[0][3] * w; + v->tmuvtx[1].oow *= tc1[0][3]; } - else { - v->tmuvtx[1].sow = tc1[0][0] * u1scale * w; - v->tmuvtx[1].tow = tc1[0][1] * v1scale * w; - } tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride); } } @@ -160,14 +220,15 @@ static GLboolean TAG(check_tex_sizes)( GLcontext *ctx ) struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb; if (IND & SETUP_TMU1) { - if (VB->TexCoordPtr[0] == 0) - VB->TexCoordPtr[0] = VB->TexCoordPtr[1]; + if (VB->AttribPtr[_TNL_ATTRIB_TEX0] == 0) + VB->AttribPtr[_TNL_ATTRIB_TEX0] = VB->AttribPtr[_TNL_ATTRIB_TEX1]; - if (VB->TexCoordPtr[1]->size == 4) + if (VB->AttribPtr[_TNL_ATTRIB_TEX1]->size == 4) return GL_FALSE; } - if (VB->TexCoordPtr[0] && VB->TexCoordPtr[0]->size == 4) + if (VB->AttribPtr[_TNL_ATTRIB_TEX0] && + VB->AttribPtr[_TNL_ATTRIB_TEX0]->size == 4) return GL_FALSE; } @@ -188,12 +249,12 @@ static void TAG(interp)( GLcontext *ctx, GrVertex *dst = (GrVertex *) (fxverts + edst); const GrVertex *out = (const GrVertex *) (fxverts + eout); const GrVertex *in = (const GrVertex *) (fxverts + ein); - const GLfloat wout = 1.0F / out->oow; - const GLfloat win = 1.0F / in->oow; + const GLfloat wout = oow / out->oow; + const GLfloat win = oow / in->oow; - dst->x = s[0] * dstclip[0] * oow + s[12]; - dst->y = s[5] * dstclip[1] * oow + s[13]; - dst->ooz = s[10] * dstclip[2] * oow + s[14]; + VIEWPORT_X(dst->x, dstclip[0] * oow); + VIEWPORT_Y(dst->y, dstclip[1] * oow); + VIEWPORT_Z(dst->ooz, dstclip[2] * oow); dst->oow = oow; if (IND & SETUP_SNAP) { @@ -210,74 +271,65 @@ static void TAG(interp)( GLcontext *ctx, } +#if FX_PACKEDCOLOR + INTERP_UB( t, dst->pargb[0], out->pargb[0], in->pargb[0] ); + INTERP_UB( t, dst->pargb[1], out->pargb[1], in->pargb[1] ); + INTERP_UB( t, dst->pargb[2], out->pargb[2], in->pargb[2] ); + INTERP_UB( t, dst->pargb[3], out->pargb[3], in->pargb[3] ); +#else /* !FX_PACKEDCOLOR */ INTERP_F( t, dst->r, out->r, in->r ); INTERP_F( t, dst->g, out->g, in->g ); INTERP_F( t, dst->b, out->b, in->b ); INTERP_F( t, dst->a, out->a, in->a ); +#endif /* !FX_PACKEDCOLOR */ + + if (IND & SETUP_SPEC) { +#if FX_PACKEDCOLOR + INTERP_UB( t, dst->pspec[0], out->pspec[0], in->pspec[0] ); + INTERP_UB( t, dst->pspec[1], out->pspec[1], in->pspec[1] ); + INTERP_UB( t, dst->pspec[2], out->pspec[2], in->pspec[2] ); +#else /* !FX_PACKEDCOLOR */ + INTERP_F( t, dst->r1, out->r1, in->r1 ); + INTERP_F( t, dst->g1, out->g1, in->g1 ); + INTERP_F( t, dst->b1, out->b1, in->b1 ); +#endif /* !FX_PACKEDCOLOR */ + } + + if (IND & SETUP_FOGC) { + INTERP_F( t, dst->fog, out->fog, in->fog ); + } if (IND & SETUP_TMU0) { + INTERP_F( t, + dst->tmuvtx[0].sow, + out->tmuvtx[0].sow * wout, + in->tmuvtx[0].sow * win ); + INTERP_F( t, + dst->tmuvtx[0].tow, + out->tmuvtx[0].tow * wout, + in->tmuvtx[0].tow * win ); if (IND & SETUP_PTEX) { - INTERP_F( t, - dst->tmuvtx[0].sow, - out->tmuvtx[0].sow * wout, - in->tmuvtx[0].sow * win ); INTERP_F( t, - dst->tmuvtx[0].tow, - out->tmuvtx[0].tow * wout, - in->tmuvtx[0].tow * win ); - INTERP_F( t, dst->tmuvtx[0].oow, out->tmuvtx[0].oow * wout, in->tmuvtx[0].oow * win ); - - dst->tmuvtx[0].sow *= oow; - dst->tmuvtx[0].tow *= oow; - dst->tmuvtx[0].oow *= oow; - } else { - INTERP_F( t, - dst->tmuvtx[0].sow, - out->tmuvtx[0].sow * wout, - in->tmuvtx[0].sow * win ); - INTERP_F( t, - dst->tmuvtx[0].tow, - out->tmuvtx[0].tow * wout, - in->tmuvtx[0].tow * win ); - - dst->tmuvtx[0].sow *= oow; - dst->tmuvtx[0].tow *= oow; } } if (IND & SETUP_TMU1) { + INTERP_F( t, + dst->tmuvtx[1].sow, + out->tmuvtx[1].sow * wout, + in->tmuvtx[1].sow * win ); + INTERP_F( t, + dst->tmuvtx[1].tow, + out->tmuvtx[1].tow * wout, + in->tmuvtx[1].tow * win ); if (IND & SETUP_PTEX) { - INTERP_F( t, - dst->tmuvtx[1].sow, - out->tmuvtx[1].sow * wout, - in->tmuvtx[1].sow * win ); INTERP_F( t, - dst->tmuvtx[1].tow, - out->tmuvtx[1].tow * wout, - in->tmuvtx[1].tow * win ); - INTERP_F( t, dst->tmuvtx[1].oow, out->tmuvtx[1].oow * wout, in->tmuvtx[1].oow * win ); - - dst->tmuvtx[1].sow *= oow; - dst->tmuvtx[1].tow *= oow; - dst->tmuvtx[1].oow *= oow; - } else { - INTERP_F( t, - dst->tmuvtx[1].sow, - out->tmuvtx[1].sow * wout, - in->tmuvtx[1].sow * win ); - INTERP_F( t, - dst->tmuvtx[1].tow, - out->tmuvtx[1].tow * wout, - in->tmuvtx[1].tow * win ); - - dst->tmuvtx[1].sow *= oow; - dst->tmuvtx[1].tow *= oow; } } } @@ -288,20 +340,26 @@ static void TAG(init)( void ) { setup_tab[IND].emit = TAG(emit); + if (IND & SETUP_SPEC) { + setup_tab[IND].copy_pv = copy_pv2; + } else { + setup_tab[IND].copy_pv = copy_pv; + } + #if ((IND & SETUP_XYZW) && (IND & SETUP_RGBA)) setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes); setup_tab[IND].interp = TAG(interp); + setup_tab[IND].vertex_format = 0; if (IND & SETUP_PTEX) { - setup_tab[IND].vertex_format = (GR_STWHINT_W_DIFF_TMU0 | - GR_STWHINT_W_DIFF_TMU1); - } - else { - setup_tab[IND].vertex_format = 0; + setup_tab[IND].vertex_format |= GR_STWHINT_W_DIFF_TMU0; } #if (IND & SETUP_TMU1) - setup_tab[IND].vertex_format |= GR_STWHINT_ST_DIFF_TMU1; + setup_tab[IND].vertex_format |= GR_STWHINT_ST_DIFF_TMU1; + if (IND & SETUP_PTEX) { + setup_tab[IND].vertex_format |= GR_STWHINT_W_DIFF_TMU1; + } #endif #endif