Move the transform and lighting code to two new directories
[mesa.git] / src / mesa / math / m_xform_tmp.h
1 /* $Id: m_xform_tmp.h,v 1.1 2000/11/16 21:05:41 keithw Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.1
6 *
7 * Copyright (C) 1999 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 /* This may not be called too often, but I wouldn't say it was dead
461 * code. It's also hard to remove any of these functions if you are
462 * attached to the assertions that have appeared in them.
463 */
464 static void _XFORMAPI
465 TAG(transform_points2_perspective)( GLvector4f *to_vec,
466 const GLfloat m[16],
467 const GLvector4f *from_vec,
468 const GLubyte *mask,
469 const GLubyte flag )
470 {
471 const GLuint stride = from_vec->stride;
472 GLfloat *from = from_vec->start;
473 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
474 GLuint count = from_vec->count;
475 const GLfloat m0 = m[0], m5 = m[5], m14 = m[14];
476 GLuint i;
477 (void) mask;
478 (void) flag;
479 STRIDE_LOOP {
480 CLIP_CHECK {
481 const GLfloat ox = from[0], oy = from[1];
482 to[i][0] = m0 * ox ;
483 to[i][1] = m5 * oy ;
484 to[i][2] = m14;
485 to[i][3] = 0;
486 }
487 }
488 to_vec->size = 4;
489 to_vec->flags |= VEC_SIZE_4;
490 to_vec->count = from_vec->count;
491 }
492
493
494
495 static void _XFORMAPI
496 TAG(transform_points3_general)( GLvector4f *to_vec,
497 const GLfloat m[16],
498 const GLvector4f *from_vec,
499 const GLubyte *mask,
500 const GLubyte flag )
501 {
502 const GLuint stride = from_vec->stride;
503 GLfloat *from = from_vec->start;
504 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
505 GLuint count = from_vec->count;
506 const GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12];
507 const GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13];
508 const GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14];
509 const GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15];
510 GLuint i;
511 (void) mask;
512 (void) flag;
513 STRIDE_LOOP {
514 CLIP_CHECK {
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;
519 to[i][3] = m3 * ox + m7 * oy + m11 * oz + m15;
520 }
521 }
522 to_vec->size = 4;
523 to_vec->flags |= VEC_SIZE_4;
524 to_vec->count = from_vec->count;
525 }
526
527 static void _XFORMAPI
528 TAG(transform_points3_identity)( GLvector4f *to_vec,
529 const GLfloat m[16],
530 const GLvector4f *from_vec,
531 const GLubyte *mask,
532 const GLubyte flag )
533 {
534 const GLuint stride = from_vec->stride;
535 GLfloat *from = from_vec->start;
536 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
537 GLuint count = from_vec->count;
538 GLuint i;
539 (void) mask;
540 (void) flag;
541 if (to_vec == from_vec) return;
542 STRIDE_LOOP {
543 CLIP_CHECK {
544 to[i][0] = from[0];
545 to[i][1] = from[1];
546 to[i][2] = from[2];
547 }
548 }
549 to_vec->size = 3;
550 to_vec->flags |= VEC_SIZE_3;
551 to_vec->count = from_vec->count;
552 }
553
554 static void _XFORMAPI
555 TAG(transform_points3_2d)( GLvector4f *to_vec,
556 const GLfloat m[16],
557 const GLvector4f *from_vec,
558 const GLubyte *mask,
559 const GLubyte flag )
560 {
561 const GLuint stride = from_vec->stride;
562 GLfloat *from = from_vec->start;
563 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
564 GLuint count = from_vec->count;
565 const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
566 const GLfloat m12 = m[12], m13 = m[13];
567 GLuint i;
568 (void) mask;
569 (void) flag;
570 STRIDE_LOOP {
571 CLIP_CHECK {
572 const GLfloat ox = from[0], oy = from[1], oz = from[2];
573 to[i][0] = m0 * ox + m4 * oy + m12 ;
574 to[i][1] = m1 * ox + m5 * oy + m13 ;
575 to[i][2] = + oz ;
576 }
577 }
578 to_vec->size = 3;
579 to_vec->flags |= VEC_SIZE_3;
580 to_vec->count = from_vec->count;
581 }
582
583 static void _XFORMAPI
584 TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec,
585 const GLfloat m[16],
586 const GLvector4f *from_vec,
587 const GLubyte *mask,
588 const GLubyte flag )
589 {
590 const GLuint stride = from_vec->stride;
591 GLfloat *from = from_vec->start;
592 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
593 GLuint count = from_vec->count;
594 const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
595 GLuint i;
596 (void) mask;
597 (void) flag;
598 STRIDE_LOOP {
599 CLIP_CHECK {
600 const GLfloat ox = from[0], oy = from[1], oz = from[2];
601 to[i][0] = m0 * ox + m12 ;
602 to[i][1] = m5 * oy + m13 ;
603 to[i][2] = + oz ;
604 }
605 }
606 to_vec->size = 3;
607 to_vec->flags |= VEC_SIZE_3;
608 to_vec->count = from_vec->count;
609 }
610
611 static void _XFORMAPI
612 TAG(transform_points3_3d)( GLvector4f *to_vec,
613 const GLfloat m[16],
614 const GLvector4f *from_vec,
615 const GLubyte *mask,
616 const GLubyte flag )
617 {
618 const GLuint stride = from_vec->stride;
619 GLfloat *from = from_vec->start;
620 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
621 GLuint count = from_vec->count;
622 const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
623 const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10];
624 const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
625 GLuint i;
626 (void) mask;
627 (void) flag;
628 STRIDE_LOOP {
629 CLIP_CHECK {
630 const GLfloat ox = from[0], oy = from[1], oz = from[2];
631 to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 ;
632 to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 ;
633 to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 ;
634 }
635 }
636 to_vec->size = 3;
637 to_vec->flags |= VEC_SIZE_3;
638 to_vec->count = from_vec->count;
639 }
640
641 /* previously known as ortho...
642 */
643 static void _XFORMAPI
644 TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec,
645 const GLfloat m[16],
646 const GLvector4f *from_vec,
647 const GLubyte *mask,
648 const GLubyte flag )
649 {
650 const GLuint stride = from_vec->stride;
651 GLfloat *from = from_vec->start;
652 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
653 GLuint count = from_vec->count;
654 const GLfloat m0 = m[0], m5 = m[5];
655 const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14];
656 GLuint i;
657 (void) mask;
658 (void) flag;
659 STRIDE_LOOP {
660 CLIP_CHECK {
661 const GLfloat ox = from[0], oy = from[1], oz = from[2];
662 to[i][0] = m0 * ox + m12 ;
663 to[i][1] = m5 * oy + m13 ;
664 to[i][2] = m10 * oz + m14 ;
665 }
666 }
667 to_vec->size = 3;
668 to_vec->flags |= VEC_SIZE_3;
669 to_vec->count = from_vec->count;
670 }
671
672 static void _XFORMAPI
673 TAG(transform_points3_perspective)( GLvector4f *to_vec,
674 const GLfloat m[16],
675 const GLvector4f *from_vec,
676 const GLubyte *mask,
677 const GLubyte flag )
678 {
679 const GLuint stride = from_vec->stride;
680 GLfloat *from = from_vec->start;
681 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
682 GLuint count = from_vec->count;
683 const GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9];
684 const GLfloat m10 = m[10], m14 = m[14];
685 GLuint i;
686 (void) mask;
687 (void) flag;
688 STRIDE_LOOP {
689 CLIP_CHECK {
690 const GLfloat ox = from[0], oy = from[1], oz = from[2];
691 to[i][0] = m0 * ox + m8 * oz ;
692 to[i][1] = m5 * oy + m9 * oz ;
693 to[i][2] = m10 * oz + m14 ;
694 to[i][3] = -oz ;
695 }
696 }
697 to_vec->size = 4;
698 to_vec->flags |= VEC_SIZE_4;
699 to_vec->count = from_vec->count;
700 }
701
702
703
704 static void _XFORMAPI
705 TAG(transform_points4_general)( GLvector4f *to_vec,
706 const GLfloat m[16],
707 const GLvector4f *from_vec,
708 const GLubyte *mask,
709 const GLubyte flag )
710 {
711 const GLuint stride = from_vec->stride;
712 GLfloat *from = from_vec->start;
713 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
714 GLuint count = from_vec->count;
715 const GLfloat m0 = m[0], m4 = m[4], m8 = m[8], m12 = m[12];
716 const GLfloat m1 = m[1], m5 = m[5], m9 = m[9], m13 = m[13];
717 const GLfloat m2 = m[2], m6 = m[6], m10 = m[10], m14 = m[14];
718 const GLfloat m3 = m[3], m7 = m[7], m11 = m[11], m15 = m[15];
719 GLuint i;
720 (void) mask;
721 (void) flag;
722 STRIDE_LOOP {
723 CLIP_CHECK {
724 const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
725 to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 * ow;
726 to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 * ow;
727 to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 * ow;
728 to[i][3] = m3 * ox + m7 * oy + m11 * oz + m15 * ow;
729 }
730 }
731 to_vec->size = 4;
732 to_vec->flags |= VEC_SIZE_4;
733 to_vec->count = from_vec->count;
734 }
735
736 static void _XFORMAPI
737 TAG(transform_points4_identity)( GLvector4f *to_vec,
738 const GLfloat m[16],
739 const GLvector4f *from_vec,
740 const GLubyte *mask,
741 const GLubyte flag )
742 {
743 const GLuint stride = from_vec->stride;
744 GLfloat *from = from_vec->start;
745 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
746 GLuint count = from_vec->count;
747 GLuint i;
748 (void) mask;
749 (void) flag;
750 if (to_vec == from_vec) return;
751 STRIDE_LOOP {
752 CLIP_CHECK {
753 to[i][0] = from[0];
754 to[i][1] = from[1];
755 to[i][2] = from[2];
756 to[i][3] = from[3];
757 }
758 }
759 to_vec->size = 4;
760 to_vec->flags |= VEC_SIZE_4;
761 to_vec->count = from_vec->count;
762 }
763
764 static void _XFORMAPI
765 TAG(transform_points4_2d)( GLvector4f *to_vec,
766 const GLfloat m[16],
767 const GLvector4f *from_vec,
768 const GLubyte *mask,
769 const GLubyte flag )
770 {
771 const GLuint stride = from_vec->stride;
772 GLfloat *from = from_vec->start;
773 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
774 GLuint count = from_vec->count;
775 const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
776 const GLfloat m12 = m[12], m13 = m[13];
777 GLuint i;
778 (void) mask;
779 (void) flag;
780 STRIDE_LOOP {
781 CLIP_CHECK {
782 const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
783 to[i][0] = m0 * ox + m4 * oy + m12 * ow;
784 to[i][1] = m1 * ox + m5 * oy + m13 * ow;
785 to[i][2] = + oz ;
786 to[i][3] = ow;
787 }
788 }
789 to_vec->size = 4;
790 to_vec->flags |= VEC_SIZE_4;
791 to_vec->count = from_vec->count;
792 }
793
794 static void _XFORMAPI
795 TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec,
796 const GLfloat m[16],
797 const GLvector4f *from_vec,
798 const GLubyte *mask,
799 const GLubyte flag )
800 {
801 const GLuint stride = from_vec->stride;
802 GLfloat *from = from_vec->start;
803 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
804 GLuint count = from_vec->count;
805 const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
806 GLuint i;
807 (void) mask;
808 (void) flag;
809 STRIDE_LOOP {
810 CLIP_CHECK {
811 const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
812 to[i][0] = m0 * ox + m12 * ow;
813 to[i][1] = m5 * oy + m13 * ow;
814 to[i][2] = + oz ;
815 to[i][3] = ow;
816 }
817 }
818 to_vec->size = 4;
819 to_vec->flags |= VEC_SIZE_4;
820 to_vec->count = from_vec->count;
821 }
822
823 static void _XFORMAPI
824 TAG(transform_points4_3d)( GLvector4f *to_vec,
825 const GLfloat m[16],
826 const GLvector4f *from_vec,
827 const GLubyte *mask,
828 const GLubyte flag )
829 {
830 const GLuint stride = from_vec->stride;
831 GLfloat *from = from_vec->start;
832 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
833 GLuint count = from_vec->count;
834 const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
835 const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10];
836 const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
837 GLuint i;
838 (void) mask;
839 (void) flag;
840 STRIDE_LOOP {
841 CLIP_CHECK {
842 const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
843 to[i][0] = m0 * ox + m4 * oy + m8 * oz + m12 * ow;
844 to[i][1] = m1 * ox + m5 * oy + m9 * oz + m13 * ow;
845 to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 * ow;
846 to[i][3] = ow;
847 }
848 }
849 to_vec->size = 4;
850 to_vec->flags |= VEC_SIZE_4;
851 to_vec->count = from_vec->count;
852 }
853
854 static void _XFORMAPI
855 TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec,
856 const GLfloat m[16],
857 const GLvector4f *from_vec,
858 const GLubyte *mask,
859 const GLubyte flag )
860 {
861 const GLuint stride = from_vec->stride;
862 GLfloat *from = from_vec->start;
863 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
864 GLuint count = from_vec->count;
865 const GLfloat m0 = m[0], m5 = m[5];
866 const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14];
867 GLuint i;
868 (void) mask;
869 (void) flag;
870 STRIDE_LOOP {
871 CLIP_CHECK {
872 const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
873 to[i][0] = m0 * ox + m12 * ow;
874 to[i][1] = m5 * oy + m13 * ow;
875 to[i][2] = m10 * oz + m14 * ow;
876 to[i][3] = ow;
877 }
878 }
879 to_vec->size = 4;
880 to_vec->flags |= VEC_SIZE_4;
881 to_vec->count = from_vec->count;
882 }
883
884 static void _XFORMAPI
885 TAG(transform_points4_perspective)( GLvector4f *to_vec,
886 const GLfloat m[16],
887 const GLvector4f *from_vec,
888 const GLubyte *mask,
889 const GLubyte flag )
890 {
891 const GLuint stride = from_vec->stride;
892 GLfloat *from = from_vec->start;
893 GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
894 GLuint count = from_vec->count;
895 const GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9];
896 const GLfloat m10 = m[10], m14 = m[14];
897 GLuint i;
898 (void) mask;
899 (void) flag;
900 STRIDE_LOOP {
901 CLIP_CHECK {
902 const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
903 to[i][0] = m0 * ox + m8 * oz ;
904 to[i][1] = m5 * oy + m9 * oz ;
905 to[i][2] = m10 * oz + m14 * ow ;
906 to[i][3] = -oz ;
907 }
908 }
909
910 to_vec->size = 4;
911 to_vec->flags |= VEC_SIZE_4;
912 to_vec->count = from_vec->count;
913 }
914
915 static transform_func _XFORMAPI TAG(transform_tab_1)[7];
916 static transform_func _XFORMAPI TAG(transform_tab_2)[7];
917 static transform_func _XFORMAPI TAG(transform_tab_3)[7];
918 static transform_func _XFORMAPI TAG(transform_tab_4)[7];
919
920 /* Similar functions could be called several times, with more highly
921 * optimized routines overwriting the arrays. This only occurs during
922 * startup.
923 */
924 static void _XFORMAPI TAG(init_c_transformations)( void )
925 {
926 #define TAG_TAB gl_transform_tab[IDX]
927 #define TAG_TAB_1 TAG(transform_tab_1)
928 #define TAG_TAB_2 TAG(transform_tab_2)
929 #define TAG_TAB_3 TAG(transform_tab_3)
930 #define TAG_TAB_4 TAG(transform_tab_4)
931
932 TAG_TAB[1] = TAG_TAB_1;
933 TAG_TAB[2] = TAG_TAB_2;
934 TAG_TAB[3] = TAG_TAB_3;
935 TAG_TAB[4] = TAG_TAB_4;
936
937 /* 1-D points (ie texcoords) */
938 TAG_TAB_1[MATRIX_GENERAL] = TAG(transform_points1_general);
939 TAG_TAB_1[MATRIX_IDENTITY] = TAG(transform_points1_identity);
940 TAG_TAB_1[MATRIX_3D_NO_ROT] = TAG(transform_points1_3d_no_rot);
941 TAG_TAB_1[MATRIX_PERSPECTIVE] = TAG(transform_points1_perspective) ;
942 TAG_TAB_1[MATRIX_2D] = TAG(transform_points1_2d);
943 TAG_TAB_1[MATRIX_2D_NO_ROT] = TAG(transform_points1_2d_no_rot);
944 TAG_TAB_1[MATRIX_3D] = TAG(transform_points1_3d);
945
946 /* 2-D points */
947 TAG_TAB_2[MATRIX_GENERAL] = TAG(transform_points2_general);
948 TAG_TAB_2[MATRIX_IDENTITY] = TAG(transform_points2_identity);
949 TAG_TAB_2[MATRIX_3D_NO_ROT] = TAG(transform_points2_3d_no_rot);
950 TAG_TAB_2[MATRIX_PERSPECTIVE] = TAG(transform_points2_perspective) ;
951 TAG_TAB_2[MATRIX_2D] = TAG(transform_points2_2d);
952 TAG_TAB_2[MATRIX_2D_NO_ROT] = TAG(transform_points2_2d_no_rot);
953 TAG_TAB_2[MATRIX_3D] = TAG(transform_points2_3d);
954
955 /* 3-D points */
956 TAG_TAB_3[MATRIX_GENERAL] = TAG(transform_points3_general);
957 TAG_TAB_3[MATRIX_IDENTITY] = TAG(transform_points3_identity);
958 TAG_TAB_3[MATRIX_3D_NO_ROT] = TAG(transform_points3_3d_no_rot);
959 TAG_TAB_3[MATRIX_PERSPECTIVE] = TAG(transform_points3_perspective);
960 TAG_TAB_3[MATRIX_2D] = TAG(transform_points3_2d);
961 TAG_TAB_3[MATRIX_2D_NO_ROT] = TAG(transform_points3_2d_no_rot);
962 TAG_TAB_3[MATRIX_3D] = TAG(transform_points3_3d);
963
964 /* 4-D points */
965 TAG_TAB_4[MATRIX_GENERAL] = TAG(transform_points4_general);
966 TAG_TAB_4[MATRIX_IDENTITY] = TAG(transform_points4_identity);
967 TAG_TAB_4[MATRIX_3D_NO_ROT] = TAG(transform_points4_3d_no_rot);
968 TAG_TAB_4[MATRIX_PERSPECTIVE] = TAG(transform_points4_perspective);
969 TAG_TAB_4[MATRIX_2D] = TAG(transform_points4_2d);
970 TAG_TAB_4[MATRIX_2D_NO_ROT] = TAG(transform_points4_2d_no_rot);
971 TAG_TAB_4[MATRIX_3D] = TAG(transform_points4_3d);
972
973 #undef TAG_TAB
974 }