3 * Mesa 3-D graphics library
6 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
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:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
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.
26 * Keith Whitwell <keith_whitwell@yahoo.com>
29 /* Template to build support for t_dd_imm_* tnl module using vertices
30 * as defined in t_dd_vertex.h.
32 * See t_dd_vbtmp.h for definitions of arguments to this file.
33 * Unfortunately it seems necessary to duplicate a lot of that code.
42 /* COPY_VERTEX_FROM_CURRENT in t_dd_imm_vapi.c
44 static void TAG(emit_vfmt)( struct gl_context *ctx, VERTEX *v )
49 /* This template assumes (like t_dd_vbtmp.h) that color is ubyte.
51 if (DO_TEX0 || DO_TEX1 || !HAVE_TINY_VERTICES)
53 const GLubyte *col = GET_HARDWARE_COLOR();
54 if (HAVE_RGBA_COLOR) {
55 v->v.ui[4] = *(GLuint *)&col;
57 v->v.color.blue = col[2];
58 v->v.color.green = col[1];
59 v->v.color.red = col[0];
60 v->v.color.alpha = col[3];
64 if (HAVE_RGBA_COLOR) {
65 v->v.ui[3] = *(GLuint *)col;
68 v->tv.color.blue = col[2];
69 v->tv.color.green = col[1];
70 v->tv.color.red = col[0];
71 v->tv.color.alpha = col[3];
76 GLfloat *tc = ctx->Current.Texture[0];
80 if (HAVE_PTEX_VERTICES) {
84 float rhw = 1.0 / tc[3];
92 GLfloat *tc = ctx->Current.Texture[1];
104 *(GLuint *)&v->pv.q1 = 0; /* avoid culling on radeon */
107 GLfloat *tc = ctx->Current.Texture[2];
119 GLfloat *tc = ctx->Current.Texture[3];
135 static void TAG(interp)( struct gl_context *ctx,
142 const GLfloat *s = GET_VIEWPORT_MAT();
147 if (HAVE_HW_DIVIDE) {
148 VIEWPORT_X( dst->v.v.x, dst->clip[0] );
149 VIEWPORT_Y( dst->v.v.y, dst->clip[1] );
150 VIEWPORT_Z( dst->v.v.z, dst->clip[2] );
154 w = 1.0 / dst->clip[3];
155 VIEWPORT_X( dst->v.v.x, dst->clip[0] * w );
156 VIEWPORT_Y( dst->v.v.y, dst->clip[1] * w );
157 VIEWPORT_Z( dst->v.v.z, dst->clip[2] * w );
160 if (HAVE_HW_DIVIDE || DO_TEX0) {
164 INTERP_UB( t, dst->v.ub4[4][0], out->v.ub4[4][0], in->v.ub4[4][0] );
165 INTERP_UB( t, dst->v.ub4[4][1], out->v.ub4[4][1], in->v.ub4[4][1] );
166 INTERP_UB( t, dst->v.ub4[4][2], out->v.ub4[4][2], in->v.ub4[4][2] );
167 INTERP_UB( t, dst->v.ub4[4][3], out->v.ub4[4][3], in->v.ub4[4][3] );
171 if (HAVE_PTEX_VERTICES) {
172 INTERP_F( t, dst->v.pv.u0, out->v.pv.u0, in->v.pv.u0 );
173 INTERP_F( t, dst->v.pv.v0, out->v.pv.v0, in->v.pv.v0 );
174 INTERP_F( t, dst->v.pv.q0, out->v.pv.q0, in->v.pv.q0 );
176 GLfloat wout = out->clip[3]; /* projected clip */
177 GLfloat win = in->clip[3]; /* projected clip */
178 GLfloat qout = out->v.pv.w / wout;
179 GLfloat qin = in->v.pv.w / win;
182 ASSERT( !HAVE_HW_DIVIDE ); /* assert win, wout projected clip */
184 INTERP_F( t, dst->v.v.u0, out->v.v.u0 * qout, in->v.v.u0 * qin );
185 INTERP_F( t, dst->v.v.v0, out->v.v.v0 * qout, in->v.v.v0 * qin );
186 INTERP_F( t, qdst, qout, qin );
189 dst->v.v.u0 *= rqdst;
190 dst->v.v.v0 *= rqdst;
195 INTERP_F( t, dst->v.v.u0, out->v.v.u0, in->v.v.u0 );
196 INTERP_F( t, dst->v.v.v0, out->v.v.v0, in->v.v.v0 );
201 INTERP_F( t, dst->v.pv.u1, out->v.pv.u1, in->v.pv.u1 );
202 INTERP_F( t, dst->v.pv.v1, out->v.pv.v1, in->v.pv.v1 );
203 INTERP_F( t, dst->v.pv.q1, out->v.pv.q1, in->v.pv.q1 );
205 INTERP_F( t, dst->v.v.u1, out->v.v.u1, in->v.v.u1 );
206 INTERP_F( t, dst->v.v.v1, out->v.v.v1, in->v.v.v1 );
210 dst->v.pv.q0 = 0.0; /* must be a valid float on radeon */
214 INTERP_F( t, dst->v.pv.u2, out->v.pv.u2, in->v.pv.u2 );
215 INTERP_F( t, dst->v.pv.v2, out->v.pv.v2, in->v.pv.v2 );
216 INTERP_F( t, dst->v.pv.q2, out->v.pv.q2, in->v.pv.q2 );
218 INTERP_F( t, dst->v.v.u2, out->v.v.u2, in->v.v.u2 );
219 INTERP_F( t, dst->v.v.v2, out->v.v.v2, in->v.v.v2 );
224 INTERP_F( t, dst->v.pv.u3, out->v.pv.u3, in->v.pv.u3 );
225 INTERP_F( t, dst->v.pv.v3, out->v.pv.v3, in->v.pv.v3 );
226 INTERP_F( t, dst->v.pv.q3, out->v.pv.q3, in->v.pv.q3 );
228 INTERP_F( t, dst->v.v.u3, out->v.v.u3, in->v.v.u3 );
229 INTERP_F( t, dst->v.v.v3, out->v.v.v3, in->v.v.v3 );
233 /* 4-dword vertex. Color is in v[3] and there is no oow coordinate.
235 INTERP_UB( t, dst->v.ub4[3][0], out->v.ub4[3][0], in->v.ub4[3][0] );
236 INTERP_UB( t, dst->v.ub4[3][1], out->v.ub4[3][1], in->v.ub4[3][1] );
237 INTERP_UB( t, dst->v.ub4[3][2], out->v.ub4[3][2], in->v.ub4[3][2] );
238 INTERP_UB( t, dst->v.ub4[3][3], out->v.ub4[3][3], in->v.ub4[3][3] );
243 static __inline void TAG(copy_pv)( struct gl_context *ctx,
247 if (DO_TEX0 || DO_TEX1 || !HAVE_TINY_VERTICES) {
248 dst->v.v.ui[4] = src->v.v.ui[4];
251 dst->v.v.ui[3] = src->v.v.ui[3];
257 static void TAG(init)( void )
259 setup_tab[IND].emit = TAG(emit_vfmt);
260 setup_tab[IND].interp = TAG(interp_vfmt);