Subversion Repositories Kolibri OS

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
5563 serge 1
 
2
 * Mesa 3-D graphics library
3
 *
4
 * Copyright (C) 1999-2001  Brian Paul   All Rights Reserved.
5
 *
6
 * Permission is hereby granted, free of charge, to any person obtaining a
7
 * copy of this software and associated documentation files (the "Software"),
8
 * to deal in the Software without restriction, including without limitation
9
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10
 * and/or sell copies of the Software, and to permit persons to whom the
11
 * Software is furnished to do so, subject to the following conditions:
12
 *
13
 * The above copyright notice and this permission notice shall be included
14
 * in all copies or substantial portions of the Software.
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17
 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
 * OTHER DEALINGS IN THE SOFTWARE.
23
 */
24
25
 
26
 * New (3.1) transformation code written by Keith Whitwell.
27
 */
28
29
 
30
 
31
 * Begin Keith's new code
32
 *
33
 *----------------------------------------------------------------------
34
 */
35
36
 
37
 */
38
39
 
40
 *     which transforms all incoming points, and a second which
41
 *     takes notice of a cullmask array, and only transforms
42
 *     unculled vertices.
43
 */
44
45
 
46
 *     interface.  These functions are here because I want consistant
47
 *     treatment of the vertex sizes and a lazy strategy for
48
 *     cleaning unused parts of the vector, and so as not to exclude
49
 *     them from the vertex array interface.
50
 *
51
 *     Under our current analysis of matrices, there is no way that
52
 *     the product of a matrix and a 1-vector can remain a 1-vector,
53
 *     with the exception of the identity transform.
54
 */
55
56
 
57
 *     vectors can get into the pipeline we cannot ever assume
58
 *     that there is more to a vector than indicated by its
59
 *     size.
60
 */
61
62
 
63
 *     cliped and/or culled vertices.
64
 */
65
66
 
67
 *     entire vector.  Clipping and culling are handled further down
68
 *     the pipe, most often during or after the conversion to some
69
 *     driver-specific vertex format.
70
 */
71
72
 
73
TAG(transform_points1_general)( GLvector4f *to_vec,
74
				const GLfloat m[16],
75
				const GLvector4f *from_vec )
76
{
77
   const GLuint stride = from_vec->stride;
78
   GLfloat *from = from_vec->start;
79
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
80
   GLuint count = from_vec->count;
81
   const GLfloat m0 = m[0],  m12 = m[12];
82
   const GLfloat m1 = m[1],  m13 = m[13];
83
   const GLfloat m2 = m[2],  m14 = m[14];
84
   const GLfloat m3 = m[3],  m15 = m[15];
85
   GLuint i;
86
   STRIDE_LOOP {
87
      const GLfloat ox = from[0];
88
      to[i][0] = m0 * ox + m12;
89
      to[i][1] = m1 * ox + m13;
90
      to[i][2] = m2 * ox + m14;
91
      to[i][3] = m3 * ox + m15;
92
   }
93
   to_vec->size = 4;
94
   to_vec->flags |= VEC_SIZE_4;
95
   to_vec->count = from_vec->count;
96
}
97
98
 
99
TAG(transform_points1_identity)( GLvector4f *to_vec,
100
				 const GLfloat m[16],
101
				 const GLvector4f *from_vec )
102
{
103
   const GLuint stride = from_vec->stride;
104
   GLfloat *from = from_vec->start;
105
   GLuint count = from_vec->count;
106
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
107
   GLuint i;
108
   (void) m;
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
 
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
 
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
 
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
 
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
 
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
 
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
 
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
   (void) m;
275
   if (to_vec == from_vec) return;
276
   STRIDE_LOOP {
277
      to[i][0] = from[0];
278
      to[i][1] = from[1];
279
   }
280
   to_vec->size = 2;
281
   to_vec->flags |= VEC_SIZE_2;
282
   to_vec->count = from_vec->count;
283
}
284
285
 
286
TAG(transform_points2_2d)( GLvector4f *to_vec,
287
			   const GLfloat m[16],
288
			   const GLvector4f *from_vec )
289
{
290
   const GLuint stride = from_vec->stride;
291
   GLfloat *from = from_vec->start;
292
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
293
   GLuint count = from_vec->count;
294
   const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
295
   const GLfloat m12 = m[12], m13 = m[13];
296
   GLuint i;
297
   STRIDE_LOOP {
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
   }
302
   to_vec->size = 2;
303
   to_vec->flags |= VEC_SIZE_2;
304
   to_vec->count = from_vec->count;
305
}
306
307
 
