14eb0463abf4d9d6e92c16fe49f30ec93e8e809f
2 * \file texformat_tmp.h
3 * Texel fetch functions template.
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.
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.
12 * \sa texformat.c and FetchTexel.
14 * \author Gareth Hughes
19 * Mesa 3-D graphics library
22 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
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:
31 * The above copyright notice and this permission notice shall be included
32 * in all copies or substantial portions of the Software.
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.
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))
54 #define FETCH(x) fetch_1d_texel_##x
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)))
67 #define FETCH(x) fetch_2d_texel_##x
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)))
84 #define FETCH(x) fetch_3d_texel_##x
87 #error illegal number of texture dimensions
91 static void FETCH(rgba
)( const struct gl_texture_image
*texImage
,
92 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
94 const GLchan
*src
= CHAN_SRC( texImage
, i
, j
, k
, 4 );
95 GLchan
*rgba
= (GLchan
*) texel
;
96 COPY_CHAN4( rgba
, src
);
99 static void FETCH(rgb
)( const struct gl_texture_image
*texImage
,
100 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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
;
110 static void FETCH(alpha
)( const struct gl_texture_image
*texImage
,
111 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
113 const GLchan
*src
= CHAN_SRC( texImage
, i
, j
, k
, 1 );
114 GLchan
*rgba
= (GLchan
*) texel
;
118 rgba
[ACOMP
] = src
[0];
121 static void FETCH(luminance
)( const struct gl_texture_image
*texImage
,
122 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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
;
132 static void FETCH(luminance_alpha
)( const struct gl_texture_image
*texImage
,
133 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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];
143 static void FETCH(intensity
)( const struct gl_texture_image
*texImage
,
144 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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];
154 static void FETCH(color_index
)( const struct gl_texture_image
*texImage
,
155 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
157 const GLchan
*src
= CHAN_SRC( texImage
, i
, j
, k
, 1 );
158 GLchan
*index
= (GLchan
*) texel
;
162 static void FETCH(depth_component
)( const struct gl_texture_image
*texImage
,
163 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
165 const GLfloat
*src
= FLOAT_SRC( texImage
, i
, j
, k
);
166 GLfloat
*depth
= (GLfloat
*) texel
;
170 static void FETCH(rgba8888
)( const struct gl_texture_image
*texImage
,
171 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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] );
181 static void FETCH(argb8888
)( const struct gl_texture_image
*texImage
,
182 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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] );
192 static void FETCH(rgb888
)( const struct gl_texture_image
*texImage
,
193 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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
;
203 static void FETCH(rgb565
)( const struct gl_texture_image
*texImage
,
204 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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
;
215 static void FETCH(argb4444
)( const struct gl_texture_image
*texImage
,
216 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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 );
227 static void FETCH(argb1555
)( const struct gl_texture_image
*texImage
,
228 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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 );
239 static void FETCH(al88
)( const struct gl_texture_image
*texImage
,
240 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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] );
250 static void FETCH(rgb332
)( const struct gl_texture_image
*texImage
,
251 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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
;
262 static void FETCH(a8
)( const struct gl_texture_image
*texImage
,
263 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
265 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 1 );
266 GLchan
*rgba
= (GLchan
*) texel
;
270 rgba
[ACOMP
] = UBYTE_TO_CHAN( src
[0] );
273 static void FETCH(l8
)( const struct gl_texture_image
*texImage
,
274 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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
;
284 static void FETCH(i8
)( const struct gl_texture_image
*texImage
,
285 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
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] );
295 static void FETCH(ci8
)( const struct gl_texture_image
*texImage
,
296 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
298 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 1 );
299 GLchan
*index
= (GLchan
*) texel
;
300 *index
= UBYTE_TO_CHAN( *src
);
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
)
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
;
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));
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));
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
;
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
)
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 V */
341 const GLubyte y1
= *src1
& 0xff; /* luminance */
342 const GLubyte cb
= (*src1
>> 8) & 0xff; /* chroma U */
343 GLchan
*rgba
= (GLchan
*) texel
;
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));
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));
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
;
365 static void FETCH(rgb_fxt1
)( const struct gl_texture_image
*texImage
,
366 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
368 /* Extract the (i,j) pixel from texImage->Data and return it
369 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
375 static void FETCH(rgba_fxt1
)( const struct gl_texture_image
*texImage
,
376 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
378 /* Extract the (i,j) pixel from texImage->Data and return it
379 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
386 static void FETCH(rgb_dxt1
)( const struct gl_texture_image
*texImage
,
387 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
389 /* Extract the (i,j) pixel from texImage->Data and return it
390 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
396 static void FETCH(rgba_dxt1
)( const struct gl_texture_image
*texImage
,
397 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
399 /* Extract the (i,j) pixel from texImage->Data and return it
400 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
406 static void FETCH(rgba_dxt3
)( const struct gl_texture_image
*texImage
,
407 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
409 /* Extract the (i,j) pixel from texImage->Data and return it
410 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
416 static void FETCH(rgba_dxt5
)( const struct gl_texture_image
*texImage
,
417 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
419 /* Extract the (i,j) pixel from texImage->Data and return it
420 * in texel[RCOMP], texel[GCOMP], texel[BCOMP], texel[ACOMP].
430 static void FETCH(abgr8888
)( const struct gl_texture_image
*texImage
,
431 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
433 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 4 );
434 GLchan
*rgba
= (GLchan
*) texel
;
435 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[3] );
436 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[2] );
437 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[1] );
438 rgba
[ACOMP
] = UBYTE_TO_CHAN( src
[0] );
441 static void FETCH(bgra8888
)( const struct gl_texture_image
*texImage
,
442 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
444 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 4 );
445 GLchan
*rgba
= (GLchan
*) texel
;
446 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[2] );
447 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[1] );
448 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[0] );
449 rgba
[ACOMP
] = UBYTE_TO_CHAN( src
[3] );
452 static void FETCH(bgr888
)( const struct gl_texture_image
*texImage
,
453 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
455 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 3 );
456 GLchan
*rgba
= (GLchan
*) texel
;
457 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[2] );
458 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[1] );
459 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[0] );
460 rgba
[ACOMP
] = CHAN_MAX
;
463 static void FETCH(bgr565
)( const struct gl_texture_image
*texImage
,
464 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
466 const GLushort
*src
= USHORT_SRC( texImage
, i
, j
, k
);
467 const GLushort s
= *src
;
468 GLchan
*rgba
= (GLchan
*) texel
;
469 rgba
[RCOMP
] = UBYTE_TO_CHAN( ((s
>> 8) & 0xf8) * 255 / 0xf8 );
470 rgba
[GCOMP
] = UBYTE_TO_CHAN( ((s
>> 3) & 0xfc) * 255 / 0xfc );
471 rgba
[BCOMP
] = UBYTE_TO_CHAN( ((s
<< 3) & 0xf8) * 255 / 0xf8 );
472 rgba
[ACOMP
] = CHAN_MAX
;
475 static void FETCH(bgra4444
)( const struct gl_texture_image
*texImage
,
476 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
478 const GLushort
*src
= USHORT_SRC( texImage
, i
, j
, k
);
479 const GLushort s
= *src
;
480 GLchan
*rgba
= (GLchan
*) texel
;
481 rgba
[RCOMP
] = UBYTE_TO_CHAN( ((s
>> 8) & 0xf) * 255 / 0xf );
482 rgba
[GCOMP
] = UBYTE_TO_CHAN( ((s
>> 4) & 0xf) * 255 / 0xf );
483 rgba
[BCOMP
] = UBYTE_TO_CHAN( ((s
) & 0xf) * 255 / 0xf );
484 rgba
[ACOMP
] = UBYTE_TO_CHAN( ((s
>> 12) & 0xf) * 255 / 0xf );
487 static void FETCH(bgra5551
)( const struct gl_texture_image
*texImage
,
488 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
490 const GLushort
*src
= USHORT_SRC( texImage
, i
, j
, k
);
491 const GLushort s
= *src
;
492 GLchan
*rgba
= (GLchan
*) texel
;
493 rgba
[RCOMP
] = UBYTE_TO_CHAN( ((s
>> 10) & 0x1f) * 255 / 0x1f );
494 rgba
[GCOMP
] = UBYTE_TO_CHAN( ((s
>> 5) & 0x1f) * 255 / 0x1f );
495 rgba
[BCOMP
] = UBYTE_TO_CHAN( ((s
) & 0x1f) * 255 / 0x1f );
496 rgba
[ACOMP
] = UBYTE_TO_CHAN( ((s
>> 15) & 0x01) * 255 );
499 static void FETCH(la88
)( const struct gl_texture_image
*texImage
,
500 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
502 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 2 );
503 GLchan
*rgba
= (GLchan
*) texel
;
504 rgba
[RCOMP
] = UBYTE_TO_CHAN( src
[0] );
505 rgba
[GCOMP
] = UBYTE_TO_CHAN( src
[0] );
506 rgba
[BCOMP
] = UBYTE_TO_CHAN( src
[0] );
507 rgba
[ACOMP
] = UBYTE_TO_CHAN( src
[1] );
510 static void FETCH(bgr233
)( const struct gl_texture_image
*texImage
,
511 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
513 const GLubyte
*src
= UBYTE_SRC( texImage
, i
, j
, k
, 1 );
514 const GLubyte s
= *src
;
515 GLchan
*rgba
= (GLchan
*) texel
;
516 rgba
[RCOMP
] = UBYTE_TO_CHAN( ((s
) & 0xe0) * 255 / 0xe0 );
517 rgba
[GCOMP
] = UBYTE_TO_CHAN( ((s
<< 3) & 0xe0) * 255 / 0xe0 );
518 rgba
[BCOMP
] = UBYTE_TO_CHAN( ((s
<< 5) & 0xc0) * 255 / 0xc0 );
519 rgba
[ACOMP
] = CHAN_MAX
;