- Add -D_POSIX_SOURCE -D_POSIX_C_SOURCE=199309L to linux builds, we've
[mesa.git] / src / mesa / math / m_xform_tmp.h
1 /* $Id: m_xform_tmp.h,v 1.5 2001/03/12 02:02:36 gareth Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
6 *
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
8 *
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:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
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.
25 */
26
27 /*
28 * New (3.1) transformation code written by Keith Whitwell.
29 */
30
31
32 /*----------------------------------------------------------------------
33 * Begin Keith's new code
34 *
35 *----------------------------------------------------------------------
36 */
37
38 /* KW: Fixed stride, now measured in bytes as is the OpenGL array stride.
39 */
40
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
44 * unculled vertices.
45 */
46
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.
52 *
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.
56 */
57
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
61 * size.
62 */
63
64 /* KW: Now uses clipmask and a flag to allow us to skip both/either
65 * cliped and/or culled vertices.
66 */
67
68 static void _XFORMAPI
69 TAG(transform_points1_general)( GLvector4f *to_vec,
70 const GLfloat m[16],
71 const GLvector4f *from_vec,
72 const GLubyte *mask,
73 const GLubyte flag )
74 {
75 const GLuint stride = from_vec->stride;
76 GLfloat *from = from_vec->start;
77 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
78 GLuint count = from_vec->count;
79 const GLfloat m0 = m[0], m12 = m[12];
80 const GLfloat m1 = m[1], m13 = m[13];
81 const GLfloat m2 = m[2], m14 = m[14];
82 const GLfloat m3 = m[3], m15 = m[15];
83 GLuint i;
84 (void) mask;
85 (void) flag;
86 STRIDE_LOOP {
87 CLIP_CHECK {
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;
93 }
94 }
95
96 to_vec->size = 4;
97 to_vec->flags |= VEC_SIZE_4;
98 to_vec->count = from_vec->count;
99 }
100
101 static void _XFORMAPI
102 TAG(transform_points1_identity)( GLvector4f *to_vec,
103 const GLfloat m[16],
104 const GLvector4f *from_vec,
105 const GLubyte *mask,
106 const GLubyte flag )
107 {
108 const GLuint stride = from_vec->stride;
109 GLfloat *from = from_vec->start;
110 GLuint count = from_vec->count;
111 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
112 GLuint i;
113 (void) mask;
114 (void) flag;
115 if (to_vec == from_vec) return;
116 STRIDE_LOOP {
117 CLIP_CHECK {
118 to[i][0] = from[0];
119 }
120 }
121
122 to_vec->size = 1;
123 to_vec->flags |= VEC_SIZE_1;
124 to_vec->count = from_vec->count;
125 }
126
127 static void _XFORMAPI
128 TAG(transform_points1_2d)( GLvector4f *to_vec,
129 const GLfloat m[16],
130 const GLvector4f *from_vec,
131 const GLubyte *mask,
132 const GLubyte flag )
133 {
134 const GLuint stride = from_vec->stride;
135 GLfloat *from = from_vec->start;
136 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
137 GLuint count = from_vec->count;
138 const GLfloat m0 = m[0], m1 = m[1];
139 const GLfloat m12 = m[12], m13 = m[13];
140 GLuint i;
141 (void) mask;
142 (void) flag;
143 STRIDE_LOOP {
144 CLIP_CHECK {
145 const GLfloat ox = from[0];
146 to[i][0] = m0 * ox + m12;
147 to[i][1] = m1 * ox + m13;
148 }
149 }
150 to_vec->size = 2;
151 to_vec->flags |= VEC_SIZE_2;
152 to_vec->count = from_vec->count;
153 }
154
155 static void _XFORMAPI
156 TAG(transform_points1_2d_no_rot)( GLvector4f *to_vec,
157 const GLfloat m[16],
158 const GLvector4f *from_vec,
159 const GLubyte *mask,
160 const GLubyte flag )
161 {
162 const GLuint stride = from_vec->stride;
163 GLfloat *from = from_vec->start;
164 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
165 GLuint count = from_vec->count;
166 const GLfloat m0 = m[0], m12 = m[12], m13 = m[13];
167 GLuint i;
168 (void) mask;
169 (void) flag;
170 STRIDE_LOOP {
171 CLIP_CHECK {
172 const GLfloat ox = from[0];
173 to[i][0] = m0 * ox + m12;
174 to[i][1] = m13;
175 }
176 }
177
178 to_vec->size = 2;
179 to_vec->flags |= VEC_SIZE_2;
180 to_vec->count = from_vec->count;
181 }
182
183 static void _XFORMAPI
184 TAG(transform_points1_3d)( GLvector4f *to_vec,
185 const GLfloat m[16],
186 const GLvector4f *from_vec,
187 const GLubyte *mask,
188 const GLubyte flag )
189 {
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], m1 = m[1], m2 = m[2];
195 const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
196 GLuint i;
197 (void) mask;
198 (void) flag;
199 STRIDE_LOOP {
200 CLIP_CHECK {
201 const GLfloat ox = from[0];
202 to[i][0] = m0 * ox + m12;
203 to[i][1] = m1 * ox + m13;
204 to[i][2] = m2 * ox + m14;
205 }
206 }
207 to_vec->size = 3;
208 to_vec->flags |= VEC_SIZE_3;
209 to_vec->count = from_vec->count;
210 }
211
212
213 static void _XFORMAPI
214 TAG(transform_points1_3d_no_rot)( GLvector4f *to_vec,
215 const GLfloat m[16],
216 const GLvector4f *from_vec,
217 const GLubyte *mask,
218 const GLubyte flag )
219 {
220 const GLuint stride = from_vec->stride;
221 GLfloat *from = from_vec->start;
222 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
223 GLuint count = from_vec->count;
224 const GLfloat m0 = m[0];
225 const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
226 GLuint i;
227 (void) mask;
228 (void) flag;
229 STRIDE_LOOP {
230 CLIP_CHECK {
231 const GLfloat ox = from[0];
232 to[i][0] = m0 * ox + m12;
233 to[i][1] = m13;
234 to[i][2] = m14;
235 }
236 }
237 to_vec->size = 3;
238 to_vec->flags |= VEC_SIZE_3;
239 to_vec->count = from_vec->count;
240 }
241
242 static void _XFORMAPI
243 TAG(transform_points1_perspective)( GLvector4f *to_vec,
244 const GLfloat m[16],
245 const GLvector4f *from_vec,
246 const GLubyte *mask,
247 const GLubyte flag )
248 {
249 const GLuint stride = from_vec->stride;
250 GLfloat *from = from_vec->start;
251 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
252 GLuint count = from_vec->count;
253 const GLfloat m0 = m[0], m14 = m[14];
254 GLuint i;
255 (void) mask;
256 (void) flag;
257 STRIDE_LOOP {
258 CLIP_CHECK {
259 const GLfloat ox = from[0];
260 to[i][0] = m0 * ox ;
261 to[i][1] = 0 ;
262 to[i][2] = m14;
263 to[i][3] = 0;
264 }
265 }
266 to_vec->size = 4;
267 to_vec->flags |= VEC_SIZE_4;
268 to_vec->count = from_vec->count;
269 }
270
271
272
273
274 /* 2-vectors, which are a lot more relevant than 1-vectors, are
275 * present early in the geometry pipeline and throughout the
276 * texture pipeline.
277 */
278 static void _XFORMAPI
279 TAG(transform_points2_general)( GLvector4f *to_vec,
280 const GLfloat m[16],
281 const GLvector4f *from_vec,
282 const GLubyte *mask,
283 const GLubyte flag )
284 {
285 const GLuint stride = from_vec->stride;
286 GLfloat *from = from_vec->start;
287 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
288 GLuint count = from_vec->count;
289 const GLfloat m0 = m[0], m4 = m[4], m12 = m[12];
290 const GLfloat m1 = m[1], m5 = m[5], m13 = m[13];
291 const GLfloat m2 = m[2], m6 = m[6], m14 = m[14];
292 const GLfloat m3 = m[3], m7 = m[7], m15 = m[15];
293 GLuint i;
294 (void) mask;
295 (void) flag;
296 STRIDE_LOOP {
297 CLIP_CHECK {
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;
301 to[i][2] = m2 * ox + m6 * oy + m14;
302 to[i][3] = m3 * ox + m7 * oy + m15;
303 }
304 }
305 to_vec->size = 4;
306 to_vec->flags |= VEC_SIZE_4;
307 to_vec->count = from_vec->count;
308 }
309
310 static void _XFORMAPI
311 TAG(transform_points2_identity)( GLvector4f *to_vec,
312 const GLfloat m[16],
313 const GLvector4f *from_vec,
314 const GLubyte *mask,
315 const GLubyte flag )
316 {
317 const GLuint stride = from_vec->stride;
318 GLfloat *from = from_vec->start;
319 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
320 GLuint count = from_vec->count;
321 GLuint i;
322 (void) mask;
323 (void) flag;
324 if (to_vec == from_vec) return;
325 STRIDE_LOOP {
326 CLIP_CHECK {
327 to[i][0] = from[0];
328 to[i][1] = from[1];
329 }
330 }
331 to_vec->size = 2;
332 to_vec->flags |= VEC_SIZE_2;
333 to_vec->count = from_vec->count;
334 }
335
336 static void _XFORMAPI
337 TAG(transform_points2_2d)( GLvector4f *to_vec,
338 const GLfloat m[16],
339 const GLvector4f *from_vec,
340 const GLubyte *mask,
341 const GLubyte flag )
342 {
343 const GLuint stride = from_vec->stride;
344 GLfloat *from = from_vec->start;
345 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
346 GLuint count = from_vec->count;
347 const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
348 const GLfloat m12 = m[12], m13 = m[13];
349 GLuint i;
350 (void) mask;
351 (void) flag;
352 STRIDE_LOOP {
353 CLIP_CHECK {
354 const GLfloat ox = from[0], oy = from[1];
355 to[i][0] = m0 * ox + m4 * oy + m12;
356 to[i][1] = m1 * ox + m5 * oy + m13;
357 }
358 }
359
360 to_vec->size = 2;
361 to_vec->flags |= VEC_SIZE_2;
362 to_vec->count = from_vec->count;
363 }
364
365 static void _XFORMAPI
366 TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec,
367 const GLfloat m[16],
368 const GLvector4f *from_vec,
369 const GLubyte *mask,
370 const GLubyte flag )
371 {
372 const GLuint stride = from_vec->stride;
373 GLfloat *from = from_vec->start;
374 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
375 GLuint count = from_vec->count;
376 const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
377 GLuint i;
378 (void) mask;
379 (void) flag;
380 STRIDE_LOOP {
381 CLIP_CHECK {
382 const GLfloat ox = from[0], oy = from[1];
383 to[i][0] = m0 * ox + m12;
384 to[i][1] = m5 * oy + m13;
385 }
386 }
387
388 to_vec->size = 2;
389 to_vec->flags |= VEC_SIZE_2;
390 to_vec->count = from_vec->count;
391 }
392
393 static void _XFORMAPI
394 TAG(transform_points2_3d)( GLvector4f *to_vec,
395 const GLfloat m[16],
396 const GLvector4f *from_vec,
397 const GLubyte *mask,
398 const GLubyte flag )
399 {
400 const GLuint stride = from_vec->stride;
401 GLfloat *from = from_vec->start;
402 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
403 GLuint count = from_vec->count;
404 const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
405 const GLfloat m6 = m[6], m12 = m[12], m13 = m[13], m14 = m[14];
406 GLuint i;
407 (void) mask;
408 (void) flag;
409 STRIDE_LOOP {
410 CLIP_CHECK {
411 const GLfloat ox = from[0], oy = from[1];
412 to[i][0] = m0 * ox + m4 * oy + m12;
413 to[i][1] = m1 * ox + m5 * oy + m13;
414 to[i][2] = m2 * ox + m6 * oy + m14;
415 }
416 }
417 to_vec->size = 3;
418 to_vec->flags |= VEC_SIZE_3;
419 to_vec->count = from_vec->count;
420 }
421
422
423 /* I would actually say this was a fairly important function, from
424 * a texture transformation point of view.
425 */
426 static void _XFORMAPI
427 TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec,
428 const GLfloat m[16],
429 const GLvector4f *from_vec,
430 const GLubyte *mask,
431 const GLubyte flag )
432 {
433 const GLuint stride = from_vec->stride;
434 GLfloat *from = from_vec->start;
435 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
436 GLuint count = from_vec->count;
437 const GLfloat m0 = m[0], m5 = m[5];
438 const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
439 GLuint i;
440 (void) mask;
441 (void) flag;
442 STRIDE_LOOP {
443 CLIP_CHECK {
444 const GLfloat ox = from[0], oy = from[1];
445 to[i][0] = m0 * ox + m12;
446 to[i][1] = m5 * oy + m13;
447 to[i][2] = m14;
448 }
449 }
450 if (m14 == 0) {
451 to_vec->size = 2;
452 to_vec->flags |= VEC_SIZE_2;
453 } else {
454 to_vec->size = 3;
455 to_vec->flags |= VEC_SIZE_3;
456 }
457 to_vec->count = from_vec->count;
458 }
459
460
461 static void _XFORMAPI
462 TAG(transform_points2_perspective)( GLvector4f *to_vec,
463 const GLfloat m[16],
464 const GLvector4f *from_vec,
465 const GLubyte *mask,
466 const GLubyte flag )
467 {
468 const GLuint stride = from_vec->stride;
469 GLfloat *from = from_vec->start;
470 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
471 GLuint count = from_vec->count;
472 const GLfloat m0 = m[0], m5 = m[5], m14 = m[14];
473 GLuint i;
474 (void) mask;
475 (void) flag;
476 STRIDE_LOOP {
477 CLIP_CHECK {
478 const GLfloat ox = from[0], oy = from[1];
479 to[i][0] = m0 * ox ;
480 to[i][1] = m5 * oy ;
481 to[i][2] = m14;
482 to[i][3] = 0;
483 }
484 }
485 to_vec->size = 4;
486 to_vec->flags |= VEC_SIZE_4;
487 to_vec->count = from_vec->count;
488 }
489
490
491
492 static void _XFORMAPI
493 TAG(transform_points3_general)( GLvector4f *to_vec,
494 const GLfloat m[16],
495 const GLvector4f *from_vec,
496 const GLubyte *mask,
497 const GLubyte flag )
498 {
499 const GLuint stride = from_vec->stride;
500 GLfloat *from = from_vec->start;
501 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
502 GLuint count = from_vec->count;
503 const GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12];
504 const GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13];
505 const GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14];
506 const GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15];
507 GLuint i;
508 (void) mask;
509 (void) flag;
510 STRIDE_LOOP {
511 CLIP_CHECK {
512 const GLfloat ox = from[0], oy = from[1], oz = from[2];
513 to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12;
514 to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13;
515 to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14;
516 to[i][3] = m3 * ox + m7 * oy + m11 * oz + m15;
517 }
518 }
519 to_vec->size = 4;
520 to_vec->flags |= VEC_SIZE_4;
521 to_vec->count = from_vec->count;
522 }
523
524 static void _XFORMAPI
525 TAG(transform_points3_identity)( GLvector4f *to_vec,
526 const GLfloat m[16],
527 const GLvector4f *from_vec,
528 const GLubyte *mask,
529 const GLubyte flag )
530 {
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 GLuint i;
536 (void) mask;
537 (void) flag;
538 if (to_vec == from_vec) return;
539 STRIDE_LOOP {
540 CLIP_CHECK {
541 to[i][0] = from[0];
542 to[i][1] = from[1];
543 to[i][2] = from[2];
544 }
545 }
546 to_vec->size = 3;
547 to_vec->flags |= VEC_SIZE_3;
548 to_vec->count = from_vec->count;
549 }
550
551 static void _XFORMAPI
552 TAG(transform_points3_2d)( GLvector4f *to_vec,
553 const GLfloat m[16],
554 const GLvector4f *from_vec,
555 const GLubyte *mask,
556 const GLubyte flag )
557 {
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], m1 = m[1], m4 = m[4], m5 = m[5];
563 const GLfloat m12 = m[12], m13 = m[13];
564 GLuint i;
565 (void) mask;
566 (void) flag;
567 STRIDE_LOOP {
568 CLIP_CHECK {
569 const GLfloat ox = from[0], oy = from[1], oz = from[2];
570 to[i][0] = m0 * ox + m4 * oy + m12 ;
571 to[i][1] = m1 * ox + m5 * oy + m13 ;
572 to[i][2] = + oz ;
573 }
574 }
575 to_vec->size = 3;
576 to_vec->flags |= VEC_SIZE_3;
577 to_vec->count = from_vec->count;
578 }
579
580 static void _XFORMAPI
581 TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec,
582 const GLfloat m[16],
583 const GLvector4f *from_vec,
584 const GLubyte *mask,
585 const GLubyte flag )
586 {
587 const GLuint stride = from_vec->stride;
588 GLfloat *from = from_vec->start;
589 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
590 GLuint count = from_vec->count;
591 const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
592 GLuint i;
593 (void) mask;
594 (void) flag;
595 STRIDE_LOOP {
596 CLIP_CHECK {
597 const GLfloat ox = from[0], oy = from[1], oz = from[2];
598 to[i][0] = m0 * ox + m12 ;
599 to[i][1] = m5 * oy + m13 ;
600 to[i][2] = + oz ;
601 }
602 }
603 to_vec->size = 3;
604 to_vec->flags |= VEC_SIZE_3;
605 to_vec->count = from_vec->count;
606 }
607
608 static void _XFORMAPI
609 TAG(transform_points3_3d)( GLvector4f *to_vec,
610 const GLfloat m[16],
611 const GLvector4f *from_vec,
612 const GLubyte *mask,
613 const GLubyte flag )
614 {
615 const GLuint stride = from_vec->stride;
616 GLfloat *from = from_vec->start;
617 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
618 GLuint count = from_vec->count;
619 const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
620 const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10];
621 const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
622 GLuint i;
623 (void) mask;
624 (void) flag;
625 STRIDE_LOOP {
626 CLIP_CHECK {
627 const GLfloat ox = from[0], oy = from[1], oz = from[2];
628 to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 ;
629 to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 ;
630 to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 ;
631 }
632 }
633 to_vec->size = 3;
634 to_vec->flags |= VEC_SIZE_3;
635 to_vec->count = from_vec->count;
636 }
637
638 /* previously known as ortho...
639 */
640 static void _XFORMAPI
641 TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec,
642 const GLfloat m[16],
643 const GLvector4f *from_vec,
644 const GLubyte *mask,
645 const GLubyte flag )
646 {
647 const GLuint stride = from_vec->stride;
648 GLfloat *from = from_vec->start;
649 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
650 GLuint count = from_vec->count;
651 const GLfloat m0 = m[0], m5 = m[5];
652 const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14];
653 GLuint i;
654 (void) mask;
655 (void) flag;
656 STRIDE_LOOP {
657 CLIP_CHECK {
658 const GLfloat ox = from[0], oy = from[1], oz = from[2];
659 to[i][0] = m0 * ox + m12 ;
660 to[i][1] = m5 * oy + m13 ;
661 to[i][2] = m10 * oz + m14 ;
662 }
663 }
664 to_vec->size = 3;
665 to_vec->flags |= VEC_SIZE_3;
666 to_vec->count = from_vec->count;
667 }
668
669 static void _XFORMAPI
670 TAG(transform_points3_perspective)( GLvector4f *to_vec,
671 const GLfloat m[16],
672 const GLvector4f *from_vec,
673 const GLubyte *mask,
674 const GLubyte flag )
675 {
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], m5 = m[5], m8 = m[8], m9 = m[9];
681 const GLfloat m10 = m[10], m14 = m[14];
682 GLuint i;
683 (void) mask;
684 (void) flag;
685 STRIDE_LOOP {
686 CLIP_CHECK {
687 const GLfloat ox = from[0], oy = from[1], oz = from[2];
688 to[i][0] = m0 * ox + m8 * oz ;
689 to[i][1] = m5 * oy + m9 * oz ;
690 to[i][2] = m10 * oz + m14 ;
691 to[i][3] = -oz ;
692 }
693 }
694 to_vec->size = 4;
695 to_vec->flags |= VEC_SIZE_4;
696 to_vec->count = from_vec->count;
697 }
698
699
700
701 static void _XFORMAPI
702 TAG(transform_points4_general)( GLvector4f *to_vec,
703 const GLfloat m[16],
704 const GLvector4f *from_vec,
705 const GLubyte *mask,
706 const GLubyte flag )
707 {
708 const GLuint stride = from_vec->stride;
709 GLfloat *from = from_vec->start;
710 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
711 GLuint count = from_vec->count;
712 const GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12];
713 const GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13];
714 const GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14];
715 const GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15];
716 GLuint i;
717 (void) mask;
718 (void) flag;
719 STRIDE_LOOP {
720 CLIP_CHECK {
721 const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
722 to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 * ow;
723 to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 * ow;
724 to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 * ow;
725 to[i][3] = m3 * ox + m7 * oy + m11 * oz + m15 * ow;
726 }
727 }
728 to_vec->size = 4;
729 to_vec->flags |= VEC_SIZE_4;
730 to_vec->count = from_vec->count;
731 }
732
733 static void _XFORMAPI
734 TAG(transform_points4_identity)( GLvector4f *to_vec,
735 const GLfloat m[16],
736 const GLvector4f *from_vec,
737 const GLubyte *mask,
738 const GLubyte flag )
739 {
740 const GLuint stride = from_vec->stride;
741 GLfloat *from = from_vec->start;
742 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
743 GLuint count = from_vec->count;
744 GLuint i;
745 (void) mask;
746 (void) flag;
747 if (to_vec == from_vec) return;
748 STRIDE_LOOP {
749 CLIP_CHECK {
750 to[i][0] = from[0];
751 to[i][1] = from[1];
752 to[i][2] = from[2];
753 to[i][3] = from[3];
754 }
755 }
756 to_vec->size = 4;
757 to_vec->flags |= VEC_SIZE_4;
758 to_vec->count = from_vec->count;
759 }
760
761 static void _XFORMAPI
762 TAG(transform_points4_2d)( GLvector4f *to_vec,
763 const GLfloat m[16],
764 const GLvector4f *from_vec,
765 const GLubyte *mask,
766 const GLubyte flag )
767 {
768 const GLuint stride = from_vec->stride;
769 GLfloat *from = from_vec->start;
770 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
771 GLuint count = from_vec->count;
772 const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
773 const GLfloat m12 = m[12], m13 = m[13];
774 GLuint i;
775 (void) mask;
776 (void) flag;
777 STRIDE_LOOP {
778 CLIP_CHECK {
779 const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
780 to[i][0] = m0 * ox + m4 * oy + m12 * ow;
781 to[i][1] = m1 * ox + m5 * oy + m13 * ow;
782 to[i][2] = + oz ;
783 to[i][3] = ow;
784 }
785 }
786 to_vec->size = 4;
787 to_vec->flags |= VEC_SIZE_4;
788 to_vec->count = from_vec->count;
789 }
790
791 static void _XFORMAPI
792 TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec,
793 const GLfloat m[16],
794 const GLvector4f *from_vec,
795 const GLubyte *mask,
796 const GLubyte flag )
797 {
798 const GLuint stride = from_vec->stride;
799 GLfloat *from = from_vec->start;
800 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
801 GLuint count = from_vec->count;
802 const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
803 GLuint i;
804 (void) mask;
805 (void) flag;
806 STRIDE_LOOP {
807 CLIP_CHECK {
808 const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
809 to[i][0] = m0 * ox + m12 * ow;
810 to[i][1] = m5 * oy + m13 * ow;
811 to[i][2] = + oz ;
812 to[i][3] = ow;
813 }
814 }
815 to_vec->size = 4;
816 to_vec->flags |= VEC_SIZE_4;
817 to_vec->count = from_vec->count;
818 }
819
820 static void _XFORMAPI
821 TAG(transform_points4_3d)( GLvector4f *to_vec,
822 const GLfloat m[16],
823 const GLvector4f *from_vec,
824 const GLubyte *mask,
825 const GLubyte flag )
826 {
827 const GLuint stride = from_vec->stride;
828 GLfloat *from = from_vec->start;
829 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
830 GLuint count = from_vec->count;
831 const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
832 const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10];
833 const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
834 GLuint i;
835 (void) mask;
836 (void) flag;
837 STRIDE_LOOP {
838 CLIP_CHECK {
839 const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
840 to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 * ow;
841 to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 * ow;
842 to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 * ow;
843 to[i][3] = ow;
844 }
845 }
846 to_vec->size = 4;
847 to_vec->flags |= VEC_SIZE_4;
848 to_vec->count = from_vec->count;
849 }
850
851 static void _XFORMAPI
852 TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec,
853 const GLfloat m[16],
854 const GLvector4f *from_vec,
855 const GLubyte *mask,
856 const GLubyte flag )
857 {
858 const GLuint stride = from_vec->stride;
859 GLfloat *from = from_vec->start;
860 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
861 GLuint count = from_vec->count;
862 const GLfloat m0 = m[0], m5 = m[5];
863 const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14];
864 GLuint i;
865 (void) mask;
866 (void) flag;
867 STRIDE_LOOP {
868 CLIP_CHECK {
869 const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
870 to[i][0] = m0 * ox + m12 * ow;
871 to[i][1] = m5 * oy + m13 * ow;
872 to[i][2] = m10 * oz + m14 * ow;
873 to[i][3] = ow;
874 }
875 }
876 to_vec->size = 4;
877 to_vec->flags |= VEC_SIZE_4;
878 to_vec->count = from_vec->count;
879 }
880
881 static void _XFORMAPI
882 TAG(transform_points4_perspective)( GLvector4f *to_vec,
883 const GLfloat m[16],
884 const GLvector4f *from_vec,
885 const GLubyte *mask,
886 const GLubyte flag )
887 {
888 const GLuint stride = from_vec->stride;
889 GLfloat *from = from_vec->start;
890 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
891 GLuint count = from_vec->count;
892 const GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9];
893 const GLfloat m10 = m[10], m14 = m[14];
894 GLuint i;
895 (void) mask;
896 (void) flag;
897 STRIDE_LOOP {
898 CLIP_CHECK {
899 const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
900 to[i][0] = m0 * ox + m8 * oz ;
901 to[i][1] = m5 * oy + m9 * oz ;
902 to[i][2] = m10 * oz + m14 * ow ;
903 to[i][3] = -oz ;
904 }
905 }
906
907 to_vec->size = 4;
908 to_vec->flags |= VEC_SIZE_4;
909 to_vec->count = from_vec->count;
910 }
911
912 static transform_func _XFORMAPI TAG(transform_tab_1)[7];
913 static transform_func _XFORMAPI TAG(transform_tab_2)[7];
914 static transform_func _XFORMAPI TAG(transform_tab_3)[7];
915 static transform_func _XFORMAPI TAG(transform_tab_4)[7];
916
917 /* Similar functions could be called several times, with more highly
918 * optimized routines overwriting the arrays. This only occurs during
919 * startup.
920 */
921 static void _XFORMAPI TAG(init_c_transformations)( void )
922 {
923 #define TAG_TAB _mesa_transform_tab[IDX]
924 #define TAG_TAB_1 TAG(transform_tab_1)
925 #define TAG_TAB_2 TAG(transform_tab_2)
926 #define TAG_TAB_3 TAG(transform_tab_3)
927 #define TAG_TAB_4 TAG(transform_tab_4)
928
929 TAG_TAB[1] = TAG_TAB_1;
930 TAG_TAB[2] = TAG_TAB_2;
931 TAG_TAB[3] = TAG_TAB_3;
932 TAG_TAB[4] = TAG_TAB_4;
933
934 /* 1-D points (ie texcoords) */
935 TAG_TAB_1[MATRIX_GENERAL] = TAG(transform_points1_general);
936 TAG_TAB_1[MATRIX_IDENTITY] = TAG(transform_points1_identity);
937 TAG_TAB_1[MATRIX_3D_NO_ROT] = TAG(transform_points1_3d_no_rot);
938 TAG_TAB_1[MATRIX_PERSPECTIVE] = TAG(transform_points1_perspective) ;
939 TAG_TAB_1[MATRIX_2D] = TAG(transform_points1_2d);
940 TAG_TAB_1[MATRIX_2D_NO_ROT] = TAG(transform_points1_2d_no_rot);
941 TAG_TAB_1[MATRIX_3D] = TAG(transform_points1_3d);
942
943 /* 2-D points */
944 TAG_TAB_2[MATRIX_GENERAL] = TAG(transform_points2_general);
945 TAG_TAB_2[MATRIX_IDENTITY] = TAG(transform_points2_identity);
946 TAG_TAB_2[MATRIX_3D_NO_ROT] = TAG(transform_points2_3d_no_rot);
947 TAG_TAB_2[MATRIX_PERSPECTIVE] = TAG(transform_points2_perspective) ;
948 TAG_TAB_2[MATRIX_2D] = TAG(transform_points2_2d);
949 TAG_TAB_2[MATRIX_2D_NO_ROT] = TAG(transform_points2_2d_no_rot);
950 TAG_TAB_2[MATRIX_3D] = TAG(transform_points2_3d);
951
952 /* 3-D points */
953 TAG_TAB_3[MATRIX_GENERAL] = TAG(transform_points3_general);
954 TAG_TAB_3[MATRIX_IDENTITY] = TAG(transform_points3_identity);
955 TAG_TAB_3[MATRIX_3D_NO_ROT] = TAG(transform_points3_3d_no_rot);
956 TAG_TAB_3[MATRIX_PERSPECTIVE] = TAG(transform_points3_perspective);
957 TAG_TAB_3[MATRIX_2D] = TAG(transform_points3_2d);
958 TAG_TAB_3[MATRIX_2D_NO_ROT] = TAG(transform_points3_2d_no_rot);
959 TAG_TAB_3[MATRIX_3D] = TAG(transform_points3_3d);
960
961 /* 4-D points */
962 TAG_TAB_4[MATRIX_GENERAL] = TAG(transform_points4_general);
963 TAG_TAB_4[MATRIX_IDENTITY] = TAG(transform_points4_identity);
964 TAG_TAB_4[MATRIX_3D_NO_ROT] = TAG(transform_points4_3d_no_rot);
965 TAG_TAB_4[MATRIX_PERSPECTIVE] = TAG(transform_points4_perspective);
966 TAG_TAB_4[MATRIX_2D] = TAG(transform_points4_2d);
967 TAG_TAB_4[MATRIX_2D_NO_ROT] = TAG(transform_points4_2d_no_rot);
968 TAG_TAB_4[MATRIX_3D] = TAG(transform_points4_3d);
969
970 #undef TAG_TAB
971 }