308
TAG(transform_points2_2d_no_rot)( GLvector4f *to_vec,
309
				  const GLfloat m[16],
310
				  const GLvector4f *from_vec )
311
{
312
   const GLuint stride = from_vec->stride;
313
   GLfloat *from = from_vec->start;
314
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
315
   GLuint count = from_vec->count;
316
   const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
317
   GLuint i;
318
   STRIDE_LOOP {
319
      const GLfloat ox = from[0], oy = from[1];
320
      to[i][0] = m0 * ox           + m12;
321
      to[i][1] =           m5 * oy + m13;
322
   }
323
   to_vec->size = 2;
324
   to_vec->flags |= VEC_SIZE_2;
325
   to_vec->count = from_vec->count;
326
}
327
328
 
329
TAG(transform_points2_3d)( GLvector4f *to_vec,
330
			   const GLfloat m[16],
331
			   const GLvector4f *from_vec )
332
{
333
   const GLuint stride = from_vec->stride;
334
   GLfloat *from = from_vec->start;
335
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
336
   GLuint count = from_vec->count;
337
   const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
338
   const GLfloat m6 = m[6], m12 = m[12], m13 = m[13], m14 = m[14];
339
   GLuint i;
340
   STRIDE_LOOP {
341
      const GLfloat ox = from[0], oy = from[1];
342
      to[i][0] = m0 * ox + m4 * oy + m12;
343
      to[i][1] = m1 * ox + m5 * oy + m13;
344
      to[i][2] = m2 * ox + m6 * oy + m14;
345
   }
346
   to_vec->size = 3;
347
   to_vec->flags |= VEC_SIZE_3;
348
   to_vec->count = from_vec->count;
349
}
350
351
 
352
 
353
 * a texture transformation point of view.
354
 */
355
static void _XFORMAPI
356
TAG(transform_points2_3d_no_rot)( GLvector4f *to_vec,
357
				  const GLfloat m[16],
358
				  const GLvector4f *from_vec )
359
{
360
   const GLuint stride = from_vec->stride;
361
   GLfloat *from = from_vec->start;
362
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
363
   GLuint count = from_vec->count;
364
   const GLfloat m0 = m[0], m5 = m[5];
365
   const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
366
   GLuint i;
367
   STRIDE_LOOP {
368
      const GLfloat ox = from[0], oy = from[1];
369
      to[i][0] = m0 * ox           + m12;
370
      to[i][1] =           m5 * oy + m13;
371
      to[i][2] =                     m14;
372
   }
373
   if (m14 == 0) {
374
      to_vec->size = 2;
375
      to_vec->flags |= VEC_SIZE_2;
376
   } else {
377
      to_vec->size = 3;
378
      to_vec->flags |= VEC_SIZE_3;
379
   }
380
   to_vec->count = from_vec->count;
381
}
382
383
 
384
 
385
TAG(transform_points2_perspective)( GLvector4f *to_vec,
386
				    const GLfloat m[16],
387
				    const GLvector4f *from_vec )
388
{
389
   const GLuint stride = from_vec->stride;
390
   GLfloat *from = from_vec->start;
391
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
392
   GLuint count = from_vec->count;
393
   const GLfloat m0 = m[0], m5 = m[5], m14 = m[14];
394
   GLuint i;
395
   STRIDE_LOOP {
396
      const GLfloat ox = from[0], oy = from[1];
397
      to[i][0] = m0 * ox                ;
398
      to[i][1] =           m5 * oy      ;
399
      to[i][2] =                     m14;
400
      to[i][3] = 0;
401
   }
402
   to_vec->size = 4;
403
   to_vec->flags |= VEC_SIZE_4;
404
   to_vec->count = from_vec->count;
405
}
406
407
 
408
 
409
 
410
TAG(transform_points3_general)( GLvector4f *to_vec,
411
				const GLfloat m[16],
412
				const GLvector4f *from_vec )
413
{
414
   const GLuint stride = from_vec->stride;
415
   GLfloat *from = from_vec->start;
416
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
417
   GLuint count = from_vec->count;
418
   const GLfloat m0 = m[0],  m4 = m[4],  m8 = m[8],  m12 = m[12];
419
   const GLfloat m1 = m[1],  m5 = m[5],  m9 = m[9],  m13 = m[13];
420
   const GLfloat m2 = m[2],  m6 = m[6],  m10 = m[10],  m14 = m[14];
421
   const GLfloat m3 = m[3],  m7 = m[7],  m11 = m[11],  m15 = m[15];
422
   GLuint i;
423
   STRIDE_LOOP {
424
      const GLfloat ox = from[0], oy = from[1], oz = from[2];
425
      to[i][0] = m0 * ox + m4 * oy + m8  * oz + m12;
426
      to[i][1] = m1 * ox + m5 * oy + m9  * oz + m13;
427
      to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14;
428
      to[i][3] = m3 * ox + m7 * oy + m11 * oz + m15;
429
   }
430
   to_vec->size = 4;
431
   to_vec->flags |= VEC_SIZE_4;
432
   to_vec->count = from_vec->count;
433
}
434
435
 
436
TAG(transform_points3_identity)( GLvector4f *to_vec,
437
				 const GLfloat m[16],
438
				 const GLvector4f *from_vec )
439
{
440
   const GLuint stride = from_vec->stride;
441
   GLfloat *from = from_vec->start;
442
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
443
   GLuint count = from_vec->count;
444
   GLuint i;
445
   (void) m;
446
   if (to_vec == from_vec) return;
447
   STRIDE_LOOP {
448
      to[i][0] = from[0];
449
      to[i][1] = from[1];
450
      to[i][2] = from[2];
451
   }
452
   to_vec->size = 3;
453
   to_vec->flags |= VEC_SIZE_3;
454
   to_vec->count = from_vec->count;
455
}
456
457
 
458
TAG(transform_points3_2d)( GLvector4f *to_vec,
459
			   const GLfloat m[16],
460
			   const GLvector4f *from_vec )
461
{
462
   const GLuint stride = from_vec->stride;
463
   GLfloat *from = from_vec->start;
464
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
465
   GLuint count = from_vec->count;
466
   const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
467
   const GLfloat m12 = m[12], m13 = m[13];
468
   GLuint i;
469
   STRIDE_LOOP {
470
      const GLfloat ox = from[0], oy = from[1], oz = from[2];
471
      to[i][0] = m0 * ox + m4 * oy            + m12       ;
472
      to[i][1] = m1 * ox + m5 * oy            + m13       ;
473
      to[i][2] =                   +       oz             ;
474
   }
475
   to_vec->size = 3;
476
   to_vec->flags |= VEC_SIZE_3;
477
   to_vec->count = from_vec->count;
478
}
479
480
 
481
TAG(transform_points3_2d_no_rot)( GLvector4f *to_vec,
482
				  const GLfloat m[16],
483
				  const GLvector4f *from_vec )
484
{
485
   const GLuint stride = from_vec->stride;
486
   GLfloat *from = from_vec->start;
487
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
488
   GLuint count = from_vec->count;
489
   const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
490
   GLuint i;
491
   STRIDE_LOOP {
492
      const GLfloat ox = from[0], oy = from[1], oz = from[2];
493
      to[i][0] = m0 * ox                      + m12       ;
494
      to[i][1] =           m5 * oy            + m13       ;
495
      to[i][2] =                   +       oz             ;
496
   }
497
   to_vec->size = 3;
498
   to_vec->flags |= VEC_SIZE_3;
499
   to_vec->count = from_vec->count;
500
}
501
502
 
503
TAG(transform_points3_3d)( GLvector4f *to_vec,
504
			   const GLfloat m[16],
505
			   const GLvector4f *from_vec )
506
{
507
   const GLuint stride = from_vec->stride;
508
   GLfloat *from = from_vec->start;
509
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
510
   GLuint count = from_vec->count;
511
   const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
512
   const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10];
513
   const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
514
   GLuint i;
515
   STRIDE_LOOP {
516
      const GLfloat ox = from[0], oy = from[1], oz = from[2];
517
      to[i][0] = m0 * ox + m4 * oy +  m8 * oz + m12       ;
518
      to[i][1] = m1 * ox + m5 * oy +  m9 * oz + m13       ;
519
      to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14       ;
520
   }
521
   to_vec->size = 3;
522
   to_vec->flags |= VEC_SIZE_3;
523
   to_vec->count = from_vec->count;
524
}
525
526
 
527
 */
528
static void _XFORMAPI
529
TAG(transform_points3_3d_no_rot)( GLvector4f *to_vec,
530
				  const GLfloat m[16],
531
				  const GLvector4f *from_vec )
