1 /* $Id: m_xform_tmp.h,v 1.7 2001/05/18 23:58:26 brianp 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.
28 * New (3.1) transformation code written by Keith Whitwell.
32 /*----------------------------------------------------------------------
33 * Begin Keith's new code
35 *----------------------------------------------------------------------
38 /* KW: Fixed stride, now measured in bytes as is the OpenGL array stride.
41 /* KW: These are now parameterized to produce two versions, one
42 * which transforms all incoming points, and a second which
43 * takes notice of a cullmask array, and only transforms
47 /* KW: 1-vectors can sneak into the texture pipeline via the array
48 * interface. These functions are here because I want consistant
49 * treatment of the vertex sizes and a lazy strategy for
50 * cleaning unused parts of the vector, and so as not to exclude
51 * them from the vertex array interface.
53 * Under our current analysis of matrices, there is no way that
54 * the product of a matrix and a 1-vector can remain a 1-vector,
55 * with the exception of the identity transform.
58 /* KW: No longer zero-pad outgoing vectors. Now that external
59 * vectors can get into the pipeline we cannot ever assume
60 * that there is more to a vector than indicated by its
64 /* KW: Now uses clipmask and a flag to allow us to skip both/either
65 * cliped and/or culled vertices.
68 /* GH: Not any more -- it's easier (and faster) to just process the
69 * entire vector. Clipping and culling are handled further down
70 * the pipe, most often during or after the conversion to some
71 * driver-specific vertex format.
75 TAG(transform_points1_general
)( GLvector4f
*to_vec
,
77 const GLvector4f
*from_vec
)
79 const GLuint stride
= from_vec
->stride
;
80 GLfloat
*from
= from_vec
->start
;
81 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
82 GLuint count
= from_vec
->count
;
83 const GLfloat m0
= m
[0], m12
= m
[12];
84 const GLfloat m1
= m
[1], m13
= m
[13];
85 const GLfloat m2
= m
[2], m14
= m
[14];
86 const GLfloat m3
= m
[3], m15
= m
[15];
89 const GLfloat ox
= from
[0];
90 to
[i
][0] = m0
* ox
+ m12
;
91 to
[i
][1] = m1
* ox
+ m13
;
92 to
[i
][2] = m2
* ox
+ m14
;
93 to
[i
][3] = m3
* ox
+ m15
;
96 to_vec
->flags
|= VEC_SIZE_4
;
97 to_vec
->count
= from_vec
->count
;
100 static void _XFORMAPI
101 TAG(transform_points1_identity
)( GLvector4f
*to_vec
,
103 const GLvector4f
*from_vec
)
105 const GLuint stride
= from_vec
->stride
;
106 GLfloat
*from
= from_vec
->start
;
107 GLuint count
= from_vec
->count
;
108 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
110 if (to_vec
== from_vec
) return;
115 to_vec
->flags
|= VEC_SIZE_1
;
116 to_vec
->count
= from_vec
->count
;
119 static void _XFORMAPI
120 TAG(transform_points1_2d
)( GLvector4f
*to_vec
,
122 const GLvector4f
*from_vec
)
124 const GLuint stride
= from_vec
->stride
;
125 GLfloat
*from
= from_vec
->start
;
126 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
127 GLuint count
= from_vec
->count
;
128 const GLfloat m0
= m
[0], m1
= m
[1];
129 const GLfloat m12
= m
[12], m13
= m
[13];
132 const GLfloat ox
= from
[0];
133 to
[i
][0] = m0
* ox
+ m12
;
134 to
[i
][1] = m1
* ox
+ m13
;
137 to_vec
->flags
|= VEC_SIZE_2
;
138 to_vec
->count
= from_vec
->count
;
141 static void _XFORMAPI
142 TAG(transform_points1_2d_no_rot
)( GLvector4f
*to_vec
,
144 const GLvector4f
*from_vec
)
146 const GLuint stride
= from_vec
->stride
;
147 GLfloat
*from
= from_vec
->start
;
148 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
149 GLuint count
= from_vec
->count
;
150 const GLfloat m0
= m
[0], m12
= m
[12], m13
= m
[13];
153 const GLfloat ox
= from
[0];
154 to
[i
][0] = m0
* ox
+ m12
;
158 to_vec
->flags
|= VEC_SIZE_2
;
159 to_vec
->count
= from_vec
->count
;
162 static void _XFORMAPI
163 TAG(transform_points1_3d
)( GLvector4f
*to_vec
,
165 const GLvector4f
*from_vec
)
167 const GLuint stride
= from_vec
->stride
;
168 GLfloat
*from
= from_vec
->start
;
169 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
170 GLuint count
= from_vec
->count
;
171 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2];
172 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
175 const GLfloat ox
= from
[0];
176 to
[i
][0] = m0
* ox
+ m12
;
177 to
[i
][1] = m1
* ox
+ m13
;
178 to
[i
][2] = m2
* ox
+ m14
;
181 to_vec
->flags
|= VEC_SIZE_3
;
182 to_vec
->count
= from_vec
->count
;
186 static void _XFORMAPI
187 TAG(transform_points1_3d_no_rot
)( GLvector4f
*to_vec
,
189 const GLvector4f
*from_vec
)
191 const GLuint stride
= from_vec
->stride
;
192 GLfloat
*from
= from_vec
->start
;
193 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
194 GLuint count
= from_vec
->count
;
195 const GLfloat m0
= m
[0];
196 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
199 const GLfloat ox
= from
[0];
200 to
[i
][0] = m0
* ox
+ m12
;
205 to_vec
->flags
|= VEC_SIZE_3
;
206 to_vec
->count
= from_vec
->count
;
209 static void _XFORMAPI
210 TAG(transform_points1_perspective
)( GLvector4f
*to_vec
,
212 const GLvector4f
*from_vec
)
214 const GLuint stride
= from_vec
->stride
;
215 GLfloat
*from
= from_vec
->start
;
216 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
217 GLuint count
= from_vec
->count
;
218 const GLfloat m0
= m
[0], m14
= m
[14];
221 const GLfloat ox
= from
[0];
228 to_vec
->flags
|= VEC_SIZE_4
;
229 to_vec
->count
= from_vec
->count
;
235 /* 2-vectors, which are a lot more relevant than 1-vectors, are
236 * present early in the geometry pipeline and throughout the
239 static void _XFORMAPI
240 TAG(transform_points2_general
)( GLvector4f
*to_vec
,
242 const GLvector4f
*from_vec
)
244 const GLuint stride
= from_vec
->stride
;
245 GLfloat
*from
= from_vec
->start
;
246 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
247 GLuint count
= from_vec
->count
;
248 const GLfloat m0
= m
[0], m4
= m
[4], m12
= m
[12];
249 const GLfloat m1
= m
[1], m5
= m
[5], m13
= m
[13];
250 const GLfloat m2
= m
[2], m6
= m
[6], m14
= m
[14];
251 const GLfloat m3
= m
[3], m7
= m
[7], m15
= m
[15];
254 const GLfloat ox
= from
[0], oy
= from
[1];
255 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
256 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
257 to
[i
][2] = m2
* ox
+ m6
* oy
+ m14
;
258 to
[i
][3] = m3
* ox
+ m7
* oy
+ m15
;
261 to_vec
->flags
|= VEC_SIZE_4
;
262 to_vec
->count
= from_vec
->count
;
265 static void _XFORMAPI
266 TAG(transform_points2_identity
)( GLvector4f
*to_vec
,
268 const GLvector4f
*from_vec
)
270 const GLuint stride
= from_vec
->stride
;
271 GLfloat
*from
= from_vec
->start
;
272 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
273 GLuint count
= from_vec
->count
;
275 if (to_vec
== from_vec
) return;
281 to_vec
->flags
|= VEC_SIZE_2
;
282 to_vec
->count
= from_vec
->count
;
285 static void _XFORMAPI
286 TAG(transform_points2_2d
)( GLvector4f
*to_vec
,
288 const GLvector4f
*from_vec
)
290 const GLuint stride
= from_vec
->stride
;
291 GLfloat
*from
= from_vec
->start
;
292 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
293 GLuint count
= from_vec
->count
;
294 const GLfloat m0
= m
[0], m1
= m
[1], m4
= m
[4], m5
= m
[5];
295 const GLfloat m12
= m
[12], m13
= m
[13];
298 const GLfloat ox
= from
[0], oy
= from
[1];
299 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
300 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
303 to_vec
->flags
|= VEC_SIZE_2
;
304 to_vec
->count
= from_vec
->count
;
307 static void _XFORMAPI
308 TAG(transform_points2_2d_no_rot
)( GLvector4f
*to_vec
,
310 const GLvector4f
*from_vec
)
312 const GLuint stride
= from_vec
->stride
;
313 GLfloat
*from
= from_vec
->start
;
314 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
315 GLuint count
= from_vec
->count
;
316 const GLfloat m0
= m
[0], m5
= m
[5], m12
= m
[12], m13
= m
[13];
319 const GLfloat ox
= from
[0], oy
= from
[1];
320 to
[i
][0] = m0
* ox
+ m12
;
321 to
[i
][1] = m5
* oy
+ m13
;
324 to_vec
->flags
|= VEC_SIZE_2
;
325 to_vec
->count
= from_vec
->count
;
328 static void _XFORMAPI
329 TAG(transform_points2_3d
)( GLvector4f
*to_vec
,
331 const GLvector4f
*from_vec
)
333 const GLuint stride
= from_vec
->stride
;
334 GLfloat
*from
= from_vec
->start
;
335 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
336 GLuint count
= from_vec
->count
;
337 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2], m4
= m
[4], m5
= m
[5];
338 const GLfloat m6
= m
[6], m12
= m
[12], m13
= m
[13], m14
= m
[14];
341 const GLfloat ox
= from
[0], oy
= from
[1];
342 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
343 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
344 to
[i
][2] = m2
* ox
+ m6
* oy
+ m14
;
347 to_vec
->flags
|= VEC_SIZE_3
;
348 to_vec
->count
= from_vec
->count
;
352 /* I would actually say this was a fairly important function, from
353 * a texture transformation point of view.
355 static void _XFORMAPI
356 TAG(transform_points2_3d_no_rot
)( GLvector4f
*to_vec
,
358 const GLvector4f
*from_vec
)
360 const GLuint stride
= from_vec
->stride
;
361 GLfloat
*from
= from_vec
->start
;
362 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
363 GLuint count
= from_vec
->count
;
364 const GLfloat m0
= m
[0], m5
= m
[5];
365 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
368 const GLfloat ox
= from
[0], oy
= from
[1];
369 to
[i
][0] = m0
* ox
+ m12
;
370 to
[i
][1] = m5
* oy
+ m13
;
375 to_vec
->flags
|= VEC_SIZE_2
;
378 to_vec
->flags
|= VEC_SIZE_3
;
380 to_vec
->count
= from_vec
->count
;
384 static void _XFORMAPI
385 TAG(transform_points2_perspective
)( GLvector4f
*to_vec
,
387 const GLvector4f
*from_vec
)
389 const GLuint stride
= from_vec
->stride
;
390 GLfloat
*from
= from_vec
->start
;
391 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
392 GLuint count
= from_vec
->count
;
393 const GLfloat m0
= m
[0], m5
= m
[5], m14
= m
[14];
396 const GLfloat ox
= from
[0], oy
= from
[1];
403 to_vec
->flags
|= VEC_SIZE_4
;
404 to_vec
->count
= from_vec
->count
;
409 static void _XFORMAPI
410 TAG(transform_points3_general
)( GLvector4f
*to_vec
,
412 const GLvector4f
*from_vec
)
414 const GLuint stride
= from_vec
->stride
;
415 GLfloat
*from
= from_vec
->start
;
416 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
417 GLuint count
= from_vec
->count
;
418 const GLfloat m0
= m
[0], m4
= m
[4], m8
= m
[8], m12
= m
[12];
419 const GLfloat m1
= m
[1], m5
= m
[5], m9
= m
[9], m13
= m
[13];
420 const GLfloat m2
= m
[2], m6
= m
[6], m10
= m
[10], m14
= m
[14];
421 const GLfloat m3
= m
[3], m7
= m
[7], m11
= m
[11], m15
= m
[15];
424 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
425 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
;
426 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
;
427 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
;
428 to
[i
][3] = m3
* ox
+ m7
* oy
+ m11
* oz
+ m15
;
431 to_vec
->flags
|= VEC_SIZE_4
;
432 to_vec
->count
= from_vec
->count
;
435 static void _XFORMAPI
436 TAG(transform_points3_identity
)( GLvector4f
*to_vec
,
438 const GLvector4f
*from_vec
)
440 const GLuint stride
= from_vec
->stride
;
441 GLfloat
*from
= from_vec
->start
;
442 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
443 GLuint count
= from_vec
->count
;
445 if (to_vec
== from_vec
) return;
452 to_vec
->flags
|= VEC_SIZE_3
;
453 to_vec
->count
= from_vec
->count
;
456 static void _XFORMAPI
457 TAG(transform_points3_2d
)( GLvector4f
*to_vec
,
459 const GLvector4f
*from_vec
)
461 const GLuint stride
= from_vec
->stride
;
462 GLfloat
*from
= from_vec
->start
;
463 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
464 GLuint count
= from_vec
->count
;
465 const GLfloat m0
= m
[0], m1
= m
[1], m4
= m
[4], m5
= m
[5];
466 const GLfloat m12
= m
[12], m13
= m
[13];
469 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
470 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
471 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
475 to_vec
->flags
|= VEC_SIZE_3
;
476 to_vec
->count
= from_vec
->count
;
479 static void _XFORMAPI
480 TAG(transform_points3_2d_no_rot
)( GLvector4f
*to_vec
,
482 const GLvector4f
*from_vec
)
484 const GLuint stride
= from_vec
->stride
;
485 GLfloat
*from
= from_vec
->start
;
486 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
487 GLuint count
= from_vec
->count
;
488 const GLfloat m0
= m
[0], m5
= m
[5], m12
= m
[12], m13
= m
[13];
491 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
492 to
[i
][0] = m0
* ox
+ m12
;
493 to
[i
][1] = m5
* oy
+ m13
;
497 to_vec
->flags
|= VEC_SIZE_3
;
498 to_vec
->count
= from_vec
->count
;
501 static void _XFORMAPI
502 TAG(transform_points3_3d
)( GLvector4f
*to_vec
,
504 const GLvector4f
*from_vec
)
506 const GLuint stride
= from_vec
->stride
;
507 GLfloat
*from
= from_vec
->start
;
508 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
509 GLuint count
= from_vec
->count
;
510 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2], m4
= m
[4], m5
= m
[5];
511 const GLfloat m6
= m
[6], m8
= m
[8], m9
= m
[9], m10
= m
[10];
512 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
515 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
516 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
;
517 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
;
518 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
;
521 to_vec
->flags
|= VEC_SIZE_3
;
522 to_vec
->count
= from_vec
->count
;
525 /* previously known as ortho...
527 static void _XFORMAPI
528 TAG(transform_points3_3d_no_rot
)( GLvector4f
*to_vec
,
530 const GLvector4f
*from_vec
)
532 const GLuint stride
= from_vec
->stride
;
533 GLfloat
*from
= from_vec
->start
;
534 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
535 GLuint count
= from_vec
->count
;
536 const GLfloat m0
= m
[0], m5
= m
[5];
537 const GLfloat m10
= m
[10], m12
= m
[12], m13
= m
[13], m14
= m
[14];
540 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
541 to
[i
][0] = m0
* ox
+ m12
;
542 to
[i
][1] = m5
* oy
+ m13
;
543 to
[i
][2] = m10
* oz
+ m14
;
546 to_vec
->flags
|= VEC_SIZE_3
;
547 to_vec
->count
= from_vec
->count
;
550 static void _XFORMAPI
551 TAG(transform_points3_perspective
)( GLvector4f
*to_vec
,
553 const GLvector4f
*from_vec
)
555 const GLuint stride
= from_vec
->stride
;
556 GLfloat
*from
= from_vec
->start
;
557 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
558 GLuint count
= from_vec
->count
;
559 const GLfloat m0
= m
[0], m5
= m
[5], m8
= m
[8], m9
= m
[9];
560 const GLfloat m10
= m
[10], m14
= m
[14];
563 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
564 to
[i
][0] = m0
* ox
+ m8
* oz
;
565 to
[i
][1] = m5
* oy
+ m9
* oz
;
566 to
[i
][2] = m10
* oz
+ m14
;
570 to_vec
->flags
|= VEC_SIZE_4
;
571 to_vec
->count
= from_vec
->count
;
576 static void _XFORMAPI
577 TAG(transform_points4_general
)( GLvector4f
*to_vec
,
579 const GLvector4f
*from_vec
)
581 const GLuint stride
= from_vec
->stride
;
582 GLfloat
*from
= from_vec
->start
;
583 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
584 GLuint count
= from_vec
->count
;
585 const GLfloat m0
= m
[0], m4
= m
[4], m8
= m
[8], m12
= m
[12];
586 const GLfloat m1
= m
[1], m5
= m
[5], m9
= m
[9], m13
= m
[13];
587 const GLfloat m2
= m
[2], m6
= m
[6], m10
= m
[10], m14
= m
[14];
588 const GLfloat m3
= m
[3], m7
= m
[7], m11
= m
[11], m15
= m
[15];
591 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
592 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
* ow
;
593 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
* ow
;
594 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
* ow
;
595 to
[i
][3] = m3
* ox
+ m7
* oy
+ m11
* oz
+ m15
* ow
;
598 to_vec
->flags
|= VEC_SIZE_4
;
599 to_vec
->count
= from_vec
->count
;
602 static void _XFORMAPI
603 TAG(transform_points4_identity
)( GLvector4f
*to_vec
,
605 const GLvector4f
*from_vec
)
607 const GLuint stride
= from_vec
->stride
;
608 GLfloat
*from
= from_vec
->start
;
609 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
610 GLuint count
= from_vec
->count
;
612 if (to_vec
== from_vec
) return;
620 to_vec
->flags
|= VEC_SIZE_4
;
621 to_vec
->count
= from_vec
->count
;
624 static void _XFORMAPI
625 TAG(transform_points4_2d
)( GLvector4f
*to_vec
,
627 const GLvector4f
*from_vec
)
629 const GLuint stride
= from_vec
->stride
;
630 GLfloat
*from
= from_vec
->start
;
631 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
632 GLuint count
= from_vec
->count
;
633 const GLfloat m0
= m
[0], m1
= m
[1], m4
= m
[4], m5
= m
[5];
634 const GLfloat m12
= m
[12], m13
= m
[13];
637 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
638 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
* ow
;
639 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
* ow
;
644 to_vec
->flags
|= VEC_SIZE_4
;
645 to_vec
->count
= from_vec
->count
;
648 static void _XFORMAPI
649 TAG(transform_points4_2d_no_rot
)( GLvector4f
*to_vec
,
651 const GLvector4f
*from_vec
)
653 const GLuint stride
= from_vec
->stride
;
654 GLfloat
*from
= from_vec
->start
;
655 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
656 GLuint count
= from_vec
->count
;
657 const GLfloat m0
= m
[0], m5
= m
[5], m12
= m
[12], m13
= m
[13];
660 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
661 to
[i
][0] = m0
* ox
+ m12
* ow
;
662 to
[i
][1] = m5
* oy
+ m13
* ow
;
667 to_vec
->flags
|= VEC_SIZE_4
;
668 to_vec
->count
= from_vec
->count
;
671 static void _XFORMAPI
672 TAG(transform_points4_3d
)( GLvector4f
*to_vec
,
674 const GLvector4f
*from_vec
)
676 const GLuint stride
= from_vec
->stride
;
677 GLfloat
*from
= from_vec
->start
;
678 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
679 GLuint count
= from_vec
->count
;
680 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2], m4
= m
[4], m5
= m
[5];
681 const GLfloat m6
= m
[6], m8
= m
[8], m9
= m
[9], m10
= m
[10];
682 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
685 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
686 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
* ow
;
687 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
* ow
;
688 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
* ow
;
692 to_vec
->flags
|= VEC_SIZE_4
;
693 to_vec
->count
= from_vec
->count
;
696 static void _XFORMAPI
697 TAG(transform_points4_3d_no_rot
)( GLvector4f
*to_vec
,
699 const GLvector4f
*from_vec
)
701 const GLuint stride
= from_vec
->stride
;
702 GLfloat
*from
= from_vec
->start
;
703 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
704 GLuint count
= from_vec
->count
;
705 const GLfloat m0
= m
[0], m5
= m
[5];
706 const GLfloat m10
= m
[10], m12
= m
[12], m13
= m
[13], m14
= m
[14];
709 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
710 to
[i
][0] = m0
* ox
+ m12
* ow
;
711 to
[i
][1] = m5
* oy
+ m13
* ow
;
712 to
[i
][2] = m10
* oz
+ m14
* ow
;
716 to_vec
->flags
|= VEC_SIZE_4
;
717 to_vec
->count
= from_vec
->count
;
720 static void _XFORMAPI
721 TAG(transform_points4_perspective
)( GLvector4f
*to_vec
,
723 const GLvector4f
*from_vec
)
725 const GLuint stride
= from_vec
->stride
;
726 GLfloat
*from
= from_vec
->start
;
727 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
728 GLuint count
= from_vec
->count
;
729 const GLfloat m0
= m
[0], m5
= m
[5], m8
= m
[8], m9
= m
[9];
730 const GLfloat m10
= m
[10], m14
= m
[14];
733 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
734 to
[i
][0] = m0
* ox
+ m8
* oz
;
735 to
[i
][1] = m5
* oy
+ m9
* oz
;
736 to
[i
][2] = m10
* oz
+ m14
* ow
;
740 to_vec
->flags
|= VEC_SIZE_4
;
741 to_vec
->count
= from_vec
->count
;
744 static transform_func _XFORMAPI
TAG(transform_tab_1
)[7];
745 static transform_func _XFORMAPI
TAG(transform_tab_2
)[7];
746 static transform_func _XFORMAPI
TAG(transform_tab_3
)[7];
747 static transform_func _XFORMAPI
TAG(transform_tab_4
)[7];
749 /* Similar functions could be called several times, with more highly
750 * optimized routines overwriting the arrays. This only occurs during
753 static void _XFORMAPI
TAG(init_c_transformations
)( void )
755 #define TAG_TAB _mesa_transform_tab
756 #define TAG_TAB_1 TAG(transform_tab_1)
757 #define TAG_TAB_2 TAG(transform_tab_2)
758 #define TAG_TAB_3 TAG(transform_tab_3)
759 #define TAG_TAB_4 TAG(transform_tab_4)
761 TAG_TAB
[1] = TAG_TAB_1
;
762 TAG_TAB
[2] = TAG_TAB_2
;
763 TAG_TAB
[3] = TAG_TAB_3
;
764 TAG_TAB
[4] = TAG_TAB_4
;
766 /* 1-D points (ie texcoords) */
767 TAG_TAB_1
[MATRIX_GENERAL
] = TAG(transform_points1_general
);
768 TAG_TAB_1
[MATRIX_IDENTITY
] = TAG(transform_points1_identity
);
769 TAG_TAB_1
[MATRIX_3D_NO_ROT
] = TAG(transform_points1_3d_no_rot
);
770 TAG_TAB_1
[MATRIX_PERSPECTIVE
] = TAG(transform_points1_perspective
);
771 TAG_TAB_1
[MATRIX_2D
] = TAG(transform_points1_2d
);
772 TAG_TAB_1
[MATRIX_2D_NO_ROT
] = TAG(transform_points1_2d_no_rot
);
773 TAG_TAB_1
[MATRIX_3D
] = TAG(transform_points1_3d
);
776 TAG_TAB_2
[MATRIX_GENERAL
] = TAG(transform_points2_general
);
777 TAG_TAB_2
[MATRIX_IDENTITY
] = TAG(transform_points2_identity
);
778 TAG_TAB_2
[MATRIX_3D_NO_ROT
] = TAG(transform_points2_3d_no_rot
);
779 TAG_TAB_2
[MATRIX_PERSPECTIVE
] = TAG(transform_points2_perspective
);
780 TAG_TAB_2
[MATRIX_2D
] = TAG(transform_points2_2d
);
781 TAG_TAB_2
[MATRIX_2D_NO_ROT
] = TAG(transform_points2_2d_no_rot
);
782 TAG_TAB_2
[MATRIX_3D
] = TAG(transform_points2_3d
);
785 TAG_TAB_3
[MATRIX_GENERAL
] = TAG(transform_points3_general
);
786 TAG_TAB_3
[MATRIX_IDENTITY
] = TAG(transform_points3_identity
);
787 TAG_TAB_3
[MATRIX_3D_NO_ROT
] = TAG(transform_points3_3d_no_rot
);
788 TAG_TAB_3
[MATRIX_PERSPECTIVE
] = TAG(transform_points3_perspective
);
789 TAG_TAB_3
[MATRIX_2D
] = TAG(transform_points3_2d
);
790 TAG_TAB_3
[MATRIX_2D_NO_ROT
] = TAG(transform_points3_2d_no_rot
);
791 TAG_TAB_3
[MATRIX_3D
] = TAG(transform_points3_3d
);
794 TAG_TAB_4
[MATRIX_GENERAL
] = TAG(transform_points4_general
);
795 TAG_TAB_4
[MATRIX_IDENTITY
] = TAG(transform_points4_identity
);
796 TAG_TAB_4
[MATRIX_3D_NO_ROT
] = TAG(transform_points4_3d_no_rot
);
797 TAG_TAB_4
[MATRIX_PERSPECTIVE
] = TAG(transform_points4_perspective
);
798 TAG_TAB_4
[MATRIX_2D
] = TAG(transform_points4_2d
);
799 TAG_TAB_4
[MATRIX_2D_NO_ROT
] = TAG(transform_points4_2d_no_rot
);
800 TAG_TAB_4
[MATRIX_3D
] = TAG(transform_points4_3d
);