Removed all RCS / CVS tags (Id, Header, Date, etc.) from everything.
[mesa.git] / src / mesa / math / m_xform_tmp.h
1
2 /*
3 * Mesa 3-D graphics library
4 * Version: 3.5
5 *
6 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
7 *
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:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
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.
24 */
25
26 /*
27 * New (3.1) transformation code written by Keith Whitwell.
28 */
29
30
31 /*----------------------------------------------------------------------
32 * Begin Keith's new code
33 *
34 *----------------------------------------------------------------------
35 */
36
37 /* KW: Fixed stride, now measured in bytes as is the OpenGL array stride.
38 */
39
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
43 * unculled vertices.
44 */
45
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.
51 *
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.
55 */
56
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
60 * size.
61 */
62
63 /* KW: Now uses clipmask and a flag to allow us to skip both/either
64 * cliped and/or culled vertices.
65 */
66
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.
71 */
72
73 static void _XFORMAPI
74 TAG(transform_points1_general)( GLvector4f *to_vec,
75 const GLfloat m[16],
76 const GLvector4f *from_vec )
77 {
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];
86 GLuint i;
87 STRIDE_LOOP {
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 to_vec->size = 4;
95 to_vec->flags |= VEC_SIZE_4;
96 to_vec->count = from_vec->count;
97 }
98
99 static void _XFORMAPI
100 TAG(transform_points1_identity)( GLvector4f *to_vec,
101 const GLfloat m[16],
102 const GLvector4f *from_vec )
103 {
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;
108 GLuint i;
109 if (to_vec == from_vec) return;
110 STRIDE_LOOP {
111 to[i][0] = from[0];
112 }
113 to_vec->size = 1;
114 to_vec->flags |= VEC_SIZE_1;
115 to_vec->count = from_vec->count;
116 }
117
118 static void _XFORMAPI
119 TAG(transform_points1_2d)( GLvector4f *to_vec,
120 const GLfloat m[16],
121 const GLvector4f *from_vec )
122 {
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];
129 GLuint i;
130 STRIDE_LOOP {
131 const GLfloat ox = from[0];
132 to[i][0] = m0 * ox + m12;
133 to[i][1] = m1 * ox + m13;
134 }
135 to_vec->size = 2;
136 to_vec->flags |= VEC_SIZE_2;
137 to_vec->count = from_vec->count;
138 }
139
140 static void _XFORMAPI
141 TAG(transform_points1_2d_no_rot)( GLvector4f *to_vec,
142 const GLfloat m[16],
143 const GLvector4f *from_vec )
144 {
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];
150 GLuint i;
151 STRIDE_LOOP {
152 const GLfloat ox = from[0];
153 to[i][0] = m0 * ox + m12;
154 to[i][1] = m13;
155 }
156 to_vec->size = 2;
157 to_vec->flags |= VEC_SIZE_2;
158 to_vec->count = from_vec->count;
159 }
160
161 static void _XFORMAPI
162 TAG(transform_points1_3d)( GLvector4f *to_vec,
163 const GLfloat m[16],
164 const GLvector4f *from_vec )
165 {
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];
172 GLuint i;
173 STRIDE_LOOP {
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;
178 }
179 to_vec->size = 3;
180 to_vec->flags |= VEC_SIZE_3;
181 to_vec->count = from_vec->count;
182 }
183
184
185 static void _XFORMAPI
186 TAG(transform_points1_3d_no_rot)( GLvector4f *to_vec,
187 const GLfloat m[16],
188 const GLvector4f *from_vec )
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];
195 const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
196 GLuint i;
197 STRIDE_LOOP {
198 const GLfloat ox = from[0];
199 to[i][0] = m0 * ox + m12;
200 to[i][1] = m13;
201 to[i][2] = m14;
202 }
203 to_vec->size = 3;
204 to_vec->flags |= VEC_SIZE_3;
205 to_vec->count = from_vec->count;
206 }
207
208 static void _XFORMAPI
209 TAG(transform_points1_perspective)( GLvector4f *to_vec,
210 const GLfloat m[16],
211 const GLvector4f *from_vec )
212 {
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];
218 GLuint i;
219 STRIDE_LOOP {
220 const GLfloat ox = from[0];
221 to[i][0] = m0 * ox ;
222 to[i][1] = 0 ;
223 to[i][2] = m14;
224 to[i][3] = 0;
225 }
226 to_vec->size = 4;
227 to_vec->flags |= VEC_SIZE_4;
228 to_vec->count = from_vec->count;
229 }
230
231
232
233
234 /* 2-vectors, which are a lot more relevant than 1-vectors, are
235 * present early in the geometry pipeline and throughout the
236 * texture pipeline.
237 */
238 static void _XFORMAPI
239 TAG(transform_points2_general)( GLvector4f *to_vec,
240 const GLfloat m[16],
241 const GLvector4f *from_vec )
242 {
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];
251 GLuint i;
252 STRIDE_LOOP {
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;
258 }
259 to_vec->size = 4;
260 to_vec->flags |= VEC_SIZE_4;
261 to_vec->count = from_vec->count;
262 }
263
264 static void _XFORMAPI
265 TAG(transform_points2_identity)( GLvector4f *to_vec,
266 const GLfloat m[16],
267 const GLvector4f *from_vec )
268 {
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;
273 GLuint i;
274 if (to_vec == from_vec) return;
275 STRIDE_LOOP {
276 to[i][0] = from[0];
277 to[i][1] = from[1];
278 }
279 to_vec->size = 2;
280 to_vec->flags |= VEC_SIZE_2;
281 to_vec->count = from_vec->count;
282 }
283
284 static void _XFORMAPI
285 TAG(transform_points2_2d)( GLvector4f *to_vec,
286 const GLfloat m[16],
287 const GLvector4f *from_vec )
288 {
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];
295 GLuint i;
296 STRIDE_LOOP {
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;
300 }
301 to_vec->size = 2;
302 to_vec->flags |= VEC_SIZE_2;
303 to_vec->count = from_vec->count;
304 }
305
306 static void _XFORMAPI
307 TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec,
308 const GLfloat m[16],
309 const GLvector4f *from_vec )
310 {
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];
316 GLuint i;
317 STRIDE_LOOP {
318 const GLfloat ox = from[0], oy = from[1];
319 to[i][0] = m0 * ox + m12;
320 to[i][1] = m5 * oy + m13;
321 }
322 to_vec->size = 2;
323 to_vec->flags |= VEC_SIZE_2;
324 to_vec->count = from_vec->count;
325 }
326
327 static void _XFORMAPI
328 TAG(transform_points2_3d)( GLvector4f *to_vec,
329 const GLfloat m[16],
330 const GLvector4f *from_vec )
331 {
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];
338 GLuint i;
339 STRIDE_LOOP {
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;
344 }
345 to_vec->size = 3;
346 to_vec->flags |= VEC_SIZE_3;
347 to_vec->count = from_vec->count;
348 }
349
350
351 /* I would actually say this was a fairly important function, from
352 * a texture transformation point of view.
353 */
354 static void _XFORMAPI
355 TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec,
356 const GLfloat m[16],
357 const GLvector4f *from_vec )
358 {
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];
365 GLuint i;
366 STRIDE_LOOP {
367 const GLfloat ox = from[0], oy = from[1];
368 to[i][0] = m0 * ox + m12;
369 to[i][1] = m5 * oy + m13;
370 to[i][2] = m14;
371 }
372 if (m14 == 0) {
373 to_vec->size = 2;
374 to_vec->flags |= VEC_SIZE_2;
375 } else {
376 to_vec->size = 3;
377 to_vec->flags |= VEC_SIZE_3;
378 }
379 to_vec->count = from_vec->count;
380 }
381
382
383 static void _XFORMAPI
384 TAG(transform_points2_perspective)( GLvector4f *to_vec,
385 const GLfloat m[16],
386 const GLvector4f *from_vec )
387 {
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];
393 GLuint i;
394 STRIDE_LOOP {
395 const GLfloat ox = from[0], oy = from[1];
396 to[i][0] = m0 * ox ;
397 to[i][1] = m5 * oy ;
398 to[i][2] = m14;
399 to[i][3] = 0;
400 }
401 to_vec->size = 4;
402 to_vec->flags |= VEC_SIZE_4;
403 to_vec->count = from_vec->count;
404 }
405
406
407
408 static void _XFORMAPI
409 TAG(transform_points3_general)( GLvector4f *to_vec,
410 const GLfloat m[16],
411 const GLvector4f *from_vec )
412 {
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];
421 GLuint i;
422 STRIDE_LOOP {
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;
428 }
429 to_vec->size = 4;
430 to_vec->flags |= VEC_SIZE_4;
431 to_vec->count = from_vec->count;
432 }
433
434 static void _XFORMAPI
435 TAG(transform_points3_identity)( GLvector4f *to_vec,
436 const GLfloat m[16],
437 const GLvector4f *from_vec )
438 {
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;
443 GLuint i;
444 if (to_vec == from_vec) return;
445 STRIDE_LOOP {
446 to[i][0] = from[0];
447 to[i][1] = from[1];
448 to[i][2] = from[2];
449 }
450 to_vec->size = 3;
451 to_vec->flags |= VEC_SIZE_3;
452 to_vec->count = from_vec->count;
453 }
454
455 static void _XFORMAPI
456 TAG(transform_points3_2d)( GLvector4f *to_vec,
457 const GLfloat m[16],
458 const GLvector4f *from_vec )
459 {
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];
466 GLuint i;
467 STRIDE_LOOP {
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 ;
471 to[i][2] = + oz ;
472 }
473 to_vec->size = 3;
474 to_vec->flags |= VEC_SIZE_3;
475 to_vec->count = from_vec->count;
476 }
477
478 static void _XFORMAPI
479 TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec,
480 const GLfloat m[16],
481 const GLvector4f *from_vec )
482 {
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];
488 GLuint i;
489 STRIDE_LOOP {
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 ;
493 to[i][2] = + oz ;
494 }
495 to_vec->size = 3;
496 to_vec->flags |= VEC_SIZE_3;
497 to_vec->count = from_vec->count;
498 }
499
500 static void _XFORMAPI
501 TAG(transform_points3_3d)( GLvector4f *to_vec,
502 const GLfloat m[16],
503 const GLvector4f *from_vec )
504 {
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];
512 GLuint i;
513 STRIDE_LOOP {
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 ;
518 }
519 to_vec->size = 3;
520 to_vec->flags |= VEC_SIZE_3;
521 to_vec->count = from_vec->count;
522 }
523
524 /* previously known as ortho...
525 */
526 static void _XFORMAPI
527 TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec,
528 const GLfloat m[16],
529 const GLvector4f *from_vec )
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 const GLfloat m0 = m[0], m5 = m[5];
536 const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14];
537 GLuint i;
538 STRIDE_LOOP {
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 ;
543 }
544 to_vec->size = 3;
545 to_vec->flags |= VEC_SIZE_3;
546 to_vec->count = from_vec->count;
547 }
548
549 static void _XFORMAPI
550 TAG(transform_points3_perspective)( GLvector4f *to_vec,
551 const GLfloat m[16],
552 const GLvector4f *from_vec )
553 {
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];
560 GLuint i;
561 STRIDE_LOOP {
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 ;
566 to[i][3] = -oz ;
567 }
568 to_vec->size = 4;
569 to_vec->flags |= VEC_SIZE_4;
570 to_vec->count = from_vec->count;
571 }
572
573
574
575 static void _XFORMAPI
576 TAG(transform_points4_general)( GLvector4f *to_vec,
577 const GLfloat m[16],
578 const GLvector4f *from_vec )
579 {
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];
588 GLuint i;
589 STRIDE_LOOP {
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;
595 }
596 to_vec->size = 4;
597 to_vec->flags |= VEC_SIZE_4;
598 to_vec->count = from_vec->count;
599 }
600
601 static void _XFORMAPI
602 TAG(transform_points4_identity)( GLvector4f *to_vec,
603 const GLfloat m[16],
604 const GLvector4f *from_vec )
605 {
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;
610 GLuint i;
611 if (to_vec == from_vec) return;
612 STRIDE_LOOP {
613 to[i][0] = from[0];
614 to[i][1] = from[1];
615 to[i][2] = from[2];
616 to[i][3] = from[3];
617 }
618 to_vec->size = 4;
619 to_vec->flags |= VEC_SIZE_4;
620 to_vec->count = from_vec->count;
621 }
622
623 static void _XFORMAPI
624 TAG(transform_points4_2d)( GLvector4f *to_vec,
625 const GLfloat m[16],
626 const GLvector4f *from_vec )
627 {
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];
634 GLuint i;
635 STRIDE_LOOP {
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;
639 to[i][2] = + oz ;
640 to[i][3] = ow;
641 }
642 to_vec->size = 4;
643 to_vec->flags |= VEC_SIZE_4;
644 to_vec->count = from_vec->count;
645 }
646
647 static void _XFORMAPI
648 TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec,
649 const GLfloat m[16],
650 const GLvector4f *from_vec )
651 {
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];
657 GLuint i;
658 STRIDE_LOOP {
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;
662 to[i][2] = + oz ;
663 to[i][3] = ow;
664 }
665 to_vec->size = 4;
666 to_vec->flags |= VEC_SIZE_4;
667 to_vec->count = from_vec->count;
668 }
669
670 static void _XFORMAPI
671 TAG(transform_points4_3d)( GLvector4f *to_vec,
672 const GLfloat m[16],
673 const GLvector4f *from_vec )
674 {
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];
682 GLuint i;
683 STRIDE_LOOP {
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;
688 to[i][3] = ow;
689 }
690 to_vec->size = 4;
691 to_vec->flags |= VEC_SIZE_4;
692 to_vec->count = from_vec->count;
693 }
694
695 static void _XFORMAPI
696 TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec,
697 const GLfloat m[16],
698 const GLvector4f *from_vec )
699 {
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];
706 GLuint i;
707 STRIDE_LOOP {
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;
712 to[i][3] = ow;
713 }
714 to_vec->size = 4;
715 to_vec->flags |= VEC_SIZE_4;
716 to_vec->count = from_vec->count;
717 }
718
719 static void _XFORMAPI
720 TAG(transform_points4_perspective)( GLvector4f *to_vec,
721 const GLfloat m[16],
722 const GLvector4f *from_vec )
723 {
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];
730 GLuint i;
731 STRIDE_LOOP {
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 ;
736 to[i][3] = -oz ;
737 }
738 to_vec->size = 4;
739 to_vec->flags |= VEC_SIZE_4;
740 to_vec->count = from_vec->count;
741 }
742
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];
747
748 /* Similar functions could be called several times, with more highly
749 * optimized routines overwriting the arrays. This only occurs during
750 * startup.
751 */
752 static void _XFORMAPI TAG(init_c_transformations)( void )
753 {
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)
759
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;
764
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);
773
774 /* 2-D points */
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);
782
783 /* 3-D points */
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);
791
792 /* 4-D points */
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);
800
801 #undef TAG_TAB
802 #undef TAG_TAB_1
803 #undef TAG_TAB_2
804 #undef TAG_TAB_3
805 #undef TAG_TAB_4
806 }