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