several new bugs
This commit is contained in:
parent
25f0e8227f
commit
1c2a498119
|
@ -26,6 +26,9 @@
|
|||
/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.c,v 1.12 2003/05/08 09:25:35 herrb Exp $ */
|
||||
|
||||
/*
|
||||
* New fixes:
|
||||
* Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
|
||||
*
|
||||
* Original rewrite:
|
||||
* Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
|
||||
*
|
||||
|
@ -68,7 +71,16 @@ static void tdfxDDInitExtensions( GLcontext *ctx )
|
|||
|
||||
_mesa_enable_extension( ctx, "GL_HP_occlusion_test" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_paletted_texture" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_shared_texture_palette" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_lod_bias" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_blend_func_separate" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_fog_coord" );
|
||||
|
||||
#if 0
|
||||
_mesa_enable_extension(ctx, "GL_EXT_secondary_color");
|
||||
_mesa_enable_extension(ctx, "GL_ARB_point_sprite");
|
||||
_mesa_enable_extension(ctx, "GL_EXT_point_parameters");
|
||||
#endif
|
||||
|
||||
if ( fxMesa->haveTwoTMUs ) {
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_env_add" );
|
||||
|
@ -76,21 +88,41 @@ static void tdfxDDInitExtensions( GLcontext *ctx )
|
|||
}
|
||||
|
||||
if ( TDFX_IS_NAPALM( fxMesa ) ) {
|
||||
#if 0
|
||||
_mesa_enable_extension( ctx, "GL_ARB_texture_compression" );
|
||||
_mesa_enable_extension( ctx, "GL_3DFX_texture_compression_FXT1" );
|
||||
#endif
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_env_combine" );
|
||||
}
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_compression_s3tc" );
|
||||
_mesa_enable_extension( ctx, "GL_S3_s3tc" );
|
||||
|
||||
#if 0
|
||||
_mesa_enable_extension( ctx, "GL_ARB_texture_cube_map");
|
||||
_mesa_enable_extension( ctx, "GL_NV_texture_rectangle");
|
||||
#endif
|
||||
_mesa_enable_extension( ctx, "GL_NV_blend_square" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_blend_subtract" );
|
||||
_mesa_enable_extension( ctx, "GL_EXT_blend_equation_separate" );
|
||||
} else {
|
||||
_mesa_enable_extension( ctx, "GL_SGIS_generate_mipmap" );
|
||||
}
|
||||
|
||||
if (fxMesa->haveHwStencil) {
|
||||
_mesa_enable_extension( ctx, "GL_EXT_stencil_wrap" );
|
||||
}
|
||||
|
||||
if (1/*fxMesa->Glide.HaveMirrorExt - JJJ*/) {
|
||||
_mesa_enable_extension(ctx, "GL_ARB_texture_mirrored_repeat");
|
||||
}
|
||||
|
||||
if (TDFX_IS_NAPALM(fxMesa)/*fxMesa->Glide.HaveCombineExt - JJJ*/) {
|
||||
_mesa_enable_extension( ctx, "GL_EXT_texture_env_combine" );
|
||||
}
|
||||
|
||||
/* core-level extensions */
|
||||
_mesa_enable_extension(ctx, "GL_EXT_multi_draw_arrays");
|
||||
_mesa_enable_extension(ctx, "GL_IBM_multimode_draw_arrays");
|
||||
_mesa_enable_extension(ctx, "GL_ARB_vertex_buffer_object");
|
||||
#if 0
|
||||
/* not just yet */
|
||||
_mesa_enable_extension(ctx, "GL_ARB_vertex_program");
|
||||
_mesa_enable_extension(ctx, "GL_NV_vertex_program");
|
||||
_mesa_enable_extension(ctx, "GL_NV_vertex_program1_1");
|
||||
_mesa_enable_extension(ctx, "GL_MESA_program_debug");
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -98,10 +130,16 @@ static void tdfxDDInitExtensions( GLcontext *ctx )
|
|||
static const struct tnl_pipeline_stage *tdfx_pipeline[] = {
|
||||
&_tnl_vertex_transform_stage,
|
||||
&_tnl_normal_transform_stage,
|
||||
&_tnl_lighting_stage, /* REMOVE: fog coord stage */
|
||||
&_tnl_lighting_stage,
|
||||
&_tnl_fog_coordinate_stage,
|
||||
&_tnl_texgen_stage,
|
||||
&_tnl_texture_transform_stage,
|
||||
/* REMOVE: point attenuation stage */
|
||||
&_tnl_point_attenuation_stage,
|
||||
#if 0
|
||||
#if defined(FEATURE_NV_vertex_program) || defined(FEATURE_ARB_vertex_program)
|
||||
&_tnl_vertex_program_stage,
|
||||
#endif
|
||||
#endif
|
||||
&_tnl_render_stage,
|
||||
0,
|
||||
};
|
||||
|
@ -157,6 +195,10 @@ GLboolean tdfxCreateContext( const __GLcontextModes *mesaVis,
|
|||
fxMesa->fxScreen = fxScreen;
|
||||
fxMesa->sarea = saPriv;
|
||||
|
||||
/*JJJ - really?*/
|
||||
fxMesa->haveHwAlpha = ( mesaVis->alphaBits &&
|
||||
((mesaVis->greenBits == 8) ||
|
||||
(mesaVis->depthBits == 0)) );
|
||||
fxMesa->haveHwStencil = ( TDFX_IS_NAPALM( fxMesa ) &&
|
||||
mesaVis->stencilBits &&
|
||||
mesaVis->depthBits == 24 );
|
||||
|
@ -293,7 +335,7 @@ static GLboolean tdfxInitVertexFormats( tdfxContextPtr fxMesa )
|
|||
fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_TINY] );
|
||||
|
||||
/* Non textured vertex format - 24 bytes (Need w for table fog)
|
||||
|
@ -315,7 +357,6 @@ static GLboolean tdfxInitVertexFormats( tdfxContextPtr fxMesa )
|
|||
fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
|
||||
/*grVertexLayout( GR_PARAM_FOG_EXT, TDFX_FOG_OFFSET, GR_PARAM_ENABLE );*/
|
||||
fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_SINGLE] );
|
||||
|
||||
/* Multitextured vertex format - 40 bytes.
|
||||
|
@ -328,10 +369,21 @@ static GLboolean tdfxInitVertexFormats( tdfxContextPtr fxMesa )
|
|||
fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_ST1, TDFX_ST1_OFFSET, GR_PARAM_ENABLE );
|
||||
/*fxMesa->Glide.grVertexLayout( GR_PARAM_FOG_EXT, TDFX_FOG_OFFSET, GR_PARAM_ENABLE );*/
|
||||
fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_MULTI] );
|
||||
|
||||
/* Projected texture vertex format - 48 bytes.
|
||||
/* Projected texture vertex format - 36 bytes.
|
||||
*/
|
||||
fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
|
||||
fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_XY, TDFX_XY_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_Z, TDFX_Z_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_Q, TDFX_Q_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_PARGB, TDFX_ARGB_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_ST0, TDFX_ST0_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_Q0, TDFX_Q0_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJ1] );
|
||||
|
||||
/* Projected multitexture vertex format - 48 bytes.
|
||||
*/
|
||||
fxMesa->Glide.grReset( GR_VERTEX_PARAMETER );
|
||||
fxMesa->Glide.grCoordinateSpace( GR_WINDOW_COORDS );
|
||||
|
@ -343,8 +395,7 @@ static GLboolean tdfxInitVertexFormats( tdfxContextPtr fxMesa )
|
|||
fxMesa->Glide.grVertexLayout( GR_PARAM_Q0, TDFX_Q0_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_ST1, TDFX_ST1_OFFSET, GR_PARAM_ENABLE );
|
||||
fxMesa->Glide.grVertexLayout( GR_PARAM_Q1, TDFX_Q1_OFFSET, GR_PARAM_ENABLE );
|
||||
/*fxMesa->Glide.grVertexLayout( GR_PARAM_FOG_EXT, TDFX_FOG_OFFSET, GR_PARAM_ENABLE );*/
|
||||
fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJECT] );
|
||||
fxMesa->Glide.grGlideGetVertexLayout( fxMesa->layout[TDFX_LAYOUT_PROJ2] );
|
||||
|
||||
UNLOCK_HARDWARE( fxMesa );
|
||||
|
||||
|
@ -361,6 +412,7 @@ tdfxInitContext( __DRIdrawablePrivate *driDrawPriv, tdfxContextPtr fxMesa )
|
|||
/* KW: Would be nice to make one of these a member of the other.
|
||||
*/
|
||||
FxI32 result[2];
|
||||
const char *gext;
|
||||
|
||||
if ( TDFX_DEBUG & DEBUG_VERBOSE_DRI ) {
|
||||
fprintf( stderr, "%s( %p )\n", __FUNCTION__, (void *)fxMesa );
|
||||
|
@ -407,6 +459,18 @@ tdfxInitContext( __DRIdrawablePrivate *driDrawPriv, tdfxContextPtr fxMesa )
|
|||
|
||||
LOCK_HARDWARE( fxMesa );
|
||||
|
||||
/* JJJ - COMMAND_TRANSPORT, PALETTE6666 */
|
||||
gext = fxMesa->Glide.grGetString( GR_EXTENSION );
|
||||
fxMesa->Glide.HaveCombineExt = strstr(gext, "COMBINE") && !getenv("MESA_FX_IGNORE_CMBEXT");
|
||||
fxMesa->Glide.HaveCommandTransportExt = GL_FALSE;
|
||||
fxMesa->Glide.HaveFogCoordExt = GL_TRUE;
|
||||
fxMesa->Glide.HavePixelExt = strstr(gext, "PIXEXT") && !getenv("MESA_FX_IGNORE_PIXEXT");
|
||||
fxMesa->Glide.HaveTextureBufferExt = GL_TRUE;
|
||||
fxMesa->Glide.HaveTexFmtExt = strstr(gext, "TEXFMT") && !getenv("MESA_FX_IGNORE_TEXFMT");
|
||||
fxMesa->Glide.HaveTexUMAExt = strstr(gext, "TEXUMA") && !getenv("MESA_FX_IGNORE_TEXUMA");
|
||||
fxMesa->Glide.HaveMirrorExt = strstr(gext, "TEXMIRROR") && !getenv("MESA_FX_IGNORE_MIREXT");
|
||||
fxMesa->Glide.HaveTexus2 = GL_FALSE;
|
||||
|
||||
if ( fxMesa->glCtx->Visual.depthBits > 0 ) {
|
||||
fxMesa->Glide.grDepthBufferMode(GR_DEPTHBUFFER_ZBUFFER);
|
||||
} else {
|
||||
|
@ -449,7 +513,7 @@ tdfxInitContext( __DRIdrawablePrivate *driDrawPriv, tdfxContextPtr fxMesa )
|
|||
printf( "GR_VERSION = %s\n", (char *) fxMesa->Glide.grGetString( GR_VERSION ) );
|
||||
printf( "GR_VENDOR = %s\n", (char *) fxMesa->Glide.grGetString( GR_VENDOR ) );
|
||||
printf( "GR_HARDWARE = %s\n", (char *) fxMesa->Glide.grGetString( GR_HARDWARE ) );
|
||||
printf( "GR_EXTENSION = %s\n", (char *) fxMesa->Glide.grGetString( GR_EXTENSION ) );
|
||||
printf( "GR_EXTENSION = %s\n", (char *) gext );
|
||||
}
|
||||
|
||||
UNLOCK_HARDWARE( fxMesa );
|
||||
|
@ -550,15 +614,19 @@ tdfxMakeCurrent( __DRIcontextPrivate *driContextPriv,
|
|||
newFx->driDrawable = driDrawPriv;
|
||||
newFx->dirty = ~0;
|
||||
}
|
||||
else if (curCtx == newCtx) {
|
||||
/* same drawable, same context -> no-op */
|
||||
/* Need to call _mesa_make_current2() in order to make sure API
|
||||
* dispatch is set correctly.
|
||||
*/
|
||||
_mesa_make_current2( newCtx,
|
||||
(GLframebuffer *) driDrawPriv->driverPrivate,
|
||||
(GLframebuffer *) driReadPriv->driverPrivate );
|
||||
return GL_TRUE;
|
||||
else {
|
||||
if (curCtx == newCtx) {
|
||||
/* same drawable, same context -> no-op */
|
||||
/* Need to call _mesa_make_current2() in order to make sure API
|
||||
* dispatch is set correctly.
|
||||
*/
|
||||
_mesa_make_current2( newCtx,
|
||||
(GLframebuffer *) driDrawPriv->driverPrivate,
|
||||
(GLframebuffer *) driReadPriv->driverPrivate );
|
||||
return GL_TRUE;
|
||||
}
|
||||
/* [dBorca] tunnel2 requires this */
|
||||
newFx->dirty = ~0;
|
||||
}
|
||||
|
||||
if ( !newFx->Glide.Initialized ) {
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_context.h,v 1.5 2002/02/24 21:51:10 dawes Exp $ */
|
||||
|
||||
/*
|
||||
* New fixes:
|
||||
* Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
|
||||
*
|
||||
* Original rewrite:
|
||||
* Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
|
||||
*
|
||||
|
@ -108,6 +111,7 @@
|
|||
#define TDFX_UPLOAD_FOG_MODE 0x00000400
|
||||
#define TDFX_UPLOAD_FOG_COLOR 0x00000800
|
||||
#define TDFX_UPLOAD_FOG_TABLE 0x00001000
|
||||
#define TDFX_UPLOAD_CONSTANT_COLOR 0x00002000
|
||||
|
||||
#define TDFX_UPLOAD_CLIP 0x00002000
|
||||
#define TDFX_UPLOAD_CULL 0x00004000
|
||||
|
@ -128,7 +132,7 @@
|
|||
|
||||
/* Flags for software fallback cases */
|
||||
/* See correponding strings in tdfx_tris.c */
|
||||
#define TDFX_FALLBACK_TEXTURE_1D_3D 0x0001
|
||||
#define TDFX_FALLBACK_TEXTURE_MAP 0x0001
|
||||
#define TDFX_FALLBACK_DRAW_BUFFER 0x0002
|
||||
#define TDFX_FALLBACK_SPECULAR 0x0004
|
||||
#define TDFX_FALLBACK_STENCIL 0x0008
|
||||
|
@ -146,15 +150,15 @@
|
|||
#define TDFX_LAYOUT_NOTEX 1
|
||||
#define TDFX_LAYOUT_SINGLE 2
|
||||
#define TDFX_LAYOUT_MULTI 3
|
||||
#define TDFX_LAYOUT_PROJECT 4
|
||||
#define TDFX_NUM_LAYOUTS 5
|
||||
#define TDFX_LAYOUT_PROJ1 4
|
||||
#define TDFX_LAYOUT_PROJ2 5
|
||||
#define TDFX_NUM_LAYOUTS 6
|
||||
|
||||
#define TDFX_XY_OFFSET 0
|
||||
#define TDFX_Z_OFFSET 8
|
||||
#define TDFX_Q_OFFSET 12
|
||||
#define TDFX_ARGB_OFFSET 16
|
||||
#define TDFX_PAD_OFFSET 20
|
||||
#define TDFX_FOG_OFFSET 20 /* experimental */
|
||||
#define TDFX_FOG_OFFSET 20
|
||||
#define TDFX_ST0_OFFSET 24
|
||||
#define TDFX_ST1_OFFSET 32
|
||||
#define TDFX_Q0_OFFSET 40
|
||||
|
@ -316,7 +320,10 @@ typedef struct tdfxTexInfo_t
|
|||
|
||||
GLfloat sScale, tScale; /* texcoord scale factor */
|
||||
|
||||
GrTexTable_t paltype;
|
||||
GuTexPalette palette;
|
||||
|
||||
GLboolean padded;
|
||||
}
|
||||
tdfxTexInfo;
|
||||
|
||||
|
@ -344,49 +351,20 @@ struct tdfxSharedState {
|
|||
/* ================================================================
|
||||
* The vertex structures.
|
||||
*/
|
||||
typedef struct {
|
||||
GLubyte blue;
|
||||
GLubyte green;
|
||||
GLubyte red;
|
||||
GLubyte alpha;
|
||||
} tdfx_color_t;
|
||||
|
||||
typedef struct {
|
||||
/* The size of this union is not of relevence:
|
||||
*/
|
||||
typedef struct tdfx_vertex_t {
|
||||
GLfloat x, y, z; /* Coordinates in screen space */
|
||||
GLfloat rhw; /* Reciprocal homogeneous w */
|
||||
tdfx_color_t color; /* Diffuse color */
|
||||
GLuint pad;
|
||||
GLfloat tu0, tv0; /* Texture 0 coordinates */
|
||||
GLfloat tu1, tv1; /* Texture 1 coordinates */
|
||||
} tdfx_vertex;
|
||||
|
||||
typedef struct {
|
||||
GLfloat x, y, z; /* Coordinates in screen space */
|
||||
GLfloat rhw; /* Reciprocal homogeneous w */
|
||||
tdfx_color_t color; /* Diffuse color */
|
||||
GLuint pad;
|
||||
GLubyte color[4]; /* Diffuse color */
|
||||
GLfloat fog;
|
||||
GLfloat tu0, tv0; /* Texture 0 coordinates */
|
||||
GLfloat tu1, tv1; /* Texture 1 coordinates */
|
||||
GLfloat tq0, tq1; /* Texture 0/1 q coords */
|
||||
} tdfx_ptex_vertex;
|
||||
|
||||
typedef struct {
|
||||
GLfloat x, y, z; /* Coordinates in screen space */
|
||||
tdfx_color_t color; /* Diffuse color */
|
||||
} tdfx_tiny_vertex;
|
||||
|
||||
/* The size of this union is not of relevence:
|
||||
*/
|
||||
union tdfx_vertex_t {
|
||||
tdfx_vertex v;
|
||||
tdfx_tiny_vertex tv;
|
||||
tdfx_ptex_vertex pv;
|
||||
GLfloat f[16];
|
||||
GLuint ui[16];
|
||||
GLubyte ub4[16][4];
|
||||
};
|
||||
|
||||
typedef union tdfx_vertex_t tdfxVertex, *tdfxVertexPtr;
|
||||
unsigned char pspec[4]; /* B, G, R, A [0..255] */
|
||||
float psize; /* point size */
|
||||
long pad[16 - 14]; /* ensure 64b structure */
|
||||
} tdfxVertex, *tdfxVertexPtr;
|
||||
|
||||
|
||||
/* ================================================================
|
||||
|
@ -528,8 +506,10 @@ struct tdfx_color {
|
|||
/* Blending */
|
||||
GrAlphaBlendFnc_t BlendSrcRGB; /* Blend source RGB factor */
|
||||
GrAlphaBlendFnc_t BlendDstRGB; /* Blend destination RGB factor */
|
||||
GrAlphaBlendOp_t BlendEqRGB; /* Blend source RGB op */
|
||||
GrAlphaBlendFnc_t BlendSrcA; /* Blend source alpha factor */
|
||||
GrAlphaBlendFnc_t BlendDstA; /* Blend destination alpha factor */
|
||||
GrAlphaBlendOp_t BlendEqA; /* Blend source alpha op */
|
||||
|
||||
GrDitherMode_t Dither; /* Dither enable */
|
||||
};
|
||||
|
@ -601,6 +581,7 @@ struct tdfx_glide {
|
|||
FxBool HaveTextureBufferExt; /* TEXTUREBUFFER */
|
||||
FxBool HaveTexFmtExt; /* TEXFMT */
|
||||
FxBool HaveTexUMAExt; /* TEXUMA */
|
||||
FxBool HaveMirrorExt; /* MIRROR */
|
||||
FxBool HaveTexus2; /* Texus 2 - FXT1 */
|
||||
|
||||
/* Glide library function pointers */
|
||||
|
@ -838,6 +819,7 @@ struct tdfx_context {
|
|||
|
||||
/* Mirror of hardware state, Glide parameters
|
||||
*/
|
||||
GLuint tmu_source[TDFX_NUM_TMU];
|
||||
struct tdfx_texsource TexSource[TDFX_NUM_TMU];
|
||||
struct tdfx_texparams TexParams[TDFX_NUM_TMU];
|
||||
struct tdfx_texpalette TexPalette;
|
||||
|
@ -879,10 +861,9 @@ struct tdfx_context {
|
|||
|
||||
/* Variable-size Glide vertex formats
|
||||
*/
|
||||
GLuint vertexFormat; /* the current format */
|
||||
GLuint vertex_stride_shift;
|
||||
GLuint vertexFormat; /* the current format */
|
||||
void *layout[TDFX_NUM_LAYOUTS];
|
||||
GLubyte *verts; /* tdfxVertices, arbitarily packed */
|
||||
tdfxVertex *verts;
|
||||
|
||||
GLfloat hw_viewport[16];
|
||||
|
||||
|
@ -903,6 +884,7 @@ struct tdfx_context {
|
|||
int screen_height;
|
||||
|
||||
GLboolean haveTwoTMUs; /* True if we have 2 tmu's */
|
||||
GLboolean haveHwAlpha;
|
||||
GLboolean haveHwStencil;
|
||||
GLboolean haveHwStipple;
|
||||
|
||||
|
@ -1019,6 +1001,10 @@ extern int TDFX_DEBUG;
|
|||
#define DEBUG_VERBOSE_IOCTL 0x20
|
||||
#define DEBUG_VERBOSE_2D 0x40
|
||||
|
||||
/* conf */
|
||||
#define FX_COMPRESS_S3TC_AS_FXT1_HACK 1
|
||||
#define FX_TC_NAPALM 0
|
||||
|
||||
#endif /* GLX_DIRECT_RENDERING */
|
||||
|
||||
#endif /* __TDFX_CONTEXT_H__ */
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
#endif
|
||||
|
||||
|
||||
#define TDFX_DATE "20021125"
|
||||
#define TDFX_DATE "20040719"
|
||||
|
||||
|
||||
/* These are used in calls to FX_grColorMaskv() */
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_render.c,v 1.4 2002/02/22 21:45:03 dawes Exp $ */
|
||||
|
||||
/*
|
||||
* New fixes:
|
||||
* Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
|
||||
*
|
||||
* Original rewrite:
|
||||
* Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
|
||||
*
|
||||
|
@ -95,7 +98,7 @@ static void tdfxClear( GLcontext *ctx,
|
|||
fxMesa->Glide.grStencilMask(/*ctx->Stencil.WriteMask*/ 0xff);
|
||||
/* set stencil ref value = desired clear value */
|
||||
fxMesa->Glide.grStencilFunc(GR_CMP_ALWAYS,
|
||||
ctx->Stencil.Clear, 0xff);
|
||||
fxMesa->Stencil.Clear, 0xff);
|
||||
fxMesa->Glide.grStencilOp(GR_STENCILOP_REPLACE,
|
||||
GR_STENCILOP_REPLACE, GR_STENCILOP_REPLACE);
|
||||
fxMesa->Glide.grEnable(GR_STENCIL_MODE_EXT);
|
||||
|
@ -532,8 +535,8 @@ static void uploadTextureImages( tdfxContextPtr fxMesa )
|
|||
GLcontext *ctx = fxMesa->glCtx;
|
||||
int unit;
|
||||
for (unit = 0; unit < TDFX_NUM_TMU; unit++) {
|
||||
if (ctx->Texture.Unit[unit]._ReallyEnabled == TEXTURE_2D_BIT) {
|
||||
struct gl_texture_object *tObj = ctx->Texture.Unit[unit].Current2D;
|
||||
if (ctx->Texture.Unit[unit]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
|
||||
struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
|
||||
tdfxTexInfo *ti = TDFX_TEXTURE_DATA(tObj);
|
||||
if (ti && ti->reloadImages && ti->whichTMU != TDFX_TMU_NONE) {
|
||||
/*
|
||||
|
@ -653,10 +656,10 @@ void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa )
|
|||
if (fxMesa->Glide.grAlphaBlendFunctionExt) {
|
||||
fxMesa->Glide.grAlphaBlendFunctionExt( fxMesa->Color.BlendSrcRGB,
|
||||
fxMesa->Color.BlendDstRGB,
|
||||
GR_BLEND_OP_ADD,
|
||||
fxMesa->Color.BlendEqRGB,
|
||||
fxMesa->Color.BlendSrcA,
|
||||
fxMesa->Color.BlendDstA,
|
||||
GR_BLEND_OP_ADD );
|
||||
fxMesa->Color.BlendEqA );
|
||||
}
|
||||
else {
|
||||
fxMesa->Glide.grAlphaBlendFunction( fxMesa->Color.BlendSrcRGB,
|
||||
|
@ -727,10 +730,10 @@ void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa )
|
|||
fxMesa->dirty &= ~TDFX_UPLOAD_COLOR_MASK;
|
||||
}
|
||||
|
||||
/* if ( fxMesa->dirty & TDFX_UPLOAD_CONSTANT_COLOR ) { */
|
||||
/* grConstantColorValue( fxMesa->Color.MonoColor ); */
|
||||
/* fxMesa->dirty &= ~TDFX_UPLOAD_CONSTANT_COLOR; */
|
||||
/* } */
|
||||
if ( fxMesa->dirty & TDFX_UPLOAD_CONSTANT_COLOR ) {
|
||||
fxMesa->Glide.grConstantColorValue( fxMesa->Color.MonoColor );
|
||||
fxMesa->dirty &= ~TDFX_UPLOAD_CONSTANT_COLOR;
|
||||
}
|
||||
|
||||
if ( fxMesa->dirty & TDFX_UPLOAD_LINE ) {
|
||||
if (fxMesa->glCtx->Line.SmoothFlag && fxMesa->glCtx->Line.Width == 1.0)
|
||||
|
@ -759,6 +762,9 @@ void tdfxEmitHwStateLocked( tdfxContextPtr fxMesa )
|
|||
|
||||
if ( fxMesa->dirty & TDFX_UPLOAD_VERTEX_LAYOUT ) {
|
||||
fxMesa->Glide.grGlideSetVertexLayout( fxMesa->layout[fxMesa->vertexFormat] );
|
||||
/* [dborca] enable fogcoord */
|
||||
fxMesa->Glide.grVertexLayout(GR_PARAM_FOG_EXT, TDFX_FOG_OFFSET,
|
||||
fxMesa->Fog.Mode == GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT);
|
||||
fxMesa->dirty &= ~TDFX_UPLOAD_VERTEX_LAYOUT;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_state.c,v 1.7 2002/10/30 12:52:00 alanh Exp $ */
|
||||
|
||||
/*
|
||||
* New fixes:
|
||||
* Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
|
||||
*
|
||||
* Original rewrite:
|
||||
* Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
|
||||
*
|
||||
|
@ -68,40 +71,19 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx )
|
|||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
GrCmpFnc_t func;
|
||||
GrAlphaBlendFnc_t srcRGB, dstRGB, srcA, dstA;
|
||||
GrAlphaBlendOp_t eqRGB, eqA;
|
||||
GrAlpha_t ref = (GLint) (ctx->Color.AlphaRef * 255.0);
|
||||
|
||||
GLboolean isNapalm = TDFX_IS_NAPALM(fxMesa);
|
||||
GLboolean have32bpp = (ctx->Visual.greenBits == 8);
|
||||
GLboolean haveAlpha = fxMesa->haveHwAlpha;
|
||||
|
||||
if ( TDFX_DEBUG & DEBUG_VERBOSE_API ) {
|
||||
fprintf( stderr, "%s()\n", __FUNCTION__ );
|
||||
}
|
||||
|
||||
if ( ctx->Color.AlphaEnabled ) {
|
||||
switch ( ctx->Color.AlphaFunc ) {
|
||||
case GL_NEVER:
|
||||
func = GR_CMP_NEVER;
|
||||
break;
|
||||
case GL_LESS:
|
||||
func = GR_CMP_LESS;
|
||||
break;
|
||||
case GL_LEQUAL:
|
||||
func = GR_CMP_LEQUAL;
|
||||
break;
|
||||
case GL_EQUAL:
|
||||
func = GR_CMP_EQUAL;
|
||||
break;
|
||||
case GL_GEQUAL:
|
||||
func = GR_CMP_GEQUAL;
|
||||
break;
|
||||
case GL_GREATER:
|
||||
func = GR_CMP_GREATER;
|
||||
break;
|
||||
case GL_NOTEQUAL:
|
||||
func = GR_CMP_NOTEQUAL;
|
||||
break;
|
||||
case GL_ALWAYS:
|
||||
default:
|
||||
func = GR_CMP_ALWAYS;
|
||||
break;
|
||||
}
|
||||
func = ctx->Color.AlphaFunc - GL_NEVER + GR_CMP_NEVER;
|
||||
} else {
|
||||
func = GR_CMP_ALWAYS;
|
||||
}
|
||||
|
@ -128,14 +110,24 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx )
|
|||
srcRGB = GR_BLEND_ONE_MINUS_SRC_ALPHA;
|
||||
break;
|
||||
case GL_DST_ALPHA:
|
||||
srcRGB = GR_BLEND_DST_ALPHA;
|
||||
srcRGB = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/;
|
||||
break;
|
||||
case GL_ONE_MINUS_DST_ALPHA:
|
||||
srcRGB = GR_BLEND_ONE_MINUS_DST_ALPHA;
|
||||
srcRGB = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/;
|
||||
break;
|
||||
case GL_SRC_ALPHA_SATURATE:
|
||||
srcRGB = GR_BLEND_ALPHA_SATURATE;
|
||||
break;
|
||||
case GL_SRC_COLOR:
|
||||
if (isNapalm) {
|
||||
srcRGB = GR_BLEND_SAME_COLOR_EXT;
|
||||
break;
|
||||
}
|
||||
case GL_ONE_MINUS_SRC_COLOR:
|
||||
if (isNapalm) {
|
||||
srcRGB = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
srcRGB = GR_BLEND_ONE;
|
||||
}
|
||||
|
@ -147,23 +139,21 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx )
|
|||
case GL_ONE:
|
||||
srcA = GR_BLEND_ONE;
|
||||
break;
|
||||
case GL_SRC_COLOR:
|
||||
case GL_SRC_ALPHA:
|
||||
srcA = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ONE/*JJJ*/;
|
||||
break;
|
||||
case GL_ONE_MINUS_SRC_COLOR:
|
||||
case GL_ONE_MINUS_SRC_ALPHA:
|
||||
srcA = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ONE/*JJJ*/;
|
||||
break;
|
||||
case GL_DST_COLOR:
|
||||
srcA = GR_BLEND_DST_ALPHA; /* Napalm only */
|
||||
case GL_DST_ALPHA:
|
||||
srcA = (have32bpp && haveAlpha) ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/;
|
||||
break;
|
||||
case GL_ONE_MINUS_DST_COLOR:
|
||||
srcA = GR_BLEND_ONE_MINUS_DST_ALPHA; /* Napalm only */
|
||||
break;
|
||||
case GL_SRC_ALPHA:
|
||||
srcA = GR_BLEND_SRC_ALPHA; /* Napalm only */
|
||||
break;
|
||||
case GL_ONE_MINUS_SRC_ALPHA:
|
||||
srcA = GR_BLEND_ONE_MINUS_SRC_ALPHA; /* Napalm only */
|
||||
break;
|
||||
case GL_DST_ALPHA:
|
||||
srcA = GR_BLEND_DST_ALPHA; /* Napalm only */
|
||||
break;
|
||||
case GL_ONE_MINUS_DST_ALPHA:
|
||||
srcA = GR_BLEND_ONE_MINUS_DST_ALPHA; /* Napalm only */
|
||||
srcA = (have32bpp && haveAlpha) ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/;
|
||||
break;
|
||||
case GL_SRC_ALPHA_SATURATE:
|
||||
srcA = GR_BLEND_ONE;
|
||||
|
@ -192,11 +182,21 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx )
|
|||
dstRGB = GR_BLEND_ONE_MINUS_SRC_ALPHA;
|
||||
break;
|
||||
case GL_DST_ALPHA:
|
||||
dstRGB = GR_BLEND_DST_ALPHA;
|
||||
dstRGB = haveAlpha ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/;
|
||||
break;
|
||||
case GL_ONE_MINUS_DST_ALPHA:
|
||||
dstRGB = GR_BLEND_ONE_MINUS_DST_ALPHA;
|
||||
dstRGB = haveAlpha ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/;
|
||||
break;
|
||||
case GL_DST_COLOR:
|
||||
if (isNapalm) {
|
||||
srcRGB = GR_BLEND_SAME_COLOR_EXT;
|
||||
break;
|
||||
}
|
||||
case GL_ONE_MINUS_DST_COLOR:
|
||||
if (isNapalm) {
|
||||
srcRGB = GR_BLEND_ONE_MINUS_SAME_COLOR_EXT;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
dstRGB = GR_BLEND_ZERO;
|
||||
}
|
||||
|
@ -209,32 +209,58 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx )
|
|||
dstA = GR_BLEND_ONE;
|
||||
break;
|
||||
case GL_SRC_COLOR:
|
||||
dstA = GR_BLEND_SRC_ALPHA; /* Napalm only */
|
||||
case GL_SRC_ALPHA:
|
||||
dstA = have32bpp ? GR_BLEND_SRC_ALPHA : GR_BLEND_ZERO/*JJJ*/;
|
||||
break;
|
||||
case GL_ONE_MINUS_SRC_COLOR:
|
||||
dstA = GR_BLEND_ONE_MINUS_SRC_ALPHA; /* Napalm only */
|
||||
break;
|
||||
case GL_SRC_ALPHA:
|
||||
dstA = GR_BLEND_SRC_ALPHA; /* Napalm only */
|
||||
break;
|
||||
case GL_ONE_MINUS_SRC_ALPHA:
|
||||
dstA = GR_BLEND_ONE_MINUS_SRC_ALPHA; /* Napalm only */
|
||||
dstA = have32bpp ? GR_BLEND_ONE_MINUS_SRC_ALPHA : GR_BLEND_ZERO/*JJJ*/;
|
||||
break;
|
||||
case GL_DST_COLOR:
|
||||
case GL_DST_ALPHA:
|
||||
dstA = GR_BLEND_DST_ALPHA; /* Napalm only */
|
||||
dstA = have32bpp ? GR_BLEND_DST_ALPHA : GR_BLEND_ONE/*JJJ*/;
|
||||
break;
|
||||
case GL_ONE_MINUS_DST_COLOR:
|
||||
case GL_ONE_MINUS_DST_ALPHA:
|
||||
dstA = GR_BLEND_ONE_MINUS_DST_ALPHA; /* Napalm only */
|
||||
dstA = have32bpp ? GR_BLEND_ONE_MINUS_DST_ALPHA : GR_BLEND_ZERO/*JJJ*/;
|
||||
break;
|
||||
default:
|
||||
dstA = GR_BLEND_ZERO;
|
||||
}
|
||||
|
||||
switch ( ctx->Color.BlendEquationRGB ) {
|
||||
case GL_FUNC_SUBTRACT:
|
||||
eqRGB = GR_BLEND_OP_SUB;
|
||||
break;
|
||||
case GL_FUNC_REVERSE_SUBTRACT:
|
||||
eqRGB = GR_BLEND_OP_REVSUB;
|
||||
break;
|
||||
case GL_FUNC_ADD:
|
||||
default:
|
||||
eqRGB = GR_BLEND_OP_ADD;
|
||||
break;
|
||||
}
|
||||
|
||||
switch ( ctx->Color.BlendEquationA ) {
|
||||
case GL_FUNC_SUBTRACT:
|
||||
eqA = GR_BLEND_OP_SUB;
|
||||
break;
|
||||
case GL_FUNC_REVERSE_SUBTRACT:
|
||||
eqA = GR_BLEND_OP_REVSUB;
|
||||
break;
|
||||
case GL_FUNC_ADD:
|
||||
default:
|
||||
eqA = GR_BLEND_OP_ADD;
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
/* blend disabled */
|
||||
srcRGB = GR_BLEND_ONE;
|
||||
dstRGB = GR_BLEND_ZERO;
|
||||
eqRGB = GR_BLEND_OP_ADD;
|
||||
srcA = GR_BLEND_ONE;
|
||||
dstA = GR_BLEND_ZERO;
|
||||
eqA = GR_BLEND_OP_ADD;
|
||||
}
|
||||
|
||||
if ( fxMesa->Color.AlphaFunc != func ) {
|
||||
|
@ -248,13 +274,17 @@ static void tdfxUpdateAlphaMode( GLcontext *ctx )
|
|||
|
||||
if ( fxMesa->Color.BlendSrcRGB != srcRGB ||
|
||||
fxMesa->Color.BlendDstRGB != dstRGB ||
|
||||
fxMesa->Color.BlendEqRGB != eqRGB ||
|
||||
fxMesa->Color.BlendSrcA != srcA ||
|
||||
fxMesa->Color.BlendDstA != dstA )
|
||||
fxMesa->Color.BlendDstA != dstA ||
|
||||
fxMesa->Color.BlendEqA != eqA )
|
||||
{
|
||||
fxMesa->Color.BlendSrcRGB = srcRGB;
|
||||
fxMesa->Color.BlendDstRGB = dstRGB;
|
||||
fxMesa->Color.BlendEqRGB = eqRGB;
|
||||
fxMesa->Color.BlendSrcA = srcA;
|
||||
fxMesa->Color.BlendDstA = dstA;
|
||||
fxMesa->Color.BlendEqA = eqA;
|
||||
fxMesa->dirty |= TDFX_UPLOAD_BLEND_FUNC;
|
||||
}
|
||||
}
|
||||
|
@ -337,40 +367,8 @@ static void tdfxUpdateZMode( GLcontext *ctx )
|
|||
bias = (FxI32) (ctx->Polygon.OffsetUnits * TDFX_DEPTH_BIAS_SCALE);
|
||||
|
||||
if ( ctx->Depth.Test ) {
|
||||
switch ( ctx->Depth.Func ) {
|
||||
case GL_NEVER:
|
||||
func = GR_CMP_NEVER;
|
||||
break;
|
||||
case GL_LESS:
|
||||
func = GR_CMP_LESS;
|
||||
break;
|
||||
case GL_LEQUAL:
|
||||
func = GR_CMP_LEQUAL;
|
||||
break;
|
||||
case GL_EQUAL:
|
||||
func = GR_CMP_EQUAL;
|
||||
break;
|
||||
case GL_GEQUAL:
|
||||
func = GR_CMP_GEQUAL;
|
||||
break;
|
||||
case GL_GREATER:
|
||||
func = GR_CMP_GREATER;
|
||||
break;
|
||||
case GL_NOTEQUAL:
|
||||
func = GR_CMP_NOTEQUAL;
|
||||
break;
|
||||
case GL_ALWAYS:
|
||||
default:
|
||||
func = GR_CMP_ALWAYS;
|
||||
break;
|
||||
}
|
||||
|
||||
if ( ctx->Depth.Mask ) {
|
||||
mask = FXTRUE;
|
||||
}
|
||||
else {
|
||||
mask = FXFALSE;
|
||||
}
|
||||
func = ctx->Depth.Func - GL_NEVER + GR_CMP_NEVER;
|
||||
mask = ctx->Depth.Mask;
|
||||
}
|
||||
else {
|
||||
/* depth testing disabled */
|
||||
|
@ -378,8 +376,7 @@ static void tdfxUpdateZMode( GLcontext *ctx )
|
|||
mask = FXFALSE; /* zbuffer is not touched */
|
||||
}
|
||||
|
||||
fxMesa->Depth.Clear = (FxU32) (((1 << fxMesa->glCtx->Visual.depthBits) - 1)
|
||||
* ctx->Depth.Clear);
|
||||
fxMesa->Depth.Clear = (FxU32) (ctx->DepthMaxF * ctx->Depth.Clear);
|
||||
|
||||
if ( fxMesa->Depth.Bias != bias ) {
|
||||
fxMesa->Depth.Bias = bias;
|
||||
|
@ -464,7 +461,7 @@ static void tdfxUpdateStencil( GLcontext *ctx )
|
|||
|
||||
if (fxMesa->haveHwStencil) {
|
||||
if (ctx->Stencil.Enabled) {
|
||||
fxMesa->Stencil.Function = ctx->Stencil.Function[0] - GL_NEVER;
|
||||
fxMesa->Stencil.Function = ctx->Stencil.Function[0] - GL_NEVER + GR_CMP_NEVER;
|
||||
fxMesa->Stencil.RefValue = ctx->Stencil.Ref[0];
|
||||
fxMesa->Stencil.ValueMask = ctx->Stencil.ValueMask[0];
|
||||
fxMesa->Stencil.WriteMask = ctx->Stencil.WriteMask[0];
|
||||
|
@ -520,7 +517,11 @@ static void tdfxUpdateFogAttrib( GLcontext *ctx )
|
|||
}
|
||||
|
||||
if ( ctx->Fog.Enabled ) {
|
||||
mode = GR_FOG_WITH_TABLE_ON_Q;
|
||||
if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) {
|
||||
mode = GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT;
|
||||
} else {
|
||||
mode = GR_FOG_WITH_TABLE_ON_Q;
|
||||
}
|
||||
} else {
|
||||
mode = GR_FOG_DISABLE;
|
||||
}
|
||||
|
@ -532,6 +533,7 @@ static void tdfxUpdateFogAttrib( GLcontext *ctx )
|
|||
if ( fxMesa->Fog.Mode != mode ) {
|
||||
fxMesa->Fog.Mode = mode;
|
||||
fxMesa->dirty |= TDFX_UPLOAD_FOG_MODE;
|
||||
fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT;/*JJJ*/
|
||||
}
|
||||
if ( fxMesa->Fog.Color != color ) {
|
||||
fxMesa->Fog.Color = color;
|
||||
|
@ -569,6 +571,26 @@ static void tdfxDDFogfv( GLcontext *ctx, GLenum pname, const GLfloat *param )
|
|||
|
||||
FLUSH_BATCH( fxMesa );
|
||||
fxMesa->new_state |= TDFX_NEW_FOG;
|
||||
|
||||
switch (pname) {
|
||||
case GL_FOG_COORDINATE_SOURCE_EXT: {
|
||||
GLenum p = (GLenum)*param;
|
||||
if (p == GL_FOG_COORDINATE_EXT) {
|
||||
_swrast_allow_vertex_fog(ctx, GL_TRUE);
|
||||
_swrast_allow_pixel_fog(ctx, GL_FALSE);
|
||||
_tnl_allow_vertex_fog( ctx, GL_TRUE);
|
||||
_tnl_allow_pixel_fog( ctx, GL_FALSE);
|
||||
} else {
|
||||
_swrast_allow_vertex_fog(ctx, GL_FALSE);
|
||||
_swrast_allow_pixel_fog(ctx, GL_TRUE);
|
||||
_tnl_allow_vertex_fog( ctx, GL_FALSE);
|
||||
_tnl_allow_pixel_fog( ctx, GL_TRUE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -912,7 +934,7 @@ static void tdfxDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
|
|||
fxMesa->new_state |= TDFX_NEW_ALPHA;
|
||||
FALLBACK( fxMesa, TDFX_FALLBACK_LOGICOP,
|
||||
(ctx->Color.ColorLogicOpEnabled &&
|
||||
ctx->Color.LogicOp != GL_COPY));
|
||||
ctx->Color.LogicOp != GL_COPY)/*JJJ - more blending*/);
|
||||
break;
|
||||
|
||||
case GL_CULL_FACE:
|
||||
|
@ -974,15 +996,16 @@ static void tdfxDDEnable( GLcontext *ctx, GLenum cap, GLboolean state )
|
|||
case GL_STENCIL_TEST:
|
||||
FLUSH_BATCH( fxMesa );
|
||||
FALLBACK( fxMesa, TDFX_FALLBACK_STENCIL, state && !fxMesa->haveHwStencil);
|
||||
fxMesa->new_state |= TDFX_NEW_STENCIL;
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_1D:
|
||||
case GL_TEXTURE_3D:
|
||||
FLUSH_BATCH( fxMesa );
|
||||
FALLBACK( fxMesa, TDFX_FALLBACK_TEXTURE_1D_3D, state); /* wrong */
|
||||
FALLBACK( fxMesa, TDFX_FALLBACK_TEXTURE_MAP, state); /* wrong */
|
||||
fxMesa->new_state |= TDFX_NEW_TEXTURE;
|
||||
break;
|
||||
|
||||
case GL_TEXTURE_1D:
|
||||
case GL_TEXTURE_2D:
|
||||
FLUSH_BATCH( fxMesa );
|
||||
fxMesa->new_state |= TDFX_NEW_TEXTURE;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -852,8 +852,8 @@ tdfxTMMoveInTM_NoLock( tdfxContextPtr fxMesa, struct gl_texture_object *tObj,
|
|||
if (ti->tm[TDFX_TMU0])
|
||||
fxMesa->stats.memTexUpload += texmemsize;
|
||||
|
||||
texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH,
|
||||
&(ti->info));
|
||||
/*texmemsize = fxMesa->Glide.grTexTextureMemRequired(GR_MIPMAPLEVELMASK_BOTH,
|
||||
&(ti->info));*/
|
||||
ti->tm[TDFX_TMU1] = AllocTexMem(fxMesa, TDFX_TMU1, texmemsize);
|
||||
break;
|
||||
default:
|
||||
|
|
|
@ -26,6 +26,9 @@
|
|||
/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_texstate.c,v 1.2 2002/02/22 21:45:04 dawes Exp $ */
|
||||
|
||||
/*
|
||||
* New fixes:
|
||||
* Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
|
||||
*
|
||||
* Original rewrite:
|
||||
* Gareth Hughes <gareth@valinux.com>, 29 Sep - 1 Oct 2000
|
||||
*
|
||||
|
@ -899,11 +902,10 @@ SetupSingleTexEnvVoodoo3(GLcontext *ctx, int unit,
|
|||
}
|
||||
else if (baseFormat == GL_INTENSITY) {
|
||||
/* Av = Af * (1 - It) + Ac * It */
|
||||
/* XXX this is wrong */
|
||||
alphaComb.Function = GR_COMBINE_FUNCTION_LOCAL;
|
||||
alphaComb.Factor = GR_COMBINE_FACTOR_NONE;
|
||||
alphaComb.Function = GR_COMBINE_FUNCTION_BLEND;
|
||||
alphaComb.Factor = GR_COMBINE_FACTOR_TEXTURE_ALPHA;
|
||||
alphaComb.Local = locala;
|
||||
alphaComb.Other = GR_COMBINE_OTHER_NONE;
|
||||
alphaComb.Other = GR_COMBINE_OTHER_CONSTANT;
|
||||
alphaComb.Invert = FXFALSE;
|
||||
}
|
||||
else {
|
||||
|
@ -922,13 +924,18 @@ SetupSingleTexEnvVoodoo3(GLcontext *ctx, int unit,
|
|||
colorComb.Invert = FXFALSE;
|
||||
}
|
||||
else {
|
||||
colorComb.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
|
||||
colorComb.Factor = GR_COMBINE_FACTOR_ONE;
|
||||
colorComb.Function = GR_COMBINE_FUNCTION_BLEND;
|
||||
colorComb.Factor = GR_COMBINE_FACTOR_TEXTURE_RGB;
|
||||
colorComb.Local = localc;
|
||||
colorComb.Other = GR_COMBINE_OTHER_TEXTURE;
|
||||
colorComb.Other = GR_COMBINE_OTHER_CONSTANT;
|
||||
colorComb.Invert = FXTRUE;
|
||||
}
|
||||
/* XXX return GL_FALSE for modes we don't support */
|
||||
fxMesa->Color.MonoColor = PACK_RGBA32(
|
||||
ctx->Texture.Unit[unit].EnvColor[0] * 255.0f,
|
||||
ctx->Texture.Unit[unit].EnvColor[1] * 255.0f,
|
||||
ctx->Texture.Unit[unit].EnvColor[2] * 255.0f,
|
||||
ctx->Texture.Unit[unit].EnvColor[3] * 255.0f);
|
||||
fxMesa->dirty |= TDFX_UPLOAD_CONSTANT_COLOR;
|
||||
break;
|
||||
|
||||
case GL_REPLACE:
|
||||
|
@ -1051,15 +1058,8 @@ SetupDoubleTexEnvVoodoo3(GLcontext *ctx, int tmu0,
|
|||
if (envMode0 == GL_MODULATE && envMode1 == GL_MODULATE) {
|
||||
GLboolean isalpha[TDFX_NUM_TMU];
|
||||
|
||||
if (baseFormat0 == GL_ALPHA)
|
||||
isalpha[tmu0] = GL_TRUE;
|
||||
else
|
||||
isalpha[tmu0] = GL_FALSE;
|
||||
|
||||
if (baseFormat1 == GL_ALPHA)
|
||||
isalpha[tmu1] = GL_TRUE;
|
||||
else
|
||||
isalpha[tmu1] = GL_FALSE;
|
||||
isalpha[tmu0] = (baseFormat0 == GL_ALPHA);
|
||||
isalpha[tmu1] = (baseFormat1 == GL_ALPHA);
|
||||
|
||||
if (isalpha[TDFX_TMU1]) {
|
||||
fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
|
||||
|
@ -1105,7 +1105,7 @@ SetupDoubleTexEnvVoodoo3(GLcontext *ctx, int tmu0,
|
|||
fxMesa->AlphaCombine.Invert = FXFALSE;
|
||||
}
|
||||
else if (envMode0 == GL_REPLACE && envMode1 == GL_BLEND) { /* Quake */
|
||||
if (tmu1 == TDFX_TMU1) {
|
||||
if (tmu0 == TDFX_TMU1) {
|
||||
fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
|
||||
fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
|
||||
fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
|
||||
|
@ -1198,14 +1198,9 @@ SetupDoubleTexEnvVoodoo3(GLcontext *ctx, int tmu0,
|
|||
else if (envMode0 == GL_MODULATE && envMode1 == GL_ADD) {
|
||||
/* Quake 3 sky */
|
||||
GLboolean isalpha[TDFX_NUM_TMU];
|
||||
if (baseFormat0 == GL_ALPHA)
|
||||
isalpha[tmu0] = GL_TRUE;
|
||||
else
|
||||
isalpha[tmu0] = GL_FALSE;
|
||||
if (baseFormat1 == GL_ALPHA)
|
||||
isalpha[tmu1] = GL_TRUE;
|
||||
else
|
||||
isalpha[tmu1] = GL_FALSE;
|
||||
|
||||
isalpha[tmu0] = (baseFormat0 == GL_ALPHA);
|
||||
isalpha[tmu1] = (baseFormat1 == GL_ALPHA);
|
||||
|
||||
if (isalpha[TDFX_TMU1]) {
|
||||
fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
|
||||
|
@ -1250,8 +1245,102 @@ SetupDoubleTexEnvVoodoo3(GLcontext *ctx, int tmu0,
|
|||
fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE;
|
||||
fxMesa->AlphaCombine.Invert = FXFALSE;
|
||||
}
|
||||
else if (envMode0 == GL_REPLACE && envMode1 == GL_ADD) {
|
||||
/* Vulpine sky */
|
||||
GLboolean isalpha[TDFX_NUM_TMU];
|
||||
|
||||
isalpha[tmu0] = (baseFormat0 == GL_ALPHA);
|
||||
isalpha[tmu1] = (baseFormat1 == GL_ALPHA);
|
||||
|
||||
if (isalpha[TDFX_TMU1]) {
|
||||
fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
|
||||
fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
|
||||
fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
|
||||
fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
|
||||
fxMesa->TexCombine[1].InvertRGB = FXTRUE;
|
||||
fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
|
||||
} else {
|
||||
fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
|
||||
fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
|
||||
fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
|
||||
fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
|
||||
fxMesa->TexCombine[1].InvertRGB = FXFALSE;
|
||||
fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
|
||||
}
|
||||
|
||||
if (isalpha[TDFX_TMU0]) {
|
||||
fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER;
|
||||
fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE;
|
||||
fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
|
||||
fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE;
|
||||
fxMesa->TexCombine[0].InvertRGB = FXFALSE;
|
||||
fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
|
||||
} else {
|
||||
fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
|
||||
fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_ONE;
|
||||
fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_SCALE_OTHER_ADD_LOCAL;
|
||||
fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_ONE;
|
||||
fxMesa->TexCombine[0].InvertRGB = FXFALSE;
|
||||
fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
|
||||
}
|
||||
|
||||
fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
|
||||
fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE;
|
||||
fxMesa->ColorCombine.Local = localc;
|
||||
fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE;
|
||||
fxMesa->ColorCombine.Invert = FXFALSE;
|
||||
fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
|
||||
fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_ONE;
|
||||
fxMesa->AlphaCombine.Local = locala;
|
||||
fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE;
|
||||
fxMesa->AlphaCombine.Invert = FXFALSE;
|
||||
}
|
||||
else if (envMode1 == GL_REPLACE) {
|
||||
/* Homeworld2 */
|
||||
|
||||
fxMesa->TexCombine[1].FunctionRGB = GR_COMBINE_FUNCTION_ZERO;
|
||||
fxMesa->TexCombine[1].FactorRGB = GR_COMBINE_FACTOR_NONE;
|
||||
fxMesa->TexCombine[1].FunctionAlpha = GR_COMBINE_FUNCTION_ZERO;
|
||||
fxMesa->TexCombine[1].FactorAlpha = GR_COMBINE_FACTOR_NONE;
|
||||
fxMesa->TexCombine[1].InvertRGB = FXFALSE;
|
||||
fxMesa->TexCombine[1].InvertAlpha = FXFALSE;
|
||||
|
||||
fxMesa->TexCombine[0].FunctionRGB = GR_COMBINE_FUNCTION_LOCAL;
|
||||
fxMesa->TexCombine[0].FactorRGB = GR_COMBINE_FACTOR_NONE;
|
||||
fxMesa->TexCombine[0].FunctionAlpha = GR_COMBINE_FUNCTION_LOCAL;
|
||||
fxMesa->TexCombine[0].FactorAlpha = GR_COMBINE_FACTOR_NONE;
|
||||
fxMesa->TexCombine[0].InvertRGB = FXFALSE;
|
||||
fxMesa->TexCombine[0].InvertAlpha = FXFALSE;
|
||||
|
||||
if ((baseFormat0 == GL_RGB) && (baseFormat0 == GL_LUMINANCE)) {
|
||||
fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
|
||||
fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_NONE;
|
||||
fxMesa->AlphaCombine.Local = locala;
|
||||
fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_NONE;
|
||||
fxMesa->AlphaCombine.Invert = FXFALSE;
|
||||
} else {
|
||||
fxMesa->AlphaCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
|
||||
fxMesa->AlphaCombine.Factor = GR_COMBINE_FACTOR_ONE;
|
||||
fxMesa->AlphaCombine.Local = locala;
|
||||
fxMesa->AlphaCombine.Other = GR_COMBINE_OTHER_TEXTURE;
|
||||
fxMesa->AlphaCombine.Invert = FXFALSE;
|
||||
}
|
||||
if (baseFormat0 == GL_ALPHA) {
|
||||
fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_LOCAL;
|
||||
fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_NONE;
|
||||
fxMesa->ColorCombine.Local = localc;
|
||||
fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_NONE;
|
||||
fxMesa->ColorCombine.Invert = FXFALSE;
|
||||
} else {
|
||||
fxMesa->ColorCombine.Function = GR_COMBINE_FUNCTION_SCALE_OTHER;
|
||||
fxMesa->ColorCombine.Factor = GR_COMBINE_FACTOR_ONE;
|
||||
fxMesa->ColorCombine.Local = localc;
|
||||
fxMesa->ColorCombine.Other = GR_COMBINE_OTHER_TEXTURE;
|
||||
fxMesa->ColorCombine.Invert = FXFALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/*_mesa_problem(ctx, "%s: Unexpected dual texture mode encountered", __FUNCTION__);*/
|
||||
_mesa_problem(ctx, "%s: Unexpected dual texture mode encountered", __FUNCTION__);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
@ -1329,7 +1418,7 @@ setupSingleTMU(tdfxContextPtr fxMesa, struct gl_texture_object *tObj)
|
|||
GLint u;
|
||||
|
||||
if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
|
||||
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
|
||||
fxMesa->TexPalette.Type = ti->paltype;
|
||||
fxMesa->TexPalette.Data = &(ti->palette);
|
||||
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
|
||||
}
|
||||
|
@ -1367,7 +1456,7 @@ setupSingleTMU(tdfxContextPtr fxMesa, struct gl_texture_object *tObj)
|
|||
}
|
||||
|
||||
if (ti->info.format == GR_TEXFMT_P_8 && !ctx->Texture.SharedPalette) {
|
||||
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
|
||||
fxMesa->TexPalette.Type = ti->paltype;
|
||||
fxMesa->TexPalette.Data = &(ti->palette);
|
||||
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
|
||||
}
|
||||
|
@ -1482,8 +1571,8 @@ selectSingleTMUSrc(tdfxContextPtr fxMesa, GLint tmu, FxBool LODblend)
|
|||
static void print_state(tdfxContextPtr fxMesa)
|
||||
{
|
||||
GLcontext *ctx = fxMesa->glCtx;
|
||||
struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].Current2D;
|
||||
struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].Current2D;
|
||||
struct gl_texture_object *tObj0 = ctx->Texture.Unit[0]._Current;
|
||||
struct gl_texture_object *tObj1 = ctx->Texture.Unit[1]._Current;
|
||||
GLenum base0 = tObj0->Image[0][tObj0->BaseLevel] ? tObj0->Image[0][tObj0->BaseLevel]->Format : 99;
|
||||
GLenum base1 = tObj1->Image[0][tObj1->BaseLevel] ? tObj1->Image[0][tObj1->BaseLevel]->Format : 99;
|
||||
|
||||
|
@ -1517,7 +1606,7 @@ static void setupTextureSingleTMU(GLcontext * ctx, GLuint unit)
|
|||
int tmu;
|
||||
GLenum envMode, baseFormat;
|
||||
|
||||
tObj = ctx->Texture.Unit[unit].Current2D;
|
||||
tObj = ctx->Texture.Unit[unit]._Current;
|
||||
if (tObj->Image[0][tObj->BaseLevel]->Border > 0) {
|
||||
FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_TRUE);
|
||||
return;
|
||||
|
@ -1544,10 +1633,10 @@ static void setupTextureSingleTMU(GLcontext * ctx, GLuint unit)
|
|||
|
||||
if (TDFX_IS_NAPALM(fxMesa)) {
|
||||
/* see if we really need to update the unit */
|
||||
if (fxMesa->TexState.Enabled[unit] != ctx->Texture.Unit[unit]._ReallyEnabled ||
|
||||
if (1/*fxMesa->TexState.Enabled[unit] != ctx->Texture.Unit[unit]._ReallyEnabled ||
|
||||
envMode != fxMesa->TexState.EnvMode[0] ||
|
||||
envMode == GL_COMBINE_EXT ||
|
||||
baseFormat != fxMesa->TexState.TexFormat[0]) {
|
||||
baseFormat != fxMesa->TexState.TexFormat[0]*/) {
|
||||
struct tdfx_texcombine_ext *otherEnv;
|
||||
if (!SetupTexEnvNapalm(ctx, GL_TRUE,
|
||||
&ctx->Texture.Unit[unit], baseFormat,
|
||||
|
@ -1578,30 +1667,34 @@ static void setupTextureSingleTMU(GLcontext * ctx, GLuint unit)
|
|||
otherEnv->Alpha.Shift = 0;
|
||||
otherEnv->Alpha.Invert = FXFALSE;
|
||||
|
||||
#if 0/*JJJ*/
|
||||
fxMesa->TexState.Enabled[unit] = ctx->Texture.Unit[unit]._ReallyEnabled;
|
||||
fxMesa->TexState.EnvMode[0] = envMode;
|
||||
fxMesa->TexState.TexFormat[0] = baseFormat;
|
||||
fxMesa->TexState.EnvMode[1] = 0;
|
||||
fxMesa->TexState.TexFormat[1] = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* Voodoo3 */
|
||||
|
||||
/* see if we really need to update the unit */
|
||||
if (fxMesa->TexState.Enabled[unit] != ctx->Texture.Unit[unit]._ReallyEnabled ||
|
||||
if (1/*fxMesa->TexState.Enabled[unit] != ctx->Texture.Unit[unit]._ReallyEnabled ||
|
||||
envMode != fxMesa->TexState.EnvMode[0] ||
|
||||
envMode == GL_COMBINE_EXT ||
|
||||
baseFormat != fxMesa->TexState.TexFormat[0]) {
|
||||
if (!SetupSingleTexEnvVoodoo3(ctx, tmu, envMode, baseFormat)) {
|
||||
baseFormat != fxMesa->TexState.TexFormat[0]*/) {
|
||||
if (!SetupSingleTexEnvVoodoo3(ctx, unit, envMode, baseFormat)) {
|
||||
/* software fallback */
|
||||
FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE);
|
||||
}
|
||||
#if 0/*JJJ*/
|
||||
fxMesa->TexState.Enabled[unit] = ctx->Texture.Unit[unit]._ReallyEnabled;
|
||||
fxMesa->TexState.EnvMode[0] = envMode;
|
||||
fxMesa->TexState.TexFormat[0] = baseFormat;
|
||||
fxMesa->TexState.EnvMode[1] = 0;
|
||||
fxMesa->TexState.TexFormat[1] = 0;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1731,12 +1824,12 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
|
|||
|
||||
if (!ctx->Texture.SharedPalette) {
|
||||
if (ti0->info.format == GR_TEXFMT_P_8) {
|
||||
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
|
||||
fxMesa->TexPalette.Type = ti0->paltype;
|
||||
fxMesa->TexPalette.Data = &(ti0->palette);
|
||||
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
|
||||
}
|
||||
else if (ti1->info.format == GR_TEXFMT_P_8) {
|
||||
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
|
||||
fxMesa->TexPalette.Type = ti1->paltype;
|
||||
fxMesa->TexPalette.Data = &(ti1->palette);
|
||||
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
|
||||
}
|
||||
|
@ -1823,8 +1916,8 @@ setupDoubleTMU(tdfxContextPtr fxMesa,
|
|||
static void setupTextureDoubleTMU(GLcontext * ctx)
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].Current2D;
|
||||
struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].Current2D;
|
||||
struct gl_texture_object *tObj0 = ctx->Texture.Unit[1]._Current;
|
||||
struct gl_texture_object *tObj1 = ctx->Texture.Unit[0]._Current;
|
||||
tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0);
|
||||
tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1);
|
||||
struct gl_texture_image *baseImage0 = tObj0->Image[0][tObj0->BaseLevel];
|
||||
|
@ -1851,29 +1944,33 @@ static void setupTextureDoubleTMU(GLcontext * ctx)
|
|||
GLboolean hw1 = GL_TRUE, hw2 = GL_TRUE;
|
||||
|
||||
/* check if we really need to update glide unit 1 */
|
||||
if (fxMesa->TexState.Enabled[0] != ctx->Texture.Unit[0]._ReallyEnabled ||
|
||||
if (1/*fxMesa->TexState.Enabled[0] != ctx->Texture.Unit[0]._ReallyEnabled ||
|
||||
envMode0 != fxMesa->TexState.EnvMode[1] ||
|
||||
envMode0 == GL_COMBINE_EXT ||
|
||||
baseImage0->Format != fxMesa->TexState.TexFormat[1] ||
|
||||
(fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)) {
|
||||
(fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)*/) {
|
||||
hw1 = SetupTexEnvNapalm(ctx, GL_TRUE, &ctx->Texture.Unit[0],
|
||||
baseImage0->Format, &fxMesa->TexCombineExt[1]);
|
||||
#if 0/*JJJ*/
|
||||
fxMesa->TexState.EnvMode[1] = envMode0;
|
||||
fxMesa->TexState.TexFormat[1] = baseImage0->Format;
|
||||
fxMesa->TexState.Enabled[0] = ctx->Texture.Unit[0]._ReallyEnabled;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* check if we really need to update glide unit 0 */
|
||||
if (fxMesa->TexState.Enabled[1] != ctx->Texture.Unit[1]._ReallyEnabled ||
|
||||
if (1/*fxMesa->TexState.Enabled[1] != ctx->Texture.Unit[1]._ReallyEnabled ||
|
||||
envMode1 != fxMesa->TexState.EnvMode[0] ||
|
||||
envMode1 == GL_COMBINE_EXT ||
|
||||
baseImage1->Format != fxMesa->TexState.TexFormat[0] ||
|
||||
(fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)) {
|
||||
(fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)*/) {
|
||||
hw2 = SetupTexEnvNapalm(ctx, GL_FALSE, &ctx->Texture.Unit[1],
|
||||
baseImage1->Format, &fxMesa->TexCombineExt[0]);
|
||||
#if 0/*JJJ*/
|
||||
fxMesa->TexState.EnvMode[0] = envMode1;
|
||||
fxMesa->TexState.TexFormat[0] = baseImage1->Format;
|
||||
fxMesa->TexState.Enabled[1] = ctx->Texture.Unit[1]._ReallyEnabled;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -1889,7 +1986,7 @@ static void setupTextureDoubleTMU(GLcontext * ctx)
|
|||
unit0 = 0;
|
||||
unit1 = 1 - unit0;
|
||||
|
||||
if (fxMesa->TexState.Enabled[0] != ctx->Texture.Unit[0]._ReallyEnabled ||
|
||||
if (1/*fxMesa->TexState.Enabled[0] != ctx->Texture.Unit[0]._ReallyEnabled ||
|
||||
fxMesa->TexState.Enabled[1] != ctx->Texture.Unit[1]._ReallyEnabled ||
|
||||
envMode0 != fxMesa->TexState.EnvMode[unit0] ||
|
||||
envMode0 == GL_COMBINE_EXT ||
|
||||
|
@ -1897,7 +1994,7 @@ static void setupTextureDoubleTMU(GLcontext * ctx)
|
|||
envMode1 == GL_COMBINE_EXT ||
|
||||
baseImage0->Format != fxMesa->TexState.TexFormat[unit0] ||
|
||||
baseImage1->Format != fxMesa->TexState.TexFormat[unit1] ||
|
||||
(fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)) {
|
||||
(fxMesa->Fallback & TDFX_FALLBACK_TEXTURE_ENV)*/) {
|
||||
|
||||
if (!SetupDoubleTexEnvVoodoo3(ctx, unit0,
|
||||
ctx->Texture.Unit[0].EnvMode, baseImage0->Format,
|
||||
|
@ -1905,12 +2002,14 @@ static void setupTextureDoubleTMU(GLcontext * ctx)
|
|||
FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_TRUE);
|
||||
}
|
||||
|
||||
#if 0/*JJJ*/
|
||||
fxMesa->TexState.EnvMode[unit0] = envMode0;
|
||||
fxMesa->TexState.TexFormat[unit0] = baseImage0->Format;
|
||||
fxMesa->TexState.EnvMode[unit1] = envMode1;
|
||||
fxMesa->TexState.TexFormat[unit1] = baseImage1->Format;
|
||||
fxMesa->TexState.Enabled[0] = ctx->Texture.Unit[0]._ReallyEnabled;
|
||||
fxMesa->TexState.Enabled[1] = ctx->Texture.Unit[1]._ReallyEnabled;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1924,20 +2023,20 @@ tdfxUpdateTextureState( GLcontext *ctx )
|
|||
FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_BORDER, GL_FALSE);
|
||||
FALLBACK(fxMesa, TDFX_FALLBACK_TEXTURE_ENV, GL_FALSE);
|
||||
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT &&
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) &&
|
||||
ctx->Texture.Unit[1]._ReallyEnabled == 0) {
|
||||
LOCK_HARDWARE( fxMesa ); /* XXX remove locking eventually */
|
||||
setupTextureSingleTMU(ctx, 0);
|
||||
UNLOCK_HARDWARE( fxMesa );
|
||||
}
|
||||
else if (ctx->Texture.Unit[0]._ReallyEnabled == 0 &&
|
||||
ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT) {
|
||||
ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
|
||||
LOCK_HARDWARE( fxMesa );
|
||||
setupTextureSingleTMU(ctx, 1);
|
||||
UNLOCK_HARDWARE( fxMesa );
|
||||
}
|
||||
else if (ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT &&
|
||||
ctx->Texture.Unit[1]._ReallyEnabled == TEXTURE_2D_BIT) {
|
||||
else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) &&
|
||||
ctx->Texture.Unit[1]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
|
||||
LOCK_HARDWARE( fxMesa );
|
||||
setupTextureDoubleTMU(ctx);
|
||||
UNLOCK_HARDWARE( fxMesa );
|
||||
|
@ -2009,8 +2108,8 @@ void
|
|||
tdfxUpdateTextureBinding( GLcontext *ctx )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
struct gl_texture_object *tObj0 = ctx->Texture.Unit[0].Current2D;
|
||||
struct gl_texture_object *tObj1 = ctx->Texture.Unit[1].Current2D;
|
||||
struct gl_texture_object *tObj0 = ctx->Texture.Unit[0]._Current;
|
||||
struct gl_texture_object *tObj1 = ctx->Texture.Unit[1]._Current;
|
||||
tdfxTexInfo *ti0 = TDFX_TEXTURE_DATA(tObj0);
|
||||
tdfxTexInfo *ti1 = TDFX_TEXTURE_DATA(tObj1);
|
||||
|
||||
|
@ -2021,12 +2120,12 @@ tdfxUpdateTextureBinding( GLcontext *ctx )
|
|||
fxMesa->sScale0 = ti0->sScale;
|
||||
fxMesa->tScale0 = ti0->tScale;
|
||||
if (ti0->info.format == GR_TEXFMT_P_8) {
|
||||
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
|
||||
fxMesa->TexPalette.Type = ti0->paltype;
|
||||
fxMesa->TexPalette.Data = &(ti0->palette);
|
||||
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
|
||||
}
|
||||
else if (ti1 && ti1->info.format == GR_TEXFMT_P_8) {
|
||||
fxMesa->TexPalette.Type = GR_TEXTABLE_PALETTE_6666_EXT;
|
||||
fxMesa->TexPalette.Type = ti1->paltype;
|
||||
fxMesa->TexPalette.Data = &(ti1->palette);
|
||||
fxMesa->dirty |= TDFX_UPLOAD_TEXTURE_PALETTE;
|
||||
}
|
||||
|
@ -2036,7 +2135,7 @@ tdfxUpdateTextureBinding( GLcontext *ctx )
|
|||
fxMesa->tScale1 = ti1->tScale;
|
||||
}
|
||||
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT &&
|
||||
if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) &&
|
||||
ctx->Texture.Unit[0]._ReallyEnabled == 0) {
|
||||
/* Only unit 0 2D enabled */
|
||||
if (shared->umaTexMemory) {
|
||||
|
@ -2070,7 +2169,7 @@ tdfxUpdateTextureBinding( GLcontext *ctx )
|
|||
}
|
||||
}
|
||||
else if (ctx->Texture.Unit[0]._ReallyEnabled == 0 &&
|
||||
ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT) {
|
||||
ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
|
||||
/* Only unit 1 2D enabled */
|
||||
if (shared->umaTexMemory) {
|
||||
fxMesa->TexSource[0].StartAddress = ti1->tm[0]->startAddr;
|
||||
|
@ -2078,8 +2177,8 @@ tdfxUpdateTextureBinding( GLcontext *ctx )
|
|||
fxMesa->TexSource[0].Info = &(ti1->info);
|
||||
}
|
||||
}
|
||||
else if (ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT &&
|
||||
ctx->Texture.Unit[0]._ReallyEnabled == TEXTURE_2D_BIT) {
|
||||
else if (ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT) &&
|
||||
ctx->Texture.Unit[0]._ReallyEnabled & (TEXTURE_1D_BIT|TEXTURE_2D_BIT)) {
|
||||
/* Both 2D enabled */
|
||||
if (shared->umaTexMemory) {
|
||||
const FxU32 tmu0 = 0, tmu1 = 1;
|
||||
|
|
|
@ -25,7 +25,10 @@
|
|||
*/
|
||||
/* $XFree86: xc/lib/GL/mesa/src/drv/tdfx/tdfx_tris.c,v 1.4 2002/10/30 12:52:01 alanh Exp $ */
|
||||
|
||||
/* Authors:
|
||||
/* New fixes:
|
||||
* Daniel Borca <dborca@users.sourceforge.net>, 19 Jul 2004
|
||||
*
|
||||
* Authors:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
*/
|
||||
|
||||
|
@ -68,8 +71,14 @@ do { \
|
|||
fxMesa->draw_triangle( fxMesa, a, b, d ); \
|
||||
fxMesa->draw_triangle( fxMesa, b, c, d ); \
|
||||
} else { \
|
||||
fxMesa->Glide.grDrawTriangle( a, b, d ); \
|
||||
fxMesa->Glide.grDrawTriangle( b, c, d ); \
|
||||
tdfxVertex *_v_[4]; \
|
||||
_v_[0] = d; \
|
||||
_v_[1] = a; \
|
||||
_v_[2] = b; \
|
||||
_v_[3] = c; \
|
||||
fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);\
|
||||
/*fxMesa->Glide.grDrawTriangle( a, b, d );*/\
|
||||
/*fxMesa->Glide.grDrawTriangle( b, c, d );*/\
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -78,15 +87,15 @@ do { \
|
|||
if (DO_FALLBACK) \
|
||||
fxMesa->draw_line( fxMesa, v0, v1 ); \
|
||||
else { \
|
||||
v0->v.x += LINE_X_OFFSET - TRI_X_OFFSET; \
|
||||
v0->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
|
||||
v1->v.x += LINE_X_OFFSET - TRI_X_OFFSET; \
|
||||
v1->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET; \
|
||||
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; \
|
||||
fxMesa->Glide.grDrawLine( v0, v1 ); \
|
||||
v0->v.x -= LINE_X_OFFSET - TRI_X_OFFSET; \
|
||||
v0->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
|
||||
v1->v.x -= LINE_X_OFFSET - TRI_X_OFFSET; \
|
||||
v1->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET; \
|
||||
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)
|
||||
|
||||
|
@ -95,11 +104,11 @@ do { \
|
|||
if (DO_FALLBACK) \
|
||||
fxMesa->draw_point( fxMesa, v0 ); \
|
||||
else { \
|
||||
v0->v.x += PNT_X_OFFSET - TRI_X_OFFSET; \
|
||||
v0->v.y += PNT_Y_OFFSET - TRI_Y_OFFSET; \
|
||||
v0->x += PNT_X_OFFSET - TRI_X_OFFSET; \
|
||||
v0->y += PNT_Y_OFFSET - TRI_Y_OFFSET; \
|
||||
fxMesa->Glide.grDrawPoint( v0 ); \
|
||||
v0->v.x -= PNT_X_OFFSET - TRI_X_OFFSET; \
|
||||
v0->v.y -= PNT_Y_OFFSET - TRI_Y_OFFSET; \
|
||||
v0->x -= PNT_X_OFFSET - TRI_X_OFFSET; \
|
||||
v0->y -= PNT_Y_OFFSET - TRI_Y_OFFSET; \
|
||||
} \
|
||||
} while (0)
|
||||
|
||||
|
@ -120,49 +129,45 @@ tdfx_translate_vertex( GLcontext *ctx, const tdfxVertex *src, SWvertex *dst)
|
|||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
|
||||
if (fxMesa->vertexFormat == TDFX_LAYOUT_TINY) {
|
||||
dst->win[0] = src->tv.x - fxMesa->x_offset;
|
||||
dst->win[1] = src->tv.y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset);
|
||||
dst->win[2] = src->tv.z;
|
||||
dst->win[0] = src->x - fxMesa->x_offset;
|
||||
dst->win[1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset);
|
||||
dst->win[2] = src->z;
|
||||
dst->win[3] = 1.0;
|
||||
|
||||
dst->color[0] = src->tv.color.red;
|
||||
dst->color[1] = src->tv.color.green;
|
||||
dst->color[2] = src->tv.color.blue;
|
||||
dst->color[3] = src->tv.color.alpha;
|
||||
dst->color[0] = src->color[2];
|
||||
dst->color[1] = src->color[1];
|
||||
dst->color[2] = src->color[0];
|
||||
dst->color[3] = src->color[3];
|
||||
}
|
||||
else {
|
||||
GLfloat w = 1.0 / src->v.rhw;
|
||||
GLfloat w = 1.0 / src->rhw;
|
||||
|
||||
dst->win[0] = src->v.x - fxMesa->x_offset;
|
||||
dst->win[1] = fxMesa->screen_height - fxMesa->y_offset - src->v.y;
|
||||
dst->win[2] = src->v.z;
|
||||
dst->win[3] = src->v.rhw;
|
||||
dst->win[0] = src->x - fxMesa->x_offset;
|
||||
dst->win[1] = src->y - (fxMesa->screen_height - fxMesa->height - fxMesa->y_offset);
|
||||
dst->win[2] = src->z;
|
||||
dst->win[3] = src->rhw;
|
||||
|
||||
dst->color[0] = src->v.color.red;
|
||||
dst->color[1] = src->v.color.green;
|
||||
dst->color[2] = src->v.color.blue;
|
||||
dst->color[3] = src->v.color.alpha;
|
||||
dst->color[0] = src->color[2];
|
||||
dst->color[1] = src->color[1];
|
||||
dst->color[2] = src->color[0];
|
||||
dst->color[3] = src->color[3];
|
||||
|
||||
if (fxMesa->vertexFormat == TDFX_LAYOUT_PROJECT) {
|
||||
dst->texcoord[0][0] = fxMesa->sScale0 * w * src->pv.tu0;
|
||||
dst->texcoord[0][1] = fxMesa->tScale0 * w * src->pv.tv0;
|
||||
dst->texcoord[0][3] = w * src->pv.tq0;
|
||||
|
||||
if (fxMesa->SetupIndex & TDFX_TEX1_BIT) {
|
||||
dst->texcoord[1][0] = fxMesa->sScale1 * w * src->pv.tu1;
|
||||
dst->texcoord[1][1] = fxMesa->tScale1 * w * src->pv.tv1;
|
||||
dst->texcoord[1][3] = w * src->pv.tq1;
|
||||
}
|
||||
} else if (fxMesa->SetupIndex & TDFX_TEX0_BIT) {
|
||||
dst->texcoord[0][0] = fxMesa->sScale0 * w * src->v.tu0;
|
||||
dst->texcoord[0][1] = fxMesa->tScale0 * w * src->v.tv0;
|
||||
dst->texcoord[0][0] = 1.0 / fxMesa->sScale0 * w * src->tu0;
|
||||
dst->texcoord[0][1] = 1.0 / fxMesa->tScale0 * w * src->tv0;
|
||||
if (fxMesa->vertexFormat == TDFX_LAYOUT_PROJ1 || fxMesa->vertexFormat == TDFX_LAYOUT_PROJ2) {
|
||||
dst->texcoord[0][3] = w * src->tq0;
|
||||
} else {
|
||||
dst->texcoord[0][3] = 1.0;
|
||||
}
|
||||
|
||||
if (fxMesa->SetupIndex & TDFX_TEX1_BIT) {
|
||||
dst->texcoord[1][0] = fxMesa->sScale1 * w * src->v.tu1;
|
||||
dst->texcoord[1][1] = fxMesa->tScale1 * w * src->v.tv1;
|
||||
if (fxMesa->SetupIndex & TDFX_TEX1_BIT) {
|
||||
dst->texcoord[1][0] = 1.0 / fxMesa->sScale1 * w * src->tu1;
|
||||
dst->texcoord[1][1] = 1.0 / fxMesa->tScale1 * w * src->tv1;
|
||||
if (fxMesa->vertexFormat == TDFX_LAYOUT_PROJ2) {
|
||||
dst->texcoord[1][3] = w * src->tq1;
|
||||
} else {
|
||||
dst->texcoord[1][3] = 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,27 +219,22 @@ tdfx_fallback_point( tdfxContextPtr fxMesa,
|
|||
|
||||
static void tdfx_print_vertex( GLcontext *ctx, const tdfxVertex *v )
|
||||
{
|
||||
tdfxContextPtr imesa = TDFX_CONTEXT( ctx );
|
||||
tdfxContextPtr tmesa = TDFX_CONTEXT( ctx );
|
||||
|
||||
fprintf(stderr, "vertex at %p\n", (void *)v);
|
||||
|
||||
if (imesa->vertexFormat == TDFX_LAYOUT_TINY) {
|
||||
fprintf(stderr, "x %f y %f z %f\n", v->v.x, v->v.y, v->v.z);
|
||||
fprintf(stderr, "r %d g %d b %d a %d\n",
|
||||
v->tv.color.red,
|
||||
v->tv.color.green,
|
||||
v->tv.color.blue,
|
||||
v->tv.color.alpha);
|
||||
if (tmesa->vertexFormat == TDFX_LAYOUT_TINY) {
|
||||
fprintf(stderr, "x %f y %f z %f\n", v->x, v->y, v->z);
|
||||
}
|
||||
else {
|
||||
fprintf(stderr, "x %f y %f z %f oow %f\n",
|
||||
v->v.x, v->v.y, v->v.z, v->v.rhw);
|
||||
fprintf(stderr, "r %d g %d b %d a %d\n",
|
||||
v->v.color.red,
|
||||
v->v.color.green,
|
||||
v->v.color.blue,
|
||||
v->v.color.alpha);
|
||||
v->x, v->y, v->z, v->rhw);
|
||||
}
|
||||
fprintf(stderr, "r %d g %d b %d a %d\n",
|
||||
v->color[0],
|
||||
v->color[1],
|
||||
v->color[2],
|
||||
v->color[3]);
|
||||
|
||||
fprintf(stderr, "\n");
|
||||
}
|
||||
|
@ -327,34 +327,36 @@ static struct {
|
|||
#define VERTEX tdfxVertex
|
||||
#define TAB rast_tab
|
||||
|
||||
#define TDFX_COLOR( dst, src ) \
|
||||
do { \
|
||||
UNCLAMPED_FLOAT_TO_UBYTE((dst)[0], (src)[2]); \
|
||||
UNCLAMPED_FLOAT_TO_UBYTE((dst)[1], (src)[1]); \
|
||||
UNCLAMPED_FLOAT_TO_UBYTE((dst)[2], (src)[0]); \
|
||||
UNCLAMPED_FLOAT_TO_UBYTE((dst)[3], (src)[3]); \
|
||||
} while (0)
|
||||
|
||||
#define DEPTH_SCALE 1.0
|
||||
#define UNFILLED_TRI unfilled_tri
|
||||
#define UNFILLED_QUAD unfilled_quad
|
||||
#define VERT_X(_v) _v->v.x
|
||||
#define VERT_Y(_v) _v->v.y
|
||||
#define VERT_Z(_v) _v->v.z
|
||||
#define VERT_X(_v) _v->x
|
||||
#define VERT_Y(_v) _v->y
|
||||
#define VERT_Z(_v) _v->z
|
||||
#define AREA_IS_CCW( a ) (a < 0)
|
||||
#define GET_VERTEX(e) (fxMesa->verts + (e<<fxMesa->vertex_stride_shift))
|
||||
#define GET_VERTEX(e) (fxMesa->verts + (e))
|
||||
|
||||
#define VERT_SET_RGBA( v, c ) TDFX_COLOR( v->ub4[coloroffset], c )
|
||||
#define VERT_COPY_RGBA( v0, v1 ) v0->ui[coloroffset] = v1->ui[coloroffset]
|
||||
#define VERT_SAVE_RGBA( idx ) color[idx] = v[idx]->ui[coloroffset]
|
||||
#define VERT_RESTORE_RGBA( idx ) v[idx]->ui[coloroffset] = color[idx]
|
||||
#define VERT_SET_RGBA( dst, f ) \
|
||||
do { \
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(dst->color[2], f[0]);\
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(dst->color[1], f[1]);\
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(dst->color[0], f[2]);\
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(dst->color[3], f[3]);\
|
||||
} while (0)
|
||||
|
||||
#define VERT_COPY_RGBA( v0, v1 ) \
|
||||
*(GLuint *)&v0->color = *(GLuint *)&v1->color
|
||||
|
||||
#define VERT_SAVE_RGBA( idx ) \
|
||||
*(GLuint *)&color[idx] = *(GLuint *)&v[idx]->color
|
||||
|
||||
#define VERT_RESTORE_RGBA( idx ) \
|
||||
*(GLuint *)&v[idx]->color = *(GLuint *)&color[idx]
|
||||
|
||||
#define LOCAL_VARS(n) \
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \
|
||||
GLuint coloroffset = (fxMesa->vertexFormat == \
|
||||
TDFX_LAYOUT_TINY) ? 3 : 4; \
|
||||
GLuint color[n]; \
|
||||
(void) color; (void)coloroffset
|
||||
GLubyte color[n][4]; \
|
||||
(void) color;
|
||||
|
||||
|
||||
|
||||
|
@ -554,6 +556,7 @@ static void init_rast_tab( void )
|
|||
/* Accelerate vertex buffer rendering when renderindex == 0 and
|
||||
* there is no clipping.
|
||||
*/
|
||||
#define INIT(x) tdfxRenderPrimitive( ctx, x )
|
||||
|
||||
static void tdfx_render_vb_points( GLcontext *ctx,
|
||||
GLuint start,
|
||||
|
@ -561,25 +564,24 @@ static void tdfx_render_vb_points( GLcontext *ctx,
|
|||
GLuint flags )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
GLuint shift = fxMesa->vertex_stride_shift;
|
||||
GLubyte *fxVB = fxMesa->verts + (start << shift);
|
||||
int stride = 1<<shift;
|
||||
GLubyte *tmp;
|
||||
tdfxVertex *fxVB = fxMesa->verts;
|
||||
GLint i;
|
||||
(void) flags;
|
||||
|
||||
INIT(GL_POINTS);
|
||||
|
||||
/* Adjust point coords */
|
||||
for (i = start, tmp = fxVB; i < count; i++, tmp += stride) {
|
||||
((tdfxVertexPtr)tmp)->v.x += PNT_X_OFFSET - TRI_X_OFFSET;
|
||||
((tdfxVertexPtr)tmp)->v.y += PNT_Y_OFFSET - TRI_Y_OFFSET;
|
||||
for (i = start; i < count; i++) {
|
||||
fxVB[i].x += PNT_X_OFFSET - TRI_X_OFFSET;
|
||||
fxVB[i].y += PNT_Y_OFFSET - TRI_Y_OFFSET;
|
||||
}
|
||||
|
||||
fxMesa->Glide.grDrawVertexArrayContiguous( GR_POINTS, count-start,
|
||||
fxVB, stride);
|
||||
fxVB + start, sizeof(tdfxVertex));
|
||||
/* restore point coords */
|
||||
for (i = start, tmp = fxVB; i < count; i++, tmp += stride) {
|
||||
((tdfxVertexPtr)tmp)->v.x -= PNT_X_OFFSET - TRI_X_OFFSET;
|
||||
((tdfxVertexPtr)tmp)->v.y -= PNT_Y_OFFSET - TRI_Y_OFFSET;
|
||||
for (i = start; i < count; i++) {
|
||||
fxVB[i].x -= PNT_X_OFFSET - TRI_X_OFFSET;
|
||||
fxVB[i].y -= PNT_Y_OFFSET - TRI_Y_OFFSET;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -589,26 +591,25 @@ static void tdfx_render_vb_line_strip( GLcontext *ctx,
|
|||
GLuint flags )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
GLuint shift = fxMesa->vertex_stride_shift;
|
||||
GLubyte *fxVB = fxMesa->verts + (start << shift);
|
||||
int stride = 1<<shift;
|
||||
GLubyte *tmp;
|
||||
tdfxVertex *fxVB = fxMesa->verts;
|
||||
GLint i;
|
||||
(void) flags;
|
||||
|
||||
INIT(GL_LINE_STRIP);
|
||||
|
||||
/* adjust line coords */
|
||||
for (i = start, tmp = fxVB; i < count; i++, tmp += stride) {
|
||||
((tdfxVertexPtr)tmp)->v.x += LINE_X_OFFSET - TRI_X_OFFSET;
|
||||
((tdfxVertexPtr)tmp)->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
|
||||
for (i = start; i < count; i++) {
|
||||
fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET;
|
||||
fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET;
|
||||
}
|
||||
|
||||
fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINE_STRIP, count-start,
|
||||
fxVB, 1<<shift);
|
||||
fxVB + start, sizeof(tdfxVertex) );
|
||||
|
||||
/* restore line coords */
|
||||
for (i = start, tmp = fxVB; i < count; i++, tmp += stride) {
|
||||
((tdfxVertexPtr)tmp)->v.x -= LINE_X_OFFSET - TRI_X_OFFSET;
|
||||
((tdfxVertexPtr)tmp)->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
|
||||
for (i = start; i < count; i++) {
|
||||
fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET;
|
||||
fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -618,36 +619,34 @@ static void tdfx_render_vb_line_loop( GLcontext *ctx,
|
|||
GLuint flags )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
GLuint shift = fxMesa->vertex_stride_shift;
|
||||
GLubyte *fxVB = fxMesa->verts + (start << shift);
|
||||
int stride = 1<<shift;
|
||||
GLubyte *tmp, *tmp2 = fxVB;
|
||||
tdfxVertex *fxVB = fxMesa->verts;
|
||||
GLint i;
|
||||
GLint j = start;
|
||||
(void) flags;
|
||||
|
||||
INIT(GL_LINE_LOOP);
|
||||
|
||||
if (!(flags & PRIM_BEGIN)) {
|
||||
fxVB += (1 << shift);
|
||||
j++;
|
||||
}
|
||||
|
||||
/* adjust line coords */
|
||||
for (i = start, tmp = tmp2; i < count; i++, tmp += stride) {
|
||||
((tdfxVertexPtr)tmp)->v.x += LINE_X_OFFSET - TRI_X_OFFSET;
|
||||
((tdfxVertexPtr)tmp)->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
|
||||
for (i = start; i < count; i++) {
|
||||
fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET;
|
||||
fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET;
|
||||
}
|
||||
|
||||
fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINE_STRIP, count-j,
|
||||
fxVB, 1<<shift);
|
||||
fxVB + j, sizeof(tdfxVertex));
|
||||
|
||||
if (flags & PRIM_END)
|
||||
fxMesa->Glide.grDrawLine( fxMesa->verts + ((count - 1)<<shift),
|
||||
fxMesa->verts + (start<<shift) );
|
||||
fxMesa->Glide.grDrawLine( fxVB + (count - 1),
|
||||
fxVB + start );
|
||||
|
||||
/* restore line coords */
|
||||
for (i = start, tmp = tmp2; i < count; i++, tmp += stride) {
|
||||
((tdfxVertexPtr)tmp)->v.x -= LINE_X_OFFSET - TRI_X_OFFSET;
|
||||
((tdfxVertexPtr)tmp)->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
|
||||
for (i = start; i < count; i++) {
|
||||
fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET;
|
||||
fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -657,26 +656,25 @@ static void tdfx_render_vb_lines( GLcontext *ctx,
|
|||
GLuint flags )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
GLuint shift = fxMesa->vertex_stride_shift;
|
||||
GLubyte *fxVB = fxMesa->verts + (start << shift);
|
||||
int stride = 1<<shift;
|
||||
GLubyte *tmp;
|
||||
tdfxVertex *fxVB = fxMesa->verts;
|
||||
GLint i;
|
||||
(void) flags;
|
||||
|
||||
INIT(GL_LINES);
|
||||
|
||||
/* adjust line coords */
|
||||
for (i = start, tmp = fxVB; i < count; i++, tmp += stride) {
|
||||
((tdfxVertexPtr)tmp)->v.x += LINE_X_OFFSET - TRI_X_OFFSET;
|
||||
((tdfxVertexPtr)tmp)->v.y += LINE_Y_OFFSET - TRI_Y_OFFSET;
|
||||
for (i = start; i < count; i++) {
|
||||
fxVB[i].x += LINE_X_OFFSET - TRI_X_OFFSET;
|
||||
fxVB[i].y += LINE_Y_OFFSET - TRI_Y_OFFSET;
|
||||
}
|
||||
|
||||
fxMesa->Glide.grDrawVertexArrayContiguous( GR_LINES, count-start,
|
||||
fxVB, 1<<shift);
|
||||
fxVB + start, sizeof(tdfxVertex));
|
||||
|
||||
/* restore line coords */
|
||||
for (i = start, tmp = fxVB; i < count; i++, tmp += stride) {
|
||||
((tdfxVertexPtr)tmp)->v.x -= LINE_X_OFFSET - TRI_X_OFFSET;
|
||||
((tdfxVertexPtr)tmp)->v.y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
|
||||
for (i = start; i < count; i++) {
|
||||
fxVB[i].x -= LINE_X_OFFSET - TRI_X_OFFSET;
|
||||
fxVB[i].y -= LINE_Y_OFFSET - TRI_Y_OFFSET;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -686,12 +684,28 @@ static void tdfx_render_vb_triangles( GLcontext *ctx,
|
|||
GLuint flags )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
GLuint shift = fxMesa->vertex_stride_shift;
|
||||
GLubyte *fxVB = fxMesa->verts + (start << shift);
|
||||
tdfxVertex *fxVB = fxMesa->verts;
|
||||
(void) flags;
|
||||
|
||||
INIT(GL_TRIANGLES);
|
||||
|
||||
#if 0
|
||||
/* [dBorca]
|
||||
* apparently, this causes troubles with some programs (GLExcess);
|
||||
* might be a bug in Glide... However, "grDrawVertexArrayContiguous"
|
||||
* eventually calls "grDrawTriangle" for GR_TRIANGLES, so we're better
|
||||
* off doing it by hand...
|
||||
*/
|
||||
fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLES, count-start,
|
||||
fxVB, 1<<shift);
|
||||
fxVB + start, sizeof(tdfxVertex));
|
||||
#else
|
||||
{
|
||||
GLuint j;
|
||||
for (j=start+2; j<count; j+=3) {
|
||||
fxMesa->Glide.grDrawTriangle(fxVB + (j-2), fxVB + (j-1), fxVB + j);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
@ -701,18 +715,19 @@ static void tdfx_render_vb_tri_strip( GLcontext *ctx,
|
|||
GLuint flags )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
GLuint shift = fxMesa->vertex_stride_shift;
|
||||
GLubyte *fxVB = fxMesa->verts + (start << shift);
|
||||
tdfxVertex *fxVB = fxMesa->verts;
|
||||
int mode;
|
||||
(void) flags;
|
||||
|
||||
INIT(GL_TRIANGLE_STRIP);
|
||||
|
||||
/* fprintf(stderr, "%s/%d\n", __FUNCTION__, 1<<shift); */
|
||||
/* if(!prevLockLine) abort(); */
|
||||
|
||||
mode = GR_TRIANGLE_STRIP;
|
||||
|
||||
fxMesa->Glide.grDrawVertexArrayContiguous( mode, count-start,
|
||||
fxVB, 1<<shift);
|
||||
fxVB + start, sizeof(tdfxVertex));
|
||||
}
|
||||
|
||||
|
||||
|
@ -722,12 +737,13 @@ static void tdfx_render_vb_tri_fan( GLcontext *ctx,
|
|||
GLuint flags )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
GLuint shift = fxMesa->vertex_stride_shift;
|
||||
GLubyte *fxVB = fxMesa->verts + (start << shift);
|
||||
tdfxVertex *fxVB = fxMesa->verts;
|
||||
(void) flags;
|
||||
|
||||
INIT(GL_TRIANGLE_FAN);
|
||||
|
||||
fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_FAN, count-start,
|
||||
fxVB, 1<<shift );
|
||||
fxVB + start, sizeof(tdfxVertex) );
|
||||
}
|
||||
|
||||
static void tdfx_render_vb_quads( GLcontext *ctx,
|
||||
|
@ -736,15 +752,22 @@ static void tdfx_render_vb_quads( GLcontext *ctx,
|
|||
GLuint flags )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
GLuint shift = fxMesa->vertex_stride_shift;
|
||||
GLubyte *fxVB = fxMesa->verts;
|
||||
tdfxVertex *fxVB = fxMesa->verts;
|
||||
GLuint i;
|
||||
(void) flags;
|
||||
|
||||
INIT(GL_QUADS);
|
||||
|
||||
for (i = start ; i < count-3 ; i += 4 ) {
|
||||
#define VERT(x) (fxVB + ((x)<<shift))
|
||||
fxMesa->Glide.grDrawTriangle( VERT(i), VERT(i+1), VERT(i+3) );
|
||||
fxMesa->Glide.grDrawTriangle( VERT(i+1), VERT(i+2), VERT(i+3) );
|
||||
for (i = start + 3 ; i < count ; i += 4 ) {
|
||||
#define VERT(x) (fxVB + (x))
|
||||
tdfxVertex *_v_[4];
|
||||
_v_[0] = VERT(i);
|
||||
_v_[1] = VERT(i-3);
|
||||
_v_[2] = VERT(i-2);
|
||||
_v_[3] = VERT(i-1);
|
||||
fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);
|
||||
/*fxMesa->Glide.grDrawTriangle( VERT(i-3), VERT(i-2), VERT(i) );*/
|
||||
/*fxMesa->Glide.grDrawTriangle( VERT(i-2), VERT(i-1), VERT(i) );*/
|
||||
#undef VERT
|
||||
}
|
||||
}
|
||||
|
@ -755,14 +778,15 @@ static void tdfx_render_vb_quad_strip( GLcontext *ctx,
|
|||
GLuint flags )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
GLuint shift = fxMesa->vertex_stride_shift;
|
||||
GLubyte *fxVB = fxMesa->verts + (start << shift);
|
||||
tdfxVertex *fxVB = fxMesa->verts;
|
||||
(void) flags;
|
||||
|
||||
INIT(GL_QUAD_STRIP);
|
||||
|
||||
count -= (count-start)&1;
|
||||
|
||||
fxMesa->Glide.grDrawVertexArrayContiguous( GR_TRIANGLE_STRIP,
|
||||
count-start, fxVB, 1<<shift);
|
||||
count-start, fxVB + start, sizeof(tdfxVertex));
|
||||
}
|
||||
|
||||
static void tdfx_render_vb_poly( GLcontext *ctx,
|
||||
|
@ -771,12 +795,13 @@ static void tdfx_render_vb_poly( GLcontext *ctx,
|
|||
GLuint flags )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
GLuint shift = fxMesa->vertex_stride_shift;
|
||||
GLubyte *fxVB = fxMesa->verts + (start << shift);
|
||||
tdfxVertex *fxVB = fxMesa->verts;
|
||||
(void) flags;
|
||||
|
||||
INIT(GL_POLYGON);
|
||||
|
||||
fxMesa->Glide.grDrawVertexArrayContiguous( GR_POLYGON, count-start,
|
||||
fxVB, 1<<shift);
|
||||
fxVB + start, sizeof(tdfxVertex));
|
||||
}
|
||||
|
||||
static void tdfx_render_vb_noop( GLcontext *ctx,
|
||||
|
@ -804,6 +829,7 @@ static void (*tdfx_render_tab_verts[GL_POLYGON+2])(GLcontext *,
|
|||
tdfx_render_vb_poly,
|
||||
tdfx_render_vb_noop,
|
||||
};
|
||||
#undef INIT
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
|
@ -811,7 +837,7 @@ static void (*tdfx_render_tab_verts[GL_POLYGON+2])(GLcontext *,
|
|||
/**********************************************************************/
|
||||
|
||||
|
||||
#define VERT(x) (tdfxVertex *)(vertptr + ((x)<<vertshift))
|
||||
#define VERT(x) (tdfxVertex *)(vertptr + (x))
|
||||
|
||||
#define RENDER_POINTS( start, count ) \
|
||||
for ( ; start < count ; start++) \
|
||||
|
@ -824,15 +850,23 @@ static void (*tdfx_render_tab_verts[GL_POLYGON+2])(GLcontext *,
|
|||
fxMesa->Glide.grDrawTriangle( VERT(v0), VERT(v1), VERT(v2) )
|
||||
|
||||
#define RENDER_QUAD( v0, v1, v2, v3 ) \
|
||||
tdfx_draw_quad( fxMesa, VERT(v0), VERT(v1), VERT(v2), VERT(v3) )
|
||||
do { \
|
||||
tdfxVertex *_v_[4]; \
|
||||
_v_[0] = VERT(v3); \
|
||||
_v_[1] = VERT(v0); \
|
||||
_v_[2] = VERT(v1); \
|
||||
_v_[3] = VERT(v2); \
|
||||
fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, 4, _v_);\
|
||||
/*fxMesa->Glide.grDrawTriangle( VERT(v0), VERT(v1), VERT(v3) );*/\
|
||||
/*fxMesa->Glide.grDrawTriangle( VERT(v1), VERT(v2), VERT(v3) );*/\
|
||||
} while (0)
|
||||
|
||||
#define INIT(x) tdfxRenderPrimitive( ctx, x )
|
||||
|
||||
#undef LOCAL_VARS
|
||||
#define LOCAL_VARS \
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx); \
|
||||
GLubyte *vertptr = (GLubyte *)fxMesa->verts; \
|
||||
const GLuint vertshift = fxMesa->vertex_stride_shift; \
|
||||
tdfxVertex *vertptr = fxMesa->verts; \
|
||||
const GLuint * const elt = TNL_CONTEXT(ctx)->vb.Elts; \
|
||||
(void) elt;
|
||||
|
||||
|
@ -848,6 +882,14 @@ static void (*tdfx_render_tab_verts[GL_POLYGON+2])(GLcontext *,
|
|||
#define ELT(x) elt[x]
|
||||
#include "tnl_dd/t_dd_rendertmp.h"
|
||||
|
||||
/* Verts, no clipping.
|
||||
*/
|
||||
#undef ELT
|
||||
#undef TAG
|
||||
#define TAG(x) tdfx_##x##_verts
|
||||
#define ELT(x) x
|
||||
/*#include "tnl_dd/t_dd_rendertmp.h"*/
|
||||
|
||||
|
||||
|
||||
/**********************************************************************/
|
||||
|
@ -888,14 +930,22 @@ static void tdfxRenderClippedLine( GLcontext *ctx, GLuint ii, GLuint jj )
|
|||
static void tdfxFastRenderClippedPoly( GLcontext *ctx, const GLuint *elts,
|
||||
GLuint n )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
|
||||
GLubyte *vertptr = (GLubyte *)fxMesa->verts;
|
||||
const GLuint vertshift = fxMesa->vertex_stride_shift;
|
||||
const GLuint *start = (const GLuint *)VERT(elts[0]);
|
||||
int i;
|
||||
|
||||
for (i = 2 ; i < n ; i++) {
|
||||
fxMesa->Glide.grDrawTriangle( VERT(elts[i-1]), VERT(elts[i]), start );
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
|
||||
tdfxVertex *vertptr = fxMesa->verts;
|
||||
if (n == 3) {
|
||||
fxMesa->Glide.grDrawTriangle( VERT(elts[0]), VERT(elts[1]), VERT(elts[2]) );
|
||||
} else if (n <= 32) {
|
||||
tdfxVertex *newvptr[32];
|
||||
for (i = 0 ; i < n ; i++) {
|
||||
newvptr[i] = VERT(elts[i]);
|
||||
}
|
||||
fxMesa->Glide.grDrawVertexArray(GR_TRIANGLE_FAN, n, newvptr);
|
||||
} else {
|
||||
const tdfxVertex *start = VERT(elts[0]);
|
||||
for (i = 2 ; i < n ; i++) {
|
||||
fxMesa->Glide.grDrawTriangle( start, VERT(elts[i-1]), VERT(elts[i]) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1166,7 +1216,7 @@ static void tdfxRenderFinish( GLcontext *ctx )
|
|||
/**********************************************************************/
|
||||
|
||||
static char *fallbackStrings[] = {
|
||||
"1D/3D Texture map",
|
||||
"3D/Rect/Cube Texture map",
|
||||
"glDrawBuffer(GL_FRONT_AND_BACK)",
|
||||
"Separate specular color",
|
||||
"glEnable/Disable(GL_STENCIL_TEST)",
|
||||
|
|
|
@ -39,35 +39,19 @@
|
|||
#include "tdfx_state.h"
|
||||
#include "tdfx_render.h"
|
||||
|
||||
static void copy_pv_rgba4( GLcontext *ctx, GLuint edst, GLuint esrc )
|
||||
static void copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
|
||||
GLubyte *tdfxverts = (GLubyte *)fxMesa->verts;
|
||||
GLuint shift = fxMesa->vertex_stride_shift;
|
||||
tdfxVertex *dst = (tdfxVertex *)(tdfxverts + (edst << shift));
|
||||
tdfxVertex *src = (tdfxVertex *)(tdfxverts + (esrc << shift));
|
||||
dst->ui[4] = src->ui[4];
|
||||
tdfxVertex *dst = fxMesa->verts + edst;
|
||||
tdfxVertex *src = fxMesa->verts + esrc;
|
||||
*(GLuint *)&dst->color = *(GLuint *)&src->color;
|
||||
}
|
||||
|
||||
static void copy_pv_rgba3( GLcontext *ctx, GLuint edst, GLuint esrc )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
|
||||
GLubyte *tdfxverts = (GLubyte *)fxMesa->verts;
|
||||
GLuint shift = fxMesa->vertex_stride_shift;
|
||||
tdfxVertex *dst = (tdfxVertex *)(tdfxverts + (edst << shift));
|
||||
tdfxVertex *src = (tdfxVertex *)(tdfxverts + (esrc << shift));
|
||||
dst->ui[3] = src->ui[3];
|
||||
}
|
||||
|
||||
typedef void (*tdfx_emit_func)( GLcontext *, GLuint, GLuint, void *, GLuint );
|
||||
|
||||
static struct {
|
||||
tdfx_emit_func emit;
|
||||
tnl_emit_func emit;
|
||||
tnl_interp_func interp;
|
||||
tnl_copy_pv_func copy_pv;
|
||||
GLboolean (*check_tex_sizes)( GLcontext *ctx );
|
||||
GLuint vertex_size;
|
||||
GLuint vertex_stride_shift;
|
||||
GLuint vertex_format;
|
||||
} setup_tab[TDFX_MAX_SETUP];
|
||||
|
||||
|
@ -87,7 +71,7 @@ static void interp_extras( GLcontext *ctx,
|
|||
/*fprintf(stderr, "%s\n", __FUNCTION__);*/
|
||||
|
||||
if (VB->ColorPtr[1]) {
|
||||
INTERP_4CHAN( t,
|
||||
INTERP_4F( t,
|
||||
GET_COLOR(VB->ColorPtr[1], dst),
|
||||
GET_COLOR(VB->ColorPtr[1], out),
|
||||
GET_COLOR(VB->ColorPtr[1], in) );
|
||||
|
@ -106,7 +90,7 @@ static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
|
|||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
|
||||
if (VB->ColorPtr[1]) {
|
||||
COPY_CHAN4( GET_COLOR(VB->ColorPtr[1], dst),
|
||||
COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst),
|
||||
GET_COLOR(VB->ColorPtr[1], src) );
|
||||
}
|
||||
|
||||
|
@ -163,6 +147,29 @@ static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
|
|||
#include "tdfx_vbtmp.h"
|
||||
|
||||
|
||||
/* fogc { */
|
||||
#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_FOGC_BIT)
|
||||
#define TAG(x) x##_wgf
|
||||
#include "tdfx_vbtmp.h"
|
||||
|
||||
#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_FOGC_BIT)
|
||||
#define TAG(x) x##_wgt0f
|
||||
#include "tdfx_vbtmp.h"
|
||||
|
||||
#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT|TDFX_FOGC_BIT)
|
||||
#define TAG(x) x##_wgt0t1f
|
||||
#include "tdfx_vbtmp.h"
|
||||
|
||||
#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_PTEX_BIT|TDFX_FOGC_BIT)
|
||||
#define TAG(x) x##_wgpt0f
|
||||
#include "tdfx_vbtmp.h"
|
||||
|
||||
#define IND (TDFX_XYZ_BIT|TDFX_RGBA_BIT|TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT|\
|
||||
TDFX_PTEX_BIT|TDFX_FOGC_BIT)
|
||||
#define TAG(x) x##_wgpt0t1f
|
||||
#include "tdfx_vbtmp.h"
|
||||
/* fogc } */
|
||||
|
||||
|
||||
static void init_setup_tab( void )
|
||||
{
|
||||
|
@ -178,19 +185,27 @@ static void init_setup_tab( void )
|
|||
init_t0t1();
|
||||
init_gt0();
|
||||
init_gt0t1();
|
||||
|
||||
/* fogcoord */
|
||||
init_wgf();
|
||||
init_wgt0f();
|
||||
init_wgt0t1f();
|
||||
init_wgpt0f();
|
||||
init_wgpt0t1f();
|
||||
}
|
||||
|
||||
|
||||
void tdfxPrintSetupFlags(char *msg, GLuint flags )
|
||||
{
|
||||
fprintf(stderr, "%s(%x): %s%s%s%s%s\n",
|
||||
fprintf(stderr, "%s(%x): %s%s%s%s%s%s\n",
|
||||
msg,
|
||||
(int)flags,
|
||||
(flags & TDFX_XYZ_BIT) ? " xyz," : "",
|
||||
(flags & TDFX_W_BIT) ? " w," : "",
|
||||
(flags & TDFX_RGBA_BIT) ? " rgba," : "",
|
||||
(flags & TDFX_TEX0_BIT) ? " tex-0," : "",
|
||||
(flags & TDFX_TEX1_BIT) ? " tex-1," : "");
|
||||
(flags & TDFX_TEX1_BIT) ? " tex-1," : "",
|
||||
(flags & TDFX_FOGC_BIT) ? " fogc," : "");
|
||||
}
|
||||
|
||||
|
||||
|
@ -210,7 +225,6 @@ void tdfxCheckTexSizes( GLcontext *ctx )
|
|||
FLUSH_BATCH(fxMesa);
|
||||
fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT;
|
||||
fxMesa->vertexFormat = setup_tab[ind].vertex_format;
|
||||
fxMesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
|
||||
|
||||
/* This is required as we have just changed the vertex
|
||||
* format, so the interp and copy routines must also change.
|
||||
|
@ -230,8 +244,7 @@ void tdfxBuildVertices( GLcontext *ctx, GLuint start, GLuint count,
|
|||
GLuint newinputs )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
|
||||
GLubyte *v = (fxMesa->verts + (start<<fxMesa->vertex_stride_shift));
|
||||
GLuint stride = 1<<fxMesa->vertex_stride_shift;
|
||||
tdfxVertex *v = fxMesa->verts + start;
|
||||
|
||||
newinputs |= fxMesa->SetupNewInputs;
|
||||
fxMesa->SetupNewInputs = 0;
|
||||
|
@ -240,12 +253,15 @@ void tdfxBuildVertices( GLcontext *ctx, GLuint start, GLuint count,
|
|||
return;
|
||||
|
||||
if (newinputs & VERT_BIT_POS) {
|
||||
setup_tab[fxMesa->SetupIndex].emit( ctx, start, count, v, stride );
|
||||
setup_tab[fxMesa->SetupIndex].emit( ctx, start, count, v );
|
||||
} else {
|
||||
GLuint ind = 0;
|
||||
|
||||
if (newinputs & VERT_BIT_COLOR0)
|
||||
ind |= TDFX_RGBA_BIT;
|
||||
|
||||
if (newinputs & VERT_BIT_FOG)
|
||||
ind |= TDFX_FOGC_BIT;
|
||||
|
||||
if (newinputs & VERT_BIT_TEX0)
|
||||
ind |= TDFX_TEX0_BIT;
|
||||
|
@ -259,7 +275,7 @@ void tdfxBuildVertices( GLcontext *ctx, GLuint start, GLuint count,
|
|||
ind &= fxMesa->SetupIndex;
|
||||
|
||||
if (ind) {
|
||||
setup_tab[ind].emit( ctx, start, count, v, stride );
|
||||
setup_tab[ind].emit( ctx, start, count, v );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -271,15 +287,25 @@ void tdfxChooseVertexState( GLcontext *ctx )
|
|||
tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
|
||||
GLuint ind = TDFX_XYZ_BIT|TDFX_RGBA_BIT;
|
||||
|
||||
if (ctx->Texture._EnabledUnits & 0x2)
|
||||
/* unit 1 enabled */
|
||||
ind |= TDFX_W_BIT|TDFX_TEX1_BIT|TDFX_TEX0_BIT;
|
||||
else if (ctx->Texture._EnabledUnits & 0x1)
|
||||
fxMesa->tmu_source[0] = 0;
|
||||
fxMesa->tmu_source[1] = 1;
|
||||
|
||||
if (ctx->Texture._EnabledUnits & 0x2) {
|
||||
if (ctx->Texture._EnabledUnits & 0x1) {
|
||||
ind |= TDFX_TEX1_BIT;
|
||||
}
|
||||
ind |= TDFX_W_BIT|TDFX_TEX0_BIT;
|
||||
fxMesa->tmu_source[0] = 1;
|
||||
fxMesa->tmu_source[1] = 0;
|
||||
} else if (ctx->Texture._EnabledUnits & 0x1) {
|
||||
/* unit 0 enabled */
|
||||
ind |= TDFX_W_BIT|TDFX_TEX0_BIT;
|
||||
else if (ctx->Fog.Enabled)
|
||||
ind |= TDFX_W_BIT;
|
||||
|
||||
}
|
||||
|
||||
if (fxMesa->Fog.Mode == GR_FOG_WITH_TABLE_ON_FOGCOORD_EXT) {
|
||||
ind |= TDFX_FOGC_BIT;
|
||||
}
|
||||
|
||||
fxMesa->SetupIndex = ind;
|
||||
|
||||
if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
|
||||
|
@ -294,7 +320,6 @@ void tdfxChooseVertexState( GLcontext *ctx )
|
|||
FLUSH_BATCH(fxMesa);
|
||||
fxMesa->dirty |= TDFX_UPLOAD_VERTEX_LAYOUT;
|
||||
fxMesa->vertexFormat = setup_tab[ind].vertex_format;
|
||||
fxMesa->vertex_stride_shift = setup_tab[ind].vertex_stride_shift;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -310,10 +335,8 @@ void tdfxInitVB( GLcontext *ctx )
|
|||
firsttime = 0;
|
||||
}
|
||||
|
||||
fxMesa->verts = (GLubyte *)ALIGN_MALLOC(size * sizeof(tdfxVertex), 32);
|
||||
fxMesa->vertexFormat = setup_tab[TDFX_XYZ_BIT|TDFX_RGBA_BIT].vertex_format;
|
||||
fxMesa->vertex_stride_shift = setup_tab[(TDFX_XYZ_BIT|
|
||||
TDFX_RGBA_BIT)].vertex_stride_shift;
|
||||
fxMesa->verts = ALIGN_MALLOC(size * sizeof(tdfxVertex), 32);
|
||||
fxMesa->vertexFormat = TDFX_LAYOUT_TINY;
|
||||
fxMesa->SetupIndex = TDFX_XYZ_BIT|TDFX_RGBA_BIT;
|
||||
}
|
||||
|
||||
|
|
|
@ -39,7 +39,8 @@
|
|||
#define TDFX_TEX1_BIT 0x8
|
||||
#define TDFX_TEX0_BIT 0x10
|
||||
#define TDFX_PTEX_BIT 0x20
|
||||
#define TDFX_MAX_SETUP 0x40
|
||||
#define TDFX_FOGC_BIT 0x40
|
||||
#define TDFX_MAX_SETUP 0x80
|
||||
|
||||
#define _TDFX_NEW_RASTERSETUP (_NEW_TEXTURE | \
|
||||
_DD_NEW_SEPARATE_SPECULAR | \
|
||||
|
|
|
@ -1,19 +1,54 @@
|
|||
/*
|
||||
* Mesa 3-D graphics library
|
||||
* Version: 4.1
|
||||
*
|
||||
* Copyright (C) 1999-2002 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.
|
||||
*/
|
||||
|
||||
/* Authors:
|
||||
* Keith Whitwell <keith@tungstengraphics.com>
|
||||
* Daniel Borca <dborca@users.sourceforge.net>
|
||||
*/
|
||||
|
||||
|
||||
#define VIEWPORT_X(dst,x) dst = s[0] * x + s[12]
|
||||
#define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13]
|
||||
#define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14]
|
||||
|
||||
#if (IND & (TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT))
|
||||
|
||||
static void TAG(emit)( GLcontext *ctx,
|
||||
GLuint start, GLuint end,
|
||||
void *dest,
|
||||
GLuint stride )
|
||||
void *dest )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_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 (*tc0)[4], (*tc1)[4];
|
||||
GLfloat (*col)[4];
|
||||
GLuint tc0_stride, tc1_stride, col_stride;
|
||||
GLuint tc0_size, tc1_size;
|
||||
GLuint tc0_size, tc1_size, col_size;
|
||||
GLfloat (*proj)[4] = VB->NdcPtr->data;
|
||||
GLuint proj_stride = VB->NdcPtr->stride;
|
||||
GLfloat (*fog)[4];
|
||||
GLuint fog_stride;
|
||||
tdfxVertex *v = (tdfxVertex *)dest;
|
||||
GLfloat u0scale,v0scale,u1scale,v1scale;
|
||||
const GLubyte *mask = VB->ClipMask;
|
||||
|
@ -21,30 +56,34 @@ static void TAG(emit)( GLcontext *ctx,
|
|||
int i;
|
||||
|
||||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
ASSERT(stride > 16);
|
||||
|
||||
|
||||
if (IND & TDFX_TEX0_BIT) {
|
||||
tc0_stride = VB->TexCoordPtr[0]->stride;
|
||||
tc0 = VB->TexCoordPtr[0]->data;
|
||||
tc0_stride = VB->TexCoordPtr[tmu0_source]->stride;
|
||||
tc0 = VB->TexCoordPtr[tmu0_source]->data;
|
||||
u0scale = fxMesa->sScale0;
|
||||
v0scale = fxMesa->tScale0;
|
||||
if (IND & TDFX_PTEX_BIT)
|
||||
tc0_size = VB->TexCoordPtr[0]->size;
|
||||
tc0_size = VB->TexCoordPtr[tmu0_source]->size;
|
||||
}
|
||||
|
||||
if (IND & TDFX_TEX1_BIT) {
|
||||
tc1 = VB->TexCoordPtr[1]->data;
|
||||
tc1_stride = VB->TexCoordPtr[1]->stride;
|
||||
tc1 = VB->TexCoordPtr[tmu1_source]->data;
|
||||
tc1_stride = VB->TexCoordPtr[tmu1_source]->stride;
|
||||
u1scale = fxMesa->sScale1;
|
||||
v1scale = fxMesa->tScale1;
|
||||
if (IND & TDFX_PTEX_BIT)
|
||||
tc1_size = VB->TexCoordPtr[1]->size;
|
||||
tc1_size = VB->TexCoordPtr[tmu1_source]->size;
|
||||
}
|
||||
|
||||
if (IND & TDFX_RGBA_BIT) {
|
||||
col = VB->ColorPtr[0]->data;
|
||||
col_stride = VB->ColorPtr[0]->stride;
|
||||
col_size = VB->ColorPtr[0]->size;
|
||||
}
|
||||
|
||||
if (IND & TDFX_FOGC_BIT) {
|
||||
fog = VB->FogCoordPtr->data;
|
||||
fog_stride = VB->FogCoordPtr->stride;
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -58,153 +97,65 @@ static void TAG(emit)( GLcontext *ctx,
|
|||
tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + start * tc1_stride);
|
||||
if (IND & TDFX_RGBA_BIT)
|
||||
STRIDE_4F(col, start * col_stride);
|
||||
if (IND & TDFX_FOGC_BIT)
|
||||
STRIDE_4F(fog, start * fog_stride);
|
||||
}
|
||||
|
||||
for (i=start; i < end; i++, v = (tdfxVertex *)((GLubyte *)v + stride)) {
|
||||
for (i=start; i < end; i++, v++) {
|
||||
if (IND & TDFX_XYZ_BIT) {
|
||||
if (mask[i] == 0) {
|
||||
/* unclipped */
|
||||
v->v.x = s[0] * proj[0][0] + s[12];
|
||||
v->v.y = s[5] * proj[0][1] + s[13];
|
||||
v->v.z = s[10] * proj[0][2] + s[14];
|
||||
v->v.rhw = proj[0][3];
|
||||
VIEWPORT_X(v->x, proj[0][0]);
|
||||
VIEWPORT_Y(v->y, proj[0][1]);
|
||||
VIEWPORT_Z(v->z, proj[0][2]);
|
||||
v->rhw = proj[0][3];
|
||||
} else {
|
||||
/* clipped */
|
||||
v->v.rhw = 1.0;
|
||||
v->rhw = 1.0;
|
||||
}
|
||||
proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride);
|
||||
}
|
||||
if (IND & TDFX_RGBA_BIT) {
|
||||
GLubyte *b = (GLubyte *)((GLuint *)v + 4);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(b[0], col[0][2]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(b[1], col[0][1]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(b[2], col[0][0]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(b[3], col[0][3]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->color[0], col[0][2]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->color[1], col[0][1]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->color[2], col[0][0]);
|
||||
if (col_size == 4) {
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(v->color[3], col[0][3]);
|
||||
} else {
|
||||
v->color[3] = 255;
|
||||
}
|
||||
STRIDE_4F(col, col_stride);
|
||||
}
|
||||
if (IND & TDFX_FOGC_BIT) {
|
||||
v->fog = CLAMP(fog[0][0], 0.0f, 1.0f);
|
||||
STRIDE_4F(fog, fog_stride);
|
||||
}
|
||||
if (IND & TDFX_TEX0_BIT) {
|
||||
GLfloat w = v->v.rhw;
|
||||
GLfloat w = v->rhw;
|
||||
v->tu0 = tc0[0][0] * u0scale * w;
|
||||
v->tv0 = tc0[0][1] * v0scale * w;
|
||||
if (IND & TDFX_PTEX_BIT) {
|
||||
v->pv.tu0 = tc0[0][0] * u0scale * w;
|
||||
v->pv.tv0 = tc0[0][1] * v0scale * w;
|
||||
v->pv.tq0 = w;
|
||||
v->tq0 = w;
|
||||
if (tc0_size == 4)
|
||||
v->pv.tq0 = tc0[0][3] * w;
|
||||
}
|
||||
else {
|
||||
v->v.tu0 = tc0[0][0] * u0scale * w;
|
||||
v->v.tv0 = tc0[0][1] * v0scale * w;
|
||||
v->tq0 = tc0[0][3] * w;
|
||||
}
|
||||
tc0 = (GLfloat (*)[4])((GLubyte *)tc0 + tc0_stride);
|
||||
}
|
||||
if (IND & TDFX_TEX1_BIT) {
|
||||
GLfloat w = v->v.rhw;
|
||||
GLfloat w = v->rhw;
|
||||
v->tu1 = tc1[0][0] * u1scale * w;
|
||||
v->tv1 = tc1[0][1] * v1scale * w;
|
||||
if (IND & TDFX_PTEX_BIT) {
|
||||
v->pv.tu1 = tc1[0][0] * u1scale * w;
|
||||
v->pv.tv1 = tc1[0][1] * v1scale * w;
|
||||
v->pv.tq1 = w;
|
||||
v->tq1 = w;
|
||||
if (tc1_size == 4)
|
||||
v->pv.tq1 = tc1[0][3] * w;
|
||||
}
|
||||
else {
|
||||
v->v.tu1 = tc1[0][0] * u1scale * w;
|
||||
v->v.tv1 = tc1[0][1] * v1scale * w;
|
||||
v->tq1 = tc1[0][3] * w;
|
||||
}
|
||||
tc1 = (GLfloat (*)[4])((GLubyte *)tc1 + tc1_stride);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
#if (IND & TDFX_XYZ_BIT)
|
||||
static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
|
||||
void *dest, GLuint stride )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
GLfloat (*col)[4];
|
||||
GLuint col_stride;
|
||||
GLfloat (*proj)[4] = VB->NdcPtr->data;
|
||||
GLuint proj_stride = VB->NdcPtr->stride;
|
||||
GLfloat *v = (GLfloat *)dest;
|
||||
const GLubyte *mask = VB->ClipMask;
|
||||
const GLfloat *s = fxMesa->hw_viewport;
|
||||
int i;
|
||||
|
||||
/* fprintf(stderr, "%s %d..%d dest %p stride %d\n", __FUNCTION__, */
|
||||
/* start, end, dest, stride); */
|
||||
|
||||
ASSERT(fxMesa->SetupIndex == (TDFX_XYZ_BIT|TDFX_RGBA_BIT));
|
||||
ASSERT(stride == 16);
|
||||
|
||||
col = VB->ColorPtr[0]->data;
|
||||
col_stride = VB->ColorPtr[0]->stride;
|
||||
ASSERT(VB->ColorPtr[0]->Type == GL_UNSIGNED_BYTE);
|
||||
|
||||
/* Pack what's left into a 4-dword vertex. Color is in a different
|
||||
* place, and there is no 'w' coordinate.
|
||||
*/
|
||||
{
|
||||
if (start) {
|
||||
proj = (GLfloat (*)[4])((GLubyte *)proj + start * proj_stride);
|
||||
STRIDE_4F(col, start * col_stride);
|
||||
}
|
||||
|
||||
for (i=start; i < end; i++, v+=4) {
|
||||
if (mask[i] == 0) {
|
||||
v[0] = s[0] * proj[0][0] + s[12];
|
||||
v[1] = s[5] * proj[0][1] + s[13];
|
||||
v[2] = s[10] * proj[0][2] + s[14];
|
||||
}
|
||||
proj = (GLfloat (*)[4])((GLubyte *)proj + proj_stride);
|
||||
{
|
||||
GLubyte *b = (GLubyte *)&v[3];
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(b[0], col[0][2]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(b[1], col[0][1]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(b[2], col[0][0]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(b[3], col[0][3]);
|
||||
STRIDE_4F(col, col_stride);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
#else
|
||||
static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
|
||||
void *dest, GLuint stride )
|
||||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT(ctx);
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
GLfloat (*col)[4];
|
||||
GLuint col_stride;
|
||||
GLfloat *v = (GLfloat *)dest;
|
||||
int i;
|
||||
|
||||
col = VB->ColorPtr[0]->data;
|
||||
col_stride = VB->ColorPtr[0]->stride;
|
||||
|
||||
if (start)
|
||||
STRIDE_4F(col, col_stride * start);
|
||||
|
||||
/* Need to figure out where color is:
|
||||
*/
|
||||
if (fxMesa->SetupIndex & TDFX_W_BIT )
|
||||
v += 4;
|
||||
else
|
||||
v += 3;
|
||||
|
||||
for (i=start; i < end; i++, STRIDE_F(v, stride)) {
|
||||
GLubyte *b = (GLubyte *)v;
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(b[0], col[0][2]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(b[1], col[0][1]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(b[2], col[0][0]);
|
||||
UNCLAMPED_FLOAT_TO_UBYTE(b[3], col[0][3]);
|
||||
STRIDE_4F(col, col_stride);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if (IND & TDFX_XYZ_BIT) && (IND & TDFX_RGBA_BIT)
|
||||
|
||||
static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
|
||||
{
|
||||
|
@ -231,6 +182,7 @@ static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
|
|||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
static void TAG(interp)( GLcontext *ctx,
|
||||
GLfloat t,
|
||||
GLuint edst, GLuint eout, GLuint ein,
|
||||
|
@ -238,69 +190,44 @@ static void TAG(interp)( GLcontext *ctx,
|
|||
{
|
||||
tdfxContextPtr fxMesa = TDFX_CONTEXT( ctx );
|
||||
struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
|
||||
const GLuint shift = fxMesa->vertex_stride_shift;
|
||||
const GLfloat *dstclip = VB->ClipPtr->data[edst];
|
||||
const GLfloat oow = (dstclip[3] == 0.0F) ? 1.0F : (1.0F / dstclip[3]);
|
||||
const GLfloat *s = fxMesa->hw_viewport;
|
||||
GLubyte *tdfxverts = (GLubyte *)fxMesa->verts;
|
||||
tdfxVertex *dst = (tdfxVertex *) (tdfxverts + (edst << shift));
|
||||
const tdfxVertex *out = (const tdfxVertex *) (tdfxverts + (eout << shift));
|
||||
const tdfxVertex *in = (const tdfxVertex *) (tdfxverts + (ein << shift));
|
||||
const GLfloat wout = 1.0F / out->v.rhw;
|
||||
const GLfloat win = 1.0F / in->v.rhw;
|
||||
tdfxVertex *dst = fxMesa->verts + edst;
|
||||
const tdfxVertex *out = fxMesa->verts + eout;
|
||||
const tdfxVertex *in = fxMesa->verts + ein;
|
||||
const GLfloat wout = oow / out->rhw;
|
||||
const GLfloat win = oow / in->rhw;
|
||||
|
||||
dst->v.x = s[0] * dstclip[0] * oow + s[12];
|
||||
dst->v.y = s[5] * dstclip[1] * oow + s[13];
|
||||
dst->v.z = s[10] * dstclip[2] * oow + s[14];
|
||||
VIEWPORT_X(dst->x, dstclip[0] * oow);
|
||||
VIEWPORT_Y(dst->y, dstclip[1] * oow);
|
||||
VIEWPORT_Z(dst->z, dstclip[2] * oow);
|
||||
dst->rhw = oow;
|
||||
|
||||
if (IND & (TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT)) {
|
||||
dst->v.rhw = oow;
|
||||
|
||||
INTERP_UB( t, dst->ub4[4][0], out->ub4[4][0], in->ub4[4][0] );
|
||||
INTERP_UB( t, dst->ub4[4][1], out->ub4[4][1], in->ub4[4][1] );
|
||||
INTERP_UB( t, dst->ub4[4][2], out->ub4[4][2], in->ub4[4][2] );
|
||||
INTERP_UB( t, dst->ub4[4][3], out->ub4[4][3], in->ub4[4][3] );
|
||||
INTERP_UB( t, dst->color[0], out->color[0], in->color[0] );
|
||||
INTERP_UB( t, dst->color[1], out->color[1], in->color[1] );
|
||||
INTERP_UB( t, dst->color[2], out->color[2], in->color[2] );
|
||||
INTERP_UB( t, dst->color[3], out->color[3], in->color[3] );
|
||||
|
||||
if (IND & TDFX_TEX0_BIT) {
|
||||
if (IND & TDFX_PTEX_BIT) {
|
||||
INTERP_F( t, dst->pv.tu0, out->pv.tu0 * wout, in->pv.tu0 * win );
|
||||
INTERP_F( t, dst->pv.tv0, out->pv.tv0 * wout, in->pv.tv0 * win );
|
||||
INTERP_F( t, dst->pv.tq0, out->pv.tq0 * wout, in->pv.tq0 * win );
|
||||
dst->pv.tu0 *= oow;
|
||||
dst->pv.tv0 *= oow;
|
||||
dst->pv.tq0 *= oow;
|
||||
} else {
|
||||
INTERP_F( t, dst->v.tu0, out->v.tu0 * wout, in->v.tu0 * win );
|
||||
INTERP_F( t, dst->v.tv0, out->v.tv0 * wout, in->v.tv0 * win );
|
||||
dst->v.tu0 *= oow;
|
||||
dst->v.tv0 *= oow;
|
||||
}
|
||||
if (IND & TDFX_FOGC_BIT) {
|
||||
INTERP_F( t, dst->fog, out->fog, in->fog );
|
||||
}
|
||||
|
||||
if (IND & TDFX_TEX0_BIT) {
|
||||
INTERP_F( t, dst->tu0, out->tu0 * wout, in->tu0 * win );
|
||||
INTERP_F( t, dst->tv0, out->tv0 * wout, in->tv0 * win );
|
||||
if (IND & TDFX_PTEX_BIT) {
|
||||
INTERP_F( t, dst->tq0, out->tq0 * wout, in->tq0 * win );
|
||||
}
|
||||
if (IND & TDFX_TEX1_BIT) {
|
||||
if (IND & TDFX_PTEX_BIT) {
|
||||
INTERP_F( t, dst->pv.tu1, out->pv.tu1 * wout, in->pv.tu1 * win );
|
||||
INTERP_F( t, dst->pv.tv1, out->pv.tv1 * wout, in->pv.tv1 * win );
|
||||
INTERP_F( t, dst->pv.tq1, out->pv.tq1 * wout, in->pv.tq1 * win );
|
||||
dst->pv.tu1 *= oow;
|
||||
dst->pv.tv1 *= oow;
|
||||
dst->pv.tq1 *= oow;
|
||||
} else {
|
||||
INTERP_F( t, dst->v.tu1, out->v.tu1 * wout, in->v.tu1 * win );
|
||||
INTERP_F( t, dst->v.tv1, out->v.tv1 * wout, in->v.tv1 * win );
|
||||
dst->v.tu1 *= oow;
|
||||
dst->v.tv1 *= oow;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* 4-dword vertex. Color is in v[3] and there is no oow coordinate.
|
||||
*/
|
||||
INTERP_UB( t, dst->ub4[3][0], out->ub4[3][0], in->ub4[3][0] );
|
||||
INTERP_UB( t, dst->ub4[3][1], out->ub4[3][1], in->ub4[3][1] );
|
||||
INTERP_UB( t, dst->ub4[3][2], out->ub4[3][2], in->ub4[3][2] );
|
||||
INTERP_UB( t, dst->ub4[3][3], out->ub4[3][3], in->ub4[3][3] );
|
||||
}
|
||||
if (IND & TDFX_TEX1_BIT) {
|
||||
INTERP_F( t, dst->tu1, out->tu1 * wout, in->tu1 * win );
|
||||
INTERP_F( t, dst->tv1, out->tv1 * wout, in->tv1 * win );
|
||||
if (IND & TDFX_PTEX_BIT) {
|
||||
INTERP_F( t, dst->tq1, out->tq1 * wout, in->tq1 * win );
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void TAG(init)( void )
|
||||
|
@ -308,50 +235,30 @@ static void TAG(init)( void )
|
|||
/* fprintf(stderr, "%s\n", __FUNCTION__); */
|
||||
|
||||
setup_tab[IND].emit = TAG(emit);
|
||||
|
||||
#if ((IND & TDFX_XYZ_BIT) && (IND & TDFX_RGBA_BIT))
|
||||
setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
|
||||
setup_tab[IND].interp = TAG(interp);
|
||||
|
||||
if (IND & (TDFX_W_BIT|TDFX_TEX0_BIT|TDFX_TEX1_BIT))
|
||||
setup_tab[IND].copy_pv = copy_pv_rgba4;
|
||||
else
|
||||
setup_tab[IND].copy_pv = copy_pv_rgba3;
|
||||
|
||||
setup_tab[IND].copy_pv = copy_pv;
|
||||
|
||||
if (IND & TDFX_TEX1_BIT) {
|
||||
if (IND & TDFX_PTEX_BIT) {
|
||||
setup_tab[IND].vertex_format = TDFX_LAYOUT_PROJECT;
|
||||
setup_tab[IND].vertex_size = 12;
|
||||
setup_tab[IND].vertex_stride_shift = 6;
|
||||
setup_tab[IND].vertex_format = TDFX_LAYOUT_PROJ2;
|
||||
}
|
||||
else {
|
||||
setup_tab[IND].vertex_format = TDFX_LAYOUT_MULTI;
|
||||
setup_tab[IND].vertex_size = 10;
|
||||
setup_tab[IND].vertex_stride_shift = 6;
|
||||
}
|
||||
}
|
||||
else if (IND & TDFX_TEX0_BIT) {
|
||||
if (IND & TDFX_PTEX_BIT) {
|
||||
setup_tab[IND].vertex_format = TDFX_LAYOUT_PROJECT;
|
||||
setup_tab[IND].vertex_size = 12;
|
||||
setup_tab[IND].vertex_stride_shift = 6;
|
||||
setup_tab[IND].vertex_format = TDFX_LAYOUT_PROJ1;
|
||||
} else {
|
||||
setup_tab[IND].vertex_format = TDFX_LAYOUT_SINGLE;
|
||||
setup_tab[IND].vertex_size = 8;
|
||||
setup_tab[IND].vertex_stride_shift = 5;
|
||||
}
|
||||
}
|
||||
else if (IND & TDFX_W_BIT) {
|
||||
setup_tab[IND].vertex_format = TDFX_LAYOUT_NOTEX;
|
||||
setup_tab[IND].vertex_size = 6;
|
||||
setup_tab[IND].vertex_stride_shift = 5;
|
||||
} else {
|
||||
setup_tab[IND].vertex_format = TDFX_LAYOUT_TINY;
|
||||
setup_tab[IND].vertex_size = 4;
|
||||
setup_tab[IND].vertex_stride_shift = 4;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue