got rid of __FUNCTION__ :(
[mesa.git] / src / mesa / drivers / glide / fxglidew.c
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 #ifdef HAVE_CONFIG_H
38 #include "conf.h"
39 #endif
40
41 #if defined(FX)
42 #include "fxglidew.h"
43 #include "fxdrv.h"
44
45 #include <stdlib.h>
46 #include <string.h>
47
48 FxI32
49 FX_grGetInteger_NoLock(FxU32 pname)
50 {
51 FxI32 result;
52
53 if (grGet(pname, 4, &result)) {
54 return result;
55 }
56
57 if (TDFX_DEBUG & VERBOSE_DRIVER) {
58 fprintf(stderr, "FX_grGetInteger_NoLock: wrong parameter (%lx)\n", pname);
59 }
60 return -1;
61 }
62
63 FxBool
64 FX_grSstControl(FxU32 code)
65 {
66 /* The glide 3 sources call for grEnable/grDisable to be called in exchange
67 * for grSstControl. */
68 switch (code) {
69 case GR_CONTROL_ACTIVATE:
70 grEnable(GR_PASSTHRU);
71 break;
72 case GR_CONTROL_DEACTIVATE:
73 grDisable(GR_PASSTHRU);
74 break;
75 }
76 /* Appearently GR_CONTROL_RESIZE can be ignored. */
77 return 1; /* OK? */
78 }
79
80
81 int
82 FX_grSstScreenWidth()
83 {
84 FxI32 result[4];
85
86 BEGIN_BOARD_LOCK();
87 grGet(GR_VIEWPORT, sizeof(FxI32) * 4, result);
88 END_BOARD_LOCK();
89
90 return result[2];
91 }
92
93 int
94 FX_grSstScreenHeight()
95 {
96 FxI32 result[4];
97
98 BEGIN_BOARD_LOCK();
99 grGet(GR_VIEWPORT, sizeof(FxI32) * 4, result);
100 END_BOARD_LOCK();
101
102 return result[3];
103 }
104
105 void
106 FX_grSstPerfStats(GrSstPerfStats_t * st)
107 {
108 FxI32 n;
109 grGet(GR_STATS_PIXELS_IN, 4, &n);
110 st->pixelsIn = n;
111 grGet(GR_STATS_PIXELS_CHROMA_FAIL, 4, &n);
112 st->chromaFail = n;
113 grGet(GR_STATS_PIXELS_DEPTHFUNC_FAIL, 4, &n);
114 st->zFuncFail = n;
115 grGet(GR_STATS_PIXELS_AFUNC_FAIL, 4, &n);
116 st->aFuncFail = n;
117 grGet(GR_STATS_PIXELS_OUT, 4, &n);
118 st->pixelsOut = n;
119 }
120
121 void
122 FX_setupGrVertexLayout(void)
123 {
124 BEGIN_BOARD_LOCK();
125 grReset(GR_VERTEX_PARAMETER);
126
127 grCoordinateSpace(GR_WINDOW_COORDS);
128 grVertexLayout(GR_PARAM_XY, GR_VERTEX_X_OFFSET << 2, GR_PARAM_ENABLE);
129 grVertexLayout(GR_PARAM_PARGB, GR_VERTEX_PARGB_OFFSET << 2, GR_PARAM_ENABLE);
130 grVertexLayout(GR_PARAM_Q, GR_VERTEX_OOW_OFFSET << 2, GR_PARAM_ENABLE);
131 grVertexLayout(GR_PARAM_Z, GR_VERTEX_OOZ_OFFSET << 2, GR_PARAM_ENABLE);
132 grVertexLayout(GR_PARAM_ST0, GR_VERTEX_SOW_TMU0_OFFSET << 2,
133 GR_PARAM_ENABLE);
134 grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2,
135 GR_PARAM_DISABLE);
136 grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2,
137 GR_PARAM_DISABLE);
138 grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2,
139 GR_PARAM_DISABLE);
140 END_BOARD_LOCK();
141 }
142
143 void
144 FX_grHints_NoLock(GrHint_t hintType, FxU32 hintMask)
145 {
146 switch (hintType) {
147 case GR_HINT_STWHINT:
148 {
149 if (hintMask & GR_STWHINT_W_DIFF_TMU0)
150 grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2,
151 GR_PARAM_ENABLE);
152 else
153 grVertexLayout(GR_PARAM_Q0, GR_VERTEX_OOW_TMU0_OFFSET << 2,
154 GR_PARAM_DISABLE);
155
156 if (hintMask & GR_STWHINT_ST_DIFF_TMU1)
157 grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2,
158 GR_PARAM_ENABLE);
159 else
160 grVertexLayout(GR_PARAM_ST1, GR_VERTEX_SOW_TMU1_OFFSET << 2,
161 GR_PARAM_DISABLE);
162
163 if (hintMask & GR_STWHINT_W_DIFF_TMU1)
164 grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2,
165 GR_PARAM_ENABLE);
166 else
167 grVertexLayout(GR_PARAM_Q1, GR_VERTEX_OOW_TMU1_OFFSET << 2,
168 GR_PARAM_DISABLE);
169
170 }
171 }
172 }
173
174 /*
175 * Glide3 doesn't have the grSstQueryHardware function anymore.
176 * Instead, we call grGet() and fill in the data structures ourselves.
177 */
178 int
179 FX_grSstQueryHardware(GrHwConfiguration * config)
180 {
181 int i, j;
182 int numFB;
183
184 BEGIN_BOARD_LOCK();
185
186 grGet(GR_NUM_BOARDS, 4, (void *) &(config->num_sst));
187 if (config->num_sst == 0)
188 return 0;
189
190 for (i = 0; i < config->num_sst; i++) {
191 FxI32 result;
192 const char *extension;
193
194 grSstSelect(i);
195
196 extension = grGetString(GR_HARDWARE);
197 if (strstr(extension, "Voodoo2")) {
198 config->SSTs[i].type = GR_SSTTYPE_Voodoo2;
199 } else if (strstr(extension, "Voodoo Banshee")) {
200 config->SSTs[i].type = GR_SSTTYPE_Banshee;
201 } else if (strstr(extension, "Voodoo3")) {
202 config->SSTs[i].type = GR_SSTTYPE_Voodoo3;
203 } else if (strstr(extension, "Voodoo4")) {
204 config->SSTs[i].type = GR_SSTTYPE_Voodoo4;
205 } else if (strstr(extension, "Voodoo5")) {
206 config->SSTs[i].type = GR_SSTTYPE_Voodoo5;
207 } else { /* Voodoo1,rush */
208 /* ZZZ TO DO: Need to distinguish whether we have V1 or Rush. */
209 config->SSTs[i].type = GR_SSTTYPE_VOODOO;
210 }
211
212 grGet(GR_MEMORY_FB, 4, &result); /* ZZZ: differs after grSstWinOpen */
213 config->SSTs[i].fbRam = result / (1024 * 1024);
214
215 grGet(GR_NUM_TMU, 4, &result);
216 config->SSTs[i].nTexelfx = result;
217
218 grGet(GR_REVISION_FB, 4, &result);
219 config->SSTs[i].fbiRev = result;
220
221 for (j = 0; j < config->SSTs[i].nTexelfx; j++) {
222 grGet(GR_MEMORY_TMU, 4, &result); /* ZZZ: differs after grSstWinOpen */
223 config->SSTs[i].tmuConfig[j].tmuRam = result / (1024 * 1024);
224 grGet(GR_REVISION_TMU, 4, &result);
225 config->SSTs[i].tmuConfig[j].tmuRev = result;
226 }
227
228 extension = grGetString(GR_EXTENSION);
229 config->SSTs[i].HavePalExt = (strstr(extension, " PALETTE6666 ") != NULL);
230 config->SSTs[i].HavePixExt = (strstr(extension, " PIXEXT ") != NULL);
231 config->SSTs[i].HaveTexFmt = (strstr(extension, " TEXFMT ") != NULL);
232 config->SSTs[i].HaveCmbExt = (strstr(extension, " COMBINE ") != NULL);
233 config->SSTs[i].HaveMirExt = (strstr(extension, " TEXMIRROR ") != NULL);
234 config->SSTs[i].HaveTexUma = (strstr(extension, " TEXUMA ") != NULL);
235
236 /* number of Voodoo chips */
237 grGet(GR_NUM_FB, 4, (void *) &numFB);
238 config->SSTs[i].numChips = numFB;
239
240 }
241
242 tdfx_hook_glide(&config->Glide);
243
244 END_BOARD_LOCK();
245 return 1;
246 }
247
248
249
250 #else
251
252 /*
253 * Need this to provide at least one external definition.
254 */
255
256 extern int gl_fx_dummy_function_glidew(void);
257 int
258 gl_fx_dummy_function_glidew(void)
259 {
260 return 0;
261 }
262
263 #endif /* FX */