added GL_EXT_fog_coord.
[mesa.git] / src / mesa / drivers / glide / fxvb.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 5.1
4 *
5 * Copyright (C) 1999-2003 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 * KEITH WHITWELL, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
21 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
22 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
23 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 /* Authors:
27 * Keith Whitwell <keith@tungstengraphics.com>
28 * Daniel Borca <dborca@users.sourceforge.net>
29 */
30
31 #ifdef HAVE_CONFIG_H
32 #include "conf.h"
33 #endif
34
35 #ifdef FX
36
37 #include "glheader.h"
38 #include "mtypes.h"
39 #include "imports.h"
40 #include "macros.h"
41 #include "colormac.h"
42
43 #include "math/m_translate.h"
44 #include "swrast_setup/swrast_setup.h"
45
46 #include "tnl/tnl.h"
47 #include "tnl/t_context.h"
48
49 #include "fxdrv.h"
50
51
52 static void copy_pv( GLcontext *ctx, GLuint edst, GLuint esrc )
53 {
54 fxMesaContext fxMesa = FX_CONTEXT( ctx );
55 GrVertex *dst = fxMesa->verts + edst;
56 GrVertex *src = fxMesa->verts + esrc;
57
58 *(GLuint *)&dst->pargb = *(GLuint *)&src->pargb;
59 }
60
61 static void copy_pv2( GLcontext *ctx, GLuint edst, GLuint esrc )
62 {
63 fxMesaContext fxMesa = FX_CONTEXT( ctx );
64 GrVertex *dst = fxMesa->verts + edst;
65 GrVertex *src = fxMesa->verts + esrc;
66
67 *(GLuint *)&dst->pargb = *(GLuint *)&src->pargb;
68 *(GLuint *)&dst->pspec = *(GLuint *)&src->pspec;
69 }
70
71 static struct {
72 void (*emit)( GLcontext *, GLuint, GLuint, void * );
73 tnl_copy_pv_func copy_pv;
74 tnl_interp_func interp;
75 GLboolean (*check_tex_sizes)( GLcontext *ctx );
76 GLuint vertex_format;
77 } setup_tab[MAX_SETUP];
78
79
80 #define GET_COLOR(ptr, idx) ((ptr)->data[idx])
81
82
83 static void interp_extras( GLcontext *ctx,
84 GLfloat t,
85 GLuint dst, GLuint out, GLuint in,
86 GLboolean force_boundary )
87 {
88 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
89
90 if (VB->ColorPtr[1]) {
91 assert(VB->ColorPtr[1]->stride == 4 * sizeof(GLfloat));
92
93 INTERP_4F( t,
94 GET_COLOR(VB->ColorPtr[1], dst),
95 GET_COLOR(VB->ColorPtr[1], out),
96 GET_COLOR(VB->ColorPtr[1], in) );
97
98 if (VB->SecondaryColorPtr[1]) {
99 INTERP_3F( t,
100 GET_COLOR(VB->SecondaryColorPtr[1], dst),
101 GET_COLOR(VB->SecondaryColorPtr[1], out),
102 GET_COLOR(VB->SecondaryColorPtr[1], in) );
103 }
104 }
105
106 if (VB->EdgeFlag) {
107 VB->EdgeFlag[dst] = VB->EdgeFlag[out] || force_boundary;
108 }
109
110 setup_tab[FX_CONTEXT(ctx)->SetupIndex].interp(ctx, t, dst, out, in,
111 force_boundary);
112 }
113
114 static void copy_pv_extras( GLcontext *ctx, GLuint dst, GLuint src )
115 {
116 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
117
118 if (VB->ColorPtr[1]) {
119 COPY_4FV( GET_COLOR(VB->ColorPtr[1], dst),
120 GET_COLOR(VB->ColorPtr[1], src) );
121
122 if (VB->SecondaryColorPtr[1]) {
123 COPY_3FV( GET_COLOR(VB->SecondaryColorPtr[1], dst),
124 GET_COLOR(VB->SecondaryColorPtr[1], src) );
125 }
126 }
127
128 setup_tab[FX_CONTEXT(ctx)->SetupIndex].copy_pv(ctx, dst, src);
129 }
130
131
132 #define IND (SETUP_XYZW|SETUP_RGBA)
133 #define TAG(x) x##_wg
134 #include "fxvbtmp.h"
135
136 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0)
137 #define TAG(x) x##_wgt0
138 #include "fxvbtmp.h"
139
140 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
141 #define TAG(x) x##_wgt0t1
142 #include "fxvbtmp.h"
143
144 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX)
145 #define TAG(x) x##_wgpt0
146 #include "fxvbtmp.h"
147
148 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
149 SETUP_PTEX)
150 #define TAG(x) x##_wgpt0t1
151 #include "fxvbtmp.h"
152
153 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ)
154 #define TAG(x) x##_wga
155 #include "fxvbtmp.h"
156
157 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ)
158 #define TAG(x) x##_wgt0a
159 #include "fxvbtmp.h"
160
161 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ)
162 #define TAG(x) x##_wgt0t1a
163 #include "fxvbtmp.h"
164
165 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ)
166 #define TAG(x) x##_wgpt0a
167 #include "fxvbtmp.h"
168
169 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
170 SETUP_PTEX|SETUP_PSIZ)
171 #define TAG(x) x##_wgpt0t1a
172 #include "fxvbtmp.h"
173
174
175 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC)
176 #define TAG(x) x##_2wg
177 #include "fxvbtmp.h"
178
179 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
180 #define TAG(x) x##_2wgt0
181 #include "fxvbtmp.h"
182
183 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1)
184 #define TAG(x) x##_2wgt0t1
185 #include "fxvbtmp.h"
186
187 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX)
188 #define TAG(x) x##_2wgpt0
189 #include "fxvbtmp.h"
190
191 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
192 SETUP_PTEX)
193 #define TAG(x) x##_2wgpt0t1
194 #include "fxvbtmp.h"
195
196 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ)
197 #define TAG(x) x##_2wga
198 #include "fxvbtmp.h"
199
200 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ)
201 #define TAG(x) x##_2wgt0a
202 #include "fxvbtmp.h"
203
204 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ)
205 #define TAG(x) x##_2wgt0t1a
206 #include "fxvbtmp.h"
207
208 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ)
209 #define TAG(x) x##_2wgpt0a
210 #include "fxvbtmp.h"
211
212 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
213 SETUP_PTEX|SETUP_PSIZ)
214 #define TAG(x) x##_2wgpt0t1a
215 #include "fxvbtmp.h"
216
217 /* fog { */
218 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_FOGC)
219 #define TAG(x) x##_wgf
220 #include "fxvbtmp.h"
221
222 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC)
223 #define TAG(x) x##_wgt0f
224 #include "fxvbtmp.h"
225
226 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC)
227 #define TAG(x) x##_wgt0t1f
228 #include "fxvbtmp.h"
229
230 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC)
231 #define TAG(x) x##_wgpt0f
232 #include "fxvbtmp.h"
233
234 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
235 SETUP_PTEX|SETUP_FOGC)
236 #define TAG(x) x##_wgpt0t1f
237 #include "fxvbtmp.h"
238
239 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC)
240 #define TAG(x) x##_wgaf
241 #include "fxvbtmp.h"
242
243 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
244 #define TAG(x) x##_wgt0af
245 #include "fxvbtmp.h"
246
247 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
248 #define TAG(x) x##_wgt0t1af
249 #include "fxvbtmp.h"
250
251 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
252 #define TAG(x) x##_wgpt0af
253 #include "fxvbtmp.h"
254
255 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_TMU0|SETUP_TMU1|\
256 SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
257 #define TAG(x) x##_wgpt0t1af
258 #include "fxvbtmp.h"
259
260
261 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC)
262 #define TAG(x) x##_2wgf
263 #include "fxvbtmp.h"
264
265 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC)
266 #define TAG(x) x##_2wgt0f
267 #include "fxvbtmp.h"
268
269 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_FOGC)
270 #define TAG(x) x##_2wgt0t1f
271 #include "fxvbtmp.h"
272
273 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_FOGC)
274 #define TAG(x) x##_2wgpt0f
275 #include "fxvbtmp.h"
276
277 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
278 SETUP_PTEX|SETUP_FOGC)
279 #define TAG(x) x##_2wgpt0t1f
280 #include "fxvbtmp.h"
281
282 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC)
283 #define TAG(x) x##_2wgaf
284 #include "fxvbtmp.h"
285
286 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
287 #define TAG(x) x##_2wgt0af
288 #include "fxvbtmp.h"
289
290 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
291 #define TAG(x) x##_2wgt0t1af
292 #include "fxvbtmp.h"
293
294 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
295 #define TAG(x) x##_2wgpt0af
296 #include "fxvbtmp.h"
297
298 #define IND (SETUP_XYZW|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1|\
299 SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
300 #define TAG(x) x##_2wgpt0t1af
301 #include "fxvbtmp.h"
302 /* fog } */
303
304
305 /* Snapping for voodoo-1
306 */
307 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA)
308 #define TAG(x) x##_wsg
309 #include "fxvbtmp.h"
310
311 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0)
312 #define TAG(x) x##_wsgt0
313 #include "fxvbtmp.h"
314
315 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
316 SETUP_TMU1)
317 #define TAG(x) x##_wsgt0t1
318 #include "fxvbtmp.h"
319
320 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
321 SETUP_PTEX)
322 #define TAG(x) x##_wsgpt0
323 #include "fxvbtmp.h"
324
325 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
326 SETUP_TMU1|SETUP_PTEX)
327 #define TAG(x) x##_wsgpt0t1
328 #include "fxvbtmp.h"
329
330 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ)
331 #define TAG(x) x##_wsga
332 #include "fxvbtmp.h"
333
334 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ)
335 #define TAG(x) x##_wsgt0a
336 #include "fxvbtmp.h"
337
338 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
339 SETUP_TMU1|SETUP_PSIZ)
340 #define TAG(x) x##_wsgt0t1a
341 #include "fxvbtmp.h"
342
343 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
344 SETUP_PTEX|SETUP_PSIZ)
345 #define TAG(x) x##_wsgpt0a
346 #include "fxvbtmp.h"
347
348 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
349 SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ)
350 #define TAG(x) x##_wsgpt0t1a
351 #include "fxvbtmp.h"
352
353
354 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC)
355 #define TAG(x) x##_2wsg
356 #include "fxvbtmp.h"
357
358 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
359 #define TAG(x) x##_2wsgt0
360 #include "fxvbtmp.h"
361
362 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
363 SETUP_TMU1)
364 #define TAG(x) x##_2wsgt0t1
365 #include "fxvbtmp.h"
366
367 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
368 SETUP_PTEX)
369 #define TAG(x) x##_2wsgpt0
370 #include "fxvbtmp.h"
371
372 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
373 SETUP_TMU1|SETUP_PTEX)
374 #define TAG(x) x##_2wsgpt0t1
375 #include "fxvbtmp.h"
376
377 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ)
378 #define TAG(x) x##_2wsga
379 #include "fxvbtmp.h"
380
381 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ)
382 #define TAG(x) x##_2wsgt0a
383 #include "fxvbtmp.h"
384
385 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
386 SETUP_TMU1|SETUP_PSIZ)
387 #define TAG(x) x##_2wsgt0t1a
388 #include "fxvbtmp.h"
389
390 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
391 SETUP_PTEX|SETUP_PSIZ)
392 #define TAG(x) x##_2wsgpt0a
393 #include "fxvbtmp.h"
394
395 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
396 SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ)
397 #define TAG(x) x##_2wsgpt0t1a
398 #include "fxvbtmp.h"
399
400 /* fog { */
401 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_FOGC)
402 #define TAG(x) x##_wsgf
403 #include "fxvbtmp.h"
404
405 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_FOGC)
406 #define TAG(x) x##_wsgt0f
407 #include "fxvbtmp.h"
408
409 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
410 SETUP_TMU1|SETUP_FOGC)
411 #define TAG(x) x##_wsgt0t1f
412 #include "fxvbtmp.h"
413
414 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
415 SETUP_PTEX|SETUP_FOGC)
416 #define TAG(x) x##_wsgpt0f
417 #include "fxvbtmp.h"
418
419 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
420 SETUP_TMU1|SETUP_PTEX|SETUP_FOGC)
421 #define TAG(x) x##_wsgpt0t1f
422 #include "fxvbtmp.h"
423
424 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_PSIZ|SETUP_FOGC)
425 #define TAG(x) x##_wsgaf
426 #include "fxvbtmp.h"
427
428 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
429 #define TAG(x) x##_wsgt0af
430 #include "fxvbtmp.h"
431
432 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
433 SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
434 #define TAG(x) x##_wsgt0t1af
435 #include "fxvbtmp.h"
436
437 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
438 SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
439 #define TAG(x) x##_wsgpt0af
440 #include "fxvbtmp.h"
441
442 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_TMU0|\
443 SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
444 #define TAG(x) x##_wsgpt0t1af
445 #include "fxvbtmp.h"
446
447
448 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_FOGC)
449 #define TAG(x) x##_2wsgf
450 #include "fxvbtmp.h"
451
452 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_FOGC)
453 #define TAG(x) x##_2wsgt0f
454 #include "fxvbtmp.h"
455
456 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
457 SETUP_TMU1|SETUP_FOGC)
458 #define TAG(x) x##_2wsgt0t1f
459 #include "fxvbtmp.h"
460
461 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
462 SETUP_PTEX|SETUP_FOGC)
463 #define TAG(x) x##_2wsgpt0f
464 #include "fxvbtmp.h"
465
466 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
467 SETUP_TMU1|SETUP_PTEX|SETUP_FOGC)
468 #define TAG(x) x##_2wsgpt0t1f
469 #include "fxvbtmp.h"
470
471 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_PSIZ|SETUP_FOGC)
472 #define TAG(x) x##_2wsgaf
473 #include "fxvbtmp.h"
474
475 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_PSIZ|SETUP_FOGC)
476 #define TAG(x) x##_2wsgt0af
477 #include "fxvbtmp.h"
478
479 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
480 SETUP_TMU1|SETUP_PSIZ|SETUP_FOGC)
481 #define TAG(x) x##_2wsgt0t1af
482 #include "fxvbtmp.h"
483
484 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
485 SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
486 #define TAG(x) x##_2wsgpt0af
487 #include "fxvbtmp.h"
488
489 #define IND (SETUP_XYZW|SETUP_SNAP|SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|\
490 SETUP_TMU1|SETUP_PTEX|SETUP_PSIZ|SETUP_FOGC)
491 #define TAG(x) x##_2wsgpt0t1af
492 #include "fxvbtmp.h"
493 /* fog } */
494
495
496 /* Vertex repair (multipass rendering)
497 */
498 #define IND (SETUP_RGBA)
499 #define TAG(x) x##_g
500 #include "fxvbtmp.h"
501
502 #define IND (SETUP_TMU0)
503 #define TAG(x) x##_t0
504 #include "fxvbtmp.h"
505
506 #define IND (SETUP_TMU0|SETUP_TMU1)
507 #define TAG(x) x##_t0t1
508 #include "fxvbtmp.h"
509
510 #define IND (SETUP_RGBA|SETUP_TMU0)
511 #define TAG(x) x##_gt0
512 #include "fxvbtmp.h"
513
514 #define IND (SETUP_RGBA|SETUP_TMU0|SETUP_TMU1)
515 #define TAG(x) x##_gt0t1
516 #include "fxvbtmp.h"
517
518
519 #define IND (SETUP_RGBA|SETUP_SPEC)
520 #define TAG(x) x##_2g
521 #include "fxvbtmp.h"
522
523 #define IND (SETUP_TMU0|SETUP_SPEC)
524 #define TAG(x) x##_2t0
525 #include "fxvbtmp.h"
526
527 #define IND (SETUP_TMU0|SETUP_SPEC|SETUP_TMU1)
528 #define TAG(x) x##_2t0t1
529 #include "fxvbtmp.h"
530
531 #define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0)
532 #define TAG(x) x##_2gt0
533 #include "fxvbtmp.h"
534
535 #define IND (SETUP_RGBA|SETUP_SPEC|SETUP_TMU0|SETUP_TMU1)
536 #define TAG(x) x##_2gt0t1
537 #include "fxvbtmp.h"
538
539
540
541 static void init_setup_tab( void )
542 {
543 init_wg();
544 init_wgt0();
545 init_wgt0t1();
546 init_wgpt0();
547 init_wgpt0t1();
548 init_wga();
549 init_wgt0a();
550 init_wgt0t1a();
551 init_wgpt0a();
552 init_wgpt0t1a();
553 init_2wg();
554 init_2wgt0();
555 init_2wgt0t1();
556 init_2wgpt0();
557 init_2wgpt0t1();
558 init_2wga();
559 init_2wgt0a();
560 init_2wgt0t1a();
561 init_2wgpt0a();
562 init_2wgpt0t1a();
563 init_wgf();
564 init_wgt0f();
565 init_wgt0t1f();
566 init_wgpt0f();
567 init_wgpt0t1f();
568 init_wgaf();
569 init_wgt0af();
570 init_wgt0t1af();
571 init_wgpt0af();
572 init_wgpt0t1af();
573 init_2wgf();
574 init_2wgt0f();
575 init_2wgt0t1f();
576 init_2wgpt0f();
577 init_2wgpt0t1f();
578 init_2wgaf();
579 init_2wgt0af();
580 init_2wgt0t1af();
581 init_2wgpt0af();
582 init_2wgpt0t1af();
583
584 init_wsg();
585 init_wsgt0();
586 init_wsgt0t1();
587 init_wsgpt0();
588 init_wsgpt0t1();
589 init_wsga();
590 init_wsgt0a();
591 init_wsgt0t1a();
592 init_wsgpt0a();
593 init_wsgpt0t1a();
594 init_2wsg();
595 init_2wsgt0();
596 init_2wsgt0t1();
597 init_2wsgpt0();
598 init_2wsgpt0t1();
599 init_2wsga();
600 init_2wsgt0a();
601 init_2wsgt0t1a();
602 init_2wsgpt0a();
603 init_2wsgpt0t1a();
604 init_wsgf();
605 init_wsgt0f();
606 init_wsgt0t1f();
607 init_wsgpt0f();
608 init_wsgpt0t1f();
609 init_wsgaf();
610 init_wsgt0af();
611 init_wsgt0t1af();
612 init_wsgpt0af();
613 init_wsgpt0t1af();
614 init_2wsgf();
615 init_2wsgt0f();
616 init_2wsgt0t1f();
617 init_2wsgpt0f();
618 init_2wsgpt0t1f();
619 init_2wsgaf();
620 init_2wsgt0af();
621 init_2wsgt0t1af();
622 init_2wsgpt0af();
623 init_2wsgpt0t1af();
624
625 init_g();
626 init_t0();
627 init_t0t1();
628 init_gt0();
629 init_gt0t1();
630 init_2g();
631 init_2t0();
632 init_2t0t1();
633 init_2gt0();
634 init_2gt0t1();
635 }
636
637
638 void fxPrintSetupFlags(char *msg, GLuint flags )
639 {
640 fprintf(stderr, "%s(%x): %s%s%s%s%s%s%s%s\n",
641 msg,
642 (int)flags,
643 (flags & SETUP_XYZW) ? " xyzw," : "",
644 (flags & SETUP_SNAP) ? " snap," : "",
645 (flags & SETUP_RGBA) ? " rgba," : "",
646 (flags & SETUP_TMU0) ? " tex-0," : "",
647 (flags & SETUP_TMU1) ? " tex-1," : "",
648 (flags & SETUP_PSIZ) ? " psiz," : "",
649 (flags & SETUP_SPEC) ? " spec," : "",
650 (flags & SETUP_FOGC) ? " fog," : "");
651 }
652
653
654
655 void fxCheckTexSizes( GLcontext *ctx )
656 {
657 TNLcontext *tnl = TNL_CONTEXT(ctx);
658 fxMesaContext fxMesa = FX_CONTEXT( ctx );
659
660 if (!setup_tab[fxMesa->SetupIndex].check_tex_sizes(ctx)) {
661 GLuint ind = fxMesa->SetupIndex |= (SETUP_PTEX|SETUP_RGBA);
662
663 /* Tdfx handles projective textures nicely; just have to change
664 * up to the new vertex format.
665 */
666 if (setup_tab[ind].vertex_format != fxMesa->stw_hint_state) {
667
668 fxMesa->stw_hint_state = setup_tab[ind].vertex_format;
669 FX_grHints(GR_HINT_STWHINT, fxMesa->stw_hint_state);
670
671 /* This is required as we have just changed the vertex
672 * format, so the interp routines must also change.
673 * In the unfilled and twosided cases we are using the
674 * Extras ones anyway, so leave them in place.
675 */
676 if (!(ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED))) {
677 tnl->Driver.Render.Interp = setup_tab[fxMesa->SetupIndex].interp;
678 }
679 }
680 }
681 }
682
683
684 void fxBuildVertices( GLcontext *ctx, GLuint start, GLuint count,
685 GLuint newinputs )
686 {
687 fxMesaContext fxMesa = FX_CONTEXT( ctx );
688 GrVertex *v = (fxMesa->verts + start);
689
690 if (!newinputs)
691 return;
692
693 if (newinputs & VERT_BIT_POS) {
694 setup_tab[fxMesa->SetupIndex].emit( ctx, start, count, v );
695 } else {
696 GLuint ind = 0;
697
698 /* [dBorca] masked by VERT_BIT_POS ?!?
699 if (newinputs & VERT_BIT_POINT_SIZE)
700 ind |= SETUP_PSIZ;*/
701
702 if (newinputs & VERT_BIT_COLOR0)
703 ind |= SETUP_RGBA;
704
705 if (newinputs & VERT_BIT_COLOR1)
706 ind |= SETUP_SPEC;
707
708 if (newinputs & VERT_BIT_FOG)
709 ind |= SETUP_FOGC;
710
711 if (newinputs & VERT_BIT_TEX0)
712 ind |= SETUP_TMU0;
713
714 if (newinputs & VERT_BIT_TEX1)
715 ind |= SETUP_TMU0|SETUP_TMU1;
716
717 if (fxMesa->SetupIndex & SETUP_PTEX)
718 ind = ~0;
719
720 ind &= fxMesa->SetupIndex;
721
722 if (ind) {
723 setup_tab[ind].emit( ctx, start, count, v );
724 }
725 }
726 }
727
728
729 void fxChooseVertexState( GLcontext *ctx )
730 {
731 TNLcontext *tnl = TNL_CONTEXT(ctx);
732 fxMesaContext fxMesa = FX_CONTEXT( ctx );
733 GLuint ind = SETUP_XYZW|SETUP_RGBA;
734
735 if (fxMesa->snapVertices)
736 ind |= SETUP_SNAP;
737
738 fxMesa->tmu_source[0] = 0;
739 fxMesa->tmu_source[1] = 1;
740
741 if (ctx->Texture._EnabledUnits & 0x2) {
742 if (ctx->Texture._EnabledUnits & 0x1) {
743 ind |= SETUP_TMU1;
744 }
745 ind |= SETUP_TMU0;
746 fxMesa->tmu_source[0] = 1;
747 fxMesa->tmu_source[1] = 0;
748 }
749 else if (ctx->Texture._EnabledUnits & 0x1) {
750 ind |= SETUP_TMU0;
751 }
752
753 if (ctx->_TriangleCaps & DD_POINT_ATTEN) {
754 ind |= SETUP_PSIZ;
755 }
756
757 if (ctx->_TriangleCaps & DD_SEPARATE_SPECULAR) {
758 ind |= SETUP_SPEC;
759 }
760
761 if (ctx->Fog.FogCoordinateSource == GL_FOG_COORDINATE_EXT) {
762 ind |= SETUP_FOGC;
763 }
764
765 fxMesa->SetupIndex = ind;
766
767 if (ctx->_TriangleCaps & (DD_TRI_LIGHT_TWOSIDE|DD_TRI_UNFILLED)) {
768 tnl->Driver.Render.Interp = interp_extras;
769 tnl->Driver.Render.CopyPV = copy_pv_extras;
770 } else {
771 tnl->Driver.Render.Interp = setup_tab[ind].interp;
772 tnl->Driver.Render.CopyPV = setup_tab[ind].copy_pv;
773 }
774
775 if (setup_tab[ind].vertex_format != fxMesa->stw_hint_state) {
776 fxMesa->stw_hint_state = setup_tab[ind].vertex_format;
777 FX_grHints(GR_HINT_STWHINT, fxMesa->stw_hint_state);
778 }
779 }
780
781
782
783 void fxAllocVB( GLcontext *ctx )
784 {
785 fxMesaContext fxMesa = FX_CONTEXT(ctx);
786 GLuint size = TNL_CONTEXT(ctx)->vb.Size;
787 static int firsttime = 1;
788 if (firsttime) {
789 init_setup_tab();
790 firsttime = 0;
791 }
792
793 fxMesa->verts = (GrVertex *)ALIGN_MALLOC(size * sizeof(GrVertex), 32);
794 fxMesa->SetupIndex = SETUP_XYZW|SETUP_RGBA;
795 }
796
797
798 void fxFreeVB( GLcontext *ctx )
799 {
800 fxMesaContext fxMesa = FX_CONTEXT(ctx);
801 if (fxMesa->verts) {
802 ALIGN_FREE(fxMesa->verts);
803 fxMesa->verts = 0;
804 }
805 }
806 #else
807
808
809 /*
810 * Need this to provide at least one external definition.
811 */
812
813 extern int gl_fx_dummy_function_vb(void);
814 int
815 gl_fx_dummy_function_vb(void)
816 {
817 return 0;
818 }
819
820 #endif /* FX */