summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/glide/fxvbtmp.h
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2001-07-12 22:09:21 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2001-07-12 22:09:21 +0000
commit1182ffeec39bf419928ba862c225e80a439fee7a (patch)
treeaf9e3f9019e3c59cb73d770eb60e94c5c77bdd25 /src/mesa/drivers/glide/fxvbtmp.h
parentfae7b778b81b686ef419f971064b5fe12fb4ead3 (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/drivers/glide/fxvbtmp.h')
-rw-r--r--src/mesa/drivers/glide/fxvbtmp.h392
1 files changed, 244 insertions, 148 deletions
diff --git a/src/mesa/drivers/glide/fxvbtmp.h b/src/mesa/drivers/glide/fxvbtmp.h
index 24d5b521a0..570e7adf16 100644
--- a/src/mesa/drivers/glide/fxvbtmp.h
+++ b/src/mesa/drivers/glide/fxvbtmp.h
@@ -1,181 +1,277 @@
-/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the "Software"),
- * to deal in the Software without restriction, including without limitation
- * the rights to use, copy, modify, merge, publish, distribute, sublicense,
- * and/or sell copies of the Software, and to permit persons to whom the
- * Software is furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included
- * in all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- * Author:
- * Keith Whitwell <keith@precisioninsight.com>
- */
-
-
-static void
-NAME(GLcontext * ctx, GLuint start, GLuint end)
+static void TAG(emit)( GLcontext *ctx,
+ GLuint start, GLuint end,
+ void *dest )
{
- fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
- fxVertex *verts = fxMesa->verts;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
GLuint tmu0_source = fxMesa->tmu_source[0];
GLuint tmu1_source = fxMesa->tmu_source[1];
- GLfloat (*tmu0_data)[4];
- GLfloat (*tmu1_data)[4];
- GLfloat (*color)[4];
- GLfloat (*proj)[4] = VB->ProjectedClipPtr->data;
- fxVertex *v = &verts[start];
- GLfloat sscale0 = fxMesa->s0scale;
- GLfloat tscale0 = fxMesa->t0scale;
- GLfloat sscale1 = fxMesa->s1scale;
- GLfloat tscale1 = fxMesa->t1scale;
- GLubyte *clipmask = VB->ClipMask;
- GLuint i;
+ GLfloat (*tc0)[4], (*tc1)[4];
+ GLubyte (*col)[4];
+ GLuint tc0_stride, tc1_stride, col_stride;
+ GLuint tc0_size, tc1_size;
+ GLfloat (*proj)[4] = VB->ProjectedClipPtr->data;
+ GLuint proj_stride = VB->ProjectedClipPtr->stride;
+ GrVertex *v = (GrVertex *)dest;
+ GLfloat u0scale,v0scale,u1scale,v1scale;
const GLfloat *const s = ctx->Viewport._WindowMap.m;
+ int i;
- if (IND & SETUP_TMU0)
- tmu0_data = VB->TexCoordPtr[tmu0_source]->data;
- if (IND & SETUP_TMU1)
- tmu1_data = VB->TexCoordPtr[tmu1_source]->data;
+ if (IND & SETUP_TMU0) {
+ tc0_stride = VB->TexCoordPtr[tmu0_source]->stride;
+ tc0 = VB->TexCoordPtr[tmu0_source]->data;
+ u0scale = fxMesa->s0scale;
+ v0scale = fxMesa->t0scale;
+ if (IND & SETUP_PTEX)
+ tc0_size = VB->TexCoordPtr[tmu0_source]->size;
+ }
+
+ if (IND & SETUP_TMU1) {
+ tc1 = VB->TexCoordPtr[tmu1_source]->data;
+ tc1_stride = VB->TexCoordPtr[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;
+ }
+
+ 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;
+ }
- if (IND & SETUP_RGBA)
- color = VB->ColorPtr[0]->Ptr;
+ if (start) {
+ proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_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);
+ }
- if (VB->ClipOrMask) {
- for (i = start; i < end; i++, v++) {
- if (!clipmask[i]) {
- if (IND & SETUP_XYZW) {
- v->v.x = s[0] * proj[i][0] + s[12];
- v->v.y = s[5] * proj[i][1] + s[13];
- v->v.ooz = s[10] * proj[i][2] + s[14];
- v->v.oow = proj[i][3];
+ for (i=start; i < end; i++, v++) {
+ 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 (IND & SETUP_SNAP) {
#if defined(USE_IEEE)
- const float snapper = (3L << 18);
- v->v.x += snapper;
- v->v.x -= snapper;
- v->v.y += snapper;
- v->v.y -= snapper;
+ const float snapper = (3L << 18);
+ v->x += snapper;
+ v->x -= snapper;
+ v->y += snapper;
+ v->y -= snapper;
#else
- v->v.x = ((int) (v->v.x * 16.0f)) * (1.0f / 16.0f);
- v->v.y = ((int) (v->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
- }
- }
- if (IND & SETUP_RGBA) {
- UNCLAMPED_FLOAT_TO_UBYTE(v->v.r, color[i][0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v->v.g, color[i][1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v->v.b, color[i][2]);
- UNCLAMPED_FLOAT_TO_UBYTE(v->v.a, color[i][3]);
- }
- if (IND & SETUP_TMU0) {
- v->v.tmuvtx[0].sow = sscale0 * tmu0_data[i][0] * v->v.oow;
- v->v.tmuvtx[0].tow = tscale0 * tmu0_data[i][1] * v->v.oow;
- }
- if (IND & SETUP_TMU1) {
- v->v.tmuvtx[1].sow = sscale1 * tmu1_data[i][0] * v->v.oow;
- v->v.tmuvtx[1].tow = tscale1 * tmu1_data[i][1] * v->v.oow;
- }
}
+
+ 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 (IND & SETUP_TMU0) {
+ GLfloat w = v->oow;
+ 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;
+ }
+ tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
+ }
+ if (IND & SETUP_TMU1) {
+ GLfloat w = v->oow;
+ 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;
+ }
+ 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);
+ }
}
- else {
- for (i = start; i < end; i++, v++) {
- if (IND & SETUP_XYZW) {
- v->v.x = s[0] * proj[i][0] + s[12];
- v->v.y = s[5] * proj[i][1] + s[13];
- v->v.ooz = s[10] * proj[i][2] + s[14];
- v->v.oow = proj[i][3];
-
- if (IND & SETUP_SNAP) {
+}
+
+#if (IND & SETUP_XYZW) && (IND & SETUP_RGBA)
+
+static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
+{
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
+
+ if (IND & SETUP_PTEX)
+ return GL_TRUE;
+
+ if (IND & SETUP_TMU0) {
+ 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->TexCoordPtr[1]->size == 4)
+ return GL_FALSE;
+ }
+
+ if (VB->TexCoordPtr[0]->size == 4)
+ return GL_FALSE;
+ }
+
+ return GL_TRUE;
+}
+
+static void TAG(interp)( GLcontext *ctx,
+ GLfloat t,
+ GLuint edst, GLuint eout, GLuint ein,
+ GLboolean force_boundary )
+{
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ const GLfloat *dstclip = VB->ClipPtr->data[edst];
+ const GLfloat oow = (dstclip[3] == 0.0F) ? 1.0F : (1.0F / dstclip[3]);
+ const GLfloat *const s = ctx->Viewport._WindowMap.m;
+ GrVertex *fxverts = fxMesa->verts;
+ 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;
+
+ dst->x = s[0] * dstclip[0] * oow + s[12];
+ dst->y = s[5] * dstclip[1] * oow + s[13];
+ dst->z = s[10] * dstclip[2] * oow + s[14];
+ dst->oow = oow;
+
+ if (IND & SETUP_SNAP) {
#if defined(USE_IEEE)
- const float snapper = (3L << 18);
- v->v.x += snapper;
- v->v.x -= snapper;
- v->v.y += snapper;
- v->v.y -= snapper;
+ const float snapper = (3L << 18);
+ dst->x += snapper;
+ dst->x -= snapper;
+ dst->y += snapper;
+ dst->y -= snapper;
#else
- v->v.x = ((int) (v->v.x * 16.0f)) * (1.0f / 16.0f);
- v->v.y = ((int) (v->v.y * 16.0f)) * (1.0f / 16.0f);
+ dst->x = ((int) (dst->x * 16.0f)) * (1.0f / 16.0f);
+ dst->y = ((int) (dst->y * 16.0f)) * (1.0f / 16.0f);
#endif
- }
- }
- if (IND & SETUP_RGBA) {
- UNCLAMPED_FLOAT_TO_UBYTE(v->v.r, color[i][0]);
- UNCLAMPED_FLOAT_TO_UBYTE(v->v.g, color[i][1]);
- UNCLAMPED_FLOAT_TO_UBYTE(v->v.b, color[i][2]);
- UNCLAMPED_FLOAT_TO_UBYTE(v->v.a, color[i][3]);
- }
- if (IND & SETUP_TMU0) {
- v->v.tmuvtx[0].sow = sscale0 * tmu0_data[i][0] * v->v.oow;
- v->v.tmuvtx[0].tow = tscale0 * tmu0_data[i][1] * v->v.oow;
- }
- if (IND & SETUP_TMU1) {
- v->v.tmuvtx[1].sow = sscale1 * tmu1_data[i][0] * v->v.oow;
- v->v.tmuvtx[1].tow = tscale1 * tmu1_data[i][1] * v->v.oow;
- }
- }
}
- if ((IND & SETUP_XYZW) &&
- ctx->ProjectionMatrix.m[15] != 0.0F && ctx->Fog.Enabled) {
- fx_fake_fog_w(ctx, v, VB, start, end);
- }
+
+ 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 );
- /* Check for and enable projective texturing in each texture unit.
- */
- if (IND & (SETUP_TMU0 | SETUP_TMU1)) {
- GLuint tmu0_sz = 2;
- GLuint tmu1_sz = 2;
- GLuint hs = fxMesa->stw_hint_state & ~(GR_STWHINT_W_DIFF_TMU0 |
- GR_STWHINT_W_DIFF_TMU1);
-
- if (VB->TexCoordPtr[tmu0_source])
- tmu0_sz = VB->TexCoordPtr[tmu0_source]->size;
-
- if (VB->TexCoordPtr[tmu1_source])
- tmu1_sz = VB->TexCoordPtr[tmu1_source]->size;
-
- if (tmu0_sz == 4) {
- project_texcoords(v, VB, 0, tmu0_source, start, end);
- if (tmu1_sz == 4)
- project_texcoords(v, VB, 1, tmu1_source, start, end);
- else
- copy_w(v, VB, 1, start, end);
- hs |= (GR_STWHINT_W_DIFF_TMU0 | GR_STWHINT_W_DIFF_TMU1);
- }
- else if (tmu1_sz == 4) {
- project_texcoords(v, VB, 1, tmu1_source, start, end);
- hs |= GR_STWHINT_W_DIFF_TMU1;
+ if (IND & SETUP_TMU0) {
+ 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) {
+ 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 );
- if (hs != fxMesa->stw_hint_state) {
- fxMesa->stw_hint_state = hs;
- FX_grHints(GR_HINT_STWHINT, hs);
+ dst->tmuvtx[1].sow *= oow;
+ dst->tmuvtx[1].tow *= oow;
}
}
}
+#endif
+
+static void TAG(init)( void )
+{
+ setup_tab[IND].emit = TAG(emit);
+
+#if ((IND & SETUP_XYZW) && (IND & SETUP_RGBA))
+ setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
+ setup_tab[IND].interp = TAG(interp);
+ 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;
+ }
+#endif
+}
#undef IND
-#undef NAME
-#undef INPUTS
+#undef TAG