source: trunk/src/opengl/mesa/translate.c@ 3721

Last change on this file since 3721 was 3598, checked in by jeroen, 25 years ago

* empty log message *

File size: 21.8 KB
Line 
1/* $Id: translate.c,v 1.2 2000-05-23 20:40:58 jeroen Exp $ */
2
3/*
4 * Mesa 3-D graphics library
5 * Version: 3.3
6 *
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27/*
28 * New (3.1) transformation code written by Keith Whitwell.
29 */
30
31
32#include "glheader.h"
33#include "types.h"
34#include "translate.h"
35#include "mmath.h"
36#include "mem.h"
37
38#undef CHECK
39
40trans_1ui_func gl_trans_1ui_tab[MAX_TYPES];
41trans_1ub_func gl_trans_1ub_tab[MAX_TYPES];
42trans_3f_func gl_trans_3f_tab[MAX_TYPES];
43trans_4ub_func gl_trans_4ub_tab[5][MAX_TYPES];
44trans_4f_func gl_trans_4f_tab[5][MAX_TYPES];
45
46trans_elt_1ui_func gl_trans_elt_1ui_tab[MAX_TYPES];
47trans_elt_1ub_func gl_trans_elt_1ub_tab[MAX_TYPES];
48trans_elt_3f_func gl_trans_elt_3f_tab[MAX_TYPES];
49trans_elt_4ub_func gl_trans_elt_4ub_tab[5][MAX_TYPES];
50trans_elt_4f_func gl_trans_elt_4f_tab[5][MAX_TYPES];
51
52
53#define PTR_ELT(ptr, elt) (((SRC *)ptr)[elt])
54
55
56#define TAB(x) gl_trans##x##_tab
57#define ARGS GLuint start, GLuint n
58#define SRC_START start
59#define DST_START 0
60#define STRIDE stride
61#define NEXT_F f += stride
62#define NEXT_F2
63#define CHECK
64
65
66
67
68/* GL_BYTE
69 */
70#define SRC GLbyte
71#define SRC_IDX TYPE_IDX(GL_BYTE)
72#define TRX_3F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
73#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
74#define TRX_UB(ub, f,n) ub = BYTE_TO_UBYTE( PTR_ELT(f,n) )
75#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
76
77
78#define SZ 4
79#define INIT init_trans_4_GLbyte_raw
80#define DEST_4F trans_4_GLbyte_4f_raw
81#define DEST_4UB trans_4_GLbyte_4ub_raw
82#include "trans_tmp.h"
83
84#define SZ 3
85#define INIT init_trans_3_GLbyte_raw
86#define DEST_4F trans_3_GLbyte_4f_raw
87#define DEST_4UB trans_3_GLbyte_4ub_raw
88#define DEST_3F trans_3_GLbyte_3f_raw
89#include "trans_tmp.h"
90
91#define SZ 2
92#define INIT init_trans_2_GLbyte_raw
93#define DEST_4F trans_2_GLbyte_4f_raw
94#include "trans_tmp.h"
95
96#define SZ 1
97#define INIT init_trans_1_GLbyte_raw
98#define DEST_4F trans_1_GLbyte_4f_raw
99#define DEST_1UB trans_1_GLbyte_1ub_raw
100#define DEST_1UI trans_1_GLbyte_1ui_raw
101#include "trans_tmp.h"
102
103#undef SRC
104#undef TRX_3F
105#undef TRX_4F
106#undef TRX_UB
107#undef TRX_UI
108#undef SRC_IDX
109
110/* GL_UNSIGNED_BYTE
111 */
112#define SRC GLubyte
113#define SRC_IDX TYPE_IDX(GL_UNSIGNED_BYTE)
114#define TRX_3F(f,n) /* unused */
115#define TRX_4F(f,n) /* unused */
116#define TRX_UB(ub, f,n) ub = PTR_ELT(f,n)
117#define TRX_UI(f,n) (GLuint)PTR_ELT(f,n)
118
119/* 4ub->4ub handled in special case below.
120 */
121
122#define SZ 3
123#define INIT init_trans_3_GLubyte_raw
124#define DEST_4UB trans_3_GLubyte_4ub_raw
125#include "trans_tmp.h"
126
127
128#define SZ 1
129#define INIT init_trans_1_GLubyte_raw
130#define DEST_1UI trans_1_GLubyte_1ui_raw
131#define DEST_1UB trans_1_GLubyte_1ub_raw
132#include "trans_tmp.h"
133
134#undef SRC
135#undef SRC_IDX
136#undef TRX_3F
137#undef TRX_4F
138#undef TRX_UB
139#undef TRX_UI
140
141
142/* GL_SHORT
143 */
144#define SRC GLshort
145#define SRC_IDX TYPE_IDX(GL_SHORT)
146#define TRX_3F(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) )
147#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
148#define TRX_UB(ub, f,n) ub = SHORT_TO_UBYTE(PTR_ELT(f,n))
149#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
150
151
152#define SZ 4
153#define INIT init_trans_4_GLshort_raw
154#define DEST_4F trans_4_GLshort_4f_raw
155#define DEST_4UB trans_4_GLshort_4ub_raw
156#include "trans_tmp.h"
157
158#define SZ 3
159#define INIT init_trans_3_GLshort_raw
160#define DEST_4F trans_3_GLshort_4f_raw
161#define DEST_4UB trans_3_GLshort_4ub_raw
162#define DEST_3F trans_3_GLshort_3f_raw
163#include "trans_tmp.h"
164
165#define SZ 2
166#define INIT init_trans_2_GLshort_raw
167#define DEST_4F trans_2_GLshort_4f_raw
168#include "trans_tmp.h"
169
170#define SZ 1
171#define INIT init_trans_1_GLshort_raw
172#define DEST_4F trans_1_GLshort_4f_raw
173#define DEST_1UB trans_1_GLshort_1ub_raw
174#define DEST_1UI trans_1_GLshort_1ui_raw
175#include "trans_tmp.h"
176
177
178#undef SRC
179#undef SRC_IDX
180#undef TRX_3F
181#undef TRX_4F
182#undef TRX_UB
183#undef TRX_UI
184
185
186/* GL_UNSIGNED_SHORT
187 */
188#define SRC GLushort
189#define SRC_IDX TYPE_IDX(GL_UNSIGNED_SHORT)
190#define TRX_3F(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) )
191#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
192#define TRX_UB(ub,f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 8)
193#define TRX_UI(f,n) (GLuint) PTR_ELT(f,n)
194
195
196#define SZ 4
197#define INIT init_trans_4_GLushort_raw
198#define DEST_4F trans_4_GLushort_4f_raw
199#define DEST_4UB trans_4_GLushort_4ub_raw
200#include "trans_tmp.h"
201
202#define SZ 3
203#define INIT init_trans_3_GLushort_raw
204#define DEST_4F trans_3_GLushort_4f_raw
205#define DEST_4UB trans_3_GLushort_4ub_raw
206#define DEST_3F trans_3_GLushort_3f_raw
207#include "trans_tmp.h"
208
209#define SZ 2
210#define INIT init_trans_2_GLushort_raw
211#define DEST_4F trans_2_GLushort_4f_raw
212#include "trans_tmp.h"
213
214#define SZ 1
215#define INIT init_trans_1_GLushort_raw
216#define DEST_4F trans_1_GLushort_4f_raw
217#define DEST_1UB trans_1_GLushort_1ub_raw
218#define DEST_1UI trans_1_GLushort_1ui_raw
219#include "trans_tmp.h"
220
221#undef SRC
222#undef SRC_IDX
223#undef TRX_3F
224#undef TRX_4F
225#undef TRX_UB
226#undef TRX_UI
227
228
229/* GL_INT
230 */
231#define SRC GLint
232#define SRC_IDX TYPE_IDX(GL_INT)
233#define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
234#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
235#define TRX_UB(ub, f,n) ub = INT_TO_UBYTE(PTR_ELT(f,n))
236#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
237
238
239#define SZ 4
240#define INIT init_trans_4_GLint_raw
241#define DEST_4F trans_4_GLint_4f_raw
242#define DEST_4UB trans_4_GLint_4ub_raw
243#include "trans_tmp.h"
244
245#define SZ 3
246#define INIT init_trans_3_GLint_raw
247#define DEST_4F trans_3_GLint_4f_raw
248#define DEST_4UB trans_3_GLint_4ub_raw
249#define DEST_3F trans_3_GLint_3f_raw
250#include "trans_tmp.h"
251
252#define SZ 2
253#define INIT init_trans_2_GLint_raw
254#define DEST_4F trans_2_GLint_4f_raw
255#include "trans_tmp.h"
256
257#define SZ 1
258#define INIT init_trans_1_GLint_raw
259#define DEST_4F trans_1_GLint_4f_raw
260#define DEST_1UB trans_1_GLint_1ub_raw
261#define DEST_1UI trans_1_GLint_1ui_raw
262#include "trans_tmp.h"
263
264
265#undef SRC
266#undef SRC_IDX
267#undef TRX_3F
268#undef TRX_4F
269#undef TRX_UB
270#undef TRX_UI
271
272
273/* GL_UNSIGNED_INT
274 */
275#define SRC GLuint
276#define SRC_IDX TYPE_IDX(GL_UNSIGNED_INT)
277#define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
278#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
279#define TRX_UB(ub, f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 24)
280#define TRX_UI(f,n) PTR_ELT(f,n)
281
282
283#define SZ 4
284#define INIT init_trans_4_GLuint_raw
285#define DEST_4F trans_4_GLuint_4f_raw
286#define DEST_4UB trans_4_GLuint_4ub_raw
287#include "trans_tmp.h"
288
289#define SZ 3
290#define INIT init_trans_3_GLuint_raw
291#define DEST_4F trans_3_GLuint_4f_raw
292#define DEST_4UB trans_3_GLuint_4ub_raw
293#define DEST_3F trans_3_GLuint_3f_raw
294#include "trans_tmp.h"
295
296#define SZ 2
297#define INIT init_trans_2_GLuint_raw
298#define DEST_4F trans_2_GLuint_4f_raw
299#include "trans_tmp.h"
300
301#define SZ 1
302#define INIT init_trans_1_GLuint_raw
303#define DEST_4F trans_1_GLuint_4f_raw
304#define DEST_1UB trans_1_GLuint_1ub_raw
305#define DEST_1UI trans_1_GLuint_1ui_raw
306#include "trans_tmp.h"
307
308#undef SRC
309#undef SRC_IDX
310#undef TRX_3F
311#undef TRX_4F
312#undef TRX_UB
313#undef TRX_UI
314
315
316/* GL_DOUBLE
317 */
318#define SRC GLdouble
319#define SRC_IDX TYPE_IDX(GL_DOUBLE)
320#define TRX_3F(f,n) PTR_ELT(f,n)
321#define TRX_4F(f,n) PTR_ELT(f,n)
322#define TRX_UB(ub,f,n) FLOAT_COLOR_TO_UBYTE_COLOR(ub, PTR_ELT(f,n))
323#define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n)
324
325
326#define SZ 4
327#define INIT init_trans_4_GLdouble_raw
328#define DEST_4F trans_4_GLdouble_4f_raw
329#define DEST_4UB trans_4_GLdouble_4ub_raw
330#include "trans_tmp.h"
331
332#define SZ 3
333#define INIT init_trans_3_GLdouble_raw
334#define DEST_4F trans_3_GLdouble_4f_raw
335#define DEST_4UB trans_3_GLdouble_4ub_raw
336#define DEST_3F trans_3_GLdouble_3f_raw
337#include "trans_tmp.h"
338
339#define SZ 2
340#define INIT init_trans_2_GLdouble_raw
341#define DEST_4F trans_2_GLdouble_4f_raw
342#include "trans_tmp.h"
343
344#define SZ 1
345#define INIT init_trans_1_GLdouble_raw
346#define DEST_4F trans_1_GLdouble_4f_raw
347#define DEST_1UB trans_1_GLdouble_1ub_raw
348#define DEST_1UI trans_1_GLdouble_1ui_raw
349#include "trans_tmp.h"
350
351#undef SRC
352#undef SRC_IDX
353
354/* GL_FLOAT
355 */
356#define SRC GLfloat
357#define SRC_IDX TYPE_IDX(GL_FLOAT)
358#define SZ 4
359#define INIT init_trans_4_GLfloat_raw
360#define DEST_4UB trans_4_GLfloat_4ub_raw
361#define DEST_4F trans_4_GLfloat_4f_raw
362#include "trans_tmp.h"
363
364#define SZ 3
365#define INIT init_trans_3_GLfloat_raw
366#define DEST_4F trans_3_GLfloat_4f_raw
367#define DEST_4UB trans_3_GLfloat_4ub_raw
368#define DEST_3F trans_3_GLfloat_3f_raw
369#include "trans_tmp.h"
370
371#define SZ 2
372#define INIT init_trans_2_GLfloat_raw
373#define DEST_4F trans_2_GLfloat_4f_raw
374#include "trans_tmp.h"
375
376#define SZ 1
377#define INIT init_trans_1_GLfloat_raw
378#define DEST_4F trans_1_GLfloat_4f_raw
379#define DEST_1UB trans_1_GLfloat_1ub_raw
380#define DEST_1UI trans_1_GLfloat_1ui_raw
381
382#include "trans_tmp.h"
383
384#undef SRC
385#undef SRC_IDX
386#undef TRX_3F
387#undef TRX_4F
388#undef TRX_UB
389#undef TRX_UI
390
391
392static void trans_4_GLubyte_4ub_raw (GLubyte (*t)[4],
393 const struct gl_client_array *from,
394 ARGS )
395{
396 GLuint stride = from->StrideB;
397 const GLubyte *f = (GLubyte *) from->Ptr + SRC_START * stride;
398 GLuint i;
399
400 if (((((long) f | (long) stride)) & 3L) == 0L) {
401 /* Aligned.
402 */
403 for (i = DST_START ; i < n ; i++, f += stride) {
404 COPY_4UBV( t[i], f );
405 }
406 } else {
407 for (i = DST_START ; i < n ; i++, f += stride) {
408 t[i][0] = f[0];
409 t[i][1] = f[1];
410 t[i][2] = f[2];
411 t[i][3] = f[3];
412 }
413 }
414}
415
416
417static void init_translate_raw(void)
418{
419 MEMSET( TAB(_1ui), 0, sizeof(TAB(_1ui)) );
420 MEMSET( TAB(_1ub), 0, sizeof(TAB(_1ub)) );
421 MEMSET( TAB(_3f), 0, sizeof(TAB(_3f)) );
422 MEMSET( TAB(_4ub), 0, sizeof(TAB(_4ub)) );
423 MEMSET( TAB(_4f), 0, sizeof(TAB(_4f)) );
424
425 TAB(_4ub)[4][TYPE_IDX(GL_UNSIGNED_BYTE)] = trans_4_GLubyte_4ub_raw;
426
427 init_trans_4_GLbyte_raw();
428 init_trans_3_GLbyte_raw();
429 init_trans_2_GLbyte_raw();
430 init_trans_1_GLbyte_raw();
431 init_trans_1_GLubyte_raw();
432 init_trans_3_GLubyte_raw();
433 init_trans_4_GLshort_raw();
434 init_trans_3_GLshort_raw();
435 init_trans_2_GLshort_raw();
436 init_trans_1_GLshort_raw();
437 init_trans_4_GLushort_raw();
438 init_trans_3_GLushort_raw();
439 init_trans_2_GLushort_raw();
440 init_trans_1_GLushort_raw();
441 init_trans_4_GLint_raw();
442 init_trans_3_GLint_raw();
443 init_trans_2_GLint_raw();
444 init_trans_1_GLint_raw();
445 init_trans_4_GLuint_raw();
446 init_trans_3_GLuint_raw();
447 init_trans_2_GLuint_raw();
448 init_trans_1_GLuint_raw();
449 init_trans_4_GLdouble_raw();
450 init_trans_3_GLdouble_raw();
451 init_trans_2_GLdouble_raw();
452 init_trans_1_GLdouble_raw();
453 init_trans_4_GLfloat_raw();
454 init_trans_3_GLfloat_raw();
455 init_trans_2_GLfloat_raw();
456 init_trans_1_GLfloat_raw();
457}
458
459
460#undef TAB
461#undef CLASS
462#undef ARGS
463#undef CHECK
464#undef SRC_START
465#undef DST_START
466#undef NEXT_F
467#undef NEXT_F2
468
469
470/* Code specific to array element implementation. There is a small
471 * subtlety in the bits CHECK() tests, and the way bits are set in
472 * glArrayElement which ensures that if, eg, in the case that the
473 * vertex array is disabled and normal array is enabled, and we get
474 * either sequence:
475 *
476 * ArrayElement() OR Normal()
477 * Normal() ArrayElement()
478 * Vertex() Vertex()
479 *
480 * That the correct value for normal is used.
481 */
482#define TAB(x) gl_trans_elt##x##_tab
483#define ARGS GLuint *flags, GLuint *elts, GLuint match, \
484 GLuint start, GLuint n
485#define SRC_START 0
486#define DST_START start
487#define CHECK if ((flags[i]&match) == VERT_ELT)
488#define NEXT_F (void)1
489#define NEXT_F2 f = first + elts[i] * stride;
490
491
492/* GL_BYTE
493 */
494#define SRC GLbyte
495#define SRC_IDX TYPE_IDX(GL_BYTE)
496#define TRX_3F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
497#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
498#define TRX_UB(ub, f,n) ub = BYTE_TO_UBYTE( PTR_ELT(f,n) )
499#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
500
501
502#define SZ 4
503#define INIT init_trans_4_GLbyte_elt
504#define DEST_4F trans_4_GLbyte_4f_elt
505#define DEST_4UB trans_4_GLbyte_4ub_elt
506#include "trans_tmp.h"
507
508#define SZ 3
509#define INIT init_trans_3_GLbyte_elt
510#define DEST_4F trans_3_GLbyte_4f_elt
511#define DEST_4UB trans_3_GLbyte_4ub_elt
512#define DEST_3F trans_3_GLbyte_3f_elt
513#include "trans_tmp.h"
514
515#define SZ 2
516#define INIT init_trans_2_GLbyte_elt
517#define DEST_4F trans_2_GLbyte_4f_elt
518#include "trans_tmp.h"
519
520#define SZ 1
521#define INIT init_trans_1_GLbyte_elt
522#define DEST_4F trans_1_GLbyte_4f_elt
523#define DEST_1UB trans_1_GLbyte_1ub_elt
524#define DEST_1UI trans_1_GLbyte_1ui_elt
525#include "trans_tmp.h"
526
527#undef SRC
528#undef TRX_3F
529#undef TRX_4F
530#undef TRX_UB
531#undef TRX_UI
532#undef SRC_IDX
533
534/* GL_UNSIGNED_BYTE
535 */
536#define SRC GLubyte
537#define SRC_IDX TYPE_IDX(GL_UNSIGNED_BYTE)
538#define TRX_3F(f,n) /* unused */
539#define TRX_4F(f,n) /* unused */
540#define TRX_UB(ub, f,n) ub = PTR_ELT(f,n)
541#define TRX_UI(f,n) (GLuint)PTR_ELT(f,n)
542
543/* 4ub->4ub handled in special case below.
544 */
545
546#define SZ 3
547#define INIT init_trans_3_GLubyte_elt
548#define DEST_4UB trans_3_GLubyte_4ub_elt
549#include "trans_tmp.h"
550
551
552#define SZ 1
553#define INIT init_trans_1_GLubyte_elt
554#define DEST_1UI trans_1_GLubyte_1ui_elt
555#define DEST_1UB trans_1_GLubyte_1ub_elt
556#include "trans_tmp.h"
557
558#undef SRC
559#undef SRC_IDX
560#undef TRX_3F
561#undef TRX_4F
562#undef TRX_UB
563#undef TRX_UI
564
565
566/* GL_SHORT
567 */
568#define SRC GLshort
569#define SRC_IDX TYPE_IDX(GL_SHORT)
570#define TRX_3F(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) )
571#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
572#define TRX_UB(ub, f,n) ub = SHORT_TO_UBYTE(PTR_ELT(f,n))
573#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
574
575
576#define SZ 4
577#define INIT init_trans_4_GLshort_elt
578#define DEST_4F trans_4_GLshort_4f_elt
579#define DEST_4UB trans_4_GLshort_4ub_elt
580#include "trans_tmp.h"
581
582#define SZ 3
583#define INIT init_trans_3_GLshort_elt
584#define DEST_4F trans_3_GLshort_4f_elt
585#define DEST_4UB trans_3_GLshort_4ub_elt
586#define DEST_3F trans_3_GLshort_3f_elt
587#include "trans_tmp.h"
588
589#define SZ 2
590#define INIT init_trans_2_GLshort_elt
591#define DEST_4F trans_2_GLshort_4f_elt
592#include "trans_tmp.h"
593
594#define SZ 1
595#define INIT init_trans_1_GLshort_elt
596#define DEST_4F trans_1_GLshort_4f_elt
597#define DEST_1UB trans_1_GLshort_1ub_elt
598#define DEST_1UI trans_1_GLshort_1ui_elt
599#include "trans_tmp.h"
600
601
602#undef SRC
603#undef SRC_IDX
604#undef TRX_3F
605#undef TRX_4F
606#undef TRX_UB
607#undef TRX_UI
608
609
610/* GL_UNSIGNED_SHORT
611 */
612#define SRC GLushort
613#define SRC_IDX TYPE_IDX(GL_UNSIGNED_SHORT)
614#define TRX_3F(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) )
615#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
616#define TRX_UB(ub,f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 8)
617#define TRX_UI(f,n) (GLuint) PTR_ELT(f,n)
618
619
620#define SZ 4
621#define INIT init_trans_4_GLushort_elt
622#define DEST_4F trans_4_GLushort_4f_elt
623#define DEST_4UB trans_4_GLushort_4ub_elt
624#include "trans_tmp.h"
625
626#define SZ 3
627#define INIT init_trans_3_GLushort_elt
628#define DEST_4F trans_3_GLushort_4f_elt
629#define DEST_4UB trans_3_GLushort_4ub_elt
630#define DEST_3F trans_3_GLushort_3f_elt
631#include "trans_tmp.h"
632
633#define SZ 2
634#define INIT init_trans_2_GLushort_elt
635#define DEST_4F trans_2_GLushort_4f_elt
636#include "trans_tmp.h"
637
638#define SZ 1
639#define INIT init_trans_1_GLushort_elt
640#define DEST_4F trans_1_GLushort_4f_elt
641#define DEST_1UB trans_1_GLushort_1ub_elt
642#define DEST_1UI trans_1_GLushort_1ui_elt
643#include "trans_tmp.h"
644
645#undef SRC
646#undef SRC_IDX
647#undef TRX_3F
648#undef TRX_4F
649#undef TRX_UB
650#undef TRX_UI
651
652
653/* GL_INT
654 */
655#define SRC GLint
656#define SRC_IDX TYPE_IDX(GL_INT)
657#define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
658#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
659#define TRX_UB(ub, f,n) ub = INT_TO_UBYTE(PTR_ELT(f,n))
660#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
661
662
663#define SZ 4
664#define INIT init_trans_4_GLint_elt
665#define DEST_4F trans_4_GLint_4f_elt
666#define DEST_4UB trans_4_GLint_4ub_elt
667#include "trans_tmp.h"
668
669#define SZ 3
670#define INIT init_trans_3_GLint_elt
671#define DEST_4F trans_3_GLint_4f_elt
672#define DEST_4UB trans_3_GLint_4ub_elt
673#define DEST_3F trans_3_GLint_3f_elt
674#include "trans_tmp.h"
675
676#define SZ 2
677#define INIT init_trans_2_GLint_elt
678#define DEST_4F trans_2_GLint_4f_elt
679#include "trans_tmp.h"
680
681#define SZ 1
682#define INIT init_trans_1_GLint_elt
683#define DEST_4F trans_1_GLint_4f_elt
684#define DEST_1UB trans_1_GLint_1ub_elt
685#define DEST_1UI trans_1_GLint_1ui_elt
686#include "trans_tmp.h"
687
688
689#undef SRC
690#undef SRC_IDX
691#undef TRX_3F
692#undef TRX_4F
693#undef TRX_UB
694#undef TRX_UI
695
696
697/* GL_UNSIGNED_INT
698 */
699#define SRC GLuint
700#define SRC_IDX TYPE_IDX(GL_UNSIGNED_INT)
701#define TRX_3F(f,n) UINT_TO_FLOAT( PTR_ELT(f,n) )
702#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
703#define TRX_UB(ub, f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 24)
704#define TRX_UI(f,n) PTR_ELT(f,n)
705
706
707#define SZ 4
708#define INIT init_trans_4_GLuint_elt
709#define DEST_4F trans_4_GLuint_4f_elt
710#define DEST_4UB trans_4_GLuint_4ub_elt
711#include "trans_tmp.h"
712
713#define SZ 3
714#define INIT init_trans_3_GLuint_elt
715#define DEST_4F trans_3_GLuint_4f_elt
716#define DEST_4UB trans_3_GLuint_4ub_elt
717#define DEST_3F trans_3_GLuint_3f_elt
718#include "trans_tmp.h"
719
720#define SZ 2
721#define INIT init_trans_2_GLuint_elt
722#define DEST_4F trans_2_GLuint_4f_elt
723#include "trans_tmp.h"
724
725#define SZ 1
726#define INIT init_trans_1_GLuint_elt
727#define DEST_4F trans_1_GLuint_4f_elt
728#define DEST_1UB trans_1_GLuint_1ub_elt
729#define DEST_1UI trans_1_GLuint_1ui_elt
730#include "trans_tmp.h"
731
732#undef SRC
733#undef SRC_IDX
734#undef TRX_3F
735#undef TRX_4F
736#undef TRX_UB
737#undef TRX_UI
738
739
740/* GL_DOUBLE
741 */
742#define SRC GLdouble
743#define SRC_IDX TYPE_IDX(GL_DOUBLE)
744#define TRX_3F(f,n) PTR_ELT(f,n)
745#define TRX_4F(f,n) PTR_ELT(f,n)
746#define TRX_UB(ub,f,n) FLOAT_COLOR_TO_UBYTE_COLOR(ub, PTR_ELT(f,n))
747#define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n)
748
749
750#define SZ 4
751#define INIT init_trans_4_GLdouble_elt
752#define DEST_4F trans_4_GLdouble_4f_elt
753#define DEST_4UB trans_4_GLdouble_4ub_elt
754#include "trans_tmp.h"
755
756#define SZ 3
757#define INIT init_trans_3_GLdouble_elt
758#define DEST_4F trans_3_GLdouble_4f_elt
759#define DEST_4UB trans_3_GLdouble_4ub_elt
760#define DEST_3F trans_3_GLdouble_3f_elt
761#include "trans_tmp.h"
762
763#define SZ 2
764#define INIT init_trans_2_GLdouble_elt
765#define DEST_4F trans_2_GLdouble_4f_elt
766#include "trans_tmp.h"
767
768#define SZ 1
769#define INIT init_trans_1_GLdouble_elt
770#define DEST_4F trans_1_GLdouble_4f_elt
771#define DEST_1UB trans_1_GLdouble_1ub_elt
772#define DEST_1UI trans_1_GLdouble_1ui_elt
773#include "trans_tmp.h"
774
775#undef SRC
776#undef SRC_IDX
777
778/* GL_FLOAT
779 */
780#define SRC GLfloat
781#define SRC_IDX TYPE_IDX(GL_FLOAT)
782#define SZ 4
783#define INIT init_trans_4_GLfloat_elt
784#define DEST_4UB trans_4_GLfloat_4ub_elt
785#define DEST_4F trans_4_GLfloat_4f_elt
786#include "trans_tmp.h"
787
788#define SZ 3
789#define INIT init_trans_3_GLfloat_elt
790#define DEST_4F trans_3_GLfloat_4f_elt
791#define DEST_4UB trans_3_GLfloat_4ub_elt
792#define DEST_3F trans_3_GLfloat_3f_elt
793#include "trans_tmp.h"
794
795#define SZ 2
796#define INIT init_trans_2_GLfloat_elt
797#define DEST_4F trans_2_GLfloat_4f_elt
798#include "trans_tmp.h"
799
800#define SZ 1
801#define INIT init_trans_1_GLfloat_elt
802#define DEST_4F trans_1_GLfloat_3f_elt
803#define DEST_1UB trans_1_GLfloat_1ub_elt
804#define DEST_1UI trans_1_GLfloat_1ui_elt
805#include "trans_tmp.h"
806
807#undef SRC
808#undef SRC_IDX
809#undef TRX_3F
810#undef TRX_4F
811#undef TRX_UB
812#undef TRX_UI
813
814
815static void trans_4_GLubyte_4ub(GLubyte (*t)[4],
816 const struct gl_client_array *from,
817 ARGS )
818{
819 GLuint stride = from->StrideB;
820 const GLubyte *f = (GLubyte *) from->Ptr + SRC_START * stride;
821 const GLubyte *first = f;
822 GLuint i;
823 (void) start;
824 if (((((long) f | (long) stride)) & 3L) == 0L) {
825 /* Aligned.
826 */
827 for (i = DST_START ; i < n ; i++, NEXT_F) {
828 CHECK {
829 NEXT_F2;
830 COPY_4UBV( t[i], f );
831 }
832 }
833 } else {
834 for (i = DST_START ; i < n ; i++, NEXT_F) {
835 CHECK {
836 NEXT_F2;
837 t[i][0] = f[0];
838 t[i][1] = f[1];
839 t[i][2] = f[2];
840 t[i][3] = f[3];
841 }
842 }
843 }
844}
845
846
847static void init_translate_elt(void)
848{
849 MEMSET( TAB(_1ui), 0, sizeof(TAB(_1ui)) );
850 MEMSET( TAB(_1ub), 0, sizeof(TAB(_1ub)) );
851 MEMSET( TAB(_3f), 0, sizeof(TAB(_3f)) );
852 MEMSET( TAB(_4ub), 0, sizeof(TAB(_4ub)) );
853 MEMSET( TAB(_4f), 0, sizeof(TAB(_4f)) );
854
855 TAB(_4ub)[4][TYPE_IDX(GL_UNSIGNED_BYTE)] = trans_4_GLubyte_4ub;
856
857 init_trans_4_GLbyte_elt();
858 init_trans_3_GLbyte_elt();
859 init_trans_2_GLbyte_elt();
860 init_trans_1_GLbyte_elt();
861 init_trans_1_GLubyte_elt();
862 init_trans_3_GLubyte_elt();
863 init_trans_4_GLshort_elt();
864 init_trans_3_GLshort_elt();
865 init_trans_2_GLshort_elt();
866 init_trans_1_GLshort_elt();
867 init_trans_4_GLushort_elt();
868 init_trans_3_GLushort_elt();
869 init_trans_2_GLushort_elt();
870 init_trans_1_GLushort_elt();
871 init_trans_4_GLint_elt();
872 init_trans_3_GLint_elt();
873 init_trans_2_GLint_elt();
874 init_trans_1_GLint_elt();
875 init_trans_4_GLuint_elt();
876 init_trans_3_GLuint_elt();
877 init_trans_2_GLuint_elt();
878 init_trans_1_GLuint_elt();
879 init_trans_4_GLdouble_elt();
880 init_trans_3_GLdouble_elt();
881 init_trans_2_GLdouble_elt();
882 init_trans_1_GLdouble_elt();
883 init_trans_4_GLfloat_elt();
884 init_trans_3_GLfloat_elt();
885 init_trans_2_GLfloat_elt();
886 init_trans_1_GLfloat_elt();
887}
888
889
890#undef TAB
891#undef CLASS
892#undef ARGS
893#undef CHECK
894#undef START
895
896
897
898
899void gl_init_translate( void )
900{
901 init_translate_raw();
902 init_translate_elt();
903}
Note: See TracBrowser for help on using the repository browser.