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