1f984887d333de907e0a54ce15761645f9c67319
[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 * 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.
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 /* 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.
72 */
73
74 static void _XFORMAPI
75 TAG(transform_points1_general)( GLvector4f *to_vec,
76 const GLfloat m[16],
77 const GLvector4f *from_vec )
78 {
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];
87 GLuint i;
88 STRIDE_LOOP {
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;
94 }
95 to_vec->size = 4;
96 to_vec->flags |= VEC_SIZE_4;
97 to_vec->count = from_vec->count;
98 }
99
100 static void _XFORMAPI
101 TAG(transform_points1_identity)( GLvector4f *to_vec,
102 const GLfloat m[16],
103 const GLvector4f *from_vec )
104 {
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;
109 GLuint i;
110 (void) m;
111 if (to_vec == from_vec) return;
112 STRIDE_LOOP {
113 to[i][0] = from[0];
114 }
115 to_vec->size = 1;
116 to_vec->flags |= VEC_SIZE_1;
117 to_vec->count = from_vec->count;
118 }
119
120 static void _XFORMAPI
121 TAG(transform_points1_2d)( GLvector4f *to_vec,
122 const GLfloat m[16],
123 const GLvector4f *from_vec )
124 {
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];
131 GLuint i;
132 STRIDE_LOOP {
133 const GLfloat ox = from[0];
134 to[i][0] = m0 * ox + m12;
135 to[i][1] = m1 * ox + m13;
136 }
137 to_vec->size = 2;
138 to_vec->flags |= VEC_SIZE_2;
139 to_vec->count = from_vec->count;
140 }
141
142 static void _XFORMAPI
143 TAG(transform_points1_2d_no_rot)( GLvector4f *to_vec,
144 const GLfloat m[16],
145 const GLvector4f *from_vec )
146 {
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];
152 GLuint i;
153 STRIDE_LOOP {
154 const GLfloat ox = from[0];
155 to[i][0] = m0 * ox + m12;
156 to[i][1] = m13;
157 }
158 to_vec->size = 2;
159 to_vec->flags |= VEC_SIZE_2;
160 to_vec->count = from_vec->count;
161 }
162
163 static void _XFORMAPI
164 TAG(transform_points1_3d)( GLvector4f *to_vec,
165 const GLfloat m[16],
166 const GLvector4f *from_vec )
167 {
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];
174 GLuint i;
175 STRIDE_LOOP {
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;
180 }
181 to_vec->size = 3;
182 to_vec->flags |= VEC_SIZE_3;
183 to_vec->count = from_vec->count;
184 }
185
186
187 static void _XFORMAPI
188 TAG(transform_points1_3d_no_rot)( GLvector4f *to_vec,
189 const GLfloat m[16],
190 const GLvector4f *from_vec )
191 {
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];
198 GLuint i;
199 STRIDE_LOOP {
200 const GLfloat ox = from[0];
201 to[i][0] = m0 * ox + m12;
202 to[i][1] = m13;
203 to[i][2] = m14;
204 }
205 to_vec->size = 3;
206 to_vec->flags |= VEC_SIZE_3;
207 to_vec->count = from_vec->count;
208 }
209
210 static void _XFORMAPI
211 TAG(transform_points1_perspective)( GLvector4f *to_vec,
212 const GLfloat m[16],
213 const GLvector4f *from_vec )
214 {
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];
220 GLuint i;
221 STRIDE_LOOP {
222 const GLfloat ox = from[0];
223 to[i][0] = m0 * ox ;
224 to[i][1] = 0 ;
225 to[i][2] = m14;
226 to[i][3] = 0;
227 }
228 to_vec->size = 4;
229 to_vec->flags |= VEC_SIZE_4;
230 to_vec->count = from_vec->count;
231 }
232
233
234
235
236 /* 2-vectors, which are a lot more relevant than 1-vectors, are
237 * present early in the geometry pipeline and throughout the
238 * texture pipeline.
239 */
240 static void _XFORMAPI
241 TAG(transform_points2_general)( GLvector4f *to_vec,
242 const GLfloat m[16],
243 const GLvector4f *from_vec )
244 {
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];
253 GLuint i;
254 STRIDE_LOOP {
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;
260 }
261 to_vec->size = 4;
262 to_vec->flags |= VEC_SIZE_4;
263 to_vec->count = from_vec->count;
264 }
265
266 static void _XFORMAPI
267 TAG(transform_points2_identity)( GLvector4f *to_vec,
268 const GLfloat m[16],
269 const GLvector4f *from_vec )
270 {
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;
275 GLuint i;
276 (void) m;
277 if (to_vec == from_vec) return;
278 STRIDE_LOOP {
279 to[i][0] = from[0];
280 to[i][1] = from[1];
281 }
282 to_vec->size = 2;
283 to_vec->flags |= VEC_SIZE_2;
284 to_vec->count = from_vec->count;
285 }
286
287 static void _XFORMAPI
288 TAG(transform_points2_2d)( GLvector4f *to_vec,
289 const GLfloat m[16],
290 const GLvector4f *from_vec )
291 {
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];
298 GLuint i;
299 STRIDE_LOOP {
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;
303 }
304 to_vec->size = 2;
305 to_vec->flags |= VEC_SIZE_2;
306 to_vec->count = from_vec->count;
307 }
308
309 static void _XFORMAPI
310 TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec,
311 const GLfloat m[16],
312 const GLvector4f *from_vec )
313 {
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];
319 GLuint i;
320 STRIDE_LOOP {
321 const GLfloat ox = from[0], oy = from[1];
322 to[i][0] = m0 * ox + m12;
323 to[i][1] = m5 * oy + m13;
324 }
325 to_vec->size = 2;
326 to_vec->flags |= VEC_SIZE_2;
327 to_vec->count = from_vec->count;
328 }
329
330 static void _XFORMAPI
331 TAG(transform_points2_3d)( GLvector4f *to_vec,
332 const GLfloat m[16],
333 const GLvector4f *from_vec )
334 {
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];
341 GLuint i;
342 STRIDE_LOOP {
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;
347 }
348 to_vec->size = 3;
349 to_vec->flags |= VEC_SIZE_3;
350 to_vec->count = from_vec->count;
351 }
352
353
354 /* I would actually say this was a fairly important function, from
355 * a texture transformation point of view.
356 */
357 static void _XFORMAPI
358 TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec,
359 const GLfloat m[16],
360 const GLvector4f *from_vec )
361 {
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];
368 GLuint i;
369 STRIDE_LOOP {
370 const GLfloat ox = from[0], oy = from[1];
371 to[i][0] = m0 * ox + m12;
372 to[i][1] = m5 * oy + m13;
373 to[i][2] = m14;
374 }
375 if (m14 == 0) {
376 to_vec->size = 2;
377 to_vec->flags |= VEC_SIZE_2;
378 } else {
379 to_vec->size = 3;
380 to_vec->flags |= VEC_SIZE_3;
381 }
382 to_vec->count = from_vec->count;
383 }
384
385
386 static void _XFORMAPI
387 TAG(transform_points2_perspective)( GLvector4f *to_vec,
388 const GLfloat m[16],
389 const GLvector4f *from_vec )
390 {
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];
396 GLuint i;
397 STRIDE_LOOP {
398 const GLfloat ox = from[0], oy = from[1];
399 to[i][0] = m0 * ox ;
400 to[i][1] = m5 * oy ;
401 to[i][2] = m14;
402 to[i][3] = 0;
403 }
404 to_vec->size = 4;
405 to_vec->flags |= VEC_SIZE_4;
406 to_vec->count = from_vec->count;
407 }
408
409
410
411 static void _XFORMAPI
412 TAG(transform_points3_general)( GLvector4f *to_vec,
413 const GLfloat m[16],
414 const GLvector4f *from_vec )
415 {
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];
424 GLuint i;
425 STRIDE_LOOP {
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;
431 }
432 to_vec->size = 4;
433 to_vec->flags |= VEC_SIZE_4;
434 to_vec->count = from_vec->count;
435 }
436
437 static void _XFORMAPI
438 TAG(transform_points3_identity)( GLvector4f *to_vec,
439 const GLfloat m[16],
440 const GLvector4f *from_vec )
441 {
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;
446 GLuint i;
447 (void) m;
448 if (to_vec == from_vec) return;
449 STRIDE_LOOP {
450 to[i][0] = from[0];
451 to[i][1] = from[1];
452 to[i][2] = from[2];
453 }
454 to_vec->size = 3;
455 to_vec->flags |= VEC_SIZE_3;
456 to_vec->count = from_vec->count;
457 }
458
459 static void _XFORMAPI
460 TAG(transform_points3_2d)( GLvector4f *to_vec,
461 const GLfloat m[16],
462 const GLvector4f *from_vec )
463 {
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];
470 GLuint i;
471 STRIDE_LOOP {
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 ;
475 to[i][2] = + oz ;
476 }
477 to_vec->size = 3;
478 to_vec->flags |= VEC_SIZE_3;
479 to_vec->count = from_vec->count;
480 }
481
482 static void _XFORMAPI
483 TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec,
484 const GLfloat m[16],
485 const GLvector4f *from_vec )
486 {
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];
492 GLuint i;
493 STRIDE_LOOP {
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 ;
497 to[i][2] = + oz ;
498 }
499 to_vec->size = 3;
500 to_vec->flags |= VEC_SIZE_3;
501 to_vec->count = from_vec->count;
502 }
503
504 static void _XFORMAPI
505 TAG(transform_points3_3d)( GLvector4f *to_vec,
506 const GLfloat m[16],
507 const GLvector4f *from_vec )
508 {
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];
516 GLuint i;
517 STRIDE_LOOP {
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 ;
522 }
523 to_vec->size = 3;
524 to_vec->flags |= VEC_SIZE_3;
525 to_vec->count = from_vec->count;
526 }
527
528 /* previously known as ortho...
529 */
530 static void _XFORMAPI
531 TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec,
532 const GLfloat m[16],
533 const GLvector4f *from_vec )
534 {
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];
541 GLuint i;
542 STRIDE_LOOP {
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 ;
547 }
548 to_vec->size = 3;
549 to_vec->flags |= VEC_SIZE_3;
550 to_vec->count = from_vec->count;
551 }
552
553 static void _XFORMAPI
554 TAG(transform_points3_perspective)( GLvector4f *to_vec,
555 const GLfloat m[16],
556 const GLvector4f *from_vec )
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], m5 = m[5], m8 = m[8], m9 = m[9];
563 const GLfloat m10 = m[10], m14 = m[14];
564 GLuint i;
565 STRIDE_LOOP {
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 ;
570 to[i][3] = -oz ;
571 }
572 to_vec->size = 4;
573 to_vec->flags |= VEC_SIZE_4;
574 to_vec->count = from_vec->count;
575 }
576
577
578
579 static void _XFORMAPI
580 TAG(transform_points4_general)( GLvector4f *to_vec,
581 const GLfloat m[16],
582 const GLvector4f *from_vec )
583 {
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];
592 GLuint i;
593 STRIDE_LOOP {
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;
599 }
600 to_vec->size = 4;
601 to_vec->flags |= VEC_SIZE_4;
602 to_vec->count = from_vec->count;
603 }
604
605 static void _XFORMAPI
606 TAG(transform_points4_identity)( GLvector4f *to_vec,
607 const GLfloat m[16],
608 const GLvector4f *from_vec )
609 {
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;
614 GLuint i;
615 (void) m;
616 if (to_vec == from_vec) return;
617 STRIDE_LOOP {
618 to[i][0] = from[0];
619 to[i][1] = from[1];
620 to[i][2] = from[2];
621 to[i][3] = from[3];
622 }
623 to_vec->size = 4;
624 to_vec->flags |= VEC_SIZE_4;
625 to_vec->count = from_vec->count;
626 }
627
628 static void _XFORMAPI
629 TAG(transform_points4_2d)( GLvector4f *to_vec,
630 const GLfloat m[16],
631 const GLvector4f *from_vec )
632 {
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];
639 GLuint i;
640 STRIDE_LOOP {
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;
644 to[i][2] = + oz ;
645 to[i][3] = ow;
646 }
647 to_vec->size = 4;
648 to_vec->flags |= VEC_SIZE_4;
649 to_vec->count = from_vec->count;
650 }
651
652 static void _XFORMAPI
653 TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec,
654 const GLfloat m[16],
655 const GLvector4f *from_vec )
656 {
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];
662 GLuint i;
663 STRIDE_LOOP {
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;
667 to[i][2] = + oz ;
668 to[i][3] = ow;
669 }
670 to_vec->size = 4;
671 to_vec->flags |= VEC_SIZE_4;
672 to_vec->count = from_vec->count;
673 }
674
675 static void _XFORMAPI
676 TAG(transform_points4_3d)( GLvector4f *to_vec,
677 const GLfloat m[16],
678 const GLvector4f *from_vec )
679 {
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];
687 GLuint i;
688 STRIDE_LOOP {
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;
693 to[i][3] = ow;
694 }
695 to_vec->size = 4;
696 to_vec->flags |= VEC_SIZE_4;
697 to_vec->count = from_vec->count;
698 }
699
700 static void _XFORMAPI
701 TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec,
702 const GLfloat m[16],
703 const GLvector4f *from_vec )
704 {
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];
711 GLuint i;
712 STRIDE_LOOP {
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;
717 to[i][3] = ow;
718 }
719 to_vec->size = 4;
720 to_vec->flags |= VEC_SIZE_4;
721 to_vec->count = from_vec->count;
722 }
723
724 static void _XFORMAPI
725 TAG(transform_points4_perspective)( GLvector4f *to_vec,
726 const GLfloat m[16],
727 const GLvector4f *from_vec )
728 {
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];
735 GLuint i;
736 STRIDE_LOOP {
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 ;
741 to[i][3] = -oz ;
742 }
743 to_vec->size = 4;
744 to_vec->flags |= VEC_SIZE_4;
745 to_vec->count = from_vec->count;
746 }
747
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];
752
753 /* Similar functions could be called several times, with more highly
754 * optimized routines overwriting the arrays. This only occurs during
755 * startup.
756 */
757 static void _XFORMAPI TAG(init_c_transformations)( void )
758 {
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)
764
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;
769
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);
778
779 /* 2-D points */
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);
787
788 /* 3-D points */
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);
796
797 /* 4-D points */
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);
805
806 #undef TAG_TAB
807 #undef TAG_TAB_1
808 #undef TAG_TAB_2
809 #undef TAG_TAB_3
810 #undef TAG_TAB_4
811 }