summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2001-07-12 22:09:21 +0000
committerKeith Whitwell <[email protected]>2001-07-12 22:09:21 +0000
commit1182ffeec39bf419928ba862c225e80a439fee7a (patch)
treeaf9e3f9019e3c59cb73d770eb60e94c5c77bdd25 /src/mesa/drivers
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')
-rw-r--r--src/mesa/drivers/glide/fxdd.c95
-rw-r--r--src/mesa/drivers/glide/fxdrv.h136
-rw-r--r--src/mesa/drivers/glide/fxsetup.c148
-rw-r--r--src/mesa/drivers/glide/fxtris.c1119
-rw-r--r--src/mesa/drivers/glide/fxvb.c556
-rw-r--r--src/mesa/drivers/glide/fxvbtmp.h392
-rw-r--r--src/mesa/drivers/osmesa/osmesa.c17
-rw-r--r--src/mesa/drivers/x11/xm_dd.c19
8 files changed, 1211 insertions, 1271 deletions
diff --git a/src/mesa/drivers/glide/fxdd.c b/src/mesa/drivers/glide/fxdd.c
index 117e9d7dead..e645f65be68 100644
--- a/src/mesa/drivers/glide/fxdd.c
+++ b/src/mesa/drivers/glide/fxdd.c
@@ -674,11 +674,6 @@ fxDDInitFxMesaContext(fxMesaContext fxMesa)
if (getenv("FX_EMULATE_SINGLE_TMU"))
fxMesa->haveTwoTMUs = GL_FALSE;
- fxMesa->emulateTwoTMUs = fxMesa->haveTwoTMUs;
-
- if (!getenv("FX_DONT_FAKE_MULTITEX"))
- fxMesa->emulateTwoTMUs = GL_TRUE;
-
if (getenv("FX_GLIDE_SWAPINTERVAL"))
fxMesa->swapInterval = atoi(getenv("FX_GLIDE_SWAPINTERVAL"));
else
@@ -754,7 +749,7 @@ fxDDInitFxMesaContext(fxMesaContext fxMesa)
fxMesa->textureAlign = FX_grGetInteger(FX_TEXTURE_ALIGN);
fxMesa->glCtx->Const.MaxTextureLevels = 9;
- fxMesa->glCtx->Const.MaxTextureUnits = fxMesa->emulateTwoTMUs ? 2 : 1;
+ fxMesa->glCtx->Const.MaxTextureUnits = fxMesa->haveTwoTMUs ? 2 : 1;
fxMesa->new_state = _NEW_ALL;
/* Initialize the software rasterizer and helper modules.
@@ -783,10 +778,6 @@ fxDDInitFxMesaContext(fxMesaContext fxMesa)
fxDDInitExtensions(fxMesa->glCtx);
-#ifdef FXVTXFMT
- fxDDInitVtxfmt(fxMesa->glCtx);
-#endif
-
FX_grGlideGetState((GrState *) fxMesa->state);
/* Run the config file */
@@ -830,7 +821,7 @@ fxDDInitExtensions(GLcontext * ctx)
if (fxMesa->haveTwoTMUs)
_mesa_enable_extension(ctx, "GL_EXT_texture_env_add");
- if (fxMesa->emulateTwoTMUs)
+ if (fxMesa->haveTwoTMUs)
_mesa_enable_extension(ctx, "GL_ARB_multitexture");
}
@@ -843,8 +834,8 @@ fxDDInitExtensions(GLcontext * ctx)
*
* Performs similar work to fxDDChooseRenderState() - should be merged.
*/
-static GLboolean
-fxIsInHardware(GLcontext * ctx)
+GLboolean
+fx_check_IsInHardware(GLcontext * ctx)
{
fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
@@ -868,7 +859,7 @@ fxIsInHardware(GLcontext * ctx)
}
/* Unsupported texture/multitexture cases */
- if (fxMesa->emulateTwoTMUs) {
+ if (fxMesa->haveTwoTMUs) {
if (ctx->Texture._ReallyEnabled & (TEXTURE0_3D | TEXTURE1_3D))
return GL_FALSE; /* can't do 3D textures */
if (ctx->Texture._ReallyEnabled & (TEXTURE0_1D | TEXTURE1_1D))
@@ -939,6 +930,9 @@ fxIsInHardware(GLcontext * ctx)
return GL_TRUE;
}
+
+
+
static void
update_texture_scales(GLcontext * ctx)
{
@@ -980,79 +974,34 @@ fxDDUpdateDDPointers(GLcontext * ctx, GLuint new_state)
if (new_state & (_FX_NEW_IS_IN_HARDWARE |
_FX_NEW_RENDERSTATE |
- _FX_NEW_SETUP_FUNCTION | _NEW_TEXTURE)) {
+ _FX_NEW_SETUP_FUNCTION |
+ _NEW_TEXTURE)) {
if (new_state & _FX_NEW_IS_IN_HARDWARE)
- fxMesa->is_in_hardware = fxIsInHardware(ctx);
+ fxCheckIsInHardware(ctx);
if (fxMesa->new_state)
fxSetupFXUnits(ctx);
- if (new_state & _FX_NEW_RENDERSTATE)
- fxDDChooseRenderState(ctx);
+ if (fxMesa->is_in_hardware) {
+ if (new_state & _FX_NEW_RENDERSTATE)
+ fxDDChooseRenderState(ctx);
- if (new_state & _FX_NEW_SETUP_FUNCTION)
- tnl->Driver.BuildProjectedVertices = fx_validate_BuildProjVerts;
+ if (new_state & _FX_NEW_SETUP_FUNCTION)
+ fxDDChooseSetupState(ctx);
+ }
if (new_state & _NEW_TEXTURE)
update_texture_scales(ctx);
-
- }
-
-#ifdef FXVTXFMT
- if (fxMesa->allow_vfmt) {
- if (new_state & _NEW_LIGHT)
- fx_update_lighting(ctx);
-
- if (new_state & _FX_NEW_VTXFMT)
- fxDDCheckVtxfmt(ctx);
- }
-#endif
-}
-
-static void
-fxDDRenderPrimitive(GLcontext * ctx, GLenum mode)
-{
- fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
-
- if (!fxMesa->is_in_hardware) {
- _swsetup_RenderPrimitive(ctx, mode);
- }
- else {
- fxMesa->render_prim = mode;
}
}
-static void
-fxDDRenderStart(GLcontext * ctx)
-{
- fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
-
- _swsetup_RenderStart(ctx);
-
- if (fxMesa->new_state) {
- fxSetupFXUnits(ctx);
- }
-}
-
-static void
-fxDDRenderFinish(GLcontext * ctx)
-{
- fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
-
- if (!fxMesa->is_in_hardware) {
- _swsetup_RenderFinish(ctx);
- }
-}
-
void
fxSetupDDPointers(GLcontext * ctx)
{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
-
if (MESA_VERBOSE & VERBOSE_DRIVER) {
fprintf(stderr, "fxmesa: fxSetupDDPointers()\n");
}
@@ -1106,16 +1055,6 @@ fxSetupDDPointers(GLcontext * ctx)
ctx->Driver.ShadeModel = fxDDShadeModel;
ctx->Driver.Enable = fxDDEnable;
- tnl->Driver.RunPipeline = _tnl_run_pipeline;
- tnl->Driver.RenderStart = fxDDRenderStart;
- tnl->Driver.RenderFinish = fxDDRenderFinish;
- tnl->Driver.ResetLineStipple = _swrast_ResetLineStipple;
- tnl->Driver.RenderPrimitive = fxDDRenderPrimitive;
- tnl->Driver.RenderInterp = _swsetup_RenderInterp;
- tnl->Driver.RenderCopyPV = _swsetup_RenderCopyPV;
- tnl->Driver.RenderClippedLine = _swsetup_RenderClippedLine;
- tnl->Driver.RenderClippedPolygon = _swsetup_RenderClippedPolygon;
-
fxSetupDDSpanPointers(ctx);
fxDDUpdateDDPointers(ctx, ~0);
}
diff --git a/src/mesa/drivers/glide/fxdrv.h b/src/mesa/drivers/glide/fxdrv.h
index 0d4c7a45bd2..09674680c97 100644
--- a/src/mesa/drivers/glide/fxdrv.h
+++ b/src/mesa/drivers/glide/fxdrv.h
@@ -94,37 +94,6 @@ extern float gl_ubyte_to_float_255_color_tab[256];
-/* Should have size == 16 * sizeof(float).
- */
-typedef union
-{
- GrVertex v;
- GLfloat f[16];
- GLuint ui[16];
-}
-fxVertex;
-
-/* Used in the fxvtxfmt t&l engine.
- */
-typedef struct
-{
- GrVertex v;
- GLfloat clip[4];
- GLfloat texcoord[2][2];
- GLubyte mask;
- GLfloat normal[3]; /* for replay & fallback */
-}
-fxClipVertex;
-
-
-
-typedef void (*vfmt_project_func) (GLcontext * ctx, fxClipVertex * v);
-typedef void (*vfmt_interpolate_func) (GLfloat t,
- fxClipVertex * O,
- const fxClipVertex * I,
- const fxClipVertex * J);
-
-
#if defined(FXMESA_USE_ARGB)
#define FXCOLOR4( c ) ( \
@@ -147,14 +116,15 @@ typedef void (*vfmt_interpolate_func) (GLfloat t,
-/* fastpath/vtxfmt flags first
+/* fastpath flags first
*/
#define SETUP_TMU0 0x1
#define SETUP_TMU1 0x2
#define SETUP_RGBA 0x4
#define SETUP_SNAP 0x8
#define SETUP_XYZW 0x10
-#define MAX_SETUP 0x20
+#define SETUP_PTEX 0x20
+#define MAX_SETUP 0x40
#define FX_NUM_TMU 2
@@ -356,6 +326,7 @@ tfxUnitsState;
_DD_NEW_POINT_SIZE | \
_NEW_LINE)
+
/* Covers the state referenced by fxDDChooseSetupFunction.
*/
#define _FX_NEW_SETUP_FUNCTION (_NEW_LIGHT| \
@@ -364,18 +335,6 @@ tfxUnitsState;
_NEW_COLOR) \
-/* Covers the state referenced in fxDDCheckVtxfmt.
- */
-#define _FX_NEW_VTXFMT (_NEW_TEXTURE | \
- _NEW_TEXTURE_MATRIX | \
- _NEW_TRANSFORM | \
- _NEW_LIGHT | \
- _NEW_PROJECTION | \
- _NEW_MODELVIEW | \
- _TNL_NEW_NEED_EYE_COORDS | \
- _FX_NEW_RENDERSTATE)
-
-
/* These lookup table are used to extract RGB values in [0,255] from
* 16-bit pixel values.
*/
@@ -384,11 +343,9 @@ extern GLubyte FX_PixelToG[0x10000];
extern GLubyte FX_PixelToB[0x10000];
-typedef void (*fx_tri_func) (GLcontext *, const fxVertex *,
- const fxVertex *, const fxVertex *);
-typedef void (*fx_line_func) (GLcontext *, const fxVertex *,
- const fxVertex *);
-typedef void (*fx_point_func) (GLcontext *, const fxVertex *);
+typedef void (*fx_tri_func) (fxMesaContext, GrVertex *, GrVertex *, GrVertex *);
+typedef void (*fx_line_func) (fxMesaContext, GrVertex *, GrVertex *);
+typedef void (*fx_point_func) (fxMesaContext, GrVertex *);
struct tfxMesaContext
{
@@ -434,19 +391,18 @@ struct tfxMesaContext
/* Vertex building and storage:
*/
GLuint tmu_source[FX_NUM_TMU];
- GLuint tex_dest[MAX_TEXTURE_UNITS];
- GLuint setupindex;
- GLuint setup_gone; /* for multipass */
+ GLuint SetupIndex;
GLuint stw_hint_state; /* for grHints */
- fxVertex *verts;
+ GrVertex *verts;
GLboolean snapVertices; /* needed for older Voodoo hardware */
+ struct gl_client_array UbyteColor;
/* Rasterization:
*/
GLuint render_index;
- GLuint passes, multipass;
GLuint is_in_hardware;
- GLenum render_prim;
+ GLenum render_primitive;
+ GLenum raster_primitive;
/* Current rasterization functions
*/
@@ -454,15 +410,6 @@ struct tfxMesaContext
fx_line_func draw_line;
fx_tri_func draw_tri;
- /* System to turn culling on/off for tris/lines/points.
- */
- fx_point_func initial_point;
- fx_line_func initial_line;
- fx_tri_func initial_tri;
-
- fx_point_func subsequent_point;
- fx_line_func subsequent_line;
- fx_tri_func subsequent_tri;
/* Keep texture scales somewhere handy:
*/
@@ -485,7 +432,6 @@ struct tfxMesaContext
GLboolean verbose;
GLboolean haveTwoTMUs; /* True if we really have 2 tmu's */
- GLboolean emulateTwoTMUs; /* True if we present 2 tmu's to mesa. */
GLboolean haveAlphaBuffer;
GLboolean haveZBuffer;
GLboolean haveDoubleBuffer;
@@ -502,37 +448,8 @@ struct tfxMesaContext
int clipMaxX;
int clipMinY;
int clipMaxY;
-
- /* fxvtxfmt
- */
- GLboolean allow_vfmt;
- GLvertexformat vtxfmt;
- fxClipVertex current;
- fxClipVertex *vert; /* points into verts[] */
- void (*fire_on_vertex) (GLcontext *);
- void (*fire_on_end) (GLcontext *);
- void (*fire_on_fallback) (GLcontext *);
-
- vfmt_project_func project_vertex;
- vfmt_interpolate_func interpolate_vertices;
-
- int vtxfmt_fallback_count;
- int vtxfmt_installed;
- void (*old_begin) (GLenum);
- GLenum prim;
-
- GLuint accel_light;
- GLfloat basecolor[4];
-
-
- /* Projected vertices, fastpath data:
- */
- GLvector1ui clipped_elements;
- fxVertex *last_vert;
- GLuint size;
};
-typedef void (*tfxSetupFunc) (GLcontext * ctx, GLuint, GLuint);
extern GrHwConfiguration glbHWConfig;
extern int glbCurrentBoard;
@@ -540,17 +457,20 @@ extern int glbCurrentBoard;
extern void fxSetupFXUnits(GLcontext *);
extern void fxSetupDDPointers(GLcontext *);
-/* fxvsetup:
+/* fxvb.c:
*/
-extern void fxDDSetupInit(void);
extern void fxAllocVB(GLcontext * ctx);
extern void fxFreeVB(GLcontext * ctx);
-extern void fxPrintSetupFlags(const char *msg, GLuint flags);
-extern void fx_BuildProjVerts(GLcontext * ctx,
- GLuint start, GLuint count, GLuint newinputs);
-extern void fx_validate_BuildProjVerts(GLcontext * ctx,
- GLuint start, GLuint count,
- GLuint newinputs);
+extern void fxPrintSetupFlags(char *msg, GLuint flags );
+extern void fxCheckTexSizes( GLcontext *ctx );
+extern void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint newinputs );
+extern void fxChooseVertexState( GLcontext *ctx );
+
+
+
+
+
/* fxtrifuncs:
*/
@@ -655,14 +575,4 @@ extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa,
extern void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder);
-/* fxvtxfmt:
- */
-extern void fxDDCheckVtxfmt(GLcontext * ctx);
-extern void fx_update_lighting(GLcontext * ctx);
-extern void fxDDInitVtxfmt(GLcontext * ctx);
-
-/* fxsimplerender
- */
-extern const struct gl_pipeline_stage fx_render_stage;
-
#endif
diff --git a/src/mesa/drivers/glide/fxsetup.c b/src/mesa/drivers/glide/fxsetup.c
index 2e33bd47e3d..ca79cc4e192 100644
--- a/src/mesa/drivers/glide/fxsetup.c
+++ b/src/mesa/drivers/glide/fxsetup.c
@@ -55,8 +55,6 @@
#include "enums.h"
#include "tnl/t_context.h"
-/*static GLboolean fxMultipassTexture(GLcontext *, GLuint);*/
-
static void
fxTexValidate(GLcontext * ctx, struct gl_texture_object *tObj)
{
@@ -531,23 +529,8 @@ fxSetupTextureSingleTMU_NoLock(GLcontext * ctx, GLuint textureset)
localc, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
break;
case GL_BLEND:
-#if 0
- FX_grAlphaCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER,
- GR_COMBINE_FACTOR_LOCAL,
- locala, GR_COMBINE_OTHER_TEXTURE, FXFALSE);
- if (ifmt == GL_ALPHA)
- FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_LOCAL,
- GR_COMBINE_FACTOR_NONE,
- localc, GR_COMBINE_OTHER_NONE, FXFALSE);
- else
- FX_grColorCombine_NoLock(GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL,
- GR_COMBINE_FACTOR_LOCAL,
- localc, GR_COMBINE_OTHER_TEXTURE, FXTRUE);
- ctx->Driver.MultipassFunc = fxMultipassBlend;
-#else
if (MESA_VERBOSE & VERBOSE_DRIVER)
fprintf(stderr, "fx Driver: GL_BLEND not yet supported\n");
-#endif
break;
case GL_REPLACE:
if ((ifmt == GL_RGB) || (ifmt == GL_LUMINANCE))
@@ -1037,7 +1020,7 @@ fxSetupTexture_NoLock(GLcontext * ctx)
*/
tex2Denabled = (ctx->Texture._ReallyEnabled & TEXTURE0_2D);
- if (fxMesa->emulateTwoTMUs)
+ if (fxMesa->haveTwoTMUs)
tex2Denabled |= (ctx->Texture._ReallyEnabled & TEXTURE1_2D);
switch (tex2Denabled) {
@@ -1055,7 +1038,6 @@ fxSetupTexture_NoLock(GLcontext * ctx)
fprintf(stderr, "fxmesa: enabling fake multitexture\n");
fxSetupTextureSingleTMU_NoLock(ctx, 0);
- /*ctx->Driver.MultipassFunc = fxMultipassTexture;*/
}
break;
default:
@@ -1547,7 +1529,8 @@ fxSetupCull(GLcontext * ctx)
else
FX_CONTEXT(ctx)->cullMode = GR_CULL_DISABLE;
- FX_grCullMode(FX_CONTEXT(ctx)->cullMode);
+ if (FX_CONTEXT(ctx)->raster_primitive == GL_TRIANGLES)
+ FX_grCullMode(FX_CONTEXT(ctx)->cullMode);
}
@@ -1616,129 +1599,7 @@ fxDDEnable(GLcontext * ctx, GLenum cap, GLboolean state)
}
}
-#if 0
-/*
- Multipass to do GL_BLEND texture functions
- Cf*(1-Ct) has already been written to the buffer during the first pass
- Cc*Ct gets written during the second pass (in this function)
- Everything gets reset in the third call (in this function)
-*/
-static GLboolean
-fxMultipassBlend(struct vertex_buffer *VB, GLuint pass)
-{
- GLcontext *ctx = VB->ctx;
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
-
- switch (pass) {
- case 1:
- /* Add Cc*Ct */
- fxMesa->restoreUnitsState = fxMesa->unitsState;
- if (ctx->Depth.Mask) {
- /* We don't want to check or change the depth buffers */
- switch (ctx->Depth.Func) {
- case GL_NEVER:
- case GL_ALWAYS:
- break;
- default:
- fxDDDepthFunc(ctx, GL_EQUAL);
- break;
- }
- fxDDDepthMask(ctx, FALSE);
- }
- /* Enable Cc*Ct mode */
- /* XXX Set the Constant Color ? */
- fxDDEnable(ctx, GL_BLEND, GL_TRUE);
- fxDDBlendFunc(ctx, XXX, XXX);
- fxSetupTextureSingleTMU(ctx, XXX);
- fxSetupBlend(ctx);
- fxSetupDepthTest(ctx);
- break;
-
- case 2:
- /* Reset everything back to normal */
- fxMesa->unitsState = fxMesa->restoreUnitsState;
- fxMesa->setup_gone |= XXX;
- fxSetupTextureSingleTMU(ctx, XXX);
- fxSetupBlend(ctx);
- fxSetupDepthTest(ctx);
- break;
- }
-
- return pass == 1;
-}
-#endif
-/************************************************************************/
-/******************** Fake Multitexture Support *************************/
-/************************************************************************/
-
-/* Its considered cheeky to try to fake ARB multitexture by doing
- * multipass rendering, because it is not possible to emulate the full
- * spec in this way. The fact is that the voodoo 2 supports only a
- * subset of the possible multitexturing modes, and it is possible to
- * support almost the same subset using multipass blending on the
- * voodoo 1. In all other cases for both voodoo 1 and 2, we fall back
- * to software rendering, satisfying the spec if not the user.
- */
-static GLboolean
-fxMultipassTexture(GLcontext * ctx, GLuint pass)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- TNLcontext *tnl = TNL_CONTEXT(ctx);
- fxVertex *v = fxMesa->verts;
- fxVertex *last = fxMesa->verts + tnl->vb.Count;
-
- switch (pass) {
- case 1:
- if (MESA_VERBOSE &
- (VERBOSE_DRIVER | VERBOSE_PIPELINE | VERBOSE_TEXTURE))
- fprintf(stderr, "fxmesa: Second texture pass\n");
-
- for (; v != last; v++) {
- v->f[S0COORD] = v->f[S1COORD];
- v->f[T0COORD] = v->f[T1COORD];
- }
-
- fxMesa->restoreUnitsState = fxMesa->unitsState;
- fxMesa->tmu_source[0] = 1;
-
- if (ctx->Depth.Mask) {
- switch (ctx->Depth.Func) {
- case GL_NEVER:
- case GL_ALWAYS:
- break;
- default:
- fxDDDepthFunc(ctx, GL_EQUAL);
- break;
- }
-
- fxDDDepthMask(ctx, GL_FALSE);
- }
-
- if (ctx->Texture.Unit[1].EnvMode == GL_MODULATE) {
- fxDDEnable(ctx, GL_BLEND, GL_TRUE);
- fxDDBlendFunc(ctx, GL_DST_COLOR, GL_ZERO);
- }
-
- fxSetupTextureSingleTMU(ctx, 1);
- fxSetupBlend(ctx);
- fxSetupDepthTest(ctx);
- break;
-
- case 2:
- /* Restore original state.
- */
- fxMesa->tmu_source[0] = 0;
- fxMesa->unitsState = fxMesa->restoreUnitsState;
- fxMesa->setup_gone |= SETUP_TMU0;
- fxSetupTextureSingleTMU(ctx, 0);
- fxSetupBlend(ctx);
- fxSetupDepthTest(ctx);
- break;
- }
-
- return pass == 1;
-}
/************************************************************************/
@@ -1809,9 +1670,6 @@ fxSetupFXUnits(GLcontext * ctx)
if (newstate & FX_NEW_CULL)
fxSetupCull(ctx);
- fxMesa->draw_point = fxMesa->initial_point;
- fxMesa->draw_line = fxMesa->initial_line;
- fxMesa->draw_tri = fxMesa->initial_tri;
fxMesa->new_state = 0;
}
}
diff --git a/src/mesa/drivers/glide/fxtris.c b/src/mesa/drivers/glide/fxtris.c
index 829aabe7492..5129a94476b 100644
--- a/src/mesa/drivers/glide/fxtris.c
+++ b/src/mesa/drivers/glide/fxtris.c
@@ -1,641 +1,824 @@
+/* -*- mode: c; c-basic-offset: 3 -*-
+ *
+ * Copyright 2000 VA Linux Systems Inc., Fremont, California.
+ *
+ * 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 (including the next
+ * paragraph) 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
+ * VA LINUX SYSTEMS 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.
+ */
+/* $XFree86: xc/lib/GL/mesa/src/drv/fx/fxtris.c,v 1.5 2000/09/24 13:51:04 alanh Exp $ */
+/* Authors:
+ * Keith Whitwell <[email protected]>
+ */
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
+#include <stdio.h>
+#include <math.h>
-#if defined(FX)
+#include "glheader.h"
+#include "mtypes.h"
+#include "macros.h"
+#include "colormac.h"
-#include "mmath.h"
#include "swrast/swrast.h"
#include "swrast_setup/swrast_setup.h"
-
#include "tnl/t_context.h"
#include "tnl/t_pipeline.h"
#include "fxdrv.h"
-#include "fxglidew.h"
-
-
-
-
-
-
-static void
-fx_draw_point(GLcontext * ctx, const fxVertex * v)
+/*
+ * Subpixel offsets to adjust Mesa's (true) window coordinates to
+ * Glide coordinates. We need these to ensure precise rasterization.
+ * Otherwise, we'll fail a bunch of conformance tests.
+ */
+#define TRI_X_OFFSET ( 0.0F)
+#define TRI_Y_OFFSET ( 0.0F)
+#define LINE_X_OFFSET ( 0.0F)
+#define LINE_Y_OFFSET ( 0.125F)
+#define PNT_X_OFFSET ( 0.375F)
+#define PNT_Y_OFFSET ( 0.375F)
+
+static void fxRasterPrimitive( GLcontext *ctx, GLenum prim );
+static void fxRenderPrimitive( GLcontext *ctx, GLenum prim );
+
+/***********************************************************************
+ * Macros for t_dd_tritmp.h to draw basic primitives *
+ ***********************************************************************/
+
+#define TRI( a, b, c ) \
+do { \
+ if (DO_FALLBACK) \
+ fxMesa->draw_tri( fxMesa, a, b, c ); \
+ else \
+ grDrawTriangle( a, b, c ); \
+} while (0) \
+
+#define QUAD( a, b, c, d ) \
+do { \
+ if (DO_FALLBACK) { \
+ fxMesa->draw_tri( fxMesa, a, b, d ); \
+ fxMesa->draw_tri( fxMesa, b, c, d ); \
+ } else { \
+ grDrawTriangle( a, b, d ); \
+ grDrawTriangle( b, c, d ); \
+ } \
+} while (0)
+
+#define LINE( v0, v1 ) \
+do { \
+ if (DO_FALLBACK) \
+ fxMesa->draw_line( fxMesa, v0, v1 ); \
+ else { \
+ v0->x += LINE_X_OFFSET - TRI_X_OFFSET; \
+ v0->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ v1->x += LINE_X_OFFSET - TRI_X_OFFSET; \
+ v1->y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ grDrawLine( v0, v1 ); \
+ v0->x -= LINE_X_OFFSET - TRI_X_OFFSET; \
+ v0->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ v1->x -= LINE_X_OFFSET - TRI_X_OFFSET; \
+ v1->y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
+ } \
+} while (0)
+
+#define POINT( v0 ) \
+do { \
+ if (DO_FALLBACK) \
+ fxMesa->draw_point( fxMesa, v0 ); \
+ else { \
+ v0->x += PNT_X_OFFSET - TRI_X_OFFSET; \
+ v0->y += PNT_Y_OFFSET - TRI_Y_OFFSET; \
+ grDrawPoint( v0 ); \
+ v0->x -= PNT_X_OFFSET - TRI_X_OFFSET; \
+ v0->y -= PNT_Y_OFFSET - TRI_Y_OFFSET; \
+ } \
+} while (0)
+
+
+/***********************************************************************
+ * Fallback to swrast for basic primitives *
+ ***********************************************************************/
+
+/* Build an SWvertex from a hardware vertex.
+ *
+ * This code is hit only when a mix of accelerated and unaccelerated
+ * primitives are being drawn, and only for the unaccelerated
+ * primitives.
+ */
+static void
+fx_translate_vertex( GLcontext *ctx, const GrVertex *src, SWvertex *dst)
{
- GLfloat sz = ctx->Point._Size;
-
- if (sz <= 1.0) {
- grDrawPoint(&(v->v));
- }
- else {
- GrVertex verts[4];
-
- sz *= .5;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLuint ts0 = fxMesa->tmu_source[0];
+ GLuint ts1 = fxMesa->tmu_source[1];
+ GLfloat w = 1.0 / src->oow;
- verts[0] = v->v;
- verts[1] = v->v;
- verts[2] = v->v;
- verts[3] = v->v;
+ dst->win[0] = src->x;
+ dst->win[1] = src->y;
+ dst->win[2] = src->ooz;
+ dst->win[3] = src->oow;
- verts[0].x = v->v.x - sz;
- verts[0].y = v->v.y - sz;
+ dst->color[0] = (GLubyte) src->r;
+ dst->color[1] = (GLubyte) src->g;
+ dst->color[2] = (GLubyte) src->b;
+ dst->color[3] = (GLubyte) src->a;
- verts[1].x = v->v.x + sz;
- verts[1].y = v->v.y - sz;
+ dst->texcoord[ts0][0] = fxMesa->inv_s0scale * src->tmuvtx[0].sow * w;
+ dst->texcoord[ts0][1] = fxMesa->inv_t0scale * src->tmuvtx[0].tow * w;
- verts[2].x = v->v.x + sz;
- verts[2].y = v->v.y + sz;
+ if (fxMesa->stw_hint_state & GR_STWHINT_W_DIFF_TMU0)
+ dst->texcoord[ts0][3] = src->tmuvtx[0].oow * w;
+ else
+ dst->texcoord[ts0][3] = 1.0;
- verts[3].x = v->v.x - sz;
- verts[3].y = v->v.y + sz;
+ if (fxMesa->SetupIndex & SETUP_TMU1) {
+ dst->texcoord[ts1][0] = fxMesa->inv_s1scale * src->tmuvtx[1].sow * w;
+ dst->texcoord[ts1][1] = fxMesa->inv_t1scale * src->tmuvtx[1].tow * w;
- grDrawTriangle(&verts[0], &verts[1], &verts[3]);
- grDrawTriangle(&verts[1], &verts[2], &verts[3]);
+ if (fxMesa->stw_hint_state & GR_STWHINT_W_DIFF_TMU1)
+ dst->texcoord[ts1][3] = src->tmuvtx[1].oow * w;
+ else
+ dst->texcoord[ts1][3] = 1.0;
}
+
+ dst->pointSize = ctx->Point._Size;
}
-static void
-fx_draw_line(GLcontext * ctx, const fxVertex * v0, const fxVertex * v1)
+static void
+fx_fallback_tri( fxMesaContext fxMesa,
+ GrVertex *v0,
+ GrVertex *v1,
+ GrVertex *v2 )
{
- float width = ctx->Line.Width;
-
- if (width <= 1.0) {
- grDrawLine(&(v0->v), &(v1->v));
- }
- else {
- GrVertex verts[4];
- float dx, dy, ix, iy;
-
- dx = v0->v.x - v1->v.x;
- dy = v0->v.y - v1->v.y;
-
- if (dx * dx > dy * dy) {
- iy = width * .5;
- ix = 0;
- }
- else {
- iy = 0;
- ix = width * .5;
- }
-
-
- verts[0] = v0->v;
- verts[0].x -= ix;
- verts[0].y -= iy;
+ GLcontext *ctx = fxMesa->glCtx;
+ SWvertex v[3];
+ fx_translate_vertex( ctx, v0, &v[0] );
+ fx_translate_vertex( ctx, v1, &v[1] );
+ fx_translate_vertex( ctx, v2, &v[2] );
+ _swrast_Triangle( ctx, &v[0], &v[1], &v[2] );
+}
- verts[1] = v0->v;
- verts[1].x += ix;
- verts[1].y += iy;
- verts[2] = v1->v;
- verts[2].x += ix;
- verts[2].y += iy;
+static void
+fx_fallback_line( fxMesaContext fxMesa,
+ GrVertex *v0,
+ GrVertex *v1 )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ SWvertex v[2];
+ fx_translate_vertex( ctx, v0, &v[0] );
+ fx_translate_vertex( ctx, v1, &v[1] );
+ _swrast_Line( ctx, &v[0], &v[1] );
+}
- verts[3] = v1->v;
- verts[3].x -= ix;
- verts[3].y -= iy;
- grDrawTriangle(&verts[0], &verts[1], &verts[3]);
- grDrawTriangle(&verts[1], &verts[2], &verts[3]);
- }
+static void
+fx_fallback_point( fxMesaContext fxMesa,
+ GrVertex *v0 )
+{
+ GLcontext *ctx = fxMesa->glCtx;
+ SWvertex v[1];
+ fx_translate_vertex( ctx, v0, &v[0] );
+ _swrast_Point( ctx, &v[0] );
}
-static void
-fx_draw_tri(GLcontext * ctx, const fxVertex * v0, const fxVertex * v1,
- const fxVertex * v2)
+/***********************************************************************
+ * Functions to draw basic primitives *
+ ***********************************************************************/
+
+static void fx_print_vertex( GLcontext *ctx, const GrVertex *v )
{
- grDrawTriangle(&(v0->v), &(v1->v), &(v2->v));
+ fprintf(stderr, "vertex at %p\n", v);
+
+ fprintf(stderr, "x %f y %f z %f oow %f\n",
+ v->x, v->y, v->ooz, v->oow);
+ fprintf(stderr, "r %f g %f b %f a %f\n",
+ v->r,
+ v->g,
+ v->b,
+ v->a);
+
+ fprintf(stderr, "\n");
}
+#define DO_FALLBACK 0
-
-#define FX_COLOR(vert, c) { \
- GLfloat *col = c; \
- UNCLAMPED_FLOAT_TO_UBYTE(vert->v.r, col[0]); \
- UNCLAMPED_FLOAT_TO_UBYTE(vert->v.g, col[1]); \
- UNCLAMPED_FLOAT_TO_UBYTE(vert->v.b, col[2]); \
- UNCLAMPED_FLOAT_TO_UBYTE(vert->v.a, col[3]); \
+/* Need to do clip loop at each triangle when mixing swrast and hw
+ * rendering. These functions are only used when mixed-mode rendering
+ * is occurring.
+ */
+static void fx_draw_quad( fxMesaContext fxMesa,
+ GrVertex *v0,
+ GrVertex *v1,
+ GrVertex *v2,
+ GrVertex *v3 )
+{
+ QUAD( v0, v1, v2, v3 );
}
-#define FX_COPY_COLOR( dst, src ) { \
- dst->v.r = src->v.r; \
- dst->v.g = src->v.g; \
- dst->v.b = src->v.b; \
- dst->v.a = src->v.a; \
+static void fx_draw_triangle( fxMesaContext fxMesa,
+ GrVertex *v0,
+ GrVertex *v1,
+ GrVertex *v2 )
+{
+ TRI( v0, v1, v2 );
}
+static void fx_draw_line( fxMesaContext fxMesa,
+ GrVertex *v0,
+ GrVertex *v1 )
+{
+ /* No support for wide lines (avoid wide/aa line fallback).
+ */
+ LINE(v0, v1);
+}
-
-#define FX_FLAT_BIT 0x01
-#define FX_OFFSET_BIT 0x02
-#define FX_TWOSIDE_BIT 0x04
-#define FX_UNFILLED_BIT 0x10
-#define FX_FALLBACK_BIT 0x20
-#define FX_MAX_TRIFUNC 0x40
-
-static struct
+static void fx_draw_point( fxMesaContext fxMesa,
+ GrVertex *v0 )
{
- points_func points;
- line_func line;
- triangle_func triangle;
- quad_func quad;
+ /* No support for wide points.
+ */
+ POINT( v0 );
}
-rast_tab[FX_MAX_TRIFUNC];
+#undef DO_FALLBACK
+
+
+#define FX_UNFILLED_BIT 0x1
+#define FX_OFFSET_BIT 0x2
+#define FX_TWOSIDE_BIT 0x4
+#define FX_FLAT_BIT 0x8
+#define FX_FALLBACK_BIT 0x10
+#define FX_MAX_TRIFUNC 0x20
+
+static struct {
+ points_func points;
+ line_func line;
+ triangle_func triangle;
+ quad_func quad;
+} rast_tab[FX_MAX_TRIFUNC];
+
+#define DO_FALLBACK (IND & FX_FALLBACK_BIT)
+#define DO_OFFSET (IND & FX_OFFSET_BIT)
+#define DO_UNFILLED (IND & FX_UNFILLED_BIT)
+#define DO_TWOSIDE (IND & FX_TWOSIDE_BIT)
+#define DO_FLAT (IND & FX_FLAT_BIT)
+#define DO_TRI 1
+#define DO_QUAD 1
+#define DO_LINE 1
+#define DO_POINTS 1
+#define DO_FULL_QUAD 1
+
+#define HAVE_RGBA 1
+#define HAVE_SPEC 0
+#define HAVE_HW_FLATSHADE 0
+#define HAVE_BACK_COLORS 0
+#define VERTEX GrVertex
+#define TAB rast_tab
+
+#define DEPTH_SCALE 1.0
+#define UNFILLED_TRI unfilled_tri
+#define UNFILLED_QUAD unfilled_quad
+#define VERT_X(_v) _v->x
+#define VERT_Y(_v) _v->y
+#define VERT_Z(_v) _v->ooz
+#define AREA_IS_CCW( a ) (a < 0)
+#define GET_VERTEX(e) (fxMesa->verts + e)
+
+#define VERT_SET_RGBA( dst, f ) \
+do { \
+ dst->r = CLAMP( f[0], 0, 1 ) * 255.0; \
+ dst->g = CLAMP( f[1], 0, 1 ) * 255.0; \
+ dst->b = CLAMP( f[2], 0, 1 ) * 255.0; \
+ dst->a = CLAMP( f[3], 0, 1 ) * 255.0; \
+} while (0)
+
+#define VERT_COPY_RGBA( v0, v1 ) \
+do { \
+ v0->r = v1->r; \
+ v0->g = v1->g; \
+ v0->b = v1->b; \
+ v0->a = v1->a; \
+} while (0)
+
+#define VERT_SAVE_RGBA( idx ) \
+do { \
+ color[idx][0] = v[idx]->r; \
+ color[idx][1] = v[idx]->g; \
+ color[idx][1] = v[idx]->b; \
+ color[idx][3] = v[idx]->a; \
+} while (0)
+
+
+#define VERT_RESTORE_RGBA( idx ) \
+do { \
+ v[idx]->r = color[idx][0]; \
+ v[idx]->g = color[idx][1]; \
+ v[idx]->b = color[idx][2]; \
+ v[idx]->a = color[idx][3]; \
+} while (0)
+
+
+#define LOCAL_VARS(n) \
+ fxMesaContext fxMesa = FX_CONTEXT(ctx); \
+ GLfloat color[n][4]; \
+ (void) color;
+
+
+
+/***********************************************************************
+ * Functions to draw basic unfilled primitives *
+ ***********************************************************************/
+
+#define RASTERIZE(x) if (fxMesa->raster_primitive != x) \
+ fxRasterPrimitive( ctx, x )
+#define RENDER_PRIMITIVE fxMesa->render_primitive
+#define IND FX_FALLBACK_BIT
+#define TAG(x) x
+#include "tnl_dd/t_dd_unfilled.h"
+#undef IND
+
+/***********************************************************************
+ * Functions to draw GL primitives *
+ ***********************************************************************/
#define IND (0)
#define TAG(x) x
-#include "fxtritmp.h"
-
-#define IND (FX_FLAT_BIT)
-#define TAG(x) x##_flat
-#include "fxtritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
#define IND (FX_OFFSET_BIT)
#define TAG(x) x##_offset
-#include "fxtritmp.h"
-
-#define IND (FX_OFFSET_BIT | FX_FLAT_BIT)
-#define TAG(x) x##_offset_flat
-#include "fxtritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
#define IND (FX_TWOSIDE_BIT)
#define TAG(x) x##_twoside
-#include "fxtritmp.h"
-
-#define IND (FX_TWOSIDE_BIT | FX_FLAT_BIT)
-#define TAG(x) x##_twoside_flat
-#include "fxtritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_TWOSIDE_BIT | FX_OFFSET_BIT)
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT)
#define TAG(x) x##_twoside_offset
-#include "fxtritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_TWOSIDE_BIT | FX_OFFSET_BIT | FX_FLAT_BIT)
-#define TAG(x) x##_twoside_offset_flat
-#include "fxtritmp.h"
+#define IND (FX_UNFILLED_BIT)
+#define TAG(x) x##_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT)
+#define TAG(x) x##_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT)
+#define TAG(x) x##_twoside_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
+
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT)
+#define TAG(x) x##_twoside_offset_unfilled
+#include "tnl_dd/t_dd_tritmp.h"
#define IND (FX_FALLBACK_BIT)
#define TAG(x) x##_fallback
-#include "fxtritmp.h"
-
-#define IND (FX_FLAT_BIT | FX_FALLBACK_BIT)
-#define TAG(x) x##_flat_fallback
-#include "fxtritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_OFFSET_BIT | FX_FALLBACK_BIT)
+#define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT)
#define TAG(x) x##_offset_fallback
-#include "fxtritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_OFFSET_BIT | FX_FLAT_BIT | FX_FALLBACK_BIT)
-#define TAG(x) x##_offset_flat_fallback
-#include "fxtritmp.h"
-
-#define IND (FX_TWOSIDE_BIT | FX_FALLBACK_BIT)
+#define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT)
#define TAG(x) x##_twoside_fallback
-#include "fxtritmp.h"
-
-#define IND (FX_TWOSIDE_BIT | FX_FLAT_BIT | FX_FALLBACK_BIT)
-#define TAG(x) x##_twoside_flat_fallback
-#include "fxtritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_TWOSIDE_BIT | FX_OFFSET_BIT | FX_FALLBACK_BIT)
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT)
#define TAG(x) x##_twoside_offset_fallback
-#include "fxtritmp.h"
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_TWOSIDE_BIT | FX_OFFSET_BIT | FX_FLAT_BIT | FX_FALLBACK_BIT)
-#define TAG(x) x##_twoside_offset_flat_fallback
-#include "fxtritmp.h"
+#define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT)
+#define TAG(x) x##_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_UNFILLED_BIT)
-#define TAG(x) x##_unfilled
-#include "fxtritmp.h"
+#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT)
+#define TAG(x) x##_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_FLAT_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_flat_unfilled
-#include "fxtritmp.h"
+#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_OFFSET_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_offset_unfilled
-#include "fxtritmp.h"
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \
+ FX_FALLBACK_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_OFFSET_BIT | FX_FLAT_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_offset_flat_unfilled
-#include "fxtritmp.h"
-#define IND (FX_TWOSIDE_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_twoside_unfilled
-#include "fxtritmp.h"
+/* Fx doesn't support provoking-vertex flat-shading?
+ */
+#define IND (FX_FLAT_BIT)
+#define TAG(x) x##_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_TWOSIDE_BIT | FX_FLAT_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_twoside_flat_unfilled
-#include "fxtritmp.h"
+#define IND (FX_OFFSET_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_offset_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_TWOSIDE_BIT | FX_OFFSET_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_twoside_offset_unfilled
-#include "fxtritmp.h"
+#define IND (FX_TWOSIDE_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_TWOSIDE_BIT | FX_OFFSET_BIT | FX_FLAT_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_twoside_offset_flat_unfilled
-#include "fxtritmp.h"
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_FALLBACK_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_fallback_unfilled
-#include "fxtritmp.h"
+#define IND (FX_UNFILLED_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_FLAT_BIT | FX_FALLBACK_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_flat_fallback_unfilled
-#include "fxtritmp.h"
+#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_offset_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_OFFSET_BIT | FX_FALLBACK_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_offset_fallback_unfilled
-#include "fxtritmp.h"
+#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_OFFSET_BIT | FX_FLAT_BIT | FX_FALLBACK_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_offset_flat_fallback_unfilled
-#include "fxtritmp.h"
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_TWOSIDE_BIT | FX_FALLBACK_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_twoside_fallback_unfilled
-#include "fxtritmp.h"
+#define IND (FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_TWOSIDE_BIT | FX_FLAT_BIT | FX_FALLBACK_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_twoside_flat_fallback_unfilled
-#include "fxtritmp.h"
+#define IND (FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_offset_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_TWOSIDE_BIT | FX_OFFSET_BIT | FX_FALLBACK_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_twoside_offset_fallback_unfilled
-#include "fxtritmp.h"
+#define IND (FX_TWOSIDE_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
-#define IND (FX_TWOSIDE_BIT | FX_OFFSET_BIT | FX_FLAT_BIT | FX_FALLBACK_BIT | FX_UNFILLED_BIT)
-#define TAG(x) x##_twoside_offset_flat_fallback_unfilled
-#include "fxtritmp.h"
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+#define IND (FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+#define IND (FX_OFFSET_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_offset_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+#define IND (FX_TWOSIDE_BIT|FX_UNFILLED_BIT|FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
+#define IND (FX_TWOSIDE_BIT|FX_OFFSET_BIT|FX_UNFILLED_BIT| \
+ FX_FALLBACK_BIT|FX_FLAT_BIT)
+#define TAG(x) x##_twoside_offset_unfilled_fallback_flat
+#include "tnl_dd/t_dd_tritmp.h"
-void
-fxDDTrifuncInit(void)
+static void init_rast_tab( void )
{
init();
- init_flat();
init_offset();
- init_offset_flat();
init_twoside();
- init_twoside_flat();
init_twoside_offset();
- init_twoside_offset_flat();
+ init_unfilled();
+ init_offset_unfilled();
+ init_twoside_unfilled();
+ init_twoside_offset_unfilled();
init_fallback();
- init_flat_fallback();
init_offset_fallback();
- init_offset_flat_fallback();
init_twoside_fallback();
- init_twoside_flat_fallback();
init_twoside_offset_fallback();
- init_twoside_offset_flat_fallback();
+ init_unfilled_fallback();
+ init_offset_unfilled_fallback();
+ init_twoside_unfilled_fallback();
+ init_twoside_offset_unfilled_fallback();
- init_unfilled();
- init_flat_unfilled();
- init_offset_unfilled();
- init_offset_flat_unfilled();
- init_twoside_unfilled();
- init_twoside_flat_unfilled();
- init_twoside_offset_unfilled();
- init_twoside_offset_flat_unfilled();
- init_fallback_unfilled();
- init_flat_fallback_unfilled();
- init_offset_fallback_unfilled();
- init_offset_flat_fallback_unfilled();
- init_twoside_fallback_unfilled();
- init_twoside_flat_fallback_unfilled();
- init_twoside_offset_fallback_unfilled();
- init_twoside_offset_flat_fallback_unfilled();
+ init_flat();
+ init_offset_flat();
+ init_twoside_flat();
+ init_twoside_offset_flat();
+ init_unfilled_flat();
+ init_offset_unfilled_flat();
+ init_twoside_unfilled_flat();
+ init_twoside_offset_unfilled_flat();
+ init_fallback_flat();
+ init_offset_fallback_flat();
+ init_twoside_fallback_flat();
+ init_twoside_offset_fallback_flat();
+ init_unfilled_fallback_flat();
+ init_offset_unfilled_fallback_flat();
+ init_twoside_unfilled_fallback_flat();
+ init_twoside_offset_unfilled_fallback_flat();
}
-/* Build an SWvertex from a GrVertex. This is workable because in
- * states where the GrVertex is insufficent (eg separate-specular),
- * the driver initiates a total fallback, and builds SWvertices
- * directly -- it recognizes that it will never have use for the
- * GrVertex.
- *
- * This code is hit only when a mix of accelerated and unaccelerated
- * primitives are being drawn, and only for the unaccelerated
- * primitives.
- */
-static void
-fx_translate_vertex(GLcontext * ctx, const fxVertex * src, SWvertex * dst)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GLuint ts0 = fxMesa->tmu_source[0];
- GLuint ts1 = fxMesa->tmu_source[1];
- GLfloat w = 1.0 / src->v.oow;
-
- dst->win[0] = src->v.x;
- dst->win[1] = src->v.y;
- dst->win[2] = src->v.ooz;
- dst->win[3] = src->v.oow;
-
- dst->color[0] = (GLubyte) src->v.r;
- dst->color[1] = (GLubyte) src->v.g;
- dst->color[2] = (GLubyte) src->v.b;
- dst->color[3] = (GLubyte) src->v.a;
-
- dst->texcoord[ts0][0] = fxMesa->inv_s0scale * src->v.tmuvtx[0].sow * w;
- dst->texcoord[ts0][1] = fxMesa->inv_t0scale * src->v.tmuvtx[0].tow * w;
- if (fxMesa->stw_hint_state & GR_STWHINT_W_DIFF_TMU0)
- dst->texcoord[ts0][3] = src->v.tmuvtx[0].oow * w;
- else
- dst->texcoord[ts0][3] = 1.0;
+/**********************************************************************/
+/* Render whole (indexed) begin/end objects */
+/**********************************************************************/
- dst->texcoord[ts1][0] = fxMesa->inv_s1scale * src->v.tmuvtx[1].sow * w;
- dst->texcoord[ts1][1] = fxMesa->inv_t1scale * src->v.tmuvtx[1].tow * w;
- if (fxMesa->stw_hint_state & GR_STWHINT_W_DIFF_TMU1)
- dst->texcoord[ts1][3] = src->v.tmuvtx[1].oow * w;
- else
- dst->texcoord[ts1][3] = 1.0;
-}
+#define VERT(x) (vertptr + x)
+#define RENDER_POINTS( start, count ) \
+ for ( ; start < count ; start++) \
+ grDrawPoint( VERT(ELT(start)) );
-static void
-fx_fallback_tri(GLcontext * ctx,
- const fxVertex * v0, const fxVertex * v1, const fxVertex * v2)
-{
- SWvertex v[3];
- fx_translate_vertex(ctx, v0, &v[0]);
- fx_translate_vertex(ctx, v1, &v[1]);
- fx_translate_vertex(ctx, v2, &v[2]);
- _swrast_Triangle(ctx, &v[0], &v[1], &v[2]);
-}
+#define RENDER_LINE( v0, v1 ) \
+ grDrawLine( VERT(v0), VERT(v1) )
+#define RENDER_TRI( v0, v1, v2 ) \
+ grDrawTriangle( VERT(v0), VERT(v1), VERT(v2) )
-static void
-fx_fallback_line(GLcontext * ctx, const fxVertex * v0, const fxVertex * v1)
-{
- SWvertex v[2];
- fx_translate_vertex(ctx, v0, &v[0]);
- fx_translate_vertex(ctx, v1, &v[1]);
- _swrast_Line(ctx, &v[0], &v[1]);
-}
+#define RENDER_QUAD( v0, v1, v2, v3 ) \
+ fx_draw_quad( fxMesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
+#define INIT(x) fxRenderPrimitive( ctx, x )
-static void
-fx_fallback_point(GLcontext * ctx, const fxVertex * v0)
-{
- SWvertex v[1];
- fx_translate_vertex(ctx, v0, &v[0]);
- _swrast_Point(ctx, &v[0]);
-}
+#undef LOCAL_VARS
+#define LOCAL_VARS \
+ fxMesaContext fxMesa = FX_CONTEXT(ctx); \
+ GrVertex *vertptr = fxMesa->verts; \
+ const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
+ (void) elt;
+#define RESET_STIPPLE
+#define RESET_OCCLUSION
+#define PRESERVE_VB_DEFS
-/* System to turn culling off for rasterized lines and points, and
- * back on for rasterized triangles.
+/* Elts, no clipping.
*/
-static void
-fx_cull_draw_tri(GLcontext * ctx,
- const fxVertex * v0, const fxVertex * v1,
- const fxVertex * v2)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
-
- FX_grCullMode(fxMesa->cullMode);
-
- fxMesa->draw_line = fxMesa->initial_line;
- fxMesa->draw_point = fxMesa->initial_point;
- fxMesa->draw_tri = fxMesa->subsequent_tri;
-
- fxMesa->draw_tri(ctx, v0, v1, v2);
-}
+#undef ELT
+#undef TAG
+#define TAG(x) fx_##x##_elts
+#define ELT(x) elt[x]
+#include "tnl_dd/t_dd_rendertmp.h"
+/* Verts, no clipping.
+ */
+#undef ELT
+#undef TAG
+#define TAG(x) fx_##x##_verts
+#define ELT(x) x
+#include "tnl_dd/t_dd_rendertmp.h"
-static void
-fx_cull_draw_line(GLcontext * ctx, const fxVertex * v0, const fxVertex * v1)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- FX_grCullMode(GR_CULL_DISABLE);
- fxMesa->draw_point = fxMesa->initial_point;
- fxMesa->draw_tri = fxMesa->initial_tri;
- fxMesa->draw_line = fxMesa->subsequent_line;
+/**********************************************************************/
+/* Render clipped primitives */
+/**********************************************************************/
- fxMesa->draw_line(ctx, v0, v1);
-}
-static void
-fx_cull_draw_point(GLcontext * ctx, const fxVertex * v0)
+static void fxRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
{
fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ struct vertex_buffer *VB = &tnl->vb;
+ GLuint prim = fxMesa->render_primitive;
+
+ /* Render the new vertices as an unclipped polygon.
+ */
+ {
+ GLuint *tmp = VB->Elts;
+ VB->Elts = (GLuint *)elts;
+ tnl->Driver.Render.PrimTabElts[GL_POLYGON]( ctx, 0, n,
+ PRIM_BEGIN|PRIM_END );
+ VB->Elts = tmp;
+ }
- FX_grCullMode(GR_CULL_DISABLE);
-
- fxMesa->draw_line = fxMesa->initial_line;
- fxMesa->draw_tri = fxMesa->initial_tri;
- fxMesa->draw_point = fxMesa->subsequent_point;
-
- fxMesa->draw_point(ctx, v0);
+ /* Restore the render primitive
+ */
+ if (prim != GL_POLYGON)
+ tnl->Driver.Render.PrimitiveNotify( ctx, prim );
}
-static void
-fx_null_tri(GLcontext * ctx,
- const fxVertex * v0, const fxVertex * v1, const fxVertex * v2)
+static void fxFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
+ GLuint n )
{
- (void) v0;
- (void) v1;
- (void) v2;
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ GrVertex *vertptr = fxMesa->verts;
+ const GrVertex *start = VERT(elts[0]);
+ int i;
+
+ for (i = 2 ; i < n ; i++) {
+ grDrawTriangle( start, VERT(elts[i-1]), VERT(elts[i]) );
+ }
}
+/**********************************************************************/
+/* Choose render functions */
+/**********************************************************************/
+#define POINT_FALLBACK (DD_POINT_SMOOTH)
+#define LINE_FALLBACK (DD_LINE_STIPPLE)
+#define TRI_FALLBACK (DD_TRI_SMOOTH)
+#define ANY_FALLBACK_FLAGS (POINT_FALLBACK|LINE_FALLBACK|TRI_FALLBACK|DD_TRI_STIPPLE)
+#define ANY_RASTER_FLAGS (DD_FLATSHADE|DD_TRI_LIGHT_TWOSIDE|DD_TRI_OFFSET| \
+ DD_TRI_UNFILLED)
-/**********************************************************************/
-/* Render whole begin/end objects */
-/**********************************************************************/
-/* Vertices, no clipping.
- */
-#define RENDER_POINTS( start, count ) \
- for ( ; start < count ; start++) \
- grDrawPoint( &v[ELT(start)].v );
+static void fxChooseRenderState(GLcontext *ctx)
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLuint flags = ctx->_TriangleCaps;
+ GLuint index = 0;
-#define RENDER_LINE( i1, i ) \
- grDrawLine( &v[i1].v, &v[i].v )
+/* fprintf(stderr, "%s\n", __FUNCTION__); */
-#define RENDER_TRI( i2, i1, i ) \
- grDrawTriangle( &v[i2].v, &v[i1].v, &v[i].v )
+ if (flags & (ANY_FALLBACK_FLAGS|ANY_RASTER_FLAGS)) {
+ if (flags & ANY_RASTER_FLAGS) {
+ if (flags & DD_TRI_LIGHT_TWOSIDE) index |= FX_TWOSIDE_BIT;
+ if (flags & DD_TRI_OFFSET) index |= FX_OFFSET_BIT;
+ if (flags & DD_TRI_UNFILLED) index |= FX_UNFILLED_BIT;
+ if (flags & DD_FLATSHADE) index |= FX_FLAT_BIT;
+ }
-#define RENDER_QUAD( i3, i2, i1, i ) \
- grDrawTriangle( &v[i3].v, &v[i2].v, &v[i].v ); \
- grDrawTriangle( &v[i2].v, &v[i1].v, &v[i].v )
+ fxMesa->draw_point = fx_draw_point;
+ fxMesa->draw_line = fx_draw_line;
+ fxMesa->draw_tri = fx_draw_triangle;
-#define TAG(x) fx_##x##_verts
-#define LOCAL_VARS \
- fxVertex *v = FX_CONTEXT(ctx)->verts; \
- const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
- (void) elt;
+ /* Hook in fallbacks for specific primitives.
+ *
+ *
+ */
+ if (flags & (POINT_FALLBACK|
+ LINE_FALLBACK|
+ TRI_FALLBACK))
+ {
+ if (flags & POINT_FALLBACK)
+ fxMesa->draw_point = fx_fallback_point;
-/* Verts, no clipping.
- */
-#define ELT(x) x
-#define RESET_STIPPLE
-#define RESET_OCCLUSION
-#define PRESERVE_VB_DEFS
-#include "tnl/t_vb_rendertmp.h"
+ if (flags & LINE_FALLBACK)
+ fxMesa->draw_line = fx_fallback_line;
+ if (flags & TRI_FALLBACK)
+ fxMesa->draw_tri = fx_fallback_tri;
-/* Elts, no clipping.
- */
-#undef ELT
-#undef TAG
-#define TAG(x) fx_##x##_elts
-#define ELT(x) elt[x]
-#include "tnl/t_vb_rendertmp.h"
+ index |= FX_FALLBACK_BIT;
+ }
+ }
+ tnl->Driver.Render.Points = rast_tab[index].points;
+ tnl->Driver.Render.Line = rast_tab[index].line;
+ tnl->Driver.Render.ClippedLine = rast_tab[index].line;
+ tnl->Driver.Render.Triangle = rast_tab[index].triangle;
+ tnl->Driver.Render.Quad = rast_tab[index].quad;
+
+ if (index == 0) {
+ tnl->Driver.Render.PrimTabVerts = fx_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = fx_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = fxFastRenderClippedPoly;
+ } else {
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ClippedPolygon = fxRenderClippedPoly;
+ }
+}
/**********************************************************************/
-/* Choose render functions */
+/* Runtime render state and callbacks */
/**********************************************************************/
+static GLenum reduced_prim[GL_POLYGON+1] = {
+ GL_POINTS,
+ GL_LINES,
+ GL_LINES,
+ GL_LINES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES,
+ GL_TRIANGLES
+};
-#define POINT_FALLBACK (DD_POINT_SMOOTH )
-#define LINE_FALLBACK (DD_LINE_STIPPLE)
-#define TRI_FALLBACK (DD_TRI_SMOOTH | DD_TRI_STIPPLE )
-#define ANY_FALLBACK (POINT_FALLBACK | LINE_FALLBACK | TRI_FALLBACK)
+/* Always called between RenderStart and RenderFinish --> We already
+ * hold the lock.
+ */
+static void fxRasterPrimitive( GLcontext *ctx, GLenum prim )
+{
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
-#define ANY_RENDER_FLAGS (DD_FLATSHADE | \
- DD_TRI_LIGHT_TWOSIDE | \
- DD_TRI_OFFSET | \
- DD_TRI_UNFILLED)
+ fxMesa->raster_primitive = prim;
+ if (prim == GL_TRIANGLES)
+ grCullMode( fxMesa->cullMode );
+ else
+ grCullMode( GR_CULL_DISABLE );
+}
-/* Setup the Point, Line, Triangle and Quad functions based on the
- * current rendering state. Wherever possible, use the hardware to
- * render the primitive. Otherwise, fallback to software rendering.
+/* Determine the rasterized primitive when not drawing unfilled
+ * polygons.
*/
-void
-fxDDChooseRenderState(GLcontext * ctx)
+static void fxRenderPrimitive( GLcontext *ctx, GLenum prim )
{
- TNLcontext *tnl = TNL_CONTEXT(ctx);
fxMesaContext fxMesa = FX_CONTEXT(ctx);
- GLuint flags = ctx->_TriangleCaps;
- GLuint index = 0;
+ GLuint rprim = reduced_prim[prim];
- if (!fxMesa->is_in_hardware) {
- /* Build software vertices directly. No acceleration is
- * possible. GrVertices may be insufficient for this mode.
- */
- tnl->Driver.PointsFunc = _swsetup_Points;
- tnl->Driver.LineFunc = _swsetup_Line;
- tnl->Driver.TriangleFunc = _swsetup_Triangle;
- tnl->Driver.QuadFunc = _swsetup_Quad;
- tnl->Driver.RenderTabVerts = _tnl_render_tab_verts;
- tnl->Driver.RenderTabElts = _tnl_render_tab_elts;
-
- fxMesa->render_index = FX_FALLBACK_BIT;
- return;
- }
+ fxMesa->render_primitive = prim;
- if (flags & ANY_RENDER_FLAGS) {
- if (flags & DD_FLATSHADE)
- index |= FX_FLAT_BIT;
- if (flags & DD_TRI_LIGHT_TWOSIDE)
- index |= FX_TWOSIDE_BIT;
- if (flags & DD_TRI_OFFSET)
- index |= FX_OFFSET_BIT;
- if (flags & DD_TRI_UNFILLED)
- index |= FX_UNFILLED_BIT;
+ if (rprim == GL_TRIANGLES && (ctx->_TriangleCaps & DD_TRI_UNFILLED))
+ return;
+
+ if (fxMesa->raster_primitive != rprim) {
+ fxRasterPrimitive( ctx, rprim );
}
+}
- if (flags & (ANY_FALLBACK |
- DD_LINE_WIDTH | DD_POINT_SIZE | DD_TRI_CULL_FRONT_BACK)) {
-
- /* Hook in fallbacks for specific primitives.
-
- * Set up a system to turn culling on/off for wide points and
- * lines. Alternately: figure out what tris to send so that
- * culling isn't a problem.
- *
- * This replaces the ReducedPrimitiveChange mechanism.
- */
- index |= FX_FALLBACK_BIT;
- fxMesa->initial_point = fx_cull_draw_point;
- fxMesa->initial_line = fx_cull_draw_line;
- fxMesa->initial_tri = fx_cull_draw_tri;
-
- fxMesa->subsequent_point = fx_draw_point;
- fxMesa->subsequent_line = fx_draw_line;
- fxMesa->subsequent_tri = fx_draw_tri;
-
- if (flags & POINT_FALLBACK)
- fxMesa->initial_point = fx_fallback_point;
-
- if (flags & LINE_FALLBACK)
- fxMesa->initial_line = fx_fallback_line;
- if ((flags & DD_LINE_SMOOTH) && ctx->Line.Width != 1.0)
- fxMesa->initial_line = fx_fallback_line;
- if (flags & TRI_FALLBACK)
- fxMesa->initial_tri = fx_fallback_tri;
+/**********************************************************************/
+/* Manage total rasterization fallbacks */
+/**********************************************************************/
- if (flags & DD_TRI_CULL_FRONT_BACK)
- fxMesa->initial_tri = fx_null_tri;
- fxMesa->draw_point = fxMesa->initial_point;
- fxMesa->draw_line = fxMesa->initial_line;
- fxMesa->draw_tri = fxMesa->initial_tri;
- }
- else if (fxMesa->render_index & FX_FALLBACK_BIT) {
- FX_grCullMode(fxMesa->cullMode);
- }
+void fxCheckIsInHardware( GLcontext *ctx )
+{
+ fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ GLuint oldfallback = !fxMesa->is_in_hardware;
+ GLuint newfallback;
- tnl->Driver.PointsFunc = rast_tab[index].points;
- tnl->Driver.LineFunc = rast_tab[index].line;
- tnl->Driver.TriangleFunc = rast_tab[index].triangle;
- tnl->Driver.QuadFunc = rast_tab[index].quad;
- fxMesa->render_index = index;
+ fxMesa->is_in_hardware = check_IsInHardware( ctx );
+ newfallback = !fxMesa->is_in_hardware;
- if (fxMesa->render_index == 0) {
- tnl->Driver.RenderTabVerts = fx_render_tab_verts;
- tnl->Driver.RenderTabElts = fx_render_tab_elts;
+ if (newfallback) {
+ if (oldfallback == 0) {
+ _swsetup_Wakeup( ctx );
+ }
}
else {
- tnl->Driver.RenderTabVerts = _tnl_render_tab_verts;
- tnl->Driver.RenderTabElts = _tnl_render_tab_elts;
+ if (oldfallback) {
+ _swrast_flush( ctx );
+ tnl->Driver.Render.Start = fxCheckTexSizes;
+ tnl->Driver.Render.Finish = _swrast_flush;
+ tnl->Driver.Render.PrimitiveNotify = fxRenderPrimitive;
+ tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
+ tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine;
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = fxBuildVertices;
+ tnl->Driver.Render.Multipass = 0;
+ fxDDChooseSetupState(ctx);
+ fxDDChooseRenderState(ctx);
+ }
}
}
+void fxDDInitTriFuncs( GLcontext *ctx )
+{
+ TNLcontext *tnl = TNL_CONTEXT(ctx);
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ static int firsttime = 1;
+ if (firsttime) {
+ init_rast_tab();
+ firsttime = 0;
+ }
-
-#else
-
-
-/*
- * Need this to provide at least one external definition.
- */
-
-extern int gl_fx_dummy_function_trifuncs(void);
-int
-gl_fx_dummy_function_trifuncs(void)
-{
- return 0;
+ tnl->Driver.Render.Start = fxCheckTexSizes;
+ tnl->Driver.Render.Finish = _swrast_flush;
+ tnl->Driver.Render.PrimitiveNotify = fxRenderPrimitive;
+ tnl->Driver.Render.ClippedPolygon = _tnl_RenderClippedPolygon;
+ tnl->Driver.Render.ClippedLine = _tnl_RenderClippedLine;
+ tnl->Driver.Render.PrimTabVerts = _tnl_render_tab_verts;
+ tnl->Driver.Render.PrimTabElts = _tnl_render_tab_elts;
+ tnl->Driver.Render.ResetLineStipple = _swrast_ResetLineStipple;
+ tnl->Driver.Render.BuildVertices = fxBuildVertices;
+ tnl->Driver.Render.Multipass = 0;
+
+ (void) fx_print_vertex;
}
-
-#endif /* FX */
diff --git a/src/mesa/drivers/glide/fxvb.c b/src/mesa/drivers/glide/fxvb.c
index e38d3c3cdd5..9468d83e3b4 100644
--- a/src/mesa/drivers/glide/fxvb.c
+++ b/src/mesa/drivers/glide/fxvb.c
@@ -1,9 +1,6 @@
-
/*
- * Mesa 3-D graphics library
- * Version: 3.3
- *
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
+ * GLX Hardware Device Driver for Intel i810
+ * Copyright (C) 1999 Keith Whitwell
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
@@ -18,400 +15,379 @@
* 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.
- *
+ * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS 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.
*
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
*
- * Author:
- * Keith Whitwell <[email protected]>
*/
-
-
-/* fxvsetup.c - 3Dfx VooDoo vertices setup functions */
-
-
-#ifdef HAVE_CONFIG_H
-#include "conf.h"
-#endif
-
-#if defined(FX)
-
-#include "fxdrv.h"
+/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfxvb.c,v 1.7 2000/11/08 05:02:43 dawes Exp $ */
+
+#include "glheader.h"
+#include "mtypes.h"
+#include "mem.h"
+#include "macros.h"
+#include "colormac.h"
#include "mmath.h"
+
+#include "math/m_translate.h"
#include "swrast_setup/swrast_setup.h"
+#include "tnl/tnl.h"
#include "tnl/t_context.h"
-#include "tnl/t_pipeline.h"
+
+#include "fxdrv.h"
-void
-fxPrintSetupFlags(const char *msg, GLuint flags)
+static void copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )
{
- fprintf(stderr, "%s: %d %s%s%s%s%s\n",
- msg,
- flags,
- (flags & SETUP_XYZW) ? " xyzw," : "",
- (flags & SETUP_SNAP) ? " snap," : "",
- (flags & SETUP_RGBA) ? " rgba," : "",
- (flags & SETUP_TMU0) ? " tmu0," : "",
- (flags & SETUP_TMU1) ? " tmu1," : "");
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ GrVertex *dst = fxMesa->verts + edst;
+ GrVertex *src = fxMesa->verts + esrc;
+
+ dst->r = src->r;
+ dst->g = src->g;
+ dst->b = src->b;
+ dst->a = src->a;
}
-static void
-project_texcoords(fxVertex * v,
- struct vertex_buffer *VB,
- GLuint tmu_nr, GLuint tc_nr, GLuint start, GLuint count)
+typedef void (*emit_func)( GLcontext *, GLuint, GLuint, void * );
+
+static struct {
+ emit_func emit;
+ interp_func interp;
+ GLboolean (*check_tex_sizes)( GLcontext *ctx );
+ GLuint vertex_format;
+} setup_tab[MAX_SETUP];
+
+
+static void import_float_colors( GLcontext *ctx )
{
- GrTmuVertex *tmu = &(v->v.tmuvtx[tmu_nr]);
- GLvector4f *vec = VB->TexCoordPtr[tc_nr];
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ struct gl_client_array *from = VB->ColorPtr[0];
+ struct gl_client_array *to = &FX_CONTEXT(ctx)->UbyteColor;
+ GLuint count = VB->Count;
- GLuint i;
- GLuint stride = vec->stride;
- GLfloat *data = VEC_ELT(vec, GLfloat, start);
+ if (!to->Ptr) {
+ to->Ptr = ALIGN_MALLOC( VB->Size * 4 * sizeof(GLubyte), 32 );
+ to->Type = GL_UNSIGNED_BYTE;
+ }
- for (i = start; i < count; i++, STRIDE_F(data, stride), v++) {
- tmu->oow = v->v.oow * data[3];
- tmu = (GrTmuVertex *) ((char *) tmu + sizeof(fxVertex));
+ /* 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;
}
-static void
-copy_w(fxVertex * v,
- struct vertex_buffer *VB, GLuint tmu_nr, GLuint start, GLuint count)
-{
- GrTmuVertex *tmu = &(v->v.tmuvtx[tmu_nr]);
- GLuint i;
+#define GET_COLOR(ptr, idx) (((GLfloat (*)[4])((ptr)->Ptr))[idx])
- for (i = start; i < count; i++, v++) {
- tmu->oow = v->v.oow;
- tmu = (GrTmuVertex *) ((char *) tmu + sizeof(fxVertex));
- }
-}
-/* need to compute W values for fogging purposes
- */
-static void
-fx_fake_fog_w(GLcontext * ctx,
- fxVertex * verts,
- struct vertex_buffer *VB, GLuint start, GLuint end)
+static void interp_extras( GLcontext *ctx,
+ GLfloat t,
+ GLuint dst, GLuint out, GLuint in,
+ GLboolean force_boundary )
{
- const GLfloat m10 = ctx->ProjectionMatrix.m[10];
- const GLfloat m14 = ctx->ProjectionMatrix.m[14];
- GLfloat(*clip)[4] = VB->ClipPtr->data;
- GLubyte *clipmask = VB->ClipMask;
- GLuint i;
-
- for (i = start; i < end; i++) {
- if (clipmask[i] == 0) {
- verts[i].v.oow = -m10 / (clip[i][2] - m14); /* -1/zEye */
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+
+ /*fprintf(stderr, "%s\n", __FUNCTION__);*/
+
+ if (VB->ColorPtr[1]) {
+ INTERP_4F( t,
+ GET_COLOR(VB->ColorPtr[1], dst),
+ GET_COLOR(VB->ColorPtr[1], out),
+ GET_COLOR(VB->ColorPtr[1], in) );
+
+ if (VB->SecondaryColorPtr[1]) {
+ INTERP_3F( t,
+ GET_COLOR(VB->SecondaryColorPtr[1], dst),
+ GET_COLOR(VB->SecondaryColorPtr[1], out),
+ GET_COLOR(VB->SecondaryColorPtr[1], in) );
}
}
-}
+ if (VB->EdgeFlag) {
+ VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
+ }
+ setup_tab[FX_CONTEXT(ctx)->SetupIndex].interp(ctx, t, dst, out, in,
+ force_boundary);
+}
-static tfxSetupFunc setupfuncs[MAX_SETUP];
+static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
+{
+ struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ if (VB->ColorPtr[1]) {
+ COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst),
+ GET_COLOR(VB->ColorPtr[1], src) );
-#define IND (SETUP_XYZW)
-#define INPUTS (VERT_CLIP)
-#define NAME fxsetupXYZW
-#include "fxvbtmp.h"
+ if (VB->SecondaryColorPtr[1]) {
+ COPY_4FV( GET_COLOR(VB->SecondaryColorPtr[1], dst),
+ GET_COLOR(VB->SecondaryColorPtr[1], src) );
+ }
+ }
-#define IND (SETUP_XYZW|SETUP_RGBA)
-#define INPUTS (VERT_CLIP|VERT_RGBA)
-#define NAME fxsetupXYZWRGBA
-#include "fxvbtmp.h"
+ copy_pv(ctx, dst, src);
+}
-#define IND (SETUP_XYZW|SETUP_TMU0)
-#define INPUTS (VERT_CLIP|VERT_TEX_ANY)
-#define NAME fxsetupXYZWT0
-#include "fxvbtmp.h"
-#define IND (SETUP_XYZW|SETUP_TMU1)
-#define INPUTS (VERT_CLIP|VERT_TEX_ANY)
-#define NAME fxsetupXYZWT1
+#define IND (SETUP_XYZW|SETUP_RGBA)
+#define TAG(x) x##_wg
#include "fxvbtmp.h"
-#define IND (SETUP_XYZW|SETUP_TMU1|SETUP_TMU0)
-#define INPUTS (VERT_CLIP|VERT_TEX_ANY)
-#define NAME fxsetupXYZWT0T1
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0)
+#define TAG(x) x##_wgt0
#include "fxvbtmp.h"
-#define IND (SETUP_XYZW|SETUP_TMU0|SETUP_RGBA)
-#define INPUTS (VERT_CLIP|VERT_RGBA|VERT_TEX_ANY)
-#define NAME fxsetupXYZWRGBAT0
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_wgt0t1
#include "fxvbtmp.h"
-#define IND (SETUP_XYZW|SETUP_TMU1|SETUP_RGBA)
-#define INPUTS (VERT_CLIP|VERT_RGBA|VERT_TEX_ANY)
-#define NAME fxsetupXYZWRGBAT1
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX)
+#define TAG(x) x##_wgpt0
#include "fxvbtmp.h"
-#define IND (SETUP_XYZW|SETUP_TMU1|SETUP_TMU0|SETUP_RGBA)
-#define INPUTS (VERT_CLIP|VERT_RGBA|VERT_TEX_ANY)
-#define NAME fxsetupXYZWRGBAT0T1
+#define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
+ SETUP_PTEX)
+#define TAG(x) x##_wgpt0t1
#include "fxvbtmp.h"
-#define IND (SETUP_XYZW|SETUP_SNAP)
-#define INPUTS (VERT_CLIP)
-#define NAME fxsetupXYZW_SNAP
-#include "fxvbtmp.h"
-
+/* Snapping for voodoo-1
+ */
#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA)
-#define INPUTS (VERT_CLIP|VERT_RGBA)
-#define NAME fxsetupXYZW_SNAP_RGBA
-#include "fxvbtmp.h"
-
-#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_TMU0)
-#define INPUTS (VERT_CLIP|VERT_TEX_ANY)
-#define NAME fxsetupXYZW_SNAP_T0
+#define TAG(x) x##_wsg
#include "fxvbtmp.h"
-#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_TMU1)
-#define INPUTS (VERT_CLIP|VERT_TEX_ANY)
-#define NAME fxsetupXYZW_SNAP_T1
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0)
+#define TAG(x) x##_wsgt0
#include "fxvbtmp.h"
-#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_TMU1|SETUP_TMU0)
-#define INPUTS (VERT_CLIP|VERT_TEX_ANY)
-#define NAME fxsetupXYZW_SNAP_T0T1
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_TMU1)
+#define TAG(x) x##_wsgt0t1
#include "fxvbtmp.h"
-#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_TMU0|SETUP_RGBA)
-#define INPUTS (VERT_CLIP|VERT_RGBA|VERT_TEX_ANY)
-#define NAME fxsetupXYZW_SNAP_RGBAT0
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_PTEX)
+#define TAG(x) x##_wsgpt0
#include "fxvbtmp.h"
-#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_TMU1|SETUP_RGBA)
-#define INPUTS (VERT_CLIP|VERT_RGBA|VERT_TEX_ANY)
-#define NAME fxsetupXYZW_SNAP_RGBAT1
+#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
+ SETUP_TMU1|SETUP_PTEX)
+#define TAG(x) x##_wsgpt0t1
#include "fxvbtmp.h"
-#define IND (SETUP_XYZW|SETUP_SNAP|SETUP_TMU1|SETUP_TMU0|SETUP_RGBA)
-#define INPUTS (VERT_CLIP|VERT_RGBA|VERT_TEX_ANY)
-#define NAME fxsetupXYZW_SNAP_RGBAT0T1
-#include "fxvbtmp.h"
-
-
+/* Vertex repair (multipass rendering)
+ */
#define IND (SETUP_RGBA)
-#define INPUTS (VERT_RGBA)
-#define NAME fxsetupRGBA
+#define TAG(x) x##_g
#include "fxvbtmp.h"
#define IND (SETUP_TMU0)
-#define INPUTS (VERT_TEX_ANY)
-#define NAME fxsetupT0
-#include "fxvbtmp.h"
-
-#define IND (SETUP_TMU1)
-#define INPUTS (VERT_TEX_ANY)
-#define NAME fxsetupT1
+#define TAG(x) x##_t0
#include "fxvbtmp.h"
-#define IND (SETUP_TMU1|SETUP_TMU0)
-#define INPUTS (VERT_TEX_ANY)
-#define NAME fxsetupT0T1
+#define IND (SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_t0t1
#include "fxvbtmp.h"
-#define IND (SETUP_TMU0|SETUP_RGBA)
-#define INPUTS (VERT_RGBA|VERT_TEX_ANY)
-#define NAME fxsetupRGBAT0
+#define IND (SETUP_RGBA|SETUP_TMU0)
+#define TAG(x) x##_gt0
#include "fxvbtmp.h"
-#define IND (SETUP_TMU1|SETUP_RGBA)
-#define INPUTS (VERT_RGBA|VERT_TEX_ANY)
-#define NAME fxsetupRGBAT1
+#define IND (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
+#define TAG(x) x##_gt0t1
#include "fxvbtmp.h"
-#define IND (SETUP_TMU1|SETUP_TMU0|SETUP_RGBA)
-#define INPUTS (VERT_RGBA|VERT_TEX_ANY)
-#define NAME fxsetupRGBAT0T1
-#include "fxvbtmp.h"
-static void
-fxsetup_invalid(GLcontext * ctx, GLuint start, GLuint end)
+static void init_setup_tab( void )
{
- fprintf(stderr, "fxMesa: invalid setup function\n");
- (void) (ctx && start && end);
+ init_wg();
+ init_wgt0();
+ init_wgt0t1();
+ init_wgpt0();
+ init_wgpt0t1();
+
+ init_wsg();
+ init_wsgt0();
+ init_wsgt0t1();
+ init_wsgpt0();
+ init_wsgpt0t1();
+
+ init_g();
+ init_t0();
+ init_t0t1();
+ init_gt0();
+ init_gt0t1();
}
-void
-fxDDSetupInit(void)
+void fxPrintSetupFlags(char *msg, GLuint flags )
{
- GLuint i;
- for (i = 0; i < Elements(setupfuncs); i++)
- setupfuncs[i] = fxsetup_invalid;
-
- setupfuncs[SETUP_XYZW] = fxsetupXYZW;
- setupfuncs[SETUP_XYZW | SETUP_RGBA] = fxsetupXYZWRGBA;
- setupfuncs[SETUP_XYZW | SETUP_TMU0] = fxsetupXYZWT0;
- setupfuncs[SETUP_XYZW | SETUP_TMU1] = fxsetupXYZWT1;
- setupfuncs[SETUP_XYZW | SETUP_TMU0 | SETUP_RGBA] = fxsetupXYZWRGBAT0;
- setupfuncs[SETUP_XYZW | SETUP_TMU1 | SETUP_RGBA] = fxsetupXYZWRGBAT1;
- setupfuncs[SETUP_XYZW | SETUP_TMU1 | SETUP_TMU0] = fxsetupXYZWT0T1;
- setupfuncs[SETUP_XYZW | SETUP_TMU1 | SETUP_TMU0 | SETUP_RGBA] =
- fxsetupXYZWRGBAT0T1;
-
- setupfuncs[SETUP_XYZW | SETUP_SNAP] = fxsetupXYZW_SNAP;
- setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_RGBA] = fxsetupXYZW_SNAP_RGBA;
- setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_TMU0] = fxsetupXYZW_SNAP_T0;
- setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_TMU1] = fxsetupXYZW_SNAP_T1;
- setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_TMU0 | SETUP_RGBA] =
- fxsetupXYZW_SNAP_RGBAT0;
- setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_TMU1 | SETUP_RGBA] =
- fxsetupXYZW_SNAP_RGBAT1;
- setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_TMU1 | SETUP_TMU0] =
- fxsetupXYZW_SNAP_T0T1;
- setupfuncs[SETUP_XYZW | SETUP_SNAP | SETUP_TMU1 | SETUP_TMU0 | SETUP_RGBA]
- = fxsetupXYZW_SNAP_RGBAT0T1;
-
- setupfuncs[SETUP_RGBA] = fxsetupRGBA;
- setupfuncs[SETUP_TMU0] = fxsetupT0;
- setupfuncs[SETUP_TMU1] = fxsetupT1;
- setupfuncs[SETUP_TMU1 | SETUP_TMU0] = fxsetupT0T1;
- setupfuncs[SETUP_TMU0 | SETUP_RGBA] = fxsetupRGBAT0;
- setupfuncs[SETUP_TMU1 | SETUP_RGBA] = fxsetupRGBAT1;
- setupfuncs[SETUP_TMU1 | SETUP_TMU0 | SETUP_RGBA] = fxsetupRGBAT0T1;
+ fprintf(stderr, "%s(%x): %s%s%s%s\n",
+ msg,
+ (int)flags,
+ (flags & SETUP_XYZW) ? " xyzw," : "",
+ (flags & SETUP_SNAP) ? " snap," : "",
+ (flags & SETUP_RGBA) ? " rgba," : "",
+ (flags & SETUP_TMU0) ? " tex-0," : "",
+ (flags & SETUP_TMU1) ? " tex-1," : "");
}
-void
-fx_validate_BuildProjVerts(GLcontext * ctx, GLuint start, GLuint count,
- GLuint newinputs)
+void fxCheckTexSizes( GLcontext *ctx )
{
TNLcontext *tnl = TNL_CONTEXT(ctx);
- fxMesaContext fxMesa = (fxMesaContext) ctx->DriverCtx;
-
- if (!fxMesa->is_in_hardware)
- tnl->Driver.BuildProjectedVertices = _swsetup_BuildProjectedVertices;
- else {
- GLuint setupindex = SETUP_XYZW;
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
- if (fxMesa->snapVertices)
- setupindex |= SETUP_SNAP;
+ if (!setup_tab[fxMesa->SetupIndex].check_tex_sizes(ctx)) {
+ GLuint ind = fxMesa->SetupIndex |= (SETUP_PTEX|SETUP_RGBA);
- fxMesa->tmu_source[0] = 0;
- fxMesa->tmu_source[1] = 1;
- fxMesa->tex_dest[0] = SETUP_TMU0;
- fxMesa->tex_dest[1] = SETUP_TMU1;
-
- /* For flat and two-side-lit triangles, colors will always be added
- * to vertices in the triangle functions. Vertices will *always*
- * have rbga values, but only sometimes will they come from here.
+ /* Tdfx handles projective textures nicely; just have to change
+ * up to the new vertex format.
*/
- if ((ctx->_TriangleCaps & (DD_FLATSHADE | DD_TRI_LIGHT_TWOSIDE)) == 0)
- setupindex |= SETUP_RGBA;
-
- if (ctx->Texture._ReallyEnabled & TEXTURE0_2D)
- setupindex |= SETUP_TMU0;
-
- if (ctx->Texture._ReallyEnabled & TEXTURE1_2D) {
- if ((ctx->Texture._ReallyEnabled & TEXTURE0_2D) == 0) {
- fxMesa->tmu_source[0] = 1;
- fxMesa->tex_dest[0] = SETUP_TMU1;
- fxMesa->tmu_source[1] = 0;
- fxMesa->tex_dest[1] = SETUP_TMU0;
- setupindex |= SETUP_TMU0;
- }
- else {
- setupindex |= SETUP_TMU1;
+ if (setup_tab[ind].vertex_format != fxMesa->stw_hint_state) {
+
+ fxMesa->stw_hint_state = setup_tab[ind].vertex_format;
+ FX_grHints(GR_HINT_STWHINT, fxMesa->stw_hint_state);
+
+ /* This is required as we have just changed the vertex
+ * format, so the interp routines must also change.
+ * In the unfilled and twosided cases we are using the
+ * Extras ones anyway, so leave them in place.
+ */
+ if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
+ tnl->Driver.Render.Interp = setup_tab[fxMesa->SetupIndex].interp;
}
}
-
- if (MESA_VERBOSE & (VERBOSE_DRIVER | VERBOSE_PIPELINE | VERBOSE_STATE))
- fxPrintSetupFlags("fxmesa: vertex setup function", setupindex);
-
- fxMesa->setupindex = setupindex;
- tnl->Driver.BuildProjectedVertices = fx_BuildProjVerts;
}
- tnl->Driver.BuildProjectedVertices(ctx, start, count, newinputs);
}
-void
-fx_BuildProjVerts(GLcontext * ctx, GLuint start, GLuint count,
- GLuint newinputs)
+void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint count,
+ GLuint newinputs )
{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ GrVertex *v = (fxMesa->verts + start);
- if (newinputs == ~0) {
- /* build interpolated vertices */
- setupfuncs[fxMesa->setupindex] (ctx, start, count);
- }
- else {
- GLuint ind = fxMesa->setup_gone;
- fxMesa->setup_gone = 0;
-
- if (newinputs & VERT_CLIP)
- ind = fxMesa->setupindex; /* clipmask has potentially changed */
- else {
- if (newinputs & VERT_TEX0)
- ind |= fxMesa->tex_dest[0];
+ if (!newinputs)
+ return;
- if (newinputs & VERT_TEX1)
- ind |= fxMesa->tex_dest[1];
+ if (newinputs & VERT_CLIP) {
+ setup_tab[fxMesa->SetupIndex].emit( ctx, start, count, v );
+ } else {
+ GLuint ind = 0;
- if (newinputs & VERT_RGBA)
- ind |= SETUP_RGBA;
+ if (newinputs & VERT_RGBA)
+ ind |= SETUP_RGBA;
+
+ if (newinputs & VERT_TEX0)
+ ind |= SETUP_TMU0;
- ind &= fxMesa->setupindex;
- }
+ if (newinputs & VERT_TEX1)
+ ind |= SETUP_TMU0|SETUP_TMU1;
- if (ind) {
- if (fxMesa->new_state)
- fxSetupFXUnits(ctx); /* why? */
+ if (fxMesa->SetupIndex & SETUP_PTEX)
+ ind = ~0;
- if (VB->importable_data & newinputs)
- VB->import_data(ctx, VB->importable_data & newinputs,
- VEC_BAD_STRIDE);
+ ind &= fxMesa->SetupIndex;
- setupfuncs[ind] (ctx, start, count);
+ if (ind) {
+ setup_tab[ind].emit( ctx, start, count, v );
}
}
}
-void
-fxAllocVB(GLcontext * ctx)
+
+void fxChooseVertexState( GLcontext *ctx )
{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
TNLcontext *tnl = TNL_CONTEXT(ctx);
- fxMesa->verts = ALIGN_MALLOC(tnl->vb.Size * sizeof(fxMesa->verts[0]), 32);
-}
+ fxMesaContext fxMesa = FX_CONTEXT( ctx );
+ GLuint ind = SETUP_XYZW|SETUP_RGBA;
-void
-fxFreeVB(GLcontext * ctx)
-{
- fxMesaContext fxMesa = FX_CONTEXT(ctx);
- if (fxMesa->verts)
- ALIGN_FREE(fxMesa->verts);
- fxMesa->verts = 0;
-}
+ if (fxMesa->snapVertices)
+ ind |= SETUP_SNAP;
+
+ fxMesa->tmu_source[0] = 0;
+ fxMesa->tmu_source[1] = 1;
+ if (ctx->Texture._ReallyEnabled & 0xf0) {
+ if (ctx->Texture._ReallyEnabled & 0xf) {
+ ind |= SETUP_TMU1|SETUP_TMU0;
+ }
+ else {
+ fxMesa->tmu_source[0] = 1;
+ fxMesa->tmu_source[1] = 0;
+ ind |= SETUP_TMU0;
+ }
+ }
+ else if (ctx->Texture._ReallyEnabled & 0xf) {
+ ind |= SETUP_TMU0;
+ }
+
+ fxMesa->SetupIndex = ind;
+
+ if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
+ tnl->Driver.Render.Interp = interp_extras;
+ tnl->Driver.Render.CopyPV = copy_pv_extras;
+ } else {
+ tnl->Driver.Render.Interp = setup_tab[ind].interp;
+ tnl->Driver.Render.CopyPV = copy_pv;
+ }
-#else
+ if (setup_tab[ind].vertex_format != fxMesa->stw_hint_state) {
+ fxMesa->stw_hint_state = setup_tab[ind].vertex_format;
+ FX_grHints(GR_HINT_STWHINT, fxMesa->stw_hint_state);
+ }
+}
-/*
- * Need this to provide at least one external definition.
- */
-extern int gl_fx_dummy_function_vsetup(void);
-int
-gl_fx_dummy_function_vsetup(void)
+void fxAllocVB( GLcontext *ctx )
{
- return 0;
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ GLuint size = TNL_CONTEXT(ctx)->vb.Size;
+ static int firsttime = 1;
+ if (firsttime) {
+ init_setup_tab();
+ firsttime = 0;
+ }
+
+ fxMesa->verts = (GrVertex *)ALIGN_MALLOC(size * sizeof(GrVertex), 32);
+ fxMesa->SetupIndex = SETUP_XYZW|SETUP_RGBA;
}
-#endif /* FX */
+
+void fxFreeVB( GLcontext *ctx )
+{
+ fxMesaContext fxMesa = FX_CONTEXT(ctx);
+ if (fxMesa->verts) {
+ 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/glide/fxvbtmp.h b/src/mesa/drivers/glide/fxvbtmp.h
index 24d5b521a00..570e7adf16b 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 <[email protected]>
- */
-
-
-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
diff --git a/src/mesa/drivers/osmesa/osmesa.c b/src/mesa/drivers/osmesa/osmesa.c
index 85679d6a928..a0f2823f1d9 100644
--- a/src/mesa/drivers/osmesa/osmesa.c
+++ b/src/mesa/drivers/osmesa/osmesa.c
@@ -1,4 +1,4 @@
-/* $Id: osmesa.c,v 1.60 2001/07/05 15:12:13 brianp Exp $ */
+/* $Id: osmesa.c,v 1.61 2001/07/12 22:09:21 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -346,6 +346,7 @@ OSMesaCreateContextExt( GLenum format, GLint depthBits, GLint stencilBits,
_tnl_CreateContext( ctx );
_swsetup_CreateContext( ctx );
+ _swsetup_Wakeup( ctx );
osmesa_register_swrast_functions( ctx );
}
}
@@ -2072,20 +2073,6 @@ static void osmesa_update_state( GLcontext *ctx, GLuint new_state )
swdd->SetReadBuffer = set_read_buffer;
tnl->Driver.RunPipeline = _tnl_run_pipeline;
- tnl->Driver.RenderStart = _swsetup_RenderStart;
- tnl->Driver.RenderFinish = _swsetup_RenderFinish;
- tnl->Driver.BuildProjectedVertices = _swsetup_BuildProjectedVertices;
- tnl->Driver.RenderPrimitive = _swsetup_RenderPrimitive;
- tnl->Driver.PointsFunc = _swsetup_Points;
- tnl->Driver.LineFunc = _swsetup_Line;
- tnl->Driver.TriangleFunc = _swsetup_Triangle;
- tnl->Driver.QuadFunc = _swsetup_Quad;
- tnl->Driver.ResetLineStipple = _swrast_ResetLineStipple;
- tnl->Driver.RenderInterp = _swsetup_RenderInterp;
- tnl->Driver.RenderCopyPV = _swsetup_RenderCopyPV;
- tnl->Driver.RenderClippedLine = _swsetup_RenderClippedLine;
- tnl->Driver.RenderClippedPolygon = _swsetup_RenderClippedPolygon;
-
_swrast_InvalidateState( ctx, new_state );
_swsetup_InvalidateState( ctx, new_state );
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c
index dbb01f343ef..768aa2f56bd 100644
--- a/src/mesa/drivers/x11/xm_dd.c
+++ b/src/mesa/drivers/x11/xm_dd.c
@@ -1,4 +1,4 @@
-/* $Id: xm_dd.c,v 1.24 2001/05/10 12:22:32 keithw Exp $ */
+/* $Id: xm_dd.c,v 1.25 2001/07/12 22:09:21 keithw Exp $ */
/*
* Mesa 3-D graphics library
@@ -992,19 +992,10 @@ void xmesa_init_pointers( GLcontext *ctx )
*/
tnl = TNL_CONTEXT(ctx);
tnl->Driver.RunPipeline = _tnl_run_pipeline;
- tnl->Driver.RenderStart = _swsetup_RenderStart;
- tnl->Driver.RenderFinish = _swsetup_RenderFinish;
- tnl->Driver.BuildProjectedVertices = _swsetup_BuildProjectedVertices;
- tnl->Driver.RenderPrimitive = _swsetup_RenderPrimitive;
- tnl->Driver.PointsFunc = _swsetup_Points;
- tnl->Driver.LineFunc = _swsetup_Line;
- tnl->Driver.TriangleFunc = _swsetup_Triangle;
- tnl->Driver.QuadFunc = _swsetup_Quad;
- tnl->Driver.ResetLineStipple = _swrast_ResetLineStipple;
- tnl->Driver.RenderInterp = _swsetup_RenderInterp;
- tnl->Driver.RenderCopyPV = _swsetup_RenderCopyPV;
- tnl->Driver.RenderClippedLine = _swsetup_RenderClippedLine;
- tnl->Driver.RenderClippedPolygon = _swsetup_RenderClippedPolygon;
+
+ /* Install swsetup for tnl->Driver.Render.*:
+ */
+ _swsetup_Wakeup(ctx);
(void) DitherValues; /* silenced unused var warning */
}