3 * Mesa 3-D graphics library
6 * Copyright (C) 1999-2000 Brian Paul All Rights Reserved.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
29 * Thank you for your contribution, David!
31 * Please make note of the above copyright/license statement. If you
32 * contributed code or bug fixes to this code under the previous (GNU
33 * Library) license and object to the new license, your code will be
34 * removed at your request. Please see the Mesa docs/COPYRIGHT file
35 * for more information.
37 * Additional Mesa/3Dfx driver developers:
38 * Daryll Strauss <daryll@precisioninsight.com>
39 * Keith Whitwell <keith@precisioninsight.com>
41 * See fxapi.h for more revision/author details.
45 #ifndef __FX_GLIDE_WARPER__
46 #define __FX_GLIDE_WARPER__
53 #if !defined(FX_GLIDE3)
54 typedef FxU32 FX_GrContext_t
; /* Not used in Glide2 */
56 typedef GrContext_t FX_GrContext_t
;
60 * Glide3 emulation on Glide2:
62 #if !defined(FX_GLIDE3)
63 /* Constanst for FX_grGetInteger( ) */
64 #define FX_FOG_TABLE_ENTRIES 0x0004 /* The number of entries in the hardware fog table. */
65 #define FX_GLIDE_STATE_SIZE 0x0006 /* Size of buffer, in bytes, needed to save Glide state. */
66 #define FX_LFB_PIXEL_PIPE 0x0009 /* 1 if LFB writes can go through the 3D pixel pipe. */
67 #define FX_PENDING_BUFFERSWAPS 0x0014 /* The number of buffer swaps pending. */
68 #define FX_TEXTURE_ALIGN 0x0024 /* The required alignment for textures */
70 #define FX_FOG_TABLE_ENTRIES GR_FOG_TABLE_ENTRIES
71 #define FX_GLIDE_STATE_SIZE GR_GLIDE_STATE_SIZE
72 #define FX_LFB_PIXEL_PIPE GR_LFB_PIXEL_PIPE
73 #define FX_PENDING_BUFFERSWAPS GR_PENDING_BUFFERSWAPS
74 #define FX_TEXTURE_ALIGN GR_TEXTURE_ALIGN
78 * Genral warper functions for Glide2/Glide3:
80 extern FxI32
FX_grGetInteger(FxU32 pname
);
81 extern FxI32
FX_grGetInteger_NoLock(FxU32 pname
);
84 * Glide2 emulation on Glide3:
86 #if defined(FX_GLIDE3)
88 #define GR_ASPECT_1x1 GR_ASPECT_LOG2_1x1
89 #define GR_ASPECT_2x1 GR_ASPECT_LOG2_2x1
90 #define GR_ASPECT_4x1 GR_ASPECT_LOG2_4x1
91 #define GR_ASPECT_8x1 GR_ASPECT_LOG2_8x1
92 #define GR_ASPECT_1x2 GR_ASPECT_LOG2_1x2
93 #define GR_ASPECT_1x4 GR_ASPECT_LOG2_1x4
94 #define GR_ASPECT_1x8 GR_ASPECT_LOG2_1x8
96 #define GR_LOD_256 GR_LOD_LOG2_256
97 #define GR_LOD_128 GR_LOD_LOG2_128
98 #define GR_LOD_64 GR_LOD_LOG2_64
99 #define GR_LOD_32 GR_LOD_LOG2_32
100 #define GR_LOD_16 GR_LOD_LOG2_16
101 #define GR_LOD_8 GR_LOD_LOG2_8
102 #define GR_LOD_4 GR_LOD_LOG2_4
103 #define GR_LOD_2 GR_LOD_LOG2_2
104 #define GR_LOD_1 GR_LOD_LOG2_1
106 #define GR_FOG_WITH_TABLE GR_FOG_WITH_TABLE_ON_Q
108 typedef int GrSstType
;
110 #define MAX_NUM_SST 4
112 #define GR_SSTTYPE_VOODOO 0
113 #define GR_SSTTYPE_SST96 1
114 #define GR_SSTTYPE_AT3D 2
115 #define GR_SSTTYPE_Voodoo2 3
117 typedef struct GrTMUConfig_St
119 int tmuRev
; /* Rev of Texelfx chip */
120 int tmuRam
; /* 1, 2, or 4 MB */
124 typedef struct GrVoodooConfig_St
126 int fbRam
; /* 1, 2, or 4 MB */
127 int fbiRev
; /* Rev of Pixelfx chip */
128 int nTexelfx
; /* How many texelFX chips are there? */
129 FxBool sliDetect
; /* Is it a scan-line interleaved board? */
130 GrTMUConfig_t tmuConfig
[GLIDE_NUM_TMU
]; /* Configuration of the Texelfx chips */
134 typedef struct GrSst96Config_St
136 int fbRam
; /* How much? */
138 GrTMUConfig_t tmuConfig
;
142 typedef GrVoodooConfig_t GrVoodoo2Config_t
;
144 typedef struct GrAT3DConfig_St
152 int num_sst
; /* # of HW units in the system */
155 GrSstType type
; /* Which hardware is it? */
158 GrVoodooConfig_t VoodooConfig
;
159 GrSst96Config_t SST96Config
;
160 GrAT3DConfig_t AT3DConfig
;
161 GrVoodoo2Config_t Voodoo2Config
;
165 SSTs
[MAX_NUM_SST
]; /* configuration for each board */
169 typedef FxU32 GrHint_t
;
170 #define GR_HINTTYPE_MIN 0
171 #define GR_HINT_STWHINT 0
173 typedef FxU32 GrSTWHint_t
;
174 #define GR_STWHINT_W_DIFF_FBI FXBIT(0)
175 #define GR_STWHINT_W_DIFF_TMU0 FXBIT(1)
176 #define GR_STWHINT_ST_DIFF_TMU0 FXBIT(2)
177 #define GR_STWHINT_W_DIFF_TMU1 FXBIT(3)
178 #define GR_STWHINT_ST_DIFF_TMU1 FXBIT(4)
179 #define GR_STWHINT_W_DIFF_TMU2 FXBIT(5)
180 #define GR_STWHINT_ST_DIFF_TMU2 FXBIT(6)
182 #define GR_CONTROL_ACTIVATE 1
183 #define GR_CONTROL_DEACTIVATE 0
188 ** move the vertex layout defintion to application
192 float sow
; /* s texture ordinate (s over w) */
193 float tow
; /* t texture ordinate (t over w) */
194 float oow
; /* 1/w (used mipmapping - really 0xfff/w) */
201 float x
, y
, z
; /* X, Y, and Z of scrn space -- Z is ignored */
202 float r
, g
, b
; /* R, G, B, ([0..255.0]) */
203 float ooz
; /* 65535/Z (used for Z-buffering) */
204 float a
; /* Alpha [0..255.0] */
205 float oow
; /* 1/W (used for W-buffering, texturing) */
206 GrTmuVertex tmuvtx
[GLIDE_NUM_TMU
];
210 #define GR_VERTEX_X_OFFSET 0
211 #define GR_VERTEX_Y_OFFSET 1
212 #define GR_VERTEX_Z_OFFSET 2
213 #define GR_VERTEX_R_OFFSET 3
214 #define GR_VERTEX_G_OFFSET 4
215 #define GR_VERTEX_B_OFFSET 5
216 #define GR_VERTEX_OOZ_OFFSET 6
217 #define GR_VERTEX_A_OFFSET 7
218 #define GR_VERTEX_OOW_OFFSET 8
219 #define GR_VERTEX_SOW_TMU0_OFFSET 9
220 #define GR_VERTEX_TOW_TMU0_OFFSET 10
221 #define GR_VERTEX_OOW_TMU0_OFFSET 11
222 #define GR_VERTEX_SOW_TMU1_OFFSET 12
223 #define GR_VERTEX_TOW_TMU1_OFFSET 13
224 #define GR_VERTEX_OOW_TMU1_OFFSET 14
230 * Glide2 functions for Glide3
232 #if defined(FX_GLIDE3)
233 #define FX_grTexDownloadTable(TMU,type,data) \
235 BEGIN_BOARD_LOCK(); \
236 grTexDownloadTable(type,data); \
239 #define FX_grTexDownloadTable_NoLock(TMU,type,data) \
240 grTexDownloadTable(type, data)
242 #define FX_grTexDownloadTable(TMU,type,data) \
244 BEGIN_BOARD_LOCK(); \
245 grTexDownloadTable(TMU,type,data); \
248 #define FX_grTexDownloadTable_NoLock grTexDownloadTable
254 #if defined(FX_GLIDE3)
255 #define FX_grFlush() \
257 BEGIN_BOARD_LOCK(); \
262 #define FX_grFlush() \
264 BEGIN_BOARD_LOCK(); \
270 #define FX_grFinish() \
272 BEGIN_BOARD_LOCK(); \
278 * Write region: ToDo possible exploit the PixelPipe parameter.
280 #if defined(FX_GLIDE3)
281 #define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
283 BEGIN_BOARD_LOCK(); \
284 grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data); \
288 #define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
290 BEGIN_BOARD_LOCK(); \
291 grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data); \
299 #define FX_grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data) \
301 BEGIN_BOARD_LOCK(); \
302 grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data); \
309 #define FX_grDrawTriangle(a,b,c) \
312 grDrawTriangle(a,b,c); \
317 * For Lod/LodLog2 conversion.
319 #if defined(FX_GLIDE3)
320 #define FX_largeLodLog2(info) (info).largeLodLog2
322 #define FX_largeLodLog2(info) (info).largeLod
325 #if defined(FX_GLIDE3)
326 #define FX_aspectRatioLog2(info) (info).aspectRatioLog2
328 #define FX_aspectRatioLog2(info) (info).aspectRatio
331 #if defined(FX_GLIDE3)
332 #define FX_smallLodLog2(info) (info).smallLodLog2
334 #define FX_smallLodLog2(info) (info).smallLod
337 #if defined(FX_GLIDE3)
338 #define FX_lodToValue(val) ((int)(GR_LOD_256-val))
340 #define FX_lodToValue(val) ((int)(val))
343 #if defined(FX_GLIDE3)
344 #define FX_largeLodValue(info) ((int)(GR_LOD_256-(info).largeLodLog2))
346 #define FX_largeLodValue(info) ((int)(info).largeLod)
348 #define FX_largeLodValue_NoLock FX_largeLodValue
350 #if defined(FX_GLIDE3)
351 #define FX_smallLodValue(info) ((int)(GR_LOD_256-(info).smallLodLog2))
353 #define FX_smallLodValue(info) ((int)(info).smallLod)
355 #define FX_smallLodValue_NoLock FX_smallLodValue
357 #if defined(FX_GLIDE3)
358 #define FX_valueToLod(val) ((GrLOD_t)(GR_LOD_256-val))
360 #define FX_valueToLod(val) ((GrLOD_t)(val))
364 * ScreenWidth/Height stuff.
366 extern int FX_grSstScreenWidth(void);
367 extern int FX_grSstScreenHeight(void);
374 #if defined(FX_GLIDE3)
375 extern void FX_grGlideGetVersion(char *buf
);
377 #define FX_grGlideGetVersion(b) \
379 BEGIN_BOARD_LOCK(); \
380 grGlideGetVersion(b); \
385 * Performance statistics
387 #if defined(FX_GLIDE3)
388 extern void FX_grSstPerfStats(GrSstPerfStats_t
* st
);
390 #define FX_grSstPerfStats(s) \
392 BEGIN_BOARD_LOCK(); \
401 extern int FX_grSstQueryHardware(GrHwConfiguration
* config
);
406 #if defined(FX_GLIDE3)
407 extern void FX_grHints_NoLock(GrHint_t hintType
, FxU32 hintMask
);
408 extern void FX_grHints(GrHint_t hintType
, FxU32 hintMask
);
410 #define FX_grHints(t,m) \
412 BEGIN_BOARD_LOCK(); \
416 #define FX_grHints_NoLock grHints
419 * Antialiashed line+point drawing.
421 #if defined(FX_GLIDE3)
422 extern void FX_grAADrawLine(GrVertex
* a
, GrVertex
* b
);
424 #define FX_grAADrawLine(a,b) \
432 #if defined(FX_GLIDE3)
433 extern void FX_grAADrawPoint(GrVertex
* a
);
435 #define FX_grAADrawPoint(a) \
444 * Needed for Glide3 only, to set up Glide2 compatible vertex layout.
446 #if defined(FX_GLIDE3)
447 extern void FX_setupGrVertexLayout(void);
449 #define FX_setupGrVertexLayout() do {} while (0)
454 extern FxBool
FX_grSstControl(FxU32 code
);
457 * grGammaCorrectionValue
459 #if defined(FX_GLIDE3)
460 extern void FX_grGammaCorrectionValue(float val
);
462 #define FX_grGammaCorrectionValue(v) \
464 BEGIN_BOARD_LOCK(); \
465 grGammaCorrectionValue(v) \
470 #if defined(FX_GLIDE3)
471 #define FX_grSstWinClose(w) \
473 BEGIN_BOARD_LOCK(); \
478 #define FX_grSstWinClose(w) \
480 BEGIN_BOARD_LOCK(); \
487 extern FX_GrContext_t
FX_grSstWinOpen(FxU32 hWnd
,
488 GrScreenResolution_t screen_resolution
,
489 GrScreenRefresh_t refresh_rate
,
490 GrColorFormat_t color_format
,
491 GrOriginLocation_t origin_location
,
492 int nColBuffers
, int nAuxBuffers
);
495 #define FX_grDrawLine(v1, v2) \
498 grDrawLine(v1, v2); \
502 #define FX_grDrawPoint(p) \
509 #if defined(FX_GLIDE3)
510 extern void FX_grDrawPolygonVertexList(int n
, GrVertex
* v
);
512 #define FX_grDrawPolygonVertexList(n, v) \
515 grDrawPolygonVertexList(n, v); \
520 #define FX_grDitherMode(m) \
522 BEGIN_BOARD_LOCK(); \
527 #define FX_grRenderBuffer(b) \
529 BEGIN_BOARD_LOCK(); \
534 #define FX_grBufferClear(c, a, d) \
537 grBufferClear(c, a, d); \
541 #define FX_grDepthMask(m) \
543 BEGIN_BOARD_LOCK(); \
548 #define FX_grColorMask(c, a) \
550 BEGIN_BOARD_LOCK(); \
555 extern FxBool
FX_grLfbLock(GrLock_t type
, GrBuffer_t buffer
,
556 GrLfbWriteMode_t writeMode
,
557 GrOriginLocation_t origin
, FxBool pixelPipeline
,
560 #define FX_grLfbUnlock(t, b) \
562 BEGIN_BOARD_LOCK(); \
567 #define FX_grConstantColorValue(v) \
569 BEGIN_BOARD_LOCK(); \
570 grConstantColorValue(v); \
574 #define FX_grConstantColorValue_NoLock grConstantColorValue
576 #define FX_grAADrawTriangle(a, b, c, ab, bc, ca) \
579 grAADrawTriangle(a, b, c, ab, bc, ca); \
583 #define FX_grAlphaBlendFunction(rs, rd, as, ad) \
585 BEGIN_BOARD_LOCK(); \
586 grAlphaBlendFunction(rs, rd, as, ad); \
590 #define FX_grAlphaCombine(func, fact, loc, oth, inv) \
592 BEGIN_BOARD_LOCK(); \
593 grAlphaCombine(func, fact, loc, oth, inv); \
597 #define FX_grAlphaCombine_NoLock grAlphaCombine
599 #define FX_grAlphaTestFunction(f) \
601 BEGIN_BOARD_LOCK(); \
602 grAlphaTestFunction(f); \
606 #define FX_grAlphaTestReferenceValue(v) \
608 BEGIN_BOARD_LOCK(); \
609 grAlphaTestReferenceValue(v); \
613 #define FX_grClipWindow(minx, miny, maxx, maxy) \
615 BEGIN_BOARD_LOCK(); \
616 grClipWindow(minx, miny, maxx, maxy); \
620 #define FX_grClipWindow_NoLock grClipWindow
622 #define FX_grColorCombine(func, fact, loc, oth, inv) \
624 BEGIN_BOARD_LOCK(); \
625 grColorCombine(func, fact, loc, oth, inv); \
629 #define FX_grColorCombine_NoLock grColorCombine
631 #define FX_grCullMode(m) \
633 BEGIN_BOARD_LOCK(); \
638 #define FX_grDepthBiasLevel(lev) \
640 BEGIN_BOARD_LOCK(); \
641 grDepthBiasLevel(lev); \
645 #define FX_grDepthBufferFunction(func) \
647 BEGIN_BOARD_LOCK(); \
648 grDepthBufferFunction(func); \
652 #define FX_grFogColorValue(c) \
654 BEGIN_BOARD_LOCK(); \
655 grFogColorValue(c); \
659 #define FX_grFogMode(m) \
661 BEGIN_BOARD_LOCK(); \
666 #define FX_grFogTable(t) \
668 BEGIN_BOARD_LOCK(); \
673 #define FX_grTexClampMode(t, sc, tc) \
675 BEGIN_BOARD_LOCK(); \
676 grTexClampMode(t, sc, tc); \
680 #define FX_grTexClampMode_NoLock grTexClampMode
682 #define FX_grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv) \
684 BEGIN_BOARD_LOCK(); \
685 grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv); \
689 #define FX_grTexCombine_NoLock grTexCombine
691 #define FX_grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d) \
693 BEGIN_BOARD_LOCK(); \
694 grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d); \
698 #define FX_grTexDownloadMipMapLevel_NoLock grTexDownloadMipMapLevel
700 #define FX_grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e); \
702 BEGIN_BOARD_LOCK(); \
703 grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e); \
707 #define FX_grTexFilterMode(t, minf, magf) \
709 BEGIN_BOARD_LOCK(); \
710 grTexFilterMode(t, minf, magf); \
714 #define FX_grTexFilterMode_NoLock grTexFilterMode
716 extern FxU32
FX_grTexMinAddress(GrChipID_t tmu
);
717 extern FxU32
FX_grTexMaxAddress(GrChipID_t tmu
);
719 #define FX_grTexMipMapMode(t, m, lod) \
721 BEGIN_BOARD_LOCK(); \
722 grTexMipMapMode(t, m, lod); \
726 #define FX_grTexMipMapMode_NoLock grTexMipMapMode
728 #define FX_grTexSource(t, sa, eo, i) \
730 BEGIN_BOARD_LOCK(); \
731 grTexSource(t, sa, eo, i); \
735 #define FX_grTexSource_NoLock grTexSource
737 extern FxU32
FX_grTexTextureMemRequired(FxU32 evenOdd
, GrTexInfo
* info
);
738 #define FX_grTexTextureMemRequired_NoLock grTexTextureMemRequired
740 #define FX_grGlideGetState(s) \
742 BEGIN_BOARD_LOCK(); \
743 grGlideGetState(s); \
746 #define FX_grGlideGetState_NoLock(s) grGlideGetState(s);
748 #define FX_grDRIBufferSwap(i) \
750 BEGIN_BOARD_LOCK(); \
751 grDRIBufferSwap(i); \
755 #define FX_grSstSelect(b) \
757 BEGIN_BOARD_LOCK(); \
762 #define FX_grSstSelect_NoLock grSstSelect
764 #define FX_grGlideSetState(s) \
766 BEGIN_BOARD_LOCK(); \
767 grGlideSetState(s); \
770 #define FX_grGlideSetState_NoLock(s) grGlideSetState(s);
772 #define FX_grDepthBufferMode(m) \
774 BEGIN_BOARD_LOCK(); \
775 grDepthBufferMode(m); \
779 #define FX_grLfbWriteColorFormat(f) \
781 BEGIN_BOARD_LOCK(); \
782 grLfbWriteColorFormat(f); \
786 #define FX_grDrawVertexArray(m, c, p) \
789 grDrawVertexArray(m, c, p); \
793 #define FX_grGlideShutdown() \
795 BEGIN_BOARD_LOCK(); \
800 #define FX_grTexLodBiasValue_NoLock(t, v) grTexLodBiasValue(t, v)
802 #define FX_grTexLodBiasValue(t, v) \
804 BEGIN_BOARD_LOCK(); \
805 grTexLodBiasValue(t, v); \
809 #define FX_grGlideInit_NoLock grGlideInit
810 #define FX_grSstWinOpen_NoLock grSstWinOpen
812 extern int FX_getFogTableSize(void);
813 extern int FX_getGrStateSize(void);
815 #endif /* __FX_GLIDE_WARPER__ */