31a8fa3b02eece2421ce74da40af4dd487c470bc
[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 FxBool HaveTexus2; /* Texus 2 - FXT1 */
82 }
83 SSTs[MAX_NUM_SST]; /* configuration for each board */
84 struct tdfx_glide Glide;
85 } GrHwConfiguration;
86
87
88
89 typedef FxU32 GrHint_t;
90 #define GR_HINTTYPE_MIN 0
91 #define GR_HINT_STWHINT 0
92
93 typedef FxU32 GrSTWHint_t;
94 #define GR_STWHINT_W_DIFF_FBI FXBIT(0)
95 #define GR_STWHINT_W_DIFF_TMU0 FXBIT(1)
96 #define GR_STWHINT_ST_DIFF_TMU0 FXBIT(2)
97 #define GR_STWHINT_W_DIFF_TMU1 FXBIT(3)
98 #define GR_STWHINT_ST_DIFF_TMU1 FXBIT(4)
99 #define GR_STWHINT_W_DIFF_TMU2 FXBIT(5)
100 #define GR_STWHINT_ST_DIFF_TMU2 FXBIT(6)
101
102 #define GR_CONTROL_ACTIVATE 1
103 #define GR_CONTROL_DEACTIVATE 0
104
105
106
107 /*
108 ** move the vertex layout defintion to application
109 */
110 typedef struct {
111 float sow; /* s texture ordinate (s over w) */
112 float tow; /* t texture ordinate (t over w) */
113 float oow; /* 1/w (used mipmapping - really 0xfff/w) */
114 } GrTmuVertex;
115
116 typedef struct {
117 float x, y; /* X and Y in screen space */
118 float ooz; /* 65535/Z (used for Z-buffering) */
119 float oow; /* 1/W (used for W-buffering, texturing) */
120 unsigned char pargb[4]; /* B, G, R, A [0..255] */
121 GrTmuVertex tmuvtx[GLIDE_NUM_TMU];
122 long pad[16 - 11]; /* future use; also ensure 64b structure */
123 } GrVertex;
124
125 #define GR_VERTEX_X_OFFSET 0
126 #define GR_VERTEX_Y_OFFSET 1
127 #define GR_VERTEX_OOZ_OFFSET 2
128 #define GR_VERTEX_OOW_OFFSET 3
129 #define GR_VERTEX_PARGB_OFFSET 4
130 #define GR_VERTEX_SOW_TMU0_OFFSET 5
131 #define GR_VERTEX_TOW_TMU0_OFFSET 6
132 #define GR_VERTEX_OOW_TMU0_OFFSET 7
133 #define GR_VERTEX_SOW_TMU1_OFFSET 8
134 #define GR_VERTEX_TOW_TMU1_OFFSET 9
135 #define GR_VERTEX_OOW_TMU1_OFFSET 10
136
137
138
139 /*
140 * For Lod/LodLog2 conversion.
141 */
142 #define FX_largeLodLog2(info) (info).largeLodLog2
143 #define FX_aspectRatioLog2(info) (info).aspectRatioLog2
144 #define FX_smallLodLog2(info) (info).smallLodLog2
145 #define FX_lodToValue(val) ((int)(GR_LOD_LOG2_256-val))
146 #define FX_largeLodValue(info) ((int)(GR_LOD_LOG2_256-(info).largeLodLog2))
147 #define FX_smallLodValue(info) ((int)(GR_LOD_LOG2_256-(info).smallLodLog2))
148 #define FX_valueToLod(val) ((GrLOD_t)(GR_LOD_LOG2_256-val))
149
150
151
152 /*
153 * Write region: ToDo possible exploit the PixelPipe parameter.
154 */
155 #define FX_grLfbWriteRegion(dst_buffer,dst_x,dst_y,src_format,src_width,src_height,src_stride,src_data) \
156 do { \
157 BEGIN_BOARD_LOCK(); \
158 grLfbWriteRegion(dst_buffer,\
159 dst_x, \
160 dst_y, \
161 src_format,\
162 src_width, \
163 src_height,\
164 FXFALSE, \
165 src_stride,\
166 src_data); \
167 END_BOARD_LOCK(); \
168 } while(0)
169
170
171
172 /*
173 * ScreenWidth/Height stuff.
174 */
175 extern int FX_grSstScreenWidth(void);
176 extern int FX_grSstScreenHeight(void);
177
178
179
180 /*
181 * Query
182 */
183 extern void FX_grSstPerfStats(GrSstPerfStats_t *st);
184 extern int FX_grSstQueryHardware(GrHwConfiguration *config);
185 #define FX_grGetInteger FX_grGetInteger_NoLock
186 extern FxI32 FX_grGetInteger_NoLock(FxU32 pname);
187
188
189
190 /*
191 * GrHints
192 */
193 #define FX_grHints FX_grHints_NoLock
194 extern void FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask);
195
196
197
198 /*
199 * Needed for Glide3 only, to set up Glide2 compatible vertex layout.
200 */
201 extern void FX_setupGrVertexLayout(void);
202
203
204
205 /*
206 * grSstControl stuff
207 */
208 extern FxBool FX_grSstControl(FxU32 code);
209
210 #define FX_grBufferClear(c, a, d) \
211 do { \
212 BEGIN_CLIP_LOOP(); \
213 grBufferClear(c, a, d); \
214 END_CLIP_LOOP(); \
215 } while (0)
216
217
218
219 #endif /* __FX_GLIDE_WARPER__ */