Replace ctx->Driver.StencilOp/Func/Mask() functions with
[mesa.git] / src / mesa / drivers / glide / fxdrv.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 4.0
4 *
5 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25 /* Authors:
26 * David Bucciarelli
27 * Brian Paul
28 * Daryll Strauss
29 * Keith Whitwell
30 * Daniel Borca
31 * Hiroshi Morii
32 */
33
34 /* fxsetup.c - 3Dfx VooDoo rendering mode setup functions */
35
36
37 #ifndef FXDRV_H
38 #define FXDRV_H
39
40 /* If you comment out this define, a variable takes its place, letting
41 * you turn debugging on/off from the debugger.
42 */
43
44 #include "glheader.h"
45
46
47 #if defined(__linux__)
48 #include <signal.h>
49 #endif
50
51 #include "context.h"
52 #include "imports.h"
53 #include "macros.h"
54 #include "matrix.h"
55 #include "mtypes.h"
56
57 #include "GL/fxmesa.h"
58 #include "fxglidew.h"
59
60 #include "math/m_vector.h"
61
62
63 /* Define some shorter names for these things.
64 */
65 #define XCOORD GR_VERTEX_X_OFFSET
66 #define YCOORD GR_VERTEX_Y_OFFSET
67 #define ZCOORD GR_VERTEX_OOZ_OFFSET
68 #define OOWCOORD GR_VERTEX_OOW_OFFSET
69
70 #define S0COORD GR_VERTEX_SOW_TMU0_OFFSET
71 #define T0COORD GR_VERTEX_TOW_TMU0_OFFSET
72 #define S1COORD GR_VERTEX_SOW_TMU1_OFFSET
73 #define T1COORD GR_VERTEX_TOW_TMU1_OFFSET
74
75
76
77 #ifdef __i386__
78 #define FXCOLOR4( c ) (* (int *)c)
79 #else
80 #define FXCOLOR4( c ) ( \
81 ( ((unsigned int)(c[3]))<<24 ) | \
82 ( ((unsigned int)(c[2]))<<16 ) | \
83 ( ((unsigned int)(c[1]))<<8 ) | \
84 ( (unsigned int)(c[0])) )
85 #endif
86
87 #define TDFXPACKCOLOR1555( r, g, b, a ) \
88 ((((r) & 0xf8) << 7) | (((g) & 0xf8) << 2) | (((b) & 0xf8) >> 3) | \
89 ((a) ? 0x8000 : 0))
90 #define TDFXPACKCOLOR565( r, g, b ) \
91 ((((r) & 0xf8) << 8) | (((g) & 0xfc) << 3) | (((b) & 0xf8) >> 3))
92 #define TDFXPACKCOLOR8888( r, g, b, a ) \
93 (((a) << 24) | ((r) << 16) | ((g) << 8) | (b))
94
95
96
97 /* fastpath flags first
98 */
99 #define SETUP_TMU0 0x1
100 #define SETUP_TMU1 0x2
101 #define SETUP_RGBA 0x4
102 #define SETUP_SNAP 0x8
103 #define SETUP_XYZW 0x10
104 #define SETUP_PTEX 0x20
105 #define SETUP_PSIZ 0x40
106 #define SETUP_SPEC 0x80
107 #define SETUP_FOGC 0x100
108 #define MAX_SETUP 0x200
109
110
111 #define FX_NUM_TMU 2
112
113 #define FX_TMU0 GR_TMU0
114 #define FX_TMU1 GR_TMU1
115 #define FX_TMU_SPLIT 98
116 #define FX_TMU_BOTH 99
117 #define FX_TMU_NONE 100
118
119 /* Used for fxMesa->lastUnitsMode */
120
121 #define FX_UM_NONE 0x00000000
122
123 #define FX_UM_E0_REPLACE 0x00000001
124 #define FX_UM_E0_MODULATE 0x00000002
125 #define FX_UM_E0_DECAL 0x00000004
126 #define FX_UM_E0_BLEND 0x00000008
127 #define FX_UM_E0_ADD 0x00000010
128
129 #define FX_UM_E1_REPLACE 0x00000020
130 #define FX_UM_E1_MODULATE 0x00000040
131 #define FX_UM_E1_DECAL 0x00000080
132 #define FX_UM_E1_BLEND 0x00000100
133 #define FX_UM_E1_ADD 0x00000200
134
135 #define FX_UM_E_ENVMODE 0x000003ff
136
137 #define FX_UM_E0_ALPHA 0x00001000
138 #define FX_UM_E0_LUMINANCE 0x00002000
139 #define FX_UM_E0_LUMINANCE_ALPHA 0x00004000
140 #define FX_UM_E0_INTENSITY 0x00008000
141 #define FX_UM_E0_RGB 0x00010000
142 #define FX_UM_E0_RGBA 0x00020000
143
144 #define FX_UM_E1_ALPHA 0x00040000
145 #define FX_UM_E1_LUMINANCE 0x00080000
146 #define FX_UM_E1_LUMINANCE_ALPHA 0x00100000
147 #define FX_UM_E1_INTENSITY 0x00200000
148 #define FX_UM_E1_RGB 0x00400000
149 #define FX_UM_E1_RGBA 0x00800000
150
151 #define FX_UM_E_IFMT 0x00fff000
152
153 #define FX_UM_COLOR_ITERATED 0x01000000
154 #define FX_UM_COLOR_CONSTANT 0x02000000
155 #define FX_UM_ALPHA_ITERATED 0x04000000
156 #define FX_UM_ALPHA_CONSTANT 0x08000000
157
158
159 /* for Voodoo3/Banshee's grColorCombine() and grAlphaCombine() */
160 struct tdfx_combine {
161 GrCombineFunction_t Function; /* Combine function */
162 GrCombineFactor_t Factor; /* Combine scale factor */
163 GrCombineLocal_t Local; /* Local combine source */
164 GrCombineOther_t Other; /* Other combine source */
165 FxBool Invert; /* Combine result inversion flag */
166 };
167
168 /* for Voodoo3's grTexCombine() */
169 struct tdfx_texcombine {
170 GrCombineFunction_t FunctionRGB;
171 GrCombineFactor_t FactorRGB;
172 GrCombineFunction_t FunctionAlpha;
173 GrCombineFactor_t FactorAlpha;
174 FxBool InvertRGB;
175 FxBool InvertAlpha;
176 };
177
178
179 /* for Voodoo5's grColorCombineExt() */
180 struct tdfx_combine_color_ext {
181 GrCCUColor_t SourceA;
182 GrCombineMode_t ModeA;
183 GrCCUColor_t SourceB;
184 GrCombineMode_t ModeB;
185 GrCCUColor_t SourceC;
186 FxBool InvertC;
187 GrCCUColor_t SourceD;
188 FxBool InvertD;
189 FxU32 Shift;
190 FxBool Invert;
191 };
192
193 /* for Voodoo5's grAlphaCombineExt() */
194 struct tdfx_combine_alpha_ext {
195 GrACUColor_t SourceA;
196 GrCombineMode_t ModeA;
197 GrACUColor_t SourceB;
198 GrCombineMode_t ModeB;
199 GrACUColor_t SourceC;
200 FxBool InvertC;
201 GrACUColor_t SourceD;
202 FxBool InvertD;
203 FxU32 Shift;
204 FxBool Invert;
205 };
206
207 /* for Voodoo5's grTexColorCombineExt() */
208 struct tdfx_color_texenv {
209 GrTCCUColor_t SourceA;
210 GrCombineMode_t ModeA;
211 GrTCCUColor_t SourceB;
212 GrCombineMode_t ModeB;
213 GrTCCUColor_t SourceC;
214 FxBool InvertC;
215 GrTCCUColor_t SourceD;
216 FxBool InvertD;
217 FxU32 Shift;
218 FxBool Invert;
219 };
220
221 /* for Voodoo5's grTexAlphaCombineExt() */
222 struct tdfx_alpha_texenv {
223 GrTACUColor_t SourceA;
224 GrCombineMode_t ModeA;
225 GrTACUColor_t SourceB;
226 GrCombineMode_t ModeB;
227 GrTACUColor_t SourceC;
228 FxBool InvertC;
229 GrTCCUColor_t SourceD;
230 FxBool InvertD;
231 FxU32 Shift;
232 FxBool Invert;
233 };
234
235 /* Voodoo5's texture combine environment */
236 struct tdfx_texcombine_ext {
237 struct tdfx_alpha_texenv Alpha;
238 struct tdfx_color_texenv Color;
239 GrColor_t EnvColor;
240 };
241
242
243 /*
244 Memory range from startAddr to endAddr-1
245 */
246 typedef struct MemRange_t
247 {
248 struct MemRange_t *next;
249 FxU32 startAddr, endAddr;
250 }
251 MemRange;
252
253 typedef struct
254 {
255 GLsizei width, height; /* image size */
256 GLint wScale, hScale; /* image scale factor */
257 GrTextureFormat_t glideFormat; /* Glide image format */
258 }
259 tfxMipMapLevel;
260
261 /*
262 * TDFX-specific texture object data. This hangs off of the
263 * struct gl_texture_object DriverData pointer.
264 */
265 typedef struct tfxTexInfo_t
266 {
267 struct tfxTexInfo_t *next;
268 struct gl_texture_object *tObj;
269
270 GLuint lastTimeUsed;
271 FxU32 whichTMU;
272 GLboolean isInTM;
273
274 MemRange *tm[FX_NUM_TMU];
275
276 GLint minLevel, maxLevel;
277 GLint baseLevelInternalFormat;
278
279 GrTexInfo info;
280
281 GrTextureFilterMode_t minFilt;
282 GrTextureFilterMode_t maxFilt;
283 FxBool LODblend;
284
285 GrTextureClampMode_t sClamp;
286 GrTextureClampMode_t tClamp;
287
288 GrMipMapMode_t mmMode;
289
290 GLfloat sScale, tScale;
291
292 GrTexTable_t paltype;
293 GuTexPalette palette;
294
295 GLboolean fixedPalette;
296 GLboolean validated;
297
298 GLboolean padded;
299 }
300 tfxTexInfo;
301
302 typedef struct
303 {
304 GLuint swapBuffer;
305 GLuint reqTexUpload;
306 GLuint texUpload;
307 GLuint memTexUpload;
308 }
309 tfxStats;
310
311
312
313 typedef struct
314 {
315 /* Alpha test */
316
317 GLboolean alphaTestEnabled;
318 GrCmpFnc_t alphaTestFunc;
319 GLfloat alphaTestRefValue;
320
321 /* Blend function */
322
323 GLboolean blendEnabled;
324 GrAlphaBlendFnc_t blendSrcFuncRGB;
325 GrAlphaBlendFnc_t blendDstFuncRGB;
326 GrAlphaBlendFnc_t blendSrcFuncAlpha;
327 GrAlphaBlendFnc_t blendDstFuncAlpha;
328 GrAlphaBlendOp_t blendEqRGB;
329 GrAlphaBlendOp_t blendEqAlpha;
330
331 /* Depth test */
332
333 GLboolean depthTestEnabled;
334 GLboolean depthMask;
335 GrCmpFnc_t depthTestFunc;
336 FxI32 depthBias;
337
338 /* Stencil */
339
340 GLboolean stencilEnabled;
341 GrCmpFnc_t stencilFunction; /* Stencil function */
342 GrStencil_t stencilRefValue; /* Stencil reference value */
343 GrStencil_t stencilValueMask; /* Value mask */
344 GrStencil_t stencilWriteMask; /* Write mask */
345 GrCmpFnc_t stencilFailFunc; /* Stencil fail function */
346 GrCmpFnc_t stencilZFailFunc; /* Stencil pass, depth fail function */
347 GrCmpFnc_t stencilZPassFunc; /* Stencil pass, depth pass function */
348 GrStencil_t stencilClear; /* Buffer clear value */
349 }
350 tfxUnitsState;
351
352
353
354
355 /* Flags for fxMesa->new_state
356 */
357 #define FX_NEW_TEXTURING 0x1
358 #define FX_NEW_BLEND 0x2
359 #define FX_NEW_ALPHA 0x4
360 #define FX_NEW_DEPTH 0x8
361 #define FX_NEW_FOG 0x10
362 #define FX_NEW_SCISSOR 0x20
363 #define FX_NEW_COLOR_MASK 0x40
364 #define FX_NEW_CULL 0x80
365 #define FX_NEW_STENCIL 0x100
366
367
368 #define FX_CONTEXT(ctx) ((fxMesaContext)((ctx)->DriverCtx))
369
370 #define FX_TEXTURE_DATA(texUnit) fxTMGetTexInfo((texUnit)->_Current)
371
372 #define fxTMGetTexInfo(o) ((tfxTexInfo*)((o)->DriverData))
373
374 #define FX_MIPMAP_DATA(img) ((tfxMipMapLevel *) (img)->DriverData)
375
376 #define BEGIN_BOARD_LOCK()
377 #define END_BOARD_LOCK()
378 #define BEGIN_CLIP_LOOP()
379 #define END_CLIP_LOOP()
380
381
382
383
384 /* Covers the state referenced by IsInHardware:
385 */
386 #define _FX_NEW_IS_IN_HARDWARE (_NEW_TEXTURE| \
387 _NEW_HINT| \
388 _NEW_STENCIL| \
389 _NEW_BUFFERS| \
390 _NEW_COLOR| \
391 _NEW_LIGHT)
392
393 /* Covers the state referenced by fxDDChooseRenderState
394 */
395 #define _FX_NEW_RENDERSTATE (_FX_NEW_IS_IN_HARDWARE | \
396 _DD_NEW_FLATSHADE | \
397 _DD_NEW_TRI_LIGHT_TWOSIDE| \
398 _DD_NEW_TRI_OFFSET | \
399 _DD_NEW_TRI_UNFILLED | \
400 _DD_NEW_TRI_SMOOTH | \
401 _DD_NEW_TRI_STIPPLE | \
402 _DD_NEW_LINE_SMOOTH | \
403 _DD_NEW_LINE_STIPPLE | \
404 _DD_NEW_LINE_WIDTH | \
405 _DD_NEW_POINT_SMOOTH | \
406 _DD_NEW_POINT_SIZE | \
407 _NEW_LINE)
408
409
410 /* Covers the state referenced by fxDDChooseSetupFunction.
411 */
412 #define _FX_NEW_SETUP_FUNCTION (_NEW_LIGHT| \
413 _NEW_FOG| \
414 _NEW_TEXTURE| \
415 _NEW_COLOR) \
416
417
418 /* lookup table for scaling y bit colors up to 8 bits */
419 extern GLuint FX_rgb_scale_4[16];
420 extern GLuint FX_rgb_scale_5[32];
421 extern GLuint FX_rgb_scale_6[64];
422
423 typedef void (*fx_tri_func) (fxMesaContext, GrVertex *, GrVertex *, GrVertex *);
424 typedef void (*fx_line_func) (fxMesaContext, GrVertex *, GrVertex *);
425 typedef void (*fx_point_func) (fxMesaContext, GrVertex *);
426
427 struct tfxMesaContext
428 {
429 GrTexTable_t glbPalType;
430 GuTexPalette glbPalette;
431
432 GLcontext *glCtx; /* the core Mesa context */
433 GLvisual *glVis; /* describes the color buffer */
434 GLframebuffer *glBuffer; /* the ancillary buffers */
435
436 GLint board; /* the board used for this context */
437 GLint width, height; /* size of color buffer */
438
439 GrBuffer_t currentFB;
440
441 GLboolean bgrOrder;
442 GrColor_t color;
443 GrColor_t clearC;
444 GrAlpha_t clearA;
445 GLuint constColor;
446 GrCullMode_t cullMode;
447
448 tfxUnitsState unitsState;
449 tfxUnitsState restoreUnitsState; /* saved during multipass */
450 GLboolean multipass; /* true when drawing intermediate pass */
451
452 GLuint new_state;
453 GLuint new_gl_state;
454
455 /* Texture Memory Manager Data
456 */
457 GLuint texBindNumber;
458 GLint tmuSrc;
459 GLuint lastUnitsMode;
460 GLuint freeTexMem[FX_NUM_TMU];
461 MemRange *tmPool;
462 MemRange *tmFree[FX_NUM_TMU];
463
464 GLenum fogTableMode;
465 GLfloat fogDensity;
466 GLfloat fogStart, fogEnd;
467 GrFog_t *fogTable;
468 GLint textureAlign;
469 GLint textureMaxLod;
470
471 /* Vertex building and storage:
472 */
473 GLuint tmu_source[FX_NUM_TMU];
474 GLuint SetupIndex;
475 GLuint stw_hint_state; /* for grHints */
476 GrVertex *verts;
477 GLboolean snapVertices; /* needed for older Voodoo hardware */
478
479 /* Rasterization:
480 */
481 GLuint render_index;
482 GLuint fallback;
483 GLenum render_primitive;
484 GLenum raster_primitive;
485
486 /* Current rasterization functions
487 */
488 fx_point_func draw_point;
489 fx_line_func draw_line;
490 fx_tri_func draw_tri;
491
492
493 /* Keep texture scales somewhere handy:
494 */
495 GLfloat s0scale;
496 GLfloat s1scale;
497 GLfloat t0scale;
498 GLfloat t1scale;
499
500 GLfloat inv_s0scale;
501 GLfloat inv_s1scale;
502 GLfloat inv_t0scale;
503 GLfloat inv_t1scale;
504
505 /* Glide stuff
506 */
507 tfxStats stats;
508 void *state;
509
510 /* Options */
511
512 GLboolean verbose;
513 GLboolean haveTwoTMUs; /* True if we really have 2 tmu's */
514 GLboolean haveHwAlpha;
515 GLboolean haveHwStencil;
516 GLboolean haveZBuffer;
517 GLboolean haveDoubleBuffer;
518 GLboolean haveGlobalPaletteTexture;
519 GLint swapInterval;
520 GLint maxPendingSwapBuffers;
521
522 GrContext_t glideContext;
523
524 int screen_width;
525 int screen_height;
526 int clipMinX;
527 int clipMaxX;
528 int clipMinY;
529 int clipMaxY;
530
531 int colDepth;
532 GLboolean fsaa;
533
534 /* Glide (per card) capabilities. These get mirrored
535 * from `glbHWConfig' when creating a new context...
536 */
537 GrSstType type;
538 FxBool HavePalExt; /* PALETTE6666 */
539 FxBool HavePixExt; /* PIXEXT */
540 FxBool HaveTexFmt; /* TEXFMT */
541 FxBool HaveCmbExt; /* COMBINE */
542 FxBool HaveMirExt; /* TEXMIRROR */
543 FxBool HaveTexUma; /* TEXUMA */
544 FxBool HaveTexus2; /* Texus 2 - FXT1 */
545 struct tdfx_glide Glide;
546 char rendererString[64];
547 };
548
549
550 extern void fxSetupFXUnits(GLcontext *);
551 extern void fxSetupDDPointers(GLcontext *);
552
553 /* fxvb.c:
554 */
555 extern void fxAllocVB(GLcontext * ctx);
556 extern void fxFreeVB(GLcontext * ctx);
557 extern void fxPrintSetupFlags(char *msg, GLuint flags );
558 extern void fxCheckTexSizes( GLcontext *ctx );
559 extern void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint end,
560 GLuint newinputs );
561 extern void fxChooseVertexState( GLcontext *ctx );
562
563
564
565
566
567
568 /* fxtrifuncs:
569 */
570 extern void fxDDInitTriFuncs(GLcontext *);
571 extern void fxDDChooseRenderState(GLcontext * ctx);
572
573
574 extern void fxUpdateDDSpanPointers(GLcontext *);
575 extern void fxSetupDDSpanPointers(GLcontext *);
576
577 extern void fxPrintTextureData(tfxTexInfo * ti);
578
579 extern const struct gl_texture_format *
580 fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
581 GLenum srcFormat, GLenum srcType );
582 extern void fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
583 GLint internalFormat, GLint width, GLint height,
584 GLint border, GLenum format, GLenum type,
585 const GLvoid * pixels,
586 const struct gl_pixelstore_attrib *packing,
587 struct gl_texture_object *texObj,
588 struct gl_texture_image *texImage);
589 extern void fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
590 GLint xoffset, GLint yoffset,
591 GLsizei width, GLsizei height,
592 GLenum format, GLenum type,
593 const GLvoid * pixels,
594 const struct gl_pixelstore_attrib *packing,
595 struct gl_texture_object *texObj,
596 struct gl_texture_image *texImage);
597 extern void fxDDCompressedTexImage2D(GLcontext *ctx, GLenum target,
598 GLint level, GLint internalFormat,
599 GLsizei width, GLsizei height, GLint border,
600 GLsizei imageSize, const GLvoid *data,
601 struct gl_texture_object *texObj,
602 struct gl_texture_image *texImage);
603 extern void fxDDCompressedTexSubImage2D(GLcontext *ctx, GLenum target,
604 GLint level, GLint xoffset,
605 GLint yoffset, GLsizei width,
606 GLint height, GLenum format,
607 GLsizei imageSize, const GLvoid *data,
608 struct gl_texture_object *texObj,
609 struct gl_texture_image *texImage);
610 extern void fxDDTexImage1D(GLcontext * ctx, GLenum target, GLint level,
611 GLint internalFormat, GLint width,
612 GLint border, GLenum format, GLenum type,
613 const GLvoid * pixels,
614 const struct gl_pixelstore_attrib *packing,
615 struct gl_texture_object *texObj,
616 struct gl_texture_image *texImage);
617 extern void fxDDTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
618 GLint xoffset, GLint width,
619 GLenum format, GLenum type,
620 const GLvoid * pixels,
621 const struct gl_pixelstore_attrib *packing,
622 struct gl_texture_object *texObj,
623 struct gl_texture_image *texImage);
624 extern GLboolean fxDDTestProxyTexImage (GLcontext *ctx, GLenum target,
625 GLint level, GLint internalFormat,
626 GLenum format, GLenum type,
627 GLint width, GLint height,
628 GLint depth, GLint border);
629 extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *);
630 extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *,
631 GLenum, const GLfloat *);
632 extern void fxDDTexBind(GLcontext *, GLenum, struct gl_texture_object *);
633 extern struct gl_texture_object *fxDDNewTextureObject( GLcontext *ctx, GLuint name, GLenum target );
634 extern void fxDDTexDel(GLcontext *, struct gl_texture_object *);
635 extern GLboolean fxDDIsTextureResident(GLcontext *, struct gl_texture_object *);
636 extern void fxDDTexPalette(GLcontext *, struct gl_texture_object *);
637 extern void fxDDTexUseGlbPalette(GLcontext *, GLboolean);
638
639 extern void fxDDEnable(GLcontext *, GLenum, GLboolean);
640 extern void fxDDAlphaFunc(GLcontext *, GLenum, GLfloat);
641 extern void fxDDBlendFuncSeparate(GLcontext *, GLenum, GLenum, GLenum, GLenum);
642 extern void fxDDBlendEquationSeparate(GLcontext *, GLenum, GLenum);
643 extern void fxDDDepthMask(GLcontext *, GLboolean);
644 extern void fxDDDepthFunc(GLcontext *, GLenum);
645 extern void fxDDStencilFuncSeparate (GLcontext *ctx, GLenum face, GLenum func, GLint ref, GLuint mask);
646 extern void fxDDStencilMaskSeparate (GLcontext *ctx, GLenum face, GLuint mask);
647 extern void fxDDStencilOpSeparate (GLcontext *ctx, GLenum face, GLenum sfail, GLenum zfail, GLenum zpass);
648
649 extern void fxDDInitExtensions(GLcontext * ctx);
650
651 extern void fxTMInit(fxMesaContext ctx);
652 extern void fxTMClose(fxMesaContext ctx);
653 extern void fxTMRestoreTextures_NoLock(fxMesaContext ctx);
654 extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, GLint);
655 extern void fxTMMoveOutTM(fxMesaContext, struct gl_texture_object *);
656 #define fxTMMoveOutTM_NoLock fxTMMoveOutTM
657 extern void fxTMFreeTexture(fxMesaContext, struct gl_texture_object *);
658 extern void fxTMReloadMipMapLevel(fxMesaContext, struct gl_texture_object *,
659 GLint);
660 extern void fxTMReloadSubMipMapLevel(fxMesaContext,
661 struct gl_texture_object *, GLint, GLint,
662 GLint);
663 extern int fxTMCheckStartAddr (fxMesaContext fxMesa, GLint tmu, tfxTexInfo *ti);
664
665 extern void fxTexGetFormat(GLcontext *, GLenum, GrTextureFormat_t *, GLint *); /* [koolsmoky] */
666
667 extern int fxTexGetInfo(int, int, GrLOD_t *, GrAspectRatio_t *,
668 float *, float *, int *, int *);
669
670 extern void fxDDScissor(GLcontext * ctx,
671 GLint x, GLint y, GLsizei w, GLsizei h);
672 extern void fxDDFogfv(GLcontext * ctx, GLenum pname, const GLfloat * params);
673 extern void fxDDColorMask(GLcontext * ctx,
674 GLboolean r, GLboolean g, GLboolean b, GLboolean a);
675
676 extern void fxDDWriteDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
677 const GLdepth depth[], const GLubyte mask[]);
678
679 extern void fxDDReadDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
680 GLdepth depth[]);
681
682 extern void fxDDWriteDepthPixels(GLcontext * ctx, GLuint n,
683 const GLint x[], const GLint y[],
684 const GLdepth depth[], const GLubyte mask[]);
685
686 extern void fxDDReadDepthPixels(GLcontext * ctx, GLuint n,
687 const GLint x[], const GLint y[],
688 GLdepth depth[]);
689
690 extern void fxDDShadeModel(GLcontext * ctx, GLenum mode);
691
692 extern void fxDDCullFace(GLcontext * ctx, GLenum mode);
693 extern void fxDDFrontFace(GLcontext * ctx, GLenum mode);
694
695 extern void fxPrintRenderState(const char *msg, GLuint state);
696 extern void fxPrintHintState(const char *msg, GLuint state);
697
698 extern int fxDDInitFxMesaContext(fxMesaContext fxMesa);
699 extern void fxDDDestroyFxMesaContext(fxMesaContext fxMesa);
700
701
702 extern void fxSetScissorValues(GLcontext * ctx);
703 extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa,
704 struct gl_texture_object *tObj, GLint where);
705
706 extern void fxCheckIsInHardware(GLcontext *ctx);
707
708 /* fxsetup:
709 * semi-private functions
710 */
711 void fxSetupCull (GLcontext * ctx);
712 void fxSetupScissor (GLcontext * ctx);
713 void fxSetupColorMask (GLcontext * ctx);
714 void fxSetupBlend (GLcontext *ctx);
715 void fxSetupDepthTest (GLcontext *ctx);
716 void fxSetupTexture (GLcontext *ctx);
717 void fxSetupStencil (GLcontext *ctx);
718 void fxSetupStencilFace (GLcontext *ctx, GLint face);
719
720 /* Flags for software fallback cases */
721 #define FX_FALLBACK_TEXTURE_MAP 0x0001
722 #define FX_FALLBACK_DRAW_BUFFER 0x0002
723 #define FX_FALLBACK_SPECULAR 0x0004
724 #define FX_FALLBACK_STENCIL 0x0008
725 #define FX_FALLBACK_RENDER_MODE 0x0010
726 #define FX_FALLBACK_LOGICOP 0x0020
727 #define FX_FALLBACK_TEXTURE_ENV 0x0040
728 #define FX_FALLBACK_TEXTURE_BORDER 0x0080
729 #define FX_FALLBACK_COLORMASK 0x0100
730 #define FX_FALLBACK_BLEND 0x0200
731 #define FX_FALLBACK_TEXTURE_MULTI 0x0400
732
733 extern GLuint fx_check_IsInHardware(GLcontext *ctx);
734
735 /***
736 *** CNORM: clamp float to [0,1] and map to float in [0,255]
737 ***/
738 #if defined(USE_IEEE) && !defined(DEBUG)
739 #define IEEE_0996 0x3f7f0000 /* 0.996 or so */
740 #define CNORM(N, F) \
741 do { \
742 fi_type __tmp; \
743 __tmp.f = (F); \
744 if (__tmp.i < 0) \
745 N = 0; \
746 else if (__tmp.i >= IEEE_0996) \
747 N = 255.0f; \
748 else { \
749 N = (F) * 255.0f; \
750 } \
751 } while (0)
752 #else
753 #define CNORM(n, f) \
754 n = (CLAMP((f), 0.0F, 1.0F) * 255.0F)
755 #endif
756
757 /* run-time debugging */
758 #ifndef FX_DEBUG
759 #define FX_DEBUG 0
760 #endif
761 #if FX_DEBUG
762 extern int TDFX_DEBUG;
763 #else
764 #define TDFX_DEBUG 0
765 #endif
766
767 /* dirty hacks */
768 #define FX_RESCALE_BIG_TEXURES_HACK 1
769 #define FX_COMPRESS_S3TC_AS_FXT1_HACK 1
770
771 #endif