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.
27 * New (3.1) transformation code written by Keith Whitwell.
31 /*----------------------------------------------------------------------
32 * Begin Keith's new code
34 *----------------------------------------------------------------------
37 /* KW: Fixed stride, now measured in bytes as is the OpenGL array stride.
40 /* KW: These are now parameterized to produce two versions, one
41 * which transforms all incoming points, and a second which
42 * takes notice of a cullmask array, and only transforms
46 /* KW: 1-vectors can sneak into the texture pipeline via the array
47 * interface. These functions are here because I want consistant
48 * treatment of the vertex sizes and a lazy strategy for
49 * cleaning unused parts of the vector, and so as not to exclude
50 * them from the vertex array interface.
52 * Under our current analysis of matrices, there is no way that
53 * the product of a matrix and a 1-vector can remain a 1-vector,
54 * with the exception of the identity transform.
57 /* KW: No longer zero-pad outgoing vectors. Now that external
58 * vectors can get into the pipeline we cannot ever assume
59 * that there is more to a vector than indicated by its
63 /* KW: Now uses clipmask and a flag to allow us to skip both/either
64 * cliped and/or culled vertices.
67 /* GH: Not any more -- it's easier (and faster) to just process the
68 * entire vector. Clipping and culling are handled further down
69 * the pipe, most often during or after the conversion to some
70 * driver-specific vertex format.
74 TAG(transform_points1_general
)( GLvector4f
*to_vec
,
76 const GLvector4f
*from_vec
)
78 const GLuint stride
= from_vec
->stride
;
79 GLfloat
*from
= from_vec
->start
;
80 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
81 GLuint count
= from_vec
->count
;
82 const GLfloat m0
= m
[0], m12
= m
[12];
83 const GLfloat m1
= m
[1], m13
= m
[13];
84 const GLfloat m2
= m
[2], m14
= m
[14];
85 const GLfloat m3
= m
[3], m15
= m
[15];
88 const GLfloat ox
= from
[0];
89 to
[i
][0] = m0
* ox
+ m12
;
90 to
[i
][1] = m1
* ox
+ m13
;
91 to
[i
][2] = m2
* ox
+ m14
;
92 to
[i
][3] = m3
* ox
+ m15
;
95 to_vec
->flags
|= VEC_SIZE_4
;
96 to_vec
->count
= from_vec
->count
;
100 TAG(transform_points1_identity
)( GLvector4f
*to_vec
,
102 const GLvector4f
*from_vec
)
104 const GLuint stride
= from_vec
->stride
;
105 GLfloat
*from
= from_vec
->start
;
106 GLuint count
= from_vec
->count
;
107 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
109 if (to_vec
== from_vec
) return;
114 to_vec
->flags
|= VEC_SIZE_1
;
115 to_vec
->count
= from_vec
->count
;
118 static void _XFORMAPI
119 TAG(transform_points1_2d
)( GLvector4f
*to_vec
,
121 const GLvector4f
*from_vec
)
123 const GLuint stride
= from_vec
->stride
;
124 GLfloat
*from
= from_vec
->start
;
125 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
126 GLuint count
= from_vec
->count
;
127 const GLfloat m0
= m
[0], m1
= m
[1];
128 const GLfloat m12
= m
[12], m13
= m
[13];
131 const GLfloat ox
= from
[0];
132 to
[i
][0] = m0
* ox
+ m12
;
133 to
[i
][1] = m1
* ox
+ m13
;
136 to_vec
->flags
|= VEC_SIZE_2
;
137 to_vec
->count
= from_vec
->count
;
140 static void _XFORMAPI
141 TAG(transform_points1_2d_no_rot
)( GLvector4f
*to_vec
,
143 const GLvector4f
*from_vec
)
145 const GLuint stride
= from_vec
->stride
;
146 GLfloat
*from
= from_vec
->start
;
147 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
148 GLuint count
= from_vec
->count
;
149 const GLfloat m0
= m
[0], m12
= m
[12], m13
= m
[13];
152 const GLfloat ox
= from
[0];
153 to
[i
][0] = m0
* ox
+ m12
;
157 to_vec
->flags
|= VEC_SIZE_2
;
158 to_vec
->count
= from_vec
->count
;
161 static void _XFORMAPI
162 TAG(transform_points1_3d
)( GLvector4f
*to_vec
,
164 const GLvector4f
*from_vec
)
166 const GLuint stride
= from_vec
->stride
;
167 GLfloat
*from
= from_vec
->start
;
168 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
169 GLuint count
= from_vec
->count
;
170 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2];
171 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
174 const GLfloat ox
= from
[0];
175 to
[i
][0] = m0
* ox
+ m12
;
176 to
[i
][1] = m1
* ox
+ m13
;
177 to
[i
][2] = m2
* ox
+ m14
;
180 to_vec
->flags
|= VEC_SIZE_3
;
181 to_vec
->count
= from_vec
->count
;
185 static void _XFORMAPI
186 TAG(transform_points1_3d_no_rot
)( GLvector4f
*to_vec
,
188 const GLvector4f
*from_vec
)
190 const GLuint stride
= from_vec
->stride
;
191 GLfloat
*from
= from_vec
->start
;
192 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
193 GLuint count
= from_vec
->count
;
194 const GLfloat m0
= m
[0];
195 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
198 const GLfloat ox
= from
[0];
199 to
[i
][0] = m0
* ox
+ m12
;
204 to_vec
->flags
|= VEC_SIZE_3
;
205 to_vec
->count
= from_vec
->count
;
208 static void _XFORMAPI
209 TAG(transform_points1_perspective
)( GLvector4f
*to_vec
,
211 const GLvector4f
*from_vec
)
213 const GLuint stride
= from_vec
->stride
;
214 GLfloat
*from
= from_vec
->start
;
215 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
216 GLuint count
= from_vec
->count
;
217 const GLfloat m0
= m
[0], m14
= m
[14];
220 const GLfloat ox
= from
[0];
227 to_vec
->flags
|= VEC_SIZE_4
;
228 to_vec
->count
= from_vec
->count
;
234 /* 2-vectors, which are a lot more relevant than 1-vectors, are
235 * present early in the geometry pipeline and throughout the
238 static void _XFORMAPI
239 TAG(transform_points2_general
)( GLvector4f
*to_vec
,
241 const GLvector4f
*from_vec
)
243 const GLuint stride
= from_vec
->stride
;
244 GLfloat
*from
= from_vec
->start
;
245 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
246 GLuint count
= from_vec
->count
;
247 const GLfloat m0
= m
[0], m4
= m
[4], m12
= m
[12];
248 const GLfloat m1
= m
[1], m5
= m
[5], m13
= m
[13];
249 const GLfloat m2
= m
[2], m6
= m
[6], m14
= m
[14];
250 const GLfloat m3
= m
[3], m7
= m
[7], m15
= m
[15];
253 const GLfloat ox
= from
[0], oy
= from
[1];
254 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
255 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
256 to
[i
][2] = m2
* ox
+ m6
* oy
+ m14
;
257 to
[i
][3] = m3
* ox
+ m7
* oy
+ m15
;
260 to_vec
->flags
|= VEC_SIZE_4
;
261 to_vec
->count
= from_vec
->count
;
264 static void _XFORMAPI
265 TAG(transform_points2_identity
)( GLvector4f
*to_vec
,
267 const GLvector4f
*from_vec
)
269 const GLuint stride
= from_vec
->stride
;
270 GLfloat
*from
= from_vec
->start
;
271 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
272 GLuint count
= from_vec
->count
;
274 if (to_vec
== from_vec
) return;
280 to_vec
->flags
|= VEC_SIZE_2
;
281 to_vec
->count
= from_vec
->count
;
284 static void _XFORMAPI
285 TAG(transform_points2_2d
)( GLvector4f
*to_vec
,
287 const GLvector4f
*from_vec
)
289 const GLuint stride
= from_vec
->stride
;
290 GLfloat
*from
= from_vec
->start
;
291 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
292 GLuint count
= from_vec
->count
;
293 const GLfloat m0
= m
[0], m1
= m
[1], m4
= m
[4], m5
= m
[5];
294 const GLfloat m12
= m
[12], m13
= m
[13];
297 const GLfloat ox
= from
[0], oy
= from
[1];
298 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
299 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
302 to_vec
->flags
|= VEC_SIZE_2
;
303 to_vec
->count
= from_vec
->count
;
306 static void _XFORMAPI
307 TAG(transform_points2_2d_no_rot
)( GLvector4f
*to_vec
,
309 const GLvector4f
*from_vec
)
311 const GLuint stride
= from_vec
->stride
;
312 GLfloat
*from
= from_vec
->start
;
313 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
314 GLuint count
= from_vec
->count
;
315 const GLfloat m0
= m
[0], m5
= m
[5], m12
= m
[12], m13
= m
[13];
318 const GLfloat ox
= from
[0], oy
= from
[1];
319 to
[i
][0] = m0
* ox
+ m12
;
320 to
[i
][1] = m5
* oy
+ m13
;
323 to_vec
->flags
|= VEC_SIZE_2
;
324 to_vec
->count
= from_vec
->count
;
327 static void _XFORMAPI
328 TAG(transform_points2_3d
)( GLvector4f
*to_vec
,
330 const GLvector4f
*from_vec
)
332 const GLuint stride
= from_vec
->stride
;
333 GLfloat
*from
= from_vec
->start
;
334 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
335 GLuint count
= from_vec
->count
;
336 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2], m4
= m
[4], m5
= m
[5];
337 const GLfloat m6
= m
[6], m12
= m
[12], m13
= m
[13], m14
= m
[14];
340 const GLfloat ox
= from
[0], oy
= from
[1];
341 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
342 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
343 to
[i
][2] = m2
* ox
+ m6
* oy
+ m14
;
346 to_vec
->flags
|= VEC_SIZE_3
;
347 to_vec
->count
= from_vec
->count
;
351 /* I would actually say this was a fairly important function, from
352 * a texture transformation point of view.
354 static void _XFORMAPI
355 TAG(transform_points2_3d_no_rot
)( GLvector4f
*to_vec
,
357 const GLvector4f
*from_vec
)
359 const GLuint stride
= from_vec
->stride
;
360 GLfloat
*from
= from_vec
->start
;
361 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
362 GLuint count
= from_vec
->count
;
363 const GLfloat m0
= m
[0], m5
= m
[5];
364 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
367 const GLfloat ox
= from
[0], oy
= from
[1];
368 to
[i
][0] = m0
* ox
+ m12
;
369 to
[i
][1] = m5
* oy
+ m13
;
374 to_vec
->flags
|= VEC_SIZE_2
;
377 to_vec
->flags
|= VEC_SIZE_3
;
379 to_vec
->count
= from_vec
->count
;
383 static void _XFORMAPI
384 TAG(transform_points2_perspective
)( GLvector4f
*to_vec
,
386 const GLvector4f
*from_vec
)
388 const GLuint stride
= from_vec
->stride
;
389 GLfloat
*from
= from_vec
->start
;
390 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
391 GLuint count
= from_vec
->count
;
392 const GLfloat m0
= m
[0], m5
= m
[5], m14
= m
[14];
395 const GLfloat ox
= from
[0], oy
= from
[1];
402 to_vec
->flags
|= VEC_SIZE_4
;
403 to_vec
->count
= from_vec
->count
;
408 static void _XFORMAPI
409 TAG(transform_points3_general
)( GLvector4f
*to_vec
,
411 const GLvector4f
*from_vec
)
413 const GLuint stride
= from_vec
->stride
;
414 GLfloat
*from
= from_vec
->start
;
415 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
416 GLuint count
= from_vec
->count
;
417 const GLfloat m0
= m
[0], m4
= m
[4], m8
= m
[8], m12
= m
[12];
418 const GLfloat m1
= m
[1], m5
= m
[5], m9
= m
[9], m13
= m
[13];
419 const GLfloat m2
= m
[2], m6
= m
[6], m10
= m
[10], m14
= m
[14];
420 const GLfloat m3
= m
[3], m7
= m
[7], m11
= m
[11], m15
= m
[15];
423 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
424 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
;
425 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
;
426 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
;
427 to
[i
][3] = m3
* ox
+ m7
* oy
+ m11
* oz
+ m15
;
430 to_vec
->flags
|= VEC_SIZE_4
;
431 to_vec
->count
= from_vec
->count
;
434 static void _XFORMAPI
435 TAG(transform_points3_identity
)( GLvector4f
*to_vec
,
437 const GLvector4f
*from_vec
)
439 const GLuint stride
= from_vec
->stride
;
440 GLfloat
*from
= from_vec
->start
;
441 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
442 GLuint count
= from_vec
->count
;
444 if (to_vec
== from_vec
) return;
451 to_vec
->flags
|= VEC_SIZE_3
;
452 to_vec
->count
= from_vec
->count
;
455 static void _XFORMAPI
456 TAG(transform_points3_2d
)( GLvector4f
*to_vec
,
458 const GLvector4f
*from_vec
)
460 const GLuint stride
= from_vec
->stride
;
461 GLfloat
*from
= from_vec
->start
;
462 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
463 GLuint count
= from_vec
->count
;
464 const GLfloat m0
= m
[0], m1
= m
[1], m4
= m
[4], m5
= m
[5];
465 const GLfloat m12
= m
[12], m13
= m
[13];
468 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
469 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
470 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
474 to_vec
->flags
|= VEC_SIZE_3
;
475 to_vec
->count
= from_vec
->count
;
478 static void _XFORMAPI
479 TAG(transform_points3_2d_no_rot
)( GLvector4f
*to_vec
,
481 const GLvector4f
*from_vec
)
483 const GLuint stride
= from_vec
->stride
;
484 GLfloat
*from
= from_vec
->start
;
485 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
486 GLuint count
= from_vec
->count
;
487 const GLfloat m0
= m
[0], m5
= m
[5], m12
= m
[12], m13
= m
[13];
490 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
491 to
[i
][0] = m0
* ox
+ m12
;
492 to
[i
][1] = m5
* oy
+ m13
;
496 to_vec
->flags
|= VEC_SIZE_3
;
497 to_vec
->count
= from_vec
->count
;
500 static void _XFORMAPI
501 TAG(transform_points3_3d
)( GLvector4f
*to_vec
,
503 const GLvector4f
*from_vec
)
505 const GLuint stride
= from_vec
->stride
;
506 GLfloat
*from
= from_vec
->start
;
507 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
508 GLuint count
= from_vec
->count
;
509 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2], m4
= m
[4], m5
= m
[5];
510 const GLfloat m6
= m
[6], m8
= m
[8], m9
= m
[9], m10
= m
[10];
511 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
514 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
515 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
;
516 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
;
517 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
;
520 to_vec
->flags
|= VEC_SIZE_3
;
521 to_vec
->count
= from_vec
->count
;
524 /* previously known as ortho...
526 static void _XFORMAPI
527 TAG(transform_points3_3d_no_rot
)( GLvector4f
*to_vec
,
529 const GLvector4f
*from_vec
)
531 const GLuint stride
= from_vec
->stride
;
532 GLfloat
*from
= from_vec
->start
;
533 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
534 GLuint count
= from_vec
->count
;
535 const GLfloat m0
= m
[0], m5
= m
[5];
536 const GLfloat m10
= m
[10], m12
= m
[12], m13
= m
[13], m14
= m
[14];
539 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
540 to
[i
][0] = m0
* ox
+ m12
;
541 to
[i
][1] = m5
* oy
+ m13
;
542 to
[i
][2] = m10
* oz
+ m14
;
545 to_vec
->flags
|= VEC_SIZE_3
;
546 to_vec
->count
= from_vec
->count
;
549 static void _XFORMAPI
550 TAG(transform_points3_perspective
)( GLvector4f
*to_vec
,
552 const GLvector4f
*from_vec
)
554 const GLuint stride
= from_vec
->stride
;
555 GLfloat
*from
= from_vec
->start
;
556 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
557 GLuint count
= from_vec
->count
;
558 const GLfloat m0
= m
[0], m5
= m
[5], m8
= m
[8], m9
= m
[9];
559 const GLfloat m10
= m
[10], m14
= m
[14];
562 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
563 to
[i
][0] = m0
* ox
+ m8
* oz
;
564 to
[i
][1] = m5
* oy
+ m9
* oz
;
565 to
[i
][2] = m10
* oz
+ m14
;
569 to_vec
->flags
|= VEC_SIZE_4
;
570 to_vec
->count
= from_vec
->count
;
575 static void _XFORMAPI
576 TAG(transform_points4_general
)( GLvector4f
*to_vec
,
578 const GLvector4f
*from_vec
)
580 const GLuint stride
= from_vec
->stride
;
581 GLfloat
*from
= from_vec
->start
;
582 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
583 GLuint count
= from_vec
->count
;
584 const GLfloat m0
= m
[0], m4
= m
[4], m8
= m
[8], m12
= m
[12];
585 const GLfloat m1
= m
[1], m5
= m
[5], m9
= m
[9], m13
= m
[13];
586 const GLfloat m2
= m
[2], m6
= m
[6], m10
= m
[10], m14
= m
[14];
587 const GLfloat m3
= m
[3], m7
= m
[7], m11
= m
[11], m15
= m
[15];
590 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
591 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
* ow
;
592 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
* ow
;
593 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
* ow
;
594 to
[i
][3] = m3
* ox
+ m7
* oy
+ m11
* oz
+ m15
* ow
;
597 to_vec
->flags
|= VEC_SIZE_4
;
598 to_vec
->count
= from_vec
->count
;
601 static void _XFORMAPI
602 TAG(transform_points4_identity
)( GLvector4f
*to_vec
,
604 const GLvector4f
*from_vec
)
606 const GLuint stride
= from_vec
->stride
;
607 GLfloat
*from
= from_vec
->start
;
608 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
609 GLuint count
= from_vec
->count
;
611 if (to_vec
== from_vec
) return;
619 to_vec
->flags
|= VEC_SIZE_4
;
620 to_vec
->count
= from_vec
->count
;
623 static void _XFORMAPI
624 TAG(transform_points4_2d
)( GLvector4f
*to_vec
,
626 const GLvector4f
*from_vec
)
628 const GLuint stride
= from_vec
->stride
;
629 GLfloat
*from
= from_vec
->start
;
630 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
631 GLuint count
= from_vec
->count
;
632 const GLfloat m0
= m
[0], m1
= m
[1], m4
= m
[4], m5
= m
[5];
633 const GLfloat m12
= m
[12], m13
= m
[13];
636 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
637 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
* ow
;
638 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
* ow
;
643 to_vec
->flags
|= VEC_SIZE_4
;
644 to_vec
->count
= from_vec
->count
;
647 static void _XFORMAPI
648 TAG(transform_points4_2d_no_rot
)( GLvector4f
*to_vec
,
650 const GLvector4f
*from_vec
)
652 const GLuint stride
= from_vec
->stride
;
653 GLfloat
*from
= from_vec
->start
;
654 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
655 GLuint count
= from_vec
->count
;
656 const GLfloat m0
= m
[0], m5
= m
[5], m12
= m
[12], m13
= m
[13];
659 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
660 to
[i
][0] = m0
* ox
+ m12
* ow
;
661 to
[i
][1] = m5
* oy
+ m13
* ow
;
666 to_vec
->flags
|= VEC_SIZE_4
;
667 to_vec
->count
= from_vec
->count
;
670 static void _XFORMAPI
671 TAG(transform_points4_3d
)( GLvector4f
*to_vec
,
673 const GLvector4f
*from_vec
)
675 const GLuint stride
= from_vec
->stride
;
676 GLfloat
*from
= from_vec
->start
;
677 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
678 GLuint count
= from_vec
->count
;
679 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2], m4
= m
[4], m5
= m
[5];
680 const GLfloat m6
= m
[6], m8
= m
[8], m9
= m
[9], m10
= m
[10];
681 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
684 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
685 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
* ow
;
686 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
* ow
;
687 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
* ow
;
691 to_vec
->flags
|= VEC_SIZE_4
;
692 to_vec
->count
= from_vec
->count
;
695 static void _XFORMAPI
696 TAG(transform_points4_3d_no_rot
)( GLvector4f
*to_vec
,
698 const GLvector4f
*from_vec
)
700 const GLuint stride
= from_vec
->stride
;
701 GLfloat
*from
= from_vec
->start
;
702 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
703 GLuint count
= from_vec
->count
;
704 const GLfloat m0
= m
[0], m5
= m
[5];
705 const GLfloat m10
= m
[10], m12
= m
[12], m13
= m
[13], m14
= m
[14];
708 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
709 to
[i
][0] = m0
* ox
+ m12
* ow
;
710 to
[i
][1] = m5
* oy
+ m13
* ow
;
711 to
[i
][2] = m10
* oz
+ m14
* ow
;
715 to_vec
->flags
|= VEC_SIZE_4
;
716 to_vec
->count
= from_vec
->count
;
719 static void _XFORMAPI
720 TAG(transform_points4_perspective
)( GLvector4f
*to_vec
,
722 const GLvector4f
*from_vec
)
724 const GLuint stride
= from_vec
->stride
;
725 GLfloat
*from
= from_vec
->start
;
726 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
727 GLuint count
= from_vec
->count
;
728 const GLfloat m0
= m
[0], m5
= m
[5], m8
= m
[8], m9
= m
[9];
729 const GLfloat m10
= m
[10], m14
= m
[14];
732 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
733 to
[i
][0] = m0
* ox
+ m8
* oz
;
734 to
[i
][1] = m5
* oy
+ m9
* oz
;
735 to
[i
][2] = m10
* oz
+ m14
* ow
;
739 to_vec
->flags
|= VEC_SIZE_4
;
740 to_vec
->count
= from_vec
->count
;
743 static transform_func _XFORMAPI
TAG(transform_tab_1
)[7];
744 static transform_func _XFORMAPI
TAG(transform_tab_2
)[7];
745 static transform_func _XFORMAPI
TAG(transform_tab_3
)[7];
746 static transform_func _XFORMAPI
TAG(transform_tab_4
)[7];
748 /* Similar functions could be called several times, with more highly
749 * optimized routines overwriting the arrays. This only occurs during
752 static void _XFORMAPI
TAG(init_c_transformations
)( void )
754 #define TAG_TAB _mesa_transform_tab
755 #define TAG_TAB_1 TAG(transform_tab_1)
756 #define TAG_TAB_2 TAG(transform_tab_2)
757 #define TAG_TAB_3 TAG(transform_tab_3)
758 #define TAG_TAB_4 TAG(transform_tab_4)
760 TAG_TAB
[1] = TAG_TAB_1
;
761 TAG_TAB
[2] = TAG_TAB_2
;
762 TAG_TAB
[3] = TAG_TAB_3
;
763 TAG_TAB
[4] = TAG_TAB_4
;
765 /* 1-D points (ie texcoords) */
766 TAG_TAB_1
[MATRIX_GENERAL
] = TAG(transform_points1_general
);
767 TAG_TAB_1
[MATRIX_IDENTITY
] = TAG(transform_points1_identity
);
768 TAG_TAB_1
[MATRIX_3D_NO_ROT
] = TAG(transform_points1_3d_no_rot
);
769 TAG_TAB_1
[MATRIX_PERSPECTIVE
] = TAG(transform_points1_perspective
);
770 TAG_TAB_1
[MATRIX_2D
] = TAG(transform_points1_2d
);
771 TAG_TAB_1
[MATRIX_2D_NO_ROT
] = TAG(transform_points1_2d_no_rot
);
772 TAG_TAB_1
[MATRIX_3D
] = TAG(transform_points1_3d
);
775 TAG_TAB_2
[MATRIX_GENERAL
] = TAG(transform_points2_general
);
776 TAG_TAB_2
[MATRIX_IDENTITY
] = TAG(transform_points2_identity
);
777 TAG_TAB_2
[MATRIX_3D_NO_ROT
] = TAG(transform_points2_3d_no_rot
);
778 TAG_TAB_2
[MATRIX_PERSPECTIVE
] = TAG(transform_points2_perspective
);
779 TAG_TAB_2
[MATRIX_2D
] = TAG(transform_points2_2d
);
780 TAG_TAB_2
[MATRIX_2D_NO_ROT
] = TAG(transform_points2_2d_no_rot
);
781 TAG_TAB_2
[MATRIX_3D
] = TAG(transform_points2_3d
);
784 TAG_TAB_3
[MATRIX_GENERAL
] = TAG(transform_points3_general
);
785 TAG_TAB_3
[MATRIX_IDENTITY
] = TAG(transform_points3_identity
);
786 TAG_TAB_3
[MATRIX_3D_NO_ROT
] = TAG(transform_points3_3d_no_rot
);
787 TAG_TAB_3
[MATRIX_PERSPECTIVE
] = TAG(transform_points3_perspective
);
788 TAG_TAB_3
[MATRIX_2D
] = TAG(transform_points3_2d
);
789 TAG_TAB_3
[MATRIX_2D_NO_ROT
] = TAG(transform_points3_2d_no_rot
);
790 TAG_TAB_3
[MATRIX_3D
] = TAG(transform_points3_3d
);
793 TAG_TAB_4
[MATRIX_GENERAL
] = TAG(transform_points4_general
);
794 TAG_TAB_4
[MATRIX_IDENTITY
] = TAG(transform_points4_identity
);
795 TAG_TAB_4
[MATRIX_3D_NO_ROT
] = TAG(transform_points4_3d_no_rot
);
796 TAG_TAB_4
[MATRIX_PERSPECTIVE
] = TAG(transform_points4_perspective
);
797 TAG_TAB_4
[MATRIX_2D
] = TAG(transform_points4_2d
);
798 TAG_TAB_4
[MATRIX_2D_NO_ROT
] = TAG(transform_points4_2d_no_rot
);
799 TAG_TAB_4
[MATRIX_3D
] = TAG(transform_points4_3d
);