472cf9473ccf66c5d11776119ed821772e8637d0
[mesa.git] / src / mesa / drivers / glide / fxglidew.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
35 #ifndef __FX_GLIDE_WARPER__
36 #define __FX_GLIDE_WARPER__
37
38
39 #include "fxg.h"
40
41
42
43 #define MAX_NUM_SST 4
44
45 enum {
46 GR_SSTTYPE_VOODOO = 0,
47 GR_SSTTYPE_SST96 = 1,
48 GR_SSTTYPE_AT3D = 2,
49 GR_SSTTYPE_Voodoo2 = 3,
50 GR_SSTTYPE_Banshee = 4,
51 GR_SSTTYPE_Voodoo3 = 5,
52 GR_SSTTYPE_Voodoo4 = 6,
53 GR_SSTTYPE_Voodoo5 = 7
54 };
55
56 #define GrState void
57
58 typedef int GrSstType;
59
60 typedef struct GrTMUConfig_St {
61 int tmuRev; /* Rev of Texelfx chip */
62 int tmuRam; /* 1, 2, or 4 MB */
63 } GrTMUConfig_t;
64
65 typedef struct {
66 int num_sst; /* # of HW units in the system */
67 struct SstCard_St {
68 GrSstType type; /* Which hardware is it? */
69 int fbRam; /* 1, 2, or 4 MB */
70 int fbiRev; /* Rev of Pixelfx chip */
71 int nTexelfx; /* How many texelFX chips are there? */
72 int numChips; /* Number of Voodoo chips */
73 GrTMUConfig_t tmuConfig[GLIDE_NUM_TMU]; /* Configuration of the Texelfx chips */
74 /* Glide3 extensions */
75 FxBool HavePalExt; /* PALETTE6666 */
76 FxBool HavePixExt; /* PIXEXT */
77 FxBool HaveTexFmt; /* TEXFMT */
78 FxBool HaveCmbExt; /* COMBINE */
79 FxBool HaveMirExt; /* TEXMIRROR */
80 FxBool HaveTexUma; /* TEXUMA */
81 }
82 SSTs[MAX_NUM_SST]; /* configuration for each board */
83 struct tdfx_glide Glide;
84 } GrHwConfiguration;
85
86
87
88 typedef FxU32 GrHint_t;
89 #define GR_HINTTYPE_MIN 0
90 #define GR_HINT_STWHINT 0
91
92 typedef FxU32 GrSTWHint_t;
93 #define GR_STWHINT_W_DIFF_FBI FXBIT(0)
94 #define GR_STWHINT_W_DIFF_TMU0 FXBIT(1)
95 #define GR_STWHINT_ST_DIFF_TMU0 FXBIT(2)
96 #define GR_STWHINT_W_DIFF_TMU1 FXBIT(3)
97 #define GR_STWHINT_ST_DIFF_TMU1 FXBIT(4)
98 #define GR_STWHINT_W_DIFF_TMU2 FXBIT(5)
99 #define GR_STWHINT_ST_DIFF_TMU2 FXBIT(6)
100
101 #define GR_CONTROL_ACTIVATE 1
102 #define GR_CONTROL_DEACTIVATE 0
103
104
105
106 /*
107 ** move the vertex layout defintion to application
108 */
109 typedef struct {
110 float sow; /* s texture ordinate (s over w) */
111 float tow; /* t texture ordinate (t over w) */
112 float oow; /* 1/w (used mipmapping - really 0xfff/w) */
113 } GrTmuVertex;
114
115 typedef struct {
116 float x, y; /* X and Y in screen space */
117 float ooz; /* 65535/Z (used for Z-buffering) */
118 float oow; /* 1/W (used for W-buffering, texturing) */
119 unsigned char pargb[4]; /* B, G, R, A [0..255] */
120 GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
121 float fog; /* fog coordinate */
122 unsigned char pspec[4]; /* B, G, R, A [0..255] */
123 float psize; /* point size */
124 long pad[16 - 14]; /* ensure 64b structure */
125 } GrVertex;
126
127 #define GR_VERTEX_X_OFFSET 0
128 #define GR_VERTEX_Y_OFFSET 1
129 #define GR_VERTEX_OOZ_OFFSET 2
130 #define GR_VERTEX_OOW_OFFSET 3
131 #define GR_VERTEX_PARGB_OFFSET 4
132 #define GR_VERTEX_SOW_TMU0_OFFSET 5
133 #define GR_VERTEX_TOW_TMU0_OFFSET 6
134 #define GR_VERTEX_OOW_TMU0_OFFSET 7
135 #define GR_VERTEX_SOW_TMU1_OFFSET 8
136 #define GR_VERTEX_TOW_TMU1_OFFSET 9
137 #define GR_VERTEX_OOW_TMU1_OFFSET 10
138 #define GR_VERTEX_FOG_OFFSET 11
139 #define GR_VERTEX_PSPEC_OFFSET 12
140
141
142
143 /*
144 * For Lod/LodLog2 conversion.
145 */
146 #define FX_largeLodLog2(info) (info).largeLodLog2
147 #define FX_aspectRatioLog2(info) (info).aspectRatioLog2
148 #define FX_smallLodLog2(info) (info).smallLodLog2
149 #define FX_lodToValue(val) ((int)(GR_LOD_LOG2_256-val))
150 #define FX_largeLodValue(info) ((int)(GR_LOD_LOG2_256-(info).largeLodLog2))
151 #define FX_smallLodValue(info) ((int)(GR_LOD_LOG2_256-(info).smallLodLog2))
152 #define FX_valueToLod(val) ((GrLOD_t)(GR_LOD_LOG2_256-val))
153
154
155
156 /*
157 * Query
158 */
159 extern int FX_grSstScreenWidth(void);
160 extern int FX_grSstScreenHeight(void);
161 extern void FX_grSstPerfStats(GrSstPerfStats_t *st);
162 extern int FX_grSstQueryHardware(GrHwConfiguration *config);
163 #define FX_grGetInteger FX_grGetInteger_NoLock
164 extern FxI32 FX_grGetInteger_NoLock(FxU32 pname);
165
166
167
168 /*
169 * GrHints
170 */
171 #define FX_grHints FX_grHints_NoLock
172 extern void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask);
173
174
175
176 /*
177 * Needed for Glide3 only, to set up Glide2 compatible vertex layout.
178 */
179 extern void FX_setupGrVertexLayout(void);
180
181
182
183 /*
184 * grSstControl stuff
185 */
186 extern FxBool FX_grSstControl(FxU32 code);
187
188 #define FX_grBufferClear(c, a, d) \
189 do { \
190 BEGIN_CLIP_LOOP(); \
191 grBufferClear(c, a, d); \
192 END_CLIP_LOOP(); \
193 } while (0)
194
195
196
197 #endif /* __FX_GLIDE_WARPER__ */