Major rework of tnl module
[mesa.git] / src / mesa / tnl / t_imm_elt.c
1 /* $Id: t_imm_elt.c,v 1.1 2000/12/26 05:09:32 keithw Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.5
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 * Author:
27 * Keith Whitwell <keithw@valinux.com>
28 */
29
30 #include "glheader.h"
31 #include "colormac.h"
32 #include "mem.h"
33 #include "mmath.h"
34 #include "mtypes.h"
35
36 #include "math/m_translate.h"
37
38 #include "t_context.h"
39 #include "t_imm_elt.h"
40
41
42
43 typedef void (*trans_elt_1f_func)(GLfloat *to,
44 CONST void *ptr,
45 GLuint stride,
46 GLuint *flags,
47 GLuint *elts,
48 GLuint match,
49 GLuint start,
50 GLuint n );
51
52 typedef void (*trans_elt_1ui_func)(GLuint *to,
53 CONST void *ptr,
54 GLuint stride,
55 GLuint *flags,
56 GLuint *elts,
57 GLuint match,
58 GLuint start,
59 GLuint n );
60
61 typedef void (*trans_elt_1ub_func)(GLubyte *to,
62 CONST void *ptr,
63 GLuint stride,
64 GLuint *flags,
65 GLuint *elts,
66 GLuint match,
67 GLuint start,
68 GLuint n );
69
70 typedef void (*trans_elt_4ub_func)(GLubyte (*to)[4],
71 CONST void *ptr,
72 GLuint stride,
73 GLuint *flags,
74 GLuint *elts,
75 GLuint match,
76 GLuint start,
77 GLuint n );
78
79 typedef void (*trans_elt_4f_func)(GLfloat (*to)[4],
80 CONST void *ptr,
81 GLuint stride,
82 GLuint *flags,
83 GLuint *elts,
84 GLuint match,
85 GLuint start,
86 GLuint n );
87
88 typedef void (*trans_elt_3f_func)(GLfloat (*to)[3],
89 CONST void *ptr,
90 GLuint stride,
91 GLuint *flags,
92 GLuint *elts,
93 GLuint match,
94 GLuint start,
95 GLuint n );
96
97
98
99
100 static trans_elt_1f_func _tnl_trans_elt_1f_tab[MAX_TYPES];
101 static trans_elt_1ui_func _tnl_trans_elt_1ui_tab[MAX_TYPES];
102 static trans_elt_1ub_func _tnl_trans_elt_1ub_tab[MAX_TYPES];
103 static trans_elt_3f_func _tnl_trans_elt_3f_tab[MAX_TYPES];
104 static trans_elt_4ub_func _tnl_trans_elt_4ub_tab[5][MAX_TYPES];
105 static trans_elt_4f_func _tnl_trans_elt_4f_tab[5][MAX_TYPES];
106
107
108 #define PTR_ELT(ptr, elt) (((SRC *)ptr)[elt])
109
110
111
112
113
114 /* Code specific to array element implementation. There is a small
115 * subtlety in the bits CHECK() tests, and the way bits are set in
116 * glArrayElement which ensures that if, eg, in the case that the
117 * vertex array is disabled and normal array is enabled, and we get
118 * either sequence:
119 *
120 * ArrayElement() OR Normal()
121 * Normal() ArrayElement()
122 * Vertex() Vertex()
123 *
124 * That the correct value for normal is used.
125 */
126 #define TAB(x) _tnl_trans_elt##x##_tab
127 #define ARGS GLuint *flags, GLuint *elts, GLuint match, \
128 GLuint start, GLuint n
129 #define SRC_START 0
130 #define DST_START start
131 #undef CHECK
132 #define CHECK if ((flags[i]&match) == VERT_ELT)
133 #define NEXT_F (void)1
134 #define NEXT_F2 f = first + elts[i] * stride;
135
136
137 /* GL_BYTE
138 */
139 #define SRC GLbyte
140 #define SRC_IDX TYPE_IDX(GL_BYTE)
141 #define TRX_3F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
142 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
143 #define TRX_UB(ub, f,n) ub = BYTE_TO_UBYTE( PTR_ELT(f,n) )
144 #define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
145
146
147 #define SZ 4
148 #define INIT init_trans_4_GLbyte_elt
149 #define DEST_4F trans_4_GLbyte_4f_elt
150 #define DEST_4UB trans_4_GLbyte_4ub_elt
151 #include "math/m_trans_tmp.h"
152
153 #define SZ 3
154 #define INIT init_trans_3_GLbyte_elt
155 #define DEST_4F trans_3_GLbyte_4f_elt
156 #define DEST_4UB trans_3_GLbyte_4ub_elt
157 #define DEST_3F trans_3_GLbyte_3f_elt
158 #include "math/m_trans_tmp.h"
159
160 #define SZ 2
161 #define INIT init_trans_2_GLbyte_elt
162 #define DEST_4F trans_2_GLbyte_4f_elt
163 #include "math/m_trans_tmp.h"
164
165 #define SZ 1
166 #define INIT init_trans_1_GLbyte_elt
167 #define DEST_4F trans_1_GLbyte_4f_elt
168 #define DEST_1UB trans_1_GLbyte_1ub_elt
169 #define DEST_1UI trans_1_GLbyte_1ui_elt
170 #include "math/m_trans_tmp.h"
171
172 #undef SRC
173 #undef TRX_3F
174 #undef TRX_4F
175 #undef TRX_UB
176 #undef TRX_UI
177 #undef SRC_IDX
178
179 /* GL_UNSIGNED_BYTE
180 */
181 #define SRC GLubyte
182 #define SRC_IDX TYPE_IDX(GL_UNSIGNED_BYTE)
183 #define TRX_3F(f,n) /* unused */
184 #define TRX_4F(f,n) /* unused */
185 #define TRX_UB(ub, f,n) ub = PTR_ELT(f,n)
186 #define TRX_UI(f,n) (GLuint)PTR_ELT(f,n)
187
188 /* 4ub->4ub handled in special case below.
189 */
190
191 #define SZ 3
192 #define INIT init_trans_3_GLubyte_elt
193 #define DEST_4UB trans_3_GLubyte_4ub_elt
194 #include "math/m_trans_tmp.h"
195
196
197 #define SZ 1
198 #define INIT init_trans_1_GLubyte_elt
199 #define DEST_1UI trans_1_GLubyte_1ui_elt
200 #define DEST_1UB trans_1_GLubyte_1ub_elt
201 #include "math/m_trans_tmp.h"
202
203 #undef SRC
204 #undef SRC_IDX
205 #undef TRX_3F
206 #undef TRX_4F
207 #undef TRX_UB
208 #undef TRX_UI
209
210
211 /* GL_SHORT
212 */
213 #define SRC GLshort
214 #define SRC_IDX TYPE_IDX(GL_SHORT)
215 #define TRX_3F(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) )
216 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
217 #define TRX_UB(ub, f,n) ub = SHORT_TO_UBYTE(PTR_ELT(f,n))
218 #define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
219
220
221 #define SZ 4
222 #define INIT init_trans_4_GLshort_elt
223 #define DEST_4F trans_4_GLshort_4f_elt
224 #define DEST_4UB trans_4_GLshort_4ub_elt
225 #include "math/m_trans_tmp.h"
226
227 #define SZ 3
228 #define INIT init_trans_3_GLshort_elt
229 #define DEST_4F trans_3_GLshort_4f_elt
230 #define DEST_4UB trans_3_GLshort_4ub_elt
231 #define DEST_3F trans_3_GLshort_3f_elt
232 #include "math/m_trans_tmp.h"
233
234 #define SZ 2
235 #define INIT init_trans_2_GLshort_elt
236 #define DEST_4F trans_2_GLshort_4f_elt
237 #include "math/m_trans_tmp.h"
238
239 #define SZ 1
240 #define INIT init_trans_1_GLshort_elt
241 #define DEST_4F trans_1_GLshort_4f_elt
242 #define DEST_1UB trans_1_GLshort_1ub_elt
243 #define DEST_1UI trans_1_GLshort_1ui_elt
244 #include "math/m_trans_tmp.h"
245
246
247 #undef SRC
248 #undef SRC_IDX
249 #undef TRX_3F
250 #undef TRX_4F
251 #undef TRX_UB
252 #undef TRX_UI
253
254
255 /* GL_UNSIGNED_SHORT
256 */
257 #define SRC GLushort
258 #define SRC_IDX TYPE_IDX(GL_UNSIGNED_SHORT)
259 #define TRX_3F(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) )
260 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
261 #define TRX_UB(ub,f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 8)
262 #define TRX_UI(f,n) (GLuint) PTR_ELT(f,n)
263
264
265 #define SZ 4
266 #define INIT init_trans_4_GLushort_elt
267 #define DEST_4F trans_4_GLushort_4f_elt
268 #define DEST_4UB trans_4_GLushort_4ub_elt
269 #include "math/m_trans_tmp.h"
270
271 #define SZ 3
272 #define INIT init_trans_3_GLushort_elt
273 #define DEST_4F trans_3_GLushort_4f_elt
274 #define DEST_4UB trans_3_GLushort_4ub_elt
275 #define DEST_3F trans_3_GLushort_3f_elt
276 #include "math/m_trans_tmp.h"
277
278 #define SZ 2
279 #define INIT init_trans_2_GLushort_elt
280 #define DEST_4F trans_2_GLushort_4f_elt
281 #include "math/m_trans_tmp.h"
282
283 #define SZ 1
284 #define INIT init_trans_1_GLushort_elt
285 #define DEST_4F trans_1_GLushort_4f_elt
286 #define DEST_1UB trans_1_GLushort_1ub_elt
287 #define DEST_1UI trans_1_GLushort_1ui_elt
288 #include "math/m_trans_tmp.h"
289
290 #undef SRC
291 #undef SRC_IDX
292 #undef TRX_3F
293 #undef TRX_4F
294 #undef TRX_UB
295 #undef TRX_UI
296
297
298 /* GL_INT
299 */
300 #define SRC GLint
301 #define SRC_IDX TYPE_IDX(GL_INT)
302 #define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
303 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
304 #define TRX_UB(ub, f,n) ub = INT_TO_UBYTE(PTR_ELT(f,n))
305 #define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
306
307
308 #define SZ 4
309 #define INIT init_trans_4_GLint_elt
310 #define DEST_4F trans_4_GLint_4f_elt
311 #define DEST_4UB trans_4_GLint_4ub_elt
312 #include "math/m_trans_tmp.h"
313
314 #define SZ 3
315 #define INIT init_trans_3_GLint_elt
316 #define DEST_4F trans_3_GLint_4f_elt
317 #define DEST_4UB trans_3_GLint_4ub_elt
318 #define DEST_3F trans_3_GLint_3f_elt
319 #include "math/m_trans_tmp.h"
320
321 #define SZ 2
322 #define INIT init_trans_2_GLint_elt
323 #define DEST_4F trans_2_GLint_4f_elt
324 #include "math/m_trans_tmp.h"
325
326 #define SZ 1
327 #define INIT init_trans_1_GLint_elt
328 #define DEST_4F trans_1_GLint_4f_elt
329 #define DEST_1UB trans_1_GLint_1ub_elt
330 #define DEST_1UI trans_1_GLint_1ui_elt
331 #include "math/m_trans_tmp.h"
332
333
334 #undef SRC
335 #undef SRC_IDX
336 #undef TRX_3F
337 #undef TRX_4F
338 #undef TRX_UB
339 #undef TRX_UI
340
341
342 /* GL_UNSIGNED_INT
343 */
344 #define SRC GLuint
345 #define SRC_IDX TYPE_IDX(GL_UNSIGNED_INT)
346 #define TRX_3F(f,n) UINT_TO_FLOAT( PTR_ELT(f,n) )
347 #define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
348 #define TRX_UB(ub, f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 24)
349 #define TRX_UI(f,n) PTR_ELT(f,n)
350
351
352 #define SZ 4
353 #define INIT init_trans_4_GLuint_elt
354 #define DEST_4F trans_4_GLuint_4f_elt
355 #define DEST_4UB trans_4_GLuint_4ub_elt
356 #include "math/m_trans_tmp.h"
357
358 #define SZ 3
359 #define INIT init_trans_3_GLuint_elt
360 #define DEST_4F trans_3_GLuint_4f_elt
361 #define DEST_4UB trans_3_GLuint_4ub_elt
362 #define DEST_3F trans_3_GLuint_3f_elt
363 #include "math/m_trans_tmp.h"
364
365 #define SZ 2
366 #define INIT init_trans_2_GLuint_elt
367 #define DEST_4F trans_2_GLuint_4f_elt
368 #include "math/m_trans_tmp.h"
369
370 #define SZ 1
371 #define INIT init_trans_1_GLuint_elt
372 #define DEST_4F trans_1_GLuint_4f_elt
373 #define DEST_1UB trans_1_GLuint_1ub_elt
374 #define DEST_1UI trans_1_GLuint_1ui_elt
375 #include "math/m_trans_tmp.h"
376
377 #undef SRC
378 #undef SRC_IDX
379 #undef TRX_3F
380 #undef TRX_4F
381 #undef TRX_UB
382 #undef TRX_UI
383
384
385 /* GL_DOUBLE
386 */
387 #define SRC GLdouble
388 #define SRC_IDX TYPE_IDX(GL_DOUBLE)
389 #define TRX_3F(f,n) PTR_ELT(f,n)
390 #define TRX_4F(f,n) PTR_ELT(f,n)
391 #define TRX_UB(ub,f,n) FLOAT_COLOR_TO_CHAN(ub, PTR_ELT(f,n))
392 #define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n)
393 #define TRX_1F(f,n) PTR_ELT(f,n)
394
395
396 #define SZ 4
397 #define INIT init_trans_4_GLdouble_elt
398 #define DEST_4F trans_4_GLdouble_4f_elt
399 #define DEST_4UB trans_4_GLdouble_4ub_elt
400 #include "math/m_trans_tmp.h"
401
402 #define SZ 3
403 #define INIT init_trans_3_GLdouble_elt
404 #define DEST_4F trans_3_GLdouble_4f_elt
405 #define DEST_4UB trans_3_GLdouble_4ub_elt
406 #define DEST_3F trans_3_GLdouble_3f_elt
407 #include "math/m_trans_tmp.h"
408
409 #define SZ 2
410 #define INIT init_trans_2_GLdouble_elt
411 #define DEST_4F trans_2_GLdouble_4f_elt
412 #include "math/m_trans_tmp.h"
413
414 #define SZ 1
415 #define INIT init_trans_1_GLdouble_elt
416 #define DEST_4F trans_1_GLdouble_4f_elt
417 #define DEST_1UB trans_1_GLdouble_1ub_elt
418 #define DEST_1UI trans_1_GLdouble_1ui_elt
419 #define DEST_1F trans_1_GLdouble_1f_elt
420 #include "math/m_trans_tmp.h"
421
422 #undef SRC
423 #undef SRC_IDX
424
425 /* GL_FLOAT
426 */
427 #define SRC GLfloat
428 #define SRC_IDX TYPE_IDX(GL_FLOAT)
429 #define SZ 4
430 #define INIT init_trans_4_GLfloat_elt
431 #define DEST_4UB trans_4_GLfloat_4ub_elt
432 #define DEST_4F trans_4_GLfloat_4f_elt
433 #include "math/m_trans_tmp.h"
434
435 #define SZ 3
436 #define INIT init_trans_3_GLfloat_elt
437 #define DEST_4F trans_3_GLfloat_4f_elt
438 #define DEST_4UB trans_3_GLfloat_4ub_elt
439 #define DEST_3F trans_3_GLfloat_3f_elt
440 #include "math/m_trans_tmp.h"
441
442 #define SZ 2
443 #define INIT init_trans_2_GLfloat_elt
444 #define DEST_4F trans_2_GLfloat_4f_elt
445 #include "math/m_trans_tmp.h"
446
447 #define SZ 1
448 #define INIT init_trans_1_GLfloat_elt
449 #define DEST_4F trans_1_GLfloat_3f_elt
450 #define DEST_1UB trans_1_GLfloat_1ub_elt
451 #define DEST_1UI trans_1_GLfloat_1ui_elt
452 #define DEST_1F trans_1_GLfloat_1f_elt
453 #include "math/m_trans_tmp.h"
454
455 #undef SRC
456 #undef SRC_IDX
457 #undef TRX_3F
458 #undef TRX_4F
459 #undef TRX_UB
460 #undef TRX_UI
461
462
463 static void trans_4_GLubyte_4ub(GLubyte (*t)[4],
464 CONST void *Ptr,
465 GLuint stride,
466 ARGS )
467 {
468 const GLubyte *f = (GLubyte *) Ptr + SRC_START * stride;
469 const GLubyte *first = f;
470 GLuint i;
471 (void) start;
472 if (((((long) f | (long) stride)) & 3L) == 0L) {
473 /* Aligned.
474 */
475 for (i = DST_START ; i < n ; i++, NEXT_F) {
476 CHECK {
477 NEXT_F2;
478 COPY_4UBV( t[i], f );
479 }
480 }
481 } else {
482 for (i = DST_START ; i < n ; i++, NEXT_F) {
483 CHECK {
484 NEXT_F2;
485 t[i][0] = f[0];
486 t[i][1] = f[1];
487 t[i][2] = f[2];
488 t[i][3] = f[3];
489 }
490 }
491 }
492 }
493
494
495 static void init_translate_elt(void)
496 {
497 MEMSET( TAB(_1ui), 0, sizeof(TAB(_1ui)) );
498 MEMSET( TAB(_1ub), 0, sizeof(TAB(_1ub)) );
499 MEMSET( TAB(_3f), 0, sizeof(TAB(_3f)) );
500 MEMSET( TAB(_4ub), 0, sizeof(TAB(_4ub)) );
501 MEMSET( TAB(_4f), 0, sizeof(TAB(_4f)) );
502
503 TAB(_4ub)[4][TYPE_IDX(GL_UNSIGNED_BYTE)] = trans_4_GLubyte_4ub;
504
505 init_trans_4_GLbyte_elt();
506 init_trans_3_GLbyte_elt();
507 init_trans_2_GLbyte_elt();
508 init_trans_1_GLbyte_elt();
509 init_trans_1_GLubyte_elt();
510 init_trans_3_GLubyte_elt();
511 init_trans_4_GLshort_elt();
512 init_trans_3_GLshort_elt();
513 init_trans_2_GLshort_elt();
514 init_trans_1_GLshort_elt();
515 init_trans_4_GLushort_elt();
516 init_trans_3_GLushort_elt();
517 init_trans_2_GLushort_elt();
518 init_trans_1_GLushort_elt();
519 init_trans_4_GLint_elt();
520 init_trans_3_GLint_elt();
521 init_trans_2_GLint_elt();
522 init_trans_1_GLint_elt();
523 init_trans_4_GLuint_elt();
524 init_trans_3_GLuint_elt();
525 init_trans_2_GLuint_elt();
526 init_trans_1_GLuint_elt();
527 init_trans_4_GLdouble_elt();
528 init_trans_3_GLdouble_elt();
529 init_trans_2_GLdouble_elt();
530 init_trans_1_GLdouble_elt();
531 init_trans_4_GLfloat_elt();
532 init_trans_3_GLfloat_elt();
533 init_trans_2_GLfloat_elt();
534 init_trans_1_GLfloat_elt();
535 }
536
537
538 #undef TAB
539 #undef CLASS
540 #undef ARGS
541 #undef CHECK
542 #undef START
543
544
545
546
547 void _tnl_imm_elt_init( void )
548 {
549 init_translate_elt();
550 }
551
552
553 static void _tnl_trans_elt_1f(GLfloat *to,
554 const struct gl_client_array *from,
555 GLuint *flags,
556 GLuint *elts,
557 GLuint match,
558 GLuint start,
559 GLuint n )
560 {
561 _tnl_trans_elt_1f_tab[TYPE_IDX(from->Type)]( to,
562 from->Ptr,
563 from->StrideB,
564 flags,
565 elts,
566 match,
567 start,
568 n );
569
570 }
571
572 static void _tnl_trans_elt_1ui(GLuint *to,
573 const struct gl_client_array *from,
574 GLuint *flags,
575 GLuint *elts,
576 GLuint match,
577 GLuint start,
578 GLuint n )
579 {
580 _tnl_trans_elt_1ui_tab[TYPE_IDX(from->Type)]( to,
581 from->Ptr,
582 from->StrideB,
583 flags,
584 elts,
585 match,
586 start,
587 n );
588
589 }
590
591
592 static void _tnl_trans_elt_1ub(GLubyte *to,
593 const struct gl_client_array *from,
594 GLuint *flags,
595 GLuint *elts,
596 GLuint match,
597 GLuint start,
598 GLuint n )
599 {
600 _tnl_trans_elt_1ub_tab[TYPE_IDX(from->Type)]( to,
601 from->Ptr,
602 from->StrideB,
603 flags,
604 elts,
605 match,
606 start,
607 n );
608
609 }
610
611
612 static void _tnl_trans_elt_4ub(GLubyte (*to)[4],
613 const struct gl_client_array *from,
614 GLuint *flags,
615 GLuint *elts,
616 GLuint match,
617 GLuint start,
618 GLuint n )
619 {
620 _tnl_trans_elt_4ub_tab[from->Size][TYPE_IDX(from->Type)]( to,
621 from->Ptr,
622 from->StrideB,
623 flags,
624 elts,
625 match,
626 start,
627 n );
628
629 }
630
631 static void _tnl_trans_elt_4f(GLfloat (*to)[4],
632 const struct gl_client_array *from,
633 GLuint *flags,
634 GLuint *elts,
635 GLuint match,
636 GLuint start,
637 GLuint n )
638 {
639 _tnl_trans_elt_4f_tab[from->Size][TYPE_IDX(from->Type)]( to,
640 from->Ptr,
641 from->StrideB,
642 flags,
643 elts,
644 match,
645 start,
646 n );
647
648 }
649
650 static void _tnl_trans_elt_3f(GLfloat (*to)[3],
651 const struct gl_client_array *from,
652 GLuint *flags,
653 GLuint *elts,
654 GLuint match,
655 GLuint start,
656 GLuint n )
657 {
658 _tnl_trans_elt_3f_tab[TYPE_IDX(from->Type)]( to,
659 from->Ptr,
660 from->StrideB,
661 flags,
662 elts,
663 match,
664 start,
665 n );
666 }
667
668
669
670
671 /* Batch function to translate away all the array elements in the
672 * input buffer prior to transform. Done only the first time a vertex
673 * buffer is executed or compiled.
674 *
675 * KW: Have to do this after each glEnd if arrays aren't locked.
676 */
677 void _tnl_translate_array_elts( GLcontext *ctx, struct immediate *IM,
678 GLuint start, GLuint count )
679 {
680 GLuint *flags = IM->Flag;
681 GLuint *elts = IM->Elt;
682 GLuint translate = ctx->Array._Enabled;
683 GLuint i;
684
685 if (MESA_VERBOSE&VERBOSE_IMMEDIATE)
686 fprintf(stderr, "exec_array_elements %d .. %d\n", start, count);
687
688 if (translate & VERT_OBJ) {
689 _tnl_trans_elt_4f( IM->Obj,
690 &ctx->Array.Vertex,
691 flags, elts, (VERT_ELT|VERT_OBJ),
692 start, count);
693
694 if (ctx->Array.Vertex.Size == 4)
695 translate |= VERT_OBJ_234;
696 else if (ctx->Array.Vertex.Size == 3)
697 translate |= VERT_OBJ_23;
698 }
699
700
701 if (translate & VERT_NORM)
702 _tnl_trans_elt_3f( IM->Normal,
703 &ctx->Array.Normal,
704 flags, elts, (VERT_ELT|VERT_NORM),
705 start, count);
706
707 if (translate & VERT_EDGE)
708 _tnl_trans_elt_1ub( IM->EdgeFlag,
709 &ctx->Array.EdgeFlag,
710 flags, elts, (VERT_ELT|VERT_EDGE),
711 start, count);
712
713 if (translate & VERT_RGBA)
714 _tnl_trans_elt_4ub( IM->Color,
715 &ctx->Array.Color,
716 flags, elts, (VERT_ELT|VERT_RGBA),
717 start, count);
718
719
720 if (translate & VERT_SPEC_RGB)
721 _tnl_trans_elt_4ub( IM->SecondaryColor,
722 &ctx->Array.SecondaryColor,
723 flags, elts, (VERT_ELT|VERT_SPEC_RGB),
724 start, count);
725
726 if (translate & VERT_FOG_COORD)
727 _tnl_trans_elt_1f( IM->FogCoord,
728 &ctx->Array.FogCoord,
729 flags, elts, (VERT_ELT|VERT_FOG_COORD),
730 start, count);
731
732 if (translate & VERT_INDEX)
733 _tnl_trans_elt_1ui( IM->Index,
734 &ctx->Array.Index,
735 flags, elts, (VERT_ELT|VERT_INDEX),
736 start, count);
737
738 if (translate & VERT_TEX_ANY) {
739 for (i = 0 ; i < ctx->Const.MaxTextureUnits ; i++)
740 if (translate & VERT_TEX(i)) {
741 _tnl_trans_elt_4f( IM->TexCoord[i],
742 &ctx->Array.TexCoord[i],
743 flags, elts, (VERT_ELT|VERT_TEX(i)),
744 start, count);
745
746 if (ctx->Array.TexCoord[i].Size == 4)
747 IM->TexSize |= TEX_SIZE_4(i);
748 else if (ctx->Array.TexCoord[i].Size == 3)
749 IM->TexSize |= TEX_SIZE_3(i);
750 }
751 }
752
753 for (i = start ; i < count ; i++)
754 if (flags[i] & VERT_ELT) flags[i] |= translate;
755
756 IM->CopyOrFlag |= translate;
757 }
758
759