blob: def657e1c85c7f775e421264e423ff62e9187a2f [file] [log] [blame]
Keith Whitwell23caf202000-11-16 21:05:34 +00001/*
2 * Mesa 3-D graphics library
Brian Pauld18c08f2003-05-28 15:30:53 +00003 * Version: 5.1
Gareth Hughes22144ab2001-03-12 00:48:37 +00004 *
Brian Pauld18c08f2003-05-28 15:30:53 +00005 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
Gareth Hughes22144ab2001-03-12 00:48:37 +00006 *
Keith Whitwell23caf202000-11-16 21:05:34 +00007 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
Gareth Hughes22144ab2001-03-12 00:48:37 +000013 *
Keith Whitwell23caf202000-11-16 21:05:34 +000014 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
Gareth Hughes22144ab2001-03-12 00:48:37 +000016 *
Keith Whitwell23caf202000-11-16 21:05:34 +000017 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25/*
26 * New (3.1) transformation code written by Keith Whitwell.
27 */
28
29
30#include "glheader.h"
Keith Whitwell4eebc902001-02-20 18:28:52 +000031#include "mtypes.h" /* GLchan hack */
Keith Whitwell23caf202000-11-16 21:05:34 +000032#include "colormac.h"
Keith Whitwell23caf202000-11-16 21:05:34 +000033
34#include "m_translate.h"
35
Keith Whitwellcab974c2000-12-26 05:09:27 +000036
37
38typedef void (*trans_1f_func)(GLfloat *to,
39 CONST void *ptr,
40 GLuint stride,
Gareth Hughes22144ab2001-03-12 00:48:37 +000041 GLuint start,
Keith Whitwellcab974c2000-12-26 05:09:27 +000042 GLuint n );
43
44typedef void (*trans_1ui_func)(GLuint *to,
45 CONST void *ptr,
46 GLuint stride,
Gareth Hughes22144ab2001-03-12 00:48:37 +000047 GLuint start,
Keith Whitwellcab974c2000-12-26 05:09:27 +000048 GLuint n );
49
50typedef void (*trans_1ub_func)(GLubyte *to,
51 CONST void *ptr,
52 GLuint stride,
53 GLuint start,
54 GLuint n );
55
56typedef void (*trans_4ub_func)(GLubyte (*to)[4],
Brian Paul74b493a2001-01-24 00:04:58 +000057 CONST void *ptr,
58 GLuint stride,
59 GLuint start,
60 GLuint n );
61
62typedef void (*trans_4us_func)(GLushort (*to)[4],
63 CONST void *ptr,
64 GLuint stride,
65 GLuint start,
66 GLuint n );
Keith Whitwellcab974c2000-12-26 05:09:27 +000067
68typedef void (*trans_4f_func)(GLfloat (*to)[4],
69 CONST void *ptr,
70 GLuint stride,
Gareth Hughes22144ab2001-03-12 00:48:37 +000071 GLuint start,
Keith Whitwellcab974c2000-12-26 05:09:27 +000072 GLuint n );
73
74typedef void (*trans_3f_func)(GLfloat (*to)[3],
75 CONST void *ptr,
76 GLuint stride,
Gareth Hughes22144ab2001-03-12 00:48:37 +000077 GLuint start,
Keith Whitwellcab974c2000-12-26 05:09:27 +000078 GLuint n );
79
80
81
82
83#define TYPE_IDX(t) ((t) & 0xf)
84#define MAX_TYPES TYPE_IDX(GL_DOUBLE)+1 /* 0xa + 1 */
85
86
Keith Whitwell23caf202000-11-16 21:05:34 +000087/* This macro is used on other systems, so undefine it for this module */
88
89#undef CHECK
90
Keith Whitwellcab974c2000-12-26 05:09:27 +000091static trans_1f_func _math_trans_1f_tab[MAX_TYPES];
92static trans_1ui_func _math_trans_1ui_tab[MAX_TYPES];
93static trans_1ub_func _math_trans_1ub_tab[MAX_TYPES];
94static trans_3f_func _math_trans_3f_tab[MAX_TYPES];
95static trans_4ub_func _math_trans_4ub_tab[5][MAX_TYPES];
Brian Paul74b493a2001-01-24 00:04:58 +000096static trans_4us_func _math_trans_4us_tab[5][MAX_TYPES];
Keith Whitwellcab974c2000-12-26 05:09:27 +000097static trans_4f_func _math_trans_4f_tab[5][MAX_TYPES];
Keith Whitwell23caf202000-11-16 21:05:34 +000098
99
100#define PTR_ELT(ptr, elt) (((SRC *)ptr)[elt])
101
102
Keith Whitwellcab974c2000-12-26 05:09:27 +0000103#define TAB(x) _math_trans##x##_tab
Keith Whitwell23caf202000-11-16 21:05:34 +0000104#define ARGS GLuint start, GLuint n
105#define SRC_START start
106#define DST_START 0
107#define STRIDE stride
108#define NEXT_F f += stride
109#define NEXT_F2
110#define CHECK
111
112
113
114
115/* GL_BYTE
116 */
117#define SRC GLbyte
118#define SRC_IDX TYPE_IDX(GL_BYTE)
119#define TRX_3F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
Keith Whitwell5f2230c2001-05-09 14:12:34 +0000120#define TRX_4F(f,n) BYTE_TO_FLOAT( PTR_ELT(f,n) )
Keith Whitwell23caf202000-11-16 21:05:34 +0000121#define TRX_UB(ub, f,n) ub = BYTE_TO_UBYTE( PTR_ELT(f,n) )
Brian Paul74b493a2001-01-24 00:04:58 +0000122#define TRX_US(ch, f,n) ch = BYTE_TO_USHORT( PTR_ELT(f,n) )
Keith Whitwell23caf202000-11-16 21:05:34 +0000123#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
124
125
126#define SZ 4
127#define INIT init_trans_4_GLbyte_raw
128#define DEST_4F trans_4_GLbyte_4f_raw
129#define DEST_4UB trans_4_GLbyte_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000130#define DEST_4US trans_4_GLbyte_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000131#include "m_trans_tmp.h"
132
133#define SZ 3
134#define INIT init_trans_3_GLbyte_raw
135#define DEST_4F trans_3_GLbyte_4f_raw
136#define DEST_4UB trans_3_GLbyte_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000137#define DEST_4US trans_3_GLbyte_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000138#define DEST_3F trans_3_GLbyte_3f_raw
139#include "m_trans_tmp.h"
140
141#define SZ 2
142#define INIT init_trans_2_GLbyte_raw
143#define DEST_4F trans_2_GLbyte_4f_raw
144#include "m_trans_tmp.h"
145
146#define SZ 1
147#define INIT init_trans_1_GLbyte_raw
148#define DEST_4F trans_1_GLbyte_4f_raw
149#define DEST_1UB trans_1_GLbyte_1ub_raw
150#define DEST_1UI trans_1_GLbyte_1ui_raw
151#include "m_trans_tmp.h"
152
153#undef SRC
154#undef TRX_3F
155#undef TRX_4F
156#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000157#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000158#undef TRX_UI
159#undef SRC_IDX
160
Brian Paul74b493a2001-01-24 00:04:58 +0000161
Keith Whitwell23caf202000-11-16 21:05:34 +0000162/* GL_UNSIGNED_BYTE
163 */
164#define SRC GLubyte
165#define SRC_IDX TYPE_IDX(GL_UNSIGNED_BYTE)
Keith Whitwell51c0c712001-04-28 08:39:17 +0000166#define TRX_3F(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n))
167#define TRX_4F(f,n) UBYTE_TO_FLOAT(PTR_ELT(f,n))
Keith Whitwell23caf202000-11-16 21:05:34 +0000168#define TRX_UB(ub, f,n) ub = PTR_ELT(f,n)
Brian Paul74b493a2001-01-24 00:04:58 +0000169#define TRX_US(us, f,n) us = UBYTE_TO_USHORT(PTR_ELT(f,n))
Keith Whitwell23caf202000-11-16 21:05:34 +0000170#define TRX_UI(f,n) (GLuint)PTR_ELT(f,n)
171
172/* 4ub->4ub handled in special case below.
173 */
Keith Whitwell51c0c712001-04-28 08:39:17 +0000174#define SZ 4
175#define INIT init_trans_4_GLubyte_raw
176#define DEST_4F trans_4_GLubyte_4f_raw
177#define DEST_4US trans_4_GLubyte_4us_raw
178#include "m_trans_tmp.h"
179
Keith Whitwell23caf202000-11-16 21:05:34 +0000180
181#define SZ 3
182#define INIT init_trans_3_GLubyte_raw
183#define DEST_4UB trans_3_GLubyte_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000184#define DEST_4US trans_3_GLubyte_4us_raw
Keith Whitwell51c0c712001-04-28 08:39:17 +0000185#define DEST_3F trans_3_GLubyte_3f_raw
186#define DEST_4F trans_3_GLubyte_4f_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000187#include "m_trans_tmp.h"
188
189
190#define SZ 1
191#define INIT init_trans_1_GLubyte_raw
192#define DEST_1UI trans_1_GLubyte_1ui_raw
193#define DEST_1UB trans_1_GLubyte_1ub_raw
194#include "m_trans_tmp.h"
195
196#undef SRC
197#undef SRC_IDX
198#undef TRX_3F
199#undef TRX_4F
200#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000201#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000202#undef TRX_UI
203
204
205/* GL_SHORT
206 */
207#define SRC GLshort
208#define SRC_IDX TYPE_IDX(GL_SHORT)
209#define TRX_3F(f,n) SHORT_TO_FLOAT( PTR_ELT(f,n) )
210#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
211#define TRX_UB(ub, f,n) ub = SHORT_TO_UBYTE(PTR_ELT(f,n))
Brian Paul74b493a2001-01-24 00:04:58 +0000212#define TRX_US(us, f,n) us = SHORT_TO_USHORT(PTR_ELT(f,n))
Keith Whitwell23caf202000-11-16 21:05:34 +0000213#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
214
215
216#define SZ 4
217#define INIT init_trans_4_GLshort_raw
218#define DEST_4F trans_4_GLshort_4f_raw
219#define DEST_4UB trans_4_GLshort_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000220#define DEST_4US trans_4_GLshort_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000221#include "m_trans_tmp.h"
222
223#define SZ 3
224#define INIT init_trans_3_GLshort_raw
225#define DEST_4F trans_3_GLshort_4f_raw
226#define DEST_4UB trans_3_GLshort_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000227#define DEST_4US trans_3_GLshort_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000228#define DEST_3F trans_3_GLshort_3f_raw
229#include "m_trans_tmp.h"
230
231#define SZ 2
232#define INIT init_trans_2_GLshort_raw
233#define DEST_4F trans_2_GLshort_4f_raw
234#include "m_trans_tmp.h"
235
236#define SZ 1
237#define INIT init_trans_1_GLshort_raw
238#define DEST_4F trans_1_GLshort_4f_raw
239#define DEST_1UB trans_1_GLshort_1ub_raw
240#define DEST_1UI trans_1_GLshort_1ui_raw
241#include "m_trans_tmp.h"
242
243
244#undef SRC
245#undef SRC_IDX
246#undef TRX_3F
247#undef TRX_4F
248#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000249#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000250#undef TRX_UI
251
252
253/* GL_UNSIGNED_SHORT
254 */
255#define SRC GLushort
256#define SRC_IDX TYPE_IDX(GL_UNSIGNED_SHORT)
257#define TRX_3F(f,n) USHORT_TO_FLOAT( PTR_ELT(f,n) )
258#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
259#define TRX_UB(ub,f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 8)
Brian Paul74b493a2001-01-24 00:04:58 +0000260#define TRX_US(us,f,n) us = (GLushort) (PTR_ELT(f,n) >> 8)
Keith Whitwell23caf202000-11-16 21:05:34 +0000261#define TRX_UI(f,n) (GLuint) PTR_ELT(f,n)
262
263
264#define SZ 4
265#define INIT init_trans_4_GLushort_raw
266#define DEST_4F trans_4_GLushort_4f_raw
267#define DEST_4UB trans_4_GLushort_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000268#define DEST_4US trans_4_GLushort_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000269#include "m_trans_tmp.h"
270
271#define SZ 3
272#define INIT init_trans_3_GLushort_raw
273#define DEST_4F trans_3_GLushort_4f_raw
274#define DEST_4UB trans_3_GLushort_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000275#define DEST_4US trans_3_GLushort_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000276#define DEST_3F trans_3_GLushort_3f_raw
277#include "m_trans_tmp.h"
278
279#define SZ 2
280#define INIT init_trans_2_GLushort_raw
281#define DEST_4F trans_2_GLushort_4f_raw
282#include "m_trans_tmp.h"
283
284#define SZ 1
285#define INIT init_trans_1_GLushort_raw
286#define DEST_4F trans_1_GLushort_4f_raw
287#define DEST_1UB trans_1_GLushort_1ub_raw
288#define DEST_1UI trans_1_GLushort_1ui_raw
289#include "m_trans_tmp.h"
290
291#undef SRC
292#undef SRC_IDX
293#undef TRX_3F
294#undef TRX_4F
295#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000296#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000297#undef TRX_UI
298
299
300/* GL_INT
301 */
302#define SRC GLint
303#define SRC_IDX TYPE_IDX(GL_INT)
304#define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
305#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
306#define TRX_UB(ub, f,n) ub = INT_TO_UBYTE(PTR_ELT(f,n))
Brian Paul74b493a2001-01-24 00:04:58 +0000307#define TRX_US(us, f,n) us = INT_TO_USHORT(PTR_ELT(f,n))
Keith Whitwell23caf202000-11-16 21:05:34 +0000308#define TRX_UI(f,n) (PTR_ELT(f,n) < 0 ? 0 : (GLuint) PTR_ELT(f,n))
309
310
311#define SZ 4
312#define INIT init_trans_4_GLint_raw
313#define DEST_4F trans_4_GLint_4f_raw
314#define DEST_4UB trans_4_GLint_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000315#define DEST_4US trans_4_GLint_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000316#include "m_trans_tmp.h"
317
318#define SZ 3
319#define INIT init_trans_3_GLint_raw
320#define DEST_4F trans_3_GLint_4f_raw
321#define DEST_4UB trans_3_GLint_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000322#define DEST_4US trans_3_GLint_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000323#define DEST_3F trans_3_GLint_3f_raw
324#include "m_trans_tmp.h"
325
326#define SZ 2
327#define INIT init_trans_2_GLint_raw
328#define DEST_4F trans_2_GLint_4f_raw
329#include "m_trans_tmp.h"
330
331#define SZ 1
332#define INIT init_trans_1_GLint_raw
333#define DEST_4F trans_1_GLint_4f_raw
334#define DEST_1UB trans_1_GLint_1ub_raw
335#define DEST_1UI trans_1_GLint_1ui_raw
336#include "m_trans_tmp.h"
337
338
339#undef SRC
340#undef SRC_IDX
341#undef TRX_3F
342#undef TRX_4F
343#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000344#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000345#undef TRX_UI
346
347
348/* GL_UNSIGNED_INT
349 */
350#define SRC GLuint
351#define SRC_IDX TYPE_IDX(GL_UNSIGNED_INT)
352#define TRX_3F(f,n) INT_TO_FLOAT( PTR_ELT(f,n) )
353#define TRX_4F(f,n) (GLfloat)( PTR_ELT(f,n) )
354#define TRX_UB(ub, f,n) ub = (GLubyte) (PTR_ELT(f,n) >> 24)
Brian Paul74b493a2001-01-24 00:04:58 +0000355#define TRX_US(us, f,n) us = (GLshort) (PTR_ELT(f,n) >> 16)
Keith Whitwell23caf202000-11-16 21:05:34 +0000356#define TRX_UI(f,n) PTR_ELT(f,n)
357
358
359#define SZ 4
360#define INIT init_trans_4_GLuint_raw
361#define DEST_4F trans_4_GLuint_4f_raw
362#define DEST_4UB trans_4_GLuint_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000363#define DEST_4US trans_4_GLuint_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000364#include "m_trans_tmp.h"
365
366#define SZ 3
367#define INIT init_trans_3_GLuint_raw
368#define DEST_4F trans_3_GLuint_4f_raw
369#define DEST_4UB trans_3_GLuint_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000370#define DEST_4US trans_3_GLuint_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000371#define DEST_3F trans_3_GLuint_3f_raw
372#include "m_trans_tmp.h"
373
374#define SZ 2
375#define INIT init_trans_2_GLuint_raw
376#define DEST_4F trans_2_GLuint_4f_raw
377#include "m_trans_tmp.h"
378
379#define SZ 1
380#define INIT init_trans_1_GLuint_raw
381#define DEST_4F trans_1_GLuint_4f_raw
382#define DEST_1UB trans_1_GLuint_1ub_raw
383#define DEST_1UI trans_1_GLuint_1ui_raw
384#include "m_trans_tmp.h"
385
386#undef SRC
387#undef SRC_IDX
388#undef TRX_3F
389#undef TRX_4F
390#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000391#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000392#undef TRX_UI
393
394
395/* GL_DOUBLE
396 */
397#define SRC GLdouble
398#define SRC_IDX TYPE_IDX(GL_DOUBLE)
Karl Schultz7b9fe822001-09-18 23:06:14 +0000399#define TRX_3F(f,n) (GLfloat) PTR_ELT(f,n)
400#define TRX_4F(f,n) (GLfloat) PTR_ELT(f,n)
Brian Paul74b493a2001-01-24 00:04:58 +0000401#define TRX_UB(ub,f,n) UNCLAMPED_FLOAT_TO_UBYTE(ub, PTR_ELT(f,n))
402#define TRX_US(us,f,n) UNCLAMPED_FLOAT_TO_USHORT(us, PTR_ELT(f,n))
Keith Whitwell23caf202000-11-16 21:05:34 +0000403#define TRX_UI(f,n) (GLuint) (GLint) PTR_ELT(f,n)
Karl Schultz7b9fe822001-09-18 23:06:14 +0000404#define TRX_1F(f,n) (GLfloat) PTR_ELT(f,n)
Keith Whitwell23caf202000-11-16 21:05:34 +0000405
406
407#define SZ 4
408#define INIT init_trans_4_GLdouble_raw
409#define DEST_4F trans_4_GLdouble_4f_raw
410#define DEST_4UB trans_4_GLdouble_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000411#define DEST_4US trans_4_GLdouble_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000412#include "m_trans_tmp.h"
413
414#define SZ 3
415#define INIT init_trans_3_GLdouble_raw
416#define DEST_4F trans_3_GLdouble_4f_raw
417#define DEST_4UB trans_3_GLdouble_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000418#define DEST_4US trans_3_GLdouble_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000419#define DEST_3F trans_3_GLdouble_3f_raw
420#include "m_trans_tmp.h"
421
422#define SZ 2
423#define INIT init_trans_2_GLdouble_raw
424#define DEST_4F trans_2_GLdouble_4f_raw
425#include "m_trans_tmp.h"
426
427#define SZ 1
428#define INIT init_trans_1_GLdouble_raw
429#define DEST_4F trans_1_GLdouble_4f_raw
430#define DEST_1UB trans_1_GLdouble_1ub_raw
431#define DEST_1UI trans_1_GLdouble_1ui_raw
432#define DEST_1F trans_1_GLdouble_1f_raw
433#include "m_trans_tmp.h"
434
435#undef SRC
436#undef SRC_IDX
437
438/* GL_FLOAT
439 */
440#define SRC GLfloat
441#define SRC_IDX TYPE_IDX(GL_FLOAT)
442#define SZ 4
Gareth Hughes22144ab2001-03-12 00:48:37 +0000443#define INIT init_trans_4_GLfloat_raw
444#define DEST_4UB trans_4_GLfloat_4ub_raw
445#define DEST_4US trans_4_GLfloat_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000446#define DEST_4F trans_4_GLfloat_4f_raw
447#include "m_trans_tmp.h"
448
449#define SZ 3
450#define INIT init_trans_3_GLfloat_raw
451#define DEST_4F trans_3_GLfloat_4f_raw
452#define DEST_4UB trans_3_GLfloat_4ub_raw
Brian Paul74b493a2001-01-24 00:04:58 +0000453#define DEST_4US trans_3_GLfloat_4us_raw
Keith Whitwell23caf202000-11-16 21:05:34 +0000454#define DEST_3F trans_3_GLfloat_3f_raw
455#include "m_trans_tmp.h"
456
457#define SZ 2
458#define INIT init_trans_2_GLfloat_raw
459#define DEST_4F trans_2_GLfloat_4f_raw
460#include "m_trans_tmp.h"
461
462#define SZ 1
463#define INIT init_trans_1_GLfloat_raw
464#define DEST_4F trans_1_GLfloat_4f_raw
465#define DEST_1UB trans_1_GLfloat_1ub_raw
466#define DEST_1UI trans_1_GLfloat_1ui_raw
467#define DEST_1F trans_1_GLfloat_1f_raw
468
469#include "m_trans_tmp.h"
470
471#undef SRC
472#undef SRC_IDX
473#undef TRX_3F
474#undef TRX_4F
475#undef TRX_UB
Brian Paul74b493a2001-01-24 00:04:58 +0000476#undef TRX_US
Keith Whitwell23caf202000-11-16 21:05:34 +0000477#undef TRX_UI
478
479
Brian Paul74b493a2001-01-24 00:04:58 +0000480static void trans_4_GLubyte_4ub_raw(GLubyte (*t)[4],
481 CONST void *Ptr,
482 GLuint stride,
483 ARGS )
Keith Whitwell23caf202000-11-16 21:05:34 +0000484{
485 const GLubyte *f = (GLubyte *) Ptr + SRC_START * stride;
486 GLuint i;
487
Gareth Hughes22144ab2001-03-12 00:48:37 +0000488 if (((((long) f | (long) stride)) & 3L) == 0L) {
Keith Whitwell23caf202000-11-16 21:05:34 +0000489 /* Aligned.
490 */
491 for (i = DST_START ; i < n ; i++, f += stride) {
492 COPY_4UBV( t[i], f );
493 }
494 } else {
495 for (i = DST_START ; i < n ; i++, f += stride) {
496 t[i][0] = f[0];
497 t[i][1] = f[1];
498 t[i][2] = f[2];
499 t[i][3] = f[3];
500 }
501 }
502}
503
504
505static void init_translate_raw(void)
506{
507 MEMSET( TAB(_1ui), 0, sizeof(TAB(_1ui)) );
508 MEMSET( TAB(_1ub), 0, sizeof(TAB(_1ub)) );
509 MEMSET( TAB(_3f), 0, sizeof(TAB(_3f)) );
510 MEMSET( TAB(_4ub), 0, sizeof(TAB(_4ub)) );
Brian Paul74b493a2001-01-24 00:04:58 +0000511 MEMSET( TAB(_4us), 0, sizeof(TAB(_4us)) );
Keith Whitwell23caf202000-11-16 21:05:34 +0000512 MEMSET( TAB(_4f), 0, sizeof(TAB(_4f)) );
513
Keith Whitwell23caf202000-11-16 21:05:34 +0000514 init_trans_4_GLbyte_raw();
515 init_trans_3_GLbyte_raw();
516 init_trans_2_GLbyte_raw();
517 init_trans_1_GLbyte_raw();
518 init_trans_1_GLubyte_raw();
519 init_trans_3_GLubyte_raw();
Keith Whitwell51c0c712001-04-28 08:39:17 +0000520 init_trans_4_GLubyte_raw();
Keith Whitwell23caf202000-11-16 21:05:34 +0000521 init_trans_4_GLshort_raw();
522 init_trans_3_GLshort_raw();
523 init_trans_2_GLshort_raw();
524 init_trans_1_GLshort_raw();
525 init_trans_4_GLushort_raw();
526 init_trans_3_GLushort_raw();
527 init_trans_2_GLushort_raw();
528 init_trans_1_GLushort_raw();
529 init_trans_4_GLint_raw();
530 init_trans_3_GLint_raw();
531 init_trans_2_GLint_raw();
532 init_trans_1_GLint_raw();
533 init_trans_4_GLuint_raw();
534 init_trans_3_GLuint_raw();
535 init_trans_2_GLuint_raw();
536 init_trans_1_GLuint_raw();
537 init_trans_4_GLdouble_raw();
538 init_trans_3_GLdouble_raw();
539 init_trans_2_GLdouble_raw();
540 init_trans_1_GLdouble_raw();
541 init_trans_4_GLfloat_raw();
542 init_trans_3_GLfloat_raw();
543 init_trans_2_GLfloat_raw();
544 init_trans_1_GLfloat_raw();
Keith Whitwell51c0c712001-04-28 08:39:17 +0000545
546 TAB(_4ub)[4][TYPE_IDX(GL_UNSIGNED_BYTE)] = trans_4_GLubyte_4ub_raw;
Keith Whitwell23caf202000-11-16 21:05:34 +0000547}
548
549
550#undef TAB
Brian Pauld18c08f2003-05-28 15:30:53 +0000551#ifdef CLASS
Keith Whitwell23caf202000-11-16 21:05:34 +0000552#undef CLASS
Brian Pauld18c08f2003-05-28 15:30:53 +0000553#endif
Keith Whitwell23caf202000-11-16 21:05:34 +0000554#undef ARGS
555#undef CHECK
556#undef SRC_START
557#undef DST_START
558#undef NEXT_F
559#undef NEXT_F2
560
561
562
563
564
Keith Whitwellcab974c2000-12-26 05:09:27 +0000565void _math_init_translate( void )
Keith Whitwell23caf202000-11-16 21:05:34 +0000566{
567 init_translate_raw();
568}
Keith Whitwellcab974c2000-12-26 05:09:27 +0000569
570
571
572void _math_trans_1f(GLfloat *to,
573 CONST void *ptr,
574 GLuint stride,
575 GLenum type,
576 GLuint start,
577 GLuint n )
578{
579 _math_trans_1f_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
580}
581
582void _math_trans_1ui(GLuint *to,
583 CONST void *ptr,
584 GLuint stride,
585 GLenum type,
586 GLuint start,
587 GLuint n )
588{
Gareth Hughes22144ab2001-03-12 00:48:37 +0000589 _math_trans_1ui_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000590}
591
592void _math_trans_1ub(GLubyte *to,
593 CONST void *ptr,
594 GLuint stride,
595 GLenum type,
596 GLuint start,
597 GLuint n )
598{
Gareth Hughes22144ab2001-03-12 00:48:37 +0000599 _math_trans_1ub_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000600}
601
602
603void _math_trans_4ub(GLubyte (*to)[4],
604 CONST void *ptr,
605 GLuint stride,
606 GLenum type,
607 GLuint size,
608 GLuint start,
609 GLuint n )
610{
Gareth Hughes22144ab2001-03-12 00:48:37 +0000611 _math_trans_4ub_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000612}
613
Keith Whitwell4eebc902001-02-20 18:28:52 +0000614void _math_trans_4chan( GLchan (*to)[4],
615 CONST void *ptr,
616 GLuint stride,
617 GLenum type,
618 GLuint size,
619 GLuint start,
620 GLuint n )
621{
622#if CHAN_TYPE == GL_UNSIGNED_BYTE
623 _math_trans_4ub( to, ptr, stride, type, size, start, n );
624#elif CHAN_TYPE == GL_UNSIGNED_SHORT
625 _math_trans_4us( to, ptr, stride, type, size, start, n );
626#elif CHAN_TYPE == GL_FLOAT
627 _math_trans_4f( to, ptr, stride, type, size, start, n );
628#endif
629}
630
Brian Paul74b493a2001-01-24 00:04:58 +0000631void _math_trans_4us(GLushort (*to)[4],
632 CONST void *ptr,
633 GLuint stride,
634 GLenum type,
635 GLuint size,
636 GLuint start,
637 GLuint n )
638{
Gareth Hughes22144ab2001-03-12 00:48:37 +0000639 _math_trans_4us_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
Brian Paul74b493a2001-01-24 00:04:58 +0000640}
641
Keith Whitwellcab974c2000-12-26 05:09:27 +0000642void _math_trans_4f(GLfloat (*to)[4],
643 CONST void *ptr,
644 GLuint stride,
645 GLenum type,
646 GLuint size,
647 GLuint start,
648 GLuint n )
649{
Gareth Hughes22144ab2001-03-12 00:48:37 +0000650 _math_trans_4f_tab[size][TYPE_IDX(type)]( to, ptr, stride, start, n );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000651}
652
653void _math_trans_3f(GLfloat (*to)[3],
654 CONST void *ptr,
655 GLuint stride,
656 GLenum type,
657 GLuint start,
658 GLuint n )
659{
Gareth Hughes22144ab2001-03-12 00:48:37 +0000660 _math_trans_3f_tab[TYPE_IDX(type)]( to, ptr, stride, start, n );
Keith Whitwellcab974c2000-12-26 05:09:27 +0000661}