-
/*
* Mesa 3-D graphics library
- * Version: 3.3
+ * Version: 4.0
*
- * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2001 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"),
* 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.
- *
- *
- * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
- * terms stated above.
- *
- * Thank you for your contribution, David!
- *
- * Please make note of the above copyright/license statement. If you
- * contributed code or bug fixes to this code under the previous (GNU
- * Library) license and object to the new license, your code will be
- * removed at your request. Please see the Mesa docs/COPYRIGHT file
- * for more information.
- *
- * Additional Mesa/3Dfx driver developers:
- * Daryll Strauss <daryll@precisioninsight.com>
- * Keith Whitwell <keith@precisioninsight.com>
- *
- * See fxapi.h for more revision/author details.
*/
+/* Authors:
+ * David Bucciarelli
+ * Brian Paul
+ * Daryll Strauss
+ * Keith Whitwell
+ * Daniel Borca
+ * Hiroshi Morii
+ */
+
+/* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */
+
#ifndef FXDRV_H
#define FXDRV_H
#endif
#include "context.h"
+#include "imports.h"
#include "macros.h"
#include "matrix.h"
-#include "mem.h"
#include "mtypes.h"
#include "GL/fxmesa.h"
#include "math/m_vector.h"
+#define COPY_FLOAT(dst, src) (dst) = (src)
+
/* Define some shorter names for these things.
*/
#define XCOORD GR_VERTEX_X_OFFSET
#define ZCOORD GR_VERTEX_OOZ_OFFSET
#define OOWCOORD GR_VERTEX_OOW_OFFSET
-#define RCOORD GR_VERTEX_R_OFFSET
-#define GCOORD GR_VERTEX_G_OFFSET
-#define BCOORD GR_VERTEX_B_OFFSET
-#define ACOORD GR_VERTEX_A_OFFSET
-
#define S0COORD GR_VERTEX_SOW_TMU0_OFFSET
#define T0COORD GR_VERTEX_TOW_TMU0_OFFSET
#define S1COORD GR_VERTEX_SOW_TMU1_OFFSET
#define T1COORD GR_VERTEX_TOW_TMU1_OFFSET
-extern float gl_ubyte_to_float_255_color_tab[256];
-#define UBYTE_COLOR_TO_FLOAT_255_COLOR(c) gl_ubyte_to_float_255_color_tab[c]
-#define UBYTE_COLOR_TO_FLOAT_255_COLOR2(f,c) \
- (*(int *)&(f)) = ((int *)gl_ubyte_to_float_255_color_tab)[c]
-
-
-
-
-/* Should have size == 16 * sizeof(float).
- */
-typedef union
-{
- GrVertex v;
- GLfloat f[16];
- GLuint ui[16];
-}
-fxVertex;
-
-/* Used in the fxvtxfmt t&l engine.
- */
-typedef struct
-{
- GrVertex v;
- GLfloat clip[4];
- GLfloat texcoord[2][2];
- GLubyte mask;
- GLfloat normal[3]; /* for replay & fallback */
-}
-fxClipVertex;
-
-
-typedef void (*vfmt_project_func) (GLcontext * ctx, fxClipVertex * v);
-typedef void (*vfmt_interpolate_func) (GLfloat t,
- fxClipVertex * O,
- const fxClipVertex * I,
- const fxClipVertex * J);
-
-
-
-#if defined(FXMESA_USE_ARGB)
-#define FXCOLOR4( c ) ( \
- ( ((unsigned int)(c[3]))<<24 ) | \
- ( ((unsigned int)(c[0]))<<16 ) | \
- ( ((unsigned int)(c[1]))<<8 ) | \
- ( (unsigned int)(c[2])) )
-
-#else
#ifdef __i386__
#define FXCOLOR4( c ) (* (int *)c)
#else
( ((unsigned int)(c[1]))<<8 ) | \
( (unsigned int)(c[0])) )
#endif
-#endif
+
+#define TDFXPACKCOLOR1555( r, g, b, a ) \
+ ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
+ ((a) ? 0x8000 : 0))
+#define TDFXPACKCOLOR565( r, g, b ) \
+ ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
+#define TDFXPACKCOLOR8888( r, g, b, a ) \
+ (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
-/* fastpath/vtxfmt flags first
+/* fastpath flags first
*/
#define SETUP_TMU0 0x1
#define SETUP_TMU1 0x2
#define SETUP_RGBA 0x4
#define SETUP_SNAP 0x8
#define SETUP_XYZW 0x10
-#define MAX_SETUP 0x20
+#define SETUP_PTEX 0x20
+#define SETUP_PSIZ 0x40
+#define SETUP_SPEC 0x80
+#define SETUP_FOGC 0x100
+#define MAX_SETUP 0x200
#define FX_NUM_TMU 2
#define FX_UM_ALPHA_CONSTANT 0x08000000
+/* for Voodoo3/Banshee's grColorCombine() and grAlphaCombine() */
+struct tdfx_combine {
+ GrCombineFunction_t Function; /* Combine function */
+ GrCombineFactor_t Factor; /* Combine scale factor */
+ GrCombineLocal_t Local; /* Local combine source */
+ GrCombineOther_t Other; /* Other combine source */
+ FxBool Invert; /* Combine result inversion flag */
+};
+
+/* for Voodoo3's grTexCombine() */
+struct tdfx_texcombine {
+ GrCombineFunction_t FunctionRGB;
+ GrCombineFactor_t FactorRGB;
+ GrCombineFunction_t FunctionAlpha;
+ GrCombineFactor_t FactorAlpha;
+ FxBool InvertRGB;
+ FxBool InvertAlpha;
+};
+
+
+/* for Voodoo5's grColorCombineExt() */
+struct tdfx_combine_color_ext {
+ GrCCUColor_t SourceA;
+ GrCombineMode_t ModeA;
+ GrCCUColor_t SourceB;
+ GrCombineMode_t ModeB;
+ GrCCUColor_t SourceC;
+ FxBool InvertC;
+ GrCCUColor_t SourceD;
+ FxBool InvertD;
+ FxU32 Shift;
+ FxBool Invert;
+};
+
+/* for Voodoo5's grAlphaCombineExt() */
+struct tdfx_combine_alpha_ext {
+ GrACUColor_t SourceA;
+ GrCombineMode_t ModeA;
+ GrACUColor_t SourceB;
+ GrCombineMode_t ModeB;
+ GrACUColor_t SourceC;
+ FxBool InvertC;
+ GrACUColor_t SourceD;
+ FxBool InvertD;
+ FxU32 Shift;
+ FxBool Invert;
+};
+
+/* for Voodoo5's grTexColorCombineExt() */
+struct tdfx_color_texenv {
+ GrTCCUColor_t SourceA;
+ GrCombineMode_t ModeA;
+ GrTCCUColor_t SourceB;
+ GrCombineMode_t ModeB;
+ GrTCCUColor_t SourceC;
+ FxBool InvertC;
+ GrTCCUColor_t SourceD;
+ FxBool InvertD;
+ FxU32 Shift;
+ FxBool Invert;
+};
+
+/* for Voodoo5's grTexAlphaCombineExt() */
+struct tdfx_alpha_texenv {
+ GrTACUColor_t SourceA;
+ GrCombineMode_t ModeA;
+ GrTACUColor_t SourceB;
+ GrCombineMode_t ModeB;
+ GrTACUColor_t SourceC;
+ FxBool InvertC;
+ GrTCCUColor_t SourceD;
+ FxBool InvertD;
+ FxU32 Shift;
+ FxBool Invert;
+};
+
+/* Voodoo5's texture combine environment */
+struct tdfx_texcombine_ext {
+ struct tdfx_alpha_texenv Alpha;
+ struct tdfx_color_texenv Color;
+ GrColor_t EnvColor;
+};
+
+
/*
Memory range from startAddr to endAddr-1
*/
*/
typedef struct tfxTexInfo_t
{
- struct tfxTexInfo *next;
+ struct tfxTexInfo_t *next;
struct gl_texture_object *tObj;
GLuint lastTimeUsed;
GrMipMapMode_t mmMode;
GLfloat sScale, tScale;
- GLint int_sScale, int_tScale; /* x86 floating point trick for
- * multiplication by powers of 2.
- * Used in fxfasttmp.h
- */
+ GrTexTable_t paltype;
GuTexPalette palette;
GLboolean fixedPalette;
GLboolean validated;
+
+ GLboolean padded;
}
tfxTexInfo;
GLboolean alphaTestEnabled;
GrCmpFnc_t alphaTestFunc;
- GrAlpha_t alphaTestRefValue;
+ GLfloat alphaTestRefValue;
/* Blend function */
GrAlphaBlendFnc_t blendDstFuncRGB;
GrAlphaBlendFnc_t blendSrcFuncAlpha;
GrAlphaBlendFnc_t blendDstFuncAlpha;
+ GrAlphaBlendOp_t blendEqRGB;
+ GrAlphaBlendOp_t blendEqAlpha;
/* Depth test */
GLboolean depthTestEnabled;
GLboolean depthMask;
GrCmpFnc_t depthTestFunc;
+ FxI32 depthBias;
+
+ /* Stencil */
+
+ GLboolean stencilEnabled;
+ GrCmpFnc_t stencilFunction; /* Stencil function */
+ GrStencil_t stencilRefValue; /* Stencil reference value */
+ GrStencil_t stencilValueMask; /* Value mask */
+ GrStencil_t stencilWriteMask; /* Write mask */
+ GrCmpFnc_t stencilFailFunc; /* Stencil fail function */
+ GrCmpFnc_t stencilZFailFunc; /* Stencil pass, depth fail function */
+ GrCmpFnc_t stencilZPassFunc; /* Stencil pass, depth pass function */
+ GrStencil_t stencilClear; /* Buffer clear value */
}
tfxUnitsState;
#define FX_NEW_SCISSOR 0x20
#define FX_NEW_COLOR_MASK 0x40
#define FX_NEW_CULL 0x80
+#define FX_NEW_STENCIL 0x100
#define FX_CONTEXT(ctx) ((fxMesaContext)((ctx)->DriverCtx))
_DD_NEW_POINT_SIZE | \
_NEW_LINE)
+
/* Covers the state referenced by fxDDChooseSetupFunction.
*/
#define _FX_NEW_SETUP_FUNCTION (_NEW_LIGHT| \
_NEW_COLOR) \
-/* Covers the state referenced in fxDDCheckVtxfmt.
- */
-#define _FX_NEW_VTXFMT (_NEW_TEXTURE | \
- _NEW_TEXTURE_MATRIX | \
- _NEW_TRANSFORM | \
- _NEW_LIGHT | \
- _NEW_PROJECTION | \
- _NEW_MODELVIEW | \
- _TNL_NEW_NEED_EYE_COORDS | \
- _FX_NEW_RENDERSTATE)
-
-
-/* These lookup table are used to extract RGB values in [0,255] from
- * 16-bit pixel values.
- */
-extern GLubyte FX_PixelToR[0x10000];
-extern GLubyte FX_PixelToG[0x10000];
-extern GLubyte FX_PixelToB[0x10000];
-
+/* lookup table for scaling y bit colors up to 8 bits */
+extern GLuint FX_rgb_scale_4[16];
+extern GLuint FX_rgb_scale_5[32];
+extern GLuint FX_rgb_scale_6[64];
-typedef void (*fx_tri_func) (GLcontext *, const fxVertex *,
- const fxVertex *, const fxVertex *);
-typedef void (*fx_line_func) (GLcontext *, const fxVertex *,
- const fxVertex *);
-typedef void (*fx_point_func) (GLcontext *, const fxVertex *);
+typedef void (*fx_tri_func) (fxMesaContext, GrVertex *, GrVertex *, GrVertex *);
+typedef void (*fx_line_func) (fxMesaContext, GrVertex *, GrVertex *);
+typedef void (*fx_point_func) (fxMesaContext, GrVertex *);
struct tfxMesaContext
{
+ GrTexTable_t glbPalType;
GuTexPalette glbPalette;
GLcontext *glCtx; /* the core Mesa context */
tfxUnitsState unitsState;
tfxUnitsState restoreUnitsState; /* saved during multipass */
-
+ GLboolean multipass; /* true when drawing intermediate pass */
GLuint new_state;
+ GLuint new_gl_state;
- /* Texture Memory Manager Data
+ /* Texture Memory Manager Data
*/
GLuint texBindNumber;
GLint tmuSrc;
GLfloat fogStart, fogEnd;
GrFog_t *fogTable;
GLint textureAlign;
+ GLint textureMaxLod;
/* Vertex building and storage:
*/
GLuint tmu_source[FX_NUM_TMU];
- GLuint tex_dest[MAX_TEXTURE_UNITS];
- GLuint setupindex;
- GLuint setup_gone; /* for multipass */
+ GLuint SetupIndex;
GLuint stw_hint_state; /* for grHints */
- fxVertex *verts;
-
+ GrVertex *verts;
+ GLboolean snapVertices; /* needed for older Voodoo hardware */
/* Rasterization:
*/
GLuint render_index;
- GLuint passes, multipass;
- GLuint is_in_hardware;
- GLenum render_prim;
+ GLuint fallback;
+ GLenum render_primitive;
+ GLenum raster_primitive;
- /* Current rasterization functions
+ /* Current rasterization functions
*/
fx_point_func draw_point;
fx_line_func draw_line;
fx_tri_func draw_tri;
- /* System to turn culling on/off for tris/lines/points.
- */
- fx_point_func initial_point;
- fx_line_func initial_line;
- fx_tri_func initial_tri;
-
- fx_point_func subsequent_point;
- fx_line_func subsequent_line;
- fx_tri_func subsequent_tri;
/* Keep texture scales somewhere handy:
*/
GLboolean verbose;
GLboolean haveTwoTMUs; /* True if we really have 2 tmu's */
- GLboolean emulateTwoTMUs; /* True if we present 2 tmu's to mesa. */
- GLboolean haveAlphaBuffer;
+ GLboolean haveHwAlpha;
+ GLboolean haveHwStencil;
GLboolean haveZBuffer;
GLboolean haveDoubleBuffer;
GLboolean haveGlobalPaletteTexture;
GLint swapInterval;
GLint maxPendingSwapBuffers;
- FX_GrContext_t glideContext;
+ GrContext_t glideContext;
int screen_width;
int screen_height;
- int initDone;
int clipMinX;
int clipMaxX;
int clipMinY;
int clipMaxY;
- /* fxvtxfmt
- */
- GLboolean allow_vfmt;
- GLvertexformat vtxfmt;
- fxClipVertex current;
- fxClipVertex *vert; /* points into verts[] */
- void (*fire_on_vertex) (GLcontext *);
- void (*fire_on_end) (GLcontext *);
- void (*fire_on_fallback) (GLcontext *);
-
- vfmt_project_func project_vertex;
- vfmt_interpolate_func interpolate_vertices;
-
- int vtxfmt_fallback_count;
- int vtxfmt_installed;
- void (*old_begin) (GLenum);
- GLenum prim;
-
- GLuint accel_light;
- GLfloat basecolor[4];
+ int colDepth;
+ GLboolean fsaa;
-
- /* Projected vertices, fastpath data:
+ /* Glide (per card) capabilities. These get mirrored
+ * from `glbHWConfig' when creating a new context...
*/
- GLvector1ui clipped_elements;
- fxVertex *last_vert;
- GLuint size;
+ GrSstType type;
+ FxBool HavePalExt; /* PALETTE6666 */
+ FxBool HavePixExt; /* PIXEXT */
+ FxBool HaveTexFmt; /* TEXFMT */
+ FxBool HaveCmbExt; /* COMBINE */
+ FxBool HaveMirExt; /* TEXMIRROR */
+ FxBool HaveTexUma; /* TEXUMA */
+ FxBool HaveTexus2; /* Texus 2 - FXT1 */
+ struct tdfx_glide Glide;
+ char rendererString[64];
};
-typedef void (*tfxSetupFunc) (GLcontext * ctx, GLuint, GLuint);
-
-extern GrHwConfiguration glbHWConfig;
-extern int glbCurrentBoard;
extern void fxSetupFXUnits(GLcontext *);
extern void fxSetupDDPointers(GLcontext *);
-/* fxvsetup:
+/* fxvb.c:
*/
-extern void fxDDSetupInit(void);
extern void fxAllocVB(GLcontext * ctx);
extern void fxFreeVB(GLcontext * ctx);
-extern void fxPrintSetupFlags(const char *msg, GLuint flags);
-extern void fx_BuildProjVerts(GLcontext * ctx,
- GLuint start, GLuint count, GLuint newinputs);
-extern void fx_validate_BuildProjVerts(GLcontext * ctx,
- GLuint start, GLuint count,
- GLuint newinputs);
+extern void fxPrintSetupFlags(char *msg, GLuint flags );
+extern void fxCheckTexSizes( GLcontext *ctx );
+extern void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint end,
+ GLuint newinputs );
+extern void fxChooseVertexState( GLcontext *ctx );
+
+
+
+
+
/* fxtrifuncs:
*/
-extern void fxDDTrifuncInit(void);
+extern void fxDDInitTriFuncs(GLcontext *);
extern void fxDDChooseRenderState(GLcontext * ctx);
extern void fxSetupDDSpanPointers(GLcontext *);
extern void fxPrintTextureData(tfxTexInfo * ti);
+
+extern const struct gl_texture_format *
+fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
+ GLenum srcFormat, GLenum srcType );
extern void fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
GLint internalFormat, GLint width, GLint height,
GLint border, GLenum format, GLenum type,
const struct gl_pixelstore_attrib *packing,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage);
-
extern void fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
GLint xoffset, GLint yoffset,
GLsizei width, GLsizei height,
const struct gl_pixelstore_attrib *packing,
struct gl_texture_object *texObj,
struct gl_texture_image *texImage);
+extern void fxDDCompressedTexImage2D(GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLsizei width, GLsizei height, GLint border,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+extern void fxDDCompressedTexSubImage2D(GLcontext *ctx, GLenum target,
+ GLint level, GLint xoffset,
+ GLint yoffset, GLsizei width,
+ GLint height, GLenum format,
+ GLsizei imageSize, const GLvoid *data,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+extern void fxDDTexImage1D(GLcontext * ctx, GLenum target, GLint level,
+ GLint internalFormat, GLint width,
+ GLint border, GLenum format, GLenum type,
+ const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+extern void fxDDTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
+ GLint xoffset, GLint width,
+ GLenum format, GLenum type,
+ const GLvoid * pixels,
+ const struct gl_pixelstore_attrib *packing,
+ struct gl_texture_object *texObj,
+ struct gl_texture_image *texImage);
+extern GLboolean fxDDTestProxyTexImage (GLcontext *ctx, GLenum target,
+ GLint level, GLint internalFormat,
+ GLenum format, GLenum type,
+ GLint width, GLint height,
+ GLint depth, GLint border);
extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *);
extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *,
GLenum, const GLfloat *);
extern void fxDDTexBind(GLcontext *, GLenum, struct gl_texture_object *);
+extern struct gl_texture_object *fxDDNewTextureObject( GLcontext *ctx, GLuint name, GLenum target );
extern void fxDDTexDel(GLcontext *, struct gl_texture_object *);
+extern GLboolean fxDDIsTextureResident(GLcontext *, struct gl_texture_object *);
extern void fxDDTexPalette(GLcontext *, struct gl_texture_object *);
extern void fxDDTexUseGlbPalette(GLcontext *, GLboolean);
extern void fxDDEnable(GLcontext *, GLenum, GLboolean);
-extern void fxDDAlphaFunc(GLcontext *, GLenum, GLchan);
-extern void fxDDBlendFunc(GLcontext *, GLenum, GLenum);
+extern void fxDDAlphaFunc(GLcontext *, GLenum, GLfloat);
+extern void fxDDBlendFuncSeparate(GLcontext *, GLenum, GLenum, GLenum, GLenum);
+extern void fxDDBlendEquationSeparate(GLcontext *, GLenum, GLenum);
extern void fxDDDepthMask(GLcontext *, GLboolean);
extern void fxDDDepthFunc(GLcontext *, GLenum);
+extern void fxDDStencilFuncSeparate (GLcontext *ctx, GLenum face, GLenum func, GLint ref, GLuint mask);
+extern void fxDDStencilMaskSeparate (GLcontext *ctx, GLenum face, GLuint mask);
+extern void fxDDStencilOpSeparate (GLcontext *ctx, GLenum face, GLenum sfail, GLenum zfail, GLenum zpass);
extern void fxDDInitExtensions(GLcontext * ctx);
extern void fxTMReloadSubMipMapLevel(fxMesaContext,
struct gl_texture_object *, GLint, GLint,
GLint);
+extern int fxTMCheckStartAddr (fxMesaContext fxMesa, GLint tmu, tfxTexInfo *ti);
+
+extern void fxTexGetFormat(GLcontext *, GLenum, GrTextureFormat_t *, GLint *); /* [koolsmoky] */
-extern void fxTexGetFormat(GLenum, GrTextureFormat_t *, GLint *);
extern int fxTexGetInfo(int, int, GrLOD_t *, GrAspectRatio_t *,
- float *, float *, int *, int *, int *, int *);
+ float *, float *, int *, int *);
extern void fxDDScissor(GLcontext * ctx,
GLint x, GLint y, GLsizei w, GLsizei h);
GLboolean r, GLboolean g, GLboolean b, GLboolean a);
extern void fxDDWriteDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
- const GLdepth depth[], const GLubyte mask[]);
+ const GLuint depth[], const GLubyte mask[]);
extern void fxDDReadDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
- GLdepth depth[]);
+ GLuint depth[]);
extern void fxDDWriteDepthPixels(GLcontext * ctx, GLuint n,
const GLint x[], const GLint y[],
- const GLdepth depth[], const GLubyte mask[]);
+ const GLuint depth[], const GLubyte mask[]);
extern void fxDDReadDepthPixels(GLcontext * ctx, GLuint n,
const GLint x[], const GLint y[],
- GLdepth depth[]);
+ GLuint depth[]);
extern void fxDDShadeModel(GLcontext * ctx, GLenum mode);
extern void fxDDDestroyFxMesaContext(fxMesaContext fxMesa);
-
-
extern void fxSetScissorValues(GLcontext * ctx);
extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa,
struct gl_texture_object *tObj, GLint where);
-extern void fxInitPixelTables(fxMesaContext fxMesa, GLboolean bgrOrder);
+extern void fxCheckIsInHardware(GLcontext *ctx);
-/* fxvtxfmt:
+/* fxsetup:
+ * semi-private functions
*/
-extern void fxDDCheckVtxfmt(GLcontext * ctx);
-extern void fx_update_lighting(GLcontext * ctx);
-extern void fxDDInitVtxfmt(GLcontext * ctx);
+void fxSetupCull (GLcontext * ctx);
+void fxSetupScissor (GLcontext * ctx);
+void fxSetupColorMask (GLcontext * ctx);
+void fxSetupBlend (GLcontext *ctx);
+void fxSetupDepthTest (GLcontext *ctx);
+void fxSetupTexture (GLcontext *ctx);
+void fxSetupStencil (GLcontext *ctx);
+void fxSetupStencilFace (GLcontext *ctx, GLint face);
+
+/* Flags for software fallback cases */
+#define FX_FALLBACK_TEXTURE_MAP 0x0001
+#define FX_FALLBACK_DRAW_BUFFER 0x0002
+#define FX_FALLBACK_SPECULAR 0x0004
+#define FX_FALLBACK_STENCIL 0x0008
+#define FX_FALLBACK_RENDER_MODE 0x0010
+#define FX_FALLBACK_LOGICOP 0x0020
+#define FX_FALLBACK_TEXTURE_ENV 0x0040
+#define FX_FALLBACK_TEXTURE_BORDER 0x0080
+#define FX_FALLBACK_COLORMASK 0x0100
+#define FX_FALLBACK_BLEND 0x0200
+#define FX_FALLBACK_TEXTURE_MULTI 0x0400
+
+extern GLuint fx_check_IsInHardware(GLcontext *ctx);
+
+/***
+ *** CNORM: clamp float to [0,1] and map to float in [0,255]
+ ***/
+#if defined(USE_IEEE) && !defined(DEBUG)
+#define IEEE_0996 0x3f7f0000 /* 0.996 or so */
+#define CNORM(N, F) \
+ do { \
+ fi_type __tmp; \
+ __tmp.f = (F); \
+ if (__tmp.i < 0) \
+ N = 0; \
+ else if (__tmp.i >= IEEE_0996) \
+ N = 255.0f; \
+ else { \
+ N = (F) * 255.0f; \
+ } \
+ } while (0)
+#else
+#define CNORM(n, f) \
+ n = (CLAMP((f), 0.0F, 1.0F) * 255.0F)
+#endif
-/* fxsimplerender
- */
-extern const struct gl_pipeline_stage fx_render_stage;
+/* run-time debugging */
+#ifndef FX_DEBUG
+#define FX_DEBUG 0
+#endif
+#if FX_DEBUG
+extern int TDFX_DEBUG;
+#else
+#define TDFX_DEBUG 0
+#endif
+
+/* dirty hacks */
+#define FX_RESCALE_BIG_TEXURES_HACK 1
+#define FX_COMPRESS_S3TC_AS_FXT1_HACK 1
#endif