1 | /* -*- mode: C; tab-width:8; c-basic-offset:2 -*- */
|
---|
2 |
|
---|
3 | /*
|
---|
4 | * Mesa 3-D graphics library
|
---|
5 | * Version: 3.3
|
---|
6 | *
|
---|
7 | * Copyright (C) 1999 Brian Paul All Rights Reserved.
|
---|
8 | *
|
---|
9 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
10 | * copy of this software and associated documentation files (the "Software"),
|
---|
11 | * to deal in the Software without restriction, including without limitation
|
---|
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
13 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
14 | * Software is furnished to do so, subject to the following conditions:
|
---|
15 | *
|
---|
16 | * The above copyright notice and this permission notice shall be included
|
---|
17 | * in all copies or substantial portions of the Software.
|
---|
18 | *
|
---|
19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
---|
20 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
21 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
22 | * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
|
---|
23 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
---|
24 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
---|
25 | *
|
---|
26 | *
|
---|
27 | * Original Mesa / 3Dfx device driver (C) 1999 David Bucciarelli, by the
|
---|
28 | * terms stated above.
|
---|
29 | *
|
---|
30 | * Thank you for your contribution, David!
|
---|
31 | *
|
---|
32 | * Please make note of the above copyright/license statement. If you
|
---|
33 | * contributed code or bug fixes to this code under the previous (GNU
|
---|
34 | * Library) license and object to the new license, your code will be
|
---|
35 | * removed at your request. Please see the Mesa docs/COPYRIGHT file
|
---|
36 | * for more information.
|
---|
37 | *
|
---|
38 | * Additional Mesa/3Dfx driver developers:
|
---|
39 | * Daryll Strauss <daryll@precisioninsight.com>
|
---|
40 | * Keith Whitwell <keith@precisioninsight.com>
|
---|
41 | *
|
---|
42 | * See fxapi.h for more revision/author details.
|
---|
43 | */
|
---|
44 |
|
---|
45 |
|
---|
46 | /* fxtris.c - 3Dfx VooDoo triangle functions */
|
---|
47 |
|
---|
48 |
|
---|
49 | #ifdef HAVE_CONFIG_H
|
---|
50 | #include "conf.h"
|
---|
51 | #endif
|
---|
52 |
|
---|
53 | #if defined(FX)
|
---|
54 |
|
---|
55 | #include "fxdrv.h"
|
---|
56 | #include "../mmath.h"
|
---|
57 |
|
---|
58 |
|
---|
59 |
|
---|
60 | /* Is this enough? Do we need more triangle funcs?
|
---|
61 | */
|
---|
62 | static triangle_func tri_tab[0x40]; /* only 0x20 actually used */
|
---|
63 | static quad_func quad_tab[0x40]; /* only 0x20 actually used */
|
---|
64 | static line_func line_tab[0x40]; /* less than 0x20 used */
|
---|
65 | static points_func points_tab[0x40]; /* less than 0x20 used */
|
---|
66 |
|
---|
67 | #define IND (0)
|
---|
68 | #define TAG(x) x
|
---|
69 | #include "fxtritmp.h"
|
---|
70 |
|
---|
71 | #define IND (FX_OFFSET)
|
---|
72 | #define TAG(x) x##_offset
|
---|
73 | #include "fxtritmp.h"
|
---|
74 |
|
---|
75 | #define IND (FX_TWOSIDE)
|
---|
76 | #define TAG(x) x##_twoside
|
---|
77 | #include "fxtritmp.h"
|
---|
78 |
|
---|
79 | #define IND (FX_TWOSIDE|FX_OFFSET)
|
---|
80 | #define TAG(x) x##_twoside_offset
|
---|
81 | #include "fxtritmp.h"
|
---|
82 |
|
---|
83 | #define IND (FX_FRONT_BACK)
|
---|
84 | #define TAG(x) x##_front_back
|
---|
85 | #include "fxtritmp.h"
|
---|
86 |
|
---|
87 | #define IND (FX_FRONT_BACK|FX_OFFSET)
|
---|
88 | #define TAG(x) x##_front_back_offset
|
---|
89 | #include "fxtritmp.h"
|
---|
90 |
|
---|
91 | #define IND (FX_FRONT_BACK|FX_TWOSIDE)
|
---|
92 | #define TAG(x) x##_front_back_twoside
|
---|
93 | #include "fxtritmp.h"
|
---|
94 |
|
---|
95 | #define IND (FX_FRONT_BACK|FX_TWOSIDE|FX_OFFSET)
|
---|
96 | #define TAG(x) x##_front_back_twoside_offset
|
---|
97 | #include "fxtritmp.h"
|
---|
98 |
|
---|
99 | #define IND (FX_FLAT)
|
---|
100 | #define TAG(x) x##_flat
|
---|
101 | #include "fxtritmp.h"
|
---|
102 |
|
---|
103 | #define IND (FX_FLAT|FX_OFFSET)
|
---|
104 | #define TAG(x) x##_flat_offset
|
---|
105 | #include "fxtritmp.h"
|
---|
106 |
|
---|
107 | #define IND (FX_FLAT|FX_TWOSIDE)
|
---|
108 | #define TAG(x) x##_flat_twoside
|
---|
109 | #include "fxtritmp.h"
|
---|
110 |
|
---|
111 | #define IND (FX_FLAT|FX_TWOSIDE|FX_OFFSET)
|
---|
112 | #define TAG(x) x##_flat_twoside_offset
|
---|
113 | #include "fxtritmp.h"
|
---|
114 |
|
---|
115 | #define IND (FX_FLAT|FX_FRONT_BACK)
|
---|
116 | #define TAG(x) x##_flat_front_back
|
---|
117 | #include "fxtritmp.h"
|
---|
118 |
|
---|
119 | #define IND (FX_FLAT|FX_FRONT_BACK|FX_OFFSET)
|
---|
120 | #define TAG(x) x##_flat_front_back_offset
|
---|
121 | #include "fxtritmp.h"
|
---|
122 |
|
---|
123 | #define IND (FX_FLAT|FX_FRONT_BACK|FX_TWOSIDE)
|
---|
124 | #define TAG(x) x##_flat_front_back_twoside
|
---|
125 | #include "fxtritmp.h"
|
---|
126 |
|
---|
127 | #define IND (FX_FLAT|FX_FRONT_BACK|FX_TWOSIDE|FX_OFFSET)
|
---|
128 | #define TAG(x) x##_flat_front_back_twoside_offset
|
---|
129 | #include "fxtritmp.h"
|
---|
130 |
|
---|
131 | /* We don't actually do antialiasing correctly. Geometry has to be
|
---|
132 | sorted for glide's antialiasing to operate */
|
---|
133 | #if 0
|
---|
134 | #define IND (FX_ANTIALIAS)
|
---|
135 | #define TAG(x) x##_aa
|
---|
136 | #include "fxtritmp.h"
|
---|
137 |
|
---|
138 | #define IND (FX_ANTIALIAS|FX_OFFSET)
|
---|
139 | #define TAG(x) x##_aa_offset
|
---|
140 | #include "fxtritmp.h"
|
---|
141 |
|
---|
142 | #define IND (FX_ANTIALIAS|FX_TWOSIDE)
|
---|
143 | #define TAG(x) x##_aa_twoside
|
---|
144 | #include "fxtritmp.h"
|
---|
145 |
|
---|
146 | #define IND (FX_ANTIALIAS|FX_TWOSIDE|FX_OFFSET)
|
---|
147 | #define TAG(x) x##_aa_twoside_offset
|
---|
148 | #include "fxtritmp.h"
|
---|
149 |
|
---|
150 | #define IND (FX_ANTIALIAS|FX_FRONT_BACK)
|
---|
151 | #define TAG(x) x##_aa_front_back
|
---|
152 | #include "fxtritmp.h"
|
---|
153 |
|
---|
154 | #define IND (FX_ANTIALIAS|FX_FRONT_BACK|FX_OFFSET)
|
---|
155 | #define TAG(x) x##_aa_front_back_offset
|
---|
156 | #include "fxtritmp.h"
|
---|
157 |
|
---|
158 | #define IND (FX_ANTIALIAS|FX_FRONT_BACK|FX_TWOSIDE)
|
---|
159 | #define TAG(x) x##_aa_front_back_twoside
|
---|
160 | #include "fxtritmp.h"
|
---|
161 |
|
---|
162 | #define IND (FX_ANTIALIAS|FX_FRONT_BACK|FX_TWOSIDE|FX_OFFSET)
|
---|
163 | #define TAG(x) x##_aa_front_back_twoside_offset
|
---|
164 | #include "fxtritmp.h"
|
---|
165 |
|
---|
166 | #define IND (FX_ANTIALIAS|FX_FLAT)
|
---|
167 | #define TAG(x) x##_aa_flat
|
---|
168 | #include "fxtritmp.h"
|
---|
169 |
|
---|
170 | #define IND (FX_ANTIALIAS|FX_FLAT|FX_OFFSET)
|
---|
171 | #define TAG(x) x##_aa_flat_offset
|
---|
172 | #include "fxtritmp.h"
|
---|
173 |
|
---|
174 | #define IND (FX_ANTIALIAS|FX_FLAT|FX_TWOSIDE)
|
---|
175 | #define TAG(x) x##_aa_flat_twoside
|
---|
176 | #include "fxtritmp.h"
|
---|
177 |
|
---|
178 | #define IND (FX_ANTIALIAS|FX_FLAT|FX_TWOSIDE|FX_OFFSET)
|
---|
179 | #define TAG(x) x##_aa_flat_twoside_offset
|
---|
180 | #include "fxtritmp.h"
|
---|
181 |
|
---|
182 | #define IND (FX_ANTIALIAS|FX_FLAT|FX_FRONT_BACK)
|
---|
183 | #define TAG(x) x##_aa_flat_front_back
|
---|
184 | #include "fxtritmp.h"
|
---|
185 |
|
---|
186 | #define IND (FX_ANTIALIAS|FX_FLAT|FX_FRONT_BACK|FX_OFFSET)
|
---|
187 | #define TAG(x) x##_aa_flat_front_back_offset
|
---|
188 | #include "fxtritmp.h"
|
---|
189 |
|
---|
190 | #define IND (FX_ANTIALIAS|FX_FLAT|FX_FRONT_BACK|FX_TWOSIDE)
|
---|
191 | #define TAG(x) x##_aa_flat_front_back_twoside
|
---|
192 | #include "fxtritmp.h"
|
---|
193 |
|
---|
194 | #define IND (FX_ANTIALIAS|FX_FLAT|FX_FRONT_BACK|FX_TWOSIDE|FX_OFFSET)
|
---|
195 | #define TAG(x) x##_aa_flat_front_back_twoside_offset
|
---|
196 | #include "fxtritmp.h"
|
---|
197 | #endif
|
---|
198 |
|
---|
199 | void fxDDTrifuncInit()
|
---|
200 | {
|
---|
201 | init();
|
---|
202 | init_offset();
|
---|
203 | init_twoside();
|
---|
204 | init_twoside_offset();
|
---|
205 | init_front_back();
|
---|
206 | init_front_back_offset();
|
---|
207 | init_front_back_twoside();
|
---|
208 | init_front_back_twoside_offset();
|
---|
209 | init_flat();
|
---|
210 | init_flat_offset();
|
---|
211 | init_flat_twoside();
|
---|
212 | init_flat_twoside_offset();
|
---|
213 | init_flat_front_back();
|
---|
214 | init_flat_front_back_offset();
|
---|
215 | init_flat_front_back_twoside();
|
---|
216 | init_flat_front_back_twoside_offset();
|
---|
217 | #if 0
|
---|
218 | init_aa();
|
---|
219 | init_aa_offset();
|
---|
220 | init_aa_twoside();
|
---|
221 | init_aa_twoside_offset();
|
---|
222 | init_aa_front_back();
|
---|
223 | init_aa_front_back_offset();
|
---|
224 | init_aa_front_back_twoside();
|
---|
225 | init_aa_front_back_twoside_offset();
|
---|
226 | init_aa_flat();
|
---|
227 | init_aa_flat_offset();
|
---|
228 | init_aa_flat_twoside();
|
---|
229 | init_aa_flat_twoside_offset();
|
---|
230 | init_aa_flat_front_back();
|
---|
231 | init_aa_flat_front_back_offset();
|
---|
232 | init_aa_flat_front_back_twoside();
|
---|
233 | init_aa_flat_front_back_twoside_offset();
|
---|
234 | #endif
|
---|
235 | }
|
---|
236 |
|
---|
237 | void fxPrintRenderState( const char *msg, GLuint state )
|
---|
238 | {
|
---|
239 | fprintf(stderr, "%s: (%x) %s%s%s%s%s%s\n",
|
---|
240 | msg, state,
|
---|
241 | (state & FX_ANTIALIAS) ? "antialias, " : "",
|
---|
242 | (state & FX_FLAT) ? "flat, " : "",
|
---|
243 | (state & FX_TWOSIDE) ? "twoside, " : "",
|
---|
244 | (state & FX_OFFSET) ? "offset, " : "",
|
---|
245 | (state & FX_FRONT_BACK) ? "front-back, " : "",
|
---|
246 | (state & FX_FALLBACK) ? "fallback" : "");
|
---|
247 | }
|
---|
248 |
|
---|
249 |
|
---|
250 | void fxPrintHintState( const char *msg, GLuint state )
|
---|
251 | {
|
---|
252 | fprintf(stderr, "%s: (%x) %s %s%s %s%s\n",
|
---|
253 | msg, state,
|
---|
254 | (state & GR_STWHINT_W_DIFF_FBI) ? "w-fbi, " : "",
|
---|
255 | (state & GR_STWHINT_W_DIFF_TMU0) ? "w-tmu0, " : "",
|
---|
256 | (state & GR_STWHINT_ST_DIFF_TMU0) ? "st-tmu0, " : "",
|
---|
257 | (state & GR_STWHINT_W_DIFF_TMU1) ? "w-tmu1, " : "",
|
---|
258 | (state & GR_STWHINT_ST_DIFF_TMU1) ? "st-tmu1, " : "");
|
---|
259 |
|
---|
260 | }
|
---|
261 |
|
---|
262 |
|
---|
263 | void fxDDChooseRenderState( GLcontext *ctx )
|
---|
264 | {
|
---|
265 | fxMesaContext fxMesa=(fxMesaContext)ctx->DriverCtx;
|
---|
266 | GLuint ind = 0;
|
---|
267 | GLuint flags = ctx->TriangleCaps;
|
---|
268 |
|
---|
269 | ctx->IndirectTriangles &= ~DD_SW_RASTERIZE;
|
---|
270 |
|
---|
271 | if (flags) {
|
---|
272 | if (fxMesa->render_index & FX_OFFSET)
|
---|
273 | FX_grDepthBiasLevel(0);
|
---|
274 |
|
---|
275 | if (flags & (DD_SELECT|DD_FEEDBACK)) {
|
---|
276 | fxMesa->PointsFunc = 0;
|
---|
277 | fxMesa->LineFunc = 0;
|
---|
278 | fxMesa->TriangleFunc = 0;
|
---|
279 | fxMesa->QuadFunc = 0;
|
---|
280 | fxMesa->render_index = FX_FALLBACK;
|
---|
281 | ctx->IndirectTriangles |= DD_SW_RASTERIZE;
|
---|
282 | #if 0
|
---|
283 | fprintf(stderr, "Fallback select|feeback\n");
|
---|
284 | #endif
|
---|
285 | return;
|
---|
286 | }
|
---|
287 |
|
---|
288 | if (flags & DD_FLATSHADE) ind |= FX_FLAT;
|
---|
289 | if (flags & DD_TRI_LIGHT_TWOSIDE) ind |= FX_TWOSIDE;
|
---|
290 | if (flags & DD_MULTIDRAW) ind |= FX_FRONT_BACK;
|
---|
291 | if (flags & (DD_POINT_ATTEN|DD_POINT_SMOOTH)) {
|
---|
292 | ind |= FX_FALLBACK;
|
---|
293 | #if 0
|
---|
294 | if (flags&DD_POINT_ATTEN)
|
---|
295 | fprintf(stderr, "Fallback point atten\n");
|
---|
296 | if (flags&DD_POINT_SMOOTH)
|
---|
297 | fprintf(stderr, "Fallback point smooth\n");
|
---|
298 | #endif
|
---|
299 | }
|
---|
300 |
|
---|
301 | fxMesa->render_index = ind;
|
---|
302 | fxMesa->PointsFunc = points_tab[ind];
|
---|
303 | if (ind&FX_FALLBACK)
|
---|
304 | ctx->IndirectTriangles |= DD_POINT_SW_RASTERIZE;
|
---|
305 | ind &= ~(FX_ANTIALIAS|FX_FALLBACK);
|
---|
306 |
|
---|
307 | if (flags & (DD_LINE_STIPPLE|DD_LINE_SMOOTH)) {
|
---|
308 | ind |= FX_FALLBACK;
|
---|
309 | #if 0
|
---|
310 | if (flags&DD_LINE_STIPPLE)
|
---|
311 | fprintf(stderr, "Fallback line stipple\n");
|
---|
312 | if (flags&DD_LINE_SMOOTH)
|
---|
313 | fprintf(stderr, "Fallback line smooth\n");
|
---|
314 | #endif
|
---|
315 | }
|
---|
316 |
|
---|
317 | fxMesa->render_index |= ind;
|
---|
318 | fxMesa->LineFunc = line_tab[ind];
|
---|
319 | if (ind&FX_FALLBACK)
|
---|
320 | ctx->IndirectTriangles |= DD_LINE_SW_RASTERIZE;
|
---|
321 | ind &= ~(FX_ANTIALIAS|FX_FALLBACK);
|
---|
322 |
|
---|
323 | if (flags & DD_TRI_OFFSET) ind |= FX_OFFSET;
|
---|
324 | if (flags & (DD_TRI_UNFILLED|DD_TRI_STIPPLE|DD_TRI_SMOOTH)) {
|
---|
325 | ind |= FX_FALLBACK;
|
---|
326 | #if 0
|
---|
327 | if (flags&DD_TRI_UNFILLED)
|
---|
328 | fprintf(stderr, "Fallback tri unfilled\n");
|
---|
329 | if (flags&DD_TRI_STIPPLE)
|
---|
330 | fprintf(stderr, "Fallback tri stippled\n");
|
---|
331 | if (flags&DD_TRI_SMOOTH)
|
---|
332 | fprintf(stderr, "Fallback tri smooth\n");
|
---|
333 | #endif
|
---|
334 | }
|
---|
335 |
|
---|
336 | fxMesa->render_index |= ind;
|
---|
337 | fxMesa->TriangleFunc = tri_tab[ind];
|
---|
338 | fxMesa->QuadFunc = quad_tab[ind];
|
---|
339 |
|
---|
340 | if (ind&FX_FALLBACK)
|
---|
341 | ctx->IndirectTriangles |= DD_TRI_SW_RASTERIZE | DD_QUAD_SW_RASTERIZE;
|
---|
342 | }
|
---|
343 | else if (fxMesa->render_index)
|
---|
344 | {
|
---|
345 | if (fxMesa->render_index & FX_OFFSET)
|
---|
346 | FX_grDepthBiasLevel(0);
|
---|
347 |
|
---|
348 | fxMesa->render_index = 0;
|
---|
349 | fxMesa->PointsFunc = points_tab[0];
|
---|
350 | fxMesa->LineFunc = line_tab[0];
|
---|
351 | fxMesa->TriangleFunc = tri_tab[0];
|
---|
352 | fxMesa->QuadFunc = quad_tab[0];
|
---|
353 | }
|
---|
354 |
|
---|
355 | if (MESA_VERBOSE&(VERBOSE_STATE|VERBOSE_DRIVER))
|
---|
356 | fxPrintRenderState("fxmesa: Render state", fxMesa->render_index);
|
---|
357 | }
|
---|
358 |
|
---|
359 | #else
|
---|
360 |
|
---|
361 |
|
---|
362 | /*
|
---|
363 | * Need this to provide at least one external definition.
|
---|
364 | */
|
---|
365 |
|
---|
366 | extern int gl_fx_dummy_function_tris(void);
|
---|
367 | int gl_fx_dummy_function_tris(void)
|
---|
368 | {
|
---|
369 | return 0;
|
---|
370 | }
|
---|
371 |
|
---|
372 | #endif /* FX */
|
---|