532
{
533
   const GLuint stride = from_vec->stride;
534
   GLfloat *from = from_vec->start;
535
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
536
   GLuint count = from_vec->count;
537
   const GLfloat m0 = m[0], m5 = m[5];
538
   const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14];
539
   GLuint i;
540
   STRIDE_LOOP {
541
      const GLfloat ox = from[0], oy = from[1], oz = from[2];
542
      to[i][0] = m0 * ox                      + m12       ;
543
      to[i][1] =           m5 * oy            + m13       ;
544
      to[i][2] =                     m10 * oz + m14       ;
545
   }
546
   to_vec->size = 3;
547
   to_vec->flags |= VEC_SIZE_3;
548
   to_vec->count = from_vec->count;
549
}
550
551
 
552
TAG(transform_points3_perspective)( GLvector4f *to_vec,
553
				    const GLfloat m[16],
554
				    const GLvector4f *from_vec )
555
{
556
   const GLuint stride = from_vec->stride;
557
   GLfloat *from = from_vec->start;
558
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
559
   GLuint count = from_vec->count;
560
   const GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9];
561
   const GLfloat m10 = m[10], m14 = m[14];
562
   GLuint i;
563
   STRIDE_LOOP {
564
      const GLfloat ox = from[0], oy = from[1], oz = from[2];
565
      to[i][0] = m0 * ox           + m8  * oz       ;
566
      to[i][1] =           m5 * oy + m9  * oz       ;
567
      to[i][2] =                     m10 * oz + m14 ;
568
      to[i][3] =                          -oz       ;
569
   }
570
   to_vec->size = 4;
571
   to_vec->flags |= VEC_SIZE_4;
572
   to_vec->count = from_vec->count;
573
}
574
575
 
576
 
577
 
578
TAG(transform_points4_general)( GLvector4f *to_vec,
579
				const GLfloat m[16],
580
				const GLvector4f *from_vec )
581
{
582
   const GLuint stride = from_vec->stride;
583
   GLfloat *from = from_vec->start;
584
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
585
   GLuint count = from_vec->count;
586
   const GLfloat m0 = m[0],  m4 = m[4],  m8 = m[8],  m12 = m[12];
587
   const GLfloat m1 = m[1],  m5 = m[5],  m9 = m[9],  m13 = m[13];
588
   const GLfloat m2 = m[2],  m6 = m[6],  m10 = m[10],  m14 = m[14];
589
   const GLfloat m3 = m[3],  m7 = m[7],  m11 = m[11],  m15 = m[15];
590
   GLuint i;
591
   STRIDE_LOOP {
592
      const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
593
      to[i][0] = m0 * ox + m4 * oy + m8  * oz + m12 * ow;
594
      to[i][1] = m1 * ox + m5 * oy + m9  * oz + m13 * ow;
595
      to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 * ow;
596
      to[i][3] = m3 * ox + m7 * oy + m11 * oz + m15 * ow;
597
   }
598
   to_vec->size = 4;
599
   to_vec->flags |= VEC_SIZE_4;
600
   to_vec->count = from_vec->count;
601
}
602
603
 
604
TAG(transform_points4_identity)( GLvector4f *to_vec,
605
				 const GLfloat m[16],
606
				 const GLvector4f *from_vec )
607
{
608
   const GLuint stride = from_vec->stride;
609
   GLfloat *from = from_vec->start;
610
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
611
   GLuint count = from_vec->count;
612
   GLuint i;
613
   (void) m;
614
   if (to_vec == from_vec) return;
615
   STRIDE_LOOP {
616
      to[i][0] = from[0];
617
      to[i][1] = from[1];
618
      to[i][2] = from[2];
619
      to[i][3] = from[3];
620
   }
621
   to_vec->size = 4;
622
   to_vec->flags |= VEC_SIZE_4;
623
   to_vec->count = from_vec->count;
624
}
625
626
 
627
TAG(transform_points4_2d)( GLvector4f *to_vec,
628
			   const GLfloat m[16],
629
			   const GLvector4f *from_vec )
630
{
631
   const GLuint stride = from_vec->stride;
632
   GLfloat *from = from_vec->start;
633
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
634
   GLuint count = from_vec->count;
635
   const GLfloat m0 = m[0], m1 = m[1], m4 = m[4], m5 = m[5];
636
   const GLfloat m12 = m[12], m13 = m[13];
637
   GLuint i;
638
   STRIDE_LOOP {
639
      const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
640
      to[i][0] = m0 * ox + m4 * oy            + m12 * ow;
641
      to[i][1] = m1 * ox + m5 * oy            + m13 * ow;
642
      to[i][2] =                   +       oz           ;
643
      to[i][3] =                                      ow;
644
   }
645
   to_vec->size = 4;
646
   to_vec->flags |= VEC_SIZE_4;
647
   to_vec->count = from_vec->count;
648
}
649
650
 
