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 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
22 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
23 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 * 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
;
111 if (to_vec
== from_vec
) return;
116 to_vec
->flags
|= VEC_SIZE_1
;
117 to_vec
->count
= from_vec
->count
;
120 static void _XFORMAPI
121 TAG(transform_points1_2d
)( GLvector4f
*to_vec
,
123 const GLvector4f
*from_vec
)
125 const GLuint stride
= from_vec
->stride
;
126 GLfloat
*from
= from_vec
->start
;
127 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
128 GLuint count
= from_vec
->count
;
129 const GLfloat m0
= m
[0], m1
= m
[1];
130 const GLfloat m12
= m
[12], m13
= m
[13];
133 const GLfloat ox
= from
[0];
134 to
[i
][0] = m0
* ox
+ m12
;
135 to
[i
][1] = m1
* ox
+ m13
;
138 to_vec
->flags
|= VEC_SIZE_2
;
139 to_vec
->count
= from_vec
->count
;
142 static void _XFORMAPI
143 TAG(transform_points1_2d_no_rot
)( GLvector4f
*to_vec
,
145 const GLvector4f
*from_vec
)
147 const GLuint stride
= from_vec
->stride
;
148 GLfloat
*from
= from_vec
->start
;
149 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
150 GLuint count
= from_vec
->count
;
151 const GLfloat m0
= m
[0], m12
= m
[12], m13
= m
[13];
154 const GLfloat ox
= from
[0];
155 to
[i
][0] = m0
* ox
+ m12
;
159 to_vec
->flags
|= VEC_SIZE_2
;
160 to_vec
->count
= from_vec
->count
;
163 static void _XFORMAPI
164 TAG(transform_points1_3d
)( GLvector4f
*to_vec
,
166 const GLvector4f
*from_vec
)
168 const GLuint stride
= from_vec
->stride
;
169 GLfloat
*from
= from_vec
->start
;
170 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
171 GLuint count
= from_vec
->count
;
172 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2];
173 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
176 const GLfloat ox
= from
[0];
177 to
[i
][0] = m0
* ox
+ m12
;
178 to
[i
][1] = m1
* ox
+ m13
;
179 to
[i
][2] = m2
* ox
+ m14
;
182 to_vec
->flags
|= VEC_SIZE_3
;
183 to_vec
->count
= from_vec
->count
;
187 static void _XFORMAPI
188 TAG(transform_points1_3d_no_rot
)( GLvector4f
*to_vec
,
190 const GLvector4f
*from_vec
)
192 const GLuint stride
= from_vec
->stride
;
193 GLfloat
*from
= from_vec
->start
;
194 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
195 GLuint count
= from_vec
->count
;
196 const GLfloat m0
= m
[0];
197 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
200 const GLfloat ox
= from
[0];
201 to
[i
][0] = m0
* ox
+ m12
;
206 to_vec
->flags
|= VEC_SIZE_3
;
207 to_vec
->count
= from_vec
->count
;
210 static void _XFORMAPI
211 TAG(transform_points1_perspective
)( GLvector4f
*to_vec
,
213 const GLvector4f
*from_vec
)
215 const GLuint stride
= from_vec
->stride
;
216 GLfloat
*from
= from_vec
->start
;
217 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
218 GLuint count
= from_vec
->count
;
219 const GLfloat m0
= m
[0], m14
= m
[14];
222 const GLfloat ox
= from
[0];
229 to_vec
->flags
|= VEC_SIZE_4
;
230 to_vec
->count
= from_vec
->count
;
236 /* 2-vectors, which are a lot more relevant than 1-vectors, are
237 * present early in the geometry pipeline and throughout the
240 static void _XFORMAPI
241 TAG(transform_points2_general
)( GLvector4f
*to_vec
,
243 const GLvector4f
*from_vec
)
245 const GLuint stride
= from_vec
->stride
;
246 GLfloat
*from
= from_vec
->start
;
247 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
248 GLuint count
= from_vec
->count
;
249 const GLfloat m0
= m
[0], m4
= m
[4], m12
= m
[12];
250 const GLfloat m1
= m
[1], m5
= m
[5], m13
= m
[13];
251 const GLfloat m2
= m
[2], m6
= m
[6], m14
= m
[14];
252 const GLfloat m3
= m
[3], m7
= m
[7], m15
= m
[15];
255 const GLfloat ox
= from
[0], oy
= from
[1];
256 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
257 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
258 to
[i
][2] = m2
* ox
+ m6
* oy
+ m14
;
259 to
[i
][3] = m3
* ox
+ m7
* oy
+ m15
;
262 to_vec
->flags
|= VEC_SIZE_4
;
263 to_vec
->count
= from_vec
->count
;
266 static void _XFORMAPI
267 TAG(transform_points2_identity
)( GLvector4f
*to_vec
,
269 const GLvector4f
*from_vec
)
271 const GLuint stride
= from_vec
->stride
;
272 GLfloat
*from
= from_vec
->start
;
273 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
274 GLuint count
= from_vec
->count
;
277 if (to_vec
== from_vec
) return;
283 to_vec
->flags
|= VEC_SIZE_2
;
284 to_vec
->count
= from_vec
->count
;
287 static void _XFORMAPI
288 TAG(transform_points2_2d
)( GLvector4f
*to_vec
,
290 const GLvector4f
*from_vec
)
292 const GLuint stride
= from_vec
->stride
;
293 GLfloat
*from
= from_vec
->start
;
294 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
295 GLuint count
= from_vec
->count
;
296 const GLfloat m0
= m
[0], m1
= m
[1], m4
= m
[4], m5
= m
[5];
297 const GLfloat m12
= m
[12], m13
= m
[13];
300 const GLfloat ox
= from
[0], oy
= from
[1];
301 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
302 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
305 to_vec
->flags
|= VEC_SIZE_2
;
306 to_vec
->count
= from_vec
->count
;
309 static void _XFORMAPI
310 TAG(transform_points2_2d_no_rot
)( GLvector4f
*to_vec
,
312 const GLvector4f
*from_vec
)
314 const GLuint stride
= from_vec
->stride
;
315 GLfloat
*from
= from_vec
->start
;
316 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
317 GLuint count
= from_vec
->count
;
318 const GLfloat m0
= m
[0], m5
= m
[5], m12
= m
[12], m13
= m
[13];
321 const GLfloat ox
= from
[0], oy
= from
[1];
322 to
[i
][0] = m0
* ox
+ m12
;
323 to
[i
][1] = m5
* oy
+ m13
;
326 to_vec
->flags
|= VEC_SIZE_2
;
327 to_vec
->count
= from_vec
->count
;
330 static void _XFORMAPI
331 TAG(transform_points2_3d
)( GLvector4f
*to_vec
,
333 const GLvector4f
*from_vec
)
335 const GLuint stride
= from_vec
->stride
;
336 GLfloat
*from
= from_vec
->start
;
337 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
338 GLuint count
= from_vec
->count
;
339 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2], m4
= m
[4], m5
= m
[5];
340 const GLfloat m6
= m
[6], m12
= m
[12], m13
= m
[13], m14
= m
[14];
343 const GLfloat ox
= from
[0], oy
= from
[1];
344 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
345 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
346 to
[i
][2] = m2
* ox
+ m6
* oy
+ m14
;
349 to_vec
->flags
|= VEC_SIZE_3
;
350 to_vec
->count
= from_vec
->count
;
354 /* I would actually say this was a fairly important function, from
355 * a texture transformation point of view.
357 static void _XFORMAPI
358 TAG(transform_points2_3d_no_rot
)( GLvector4f
*to_vec
,
360 const GLvector4f
*from_vec
)
362 const GLuint stride
= from_vec
->stride
;
363 GLfloat
*from
= from_vec
->start
;
364 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
365 GLuint count
= from_vec
->count
;
366 const GLfloat m0
= m
[0], m5
= m
[5];
367 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
370 const GLfloat ox
= from
[0], oy
= from
[1];
371 to
[i
][0] = m0
* ox
+ m12
;
372 to
[i
][1] = m5
* oy
+ m13
;
377 to_vec
->flags
|= VEC_SIZE_2
;
380 to_vec
->flags
|= VEC_SIZE_3
;
382 to_vec
->count
= from_vec
->count
;
386 static void _XFORMAPI
387 TAG(transform_points2_perspective
)( GLvector4f
*to_vec
,
389 const GLvector4f
*from_vec
)
391 const GLuint stride
= from_vec
->stride
;
392 GLfloat
*from
= from_vec
->start
;
393 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
394 GLuint count
= from_vec
->count
;
395 const GLfloat m0
= m
[0], m5
= m
[5], m14
= m
[14];
398 const GLfloat ox
= from
[0], oy
= from
[1];
405 to_vec
->flags
|= VEC_SIZE_4
;
406 to_vec
->count
= from_vec
->count
;
411 static void _XFORMAPI
412 TAG(transform_points3_general
)( GLvector4f
*to_vec
,
414 const GLvector4f
*from_vec
)
416 const GLuint stride
= from_vec
->stride
;
417 GLfloat
*from
= from_vec
->start
;
418 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
419 GLuint count
= from_vec
->count
;
420 const GLfloat m0
= m
[0], m4
= m
[4], m8
= m
[8], m12
= m
[12];
421 const GLfloat m1
= m
[1], m5
= m
[5], m9
= m
[9], m13
= m
[13];
422 const GLfloat m2
= m
[2], m6
= m
[6], m10
= m
[10], m14
= m
[14];
423 const GLfloat m3
= m
[3], m7
= m
[7], m11
= m
[11], m15
= m
[15];
426 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
427 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
;
428 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
;
429 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
;
430 to
[i
][3] = m3
* ox
+ m7
* oy
+ m11
* oz
+ m15
;
433 to_vec
->flags
|= VEC_SIZE_4
;
434 to_vec
->count
= from_vec
->count
;
437 static void _XFORMAPI
438 TAG(transform_points3_identity
)( GLvector4f
*to_vec
,
440 const GLvector4f
*from_vec
)
442 const GLuint stride
= from_vec
->stride
;
443 GLfloat
*from
= from_vec
->start
;
444 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
445 GLuint count
= from_vec
->count
;
448 if (to_vec
== from_vec
) return;
455 to_vec
->flags
|= VEC_SIZE_3
;
456 to_vec
->count
= from_vec
->count
;
459 static void _XFORMAPI
460 TAG(transform_points3_2d
)( GLvector4f
*to_vec
,
462 const GLvector4f
*from_vec
)
464 const GLuint stride
= from_vec
->stride
;
465 GLfloat
*from
= from_vec
->start
;
466 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
467 GLuint count
= from_vec
->count
;
468 const GLfloat m0
= m
[0], m1
= m
[1], m4
= m
[4], m5
= m
[5];
469 const GLfloat m12
= m
[12], m13
= m
[13];
472 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
473 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
;
474 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
;
478 to_vec
->flags
|= VEC_SIZE_3
;
479 to_vec
->count
= from_vec
->count
;
482 static void _XFORMAPI
483 TAG(transform_points3_2d_no_rot
)( GLvector4f
*to_vec
,
485 const GLvector4f
*from_vec
)
487 const GLuint stride
= from_vec
->stride
;
488 GLfloat
*from
= from_vec
->start
;
489 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
490 GLuint count
= from_vec
->count
;
491 const GLfloat m0
= m
[0], m5
= m
[5], m12
= m
[12], m13
= m
[13];
494 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
495 to
[i
][0] = m0
* ox
+ m12
;
496 to
[i
][1] = m5
* oy
+ m13
;
500 to_vec
->flags
|= VEC_SIZE_3
;
501 to_vec
->count
= from_vec
->count
;
504 static void _XFORMAPI
505 TAG(transform_points3_3d
)( GLvector4f
*to_vec
,
507 const GLvector4f
*from_vec
)
509 const GLuint stride
= from_vec
->stride
;
510 GLfloat
*from
= from_vec
->start
;
511 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
512 GLuint count
= from_vec
->count
;
513 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2], m4
= m
[4], m5
= m
[5];
514 const GLfloat m6
= m
[6], m8
= m
[8], m9
= m
[9], m10
= m
[10];
515 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
518 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
519 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
;
520 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
;
521 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
;
524 to_vec
->flags
|= VEC_SIZE_3
;
525 to_vec
->count
= from_vec
->count
;
528 /* previously known as ortho...
530 static void _XFORMAPI
531 TAG(transform_points3_3d_no_rot
)( GLvector4f
*to_vec
,
533 const GLvector4f
*from_vec
)
535 const GLuint stride
= from_vec
->stride
;
536 GLfloat
*from
= from_vec
->start
;
537 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
538 GLuint count
= from_vec
->count
;
539 const GLfloat m0
= m
[0], m5
= m
[5];
540 const GLfloat m10
= m
[10], m12
= m
[12], m13
= m
[13], m14
= m
[14];
543 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
544 to
[i
][0] = m0
* ox
+ m12
;
545 to
[i
][1] = m5
* oy
+ m13
;
546 to
[i
][2] = m10
* oz
+ m14
;
549 to_vec
->flags
|= VEC_SIZE_3
;
550 to_vec
->count
= from_vec
->count
;
553 static void _XFORMAPI
554 TAG(transform_points3_perspective
)( GLvector4f
*to_vec
,
556 const GLvector4f
*from_vec
)
558 const GLuint stride
= from_vec
->stride
;
559 GLfloat
*from
= from_vec
->start
;
560 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
561 GLuint count
= from_vec
->count
;
562 const GLfloat m0
= m
[0], m5
= m
[5], m8
= m
[8], m9
= m
[9];
563 const GLfloat m10
= m
[10], m14
= m
[14];
566 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2];
567 to
[i
][0] = m0
* ox
+ m8
* oz
;
568 to
[i
][1] = m5
* oy
+ m9
* oz
;
569 to
[i
][2] = m10
* oz
+ m14
;
573 to_vec
->flags
|= VEC_SIZE_4
;
574 to_vec
->count
= from_vec
->count
;
579 static void _XFORMAPI
580 TAG(transform_points4_general
)( GLvector4f
*to_vec
,
582 const GLvector4f
*from_vec
)
584 const GLuint stride
= from_vec
->stride
;
585 GLfloat
*from
= from_vec
->start
;
586 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
587 GLuint count
= from_vec
->count
;
588 const GLfloat m0
= m
[0], m4
= m
[4], m8
= m
[8], m12
= m
[12];
589 const GLfloat m1
= m
[1], m5
= m
[5], m9
= m
[9], m13
= m
[13];
590 const GLfloat m2
= m
[2], m6
= m
[6], m10
= m
[10], m14
= m
[14];
591 const GLfloat m3
= m
[3], m7
= m
[7], m11
= m
[11], m15
= m
[15];
594 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
595 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
* ow
;
596 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
* ow
;
597 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
* ow
;
598 to
[i
][3] = m3
* ox
+ m7
* oy
+ m11
* oz
+ m15
* ow
;
601 to_vec
->flags
|= VEC_SIZE_4
;
602 to_vec
->count
= from_vec
->count
;
605 static void _XFORMAPI
606 TAG(transform_points4_identity
)( GLvector4f
*to_vec
,
608 const GLvector4f
*from_vec
)
610 const GLuint stride
= from_vec
->stride
;
611 GLfloat
*from
= from_vec
->start
;
612 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
613 GLuint count
= from_vec
->count
;
616 if (to_vec
== from_vec
) return;
624 to_vec
->flags
|= VEC_SIZE_4
;
625 to_vec
->count
= from_vec
->count
;
628 static void _XFORMAPI
629 TAG(transform_points4_2d
)( GLvector4f
*to_vec
,
631 const GLvector4f
*from_vec
)
633 const GLuint stride
= from_vec
->stride
;
634 GLfloat
*from
= from_vec
->start
;
635 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
636 GLuint count
= from_vec
->count
;
637 const GLfloat m0
= m
[0], m1
= m
[1], m4
= m
[4], m5
= m
[5];
638 const GLfloat m12
= m
[12], m13
= m
[13];
641 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
642 to
[i
][0] = m0
* ox
+ m4
* oy
+ m12
* ow
;
643 to
[i
][1] = m1
* ox
+ m5
* oy
+ m13
* ow
;
648 to_vec
->flags
|= VEC_SIZE_4
;
649 to_vec
->count
= from_vec
->count
;
652 static void _XFORMAPI
653 TAG(transform_points4_2d_no_rot
)( GLvector4f
*to_vec
,
655 const GLvector4f
*from_vec
)
657 const GLuint stride
= from_vec
->stride
;
658 GLfloat
*from
= from_vec
->start
;
659 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
660 GLuint count
= from_vec
->count
;
661 const GLfloat m0
= m
[0], m5
= m
[5], m12
= m
[12], m13
= m
[13];
664 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
665 to
[i
][0] = m0
* ox
+ m12
* ow
;
666 to
[i
][1] = m5
* oy
+ m13
* ow
;
671 to_vec
->flags
|= VEC_SIZE_4
;
672 to_vec
->count
= from_vec
->count
;
675 static void _XFORMAPI
676 TAG(transform_points4_3d
)( GLvector4f
*to_vec
,
678 const GLvector4f
*from_vec
)
680 const GLuint stride
= from_vec
->stride
;
681 GLfloat
*from
= from_vec
->start
;
682 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
683 GLuint count
= from_vec
->count
;
684 const GLfloat m0
= m
[0], m1
= m
[1], m2
= m
[2], m4
= m
[4], m5
= m
[5];
685 const GLfloat m6
= m
[6], m8
= m
[8], m9
= m
[9], m10
= m
[10];
686 const GLfloat m12
= m
[12], m13
= m
[13], m14
= m
[14];
689 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
690 to
[i
][0] = m0
* ox
+ m4
* oy
+ m8
* oz
+ m12
* ow
;
691 to
[i
][1] = m1
* ox
+ m5
* oy
+ m9
* oz
+ m13
* ow
;
692 to
[i
][2] = m2
* ox
+ m6
* oy
+ m10
* oz
+ m14
* ow
;
696 to_vec
->flags
|= VEC_SIZE_4
;
697 to_vec
->count
= from_vec
->count
;
700 static void _XFORMAPI
701 TAG(transform_points4_3d_no_rot
)( GLvector4f
*to_vec
,
703 const GLvector4f
*from_vec
)
705 const GLuint stride
= from_vec
->stride
;
706 GLfloat
*from
= from_vec
->start
;
707 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
708 GLuint count
= from_vec
->count
;
709 const GLfloat m0
= m
[0], m5
= m
[5];
710 const GLfloat m10
= m
[10], m12
= m
[12], m13
= m
[13], m14
= m
[14];
713 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
714 to
[i
][0] = m0
* ox
+ m12
* ow
;
715 to
[i
][1] = m5
* oy
+ m13
* ow
;
716 to
[i
][2] = m10
* oz
+ m14
* ow
;
720 to_vec
->flags
|= VEC_SIZE_4
;
721 to_vec
->count
= from_vec
->count
;
724 static void _XFORMAPI
725 TAG(transform_points4_perspective
)( GLvector4f
*to_vec
,
727 const GLvector4f
*from_vec
)
729 const GLuint stride
= from_vec
->stride
;
730 GLfloat
*from
= from_vec
->start
;
731 GLfloat (*to
)[4] = (GLfloat (*)[4])to_vec
->start
;
732 GLuint count
= from_vec
->count
;
733 const GLfloat m0
= m
[0], m5
= m
[5], m8
= m
[8], m9
= m
[9];
734 const GLfloat m10
= m
[10], m14
= m
[14];
737 const GLfloat ox
= from
[0], oy
= from
[1], oz
= from
[2], ow
= from
[3];
738 to
[i
][0] = m0
* ox
+ m8
* oz
;
739 to
[i
][1] = m5
* oy
+ m9
* oz
;
740 to
[i
][2] = m10
* oz
+ m14
* ow
;
744 to_vec
->flags
|= VEC_SIZE_4
;
745 to_vec
->count
= from_vec
->count
;
748 static transform_func
TAG(transform_tab_1
)[7];
749 static transform_func
TAG(transform_tab_2
)[7];
750 static transform_func
TAG(transform_tab_3
)[7];
751 static transform_func
TAG(transform_tab_4
)[7];
753 /* Similar functions could be called several times, with more highly
754 * optimized routines overwriting the arrays. This only occurs during
757 static void _XFORMAPI
TAG(init_c_transformations
)( void )
759 #define TAG_TAB _mesa_transform_tab
760 #define TAG_TAB_1 TAG(transform_tab_1)
761 #define TAG_TAB_2 TAG(transform_tab_2)
762 #define TAG_TAB_3 TAG(transform_tab_3)
763 #define TAG_TAB_4 TAG(transform_tab_4)
765 TAG_TAB
[1] = TAG_TAB_1
;
766 TAG_TAB
[2] = TAG_TAB_2
;
767 TAG_TAB
[3] = TAG_TAB_3
;
768 TAG_TAB
[4] = TAG_TAB_4
;
770 /* 1-D points (ie texcoords) */
771 TAG_TAB_1
[MATRIX_GENERAL
] = TAG(transform_points1_general
);
772 TAG_TAB_1
[MATRIX_IDENTITY
] = TAG(transform_points1_identity
);
773 TAG_TAB_1
[MATRIX_3D_NO_ROT
] = TAG(transform_points1_3d_no_rot
);
774 TAG_TAB_1
[MATRIX_PERSPECTIVE
] = TAG(transform_points1_perspective
);
775 TAG_TAB_1
[MATRIX_2D
] = TAG(transform_points1_2d
);
776 TAG_TAB_1
[MATRIX_2D_NO_ROT
] = TAG(transform_points1_2d_no_rot
);
777 TAG_TAB_1
[MATRIX_3D
] = TAG(transform_points1_3d
);
780 TAG_TAB_2
[MATRIX_GENERAL
] = TAG(transform_points2_general
);
781 TAG_TAB_2
[MATRIX_IDENTITY
] = TAG(transform_points2_identity
);
782 TAG_TAB_2
[MATRIX_3D_NO_ROT
] = TAG(transform_points2_3d_no_rot
);
783 TAG_TAB_2
[MATRIX_PERSPECTIVE
] = TAG(transform_points2_perspective
);
784 TAG_TAB_2
[MATRIX_2D
] = TAG(transform_points2_2d
);
785 TAG_TAB_2
[MATRIX_2D_NO_ROT
] = TAG(transform_points2_2d_no_rot
);
786 TAG_TAB_2
[MATRIX_3D
] = TAG(transform_points2_3d
);
789 TAG_TAB_3
[MATRIX_GENERAL
] = TAG(transform_points3_general
);
790 TAG_TAB_3
[MATRIX_IDENTITY
] = TAG(transform_points3_identity
);
791 TAG_TAB_3
[MATRIX_3D_NO_ROT
] = TAG(transform_points3_3d_no_rot
);
792 TAG_TAB_3
[MATRIX_PERSPECTIVE
] = TAG(transform_points3_perspective
);
793 TAG_TAB_3
[MATRIX_2D
] = TAG(transform_points3_2d
);
794 TAG_TAB_3
[MATRIX_2D_NO_ROT
] = TAG(transform_points3_2d_no_rot
);
795 TAG_TAB_3
[MATRIX_3D
] = TAG(transform_points3_3d
);
798 TAG_TAB_4
[MATRIX_GENERAL
] = TAG(transform_points4_general
);
799 TAG_TAB_4
[MATRIX_IDENTITY
] = TAG(transform_points4_identity
);
800 TAG_TAB_4
[MATRIX_3D_NO_ROT
] = TAG(transform_points4_3d_no_rot
);
801 TAG_TAB_4
[MATRIX_PERSPECTIVE
] = TAG(transform_points4_perspective
);
802 TAG_TAB_4
[MATRIX_2D
] = TAG(transform_points4_2d
);
803 TAG_TAB_4
[MATRIX_2D_NO_ROT
] = TAG(transform_points4_2d_no_rot
);
804 TAG_TAB_4
[MATRIX_3D
] = TAG(transform_points4_3d
);