added GL_EXT_fog_coord.
[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 tfxTexInfo;
299
300 typedef struct
301 {
302 GLuint swapBuffer;
303 GLuint reqTexUpload;
304 GLuint texUpload;
305 GLuint memTexUpload;
306 }
307 tfxStats;
308
309
310
311 typedef struct
312 {
313 /* Alpha test */
314
315 GLboolean alphaTestEnabled;
316 GrCmpFnc_t alphaTestFunc;
317 GLfloat alphaTestRefValue;
318
319 /* Blend function */
320
321 GLboolean blendEnabled;
322 GrAlphaBlendFnc_t blendSrcFuncRGB;
323 GrAlphaBlendFnc_t blendDstFuncRGB;
324 GrAlphaBlendFnc_t blendSrcFuncAlpha;
325 GrAlphaBlendFnc_t blendDstFuncAlpha;
326 GrAlphaBlendOp_t blendEqRGB;
327 GrAlphaBlendOp_t blendEqAlpha;
328
329 /* Depth test */
330
331 GLboolean depthTestEnabled;
332 GLboolean depthMask;
333 GrCmpFnc_t depthTestFunc;
334 FxI32 depthBias;
335
336 /* Stencil */
337
338 GLboolean stencilEnabled;
339 GrCmpFnc_t stencilFunction; /* Stencil function */
340 GrStencil_t stencilRefValue; /* Stencil reference value */
341 GrStencil_t stencilValueMask; /* Value mask */
342 GrStencil_t stencilWriteMask; /* Write mask */
343 GrCmpFnc_t stencilFailFunc; /* Stencil fail function */
344 GrCmpFnc_t stencilZFailFunc; /* Stencil pass, depth fail function */
345 GrCmpFnc_t stencilZPassFunc; /* Stencil pass, depth pass function */
346 GrStencil_t stencilClear; /* Buffer clear value */
347 }
348 tfxUnitsState;
349
350
351
352
353 /* Flags for fxMesa->new_state
354 */
355 #define FX_NEW_TEXTURING 0x1
356 #define FX_NEW_BLEND 0x2
357 #define FX_NEW_ALPHA 0x4
358 #define FX_NEW_DEPTH 0x8
359 #define FX_NEW_FOG 0x10
360 #define FX_NEW_SCISSOR 0x20
361 #define FX_NEW_COLOR_MASK 0x40
362 #define FX_NEW_CULL 0x80
363 #define FX_NEW_STENCIL 0x100
364
365
366 #define FX_CONTEXT(ctx) ((fxMesaContext)((ctx)->DriverCtx))
367
368 #define FX_TEXTURE_DATA(texUnit) fxTMGetTexInfo((texUnit)->_Current)
369
370 #define fxTMGetTexInfo(o) ((tfxTexInfo*)((o)->DriverData))
371
372 #define FX_MIPMAP_DATA(img) ((tfxMipMapLevel *) (img)->DriverData)
373
374 #define BEGIN_BOARD_LOCK()
375 #define END_BOARD_LOCK()
376 #define BEGIN_CLIP_LOOP()
377 #define END_CLIP_LOOP()
378
379
380
381
382 /* Covers the state referenced by IsInHardware:
383 */
384 #define _FX_NEW_IS_IN_HARDWARE (_NEW_TEXTURE| \
385 _NEW_HINT| \
386 _NEW_STENCIL| \
387 _NEW_BUFFERS| \
388 _NEW_COLOR| \
389 _NEW_LIGHT)
390
391 /* Covers the state referenced by fxDDChooseRenderState
392 */
393 #define _FX_NEW_RENDERSTATE (_FX_NEW_IS_IN_HARDWARE | \
394 _DD_NEW_FLATSHADE | \
395 _DD_NEW_TRI_LIGHT_TWOSIDE| \
396 _DD_NEW_TRI_OFFSET | \
397 _DD_NEW_TRI_UNFILLED | \
398 _DD_NEW_TRI_SMOOTH | \
399 _DD_NEW_TRI_STIPPLE | \
400 _DD_NEW_LINE_SMOOTH | \
401 _DD_NEW_LINE_STIPPLE | \
402 _DD_NEW_LINE_WIDTH | \
403 _DD_NEW_POINT_SMOOTH | \
404 _DD_NEW_POINT_SIZE | \
405 _NEW_LINE)
406
407
408 /* Covers the state referenced by fxDDChooseSetupFunction.
409 */
410 #define _FX_NEW_SETUP_FUNCTION (_NEW_LIGHT| \
411 _NEW_FOG| \
412 _NEW_TEXTURE| \
413 _NEW_COLOR) \
414
415
416 /* lookup table for scaling y bit colors up to 8 bits */
417 extern GLuint FX_rgb_scale_4[16];
418 extern GLuint FX_rgb_scale_5[32];
419 extern GLuint FX_rgb_scale_6[64];
420
421 typedef void (*fx_tri_func) (fxMesaContext, GrVertex *, GrVertex *, GrVertex *);
422 typedef void (*fx_line_func) (fxMesaContext, GrVertex *, GrVertex *);
423 typedef void (*fx_point_func) (fxMesaContext, GrVertex *);
424
425 struct tfxMesaContext
426 {
427 GrTexTable_t glbPalType;
428 GuTexPalette glbPalette;
429
430 GLcontext *glCtx; /* the core Mesa context */
431 GLvisual *glVis; /* describes the color buffer */
432 GLframebuffer *glBuffer; /* the ancillary buffers */
433
434 GLint board; /* the board used for this context */
435 GLint width, height; /* size of color buffer */
436
437 GrBuffer_t currentFB;
438
439 GLboolean bgrOrder;
440 GrColor_t color;
441 GrColor_t clearC;
442 GrAlpha_t clearA;
443 GLuint constColor;
444 GrCullMode_t cullMode;
445
446 tfxUnitsState unitsState;
447 tfxUnitsState restoreUnitsState; /* saved during multipass */
448
449
450 GLuint new_state;
451 GLuint new_gl_state;
452
453 /* Texture Memory Manager Data
454 */
455 GLuint texBindNumber;
456 GLint tmuSrc;
457 GLuint lastUnitsMode;
458 GLuint freeTexMem[FX_NUM_TMU];
459 MemRange *tmPool;
460 MemRange *tmFree[FX_NUM_TMU];
461
462 GLenum fogTableMode;
463 GLfloat fogDensity;
464 GLfloat fogStart, fogEnd;
465 GrFog_t *fogTable;
466 GLint textureAlign;
467 GLint textureMaxLod;
468
469 /* Vertex building and storage:
470 */
471 GLuint tmu_source[FX_NUM_TMU];
472 GLuint SetupIndex;
473 GLuint stw_hint_state; /* for grHints */
474 GrVertex *verts;
475 GLboolean snapVertices; /* needed for older Voodoo hardware */
476
477 /* Rasterization:
478 */
479 GLuint render_index;
480 GLuint fallback;
481 GLenum render_primitive;
482 GLenum raster_primitive;
483
484 /* Current rasterization functions
485 */
486 fx_point_func draw_point;
487 fx_line_func draw_line;
488 fx_tri_func draw_tri;
489
490
491 /* Keep texture scales somewhere handy:
492 */
493 GLfloat s0scale;
494 GLfloat s1scale;
495 GLfloat t0scale;
496 GLfloat t1scale;
497
498 GLfloat inv_s0scale;
499 GLfloat inv_s1scale;
500 GLfloat inv_t0scale;
501 GLfloat inv_t1scale;
502
503 /* Glide stuff
504 */
505 tfxStats stats;
506 void *state;
507
508 /* Options */
509
510 GLboolean verbose;
511 GLboolean haveTwoTMUs; /* True if we really have 2 tmu's */
512 GLboolean haveHwAlpha;
513 GLboolean haveHwStencil;
514 GLboolean haveZBuffer;
515 GLboolean haveDoubleBuffer;
516 GLboolean haveGlobalPaletteTexture;
517 GLint swapInterval;
518 GLint maxPendingSwapBuffers;
519
520 GrContext_t glideContext;
521
522 int screen_width;
523 int screen_height;
524 int clipMinX;
525 int clipMaxX;
526 int clipMinY;
527 int clipMaxY;
528
529 int colDepth;
530 GLboolean fsaa;
531
532 /* Glide (per card) capabilities. These get mirrored
533 * from `glbHWConfig' when creating a new context...
534 */
535 GrSstType type;
536 FxBool HavePalExt; /* PALETTE6666 */
537 FxBool HavePixExt; /* PIXEXT */
538 FxBool HaveTexFmt; /* TEXFMT */
539 FxBool HaveCmbExt; /* COMBINE */
540 FxBool HaveMirExt; /* TEXMIRROR */
541 FxBool HaveTexUma; /* TEXUMA */
542 FxBool HaveTexus2; /* Texus 2 - FXT1 */
543 struct tdfx_glide Glide;
544 char rendererString[64];
545 };
546
547
548 extern void fxSetupFXUnits(GLcontext *);
549 extern void fxSetupDDPointers(GLcontext *);
550
551 /* fxvb.c:
552 */
553 extern void fxAllocVB(GLcontext * ctx);
554 extern void fxFreeVB(GLcontext * ctx);
555 extern void fxPrintSetupFlags(char *msg, GLuint flags );
556 extern void fxCheckTexSizes( GLcontext *ctx );
557 extern void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint count,
558 GLuint newinputs );
559 extern void fxChooseVertexState( GLcontext *ctx );
560
561
562
563
564
565
566 /* fxtrifuncs:
567 */
568 extern void fxDDInitTriFuncs(GLcontext *);
569 extern void fxDDChooseRenderState(GLcontext * ctx);
570
571
572 extern void fxUpdateDDSpanPointers(GLcontext *);
573 extern void fxSetupDDSpanPointers(GLcontext *);
574
575 extern void fxPrintTextureData(tfxTexInfo * ti);
576
577 extern const struct gl_texture_format *
578 fxDDChooseTextureFormat( GLcontext *ctx, GLint internalFormat,
579 GLenum srcFormat, GLenum srcType );
580 extern void fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
581 GLint internalFormat, GLint width, GLint height,
582 GLint border, GLenum format, GLenum type,
583 const GLvoid * pixels,
584 const struct gl_pixelstore_attrib *packing,
585 struct gl_texture_object *texObj,
586 struct gl_texture_image *texImage);
587 extern void fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
588 GLint xoffset, GLint yoffset,
589 GLsizei width, GLsizei height,
590 GLenum format, GLenum type,
591 const GLvoid * pixels,
592 const struct gl_pixelstore_attrib *packing,
593 struct gl_texture_object *texObj,
594 struct gl_texture_image *texImage);
595 extern void fxDDCompressedTexImage2D(GLcontext *ctx, GLenum target,
596 GLint level, GLint internalFormat,
597 GLsizei width, GLsizei height, GLint border,
598 GLsizei imageSize, const GLvoid *data,
599 struct gl_texture_object *texObj,
600 struct gl_texture_image *texImage);
601 extern void fxDDCompressedTexSubImage2D(GLcontext *ctx, GLenum target,
602 GLint level, GLint xoffset,
603 GLint yoffset, GLsizei width,
604 GLint height, GLenum format,
605 GLsizei imageSize, const GLvoid *data,
606 struct gl_texture_object *texObj,
607 struct gl_texture_image *texImage);
608 extern void fxDDTexImage1D(GLcontext * ctx, GLenum target, GLint level,
609 GLint internalFormat, GLint width,
610 GLint border, GLenum format, GLenum type,
611 const GLvoid * pixels,
612 const struct gl_pixelstore_attrib *packing,
613 struct gl_texture_object *texObj,
614 struct gl_texture_image *texImage);
615 extern void fxDDTexSubImage1D(GLcontext * ctx, GLenum target, GLint level,
616 GLint xoffset, GLint width,
617 GLenum format, GLenum type,
618 const GLvoid * pixels,
619 const struct gl_pixelstore_attrib *packing,
620 struct gl_texture_object *texObj,
621 struct gl_texture_image *texImage);
622 extern GLboolean fxDDTestProxyTexImage (GLcontext *ctx, GLenum target,
623 GLint level, GLint internalFormat,
624 GLenum format, GLenum type,
625 GLint width, GLint height,
626 GLint depth, GLint border);
627 extern void fxDDTexEnv(GLcontext *, GLenum, GLenum, const GLfloat *);
628 extern void fxDDTexParam(GLcontext *, GLenum, struct gl_texture_object *,
629 GLenum, const GLfloat *);
630 extern void fxDDTexBind(GLcontext *, GLenum, struct gl_texture_object *);
631 extern struct gl_texture_object *fxDDNewTextureObject( GLcontext *ctx, GLuint name, GLenum target );
632 extern void fxDDTexDel(GLcontext *, struct gl_texture_object *);
633 extern GLboolean fxDDIsTextureResident(GLcontext *, struct gl_texture_object *);
634 extern void fxDDTexPalette(GLcontext *, struct gl_texture_object *);
635 extern void fxDDTexUseGlbPalette(GLcontext *, GLboolean);
636
637 extern void fxDDEnable(GLcontext *, GLenum, GLboolean);
638 extern void fxDDAlphaFunc(GLcontext *, GLenum, GLfloat);
639 extern void fxDDBlendFuncSeparate(GLcontext *, GLenum, GLenum, GLenum, GLenum);
640 extern void fxDDBlendEquationSeparate(GLcontext *, GLenum, GLenum);
641 extern void fxDDDepthMask(GLcontext *, GLboolean);
642 extern void fxDDDepthFunc(GLcontext *, GLenum);
643 extern void fxDDStencilFunc (GLcontext *ctx, GLenum func, GLint ref, GLuint mask);
644 extern void fxDDStencilMask (GLcontext *ctx, GLuint mask);
645 extern void fxDDStencilOp (GLcontext *ctx, GLenum sfail, GLenum zfail, GLenum zpass);
646
647 extern void fxDDInitExtensions(GLcontext * ctx);
648
649 extern void fxTMInit(fxMesaContext ctx);
650 extern void fxTMClose(fxMesaContext ctx);
651 extern void fxTMRestoreTextures_NoLock(fxMesaContext ctx);
652 extern void fxTMMoveInTM(fxMesaContext, struct gl_texture_object *, GLint);
653 extern void fxTMMoveOutTM(fxMesaContext, struct gl_texture_object *);
654 #define fxTMMoveOutTM_NoLock fxTMMoveOutTM
655 extern void fxTMFreeTexture(fxMesaContext, struct gl_texture_object *);
656 extern void fxTMReloadMipMapLevel(fxMesaContext, struct gl_texture_object *,
657 GLint);
658 extern void fxTMReloadSubMipMapLevel(fxMesaContext,
659 struct gl_texture_object *, GLint, GLint,
660 GLint);
661 extern int fxTMCheckStartAddr (fxMesaContext fxMesa, GLint tmu, tfxTexInfo *ti);
662
663 extern void fxTexGetFormat(GLcontext *, GLenum, GrTextureFormat_t *, GLint *); /* [koolsmoky] */
664
665 extern int fxTexGetInfo(int, int, GrLOD_t *, GrAspectRatio_t *,
666 float *, float *, int *, int *);
667
668 extern void fxDDScissor(GLcontext * ctx,
669 GLint x, GLint y, GLsizei w, GLsizei h);
670 extern void fxDDFogfv(GLcontext * ctx, GLenum pname, const GLfloat * params);
671 extern void fxDDColorMask(GLcontext * ctx,
672 GLboolean r, GLboolean g, GLboolean b, GLboolean a);
673
674 extern void fxDDWriteDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
675 const GLdepth depth[], const GLubyte mask[]);
676
677 extern void fxDDReadDepthSpan(GLcontext * ctx, GLuint n, GLint x, GLint y,
678 GLdepth depth[]);
679
680 extern void fxDDWriteDepthPixels(GLcontext * ctx, GLuint n,
681 const GLint x[], const GLint y[],
682 const GLdepth depth[], const GLubyte mask[]);
683
684 extern void fxDDReadDepthPixels(GLcontext * ctx, GLuint n,
685 const GLint x[], const GLint y[],
686 GLdepth depth[]);
687
688 extern void fxDDShadeModel(GLcontext * ctx, GLenum mode);
689
690 extern void fxDDCullFace(GLcontext * ctx, GLenum mode);
691 extern void fxDDFrontFace(GLcontext * ctx, GLenum mode);
692
693 extern void fxPrintRenderState(const char *msg, GLuint state);
694 extern void fxPrintHintState(const char *msg, GLuint state);
695
696 extern int fxDDInitFxMesaContext(fxMesaContext fxMesa);
697 extern void fxDDDestroyFxMesaContext(fxMesaContext fxMesa);
698
699
700 extern void fxSetScissorValues(GLcontext * ctx);
701 extern void fxTMMoveInTM_NoLock(fxMesaContext fxMesa,
702 struct gl_texture_object *tObj, GLint where);
703
704 extern void fxCheckIsInHardware(GLcontext *ctx);
705
706 /* fxsetup:
707 * semi-private functions
708 */
709 void fxSetupCull (GLcontext * ctx);
710 void fxSetupScissor (GLcontext * ctx);
711 void fxSetupColorMask (GLcontext * ctx);
712 void fxSetupBlend (GLcontext *ctx);
713 void fxSetupDepthTest (GLcontext *ctx);
714 void fxSetupTexture (GLcontext *ctx);
715
716 /* Flags for software fallback cases */
717 #define FX_FALLBACK_TEXTURE_MAP 0x0001
718 #define FX_FALLBACK_DRAW_BUFFER 0x0002
719 #define FX_FALLBACK_SPECULAR 0x0004
720 #define FX_FALLBACK_STENCIL 0x0008
721 #define FX_FALLBACK_RENDER_MODE 0x0010
722 #define FX_FALLBACK_LOGICOP 0x0020
723 #define FX_FALLBACK_TEXTURE_ENV 0x0040
724 #define FX_FALLBACK_TEXTURE_BORDER 0x0080
725 #define FX_FALLBACK_COLORMASK 0x0100
726 #define FX_FALLBACK_BLEND 0x0200
727 #define FX_FALLBACK_TEXTURE_MULTI 0x0400
728
729 extern GLuint fx_check_IsInHardware(GLcontext *ctx);
730
731 /* run-time debugging */
732 #ifndef FX_DEBUG
733 #define FX_DEBUG 0
734 #endif
735 #if FX_DEBUG
736 extern int TDFX_DEBUG;
737 #else
738 #define TDFX_DEBUG 0
739 #endif
740
741 /* dirty hacks */
742 #define FX_RESCALE_BIG_TEXURES_HACK 1
743 #define FX_COMPRESS_S3TC_AS_FXT1_HACK 1
744
745 #endif