651
TAG(transform_points4_2d_no_rot)( GLvector4f *to_vec,
652
				  const GLfloat m[16],
653
				  const GLvector4f *from_vec )
654
{
655
   const GLuint stride = from_vec->stride;
656
   GLfloat *from = from_vec->start;
657
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
658
   GLuint count = from_vec->count;
659
   const GLfloat m0 = m[0], m5 = m[5], m12 = m[12], m13 = m[13];
660
   GLuint i;
661
   STRIDE_LOOP {
662
      const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
663
      to[i][0] = m0 * ox                      + m12 * ow;
664
      to[i][1] =           m5 * oy            + m13 * ow;
665
      to[i][2] =                   +       oz           ;
666
      to[i][3] =                                      ow;
667
   }
668
   to_vec->size = 4;
669
   to_vec->flags |= VEC_SIZE_4;
670
   to_vec->count = from_vec->count;
671
}
672
673
 
674
TAG(transform_points4_3d)( GLvector4f *to_vec,
675
			   const GLfloat m[16],
676
			   const GLvector4f *from_vec )
677
{
678
   const GLuint stride = from_vec->stride;
679
   GLfloat *from = from_vec->start;
680
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
681
   GLuint count = from_vec->count;
682
   const GLfloat m0 = m[0], m1 = m[1], m2 = m[2], m4 = m[4], m5 = m[5];
683
   const GLfloat m6 = m[6], m8 = m[8], m9 = m[9], m10 = m[10];
684
   const GLfloat m12 = m[12], m13 = m[13], m14 = m[14];
685
   GLuint i;
686
   STRIDE_LOOP {
687
      const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
688
      to[i][0] = m0 * ox + m4 * oy +  m8 * oz + m12 * ow;
689
      to[i][1] = m1 * ox + m5 * oy +  m9 * oz + m13 * ow;
690
      to[i][2] = m2 * ox + m6 * oy + m10 * oz + m14 * ow;
691
      to[i][3] =                                      ow;
692
   }
693
   to_vec->size = 4;
694
   to_vec->flags |= VEC_SIZE_4;
695
   to_vec->count = from_vec->count;
696
}
697
698
 
699
TAG(transform_points4_3d_no_rot)( GLvector4f *to_vec,
700
				  const GLfloat m[16],
701
				  const GLvector4f *from_vec )
702
{
703
   const GLuint stride = from_vec->stride;
704
   GLfloat *from = from_vec->start;
705
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
706
   GLuint count = from_vec->count;
707
   const GLfloat m0 = m[0], m5 = m[5];
708
   const GLfloat m10 = m[10], m12 = m[12], m13 = m[13], m14 = m[14];
709
   GLuint i;
710
   STRIDE_LOOP {
711
      const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
712
      to[i][0] = m0 * ox                      + m12 * ow;
713
      to[i][1] =           m5 * oy            + m13 * ow;
714
      to[i][2] =                     m10 * oz + m14 * ow;
715
      to[i][3] =                                      ow;
716
   }
717
   to_vec->size = 4;
718
   to_vec->flags |= VEC_SIZE_4;
719
   to_vec->count = from_vec->count;
720
}
721
722
 
723
TAG(transform_points4_perspective)( GLvector4f *to_vec,
724
				    const GLfloat m[16],
725
				    const GLvector4f *from_vec )
726
{
727
   const GLuint stride = from_vec->stride;
728
   GLfloat *from = from_vec->start;
729
   GLfloat (*to)[4] = (GLfloat (*)[4])to_vec->start;
730
   GLuint count = from_vec->count;
731
   const GLfloat m0 = m[0], m5 = m[5], m8 = m[8], m9 = m[9];
732
   const GLfloat m10 = m[10], m14 = m[14];
733
   GLuint i;
734
   STRIDE_LOOP {
735
      const GLfloat ox = from[0], oy = from[1], oz = from[2], ow = from[3];
736
      to[i][0] = m0 * ox           + m8  * oz            ;
737
      to[i][1] =           m5 * oy + m9  * oz            ;
738
      to[i][2] =                     m10 * oz + m14 * ow ;
739
      to[i][3] =                          -oz            ;
740
   }
741
   to_vec->size = 4;
742
   to_vec->flags |= VEC_SIZE_4;
743
   to_vec->count = from_vec->count;
744
}
745
746
 
