db7bcd3334852d85b243cacc156c2a978c1de018
1 /* $XFree86$ */ /* -*- mode: c; c-basic-offset: 3 -*- */
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 <keithw@valinux.com>
28 * Adapted to Mach64 by:
29 * José Fonseca <j_r_fonseca@yahoo.co.uk>
32 #include "math/m_translate.h"
38 void TAG(translate_vertex
)(GLcontext
*ctx
,
43 GLuint format
= GET_VERTEX_FORMAT();
45 CARD32
*p
= (CARD32
*)src
+ 10 - mmesa
->vertex_size
;
50 case TEX1_VERTEX_FORMAT
:
51 #ifdef MACH64_PREMULT_TEXCOORDS
53 float rhw
= 1.0 / LE32_IN_FLOAT( p
+ 2 );
55 dst
->texcoord
[1][0] = rhw
*LE32_IN_FLOAT( p
++ );
56 dst
->texcoord
[1][1] = rhw
*LE32_IN_FLOAT( p
++ );
59 dst
->texcoord
[1][0] = LE32_IN_FLOAT( p
++ );
60 dst
->texcoord
[1][1] = LE32_IN_FLOAT( p
++ );
62 dst
->texcoord
[1][3] = 1.0;
65 case TEX0_VERTEX_FORMAT
:
66 #ifdef MACH64_PREMULT_TEXCOORDS
68 float rhw
= 1.0 / LE32_IN_FLOAT( p
+ 2 );
70 dst
->texcoord
[0][0] = rhw
*LE32_IN_FLOAT( p
++ );
71 dst
->texcoord
[0][1] = rhw
*LE32_IN_FLOAT( p
++ );
74 dst
->texcoord
[0][0] = LE32_IN_FLOAT( p
++ );
75 dst
->texcoord
[0][1] = LE32_IN_FLOAT( p
++ );
77 dst
->texcoord
[0][3] = 1.0;
78 dst
->win
[3] = LE32_IN_FLOAT( p
++ );
80 case NOTEX_VERTEX_FORMAT
:
81 dst
->specular
[2] = *((GLubyte
*)p
)++;
82 dst
->specular
[1] = *((GLubyte
*)p
)++;
83 dst
->specular
[0] = *((GLubyte
*)p
)++;
84 dst
->fog
= *((GLubyte
*)p
)++;
86 case TINY_VERTEX_FORMAT
:
87 dst
->win
[2] = UNVIEWPORT_Z( LE32_IN( p
++ ) );
89 dst
->color
[2] = *((GLubyte
*)p
)++;
90 dst
->color
[1] = *((GLubyte
*)p
)++;
91 dst
->color
[0] = *((GLubyte
*)p
)++;
92 dst
->color
[3] = *((GLubyte
*)p
)++;
95 GLuint xy
= LE32_IN( p
);
97 dst
->win
[0] = UNVIEWPORT_X( (GLfloat
)(GLshort
)( xy
>> 16 ) );
98 dst
->win
[1] = UNVIEWPORT_Y( (GLfloat
)(GLshort
)( xy
& 0xffff ) );
102 assert( p
+ 1 - (CARD32
*)src
== 10 );
104 dst
->pointSize
= ctx
->Point
._Size
;
109 void TAG(print_vertex
)( GLcontext
*ctx
, const VERTEX
*v
)
112 GLuint format
= GET_VERTEX_FORMAT();
113 CARD32
*p
= (CARD32
*)v
+ 10 - mmesa
->vertex_size
;
116 case TEX1_VERTEX_FORMAT
:
119 #ifdef MACH64_PREMULT_TEXCOORDS
120 float rhw
= 1.0 / LE32_IN_FLOAT( p
+ 2 );
122 u
= rhw
*LE32_IN_FLOAT( p
++ );
123 v
= rhw
*LE32_IN_FLOAT( p
++ );
125 u
= LE32_IN_FLOAT( p
++ );
126 v
= LE32_IN_FLOAT( p
++ );
128 w
= LE32_IN_FLOAT( p
++ );
129 fprintf( stderr
, "u1 %f v1 %f w1 %f\n", u
, v
, w
);
132 case TEX0_VERTEX_FORMAT
:
135 #ifdef MACH64_PREMULT_TEXCOORDS
136 float rhw
= 1.0 / LE32_IN_FLOAT( p
+ 2 );
138 u
= rhw
*LE32_IN_FLOAT( p
++ );
139 v
= rhw
*LE32_IN_FLOAT( p
++ );
141 u
= LE32_IN_FLOAT( p
++ );
142 v
= LE32_IN_FLOAT( p
++ );
144 w
= LE32_IN_FLOAT( p
++ );
145 fprintf( stderr
, "u0 %f v0 %f w0 %f\n", u
, v
, w
);
148 case NOTEX_VERTEX_FORMAT
:
152 b
= *((GLubyte
*)p
)++;
153 g
= *((GLubyte
*)p
)++;
154 r
= *((GLubyte
*)p
)++;
155 a
= *((GLubyte
*)p
)++;
157 fprintf(stderr
, "spec: r %d g %d b %d a %d\n", r
, g
, b
, a
);
160 case TINY_VERTEX_FORMAT
:
166 z
= LE32_IN( p
++ ) / 65536.0;
168 b
= *((GLubyte
*)p
)++;
169 g
= *((GLubyte
*)p
)++;
170 r
= *((GLubyte
*)p
)++;
171 a
= *((GLubyte
*)p
)++;
174 x
= (GLfloat
)(GLshort
)( xy
>> 16 ) / 4.0;
175 y
= (GLfloat
)(GLshort
)( xy
& 0xffff ) / 4.0;
177 fprintf(stderr
, "x %f y %f z %f\n", x
, y
, z
);
178 fprintf(stderr
, "r %d g %d b %d a %d\n", r
, g
, b
, a
);
182 assert( p
+ 1 - (CARD32
*)v
== 10 );
184 fprintf(stderr
, "\n");
187 /* Interpolate the elements of the VB not included in typical hardware
190 * NOTE: All these arrays are guarenteed by tnl to be writeable and
193 #ifndef INTERP_QUALIFIER
194 #define INTERP_QUALIFIER static
197 #define GET_COLOR(ptr, idx) ((ptr)->data[idx])
200 INTERP_QUALIFIER
void TAG(interp_extras
)( GLcontext
*ctx
,
202 GLuint dst
, GLuint out
, GLuint in
,
203 GLboolean force_boundary
)
206 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
208 if (VB
->ColorPtr
[1]) {
209 assert(VB
->ColorPtr
[1]->stride
== 4 * sizeof(GLfloat
));
212 GET_COLOR(VB
->ColorPtr
[1], dst
),
213 GET_COLOR(VB
->ColorPtr
[1], out
),
214 GET_COLOR(VB
->ColorPtr
[1], in
) );
216 if (VB
->SecondaryColorPtr
[1]) {
218 GET_COLOR(VB
->SecondaryColorPtr
[1], dst
),
219 GET_COLOR(VB
->SecondaryColorPtr
[1], out
),
220 GET_COLOR(VB
->SecondaryColorPtr
[1], in
) );
225 VB
->EdgeFlag
[dst
] = VB
->EdgeFlag
[out
] || force_boundary
;
228 INTERP_VERTEX(ctx
, t
, dst
, out
, in
, force_boundary
);
231 INTERP_QUALIFIER
void TAG(copy_pv_extras
)( GLcontext
*ctx
,
232 GLuint dst
, GLuint src
)
235 struct vertex_buffer
*VB
= &TNL_CONTEXT(ctx
)->vb
;
237 if (VB
->ColorPtr
[1]) {
238 COPY_4FV( GET_COLOR(VB
->ColorPtr
[1], dst
),
239 GET_COLOR(VB
->ColorPtr
[1], src
) );
241 if (VB
->SecondaryColorPtr
[1]) {
242 COPY_4FV( GET_COLOR(VB
->SecondaryColorPtr
[1], dst
),
243 GET_COLOR(VB
->SecondaryColorPtr
[1], src
) );
247 COPY_PV_VERTEX(ctx
, dst
, src
);
251 #undef INTERP_QUALIFIER