1 /* $Id: t_dd_vbtmp.h,v 1.14 2001/05/03 16:49:28 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
27 * Keith Whitwell <keithw@valinux.com>
31 /* Unlike the other templates here, this assumes quite a bit about the
32 * underlying hardware. Specifically it assumes a d3d-like vertex
33 * format, with a layout more or less constrained to look like the
39 * struct { char r, g, b, a; } color;
40 * struct { char r, g, b, fog; } spec;
48 * struct { char r, g, b, a; } color;
49 * struct { char r, g, b, fog; } spec;
57 * struct { char r, g, b, a; } color;
60 * unsigned int ui[16];
61 * unsigned char ub4[4][16];
65 * DO_XYZW: Emit xyz and maybe w coordinates.
66 * DO_RGBA: Emit color.
67 * DO_SPEC: Emit specular color.
68 * DO_FOG: Emit fog coordinate in specular alpha.
69 * DO_TEX0: Emit tex0 u,v coordinates.
70 * DO_TEX1: Emit tex1 u,v coordinates.
71 * DO_TEX2: Emit tex2 u,v coordinates.
72 * DO_TEX3: Emit tex3 u,v coordinates.
73 * DO_PTEX: Emit tex0,1,2,3 q coordinates where possible.
75 * HAVE_RGBA_COLOR: Hardware takes color in rgba order (else bgra).
77 * HAVE_HW_VIEWPORT: Hardware performs viewport transform.
78 * HAVE_HW_DIVIDE: Hardware performs perspective divide.
80 * HAVE_TINY_VERTICES: Hardware understands v.tv format.
81 * HAVE_PTEX_VERTICES: Hardware understands v.pv format.
82 * HAVE_NOTEX_VERTICES: Hardware understands v.v format with texcount 0.
84 * Additionally, this template assumes it is emitting *transformed*
85 * vertices; the modifications to emit untransformed vertices (ie. to
86 * t&l hardware) are probably too great to cooexist with the code
87 * already in this file.
89 * NOTE: The PTEX vertex format always includes TEX0 and TEX1, even if
90 * only TEX0 is enabled, in order to maintain a vertex size which is
91 * an exact number of quadwords.
94 #if (HAVE_HW_VIEWPORT)
95 #define VIEWPORT_X(dst,x) dst = x
96 #define VIEWPORT_Y(dst,y) dst = y
97 #define VIEWPORT_Z(dst,z) dst = z
99 #define VIEWPORT_X(dst,x) dst = s[0] * x + s[12]
100 #define VIEWPORT_Y(dst,y) dst = s[5] * y + s[13]
101 #define VIEWPORT_Z(dst,z) dst = s[10] * z + s[14]
104 #if (HAVE_HW_DIVIDE && !HAVE_PTEX_VERTICES)
105 #error "can't cope with this combination"
112 #ifndef CHECK_HW_DIVIDE
113 #define CHECK_HW_DIVIDE 1
116 #if (HAVE_HW_DIVIDE || DO_SPEC || DO_TEX0 || DO_FOG || !HAVE_TINY_VERTICES)
118 static void TAG(emit
)( GLcontext
*ctx
,
119 GLuint start
, GLuint end
,
124 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
125 GLfloat (*tc0
)[4], (*tc1
)[4], *fog
;
126 GLfloat (*tc2
)[4], (*tc3
)[4];
127 GLubyte (*col
)[4], (*spec
)[4];
128 GLuint tc0_stride
, tc1_stride
, col_stride
, spec_stride
, fog_stride
;
129 GLuint tc2_stride
, tc3_stride
;
130 GLuint tc0_size
, tc1_size
;
131 GLuint tc2_size
, tc3_size
;
134 VERTEX
*v
= (VERTEX
*)dest
;
135 const GLfloat
*s
= GET_VIEWPORT_MAT();
136 const GLubyte
*mask
= VB
->ClipMask
;
139 if (HAVE_HW_VIEWPORT
&& HAVE_HW_DIVIDE
&& CHECK_HW_DIVIDE
) {
141 coord
= VB
->ClipPtr
->data
;
142 coord_stride
= VB
->ClipPtr
->stride
;
145 coord
= VB
->ProjectedClipPtr
->data
;
146 coord_stride
= VB
->ProjectedClipPtr
->stride
;
150 const GLuint t3
= GET_TEXSOURCE(3);
151 tc3
= VB
->TexCoordPtr
[t3
]->data
;
152 tc3_stride
= VB
->TexCoordPtr
[t3
]->stride
;
154 tc3_size
= VB
->TexCoordPtr
[t3
]->size
;
158 const GLuint t2
= GET_TEXSOURCE(2);
159 tc2
= VB
->TexCoordPtr
[t2
]->data
;
160 tc2_stride
= VB
->TexCoordPtr
[t2
]->stride
;
162 tc2_size
= VB
->TexCoordPtr
[t2
]->size
;
166 const GLuint t1
= GET_TEXSOURCE(1);
167 tc1
= VB
->TexCoordPtr
[t1
]->data
;
168 tc1_stride
= VB
->TexCoordPtr
[t1
]->stride
;
170 tc1_size
= VB
->TexCoordPtr
[t1
]->size
;
174 const GLuint t0
= GET_TEXSOURCE(0);
175 tc0_stride
= VB
->TexCoordPtr
[t0
]->stride
;
176 tc0
= VB
->TexCoordPtr
[t0
]->data
;
178 tc0_size
= VB
->TexCoordPtr
[t0
]->size
;
182 if (VB
->ColorPtr
[0]->Type
!= GL_UNSIGNED_BYTE
)
183 IMPORT_FLOAT_COLORS( ctx
);
184 col
= (GLubyte (*)[4])VB
->ColorPtr
[0]->Ptr
;
185 col_stride
= VB
->ColorPtr
[0]->StrideB
;
189 if (VB
->SecondaryColorPtr
[0]->Type
!= GL_UNSIGNED_BYTE
)
190 IMPORT_FLOAT_SPEC_COLORS( ctx
);
191 spec
= (GLubyte (*)[4])VB
->SecondaryColorPtr
[0]->Ptr
;
192 spec_stride
= VB
->SecondaryColorPtr
[0]->StrideB
;
196 fog
= VB
->FogCoordPtr
->data
;
197 fog_stride
= VB
->FogCoordPtr
->stride
;
200 if (VB
->importable_data
) {
201 /* May have nonstandard strides:
204 coord
= (GLfloat (*)[4])((GLubyte
*)coord
+ start
* coord_stride
);
206 tc0
= (GLfloat (*)[4])((GLubyte
*)tc0
+ start
* tc0_stride
);
208 tc1
= (GLfloat (*)[4])((GLubyte
*)tc1
+ start
* tc1_stride
);
210 tc2
= (GLfloat (*)[4])((GLubyte
*)tc2
+ start
* tc2_stride
);
212 tc3
= (GLfloat (*)[4])((GLubyte
*)tc3
+ start
* tc3_stride
);
214 STRIDE_4UB(col
, start
* col_stride
);
216 STRIDE_4UB(spec
, start
* spec_stride
);
218 STRIDE_F(fog
, start
* fog_stride
);
221 for (i
=start
; i
< end
; i
++, v
= (VERTEX
*)((GLubyte
*)v
+ stride
)) {
223 if (HAVE_HW_VIEWPORT
|| mask
[i
] == 0) {
224 VIEWPORT_X(v
->v
.x
, coord
[0][0]);
225 VIEWPORT_Y(v
->v
.y
, coord
[0][1]);
226 VIEWPORT_Z(v
->v
.z
, coord
[0][2]);
227 v
->v
.w
= coord
[0][3];
229 coord
= (GLfloat (*)[4])((GLubyte
*)coord
+ coord_stride
);
232 if (HAVE_RGBA_COLOR
) {
233 *(GLuint
*)&v
->v
.color
= *(GLuint
*)&col
[0];
234 STRIDE_4UB(col
, col_stride
);
236 v
->v
.color
.blue
= col
[0][2];
237 v
->v
.color
.green
= col
[0][1];
238 v
->v
.color
.red
= col
[0][0];
239 v
->v
.color
.alpha
= col
[0][3];
240 STRIDE_4UB(col
, col_stride
);
244 v
->v
.specular
.red
= spec
[0][0];
245 v
->v
.specular
.green
= spec
[0][1];
246 v
->v
.specular
.blue
= spec
[0][2];
247 STRIDE_4UB(spec
, spec_stride
);
250 v
->v
.specular
.alpha
= fog
[0] * 255.0;
251 STRIDE_F(fog
, fog_stride
);
257 if (HAVE_PTEX_VERTICES
) {
259 v
->pv
.q0
= tc0
[0][3];
263 else if (tc0_size
== 4) {
264 float rhw
= 1.0 / tc0
[0][3];
270 tc0
= (GLfloat (*)[4])((GLubyte
*)tc0
+ tc0_stride
);
274 v
->pv
.u1
= tc1
[0][0];
275 v
->pv
.v1
= tc1
[0][1];
277 v
->pv
.q1
= tc1
[0][3];
285 tc1
= (GLfloat (*)[4])((GLubyte
*)tc1
+ tc1_stride
);
288 *(GLuint
*)&v
->pv
.q1
= 0; /* avoid culling on radeon */
292 v
->pv
.u2
= tc2
[0][0];
293 v
->pv
.v2
= tc2
[0][1];
295 v
->pv
.q2
= tc2
[0][3];
303 tc2
= (GLfloat (*)[4])((GLubyte
*)tc2
+ tc2_stride
);
307 v
->pv
.u3
= tc3
[0][0];
308 v
->pv
.v3
= tc3
[0][1];
310 v
->pv
.q3
= tc3
[0][3];
318 tc3
= (GLfloat (*)[4])((GLubyte
*)tc3
+ tc3_stride
);
323 for (i
=start
; i
< end
; i
++, v
= (VERTEX
*)((GLubyte
*)v
+ stride
)) {
325 if (HAVE_HW_VIEWPORT
|| mask
[i
] == 0) {
326 VIEWPORT_X(v
->v
.x
, coord
[i
][0]);
327 VIEWPORT_Y(v
->v
.y
, coord
[i
][1]);
328 VIEWPORT_Z(v
->v
.z
, coord
[i
][2]);
329 v
->v
.w
= coord
[i
][3];
333 if (HAVE_RGBA_COLOR
) {
334 *(GLuint
*)&v
->v
.color
= *(GLuint
*)&col
[i
];
337 v
->v
.color
.blue
= col
[i
][2];
338 v
->v
.color
.green
= col
[i
][1];
339 v
->v
.color
.red
= col
[i
][0];
340 v
->v
.color
.alpha
= col
[i
][3];
344 v
->v
.specular
.red
= spec
[i
][0];
345 v
->v
.specular
.green
= spec
[i
][1];
346 v
->v
.specular
.blue
= spec
[i
][2];
349 v
->v
.specular
.alpha
= fog
[i
] * 255.0;
355 if (HAVE_PTEX_VERTICES
) {
357 v
->pv
.q0
= tc0
[i
][3];
361 v
->pv
.q1
= 0; /* radeon */
363 else if (tc0_size
== 4) {
364 float rhw
= 1.0 / tc0
[i
][3];
373 v
->pv
.u1
= tc1
[i
][0];
374 v
->pv
.v1
= tc1
[i
][1];
376 v
->pv
.q1
= tc1
[i
][3];
392 #error "cannot use tiny vertices with hw perspective divide"
395 static void TAG(emit
)( GLcontext
*ctx
, GLuint start
, GLuint end
,
396 void *dest
, GLuint stride
)
399 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
402 GLfloat (*coord
)[4] = VB
->ProjectedClipPtr
->data
;
403 GLuint coord_stride
= VB
->ProjectedClipPtr
->stride
;
404 GLfloat
*v
= (GLfloat
*)dest
;
405 const GLubyte
*mask
= VB
->ClipMask
;
406 const GLfloat
*s
= GET_VIEWPORT_MAT();
413 if (VB
->ColorPtr
[0]->Type
!= GL_UNSIGNED_BYTE
)
414 IMPORT_FLOAT_COLORS( ctx
);
416 col
= (GLubyte (*)[4])VB
->ColorPtr
[0]->Ptr
;
417 col_stride
= VB
->ColorPtr
[0]->StrideB
;
418 ASSERT(VB
->ColorPtr
[0]->Type
== GL_UNSIGNED_BYTE
);
420 /* fprintf(stderr, "%s stride %d importable %d\n", */
421 /* __FUNCTION__, col_stride, VB->importable_data); */
423 /* Pack what's left into a 4-dword vertex. Color is in a different
424 * place, and there is no 'w' coordinate.
426 if (VB
->importable_data
) {
428 coord
= (GLfloat (*)[4])((GLubyte
*)coord
+ start
* coord_stride
);
429 STRIDE_4UB(col
, start
* col_stride
);
432 for (i
=start
; i
< end
; i
++, v
+=4) {
433 if (HAVE_HW_VIEWPORT
|| mask
[i
] == 0) {
434 VIEWPORT_X(v
[0], coord
[0][0]);
435 VIEWPORT_Y(v
[1], coord
[0][1]);
436 VIEWPORT_Z(v
[2], coord
[0][2]);
438 coord
= (GLfloat (*)[4])((GLubyte
*)coord
+ coord_stride
);
440 if (HAVE_RGBA_COLOR
) {
441 *(GLuint
*)&v
[3] = *(GLuint
*)col
;
444 GLubyte
*b
= (GLubyte
*)&v
[3];
450 STRIDE_4UB( col
, col_stride
);
455 for (i
=start
; i
< end
; i
++, v
+=4) {
456 if (HAVE_HW_VIEWPORT
|| mask
[i
] == 0) {
457 VIEWPORT_X(v
[0], coord
[i
][0]);
458 VIEWPORT_Y(v
[1], coord
[i
][1]);
459 VIEWPORT_Z(v
[2], coord
[i
][2]);
462 if (HAVE_RGBA_COLOR
) {
463 *(GLuint
*)&v
[3] = *(GLuint
*)&col
[i
];
466 GLubyte
*b
= (GLubyte
*)&v
[3];
477 static void TAG(emit
)( GLcontext
*ctx
, GLuint start
, GLuint end
,
478 void *dest
, GLuint stride
)
481 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
484 GLfloat
*v
= (GLfloat
*)dest
;
487 if (VB
->ColorPtr
[0]->Type
!= GL_UNSIGNED_BYTE
)
488 IMPORT_FLOAT_COLORS( ctx
);
490 col
= VB
->ColorPtr
[0]->Ptr
;
491 col_stride
= VB
->ColorPtr
[0]->StrideB
;
494 STRIDE_4UB(col
, col_stride
* start
);
496 /* Need to figure out where color is:
498 if (GET_VERTEX_FORMAT() == TINY_VERTEX_FORMAT
)
503 for (i
=start
; i
< end
; i
++, STRIDE_F(v
, stride
)) {
504 if (HAVE_RGBA_COLOR
) {
505 *(GLuint
*)v
= *(GLuint
*)col
[0];
508 GLubyte
*b
= (GLubyte
*)v
;
514 STRIDE_4UB( col
, col_stride
);
520 #if (DO_XYZW) && (DO_RGBA)
523 #if (HAVE_PTEX_VERTICES)
524 static GLboolean
TAG(check_tex_sizes
)( GLcontext
*ctx
)
527 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
529 /* Force 'missing' texcoords to something valid.
531 if (DO_TEX3
&& VB
->TexCoordPtr
[2] == 0)
532 VB
->TexCoordPtr
[2] = VB
->TexCoordPtr
[3];
534 if (DO_TEX2
&& VB
->TexCoordPtr
[1] == 0)
535 VB
->TexCoordPtr
[1] = VB
->TexCoordPtr
[2];
537 if (DO_TEX1
&& VB
->TexCoordPtr
[0] == 0)
538 VB
->TexCoordPtr
[0] = VB
->TexCoordPtr
[1];
543 if ((DO_TEX3
&& VB
->TexCoordPtr
[GET_TEXSOURCE(3)]->size
== 4) ||
544 (DO_TEX2
&& VB
->TexCoordPtr
[GET_TEXSOURCE(2)]->size
== 4) ||
545 (DO_TEX1
&& VB
->TexCoordPtr
[GET_TEXSOURCE(1)]->size
== 4) ||
546 (DO_TEX0
&& VB
->TexCoordPtr
[GET_TEXSOURCE(0)]->size
== 4))
552 static GLboolean
TAG(check_tex_sizes
)( GLcontext
*ctx
)
555 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
557 /* Force 'missing' texcoords to something valid.
559 if (DO_TEX3
&& VB
->TexCoordPtr
[2] == 0)
560 VB
->TexCoordPtr
[2] = VB
->TexCoordPtr
[3];
562 if (DO_TEX2
&& VB
->TexCoordPtr
[1] == 0)
563 VB
->TexCoordPtr
[1] = VB
->TexCoordPtr
[2];
565 if (DO_TEX1
&& VB
->TexCoordPtr
[0] == 0)
566 VB
->TexCoordPtr
[0] = VB
->TexCoordPtr
[1];
571 /* No hardware support for projective texture. Can fake it for
574 if ((DO_TEX3
&& VB
->TexCoordPtr
[GET_TEXSOURCE(3)]->size
== 4) ||
575 (DO_TEX2
&& VB
->TexCoordPtr
[GET_TEXSOURCE(2)]->size
== 4) ||
576 (DO_TEX1
&& VB
->TexCoordPtr
[GET_TEXSOURCE(1)]->size
== 4)) {
581 if (DO_TEX0
&& VB
->TexCoordPtr
[GET_TEXSOURCE(0)]->size
== 4) {
582 if (DO_TEX1
|| DO_TEX2
|| DO_TEX3
) {
593 static void TAG(interp
)( GLcontext
*ctx
,
595 GLuint edst
, GLuint eout
, GLuint ein
,
596 GLboolean force_boundary
)
599 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
600 GLubyte
*ddverts
= GET_VERTEX_STORE();
601 GLuint shift
= GET_VERTEX_STRIDE_SHIFT();
602 const GLfloat
*dstclip
= VB
->ClipPtr
->data
[edst
];
604 const GLfloat
*s
= GET_VIEWPORT_MAT();
606 VERTEX
*dst
= (VERTEX
*)(ddverts
+ (edst
<< shift
));
607 VERTEX
*in
= (VERTEX
*)(ddverts
+ (ein
<< shift
));
608 VERTEX
*out
= (VERTEX
*)(ddverts
+ (eout
<< shift
));
612 if (HAVE_HW_DIVIDE
&& CHECK_HW_DIVIDE
) {
613 VIEWPORT_X( dst
->v
.x
, dstclip
[0] );
614 VIEWPORT_Y( dst
->v
.y
, dstclip
[1] );
615 VIEWPORT_Z( dst
->v
.z
, dstclip
[2] );
619 w
= 1.0 / dstclip
[3];
620 VIEWPORT_X( dst
->v
.x
, dstclip
[0] * w
);
621 VIEWPORT_Y( dst
->v
.y
, dstclip
[1] * w
);
622 VIEWPORT_Z( dst
->v
.z
, dstclip
[2] * w
);
625 if ((HAVE_HW_DIVIDE
&& CHECK_HW_DIVIDE
) ||
626 DO_FOG
|| DO_SPEC
|| DO_TEX0
|| DO_TEX1
||
627 DO_TEX2
|| DO_TEX3
) {
631 INTERP_UB( t
, dst
->ub4
[4][0], out
->ub4
[4][0], in
->ub4
[4][0] );
632 INTERP_UB( t
, dst
->ub4
[4][1], out
->ub4
[4][1], in
->ub4
[4][1] );
633 INTERP_UB( t
, dst
->ub4
[4][2], out
->ub4
[4][2], in
->ub4
[4][2] );
634 INTERP_UB( t
, dst
->ub4
[4][3], out
->ub4
[4][3], in
->ub4
[4][3] );
637 INTERP_UB( t
, dst
->ub4
[5][0], out
->ub4
[5][0], in
->ub4
[5][0] );
638 INTERP_UB( t
, dst
->ub4
[5][1], out
->ub4
[5][1], in
->ub4
[5][1] );
639 INTERP_UB( t
, dst
->ub4
[5][2], out
->ub4
[5][2], in
->ub4
[5][2] );
642 INTERP_UB( t
, dst
->ub4
[5][3], out
->ub4
[5][3], in
->ub4
[5][3] );
646 if (HAVE_PTEX_VERTICES
) {
647 INTERP_F( t
, dst
->pv
.u0
, out
->pv
.u0
, in
->pv
.u0
);
648 INTERP_F( t
, dst
->pv
.v0
, out
->pv
.v0
, in
->pv
.v0
);
649 INTERP_F( t
, dst
->pv
.q0
, out
->pv
.q0
, in
->pv
.q0
);
651 GLfloat wout
= VB
->ProjectedClipPtr
->data
[eout
][3];
652 GLfloat win
= VB
->ProjectedClipPtr
->data
[ein
][3];
653 GLfloat qout
= out
->pv
.w
/ wout
;
654 GLfloat qin
= in
->pv
.w
/ win
;
657 ASSERT( !HAVE_HW_DIVIDE
);
659 INTERP_F( t
, dst
->v
.u0
, out
->v
.u0
* qout
, in
->v
.u0
* qin
);
660 INTERP_F( t
, dst
->v
.v0
, out
->v
.v0
* qout
, in
->v
.v0
* qin
);
661 INTERP_F( t
, qdst
, qout
, qin
);
670 INTERP_F( t
, dst
->v
.u0
, out
->v
.u0
, in
->v
.u0
);
671 INTERP_F( t
, dst
->v
.v0
, out
->v
.v0
, in
->v
.v0
);
676 INTERP_F( t
, dst
->pv
.u1
, out
->pv
.u1
, in
->pv
.u1
);
677 INTERP_F( t
, dst
->pv
.v1
, out
->pv
.v1
, in
->pv
.v1
);
678 INTERP_F( t
, dst
->pv
.q1
, out
->pv
.q1
, in
->pv
.q1
);
680 INTERP_F( t
, dst
->v
.u1
, out
->v
.u1
, in
->v
.u1
);
681 INTERP_F( t
, dst
->v
.v1
, out
->v
.v1
, in
->v
.v1
);
685 dst
->pv
.q0
= 0.0; /* must be a valid float on radeon */
689 INTERP_F( t
, dst
->pv
.u2
, out
->pv
.u2
, in
->pv
.u2
);
690 INTERP_F( t
, dst
->pv
.v2
, out
->pv
.v2
, in
->pv
.v2
);
691 INTERP_F( t
, dst
->pv
.q2
, out
->pv
.q2
, in
->pv
.q2
);
693 INTERP_F( t
, dst
->v
.u2
, out
->v
.u2
, in
->v
.u2
);
694 INTERP_F( t
, dst
->v
.v2
, out
->v
.v2
, in
->v
.v2
);
699 INTERP_F( t
, dst
->pv
.u3
, out
->pv
.u3
, in
->pv
.u3
);
700 INTERP_F( t
, dst
->pv
.v3
, out
->pv
.v3
, in
->pv
.v3
);
701 INTERP_F( t
, dst
->pv
.q3
, out
->pv
.q3
, in
->pv
.q3
);
703 INTERP_F( t
, dst
->v
.u3
, out
->v
.u3
, in
->v
.u3
);
704 INTERP_F( t
, dst
->v
.v3
, out
->v
.v3
, in
->v
.v3
);
708 /* 4-dword vertex. Color is in v[3] and there is no oow coordinate.
710 INTERP_UB( t
, dst
->ub4
[3][0], out
->ub4
[3][0], in
->ub4
[3][0] );
711 INTERP_UB( t
, dst
->ub4
[3][1], out
->ub4
[3][1], in
->ub4
[3][1] );
712 INTERP_UB( t
, dst
->ub4
[3][2], out
->ub4
[3][2], in
->ub4
[3][2] );
713 INTERP_UB( t
, dst
->ub4
[3][3], out
->ub4
[3][3], in
->ub4
[3][3] );
717 #endif /* rgba && xyzw */
720 static void TAG(init
)( void )
722 setup_tab
[IND
].emit
= TAG(emit
);
724 #if (DO_XYZW && DO_RGBA)
725 setup_tab
[IND
].check_tex_sizes
= TAG(check_tex_sizes
);
726 setup_tab
[IND
].interp
= TAG(interp
);
730 setup_tab
[IND
].copy_pv
= copy_pv_rgba4_spec5
;
731 else if (HAVE_HW_DIVIDE
|| DO_SPEC
|| DO_FOG
|| DO_TEX0
|| DO_TEX1
||
733 setup_tab
[IND
].copy_pv
= copy_pv_rgba4
;
735 setup_tab
[IND
].copy_pv
= copy_pv_rgba3
;
739 ASSERT(HAVE_PTEX_VERTICES
);
740 setup_tab
[IND
].vertex_format
= PROJ_TEX3_VERTEX_FORMAT
;
741 setup_tab
[IND
].vertex_size
= 18;
742 setup_tab
[IND
].vertex_stride_shift
= 7;
745 setup_tab
[IND
].vertex_format
= TEX3_VERTEX_FORMAT
;
746 setup_tab
[IND
].vertex_size
= 14;
747 setup_tab
[IND
].vertex_stride_shift
= 6;
752 ASSERT(HAVE_PTEX_VERTICES
);
753 setup_tab
[IND
].vertex_format
= PROJ_TEX3_VERTEX_FORMAT
;
754 setup_tab
[IND
].vertex_size
= 18;
755 setup_tab
[IND
].vertex_stride_shift
= 7;
758 setup_tab
[IND
].vertex_format
= TEX2_VERTEX_FORMAT
;
759 setup_tab
[IND
].vertex_size
= 12;
760 setup_tab
[IND
].vertex_stride_shift
= 6;
765 ASSERT(HAVE_PTEX_VERTICES
);
766 setup_tab
[IND
].vertex_format
= PROJ_TEX1_VERTEX_FORMAT
;
767 setup_tab
[IND
].vertex_size
= 12;
768 setup_tab
[IND
].vertex_stride_shift
= 6;
771 setup_tab
[IND
].vertex_format
= TEX1_VERTEX_FORMAT
;
772 setup_tab
[IND
].vertex_size
= 10;
773 setup_tab
[IND
].vertex_stride_shift
= 6;
777 if (DO_PTEX
&& HAVE_PTEX_VERTICES
) {
778 setup_tab
[IND
].vertex_format
= PROJ_TEX1_VERTEX_FORMAT
;
779 setup_tab
[IND
].vertex_size
= 12;
780 setup_tab
[IND
].vertex_stride_shift
= 6;
782 setup_tab
[IND
].vertex_format
= TEX0_VERTEX_FORMAT
;
783 setup_tab
[IND
].vertex_size
= 8;
784 setup_tab
[IND
].vertex_stride_shift
= 5;
787 else if (!HAVE_HW_DIVIDE
&& !DO_SPEC
&& !DO_FOG
&& HAVE_TINY_VERTICES
) {
788 setup_tab
[IND
].vertex_format
= TINY_VERTEX_FORMAT
;
789 setup_tab
[IND
].vertex_size
= 4;
790 setup_tab
[IND
].vertex_stride_shift
= 4;
791 } else if (HAVE_NOTEX_VERTICES
) {
792 setup_tab
[IND
].vertex_format
= NOTEX_VERTEX_FORMAT
;
793 setup_tab
[IND
].vertex_size
= 6;
794 setup_tab
[IND
].vertex_stride_shift
= 5;
796 setup_tab
[IND
].vertex_format
= TEX0_VERTEX_FORMAT
;
797 setup_tab
[IND
].vertex_size
= 8;
798 setup_tab
[IND
].vertex_stride_shift
= 5;
801 assert(setup_tab
[IND
].vertex_size
* 4 <=
802 1 << setup_tab
[IND
].vertex_stride_shift
);