fix up specular color/fog and triangle vertex retrieval
[mesa.git] / src / mesa / drivers / dri / mach64 / mach64_native_vbtmp.h
1 /* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
2 /*
3 * Mesa 3-D graphics library
4 * Version: 3.5
5 *
6 * Copyright (C) 1999-2001 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 * Original authors:
26 * Keith Whitwell <keithw@valinux.com>
27 *
28 * Adapted to Mach64 by:
29 * José Fonseca <j_r_fonseca@yahoo.co.uk>
30 */
31
32
33 /* DO_XYZW: Emit xyz and maybe w coordinates.
34 * DO_RGBA: Emit color.
35 * DO_SPEC: Emit specular color.
36 * DO_FOG: Emit fog coordinate in specular alpha.
37 * DO_TEX0: Emit tex0 u,v coordinates.
38 * DO_TEX1: Emit tex1 u,v coordinates.
39 * DO_PTEX: Emit tex0,1 q coordinates where possible.
40 *
41 * Additionally, this template assumes it is emitting *transformed*
42 * vertices; the modifications to emit untransformed vertices (ie. to
43 * t&l hardware) are probably too great to cooexist with the code
44 * already in this file.
45 */
46
47 #define VIEWPORT_X(x) ((GLint) ((s[0] * (x) + s[12]) * 4.0))
48 #define VIEWPORT_Y(y) ((GLint) ((s[5] * (y) + s[13]) * 4.0))
49 #define VIEWPORT_Z(z) (((GLuint) (s[10] * (z) + s[14])) << 15)
50
51 #ifndef LOCALVARS
52 #define LOCALVARS
53 #endif
54
55 static void TAG(emit)( GLcontext *ctx,
56 GLuint start, GLuint end,
57 void *dest,
58 GLuint stride )
59 {
60 LOCALVARS
61 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
62 #if DO_TEX1
63 GLfloat (*tc1)[4];
64 GLuint tc1_stride;
65 #if DO_PTEX
66 GLuint tc1_size;
67 #endif
68 #endif
69 #if DO_TEX0
70 GLfloat (*tc0)[4];
71 GLuint tc0_stride;
72 #if DO_PTEX
73 GLuint tc0_size;
74 #endif
75 #endif
76 #if DO_SPEC
77 GLfloat (*spec)[4];
78 GLuint spec_stride;
79 #endif
80 #if DO_FOG
81 GLfloat (*fog)[4];
82 GLuint fog_stride;
83 #endif
84 #if DO_RGBA
85 GLfloat (*col)[4];
86 GLuint col_stride;
87 #endif
88 GLfloat (*coord)[4];
89 GLuint coord_stride;
90 VERTEX *v = (VERTEX *)dest;
91 const GLfloat *s = GET_VIEWPORT_MAT();
92 #if DO_TEX1 || DO_TEX0 || DO_XYZW
93 const GLubyte *mask = VB->ClipMask;
94 #endif
95 int i;
96
97 #if !DO_XYZW
98 (void) s; /* Quiet compiler */
99 #endif
100 /* fprintf(stderr, "%s(big) importable %d %d..%d\n", */
101 /* __FUNCTION__, VB->importable_data, start, end); */
102
103 #if DO_TEX1
104 {
105 const GLuint t1 = GET_TEXSOURCE(1);
106 tc1 = VB->TexCoordPtr[t1]->data;
107 tc1_stride = VB->TexCoordPtr[t1]->stride;
108 #if DO_PTEX
109 tc1_size = VB->TexCoordPtr[t1]->size;
110 #endif
111 }
112 #endif
113
114 #if DO_TEX0
115 {
116 const GLuint t0 = GET_TEXSOURCE(0);
117 tc0 = VB->TexCoordPtr[t0]->data;
118 tc0_stride = VB->TexCoordPtr[t0]->stride;
119 #if DO_PTEX
120 tc0_size = VB->TexCoordPtr[t0]->size;
121 #endif
122 }
123 #endif
124
125 #if DO_SPEC
126 if (VB->SecondaryColorPtr[0]) {
127 spec = VB->SecondaryColorPtr[0]->data;
128 spec_stride = VB->SecondaryColorPtr[0]->stride;
129 } else {
130 spec = (GLfloat (*)[4])ctx->Current.Attrib[VERT_ATTRIB_COLOR1];
131 spec_stride = 0;
132 }
133 #endif
134
135 #if DO_FOG
136 if (VB->FogCoordPtr) {
137 fog = VB->FogCoordPtr->data;
138 fog_stride = VB->FogCoordPtr->stride;
139 } else {
140 static GLfloat tmp[4] = {0, 0, 0, 0};
141 fog = &tmp;
142 fog_stride = 0;
143 }
144 #endif
145
146 #if DO_RGBA
147 col = VB->ColorPtr[0]->data;
148 col_stride = VB->ColorPtr[0]->stride;
149 #endif
150
151 coord = VB->NdcPtr->data;
152 coord_stride = VB->NdcPtr->stride;
153
154 if (start) {
155 #if DO_TEX1
156 STRIDE_4F(tc1, start * tc1_stride);
157 #endif
158 #if DO_TEX0
159 STRIDE_4F(tc0, start * tc0_stride);
160 #endif
161 #if DO_SPEC
162 STRIDE_4F(spec, start * spec_stride);
163 #endif
164 #if DO_FOG
165 STRIDE_4F(fog, start * fog_stride);
166 #endif
167 #if DO_RGBA
168 STRIDE_4F(col, start * col_stride);
169 #endif
170 STRIDE_4F(coord, start * coord_stride);
171 }
172
173 for (i=start; i < end; i++, v = (VERTEX *)((GLubyte *)v + stride)) {
174 CARD32 *p = (CARD32 *)v;
175 #if DO_TEX1 || DO_TEX0
176 GLfloat w;
177
178 if (mask[i] == 0) {
179 /* unclipped */
180 w = coord[0][3];
181 } else {
182 /* clipped */
183 w = 1.0;
184 }
185 #endif
186
187 #if DO_TEX1
188 #if DO_PTEX
189 if (tc1_size == 4) {
190 #ifdef MACH64_PREMULT_TEXCOORDS
191 LE32_OUT_FLOAT( p++, w*tc1[0][0] ); /* VERTEX_?_SECONDARY_S */
192 LE32_OUT_FLOAT( p++, w*tc1[0][1] ); /* VERTEX_?_SECONDARY_T */
193 LE32_OUT_FLOAT( p++, w*tc1[0][3] ); /* VERTEX_?_SECONDARY_W */
194 #else /* !MACH64_PREMULT_TEXCOORDS */
195 float rhw = 1.0 / tc1[0][3];
196 LE32_OUT_FLOAT( p++, rhw*tc1[0][0] ); /* VERTEX_?_SECONDARY_S */
197 LE32_OUT_FLOAT( p++, rhw*tc1[0][1] ); /* VERTEX_?_SECONDARY_T */
198 LE32_OUT_FLOAT( p++, w*tc1[0][3] ); /* VERTEX_?_SECONDARY_W */
199 #endif /* !MACH64_PREMULT_TEXCOORDS */
200 } else {
201 #endif /* DO_PTEX */
202 #ifdef MACH64_PREMULT_TEXCOORDS
203 LE32_OUT_FLOAT( p++, w*tc1[0][0] ); /* VERTEX_?_SECONDARY_S */
204 LE32_OUT_FLOAT( p++, w*tc1[0][1] ); /* VERTEX_?_SECONDARY_T */
205 LE32_OUT_FLOAT( p++, w ); /* VERTEX_?_SECONDARY_W */
206 #else /* !MACH64_PREMULT_TEXCOORDS */
207 LE32_OUT_FLOAT( p++, tc1[0][0] ); /* VERTEX_?_SECONDARY_S */
208 LE32_OUT_FLOAT( p++, tc1[0][1] ); /* VERTEX_?_SECONDARY_T */
209 LE32_OUT_FLOAT( p++, w ); /* VERTEX_?_SECONDARY_W */
210 #endif /* !MACH64_PREMULT_TEXCOORDS */
211 #if DO_PTEX
212 }
213 #endif /* DO_PTEX */
214 STRIDE_4F(tc1, tc1_stride);
215 #else /* !DO_TEX1 */
216 p += 3;
217 #endif /* !DO_TEX1 */
218
219 #if DO_TEX0
220 #if DO_PTEX
221 if (tc0_size == 4) {
222 #ifdef MACH64_PREMULT_TEXCOORDS
223 LE32_OUT_FLOAT( p++, w*tc0[0][0] ); /* VERTEX_?_S */
224 LE32_OUT_FLOAT( p++, w*tc0[0][1] ); /* VERTEX_?_T */
225 LE32_OUT_FLOAT( p++, w*tc0[0][3] ); /* VERTEX_?_W */
226 #else /* !MACH64_PREMULT_TEXCOORDS */
227 float rhw = 1.0 / tc0[0][3];
228 LE32_OUT_FLOAT( p++, rhw*tc0[0][0] ); /* VERTEX_?_S */
229 LE32_OUT_FLOAT( p++, rhw*tc0[0][1] ); /* VERTEX_?_T */
230 LE32_OUT_FLOAT( p++, w*tc0[0][3] ); /* VERTEX_?_W */
231 #endif /* !MACH64_PREMULT_TEXCOORDS */
232 } else {
233 #endif /* DO_PTEX */
234 #ifdef MACH64_PREMULT_TEXCOORDS
235 LE32_OUT_FLOAT( p++, w*tc0[0][0] ); /* VERTEX_?_S */
236 LE32_OUT_FLOAT( p++, w*tc0[0][1] ); /* VERTEX_?_T */
237 LE32_OUT_FLOAT( p++, w ); /* VERTEX_?_W */
238 #else /* !MACH64_PREMULT_TEXCOORDS */
239 LE32_OUT_FLOAT( p++, tc0[0][0] ); /* VERTEX_?_S */
240 LE32_OUT_FLOAT( p++, tc0[0][1] ); /* VERTEX_?_T */
241 LE32_OUT_FLOAT( p++, w ); /* VERTEX_?_W */
242 #endif /* !MACH64_PREMULT_TEXCOORDS */
243 #if DO_PTEX
244 }
245 #endif /* DO_PTEX */
246 STRIDE_4F(tc0, tc0_stride);
247 #else /* !DO_TEX0 */
248 p += 3;
249 #endif /* !DO_TEX0 */
250
251 #if DO_SPEC
252 UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[0], spec[0][2]); /* VERTEX_?_SPEC_B */
253 UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[1], spec[0][1]); /* VERTEX_?_SPEC_G */
254 UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[2], spec[0][0]); /* VERTEX_?_SPEC_R */
255
256 STRIDE_4F(spec, spec_stride);
257 #endif
258 #if DO_FOG
259 UNCLAMPED_FLOAT_TO_UBYTE(((GLubyte *)p)[3], fog[0][0]); /* VERTEX_?_SPEC_A */
260 /* ((GLubyte *)p)[3] = fog[0][0] * 255.0; */
261 STRIDE_4F(fog, fog_stride);
262 #endif
263 p++;
264
265 #if DO_XYZW
266 if (mask[i] == 0) {
267 /* unclipped */
268 LE32_OUT( p++, VIEWPORT_Z( coord[0][2] ) ); /* VERTEX_?_Z */
269 } else {
270 #endif
271 p++;
272 #if DO_XYZW
273 }
274 #endif
275
276 #if DO_RGBA
277 UNCLAMPED_FLOAT_TO_UBYTE(*((GLubyte *)p), col[0][2]);
278 *((GLubyte *)p)++;
279 UNCLAMPED_FLOAT_TO_UBYTE(*((GLubyte *)p), col[0][1]);
280 *((GLubyte *)p)++;
281 UNCLAMPED_FLOAT_TO_UBYTE(*((GLubyte *)p), col[0][0]);
282 *((GLubyte *)p)++;
283 UNCLAMPED_FLOAT_TO_UBYTE(*((GLubyte *)p), col[0][3]);
284 *((GLubyte *)p)++;
285 STRIDE_4F(col, col_stride);
286 #else
287 p++;
288 #endif
289
290 #if DO_XYZW
291 if (mask[i] == 0) {
292 /* unclipped */
293 LE32_OUT( p,
294 (VIEWPORT_X( coord[0][0] ) << 16) | /* VERTEX_?_X */
295 (VIEWPORT_Y( coord[0][1] ) & 0xffff) ); /* VERTEX_?_Y */
296
297 if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) {
298 fprintf( stderr, "%s: vert %d: %.2f %.2f %.2f %x\n",
299 __FUNCTION__,
300 i,
301 (LE32_IN( p ) >> 16)/4.0,
302 (LE32_IN( p ) & 0xffff)/4.0,
303 LE32_IN( p - 2 )/65536.0,
304 *(GLuint *)(p - 1) );
305 }
306 }
307 #endif
308 #if DO_TEX1 || DO_TEX0 || DO_XYZW
309 STRIDE_4F(coord, coord_stride);
310 #endif
311
312 assert( p + 1 - (CARD32 *)v == 10 );
313 }
314 }
315
316 #if DO_XYZW && DO_RGBA
317
318 static GLboolean TAG(check_tex_sizes)( GLcontext *ctx )
319 {
320 LOCALVARS
321 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
322
323 /* Force 'missing' texcoords to something valid.
324 */
325 if (DO_TEX1 && VB->TexCoordPtr[0] == 0)
326 VB->TexCoordPtr[0] = VB->TexCoordPtr[1];
327
328 if (DO_PTEX)
329 return GL_TRUE;
330
331 /* No hardware support for projective texture. Can fake it for
332 * TEX0 only.
333 */
334 if ((DO_TEX1 && VB->TexCoordPtr[GET_TEXSOURCE(1)]->size == 4)) {
335 PTEX_FALLBACK();
336 return GL_FALSE;
337 }
338
339 if (DO_TEX0 && VB->TexCoordPtr[GET_TEXSOURCE(0)]->size == 4) {
340 if (DO_TEX1) {
341 PTEX_FALLBACK();
342 }
343 return GL_FALSE;
344 }
345
346 return GL_TRUE;
347 }
348
349
350 static void TAG(interp)( GLcontext *ctx,
351 GLfloat t,
352 GLuint edst, GLuint eout, GLuint ein,
353 GLboolean force_boundary )
354 {
355 LOCALVARS
356 struct vertex_buffer *VB = &TNL_CONTEXT(ctx)->vb;
357 GLubyte *ddverts = GET_VERTEX_STORE();
358 /* GLuint shift = GET_VERTEX_STRIDE_SHIFT();*/
359 GLuint size = GET_VERTEX_SIZE();
360 const GLfloat *dstclip = VB->ClipPtr->data[edst];
361 GLfloat w;
362 const GLfloat *s = GET_VIEWPORT_MAT();
363
364 CARD32 *dst = (CARD32 *)(ddverts + (edst * size));
365 CARD32 *in = (CARD32 *)(ddverts + (ein * size));
366 CARD32 *out = (CARD32 *)(ddverts + (eout * size));
367
368 (void)s;
369
370 w = (dstclip[3] == 0.0F) ? 1.0 : (1.0 / dstclip[3]);
371
372 #if DO_TEX1
373 {
374 GLfloat temp;
375 #if DO_PTEX
376 GLfloat wout = VB->NdcPtr->data[eout][3];
377 GLfloat win = VB->NdcPtr->data[ein][3];
378 GLfloat qout = LE32_IN_FLOAT( out + 2 ) / wout;
379 GLfloat qin = LE32_IN_FLOAT( in + 2 ) / win;
380 GLfloat qdst, rqdst;
381
382 INTERP_F( t, qdst, qout, qin );
383 rqdst = 1.0 / qdst;
384
385 INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
386 LE32_OUT_FLOAT( dst, temp*rqdst ); /* VERTEX_?_SECONDARY_S */
387 dst++; out++; in++;
388
389 INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
390 LE32_OUT_FLOAT( dst, temp*rqdst ); /* VERTEX_?_SECONDARY_T */
391 dst++; out++; in++;
392
393 LE32_OUT_FLOAT( dst, w*rqdst ); /* VERTEX_?_SECONDARY_W */
394 dst++; out++; in++;
395 #else /* !DO_PTEX */
396 #ifdef MACH64_PREMULT_TEXCOORDS
397 GLfloat qout = w / LE32_IN_FLOAT( out + 2 );
398 GLfloat qin = w / LE32_IN_FLOAT( in + 2 );
399
400 INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
401 LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_SECONDARY_S */
402 dst++; out++; in++;
403
404 INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
405 LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_SECONDARY_T */
406 dst++; out++; in++;
407 #else /* !MACH64_PREMULT_TEXCOORDS */
408 INTERP_F( t, temp, LE32_IN_FLOAT( out ), LE32_IN_FLOAT( in ) );
409 LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_SECONDARY_S */
410 dst++; out++; in++;
411
412 INTERP_F( t, temp, LE32_IN_FLOAT( out ), LE32_IN_FLOAT( in ) );
413 LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_SECONDARY_T */
414 dst++; out++; in++;
415 #endif /* !MACH64_PREMULT_TEXCOORDS */
416 LE32_OUT_FLOAT( dst, w ); /* VERTEX_?_SECONDARY_W */
417 dst++; out++; in++;
418 #endif /* !DO_PTEX */
419 }
420 #else /* !DO_TEX1 */
421 dst += 3; out += 3; in += 3;
422 #endif /* !DO_TEX1 */
423
424 #if DO_TEX0
425 {
426 GLfloat temp;
427 #if DO_PTEX
428 GLfloat wout = VB->NdcPtr->data[eout][3];
429 GLfloat win = VB->NdcPtr->data[ein][3];
430 GLfloat qout = LE32_IN_FLOAT( out + 2 ) / wout;
431 GLfloat qin = LE32_IN_FLOAT( in + 2 ) / win;
432 GLfloat qdst, rqdst;
433
434 INTERP_F( t, qdst, qout, qin );
435 rqdst = 1.0 / qdst;
436
437 INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
438 LE32_OUT_FLOAT( dst, temp*rqdst ); /* VERTEX_?_S */
439 dst++; out++; in++;
440
441 INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
442 LE32_OUT_FLOAT( dst, temp*rqdst ); /* VERTEX_?_T */
443 dst++; out++; in++;
444
445 LE32_OUT_FLOAT( dst, w*rqdst ); /* VERTEX_?_W */
446 dst++; out++; in++;
447 #else /* !DO_PTEX */
448 #ifdef MACH64_PREMULT_TEXCOORDS
449 GLfloat qout = w / LE32_IN_FLOAT( out + 2 );
450 GLfloat qin = w / LE32_IN_FLOAT( in + 2 );
451
452 INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
453 LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_S */
454 dst++; out++; in++;
455
456 INTERP_F( t, temp, LE32_IN_FLOAT( out ) * qout, LE32_IN_FLOAT( in ) * qin );
457 LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_T */
458 dst++; out++; in++;
459 #else /* !MACH64_PREMULT_TEXCOORDS */
460 INTERP_F( t, temp, LE32_IN_FLOAT( out ), LE32_IN_FLOAT( in ) );
461 LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_S */
462 dst++; out++; in++;
463
464 INTERP_F( t, temp, LE32_IN_FLOAT( out ), LE32_IN_FLOAT( in ) );
465 LE32_OUT_FLOAT( dst, temp ); /* VERTEX_?_T */
466 dst++; out++; in++;
467 #endif /* !MACH64_PREMULT_TEXCOORDS */
468 LE32_OUT_FLOAT( dst, w ); /* VERTEX_?_W */
469 dst++; out++; in++;
470 #endif /* !DO_PTEX */
471 }
472 #else /* !DO_TEX0 */
473 dst += 3; out += 3; in += 3;
474 #endif /* !DO_TEX0 */
475
476 #if DO_SPEC
477 INTERP_UB( t, *(GLubyte *)dst, *(GLubyte *)out, *(GLubyte *)in ); /* VERTEX_?_SPEC_B */
478 ((GLubyte *)dst)++; ((GLubyte *)out)++; ((GLubyte *)in)++;
479
480 INTERP_UB( t, *(GLubyte *)dst, *(GLubyte *)out, *(GLubyte *)in ); /* VERTEX_?_SPEC_G */
481 ((GLubyte *)dst)++; ((GLubyte *)out)++; ((GLubyte *)in)++;
482
483 INTERP_UB( t, *(GLubyte *)dst, *(GLubyte *)out, *(GLubyte *)in ); /* VERTEX_?_SPEC_R */
484 #if DO_FOG
485 ((GLubyte *)dst)++; ((GLubyte *)out)++; ((GLubyte *)in)++;
486 #else /* !DO_FOG */
487 ((GLubyte *)dst) += 2; ((GLubyte *)out) += 2; ((GLubyte *)in) += 2;
488 #endif /* !DO_FOG */
489 #elif DO_FOG
490 ((GLubyte *)dst) += 3; ((GLubyte *)out) += 3; ((GLubyte *)in) += 3;
491 #endif
492
493 #if DO_FOG
494 INTERP_UB( t, *(GLubyte *)dst, *(GLubyte *)out, *(GLubyte *)in ); /* VERTEX_?_SPEC_A */
495 ((GLubyte *)dst)++; ((GLubyte *)out)++; ((GLubyte *)in)++;
496 #endif /* DO_FOG */
497
498 #if !DO_SPEC && !DO_FOG
499 dst++; out++; in++;
500 #endif
501
502 LE32_OUT( dst, VIEWPORT_Z( dstclip[2] * w ) ); /* VERTEX_?_Z */
503 dst++; out++; in++;
504
505 INTERP_UB( t, *(GLubyte *)dst, *(GLubyte *)out, *(GLubyte *)in ); /* VERTEX_?_B */
506 ((GLubyte *)dst)++; ((GLubyte *)out)++; ((GLubyte *)in)++;
507
508 INTERP_UB( t, *(GLubyte *)dst, *(GLubyte *)out, *(GLubyte *)in ); /* VERTEX_?_G */
509 ((GLubyte *)dst)++; ((GLubyte *)out)++; ((GLubyte *)in)++;
510
511 INTERP_UB( t, *(GLubyte *)dst, *(GLubyte *)out, *(GLubyte *)in ); /* VERTEX_?_R */
512 ((GLubyte *)dst)++; ((GLubyte *)out)++; ((GLubyte *)in)++;
513
514 INTERP_UB( t, *(GLubyte *)dst, *(GLubyte *)out, *(GLubyte *)in ); /* VERTEX_?_A */
515 ((GLubyte *)dst)++; /* ((GLubyte *)out)++; ((GLubyte *)in)++; */
516
517 LE32_OUT( dst,
518 (VIEWPORT_X( dstclip[0] * w ) << 16) | /* VERTEX_?_X */
519 (VIEWPORT_Y( dstclip[1] * w ) & 0xffff) ); /* VERTEX_?_Y */
520
521 assert( dst + 1 - (CARD32 *)(ddverts + (edst * size)) == 10 );
522 assert( in + 2 - (CARD32 *)(ddverts + (ein * size)) == 10 );
523 assert( out + 2 - (CARD32 *)(ddverts + (eout * size)) == 10 );
524
525 if (MACH64_DEBUG & DEBUG_VERBOSE_PRIMS) {
526 fprintf( stderr, "%s: dst vert: %.2f %.2f %.2f %x\n",
527 __FUNCTION__,
528 (GLshort)(LE32_IN( dst ) >> 16)/4.0,
529 (GLshort)(LE32_IN( dst ) & 0xffff)/4.0,
530 LE32_IN( dst - 2 )/65536.0,
531 *(GLuint *)(dst - 1) );
532 }
533 }
534
535 #endif /* DO_RGBA && DO_XYZW */
536
537
538 static void TAG(copy_pv)( GLcontext *ctx, GLuint edst, GLuint esrc )
539 {
540 #if DO_SPEC || DO_FOG || DO_RGBA
541 LOCALVARS
542 GLubyte *verts = GET_VERTEX_STORE();
543 GLuint shift = GET_VERTEX_STRIDE_SHIFT();
544 GLuint *dst = (GLuint *)(verts + (edst << shift));
545 GLuint *src = (GLuint *)(verts + (esrc << shift));
546 #endif
547
548 #if DO_SPEC || DO_FOG
549 dst[6] = src[6]; /* VERTEX_?_SPEC_ARGB */
550 #endif
551
552 #if DO_RGBA
553 dst[8] = src[8]; /* VERTEX_?_ARGB */
554 #endif
555 }
556
557 static void TAG(init)( void )
558 {
559 setup_tab[IND].emit = TAG(emit);
560
561 #if DO_XYZW && DO_RGBA
562 setup_tab[IND].check_tex_sizes = TAG(check_tex_sizes);
563 setup_tab[IND].interp = TAG(interp);
564 #endif
565
566 setup_tab[IND].copy_pv = TAG(copy_pv);
567
568 /* vertex_stride_shift must be the same because each
569 * vertex is aligned with the end of the structure and
570 * not the beginning
571 */
572 #if DO_TEX1
573 setup_tab[IND].vertex_format = TEX1_VERTEX_FORMAT;
574 setup_tab[IND].vertex_size = 10;
575 setup_tab[IND].vertex_stride_shift = 6;
576 #elif DO_TEX0
577 setup_tab[IND].vertex_format = TEX0_VERTEX_FORMAT;
578 setup_tab[IND].vertex_size = 7;
579 setup_tab[IND].vertex_stride_shift = 6;
580 #elif DO_SPEC || DO_FOG
581 setup_tab[IND].vertex_format = NOTEX_VERTEX_FORMAT;
582 setup_tab[IND].vertex_size = 4;
583 setup_tab[IND].vertex_stride_shift = 6;
584 #else
585 setup_tab[IND].vertex_format = TINY_VERTEX_FORMAT;
586 setup_tab[IND].vertex_size = 3;
587 setup_tab[IND].vertex_stride_shift = 6;
588 #endif
589
590 assert(setup_tab[IND].vertex_size * 4 <=
591 1 << setup_tab[IND].vertex_stride_shift);
592 }
593
594
595 #undef IND
596 #undef TAG