867384b78dad096ea826bc4a1030fd69f42be241
[mesa.git] / src / mesa / math / m_trans_tmp.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5.1
4 *
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 *
7 * 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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * 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 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
24 */
25
26 /**
27 * \brief Templates for vector conversions.
28 * \author Keith Whitwell.
29 */
30
31 #ifdef DEST_4F
32 static void DEST_4F( GLfloat (*t)[4],
33 const void *ptr,
34 GLuint stride,
35 ARGS )
36 {
37 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
38 const GLubyte *first = f;
39 GLuint i;
40
41 (void) first;
42 (void) start;
43 for (i = DST_START ; i < n ; i++, NEXT_F) {
44 CHECK {
45 NEXT_F2;
46 if (SZ >= 1) t[i][0] = TRX_4F(f, 0);
47 if (SZ >= 2) t[i][1] = TRX_4F(f, 1);
48 if (SZ >= 3) t[i][2] = TRX_4F(f, 2);
49 if (SZ == 4) t[i][3] = TRX_4F(f, 3); else t[i][3] = 1.0;
50 }
51 }
52 }
53 #endif
54
55
56
57 #ifdef DEST_4FN
58 static void DEST_4FN( GLfloat (*t)[4],
59 const void *ptr,
60 GLuint stride,
61 ARGS )
62 {
63 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
64 const GLubyte *first = f;
65 GLuint i;
66
67 (void) first;
68 (void) start;
69 for (i = DST_START ; i < n ; i++, NEXT_F) {
70 CHECK {
71 NEXT_F2;
72 if (SZ >= 1) t[i][0] = TRX_4FN(f, 0);
73 if (SZ >= 2) t[i][1] = TRX_4FN(f, 1);
74 if (SZ >= 3) t[i][2] = TRX_4FN(f, 2);
75 if (SZ == 4) t[i][3] = TRX_4FN(f, 3); else t[i][3] = 1.0;
76 }
77 }
78 }
79 #endif
80
81
82 #ifdef DEST_3FN
83 static void DEST_3FN( GLfloat (*t)[3],
84 const void *ptr,
85 GLuint stride,
86 ARGS )
87 {
88 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
89 const GLubyte *first = f;
90 GLuint i;
91 (void) first;
92 (void) start;
93 for (i = DST_START ; i < n ; i++, NEXT_F) {
94 CHECK {
95 NEXT_F2;
96 t[i][0] = TRX_3FN(f, 0);
97 t[i][1] = TRX_3FN(f, 1);
98 t[i][2] = TRX_3FN(f, 2);
99 }
100 }
101 }
102 #endif
103
104 #ifdef DEST_1F
105 static void DEST_1F( GLfloat *t,
106 const void *ptr,
107 GLuint stride,
108 ARGS )
109 {
110 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
111 const GLubyte *first = f;
112 GLuint i;
113 (void) first;
114 (void) start;
115 for (i = DST_START ; i < n ; i++, NEXT_F) {
116 CHECK {
117 NEXT_F2;
118 t[i] = TRX_1F(f, 0);
119 }
120 }
121 }
122 #endif
123
124 #ifdef DEST_4UB
125 static void DEST_4UB( GLubyte (*t)[4],
126 const void *ptr,
127 GLuint stride,
128 ARGS )
129 {
130 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
131 const GLubyte *first = f;
132 GLuint i;
133 (void) start;
134 (void) first;
135 for (i = DST_START ; i < n ; i++, NEXT_F) {
136 CHECK {
137 NEXT_F2;
138 if (SZ >= 1) TRX_UB(t[i][0], f, 0);
139 if (SZ >= 2) TRX_UB(t[i][1], f, 1);
140 if (SZ >= 3) TRX_UB(t[i][2], f, 2);
141 if (SZ == 4) TRX_UB(t[i][3], f, 3); else t[i][3] = 255;
142 }
143 }
144 }
145 #endif
146
147
148 #ifdef DEST_4US
149 static void DEST_4US( GLushort (*t)[4],
150 const void *ptr,
151 GLuint stride,
152 ARGS )
153 {
154 const GLubyte *f = (GLubyte *) ((GLubyte *) ptr + SRC_START * stride);
155 const GLubyte *first = f;
156 GLuint i;
157 (void) start;
158 (void) first;
159 for (i = DST_START ; i < n ; i++, NEXT_F) {
160 CHECK {
161 NEXT_F2;
162 if (SZ >= 1) TRX_US(t[i][0], f, 0);
163 if (SZ >= 2) TRX_US(t[i][1], f, 1);
164 if (SZ >= 3) TRX_US(t[i][2], f, 2);
165 if (SZ == 4) TRX_US(t[i][3], f, 3); else t[i][3] = 65535;
166 }
167 }
168 }
169 #endif
170
171
172 #ifdef DEST_1UB
173 static void DEST_1UB( GLubyte *t,
174 const void *ptr,
175 GLuint stride,
176 ARGS )
177 {
178 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
179 const GLubyte *first = f;
180 GLuint i;
181 (void) start;
182 (void) first;
183 for (i = DST_START ; i < n ; i++, NEXT_F) {
184 CHECK {
185 NEXT_F2;
186 TRX_UB(t[i], f, 0);
187 }
188 }
189 }
190 #endif
191
192
193 #ifdef DEST_1UI
194 static void DEST_1UI( GLuint *t,
195 const void *ptr,
196 GLuint stride,
197 ARGS )
198 {
199 const GLubyte *f = (GLubyte *) ptr + SRC_START * stride;
200 const GLubyte *first = f;
201 GLuint i;
202 (void) start;
203 (void) first;
204
205 for (i = DST_START ; i < n ; i++, NEXT_F) {
206 CHECK {
207 NEXT_F2;
208 t[i] = TRX_UI(f, 0);
209 }
210 }
211 }
212 #endif
213
214
215 static void INIT(void)
216 {
217 #ifdef DEST_1UI
218 ASSERT(SZ == 1);
219 TAB(_1ui)[SRC_IDX] = DEST_1UI;
220 #endif
221 #ifdef DEST_1UB
222 ASSERT(SZ == 1);
223 TAB(_1ub)[SRC_IDX] = DEST_1UB;
224 #endif
225 #ifdef DEST_1F
226 ASSERT(SZ == 1);
227 TAB(_1f)[SRC_IDX] = DEST_1F;
228 #endif
229 #ifdef DEST_3FN
230 ASSERT(SZ == 3);
231 TAB(_3fn)[SRC_IDX] = DEST_3FN;
232 #endif
233 #ifdef DEST_4UB
234 TAB(_4ub)[SZ][SRC_IDX] = DEST_4UB;
235 #endif
236 #ifdef DEST_4US
237 TAB(_4us)[SZ][SRC_IDX] = DEST_4US;
238 #endif
239 #ifdef DEST_4F
240 TAB(_4f)[SZ][SRC_IDX] = DEST_4F;
241 #endif
242 #ifdef DEST_4FN
243 TAB(_4fn)[SZ][SRC_IDX] = DEST_4FN;
244 #endif
245
246 }
247
248
249 #ifdef INIT
250 #undef INIT
251 #endif
252 #ifdef DEST_1UI
253 #undef DEST_1UI
254 #endif
255 #ifdef DEST_1UB
256 #undef DEST_1UB
257 #endif
258 #ifdef DEST_4UB
259 #undef DEST_4UB
260 #endif
261 #ifdef DEST_4US
262 #undef DEST_4US
263 #endif
264 #ifdef DEST_3FN
265 #undef DEST_3FN
266 #endif
267 #ifdef DEST_4F
268 #undef DEST_4F
269 #endif
270 #ifdef DEST_4FN
271 #undef DEST_4FN
272 #endif
273 #ifdef DEST_1F
274 #undef DEST_1F
275 #endif
276 #ifdef SZ
277 #undef SZ
278 #endif
279 #ifdef TAG
280 #undef TAG
281 #endif
282