Imported the Savage DRI driver from the savage-2-0-0-branch of DRI CVS
[mesa.git] / src / mesa / tnl_dd / t_dd_vbtmp.h
1
2 /*
3 * Mesa 3-D graphics library
4 * Version: 5.0.1
5 *
6 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 *
25 * Authors:
26 * Keith Whitwell <keith@tungstengraphics.com>
27 */
28
29
30 /* Unlike the other templates here, this assumes quite a bit about the
31 * underlying hardware. Specifically it assumes a d3d-like vertex
32 * format, with a layout more or less constrained to look like the
33 * following:
34 *
35 * union {
36 * struct {
37 * float x, y, z, w;
38 * struct { char r, g, b, a; } color;
39 * struct { char r, g, b, fog; } spec;
40 * float u0, v0;
41 * float u1, v1;
42 * float u2, v2;
43 * float u3, v3;
44 * } v;
45 * struct {
46 * float x, y, z, w;
47 * struct { char r, g, b, a; } color;
48 * struct { char r, g, b, fog; } spec;
49 * float u0, v0, q0;
50 * float u1, v1, q1;
51 * float u2, v2, q2;
52 * float u3, v3, q3;
53 * } pv;
54 * struct {
55 * float x, y, z;
56 * struct { char r, g, b, a; } color;
57 * } tv;
58 * float f[16];
59 * unsigned int ui[16];
60 * unsigned char ub4[4][16];
61 * }
62 *
63
64 * VERTEX: hw vertex type as above
65 * VERTEX_COLOR: hw color struct type in VERTEX
66 *
67 * DO_XYZW: Emit xyz and maybe w coordinates.
68 * DO_RGBA: Emit color.
69 * DO_SPEC: Emit specular color.
70 * DO_FOG: Emit fog coordinate in specular alpha.
71 * DO_TEX0: Emit tex0 u,v coordinates.
72 * DO_TEX1: Emit tex1 u,v coordinates.
73 * DO_TEX2: Emit tex2 u,v coordinates.
74 * DO_TEX3: Emit tex3 u,v coordinates.
75 * DO_PTEX: Emit tex0,1,2,3 q coordinates where possible.
76 *
77 * HAVE_RGBA_COLOR: Hardware takes color in rgba order (else bgra).
78 *
79 * HAVE_HW_VIEWPORT: Hardware performs viewport transform.
80 * HAVE_HW_DIVIDE: Hardware performs perspective divide.
81 *
82 * HAVE_TINY_VERTICES: Hardware understands v.tv format.
83 * HAVE_PTEX_VERTICES: Hardware understands v.pv format.
84 * HAVE_NOTEX_VERTICES: Hardware understands v.v format with texcount 0.
85 *
86 * Additionally, this template assumes it is emitting *transformed*
87 * vertices; the modifications to emit untransformed vertices (ie. to
88 * t&l hardware) are probably too great to cooexist with the code
89 * already in this file.
90 *
91 * NOTE: The PTEX vertex format always includes TEX0 and TEX1, even if
92 * only TEX0 is enabled, in order to maintain a vertex size which is
93 * an exact number of quadwords.
94 */
95
96 #if (HAVE_HW_VIEWPORT)
97 #define VIEWPORT_X(dst,x) dst = x
98 #define VIEWPORT_Y(dst,y) dst = y
99 #define VIEWPORT_Z(dst,z) dst = z
100 #else
101 #define VIEWPORT_X(dst,x) dst = s[0] * x + s[12]
102 #define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13]
103 #define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14]
104 #endif
105
106 #if (HAVE_HW_DIVIDE && !HAVE_PTEX_VERTICES)
107 #error "can't cope with this combination"
108 #endif
109
110 #ifndef LOCALVARS
111 #define LOCALVARS
112 #endif
113
114 #ifndef CHECK_HW_DIVIDE
115 #define CHECK_HW_DIVIDE 1
116 #endif
117
118 #if (HAVE_HW_DIVIDE || DO_SPEC || DO_TEX0 || DO_FOG || !HAVE_TINY_VERTICES)
119
120 static void TAG(emit)( GLcontext *ctx,
121 GLuint start, GLuint end,
122 void *dest,
123 GLuint stride )
124 {
125 LOCALVARS
126 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
127 GLfloat (*tc0)[4], (*tc1)[4], (*fog)[4];
128 GLfloat (*tc2)[4], (*tc3)[4];
129 GLfloat (*col)[4], (*spec)[4];
130 GLuint tc0_stride, tc1_stride, col_stride, spec_stride, fog_stride;
131 GLuint tc2_stride, tc3_stride;
132 GLuint tc0_size, tc1_size;
133 GLuint tc2_size, tc3_size;
134 GLfloat (*coord)[4];
135 GLuint coord_stride;
136 VERTEX *v = (VERTEX *)dest;
137 const GLfloat *s = GET_VIEWPORT_MAT();
138 const GLubyte *mask = VB->ClipMask;
139 int i;
140
141 /* fprintf(stderr, "%s(big) importable %d %d..%d\n", */
142 /* __FUNCTION__, VB->importable_data, start, end); */
143
144 if (HAVE_HW_VIEWPORT && HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
145 (void) s;
146 coord = VB->ClipPtr->data;
147 coord_stride = VB->ClipPtr->stride;
148 }
149 else {
150 coord = VB->NdcPtr->data;
151 coord_stride = VB->NdcPtr->stride;
152 }
153
154 if (DO_TEX3) {
155 const GLuint t3 = GET_TEXSOURCE(3);
156 tc3 = VB->TexCoordPtr[t3]->data;
157 tc3_stride = VB->TexCoordPtr[t3]->stride;
158 if (DO_PTEX)
159 tc3_size = VB->TexCoordPtr[t3]->size;
160 }
161
162 if (DO_TEX2) {
163 const GLuint t2 = GET_TEXSOURCE(2);
164 tc2 = VB->TexCoordPtr[t2]->data;
165 tc2_stride = VB->TexCoordPtr[t2]->stride;
166 if (DO_PTEX)
167 tc2_size = VB->TexCoordPtr[t2]->size;
168 }
169
170 if (DO_TEX1) {
171 const GLuint t1 = GET_TEXSOURCE(1);
172 tc1 = VB->TexCoordPtr[t1]->data;
173 tc1_stride = VB->TexCoordPtr[t1]->stride;
174 if (DO_PTEX)
175 tc1_size = VB->TexCoordPtr[t1]->size;
176 }
177
178 if (DO_TEX0) {
179 const GLuint t0 = GET_TEXSOURCE(0);
180 tc0_stride = VB->TexCoordPtr[t0]->stride;
181 tc0 = VB->TexCoordPtr[t0]->data;
182 if (DO_PTEX)
183 tc0_size = VB->TexCoordPtr[t0]->size;
184 }
185
186 if (DO_RGBA) {
187 col_stride = VB->ColorPtr[0]->stride;
188 col = VB->ColorPtr[0]->data;
189 }
190
191 if (DO_SPEC) {
192 if (VB->SecondaryColorPtr[0]) {
193 spec_stride = VB->SecondaryColorPtr[0]->stride;
194 spec = VB->SecondaryColorPtr[0]->data;
195 } else {
196 spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
197 spec_stride = 0;
198 }
199 }
200
201 if (DO_FOG) {
202 if (VB->FogCoordPtr) {
203 fog = VB->FogCoordPtr->data;
204 fog_stride = VB->FogCoordPtr->stride;
205 }
206 else {
207 static GLfloat tmp[4] = {0, 0, 0, 0};
208 fog = &tmp;
209 fog_stride = 0;
210 }
211 }
212
213 /* May have nonstandard strides:
214 */
215 if (start) {
216 STRIDE_4F(coord, start * coord_stride);
217 if (DO_TEX0)
218 STRIDE_4F(tc0, start * tc0_stride);
219 if (DO_TEX1)
220 STRIDE_4F(tc1, start * tc1_stride);
221 if (DO_TEX2)
222 STRIDE_4F(tc2, start * tc2_stride);
223 if (DO_TEX3)
224 STRIDE_4F(tc3, start * tc3_stride);
225 if (DO_RGBA)
226 STRIDE_4F(col, start * col_stride);
227 if (DO_SPEC)
228 STRIDE_4F(spec, start * spec_stride);
229 if (DO_FOG)
230 STRIDE_4F(fog, start * fog_stride);
231 }
232
233 for (i=start; i < end; i++, v = (VERTEX *)((GLubyte *)v + stride)) {
234 if (DO_XYZW) {
235 if (HAVE_HW_VIEWPORT || mask[i] == 0) {
236 VIEWPORT_X(v->v.x, coord[0][0]);
237 VIEWPORT_Y(v->v.y, coord[0][1]);
238 VIEWPORT_Z(v->v.z, coord[0][2]);
239 v->v.w = coord[0][3];
240 }
241 STRIDE_4F(coord, coord_stride);
242 }
243 if (DO_RGBA) {
244 UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.red, col[0][0]);
245 UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.green, col[0][1]);
246 UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.blue, col[0][2]);
247 UNCLAMPED_FLOAT_TO_UBYTE(v->v.color.alpha, col[0][3]);
248 STRIDE_4F(col, col_stride);
249 }
250 if (DO_SPEC) {
251 UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.red, spec[0][0]);
252 UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.green, spec[0][1]);
253 UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.blue, spec[0][2]);
254 STRIDE_4F(spec, spec_stride);
255 }
256 if (DO_FOG) {
257 UNCLAMPED_FLOAT_TO_UBYTE(v->v.specular.alpha, fog[0][0]);
258 STRIDE_4F(fog, fog_stride);
259 }
260 if (DO_TEX0) {
261 v->v.u0 = tc0[0][0];
262 v->v.v0 = tc0[0][1];
263 if (DO_PTEX) {
264 if (HAVE_PTEX_VERTICES) {
265 if (tc0_size == 4)
266 v->pv.q0 = tc0[0][3];
267 else
268 v->pv.q0 = 1.0;
269 }
270 else if (tc0_size == 4) {
271 float rhw = 1.0 / tc0[0][3];
272 v->v.w *= tc0[0][3];
273 v->v.u0 *= rhw;
274 v->v.v0 *= rhw;
275 }
276 }
277 STRIDE_4F(tc0, tc0_stride);
278 }
279 if (DO_TEX1) {
280 if (DO_PTEX) {
281 v->pv.u1 = tc1[0][0];
282 v->pv.v1 = tc1[0][1];
283 if (tc1_size == 4)
284 v->pv.q1 = tc1[0][3];
285 else
286 v->pv.q1 = 1.0;
287 }
288 else {
289 v->v.u1 = tc1[0][0];
290 v->v.v1 = tc1[0][1];
291 }
292 STRIDE_4F(tc1, tc1_stride);
293 }
294 else if (DO_PTEX) {
295 *(GLuint *)&v->pv.q1 = 0; /* avoid culling on radeon */
296 }
297 if (DO_TEX2) {
298 if (DO_PTEX) {
299 v->pv.u2 = tc2[0][0];
300 v->pv.v2 = tc2[0][1];
301 if (tc2_size == 4)
302 v->pv.q2 = tc2[0][3];
303 else
304 v->pv.q2 = 1.0;
305 }
306 else {
307 v->v.u2 = tc2[0][0];
308 v->v.v2 = tc2[0][1];
309 }
310 STRIDE_4F(tc2, tc2_stride);
311 }
312 if (DO_TEX3) {
313 if (DO_PTEX) {
314 v->pv.u3 = tc3[0][0];
315 v->pv.v3 = tc3[0][1];
316 if (tc3_size == 4)
317 v->pv.q3 = tc3[0][3];
318 else
319 v->pv.q3 = 1.0;
320 }
321 else {
322 v->v.u3 = tc3[0][0];
323 v->v.v3 = tc3[0][1];
324 }
325 STRIDE_4F(tc3, tc3_stride);
326 }
327 }
328
329 }
330 #else
331
332 #if HAVE_HW_DIVIDE
333 #error "cannot use tiny vertices with hw perspective divide"
334 #endif
335
336 static void TAG(emit)( GLcontext *ctx, GLuint start, GLuint end,
337 void *dest, GLuint stride )
338 {
339 LOCALVARS
340 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
341 GLfloat (*col)[4];
342 GLuint col_stride;
343 GLfloat (*coord)[4] = VB->NdcPtr->data;
344 GLuint coord_stride = VB->NdcPtr->stride;
345 GLfloat *v = (GLfloat *)dest;
346 const GLubyte *mask = VB->ClipMask;
347 const GLfloat *s = GET_VIEWPORT_MAT();
348 int i;
349
350 (void) s;
351
352 ASSERT(stride == 4);
353
354 col = VB->ColorPtr[0]->data;
355 col_stride = VB->ColorPtr[0]->stride;
356
357 /* fprintf(stderr, "%s(small) importable %x\n", */
358 /* __FUNCTION__, VB->importable_data); */
359
360 /* Pack what's left into a 4-dword vertex. Color is in a different
361 * place, and there is no 'w' coordinate.
362 */
363 if (start) {
364 STRIDE_4F(coord, start * coord_stride);
365 STRIDE_4F(col, start * col_stride);
366 }
367
368 for (i=start; i < end; i++, v+=4) {
369 if (DO_XYZW) {
370 if (HAVE_HW_VIEWPORT || mask[i] == 0) {
371 VIEWPORT_X(v[0], coord[0][0]);
372 VIEWPORT_Y(v[1], coord[0][1]);
373 VIEWPORT_Z(v[2], coord[0][2]);
374 }
375 STRIDE_4F( coord, coord_stride );
376 }
377 if (DO_RGBA) {
378 VERTEX_COLOR *c = (VERTEX_COLOR *)&v[3];
379 UNCLAMPED_FLOAT_TO_UBYTE(c->red, col[0][0]);
380 UNCLAMPED_FLOAT_TO_UBYTE(c->green, col[0][1]);
381 UNCLAMPED_FLOAT_TO_UBYTE(c->blue, col[0][2]);
382 UNCLAMPED_FLOAT_TO_UBYTE(c->alpha, col[0][3]);
383 STRIDE_4F( col, col_stride );
384 }
385 /* fprintf(stderr, "vert %d: %.2f %.2f %.2f %x\n", */
386 /* i, v[0], v[1], v[2], *(int *)&v[3]); */
387 }
388 }
389
390 #endif /* emit */
391
392 #if (DO_XYZW) && (DO_RGBA)
393
394
395 #if (HAVE_PTEX_VERTICES)
396 static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
397 {
398 LOCALVARS
399 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
400
401 /* Force 'missing' texcoords to something valid.
402 */
403 if (DO_TEX3 && VB->TexCoordPtr[2] == 0)
404 VB->TexCoordPtr[2] = VB->TexCoordPtr[3];
405
406 if (DO_TEX2 && VB->TexCoordPtr[1] == 0)
407 VB->TexCoordPtr[1] = VB->TexCoordPtr[2];
408
409 if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
410 VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
411
412 if (DO_PTEX)
413 return GL_TRUE;
414
415 if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) ||
416 (DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) ||
417 (DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4) ||
418 (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4))
419 return GL_FALSE;
420
421 return GL_TRUE;
422 }
423 #else
424 static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
425 {
426 LOCALVARS
427 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
428
429 /* Force 'missing' texcoords to something valid.
430 */
431 if (DO_TEX3 && VB->TexCoordPtr[2] == 0)
432 VB->TexCoordPtr[2] = VB->TexCoordPtr[3];
433
434 if (DO_TEX2 && VB->TexCoordPtr[1] == 0)
435 VB->TexCoordPtr[1] = VB->TexCoordPtr[2];
436
437 if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
438 VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
439
440 if (DO_PTEX)
441 return GL_TRUE;
442
443 /* No hardware support for projective texture. Can fake it for
444 * TEX0 only.
445 */
446 if ((DO_TEX3 && VB->TexCoordPtr[GET_TEXSOURCE(3)]->size == 4) ||
447 (DO_TEX2 && VB->TexCoordPtr[GET_TEXSOURCE(2)]->size == 4) ||
448 (DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4)) {
449 PTEX_FALLBACK();
450 return GL_FALSE;
451 }
452
453 if (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4) {
454 if (DO_TEX1 || DO_TEX2 || DO_TEX3) {
455 PTEX_FALLBACK();
456 }
457 return GL_FALSE;
458 }
459
460 return GL_TRUE;
461 }
462 #endif /* ptex */
463
464
465 static void TAG(interp)( GLcontext *ctx,
466 GLfloat t,
467 GLuint edst, GLuint eout, GLuint ein,
468 GLboolean force_boundary )
469 {
470 LOCALVARS
471 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
472 GLubyte *ddverts = GET_VERTEX_STORE();
473 GLuint size = GET_VERTEX_SIZE();
474 const GLfloat *dstclip = VB->ClipPtr->data[edst];
475 GLfloat w;
476 const GLfloat *s = GET_VIEWPORT_MAT();
477
478 VERTEX *dst = (VERTEX *)(ddverts + (edst * size));
479 VERTEX *in = (VERTEX *)(ddverts + (ein * size));
480 VERTEX *out = (VERTEX *)(ddverts + (eout * size));
481
482 (void)s;
483
484 if (HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) {
485 VIEWPORT_X( dst->v.x, dstclip[0] );
486 VIEWPORT_Y( dst->v.y, dstclip[1] );
487 VIEWPORT_Z( dst->v.z, dstclip[2] );
488 w = dstclip[3];
489 }
490 else {
491 w = 1.0 / dstclip[3];
492 VIEWPORT_X( dst->v.x, dstclip[0] * w );
493 VIEWPORT_Y( dst->v.y, dstclip[1] * w );
494 VIEWPORT_Z( dst->v.z, dstclip[2] * w );
495 }
496
497 if ((HAVE_HW_DIVIDE && CHECK_HW_DIVIDE) ||
498 DO_FOG || DO_SPEC || DO_TEX0 || DO_TEX1 ||
499 DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES) {
500
501 dst->v.w = w;
502
503 INTERP_UB( t, dst->ub4[4][0], out->ub4[4][0], in->ub4[4][0] );
504 INTERP_UB( t, dst->ub4[4][1], out->ub4[4][1], in->ub4[4][1] );
505 INTERP_UB( t, dst->ub4[4][2], out->ub4[4][2], in->ub4[4][2] );
506 INTERP_UB( t, dst->ub4[4][3], out->ub4[4][3], in->ub4[4][3] );
507
508 if (DO_SPEC) {
509 INTERP_UB( t, dst->v.specular.red, out->v.specular.red, in->v.specular.red );
510 INTERP_UB( t, dst->v.specular.green, out->v.specular.green, in->v.specular.green );
511 INTERP_UB( t, dst->v.specular.blue, out->v.specular.blue, in->v.specular.blue );
512 }
513 if (DO_FOG) {
514 INTERP_UB( t, dst->v.specular.alpha, out->v.specular.alpha, in->v.specular.alpha );
515 }
516 if (DO_TEX0) {
517 if (DO_PTEX) {
518 if (HAVE_PTEX_VERTICES) {
519 INTERP_F( t, dst->pv.u0, out->pv.u0, in->pv.u0 );
520 INTERP_F( t, dst->pv.v0, out->pv.v0, in->pv.v0 );
521 INTERP_F( t, dst->pv.q0, out->pv.q0, in->pv.q0 );
522 } else {
523 GLfloat wout = VB->NdcPtr->data[eout][3];
524 GLfloat win = VB->NdcPtr->data[ein][3];
525 GLfloat qout = out->pv.w / wout;
526 GLfloat qin = in->pv.w / win;
527 GLfloat qdst, rqdst;
528
529 ASSERT( !HAVE_HW_DIVIDE );
530
531 INTERP_F( t, dst->v.u0, out->v.u0 * qout, in->v.u0 * qin );
532 INTERP_F( t, dst->v.v0, out->v.v0 * qout, in->v.v0 * qin );
533 INTERP_F( t, qdst, qout, qin );
534
535 rqdst = 1.0 / qdst;
536 dst->v.u0 *= rqdst;
537 dst->v.v0 *= rqdst;
538 dst->v.w *= rqdst;
539 }
540 }
541 else {
542 INTERP_F( t, dst->v.u0, out->v.u0, in->v.u0 );
543 INTERP_F( t, dst->v.v0, out->v.v0, in->v.v0 );
544 }
545 }
546 if (DO_TEX1) {
547 if (DO_PTEX) {
548 INTERP_F( t, dst->pv.u1, out->pv.u1, in->pv.u1 );
549 INTERP_F( t, dst->pv.v1, out->pv.v1, in->pv.v1 );
550 INTERP_F( t, dst->pv.q1, out->pv.q1, in->pv.q1 );
551 } else {
552 INTERP_F( t, dst->v.u1, out->v.u1, in->v.u1 );
553 INTERP_F( t, dst->v.v1, out->v.v1, in->v.v1 );
554 }
555 }
556 else if (DO_PTEX) {
557 dst->pv.q1 = 0.0; /* must be a valid float on radeon */
558 }
559 if (DO_TEX2) {
560 if (DO_PTEX) {
561 INTERP_F( t, dst->pv.u2, out->pv.u2, in->pv.u2 );
562 INTERP_F( t, dst->pv.v2, out->pv.v2, in->pv.v2 );
563 INTERP_F( t, dst->pv.q2, out->pv.q2, in->pv.q2 );
564 } else {
565 INTERP_F( t, dst->v.u2, out->v.u2, in->v.u2 );
566 INTERP_F( t, dst->v.v2, out->v.v2, in->v.v2 );
567 }
568 }
569 if (DO_TEX3) {
570 if (DO_PTEX) {
571 INTERP_F( t, dst->pv.u3, out->pv.u3, in->pv.u3 );
572 INTERP_F( t, dst->pv.v3, out->pv.v3, in->pv.v3 );
573 INTERP_F( t, dst->pv.q3, out->pv.q3, in->pv.q3 );
574 } else {
575 INTERP_F( t, dst->v.u3, out->v.u3, in->v.u3 );
576 INTERP_F( t, dst->v.v3, out->v.v3, in->v.v3 );
577 }
578 }
579 } else {
580 /* 4-dword vertex. Color is in v[3] and there is no oow coordinate.
581 */
582 INTERP_UB( t, dst->ub4[3][0], out->ub4[3][0], in->ub4[3][0] );
583 INTERP_UB( t, dst->ub4[3][1], out->ub4[3][1], in->ub4[3][1] );
584 INTERP_UB( t, dst->ub4[3][2], out->ub4[3][2], in->ub4[3][2] );
585 INTERP_UB( t, dst->ub4[3][3], out->ub4[3][3], in->ub4[3][3] );
586 }
587 }
588
589 #endif /* rgba && xyzw */
590
591
592 static void TAG(init)( void )
593 {
594 setup_tab[IND].emit = TAG(emit);
595
596 #if (DO_XYZW && DO_RGBA)
597 setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
598 setup_tab[IND].interp = TAG(interp);
599 #endif
600
601 if (DO_SPEC)
602 setup_tab[IND].copy_pv = copy_pv_rgba4_spec5;
603 else if (HAVE_HW_DIVIDE || DO_SPEC || DO_FOG || DO_TEX0 || DO_TEX1 ||
604 DO_TEX2 || DO_TEX3 || !HAVE_TINY_VERTICES)
605 setup_tab[IND].copy_pv = copy_pv_rgba4;
606 else
607 setup_tab[IND].copy_pv = copy_pv_rgba3;
608
609 if (DO_TEX3) {
610 if (DO_PTEX) {
611 ASSERT(HAVE_PTEX_VERTICES);
612 setup_tab[IND].vertex_format = PROJ_TEX3_VERTEX_FORMAT;
613 setup_tab[IND].vertex_size = 18;
614 }
615 else {
616 setup_tab[IND].vertex_format = TEX3_VERTEX_FORMAT;
617 setup_tab[IND].vertex_size = 14;
618 }
619 }
620 else if (DO_TEX2) {
621 if (DO_PTEX) {
622 ASSERT(HAVE_PTEX_VERTICES);
623 setup_tab[IND].vertex_format = PROJ_TEX3_VERTEX_FORMAT;
624 setup_tab[IND].vertex_size = 18;
625 }
626 else {
627 setup_tab[IND].vertex_format = TEX2_VERTEX_FORMAT;
628 setup_tab[IND].vertex_size = 12;
629 }
630 }
631 else if (DO_TEX1) {
632 if (DO_PTEX) {
633 ASSERT(HAVE_PTEX_VERTICES);
634 setup_tab[IND].vertex_format = PROJ_TEX1_VERTEX_FORMAT;
635 setup_tab[IND].vertex_size = 12;
636 }
637 else {
638 setup_tab[IND].vertex_format = TEX1_VERTEX_FORMAT;
639 setup_tab[IND].vertex_size = 10;
640 }
641 }
642 else if (DO_TEX0) {
643 if (DO_PTEX && HAVE_PTEX_VERTICES) {
644 setup_tab[IND].vertex_format = PROJ_TEX1_VERTEX_FORMAT;
645 setup_tab[IND].vertex_size = 12;
646 } else {
647 setup_tab[IND].vertex_format = TEX0_VERTEX_FORMAT;
648 setup_tab[IND].vertex_size = 8;
649 }
650 }
651 else if (!HAVE_HW_DIVIDE && !DO_SPEC && !DO_FOG && HAVE_TINY_VERTICES) {
652 setup_tab[IND].vertex_format = TINY_VERTEX_FORMAT;
653 setup_tab[IND].vertex_size = 4;
654 } else if (HAVE_NOTEX_VERTICES) {
655 setup_tab[IND].vertex_format = NOTEX_VERTEX_FORMAT;
656 setup_tab[IND].vertex_size = 6;
657 } else {
658 setup_tab[IND].vertex_format = TEX0_VERTEX_FORMAT;
659 setup_tab[IND].vertex_size = 8;
660 }
661 }
662
663
664 #undef IND
665 #undef TAG