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
{
118 int tmuRev
; /* Rev of Texelfx chip */
119 int tmuRam
; /* 1, 2, or 4 MB */
122 typedef struct GrVoodooConfig_St
{
123 int fbRam
; /* 1, 2, or 4 MB */
124 int fbiRev
; /* Rev of Pixelfx chip */
125 int nTexelfx
; /* How many texelFX chips are there? */
126 FxBool sliDetect
; /* Is it a scan-line interleaved board? */
127 GrTMUConfig_t tmuConfig
[GLIDE_NUM_TMU
]; /* Configuration of the Texelfx chips */
130 typedef struct GrSst96Config_St
{
131 int fbRam
; /* How much? */
133 GrTMUConfig_t tmuConfig
;
136 typedef GrVoodooConfig_t GrVoodoo2Config_t
;
138 typedef struct GrAT3DConfig_St
{
143 int num_sst
; /* # of HW units in the system */
145 GrSstType type
; /* Which hardware is it? */
147 GrVoodooConfig_t VoodooConfig
;
148 GrSst96Config_t SST96Config
;
149 GrAT3DConfig_t AT3DConfig
;
150 GrVoodoo2Config_t Voodoo2Config
;
152 } SSTs
[MAX_NUM_SST
]; /* configuration for each board */
155 typedef FxU32 GrHint_t
;
156 #define GR_HINTTYPE_MIN 0
157 #define GR_HINT_STWHINT 0
159 typedef FxU32 GrSTWHint_t
;
160 #define GR_STWHINT_W_DIFF_FBI FXBIT(0)
161 #define GR_STWHINT_W_DIFF_TMU0 FXBIT(1)
162 #define GR_STWHINT_ST_DIFF_TMU0 FXBIT(2)
163 #define GR_STWHINT_W_DIFF_TMU1 FXBIT(3)
164 #define GR_STWHINT_ST_DIFF_TMU1 FXBIT(4)
165 #define GR_STWHINT_W_DIFF_TMU2 FXBIT(5)
166 #define GR_STWHINT_ST_DIFF_TMU2 FXBIT(6)
168 #define GR_CONTROL_ACTIVATE 1
169 #define GR_CONTROL_DEACTIVATE 0
174 ** move the vertex layout defintion to application
177 float sow
; /* s texture ordinate (s over w) */
178 float tow
; /* t texture ordinate (t over w) */
179 float oow
; /* 1/w (used mipmapping - really 0xfff/w) */
185 float x
, y
, z
; /* X, Y, and Z of scrn space -- Z is ignored */
186 float r
, g
, b
; /* R, G, B, ([0..255.0]) */
187 float ooz
; /* 65535/Z (used for Z-buffering) */
188 float a
; /* Alpha [0..255.0] */
189 float oow
; /* 1/W (used for W-buffering, texturing) */
190 GrTmuVertex tmuvtx
[GLIDE_NUM_TMU
];
193 #define GR_VERTEX_X_OFFSET 0
194 #define GR_VERTEX_Y_OFFSET 1
195 #define GR_VERTEX_Z_OFFSET 2
196 #define GR_VERTEX_R_OFFSET 3
197 #define GR_VERTEX_G_OFFSET 4
198 #define GR_VERTEX_B_OFFSET 5
199 #define GR_VERTEX_OOZ_OFFSET 6
200 #define GR_VERTEX_A_OFFSET 7
201 #define GR_VERTEX_OOW_OFFSET 8
202 #define GR_VERTEX_SOW_TMU0_OFFSET 9
203 #define GR_VERTEX_TOW_TMU0_OFFSET 10
204 #define GR_VERTEX_OOW_TMU0_OFFSET 11
205 #define GR_VERTEX_SOW_TMU1_OFFSET 12
206 #define GR_VERTEX_TOW_TMU1_OFFSET 13
207 #define GR_VERTEX_OOW_TMU1_OFFSET 14
213 * Glide2 functions for Glide3
215 #if defined(FX_GLIDE3)
216 #define FX_grTexDownloadTable(TMU,type,data) \
218 BEGIN_BOARD_LOCK(); \
219 grTexDownloadTable(type,data); \
222 #define FX_grTexDownloadTable_NoLock(TMU,type,data) \
223 grTexDownloadTable(type, data)
225 #define FX_grTexDownloadTable(TMU,type,data) \
227 BEGIN_BOARD_LOCK(); \
228 grTexDownloadTable(TMU,type,data); \
231 #define FX_grTexDownloadTable_NoLock grTexDownloadTable
237 #if defined(FX_GLIDE3)
238 #define FX_grFlush() \
240 BEGIN_BOARD_LOCK(); \
245 #define FX_grFlush() \
247 BEGIN_BOARD_LOCK(); \
253 #define FX_grFinish() \
255 BEGIN_BOARD_LOCK(); \
261 * Write region: ToDo possible exploit the PixelPipe parameter.
263 #if defined(FX_GLIDE3)
264 #define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
266 BEGIN_BOARD_LOCK(); \
267 grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,FXFALSE,src_stride,src_data); \
271 #define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
273 BEGIN_BOARD_LOCK(); \
274 grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data); \
282 #define FX_grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data) \
284 BEGIN_BOARD_LOCK(); \
285 grLfbReadRegion(src_buffer,src_x,src_y,src_width,src_height,dst_stride,dst_data); \
292 #define FX_grDrawTriangle(a,b,c) \
295 grDrawTriangle(a,b,c); \
300 * For Lod/LodLog2 conversion.
302 #if defined(FX_GLIDE3)
303 #define FX_largeLodLog2(info) (info).largeLodLog2
305 #define FX_largeLodLog2(info) (info).largeLod
308 #if defined(FX_GLIDE3)
309 #define FX_aspectRatioLog2(info) (info).aspectRatioLog2
311 #define FX_aspectRatioLog2(info) (info).aspectRatio
314 #if defined(FX_GLIDE3)
315 #define FX_smallLodLog2(info) (info).smallLodLog2
317 #define FX_smallLodLog2(info) (info).smallLod
320 #if defined(FX_GLIDE3)
321 #define FX_lodToValue(val) ((int)(GR_LOD_256-val))
323 #define FX_lodToValue(val) ((int)(val))
326 #if defined(FX_GLIDE3)
327 #define FX_largeLodValue(info) ((int)(GR_LOD_256-(info).largeLodLog2))
329 #define FX_largeLodValue(info) ((int)(info).largeLod)
331 #define FX_largeLodValue_NoLock FX_largeLodValue
333 #if defined(FX_GLIDE3)
334 #define FX_smallLodValue(info) ((int)(GR_LOD_256-(info).smallLodLog2))
336 #define FX_smallLodValue(info) ((int)(info).smallLod)
338 #define FX_smallLodValue_NoLock FX_smallLodValue
340 #if defined(FX_GLIDE3)
341 #define FX_valueToLod(val) ((GrLOD_t)(GR_LOD_256-val))
343 #define FX_valueToLod(val) ((GrLOD_t)(val))
347 * ScreenWidth/Height stuff.
349 extern int FX_grSstScreenWidth(void);
350 extern int FX_grSstScreenHeight(void);
357 #if defined(FX_GLIDE3)
358 extern void FX_grGlideGetVersion(char *buf
);
360 #define FX_grGlideGetVersion(b) \
362 BEGIN_BOARD_LOCK(); \
363 grGlideGetVersion(b); \
368 * Performance statistics
370 #if defined(FX_GLIDE3)
371 extern void FX_grSstPerfStats(GrSstPerfStats_t
*st
);
373 #define FX_grSstPerfStats(s) \
375 BEGIN_BOARD_LOCK(); \
384 extern int FX_grSstQueryHardware(GrHwConfiguration
*config
);
389 #if defined(FX_GLIDE3)
390 extern void FX_grHints_NoLock(GrHint_t hintType
, FxU32 hintMask
);
391 extern void FX_grHints(GrHint_t hintType
, FxU32 hintMask
);
393 #define FX_grHints(t,m) \
395 BEGIN_BOARD_LOCK(); \
399 #define FX_grHints_NoLock grHints
402 * Antialiashed line+point drawing.
404 #if defined(FX_GLIDE3)
405 extern void FX_grAADrawLine(GrVertex
*a
,GrVertex
*b
);
407 #define FX_grAADrawLine(a,b) \
415 #if defined(FX_GLIDE3)
416 extern void FX_grAADrawPoint(GrVertex
*a
);
418 #define FX_grAADrawPoint(a) \
427 * Needed for Glide3 only, to set up Glide2 compatible vertex layout.
429 #if defined(FX_GLIDE3)
430 extern void FX_setupGrVertexLayout(void);
432 #define FX_setupGrVertexLayout() do {} while (0)
437 extern FxBool
FX_grSstControl(FxU32 code
);
440 * grGammaCorrectionValue
442 #if defined(FX_GLIDE3)
443 extern void FX_grGammaCorrectionValue(float val
);
445 #define FX_grGammaCorrectionValue(v) \
447 BEGIN_BOARD_LOCK(); \
448 grGammaCorrectionValue(v) \
453 #if defined(FX_GLIDE3)
454 #define FX_grSstWinClose(w) \
456 BEGIN_BOARD_LOCK(); \
461 #define FX_grSstWinClose(w) \
463 BEGIN_BOARD_LOCK(); \
470 extern FX_GrContext_t
FX_grSstWinOpen( FxU32 hWnd
,
471 GrScreenResolution_t screen_resolution
,
472 GrScreenRefresh_t refresh_rate
,
473 GrColorFormat_t color_format
,
474 GrOriginLocation_t origin_location
,
479 #define FX_grDrawLine(v1, v2) \
482 grDrawLine(v1, v2); \
486 #define FX_grDrawPoint(p) \
493 #if defined(FX_GLIDE3)
494 extern void FX_grDrawPolygonVertexList(int n
, GrVertex
*v
);
496 #define FX_grDrawPolygonVertexList(n, v) \
499 grDrawPolygonVertexList(n, v); \
504 #define FX_grDitherMode(m) \
506 BEGIN_BOARD_LOCK(); \
511 #define FX_grRenderBuffer(b) \
513 BEGIN_BOARD_LOCK(); \
518 #define FX_grBufferClear(c, a, d) \
521 grBufferClear(c, a, d); \
525 #define FX_grDepthMask(m) \
527 BEGIN_BOARD_LOCK(); \
532 #define FX_grColorMask(c, a) \
534 BEGIN_BOARD_LOCK(); \
539 extern FxBool
FX_grLfbLock(GrLock_t type
, GrBuffer_t buffer
,
540 GrLfbWriteMode_t writeMode
,
541 GrOriginLocation_t origin
, FxBool pixelPipeline
,
544 #define FX_grLfbUnlock(t, b) \
546 BEGIN_BOARD_LOCK(); \
551 #define FX_grConstantColorValue(v) \
553 BEGIN_BOARD_LOCK(); \
554 grConstantColorValue(v); \
558 #define FX_grConstantColorValue_NoLock grConstantColorValue
560 #define FX_grAADrawTriangle(a, b, c, ab, bc, ca) \
563 grAADrawTriangle(a, b, c, ab, bc, ca); \
567 #define FX_grAlphaBlendFunction(rs, rd, as, ad) \
569 BEGIN_BOARD_LOCK(); \
570 grAlphaBlendFunction(rs, rd, as, ad); \
574 #define FX_grAlphaCombine(func, fact, loc, oth, inv) \
576 BEGIN_BOARD_LOCK(); \
577 grAlphaCombine(func, fact, loc, oth, inv); \
581 #define FX_grAlphaCombine_NoLock grAlphaCombine
583 #define FX_grAlphaTestFunction(f) \
585 BEGIN_BOARD_LOCK(); \
586 grAlphaTestFunction(f); \
590 #define FX_grAlphaTestReferenceValue(v) \
592 BEGIN_BOARD_LOCK(); \
593 grAlphaTestReferenceValue(v); \
597 #define FX_grClipWindow(minx, miny, maxx, maxy) \
599 BEGIN_BOARD_LOCK(); \
600 grClipWindow(minx, miny, maxx, maxy); \
604 #define FX_grClipWindow_NoLock grClipWindow
606 #define FX_grColorCombine(func, fact, loc, oth, inv) \
608 BEGIN_BOARD_LOCK(); \
609 grColorCombine(func, fact, loc, oth, inv); \
613 #define FX_grColorCombine_NoLock grColorCombine
615 #define FX_grCullMode(m) \
617 BEGIN_BOARD_LOCK(); \
622 #define FX_grDepthBiasLevel(lev) \
624 BEGIN_BOARD_LOCK(); \
625 grDepthBiasLevel(lev); \
629 #define FX_grDepthBufferFunction(func) \
631 BEGIN_BOARD_LOCK(); \
632 grDepthBufferFunction(func); \
636 #define FX_grFogColorValue(c) \
638 BEGIN_BOARD_LOCK(); \
639 grFogColorValue(c); \
643 #define FX_grFogMode(m) \
645 BEGIN_BOARD_LOCK(); \
650 #define FX_grFogTable(t) \
652 BEGIN_BOARD_LOCK(); \
657 #define FX_grTexClampMode(t, sc, tc) \
659 BEGIN_BOARD_LOCK(); \
660 grTexClampMode(t, sc, tc); \
664 #define FX_grTexClampMode_NoLock grTexClampMode
666 #define FX_grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv) \
668 BEGIN_BOARD_LOCK(); \
669 grTexCombine(t, rfunc, rfact, afunc, afact, rinv, ainv); \
673 #define FX_grTexCombine_NoLock grTexCombine
675 #define FX_grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d) \
677 BEGIN_BOARD_LOCK(); \
678 grTexDownloadMipMapLevel(t, sa, tlod, llod, ar, f, eo, d); \
682 #define FX_grTexDownloadMipMapLevel_NoLock grTexDownloadMipMapLevel
684 #define FX_grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e); \
686 BEGIN_BOARD_LOCK(); \
687 grTexDownloadMipMapLevelPartial(t, sa, tlod, llod, ar, f, eo, d, s, e); \
691 #define FX_grTexFilterMode(t, minf, magf) \
693 BEGIN_BOARD_LOCK(); \
694 grTexFilterMode(t, minf, magf); \
698 #define FX_grTexFilterMode_NoLock grTexFilterMode
700 extern FxU32
FX_grTexMinAddress(GrChipID_t tmu
);
701 extern FxU32
FX_grTexMaxAddress(GrChipID_t tmu
);
703 #define FX_grTexMipMapMode(t, m, lod) \
705 BEGIN_BOARD_LOCK(); \
706 grTexMipMapMode(t, m, lod); \
710 #define FX_grTexMipMapMode_NoLock grTexMipMapMode
712 #define FX_grTexSource(t, sa, eo, i) \
714 BEGIN_BOARD_LOCK(); \
715 grTexSource(t, sa, eo, i); \
719 #define FX_grTexSource_NoLock grTexSource
721 extern FxU32
FX_grTexTextureMemRequired(FxU32 evenOdd
, GrTexInfo
*info
);
722 #define FX_grTexTextureMemRequired_NoLock grTexTextureMemRequired
724 #define FX_grGlideGetState(s) \
726 BEGIN_BOARD_LOCK(); \
727 grGlideGetState(s); \
730 #define FX_grGlideGetState_NoLock(s) grGlideGetState(s);
732 #define FX_grDRIBufferSwap(i) \
734 BEGIN_BOARD_LOCK(); \
735 grDRIBufferSwap(i); \
739 #define FX_grSstSelect(b) \
741 BEGIN_BOARD_LOCK(); \
746 #define FX_grSstSelect_NoLock grSstSelect
748 #define FX_grGlideSetState(s) \
750 BEGIN_BOARD_LOCK(); \
751 grGlideSetState(s); \
754 #define FX_grGlideSetState_NoLock(s) grGlideSetState(s);
756 #define FX_grDepthBufferMode(m) \
758 BEGIN_BOARD_LOCK(); \
759 grDepthBufferMode(m); \
763 #define FX_grLfbWriteColorFormat(f) \
765 BEGIN_BOARD_LOCK(); \
766 grLfbWriteColorFormat(f); \
770 #define FX_grDrawVertexArray(m, c, p) \
773 grDrawVertexArray(m, c, p); \
777 #define FX_grGlideShutdown() \
779 BEGIN_BOARD_LOCK(); \
784 #define FX_grTexLodBiasValue_NoLock(t, v) grTexLodBiasValue(t, v)
786 #define FX_grTexLodBiasValue(t, v) \
788 BEGIN_BOARD_LOCK(); \
789 grTexLodBiasValue(t, v); \
793 #define FX_grGlideInit_NoLock grGlideInit
794 #define FX_grSstWinOpen_NoLock grSstWinOpen
796 extern int FX_getFogTableSize(void);
797 extern int FX_getGrStateSize(void);
799 #endif /* __FX_GLIDE_WARPER__ */