Added most of the infrastructure required to support
[mesa.git] / src / mesa / main / texformat_tmp.h
1 /**
2 * \file texformat_tmp.h
3 * Texel fetch functions template.
4 *
5 * This template file is used by texformat.c to generate texel fetch functions
6 * for 1-D, 2-D and 3-D texture images.
7 *
8 * It should be expanded by definining \p DIM as the number texture dimensions
9 * (1, 2 or 3). According to the value of \p DIM a serie of macros is defined
10 * for the texel lookup in the gl_texture_image::Data.
11 *
12 * \sa texformat.c and FetchTexel.
13 *
14 * \author Gareth Hughes
15 * \author Brian Paul
16 */
17
18 /*
19 * Mesa 3-D graphics library
20 * Version: 5.1
21 *
22 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
23 *
24 * Permission is hereby granted, free of charge, to any person obtaining a
25 * copy of this software and associated documentation files (the "Software"),
26 * to deal in the Software without restriction, including without limitation
27 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
28 * and/or sell copies of the Software, and to permit persons to whom the
29 * Software is furnished to do so, subject to the following conditions:
30 *
31 * The above copyright notice and this permission notice shall be included
32 * in all copies or substantial portions of the Software.
33 *
34 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
35 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
36 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
37 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
38 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
39 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
40 */
41
42
43 #if DIM == 1
44
45 #define CHAN_SRC( t, i, j, k, sz ) \
46 ((GLchan *)(t)->Data + (i) * (sz))
47 #define UBYTE_SRC( t, i, j, k, sz ) \
48 ((GLubyte *)(t)->Data + (i) * (sz))
49 #define USHORT_SRC( t, i, j, k ) \
50 ((GLushort *)(t)->Data + (i))
51 #define FLOAT_SRC( t, i, j, k ) \
52 ((GLfloat *)(t)->Data + (i))
53
54 #define FETCH(x) fetch_1d_texel_##x
55
56 #elif DIM == 2
57
58 #define CHAN_SRC( t, i, j, k, sz ) \
59 ((GLchan *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz))
60 #define UBYTE_SRC( t, i, j, k, sz ) \
61 ((GLubyte *)(t)->Data + ((t)->RowStride * (j) + (i)) * (sz))
62 #define USHORT_SRC( t, i, j, k ) \
63 ((GLushort *)(t)->Data + ((t)->RowStride * (j) + (i)))
64 #define FLOAT_SRC( t, i, j, k ) \
65 ((GLfloat *)(t)->Data + ((t)->RowStride * (j) + (i)))
66
67 #define FETCH(x) fetch_2d_texel_##x
68
69 #elif DIM == 3
70
71 #define CHAN_SRC( t, i, j, k, sz ) \
72 (GLchan *)(t)->Data + (((t)->Height * (k) + (j)) * \
73 (t)->RowStride + (i)) * (sz)
74 #define UBYTE_SRC( t, i, j, k, sz ) \
75 ((GLubyte *)(t)->Data + (((t)->Height * (k) + (j)) * \
76 (t)->RowStride + (i)) * (sz))
77 #define USHORT_SRC( t, i, j, k ) \
78 ((GLushort *)(t)->Data + (((t)->Height * (k) + (j)) * \
79 (t)->RowStride + (i)))
80 #define FLOAT_SRC( t, i, j, k ) \
81 ((GLfloat *)(t)->Data + (((t)->Height * (k) + (j)) * \
82 (t)->RowStride + (i)))
83
84 #define FETCH(x) fetch_3d_texel_##x
85
86 #else
87 #error illegal number of texture dimensions
88 #endif
89
90
91 static void FETCH(rgba)( const struct gl_texture_image *texImage,
92 GLint i, GLint j, GLint k, GLvoid *texel )
93 {
94 const GLchan *src = CHAN_SRC( texImage, i, j, k, 4 );
95 GLchan *rgba = (GLchan *) texel;
96 COPY_CHAN4( rgba, src );
97 }
98
99 static void FETCH(rgb)( const struct gl_texture_image *texImage,
100 GLint i, GLint j, GLint k, GLvoid *texel )
101 {
102 const GLchan *src = CHAN_SRC( texImage, i, j, k, 3 );
103 GLchan *rgba = (GLchan *) texel;
104 rgba[RCOMP] = src[0];
105 rgba[GCOMP] = src[1];
106 rgba[BCOMP] = src[2];
107 rgba[ACOMP] = CHAN_MAX;
108 }
109
110 static void FETCH(alpha)( const struct gl_texture_image *texImage,
111 GLint i, GLint j, GLint k, GLvoid *texel )
112 {
113 const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
114 GLchan *rgba = (GLchan *) texel;
115 rgba[RCOMP] = 0;
116 rgba[GCOMP] = 0;
117 rgba[BCOMP] = 0;
118 rgba[ACOMP] = src[0];
119 }
120
121 static void FETCH(luminance)( const struct gl_texture_image *texImage,
122 GLint i, GLint j, GLint k, GLvoid *texel )
123 {
124 const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
125 GLchan *rgba = (GLchan *) texel;
126 rgba[RCOMP] = src[0];
127 rgba[GCOMP] = src[0];
128 rgba[BCOMP] = src[0];
129 rgba[ACOMP] = CHAN_MAX;
130 }
131
132 static void FETCH(luminance_alpha)( const struct gl_texture_image *texImage,
133 GLint i, GLint j, GLint k, GLvoid *texel )
134 {
135 const GLchan *src = CHAN_SRC( texImage, i, j, k, 2 );
136 GLchan *rgba = (GLchan *) texel;
137 rgba[RCOMP] = src[0];
138 rgba[GCOMP] = src[0];
139 rgba[BCOMP] = src[0];
140 rgba[ACOMP] = src[1];
141 }
142
143 static void FETCH(intensity)( const struct gl_texture_image *texImage,
144 GLint i, GLint j, GLint k, GLvoid *texel )
145 {
146 const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
147 GLchan *rgba = (GLchan *) texel;
148 rgba[RCOMP] = src[0];
149 rgba[GCOMP] = src[0];
150 rgba[BCOMP] = src[0];
151 rgba[ACOMP] = src[0];
152 }
153
154 static void FETCH(color_index)( const struct gl_texture_image *texImage,
155 GLint i, GLint j, GLint k, GLvoid *texel )
156 {
157 const GLchan *src = CHAN_SRC( texImage, i, j, k, 1 );
158 GLchan *index = (GLchan *) texel;
159 *index = *src;
160 }
161
162 static void FETCH(depth_component)( const struct gl_texture_image *texImage,
163 GLint i, GLint j, GLint k, GLvoid *texel )
164 {
165 const GLfloat *src = FLOAT_SRC( texImage, i, j, k );
166 GLfloat *depth = (GLfloat *) texel;
167 *depth = *src;
168 }
169
170 static void FETCH(rgba8888)( const struct gl_texture_image *texImage,
171 GLint i, GLint j, GLint k, GLvoid *texel )
172 {
173 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
174 GLchan *rgba = (GLchan *) texel;
175 rgba[RCOMP] = UBYTE_TO_CHAN( src[3] );
176 rgba[GCOMP] = UBYTE_TO_CHAN( src[2] );
177 rgba[BCOMP] = UBYTE_TO_CHAN( src[1] );
178 rgba[ACOMP] = UBYTE_TO_CHAN( src[0] );
179 }
180
181 static void FETCH(argb8888)( const struct gl_texture_image *texImage,
182 GLint i, GLint j, GLint k, GLvoid *texel )
183 {
184 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
185 GLchan *rgba = (GLchan *) texel;
186 rgba[RCOMP] = UBYTE_TO_CHAN( src[2] );
187 rgba[GCOMP] = UBYTE_TO_CHAN( src[1] );
188 rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
189 rgba[ACOMP] = UBYTE_TO_CHAN( src[3] );
190 }
191
192 static void FETCH(rgb888)( const struct gl_texture_image *texImage,
193 GLint i, GLint j, GLint k, GLvoid *texel )
194 {
195 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 );
196 GLchan *rgba = (GLchan *) texel;
197 rgba[RCOMP] = UBYTE_TO_CHAN( src[2] );
198 rgba[GCOMP] = UBYTE_TO_CHAN( src[1] );
199 rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
200 rgba[ACOMP] = CHAN_MAX;
201 }
202
203 static void FETCH(rgb565)( const struct gl_texture_image *texImage,
204 GLint i, GLint j, GLint k, GLvoid *texel )
205 {
206 const GLushort *src = USHORT_SRC( texImage, i, j, k );
207 const GLushort s = *src;
208 GLchan *rgba = (GLchan *) texel;
209 rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 );
210 rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc );
211 rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 );
212 rgba[ACOMP] = CHAN_MAX;
213 }
214
215 static void FETCH(argb4444)( const struct gl_texture_image *texImage,
216 GLint i, GLint j, GLint k, GLvoid *texel )
217 {
218 const GLushort *src = USHORT_SRC( texImage, i, j, k );
219 const GLushort s = *src;
220 GLchan *rgba = (GLchan *) texel;
221 rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf );
222 rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf );
223 rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf );
224 rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf );
225 }
226
227 static void FETCH(argb1555)( const struct gl_texture_image *texImage,
228 GLint i, GLint j, GLint k, GLvoid *texel )
229 {
230 const GLushort *src = USHORT_SRC( texImage, i, j, k );
231 const GLushort s = *src;
232 GLchan *rgba = (GLchan *) texel;
233 rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f );
234 rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f );
235 rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f );
236 rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 );
237 }
238
239 static void FETCH(al88)( const struct gl_texture_image *texImage,
240 GLint i, GLint j, GLint k, GLvoid *texel )
241 {
242 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 );
243 GLchan *rgba = (GLchan *) texel;
244 rgba[RCOMP] = UBYTE_TO_CHAN( src[0] );
245 rgba[GCOMP] = UBYTE_TO_CHAN( src[0] );
246 rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
247 rgba[ACOMP] = UBYTE_TO_CHAN( src[1] );
248 }
249
250 static void FETCH(rgb332)( const struct gl_texture_image *texImage,
251 GLint i, GLint j, GLint k, GLvoid *texel )
252 {
253 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
254 const GLubyte s = *src;
255 GLchan *rgba = (GLchan *) texel;
256 rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 );
257 rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 );
258 rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 );
259 rgba[ACOMP] = CHAN_MAX;
260 }
261
262 static void FETCH(a8)( const struct gl_texture_image *texImage,
263 GLint i, GLint j, GLint k, GLvoid *texel )
264 {
265 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
266 GLchan *rgba = (GLchan *) texel;
267 rgba[RCOMP] = 0;
268 rgba[GCOMP] = 0;
269 rgba[BCOMP] = 0;
270 rgba[ACOMP] = UBYTE_TO_CHAN( src[0] );
271 }
272
273 static void FETCH(l8)( const struct gl_texture_image *texImage,
274 GLint i, GLint j, GLint k, GLvoid *texel )
275 {
276 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
277 GLchan *rgba = (GLchan *) texel;
278 rgba[RCOMP] = UBYTE_TO_CHAN( src[0] );
279 rgba[GCOMP] = UBYTE_TO_CHAN( src[0] );
280 rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
281 rgba[ACOMP] = CHAN_MAX;
282 }
283
284 static void FETCH(i8)( const struct gl_texture_image *texImage,
285 GLint i, GLint j, GLint k, GLvoid *texel )
286 {
287 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
288 GLchan *rgba = (GLchan *) texel;
289 rgba[RCOMP] = UBYTE_TO_CHAN( src[0] );
290 rgba[GCOMP] = UBYTE_TO_CHAN( src[0] );
291 rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
292 rgba[ACOMP] = UBYTE_TO_CHAN( src[0] );
293 }
294
295 static void FETCH(ci8)( const struct gl_texture_image *texImage,
296 GLint i, GLint j, GLint k, GLvoid *texel )
297 {
298 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
299 GLchan *index = (GLchan *) texel;
300 *index = UBYTE_TO_CHAN( *src );
301 }
302
303 /* XXX this may break if GLchan != GLubyte */
304 static void FETCH(ycbcr)( const struct gl_texture_image *texImage,
305 GLint i, GLint j, GLint k, GLvoid *texel )
306 {
307 const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */
308 const GLushort *src1 = src0 + 1; /* odd */
309 const GLubyte y0 = (*src0 >> 8) & 0xff; /* luminance */
310 const GLubyte cb = *src0 & 0xff; /* chroma U */
311 const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */
312 const GLubyte cr = *src1 & 0xff; /* chroma V */
313 GLchan *rgba = (GLchan *) texel;
314 GLint r, g, b;
315 if (i & 1) {
316 /* odd pixel: use y1,cr,cb */
317 r = (GLint) (1.164 * (y1-16) + 1.596 * (cr-128));
318 g = (GLint) (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
319 b = (GLint) (1.164 * (y1-16) + 2.018 * (cb-128));
320 }
321 else {
322 /* even pixel: use y0,cr,cb */
323 r = (GLint) (1.164 * (y0-16) + 1.596 * (cr-128));
324 g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
325 b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128));
326 }
327 rgba[RCOMP] = CLAMP(r, 0, CHAN_MAX);
328 rgba[GCOMP] = CLAMP(g, 0, CHAN_MAX);
329 rgba[BCOMP] = CLAMP(b, 0, CHAN_MAX);
330 rgba[ACOMP] = CHAN_MAX;
331 }
332
333 /* XXX this may break if GLchan != GLubyte */
334 static void FETCH(ycbcr_rev)( const struct gl_texture_image *texImage,
335 GLint i, GLint j, GLint k, GLvoid *texel )
336 {
337 const GLushort *src0 = USHORT_SRC( texImage, (i & ~1), j, k ); /* even */
338 const GLushort *src1 = src0 + 1; /* odd */
339 const GLubyte y0 = *src0 & 0xff; /* luminance */
340 const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma U */
341 const GLubyte y1 = *src1 & 0xff; /* luminance */
342 const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma V */
343 GLchan *rgba = (GLchan *) texel;
344 GLint r, g, b;
345 if (i & 1) {
346 /* odd pixel: use y1,cr,cb */
347 r = (GLint) (1.164 * (y1-16) + 1.596 * (cr-128));
348 g = (GLint) (1.164 * (y1-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
349 b = (GLint) (1.164 * (y1-16) + 2.018 * (cb-128));
350 }
351 else {
352 /* even pixel: use y0,cr,cb */
353 r = (GLint) (1.164 * (y0-16) + 1.596 * (cr-128));
354 g = (GLint) (1.164 * (y0-16) - 0.813 * (cr-128) - 0.391 * (cb-128));
355 b = (GLint) (1.164 * (y0-16) + 2.018 * (cb-128));
356 }
357 rgba[RCOMP] = CLAMP(r, 0, CHAN_MAX);
358 rgba[GCOMP] = CLAMP(g, 0, CHAN_MAX);
359 rgba[BCOMP] = CLAMP(b, 0, CHAN_MAX);
360 rgba[ACOMP] = CHAN_MAX;
361 }
362
363
364 #if DIM == 2
365 static void FETCH(rgb_dxt1)( const struct gl_texture_image *texImage,
366 GLint i, GLint j, GLint k, GLvoid *texel )
367 {
368 /* Extract the (i,j) pixel from texImage->Data and return it
369 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
370 */
371 }
372 #endif
373
374 #if DIM == 2
375 static void FETCH(rgba_dxt1)( const struct gl_texture_image *texImage,
376 GLint i, GLint j, GLint k, GLvoid *texel )
377 {
378 /* Extract the (i,j) pixel from texImage->Data and return it
379 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
380 */
381 }
382 #endif
383
384 #if DIM == 2
385 static void FETCH(rgba_dxt3)( const struct gl_texture_image *texImage,
386 GLint i, GLint j, GLint k, GLvoid *texel )
387 {
388 /* Extract the (i,j) pixel from texImage->Data and return it
389 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
390 */
391 }
392 #endif
393
394 #if DIM == 2
395 static void FETCH(rgba_dxt5)( const struct gl_texture_image *texImage,
396 GLint i, GLint j, GLint k, GLvoid *texel )
397 {
398 /* Extract the (i,j) pixel from texImage->Data and return it
399 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
400 */
401 }
402 #endif
403
404
405
406 /* big-endian */
407
408 #if 0
409 static void FETCH(abgr8888)( const struct gl_texture_image *texImage,
410 GLint i, GLint j, GLint k, GLvoid *texel )
411 {
412 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
413 GLchan *rgba = (GLchan *) texel;
414 rgba[RCOMP] = UBYTE_TO_CHAN( src[3] );
415 rgba[GCOMP] = UBYTE_TO_CHAN( src[2] );
416 rgba[BCOMP] = UBYTE_TO_CHAN( src[1] );
417 rgba[ACOMP] = UBYTE_TO_CHAN( src[0] );
418 }
419
420 static void FETCH(bgra8888)( const struct gl_texture_image *texImage,
421 GLint i, GLint j, GLint k, GLvoid *texel )
422 {
423 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 4 );
424 GLchan *rgba = (GLchan *) texel;
425 rgba[RCOMP] = UBYTE_TO_CHAN( src[2] );
426 rgba[GCOMP] = UBYTE_TO_CHAN( src[1] );
427 rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
428 rgba[ACOMP] = UBYTE_TO_CHAN( src[3] );
429 }
430
431 static void FETCH(bgr888)( const struct gl_texture_image *texImage,
432 GLint i, GLint j, GLint k, GLvoid *texel )
433 {
434 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 3 );
435 GLchan *rgba = (GLchan *) texel;
436 rgba[RCOMP] = UBYTE_TO_CHAN( src[2] );
437 rgba[GCOMP] = UBYTE_TO_CHAN( src[1] );
438 rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
439 rgba[ACOMP] = CHAN_MAX;
440 }
441
442 static void FETCH(bgr565)( const struct gl_texture_image *texImage,
443 GLint i, GLint j, GLint k, GLvoid *texel )
444 {
445 const GLushort *src = USHORT_SRC( texImage, i, j, k );
446 const GLushort s = *src;
447 GLchan *rgba = (GLchan *) texel;
448 rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf8) * 255 / 0xf8 );
449 rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 3) & 0xfc) * 255 / 0xfc );
450 rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xf8) * 255 / 0xf8 );
451 rgba[ACOMP] = CHAN_MAX;
452 }
453
454 static void FETCH(bgra4444)( const struct gl_texture_image *texImage,
455 GLint i, GLint j, GLint k, GLvoid *texel )
456 {
457 const GLushort *src = USHORT_SRC( texImage, i, j, k );
458 const GLushort s = *src;
459 GLchan *rgba = (GLchan *) texel;
460 rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 8) & 0xf) * 255 / 0xf );
461 rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 4) & 0xf) * 255 / 0xf );
462 rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0xf) * 255 / 0xf );
463 rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 12) & 0xf) * 255 / 0xf );
464 }
465
466 static void FETCH(bgra5551)( const struct gl_texture_image *texImage,
467 GLint i, GLint j, GLint k, GLvoid *texel )
468 {
469 const GLushort *src = USHORT_SRC( texImage, i, j, k );
470 const GLushort s = *src;
471 GLchan *rgba = (GLchan *) texel;
472 rgba[RCOMP] = UBYTE_TO_CHAN( ((s >> 10) & 0x1f) * 255 / 0x1f );
473 rgba[GCOMP] = UBYTE_TO_CHAN( ((s >> 5) & 0x1f) * 255 / 0x1f );
474 rgba[BCOMP] = UBYTE_TO_CHAN( ((s ) & 0x1f) * 255 / 0x1f );
475 rgba[ACOMP] = UBYTE_TO_CHAN( ((s >> 15) & 0x01) * 255 );
476 }
477
478 static void FETCH(la88)( const struct gl_texture_image *texImage,
479 GLint i, GLint j, GLint k, GLvoid *texel )
480 {
481 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 2 );
482 GLchan *rgba = (GLchan *) texel;
483 rgba[RCOMP] = UBYTE_TO_CHAN( src[0] );
484 rgba[GCOMP] = UBYTE_TO_CHAN( src[0] );
485 rgba[BCOMP] = UBYTE_TO_CHAN( src[0] );
486 rgba[ACOMP] = UBYTE_TO_CHAN( src[1] );
487 }
488
489 static void FETCH(bgr233)( const struct gl_texture_image *texImage,
490 GLint i, GLint j, GLint k, GLvoid *texel )
491 {
492 const GLubyte *src = UBYTE_SRC( texImage, i, j, k, 1 );
493 const GLubyte s = *src;
494 GLchan *rgba = (GLchan *) texel;
495 rgba[RCOMP] = UBYTE_TO_CHAN( ((s ) & 0xe0) * 255 / 0xe0 );
496 rgba[GCOMP] = UBYTE_TO_CHAN( ((s << 3) & 0xe0) * 255 / 0xe0 );
497 rgba[BCOMP] = UBYTE_TO_CHAN( ((s << 5) & 0xc0) * 255 / 0xc0 );
498 rgba[ACOMP] = CHAN_MAX;
499 }
500 #endif
501
502
503 #undef CHAN_SRC
504 #undef UBYTE_SRC
505 #undef USHORT_SRC
506 #undef FLOAT_SRC
507 #undef FETCH
508 #undef DIM