747
static transform_func TAG(transform_tab_2)[7];
748
static transform_func TAG(transform_tab_3)[7];
749
static transform_func TAG(transform_tab_4)[7];
750
751
 
752
 * optimized routines overwriting the arrays.  This only occurs during
753
 * startup.
754
 */
755
static void _XFORMAPI TAG(init_c_transformations)( void )
756
{
757
#define TAG_TAB   _mesa_transform_tab
758
#define TAG_TAB_1 TAG(transform_tab_1)
759
#define TAG_TAB_2 TAG(transform_tab_2)
760
#define TAG_TAB_3 TAG(transform_tab_3)
761
#define TAG_TAB_4 TAG(transform_tab_4)
762
763
 
764
   TAG_TAB[2] = TAG_TAB_2;
765
   TAG_TAB[3] = TAG_TAB_3;
766
   TAG_TAB[4] = TAG_TAB_4;
767
768
 
769
   TAG_TAB_1[MATRIX_GENERAL]     = TAG(transform_points1_general);
770
   TAG_TAB_1[MATRIX_IDENTITY]    = TAG(transform_points1_identity);
771
   TAG_TAB_1[MATRIX_3D_NO_ROT]   = TAG(transform_points1_3d_no_rot);
772
   TAG_TAB_1[MATRIX_PERSPECTIVE] = TAG(transform_points1_perspective);
773
   TAG_TAB_1[MATRIX_2D]          = TAG(transform_points1_2d);
774
   TAG_TAB_1[MATRIX_2D_NO_ROT]   = TAG(transform_points1_2d_no_rot);
775
   TAG_TAB_1[MATRIX_3D]          = TAG(transform_points1_3d);
776
777
 
778
   TAG_TAB_2[MATRIX_GENERAL]     = TAG(transform_points2_general);
779
   TAG_TAB_2[MATRIX_IDENTITY]    = TAG(transform_points2_identity);
780
   TAG_TAB_2[MATRIX_3D_NO_ROT]   = TAG(transform_points2_3d_no_rot);
781
   TAG_TAB_2[MATRIX_PERSPECTIVE] = TAG(transform_points2_perspective);
782
   TAG_TAB_2[MATRIX_2D]          = TAG(transform_points2_2d);
783
   TAG_TAB_2[MATRIX_2D_NO_ROT]   = TAG(transform_points2_2d_no_rot);
784
   TAG_TAB_2[MATRIX_3D]          = TAG(transform_points2_3d);
785
786
 
787
   TAG_TAB_3[MATRIX_GENERAL]     = TAG(transform_points3_general);
788
   TAG_TAB_3[MATRIX_IDENTITY]    = TAG(transform_points3_identity);
789
   TAG_TAB_3[MATRIX_3D_NO_ROT]   = TAG(transform_points3_3d_no_rot);
790
   TAG_TAB_3[MATRIX_PERSPECTIVE] = TAG(transform_points3_perspective);
791
   TAG_TAB_3[MATRIX_2D]          = TAG(transform_points3_2d);
792
   TAG_TAB_3[MATRIX_2D_NO_ROT]   = TAG(transform_points3_2d_no_rot);
793
   TAG_TAB_3[MATRIX_3D]          = TAG(transform_points3_3d);
794
795
 
796
   TAG_TAB_4[MATRIX_GENERAL]     = TAG(transform_points4_general);
797
   TAG_TAB_4[MATRIX_IDENTITY]    = TAG(transform_points4_identity);
798
   TAG_TAB_4[MATRIX_3D_NO_ROT]   = TAG(transform_points4_3d_no_rot);
799
   TAG_TAB_4[MATRIX_PERSPECTIVE] = TAG(transform_points4_perspective);
800
   TAG_TAB_4[MATRIX_2D]          = TAG(transform_points4_2d);
801
   TAG_TAB_4[MATRIX_2D_NO_ROT]   = TAG(transform_points4_2d_no_rot);
802
   TAG_TAB_4[MATRIX_3D]          = TAG(transform_points4_3d);
803
804
 
805
#undef TAG_TAB_1
806
#undef TAG_TAB_2
807
#undef TAG_TAB_3
808
#undef TAG_TAB_4
809
}
810