2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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 * 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.
30 * \author Gareth Hughes
36 #include "texformat.h"
40 #if FEATURE_EXT_texture_sRGB
43 * Convert an 8-bit sRGB value from non-linear space to a
44 * linear RGB value in [0, 1].
45 * Implemented with a 256-entry lookup table.
48 nonlinear_to_linear(GLubyte cs8
)
50 static GLfloat table
[256];
51 static GLboolean tableReady
= GL_FALSE
;
53 /* compute lookup table now */
55 for (i
= 0; i
< 256; i
++) {
56 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
58 table
[i
] = cs
/ 12.92f
;
61 table
[i
] = (GLfloat
) _mesa_pow((cs
+ 0.055) / 1.055, 2.4);
70 #endif /* FEATURE_EXT_texture_sRGB */
73 /* Texel fetch routines for all supported formats
76 #include "texformat_tmp.h"
79 #include "texformat_tmp.h"
82 #include "texformat_tmp.h"
85 * Null texel fetch function.
87 * Have to have this so the FetchTexel function pointer is never NULL.
89 static void fetch_null_texel( const struct gl_texture_image
*texImage
,
90 GLint i
, GLint j
, GLint k
, GLchan
*texel
)
92 (void) texImage
; (void) i
; (void) j
; (void) k
;
97 _mesa_warning(NULL
, "fetch_null_texel() called!");
100 static void fetch_null_texelf( const struct gl_texture_image
*texImage
,
101 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
103 (void) texImage
; (void) i
; (void) j
; (void) k
;
108 _mesa_warning(NULL
, "fetch_null_texelf() called!");
111 static void store_null_texel(struct gl_texture_image
*texImage
,
112 GLint i
, GLint j
, GLint k
, const void *texel
)
124 * Notes about the predefined gl_texture_formats:
126 * 1. There are 1D, 2D and 3D functions for fetching texels from texture
127 * images, returning both GLchan values and GLfloat values. (six
128 * functions in total)
129 * You don't have to provide both the GLchan and GLfloat functions;
130 * just one or the other is OK. Mesa will use an "adaptor" to convert
131 * between GLchan/GLfloat when needed.
132 * Since the adaptors have small performance penalty, we provide both
133 * GLchan and GLfloat functions for some common formats like RGB, RGBA.
137 /***************************************************************/
138 /** \name Default GLchan-based formats */
141 const struct gl_texture_format _mesa_texformat_rgba
= {
142 MESA_FORMAT_RGBA
, /* MesaFormat */
143 GL_RGBA
, /* BaseFormat */
144 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
145 CHAN_BITS
, /* RedBits */
146 CHAN_BITS
, /* GreenBits */
147 CHAN_BITS
, /* BlueBits */
148 CHAN_BITS
, /* AlphaBits */
149 0, /* LuminanceBits */
150 0, /* IntensityBits */
154 4 * sizeof(GLchan
), /* TexelBytes */
155 _mesa_texstore_rgba
, /* StoreTexImageFunc */
156 fetch_texel_1d_rgba
, /* FetchTexel1D */
157 fetch_texel_2d_rgba
, /* FetchTexel2D */
158 fetch_texel_3d_rgba
, /* FetchTexel3D */
159 fetch_texel_1d_f_rgba
, /* FetchTexel1Df */
160 fetch_texel_2d_f_rgba
, /* FetchTexel2Df */
161 fetch_texel_3d_f_rgba
, /* FetchTexel3Df */
162 store_texel_rgba
/* StoreTexel */
165 const struct gl_texture_format _mesa_texformat_rgb
= {
166 MESA_FORMAT_RGB
, /* MesaFormat */
167 GL_RGB
, /* BaseFormat */
168 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
169 CHAN_BITS
, /* RedBits */
170 CHAN_BITS
, /* GreenBits */
171 CHAN_BITS
, /* BlueBits */
173 0, /* LuminanceBits */
174 0, /* IntensityBits */
178 3 * sizeof(GLchan
), /* TexelBytes */
179 _mesa_texstore_rgba
,/*yes*/ /* StoreTexImageFunc */
180 fetch_texel_1d_rgb
, /* FetchTexel1D */
181 fetch_texel_2d_rgb
, /* FetchTexel2D */
182 fetch_texel_3d_rgb
, /* FetchTexel3D */
183 fetch_texel_1d_f_rgb
, /* FetchTexel1Df */
184 fetch_texel_2d_f_rgb
, /* FetchTexel2Df */
185 fetch_texel_3d_f_rgb
, /* FetchTexel3Df */
186 store_texel_rgb
/* StoreTexel */
189 const struct gl_texture_format _mesa_texformat_alpha
= {
190 MESA_FORMAT_ALPHA
, /* MesaFormat */
191 GL_ALPHA
, /* BaseFormat */
192 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
196 CHAN_BITS
, /* AlphaBits */
197 0, /* LuminanceBits */
198 0, /* IntensityBits */
202 sizeof(GLchan
), /* TexelBytes */
203 _mesa_texstore_rgba
,/*yes*/ /* StoreTexImageFunc */
204 fetch_texel_1d_alpha
, /* FetchTexel1D */
205 fetch_texel_2d_alpha
, /* FetchTexel2D */
206 fetch_texel_3d_alpha
, /* FetchTexel3D */
207 NULL
, /* FetchTexel1Df */
208 NULL
, /* FetchTexel2Df */
209 NULL
, /* FetchTexel3Df */
210 store_texel_alpha
/* StoreTexel */
213 const struct gl_texture_format _mesa_texformat_luminance
= {
214 MESA_FORMAT_LUMINANCE
, /* MesaFormat */
215 GL_LUMINANCE
, /* BaseFormat */
216 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
221 CHAN_BITS
, /* LuminanceBits */
222 0, /* IntensityBits */
226 sizeof(GLchan
), /* TexelBytes */
227 _mesa_texstore_rgba
,/*yes*/ /* StoreTexImageFunc */
228 fetch_texel_1d_luminance
, /* FetchTexel1D */
229 fetch_texel_2d_luminance
, /* FetchTexel2D */
230 fetch_texel_3d_luminance
, /* FetchTexel3D */
231 NULL
, /* FetchTexel1Df */
232 NULL
, /* FetchTexel2Df */
233 NULL
, /* FetchTexel3Df */
234 store_texel_luminance
/* StoreTexel */
237 const struct gl_texture_format _mesa_texformat_luminance_alpha
= {
238 MESA_FORMAT_LUMINANCE_ALPHA
, /* MesaFormat */
239 GL_LUMINANCE_ALPHA
, /* BaseFormat */
240 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
244 CHAN_BITS
, /* AlphaBits */
245 CHAN_BITS
, /* LuminanceBits */
246 0, /* IntensityBits */
250 2 * sizeof(GLchan
), /* TexelBytes */
251 _mesa_texstore_rgba
,/*yes*/ /* StoreTexImageFunc */
252 fetch_texel_1d_luminance_alpha
, /* FetchTexel1D */
253 fetch_texel_2d_luminance_alpha
, /* FetchTexel2D */
254 fetch_texel_3d_luminance_alpha
, /* FetchTexel3D */
255 NULL
, /* FetchTexel1Df */
256 NULL
, /* FetchTexel2Df */
257 NULL
, /* FetchTexel3Df */
258 store_texel_luminance_alpha
/* StoreTexel */
261 const struct gl_texture_format _mesa_texformat_intensity
= {
262 MESA_FORMAT_INTENSITY
, /* MesaFormat */
263 GL_INTENSITY
, /* BaseFormat */
264 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
269 0, /* LuminanceBits */
270 CHAN_BITS
, /* IntensityBits */
274 sizeof(GLchan
), /* TexelBytes */
275 _mesa_texstore_rgba
,/*yes*/ /* StoreTexImageFunc */
276 fetch_texel_1d_intensity
, /* FetchTexel1D */
277 fetch_texel_2d_intensity
, /* FetchTexel2D */
278 fetch_texel_3d_intensity
, /* FetchTexel3D */
279 NULL
, /* FetchTexel1Df */
280 NULL
, /* FetchTexel2Df */
281 NULL
, /* FetchTexel3Df */
282 store_texel_intensity
/* StoreTexel */
286 #if FEATURE_EXT_texture_sRGB
288 const struct gl_texture_format _mesa_texformat_srgb8
= {
289 MESA_FORMAT_SRGB8
, /* MesaFormat */
290 GL_RGB
, /* BaseFormat */
291 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
296 0, /* LuminanceBits */
297 0, /* IntensityBits */
302 _mesa_texstore_srgb8
, /* StoreTexImageFunc */
303 NULL
, /* FetchTexel1D */
304 NULL
, /* FetchTexel2D */
305 NULL
, /* FetchTexel3D */
306 fetch_texel_1d_srgb8
, /* FetchTexel1Df */
307 fetch_texel_2d_srgb8
, /* FetchTexel2Df */
308 fetch_texel_3d_srgb8
, /* FetchTexel3Df */
309 store_texel_srgb8
/* StoreTexel */
312 const struct gl_texture_format _mesa_texformat_srgba8
= {
313 MESA_FORMAT_SRGBA8
, /* MesaFormat */
314 GL_RGBA
, /* BaseFormat */
315 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
320 0, /* LuminanceBits */
321 0, /* IntensityBits */
326 _mesa_texstore_srgba8
, /* StoreTexImageFunc */
327 NULL
, /* FetchTexel1D */
328 NULL
, /* FetchTexel2D */
329 NULL
, /* FetchTexel3D */
330 fetch_texel_1d_srgba8
, /* FetchTexel1Df */
331 fetch_texel_2d_srgba8
, /* FetchTexel2Df */
332 fetch_texel_3d_srgba8
, /* FetchTexel3Df */
333 store_texel_srgba8
/* StoreTexel */
336 const struct gl_texture_format _mesa_texformat_sl8
= {
337 MESA_FORMAT_SL8
, /* MesaFormat */
338 GL_LUMINANCE
, /* BaseFormat */
339 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
344 8, /* LuminanceBits */
345 0, /* IntensityBits */
350 _mesa_texstore_sl8
, /* StoreTexImageFunc */
351 NULL
, /* FetchTexel1D */
352 NULL
, /* FetchTexel2D */
353 NULL
, /* FetchTexel3D */
354 fetch_texel_1d_sl8
, /* FetchTexel1Df */
355 fetch_texel_2d_sl8
, /* FetchTexel2Df */
356 fetch_texel_3d_sl8
, /* FetchTexel3Df */
357 store_texel_sl8
/* StoreTexel */
360 const struct gl_texture_format _mesa_texformat_sla8
= {
361 MESA_FORMAT_SLA8
, /* MesaFormat */
362 GL_LUMINANCE_ALPHA
, /* BaseFormat */
363 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
368 8, /* LuminanceBits */
369 0, /* IntensityBits */
374 _mesa_texstore_sla8
, /* StoreTexImageFunc */
375 NULL
, /* FetchTexel1D */
376 NULL
, /* FetchTexel2D */
377 NULL
, /* FetchTexel3D */
378 fetch_texel_1d_sla8
, /* FetchTexel1Df */
379 fetch_texel_2d_sla8
, /* FetchTexel2Df */
380 fetch_texel_3d_sla8
, /* FetchTexel3Df */
381 store_texel_sla8
/* StoreTexel */
384 #endif /* FEATURE_EXT_texture_sRGB */
386 const struct gl_texture_format _mesa_texformat_rgba_float32
= {
387 MESA_FORMAT_RGBA_FLOAT32
, /* MesaFormat */
388 GL_RGBA
, /* BaseFormat */
389 GL_FLOAT
, /* DataType */
390 8 * sizeof(GLfloat
), /* RedBits */
391 8 * sizeof(GLfloat
), /* GreenBits */
392 8 * sizeof(GLfloat
), /* BlueBits */
393 8 * sizeof(GLfloat
), /* AlphaBits */
394 0, /* LuminanceBits */
395 0, /* IntensityBits */
399 4 * sizeof(GLfloat
), /* TexelBytes */
400 _mesa_texstore_rgba_float32
, /* StoreTexImageFunc */
401 NULL
, /* FetchTexel1D */
402 NULL
, /* FetchTexel1D */
403 NULL
, /* FetchTexel1D */
404 fetch_texel_1d_f_rgba_f32
, /* FetchTexel1Df */
405 fetch_texel_2d_f_rgba_f32
, /* FetchTexel2Df */
406 fetch_texel_3d_f_rgba_f32
, /* FetchTexel3Df */
407 store_texel_rgba_f32
/* StoreTexel */
410 const struct gl_texture_format _mesa_texformat_rgba_float16
= {
411 MESA_FORMAT_RGBA_FLOAT16
, /* MesaFormat */
412 GL_RGBA
, /* BaseFormat */
413 GL_FLOAT
, /* DataType */
414 8 * sizeof(GLhalfARB
), /* RedBits */
415 8 * sizeof(GLhalfARB
), /* GreenBits */
416 8 * sizeof(GLhalfARB
), /* BlueBits */
417 8 * sizeof(GLhalfARB
), /* AlphaBits */
418 0, /* LuminanceBits */
419 0, /* IntensityBits */
423 4 * sizeof(GLhalfARB
), /* TexelBytes */
424 _mesa_texstore_rgba_float16
, /* StoreTexImageFunc */
425 NULL
, /* FetchTexel1D */
426 NULL
, /* FetchTexel1D */
427 NULL
, /* FetchTexel1D */
428 fetch_texel_1d_f_rgba_f16
, /* FetchTexel1Df */
429 fetch_texel_2d_f_rgba_f16
, /* FetchTexel2Df */
430 fetch_texel_3d_f_rgba_f16
, /* FetchTexel3Df */
431 store_texel_rgba_f16
/* StoreTexel */
434 const struct gl_texture_format _mesa_texformat_rgb_float32
= {
435 MESA_FORMAT_RGB_FLOAT32
, /* MesaFormat */
436 GL_RGB
, /* BaseFormat */
437 GL_FLOAT
, /* DataType */
438 8 * sizeof(GLfloat
), /* RedBits */
439 8 * sizeof(GLfloat
), /* GreenBits */
440 8 * sizeof(GLfloat
), /* BlueBits */
442 0, /* LuminanceBits */
443 0, /* IntensityBits */
447 3 * sizeof(GLfloat
), /* TexelBytes */
448 _mesa_texstore_rgba_float32
,/*yes*/ /* StoreTexImageFunc */
449 NULL
, /* FetchTexel1D */
450 NULL
, /* FetchTexel1D */
451 NULL
, /* FetchTexel1D */
452 fetch_texel_1d_f_rgb_f32
, /* FetchTexel1Df */
453 fetch_texel_2d_f_rgb_f32
, /* FetchTexel2Df */
454 fetch_texel_3d_f_rgb_f32
, /* FetchTexel3Df */
455 store_texel_rgb_f32
/* StoreTexel */
458 const struct gl_texture_format _mesa_texformat_rgb_float16
= {
459 MESA_FORMAT_RGB_FLOAT16
, /* MesaFormat */
460 GL_RGB
, /* BaseFormat */
461 GL_FLOAT
, /* DataType */
462 8 * sizeof(GLhalfARB
), /* RedBits */
463 8 * sizeof(GLhalfARB
), /* GreenBits */
464 8 * sizeof(GLhalfARB
), /* BlueBits */
466 0, /* LuminanceBits */
467 0, /* IntensityBits */
471 3 * sizeof(GLhalfARB
), /* TexelBytes */
472 _mesa_texstore_rgba_float16
,/*yes*/ /* StoreTexImageFunc */
473 NULL
, /* FetchTexel1D */
474 NULL
, /* FetchTexel1D */
475 NULL
, /* FetchTexel1D */
476 fetch_texel_1d_f_rgb_f16
, /* FetchTexel1Df */
477 fetch_texel_2d_f_rgb_f16
, /* FetchTexel2Df */
478 fetch_texel_3d_f_rgb_f16
, /* FetchTexel3Df */
479 store_texel_rgb_f16
/* StoreTexel */
482 const struct gl_texture_format _mesa_texformat_alpha_float32
= {
483 MESA_FORMAT_ALPHA_FLOAT32
, /* MesaFormat */
484 GL_ALPHA
, /* BaseFormat */
485 GL_FLOAT
, /* DataType */
489 8 * sizeof(GLfloat
), /* AlphaBits */
490 0, /* LuminanceBits */
491 0, /* IntensityBits */
495 1 * sizeof(GLfloat
), /* TexelBytes */
496 _mesa_texstore_rgba_float32
,/*yes*/ /* StoreTexImageFunc */
497 NULL
, /* FetchTexel1D */
498 NULL
, /* FetchTexel1D */
499 NULL
, /* FetchTexel1D */
500 fetch_texel_1d_f_alpha_f32
, /* FetchTexel1Df */
501 fetch_texel_2d_f_alpha_f32
, /* FetchTexel2Df */
502 fetch_texel_3d_f_alpha_f32
, /* FetchTexel3Df */
503 store_texel_alpha_f32
/* StoreTexel */
506 const struct gl_texture_format _mesa_texformat_alpha_float16
= {
507 MESA_FORMAT_ALPHA_FLOAT16
, /* MesaFormat */
508 GL_ALPHA
, /* BaseFormat */
509 GL_FLOAT
, /* DataType */
513 8 * sizeof(GLhalfARB
), /* AlphaBits */
514 0, /* LuminanceBits */
515 0, /* IntensityBits */
519 1 * sizeof(GLhalfARB
), /* TexelBytes */
520 _mesa_texstore_rgba_float16
,/*yes*/ /* StoreTexImageFunc */
521 NULL
, /* FetchTexel1D */
522 NULL
, /* FetchTexel1D */
523 NULL
, /* FetchTexel1D */
524 fetch_texel_1d_f_alpha_f16
, /* FetchTexel1Df */
525 fetch_texel_2d_f_alpha_f16
, /* FetchTexel2Df */
526 fetch_texel_3d_f_alpha_f16
, /* FetchTexel3Df */
527 store_texel_alpha_f16
/* StoreTexel */
530 const struct gl_texture_format _mesa_texformat_luminance_float32
= {
531 MESA_FORMAT_LUMINANCE_FLOAT32
, /* MesaFormat */
532 GL_LUMINANCE
, /* BaseFormat */
533 GL_FLOAT
, /* DataType */
538 8 * sizeof(GLfloat
), /* LuminanceBits */
539 0, /* IntensityBits */
543 1 * sizeof(GLfloat
), /* TexelBytes */
544 _mesa_texstore_rgba_float32
,/*yes*/ /* StoreTexImageFunc */
545 NULL
, /* FetchTexel1D */
546 NULL
, /* FetchTexel2D */
547 NULL
, /* FetchTexel3D */
548 fetch_texel_1d_f_luminance_f32
, /* FetchTexel1Df */
549 fetch_texel_2d_f_luminance_f32
, /* FetchTexel2Df */
550 fetch_texel_3d_f_luminance_f32
, /* FetchTexel3Df */
551 store_texel_luminance_f32
/* StoreTexel */
554 const struct gl_texture_format _mesa_texformat_luminance_float16
= {
555 MESA_FORMAT_LUMINANCE_FLOAT16
, /* MesaFormat */
556 GL_LUMINANCE
, /* BaseFormat */
557 GL_FLOAT
, /* DataType */
562 8 * sizeof(GLhalfARB
), /* LuminanceBits */
563 0, /* IntensityBits */
567 1 * sizeof(GLhalfARB
), /* TexelBytes */
568 _mesa_texstore_rgba_float16
,/*yes*/ /* StoreTexImageFunc */
569 NULL
, /* FetchTexel1D */
570 NULL
, /* FetchTexel2D */
571 NULL
, /* FetchTexel3D */
572 fetch_texel_1d_f_luminance_f16
, /* FetchTexel1Df */
573 fetch_texel_2d_f_luminance_f16
, /* FetchTexel2Df */
574 fetch_texel_3d_f_luminance_f16
, /* FetchTexel3Df */
575 store_texel_luminance_f16
/* StoreTexel */
578 const struct gl_texture_format _mesa_texformat_luminance_alpha_float32
= {
579 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
, /* MesaFormat */
580 GL_LUMINANCE_ALPHA
, /* BaseFormat */
581 GL_FLOAT
, /* DataType */
585 8 * sizeof(GLfloat
), /* AlphaBits */
586 8 * sizeof(GLfloat
), /* LuminanceBits */
587 0, /* IntensityBits */
591 2 * sizeof(GLfloat
), /* TexelBytes */
592 _mesa_texstore_rgba_float32
, /* StoreTexImageFunc */
593 NULL
, /* FetchTexel1D */
594 NULL
, /* FetchTexel2D */
595 NULL
, /* FetchTexel3D */
596 fetch_texel_1d_f_luminance_alpha_f32
,/* FetchTexel1Df */
597 fetch_texel_2d_f_luminance_alpha_f32
,/* FetchTexel2Df */
598 fetch_texel_3d_f_luminance_alpha_f32
,/* FetchTexel3Df */
599 store_texel_luminance_alpha_f32
/* StoreTexel */
602 const struct gl_texture_format _mesa_texformat_luminance_alpha_float16
= {
603 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
, /* MesaFormat */
604 GL_LUMINANCE_ALPHA
, /* BaseFormat */
605 GL_FLOAT
, /* DataType */
609 8 * sizeof(GLhalfARB
), /* AlphaBits */
610 8 * sizeof(GLhalfARB
), /* LuminanceBits */
611 0, /* IntensityBits */
615 2 * sizeof(GLhalfARB
), /* TexelBytes */
616 _mesa_texstore_rgba_float16
, /* StoreTexImageFunc */
617 NULL
, /* FetchTexel1D */
618 NULL
, /* FetchTexel2D */
619 NULL
, /* FetchTexel3D */
620 fetch_texel_1d_f_luminance_alpha_f16
,/* FetchTexel1Df */
621 fetch_texel_2d_f_luminance_alpha_f16
,/* FetchTexel2Df */
622 fetch_texel_3d_f_luminance_alpha_f16
,/* FetchTexel3Df */
623 store_texel_luminance_alpha_f16
/* StoreTexel */
626 const struct gl_texture_format _mesa_texformat_intensity_float32
= {
627 MESA_FORMAT_INTENSITY_FLOAT32
, /* MesaFormat */
628 GL_INTENSITY
, /* BaseFormat */
629 GL_FLOAT
, /* DataType */
634 0, /* LuminanceBits */
635 8 * sizeof(GLfloat
), /* IntensityBits */
639 1 * sizeof(GLfloat
), /* TexelBytes */
640 _mesa_texstore_rgba_float32
,/*yes*/ /* StoreTexImageFunc */
641 NULL
, /* FetchTexel1D */
642 NULL
, /* FetchTexel2D */
643 NULL
, /* FetchTexel3D */
644 fetch_texel_1d_f_intensity_f32
, /* FetchTexel1Df */
645 fetch_texel_2d_f_intensity_f32
, /* FetchTexel2Df */
646 fetch_texel_3d_f_intensity_f32
, /* FetchTexel3Df */
647 store_texel_intensity_f32
/* StoreTexel */
650 const struct gl_texture_format _mesa_texformat_intensity_float16
= {
651 MESA_FORMAT_INTENSITY_FLOAT16
, /* MesaFormat */
652 GL_INTENSITY
, /* BaseFormat */
653 GL_FLOAT
, /* DataType */
658 0, /* LuminanceBits */
659 8 * sizeof(GLhalfARB
), /* IntensityBits */
663 1 * sizeof(GLhalfARB
), /* TexelBytes */
664 _mesa_texstore_rgba_float16
,/*yes*/ /* StoreTexImageFunc */
665 NULL
, /* FetchTexel1D */
666 NULL
, /* FetchTexel2D */
667 NULL
, /* FetchTexel3D */
668 fetch_texel_1d_f_intensity_f16
, /* FetchTexel1Df */
669 fetch_texel_2d_f_intensity_f16
, /* FetchTexel2Df */
670 fetch_texel_3d_f_intensity_f16
, /* FetchTexel3Df */
671 store_texel_intensity_f16
/* StoreTexel */
678 /***************************************************************/
679 /** \name Hardware formats */
682 const struct gl_texture_format _mesa_texformat_rgba8888
= {
683 MESA_FORMAT_RGBA8888
, /* MesaFormat */
684 GL_RGBA
, /* BaseFormat */
685 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
690 0, /* LuminanceBits */
691 0, /* IntensityBits */
696 _mesa_texstore_rgba8888
, /* StoreTexImageFunc */
697 fetch_texel_1d_rgba8888
, /* FetchTexel1D */
698 fetch_texel_2d_rgba8888
, /* FetchTexel2D */
699 fetch_texel_3d_rgba8888
, /* FetchTexel3D */
700 NULL
, /* FetchTexel1Df */
701 NULL
, /* FetchTexel2Df */
702 NULL
, /* FetchTexel3Df */
703 store_texel_rgba8888
/* StoreTexel */
706 const struct gl_texture_format _mesa_texformat_rgba8888_rev
= {
707 MESA_FORMAT_RGBA8888_REV
, /* MesaFormat */
708 GL_RGBA
, /* BaseFormat */
709 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
714 0, /* LuminanceBits */
715 0, /* IntensityBits */
720 _mesa_texstore_rgba8888
, /* StoreTexImageFunc */
721 fetch_texel_1d_rgba8888_rev
, /* FetchTexel1D */
722 fetch_texel_2d_rgba8888_rev
, /* FetchTexel2D */
723 fetch_texel_3d_rgba8888_rev
, /* FetchTexel3D */
724 NULL
, /* FetchTexel1Df */
725 NULL
, /* FetchTexel2Df */
726 NULL
, /* FetchTexel3Df */
727 store_texel_rgba8888_rev
/* StoreTexel */
730 const struct gl_texture_format _mesa_texformat_argb8888
= {
731 MESA_FORMAT_ARGB8888
, /* MesaFormat */
732 GL_RGBA
, /* BaseFormat */
733 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
738 0, /* LuminanceBits */
739 0, /* IntensityBits */
744 _mesa_texstore_argb8888
, /* StoreTexImageFunc */
745 fetch_texel_1d_argb8888
, /* FetchTexel1D */
746 fetch_texel_2d_argb8888
, /* FetchTexel2D */
747 fetch_texel_3d_argb8888
, /* FetchTexel3D */
748 NULL
, /* FetchTexel1Df */
749 NULL
, /* FetchTexel2Df */
750 NULL
, /* FetchTexel3Df */
751 store_texel_argb8888
/* StoreTexel */
754 const struct gl_texture_format _mesa_texformat_argb8888_rev
= {
755 MESA_FORMAT_ARGB8888_REV
, /* MesaFormat */
756 GL_RGBA
, /* BaseFormat */
757 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
762 0, /* LuminanceBits */
763 0, /* IntensityBits */
768 _mesa_texstore_argb8888
, /* StoreTexImageFunc */
769 fetch_texel_1d_argb8888_rev
, /* FetchTexel1D */
770 fetch_texel_2d_argb8888_rev
, /* FetchTexel2D */
771 fetch_texel_3d_argb8888_rev
, /* FetchTexel3D */
772 NULL
, /* FetchTexel1Df */
773 NULL
, /* FetchTexel2Df */
774 NULL
, /* FetchTexel3Df */
775 store_texel_argb8888_rev
/* StoreTexel */
778 const struct gl_texture_format _mesa_texformat_rgb888
= {
779 MESA_FORMAT_RGB888
, /* MesaFormat */
780 GL_RGB
, /* BaseFormat */
781 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
786 0, /* LuminanceBits */
787 0, /* IntensityBits */
792 _mesa_texstore_rgb888
, /* StoreTexImageFunc */
793 fetch_texel_1d_rgb888
, /* FetchTexel1D */
794 fetch_texel_2d_rgb888
, /* FetchTexel2D */
795 fetch_texel_3d_rgb888
, /* FetchTexel3D */
796 NULL
, /* FetchTexel1Df */
797 NULL
, /* FetchTexel2Df */
798 NULL
, /* FetchTexel3Df */
799 store_texel_rgb888
/* StoreTexel */
802 const struct gl_texture_format _mesa_texformat_bgr888
= {
803 MESA_FORMAT_BGR888
, /* MesaFormat */
804 GL_RGB
, /* BaseFormat */
805 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
810 0, /* LuminanceBits */
811 0, /* IntensityBits */
816 _mesa_texstore_bgr888
, /* StoreTexImageFunc */
817 fetch_texel_1d_bgr888
, /* FetchTexel1D */
818 fetch_texel_2d_bgr888
, /* FetchTexel2D */
819 fetch_texel_3d_bgr888
, /* FetchTexel3D */
820 NULL
, /* FetchTexel1Df */
821 NULL
, /* FetchTexel2Df */
822 NULL
, /* FetchTexel3Df */
823 store_texel_bgr888
/* StoreTexel */
826 const struct gl_texture_format _mesa_texformat_rgb565
= {
827 MESA_FORMAT_RGB565
, /* MesaFormat */
828 GL_RGB
, /* BaseFormat */
829 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
834 0, /* LuminanceBits */
835 0, /* IntensityBits */
840 _mesa_texstore_rgb565
, /* StoreTexImageFunc */
841 fetch_texel_1d_rgb565
, /* FetchTexel1D */
842 fetch_texel_2d_rgb565
, /* FetchTexel2D */
843 fetch_texel_3d_rgb565
, /* FetchTexel3D */
844 NULL
, /* FetchTexel1Df */
845 NULL
, /* FetchTexel2Df */
846 NULL
, /* FetchTexel3Df */
847 store_texel_rgb565
/* StoreTexel */
850 const struct gl_texture_format _mesa_texformat_rgb565_rev
= {
851 MESA_FORMAT_RGB565_REV
, /* MesaFormat */
852 GL_RGB
, /* BaseFormat */
853 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
858 0, /* LuminanceBits */
859 0, /* IntensityBits */
864 _mesa_texstore_rgb565
, /* StoreTexImageFunc */
865 fetch_texel_1d_rgb565_rev
, /* FetchTexel1D */
866 fetch_texel_2d_rgb565_rev
, /* FetchTexel2D */
867 fetch_texel_3d_rgb565_rev
, /* FetchTexel3D */
868 NULL
, /* FetchTexel1Df */
869 NULL
, /* FetchTexel2Df */
870 NULL
, /* FetchTexel3Df */
871 store_texel_rgb565_rev
/* StoreTexel */
874 const struct gl_texture_format _mesa_texformat_rgba4444
= {
875 MESA_FORMAT_RGBA4444
, /* MesaFormat */
876 GL_RGBA
, /* BaseFormat */
877 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
882 0, /* LuminanceBits */
883 0, /* IntensityBits */
888 _mesa_texstore_rgba4444
, /* StoreTexImageFunc */
889 fetch_texel_1d_rgba4444
, /* FetchTexel1D */
890 fetch_texel_2d_rgba4444
, /* FetchTexel2D */
891 fetch_texel_3d_rgba4444
, /* FetchTexel3D */
892 NULL
, /* FetchTexel1Df */
893 NULL
, /* FetchTexel2Df */
894 NULL
, /* FetchTexel3Df */
895 store_texel_rgba4444
/* StoreTexel */
898 const struct gl_texture_format _mesa_texformat_argb4444
= {
899 MESA_FORMAT_ARGB4444
, /* MesaFormat */
900 GL_RGBA
, /* BaseFormat */
901 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
906 0, /* LuminanceBits */
907 0, /* IntensityBits */
912 _mesa_texstore_argb4444
, /* StoreTexImageFunc */
913 fetch_texel_1d_argb4444
, /* FetchTexel1D */
914 fetch_texel_2d_argb4444
, /* FetchTexel2D */
915 fetch_texel_3d_argb4444
, /* FetchTexel3D */
916 NULL
, /* FetchTexel1Df */
917 NULL
, /* FetchTexel2Df */
918 NULL
, /* FetchTexel3Df */
919 store_texel_argb4444
/* StoreTexel */
922 const struct gl_texture_format _mesa_texformat_argb4444_rev
= {
923 MESA_FORMAT_ARGB4444_REV
, /* MesaFormat */
924 GL_RGBA
, /* BaseFormat */
925 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
930 0, /* LuminanceBits */
931 0, /* IntensityBits */
936 _mesa_texstore_argb4444
, /* StoreTexImageFunc */
937 fetch_texel_1d_argb4444_rev
, /* FetchTexel1D */
938 fetch_texel_2d_argb4444_rev
, /* FetchTexel2D */
939 fetch_texel_3d_argb4444_rev
, /* FetchTexel3D */
940 NULL
, /* FetchTexel1Df */
941 NULL
, /* FetchTexel2Df */
942 NULL
, /* FetchTexel3Df */
943 store_texel_argb4444_rev
/* StoreTexel */
946 const struct gl_texture_format _mesa_texformat_rgba5551
= {
947 MESA_FORMAT_RGBA5551
, /* MesaFormat */
948 GL_RGBA
, /* BaseFormat */
949 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
954 0, /* LuminanceBits */
955 0, /* IntensityBits */
960 _mesa_texstore_rgba5551
, /* StoreTexImageFunc */
961 fetch_texel_1d_rgba5551
, /* FetchTexel1D */
962 fetch_texel_2d_rgba5551
, /* FetchTexel2D */
963 fetch_texel_3d_rgba5551
, /* FetchTexel3D */
964 NULL
, /* FetchTexel1Df */
965 NULL
, /* FetchTexel2Df */
966 NULL
, /* FetchTexel3Df */
967 store_texel_rgba5551
/* StoreTexel */
970 const struct gl_texture_format _mesa_texformat_argb1555
= {
971 MESA_FORMAT_ARGB1555
, /* MesaFormat */
972 GL_RGBA
, /* BaseFormat */
973 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
978 0, /* LuminanceBits */
979 0, /* IntensityBits */
984 _mesa_texstore_argb1555
, /* StoreTexImageFunc */
985 fetch_texel_1d_argb1555
, /* FetchTexel1D */
986 fetch_texel_2d_argb1555
, /* FetchTexel2D */
987 fetch_texel_3d_argb1555
, /* FetchTexel3D */
988 NULL
, /* FetchTexel1Df */
989 NULL
, /* FetchTexel2Df */
990 NULL
, /* FetchTexel3Df */
991 store_texel_argb1555
/* StoreTexel */
994 const struct gl_texture_format _mesa_texformat_argb1555_rev
= {
995 MESA_FORMAT_ARGB1555_REV
, /* MesaFormat */
996 GL_RGBA
, /* BaseFormat */
997 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1002 0, /* LuminanceBits */
1003 0, /* IntensityBits */
1006 0, /* StencilBits */
1008 _mesa_texstore_argb1555
, /* StoreTexImageFunc */
1009 fetch_texel_1d_argb1555_rev
, /* FetchTexel1D */
1010 fetch_texel_2d_argb1555_rev
, /* FetchTexel2D */
1011 fetch_texel_3d_argb1555_rev
, /* FetchTexel3D */
1012 NULL
, /* FetchTexel1Df */
1013 NULL
, /* FetchTexel2Df */
1014 NULL
, /* FetchTexel3Df */
1015 store_texel_argb1555_rev
/* StoreTexel */
1018 const struct gl_texture_format _mesa_texformat_al88
= {
1019 MESA_FORMAT_AL88
, /* MesaFormat */
1020 GL_LUMINANCE_ALPHA
, /* BaseFormat */
1021 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1026 8, /* LuminanceBits */
1027 0, /* IntensityBits */
1030 0, /* StencilBits */
1032 _mesa_texstore_al88
, /* StoreTexImageFunc */
1033 fetch_texel_1d_al88
, /* FetchTexel1D */
1034 fetch_texel_2d_al88
, /* FetchTexel2D */
1035 fetch_texel_3d_al88
, /* FetchTexel3D */
1036 NULL
, /* FetchTexel1Df */
1037 NULL
, /* FetchTexel2Df */
1038 NULL
, /* FetchTexel3Df */
1039 store_texel_al88
/* StoreTexel */
1042 const struct gl_texture_format _mesa_texformat_al88_rev
= {
1043 MESA_FORMAT_AL88_REV
, /* MesaFormat */
1044 GL_LUMINANCE_ALPHA
, /* BaseFormat */
1045 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1050 8, /* LuminanceBits */
1051 0, /* IntensityBits */
1054 0, /* StencilBits */
1056 _mesa_texstore_al88
, /* StoreTexImageFunc */
1057 fetch_texel_1d_al88_rev
, /* FetchTexel1D */
1058 fetch_texel_2d_al88_rev
, /* FetchTexel2D */
1059 fetch_texel_3d_al88_rev
, /* FetchTexel3D */
1060 NULL
, /* FetchTexel1Df */
1061 NULL
, /* FetchTexel2Df */
1062 NULL
, /* FetchTexel3Df */
1063 store_texel_al88_rev
/* StoreTexel */
1066 const struct gl_texture_format _mesa_texformat_rgb332
= {
1067 MESA_FORMAT_RGB332
, /* MesaFormat */
1068 GL_RGB
, /* BaseFormat */
1069 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1074 0, /* LuminanceBits */
1075 0, /* IntensityBits */
1078 0, /* StencilBits */
1080 _mesa_texstore_rgb332
, /* StoreTexImageFunc */
1081 fetch_texel_1d_rgb332
, /* FetchTexel1D */
1082 fetch_texel_2d_rgb332
, /* FetchTexel2D */
1083 fetch_texel_3d_rgb332
, /* FetchTexel3D */
1084 NULL
, /* FetchTexel1Df */
1085 NULL
, /* FetchTexel2Df */
1086 NULL
, /* FetchTexel3Df */
1087 store_texel_rgb332
/* StoreTexel */
1090 const struct gl_texture_format _mesa_texformat_a8
= {
1091 MESA_FORMAT_A8
, /* MesaFormat */
1092 GL_ALPHA
, /* BaseFormat */
1093 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1098 0, /* LuminanceBits */
1099 0, /* IntensityBits */
1102 0, /* StencilBits */
1104 _mesa_texstore_a8
, /* StoreTexImageFunc */
1105 fetch_texel_1d_a8
, /* FetchTexel1D */
1106 fetch_texel_2d_a8
, /* FetchTexel2D */
1107 fetch_texel_3d_a8
, /* FetchTexel3D */
1108 NULL
, /* FetchTexel1Df */
1109 NULL
, /* FetchTexel2Df */
1110 NULL
, /* FetchTexel3Df */
1111 store_texel_a8
/* StoreTexel */
1114 const struct gl_texture_format _mesa_texformat_l8
= {
1115 MESA_FORMAT_L8
, /* MesaFormat */
1116 GL_LUMINANCE
, /* BaseFormat */
1117 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1122 8, /* LuminanceBits */
1123 0, /* IntensityBits */
1126 0, /* StencilBits */
1128 _mesa_texstore_a8
,/*yes*/ /* StoreTexImageFunc */
1129 fetch_texel_1d_l8
, /* FetchTexel1D */
1130 fetch_texel_2d_l8
, /* FetchTexel2D */
1131 fetch_texel_3d_l8
, /* FetchTexel3D */
1132 NULL
, /* FetchTexel1Df */
1133 NULL
, /* FetchTexel2Df */
1134 NULL
, /* FetchTexel3Df */
1135 store_texel_l8
/* StoreTexel */
1138 const struct gl_texture_format _mesa_texformat_i8
= {
1139 MESA_FORMAT_I8
, /* MesaFormat */
1140 GL_INTENSITY
, /* BaseFormat */
1141 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1146 0, /* LuminanceBits */
1147 8, /* IntensityBits */
1150 0, /* StencilBits */
1152 _mesa_texstore_a8
,/*yes*/ /* StoreTexImageFunc */
1153 fetch_texel_1d_i8
, /* FetchTexel1D */
1154 fetch_texel_2d_i8
, /* FetchTexel2D */
1155 fetch_texel_3d_i8
, /* FetchTexel3D */
1156 NULL
, /* FetchTexel1Df */
1157 NULL
, /* FetchTexel2Df */
1158 NULL
, /* FetchTexel3Df */
1159 store_texel_i8
/* StoreTexel */
1162 const struct gl_texture_format _mesa_texformat_ci8
= {
1163 MESA_FORMAT_CI8
, /* MesaFormat */
1164 GL_COLOR_INDEX
, /* BaseFormat */
1165 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1170 0, /* LuminanceBits */
1171 0, /* IntensityBits */
1174 0, /* StencilBits */
1176 _mesa_texstore_ci8
, /* StoreTexImageFunc */
1177 fetch_texel_1d_ci8
, /* FetchTexel1D */
1178 fetch_texel_2d_ci8
, /* FetchTexel2D */
1179 fetch_texel_3d_ci8
, /* FetchTexel3D */
1180 NULL
, /* FetchTexel1Df */
1181 NULL
, /* FetchTexel2Df */
1182 NULL
, /* FetchTexel3Df */
1183 store_texel_ci8
/* StoreTexel */
1186 const struct gl_texture_format _mesa_texformat_ycbcr
= {
1187 MESA_FORMAT_YCBCR
, /* MesaFormat */
1188 GL_YCBCR_MESA
, /* BaseFormat */
1189 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1194 0, /* LuminanceBits */
1195 0, /* IntensityBits */
1198 0, /* StencilBits */
1200 _mesa_texstore_ycbcr
, /* StoreTexImageFunc */
1201 fetch_texel_1d_ycbcr
, /* FetchTexel1D */
1202 fetch_texel_2d_ycbcr
, /* FetchTexel2D */
1203 fetch_texel_3d_ycbcr
, /* FetchTexel3D */
1204 NULL
, /* FetchTexel1Df */
1205 NULL
, /* FetchTexel2Df */
1206 NULL
, /* FetchTexel3Df */
1207 store_texel_ycbcr
/* StoreTexel */
1210 const struct gl_texture_format _mesa_texformat_ycbcr_rev
= {
1211 MESA_FORMAT_YCBCR_REV
, /* MesaFormat */
1212 GL_YCBCR_MESA
, /* BaseFormat */
1213 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1218 0, /* LuminanceBits */
1219 0, /* IntensityBits */
1222 0, /* StencilBits */
1224 _mesa_texstore_ycbcr
, /* StoreTexImageFunc */
1225 fetch_texel_1d_ycbcr_rev
, /* FetchTexel1D */
1226 fetch_texel_2d_ycbcr_rev
, /* FetchTexel2D */
1227 fetch_texel_3d_ycbcr_rev
, /* FetchTexel3D */
1228 NULL
, /* FetchTexel1Df */
1229 NULL
, /* FetchTexel2Df */
1230 NULL
, /* FetchTexel3Df */
1231 store_texel_ycbcr_rev
/* StoreTexel */
1234 const struct gl_texture_format _mesa_texformat_z24_s8
= {
1235 MESA_FORMAT_Z24_S8
, /* MesaFormat */
1236 GL_DEPTH_STENCIL_EXT
, /* BaseFormat */
1237 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1242 0, /* LuminanceBits */
1243 0, /* IntensityBits */
1246 8, /* StencilBits */
1248 _mesa_texstore_z24_s8
, /* StoreTexImageFunc */
1249 NULL
, /* FetchTexel1D */
1250 NULL
, /* FetchTexel2D */
1251 NULL
, /* FetchTexel3D */
1252 fetch_texel_1d_f_z24_s8
, /* FetchTexel1Df */
1253 fetch_texel_2d_f_z24_s8
, /* FetchTexel2Df */
1254 fetch_texel_3d_f_z24_s8
, /* FetchTexel3Df */
1255 store_texel_z24_s8
/* StoreTexel */
1258 const struct gl_texture_format _mesa_texformat_s8_z24
= {
1259 MESA_FORMAT_S8_Z24
, /* MesaFormat */
1260 GL_DEPTH_STENCIL_EXT
, /* BaseFormat */
1261 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1266 0, /* LuminanceBits */
1267 0, /* IntensityBits */
1270 8, /* StencilBits */
1272 _mesa_texstore_s8_z24
, /* StoreTexImageFunc */
1273 NULL
, /* FetchTexel1D */
1274 NULL
, /* FetchTexel2D */
1275 NULL
, /* FetchTexel3D */
1276 fetch_texel_1d_f_s8_z24
, /* FetchTexel1Df */
1277 fetch_texel_2d_f_s8_z24
, /* FetchTexel2Df */
1278 fetch_texel_3d_f_s8_z24
, /* FetchTexel3Df */
1279 store_texel_s8_z24
/* StoreTexel */
1282 const struct gl_texture_format _mesa_texformat_z16
= {
1283 MESA_FORMAT_Z16
, /* MesaFormat */
1284 GL_DEPTH_COMPONENT
, /* BaseFormat */
1285 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1290 0, /* LuminanceBits */
1291 0, /* IntensityBits */
1293 sizeof(GLushort
) * 8, /* DepthBits */
1294 0, /* StencilBits */
1295 sizeof(GLushort
), /* TexelBytes */
1296 _mesa_texstore_z16
, /* StoreTexImageFunc */
1297 NULL
, /* FetchTexel1D */
1298 NULL
, /* FetchTexel1D */
1299 NULL
, /* FetchTexel1D */
1300 fetch_texel_1d_f_z16
, /* FetchTexel1Df */
1301 fetch_texel_2d_f_z16
, /* FetchTexel2Df */
1302 fetch_texel_3d_f_z16
, /* FetchTexel3Df */
1303 store_texel_z16
/* StoreTexel */
1306 const struct gl_texture_format _mesa_texformat_z32
= {
1307 MESA_FORMAT_Z32
, /* MesaFormat */
1308 GL_DEPTH_COMPONENT
, /* BaseFormat */
1309 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1314 0, /* LuminanceBits */
1315 0, /* IntensityBits */
1317 sizeof(GLuint
) * 8, /* DepthBits */
1318 0, /* StencilBits */
1319 sizeof(GLuint
), /* TexelBytes */
1320 _mesa_texstore_z32
, /* StoreTexImageFunc */
1321 NULL
, /* FetchTexel1D */
1322 NULL
, /* FetchTexel1D */
1323 NULL
, /* FetchTexel1D */
1324 fetch_texel_1d_f_z32
, /* FetchTexel1Df */
1325 fetch_texel_2d_f_z32
, /* FetchTexel2Df */
1326 fetch_texel_3d_f_z32
, /* FetchTexel3Df */
1327 store_texel_z32
/* StoreTexel */
1333 /***************************************************************/
1334 /** \name Null format (useful for proxy textures) */
1337 const struct gl_texture_format _mesa_null_texformat
= {
1338 -1, /* MesaFormat */
1340 GL_NONE
, /* DataType */
1345 0, /* LuminanceBits */
1346 0, /* IntensityBits */
1349 0, /* StencilBits */
1351 NULL
, /* StoreTexImageFunc */
1352 fetch_null_texel
, /* FetchTexel1D */
1353 fetch_null_texel
, /* FetchTexel2D */
1354 fetch_null_texel
, /* FetchTexel3D */
1355 fetch_null_texelf
, /* FetchTexel1Df */
1356 fetch_null_texelf
, /* FetchTexel2Df */
1357 fetch_null_texelf
, /* FetchTexel3Df */
1358 store_null_texel
/* StoreTexel */
1365 * Choose an appropriate texture format given the format, type and
1366 * internalFormat parameters passed to glTexImage().
1368 * \param ctx the GL context.
1369 * \param internalFormat user's prefered internal texture format.
1370 * \param format incoming image pixel format.
1371 * \param type incoming image data type.
1373 * \return a pointer to a gl_texture_format object which describes the
1374 * choosen texture format, or NULL on failure.
1376 * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers
1377 * will typically override this function with a specialized version.
1379 const struct gl_texture_format
*
1380 _mesa_choose_tex_format( GLcontext
*ctx
, GLint internalFormat
,
1381 GLenum format
, GLenum type
)
1386 switch (internalFormat
) {
1393 return &_mesa_texformat_rgba
;
1395 return &_mesa_texformat_rgba8888
;
1397 return &_mesa_texformat_argb1555
;
1399 return &_mesa_texformat_argb4444_rev
; /* just to test another format*/
1401 return &_mesa_texformat_argb4444
;
1409 return &_mesa_texformat_rgb
;
1411 return &_mesa_texformat_rgb888
;
1413 return &_mesa_texformat_rgb332
;
1415 return &_mesa_texformat_rgb565_rev
; /* just to test another format */
1417 return &_mesa_texformat_rgb565
;
1424 return &_mesa_texformat_alpha
;
1426 return &_mesa_texformat_a8
;
1428 /* Luminance formats */
1432 case GL_LUMINANCE12
:
1433 case GL_LUMINANCE16
:
1434 return &_mesa_texformat_luminance
;
1436 return &_mesa_texformat_l8
;
1438 /* Luminance/Alpha formats */
1440 case GL_LUMINANCE_ALPHA
:
1441 case GL_LUMINANCE4_ALPHA4
:
1442 case GL_LUMINANCE6_ALPHA2
:
1443 case GL_LUMINANCE12_ALPHA4
:
1444 case GL_LUMINANCE12_ALPHA12
:
1445 case GL_LUMINANCE16_ALPHA16
:
1446 return &_mesa_texformat_luminance_alpha
;
1447 case GL_LUMINANCE8_ALPHA8
:
1448 return &_mesa_texformat_al88
;
1452 case GL_INTENSITY12
:
1453 case GL_INTENSITY16
:
1454 return &_mesa_texformat_intensity
;
1456 return &_mesa_texformat_i8
;
1458 case GL_COLOR_INDEX
:
1459 case GL_COLOR_INDEX1_EXT
:
1460 case GL_COLOR_INDEX2_EXT
:
1461 case GL_COLOR_INDEX4_EXT
:
1462 case GL_COLOR_INDEX12_EXT
:
1463 case GL_COLOR_INDEX16_EXT
:
1464 case GL_COLOR_INDEX8_EXT
:
1465 return &_mesa_texformat_ci8
;
1471 if (ctx
->Extensions
.ARB_depth_texture
) {
1472 switch (internalFormat
) {
1473 case GL_DEPTH_COMPONENT
:
1474 case GL_DEPTH_COMPONENT24
:
1475 case GL_DEPTH_COMPONENT32
:
1476 return &_mesa_texformat_z32
;
1477 case GL_DEPTH_COMPONENT16
:
1478 return &_mesa_texformat_z16
;
1484 switch (internalFormat
) {
1485 case GL_COMPRESSED_ALPHA_ARB
:
1486 return &_mesa_texformat_alpha
;
1487 case GL_COMPRESSED_LUMINANCE_ARB
:
1488 return &_mesa_texformat_luminance
;
1489 case GL_COMPRESSED_LUMINANCE_ALPHA_ARB
:
1490 return &_mesa_texformat_luminance_alpha
;
1491 case GL_COMPRESSED_INTENSITY_ARB
:
1492 return &_mesa_texformat_intensity
;
1493 case GL_COMPRESSED_RGB_ARB
:
1494 #if FEATURE_texture_fxt1
1495 if (ctx
->Extensions
.TDFX_texture_compression_FXT1
)
1496 return &_mesa_texformat_rgb_fxt1
;
1498 #if FEATURE_texture_s3tc
1499 if (ctx
->Extensions
.EXT_texture_compression_s3tc
||
1500 ctx
->Extensions
.S3_s3tc
)
1501 return &_mesa_texformat_rgb_dxt1
;
1503 return &_mesa_texformat_rgb
;
1504 case GL_COMPRESSED_RGBA_ARB
:
1505 #if FEATURE_texture_fxt1
1506 if (ctx
->Extensions
.TDFX_texture_compression_FXT1
)
1507 return &_mesa_texformat_rgba_fxt1
;
1509 #if FEATURE_texture_s3tc
1510 if (ctx
->Extensions
.EXT_texture_compression_s3tc
||
1511 ctx
->Extensions
.S3_s3tc
)
1512 return &_mesa_texformat_rgba_dxt3
; /* Not rgba_dxt1, see spec */
1514 return &_mesa_texformat_rgba
;
1519 if (ctx
->Extensions
.MESA_ycbcr_texture
) {
1520 if (internalFormat
== GL_YCBCR_MESA
) {
1521 if (type
== GL_UNSIGNED_SHORT_8_8_MESA
)
1522 return &_mesa_texformat_ycbcr
;
1524 return &_mesa_texformat_ycbcr_rev
;
1528 #if FEATURE_texture_fxt1
1529 if (ctx
->Extensions
.TDFX_texture_compression_FXT1
) {
1530 switch (internalFormat
) {
1531 case GL_COMPRESSED_RGB_FXT1_3DFX
:
1532 return &_mesa_texformat_rgb_fxt1
;
1533 case GL_COMPRESSED_RGBA_FXT1_3DFX
:
1534 return &_mesa_texformat_rgba_fxt1
;
1541 #if FEATURE_texture_s3tc
1542 if (ctx
->Extensions
.EXT_texture_compression_s3tc
) {
1543 switch (internalFormat
) {
1544 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT
:
1545 return &_mesa_texformat_rgb_dxt1
;
1546 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
:
1547 return &_mesa_texformat_rgba_dxt1
;
1548 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
:
1549 return &_mesa_texformat_rgba_dxt3
;
1550 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
:
1551 return &_mesa_texformat_rgba_dxt5
;
1557 if (ctx
->Extensions
.S3_s3tc
) {
1558 switch (internalFormat
) {
1561 return &_mesa_texformat_rgb_dxt1
;
1564 return &_mesa_texformat_rgba_dxt3
;
1571 if (ctx
->Extensions
.ARB_texture_float
) {
1572 switch (internalFormat
) {
1573 case GL_ALPHA16F_ARB
:
1574 return &_mesa_texformat_alpha_float16
;
1575 case GL_ALPHA32F_ARB
:
1576 return &_mesa_texformat_alpha_float32
;
1577 case GL_LUMINANCE16F_ARB
:
1578 return &_mesa_texformat_luminance_float16
;
1579 case GL_LUMINANCE32F_ARB
:
1580 return &_mesa_texformat_luminance_float32
;
1581 case GL_LUMINANCE_ALPHA16F_ARB
:
1582 return &_mesa_texformat_luminance_alpha_float16
;
1583 case GL_LUMINANCE_ALPHA32F_ARB
:
1584 return &_mesa_texformat_luminance_alpha_float32
;
1585 case GL_INTENSITY16F_ARB
:
1586 return &_mesa_texformat_intensity_float16
;
1587 case GL_INTENSITY32F_ARB
:
1588 return &_mesa_texformat_intensity_float32
;
1590 return &_mesa_texformat_rgb_float16
;
1592 return &_mesa_texformat_rgb_float32
;
1593 case GL_RGBA16F_ARB
:
1594 return &_mesa_texformat_rgba_float16
;
1595 case GL_RGBA32F_ARB
:
1596 return &_mesa_texformat_rgba_float32
;
1602 if (ctx
->Extensions
.EXT_packed_depth_stencil
) {
1603 switch (internalFormat
) {
1604 case GL_DEPTH_STENCIL_EXT
:
1605 case GL_DEPTH24_STENCIL8_EXT
:
1606 return &_mesa_texformat_z24_s8
;
1612 #if FEATURE_EXT_texture_sRGB
1613 if (ctx
->Extensions
.EXT_texture_sRGB
) {
1614 switch (internalFormat
) {
1617 return &_mesa_texformat_srgb8
;
1618 case GL_SRGB_ALPHA_EXT
:
1619 case GL_SRGB8_ALPHA8_EXT
:
1620 return &_mesa_texformat_srgba8
;
1621 case GL_SLUMINANCE_EXT
:
1622 case GL_SLUMINANCE8_EXT
:
1623 return &_mesa_texformat_sl8
;
1624 case GL_SLUMINANCE_ALPHA_EXT
:
1625 case GL_SLUMINANCE8_ALPHA8_EXT
:
1626 return &_mesa_texformat_sla8
;
1627 /* NOTE: not supporting any compression of sRGB at this time */
1628 case GL_COMPRESSED_SRGB_EXT
:
1629 return &_mesa_texformat_srgb8
;
1630 case GL_COMPRESSED_SRGB_ALPHA_EXT
:
1631 return &_mesa_texformat_srgba8
;
1632 case GL_COMPRESSED_SLUMINANCE_EXT
:
1633 return &_mesa_texformat_sl8
;
1634 case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT
:
1635 return &_mesa_texformat_sla8
;
1636 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
:
1637 return &_mesa_texformat_srgb8
;
1638 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
:
1639 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
:
1640 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
:
1641 return &_mesa_texformat_srgba8
;
1646 #endif /* FEATURE_EXT_texture_sRGB */
1648 _mesa_problem(ctx
, "unexpected format in _mesa_choose_tex_format()");
1655 * Return datatype and number of components per texel for the
1656 * given gl_texture_format.
1659 _mesa_format_to_type_and_comps(const struct gl_texture_format
*format
,
1660 GLenum
*datatype
, GLuint
*comps
)
1662 switch (format
->MesaFormat
) {
1663 case MESA_FORMAT_RGBA8888
:
1664 case MESA_FORMAT_RGBA8888_REV
:
1665 case MESA_FORMAT_ARGB8888
:
1666 case MESA_FORMAT_ARGB8888_REV
:
1667 *datatype
= CHAN_TYPE
;
1670 case MESA_FORMAT_RGB888
:
1671 case MESA_FORMAT_BGR888
:
1672 *datatype
= GL_UNSIGNED_BYTE
;
1675 case MESA_FORMAT_RGB565
:
1676 case MESA_FORMAT_RGB565_REV
:
1677 *datatype
= GL_UNSIGNED_SHORT_5_6_5
;
1681 case MESA_FORMAT_ARGB4444
:
1682 case MESA_FORMAT_ARGB4444_REV
:
1683 *datatype
= GL_UNSIGNED_SHORT_4_4_4_4
;
1687 case MESA_FORMAT_ARGB1555
:
1688 case MESA_FORMAT_ARGB1555_REV
:
1689 *datatype
= GL_UNSIGNED_SHORT_1_5_5_5_REV
;
1693 case MESA_FORMAT_AL88
:
1694 case MESA_FORMAT_AL88_REV
:
1695 *datatype
= GL_UNSIGNED_BYTE
;
1698 case MESA_FORMAT_RGB332
:
1699 *datatype
= GL_UNSIGNED_BYTE_3_3_2
;
1703 case MESA_FORMAT_A8
:
1704 case MESA_FORMAT_L8
:
1705 case MESA_FORMAT_I8
:
1706 case MESA_FORMAT_CI8
:
1707 *datatype
= GL_UNSIGNED_BYTE
;
1711 case MESA_FORMAT_YCBCR
:
1712 case MESA_FORMAT_YCBCR_REV
:
1713 *datatype
= GL_UNSIGNED_SHORT
;
1717 case MESA_FORMAT_Z24_S8
:
1718 *datatype
= GL_UNSIGNED_INT
;
1719 *comps
= 1; /* XXX OK? */
1722 case MESA_FORMAT_Z16
:
1723 *datatype
= GL_UNSIGNED_SHORT
;
1727 case MESA_FORMAT_Z32
:
1728 *datatype
= GL_UNSIGNED_INT
;
1732 case MESA_FORMAT_SRGB8
:
1733 *datatype
= GL_UNSIGNED_BYTE
;
1736 case MESA_FORMAT_SRGBA8
:
1737 *datatype
= GL_UNSIGNED_BYTE
;
1740 case MESA_FORMAT_SL8
:
1741 *datatype
= GL_UNSIGNED_BYTE
;
1744 case MESA_FORMAT_SLA8
:
1745 *datatype
= GL_UNSIGNED_BYTE
;
1749 case MESA_FORMAT_RGB_FXT1
:
1750 case MESA_FORMAT_RGBA_FXT1
:
1751 case MESA_FORMAT_RGB_DXT1
:
1752 case MESA_FORMAT_RGBA_DXT1
:
1753 case MESA_FORMAT_RGBA_DXT3
:
1754 case MESA_FORMAT_RGBA_DXT5
:
1755 /* XXX generate error instead? */
1756 *datatype
= GL_UNSIGNED_BYTE
;
1760 case MESA_FORMAT_RGBA
:
1761 *datatype
= CHAN_TYPE
;
1764 case MESA_FORMAT_RGB
:
1765 *datatype
= CHAN_TYPE
;
1768 case MESA_FORMAT_LUMINANCE_ALPHA
:
1769 *datatype
= CHAN_TYPE
;
1772 case MESA_FORMAT_ALPHA
:
1773 case MESA_FORMAT_LUMINANCE
:
1774 case MESA_FORMAT_INTENSITY
:
1775 *datatype
= CHAN_TYPE
;
1779 case MESA_FORMAT_RGBA_FLOAT32
:
1780 *datatype
= GL_FLOAT
;
1783 case MESA_FORMAT_RGBA_FLOAT16
:
1784 *datatype
= GL_HALF_FLOAT_ARB
;
1787 case MESA_FORMAT_RGB_FLOAT32
:
1788 *datatype
= GL_FLOAT
;
1791 case MESA_FORMAT_RGB_FLOAT16
:
1792 *datatype
= GL_HALF_FLOAT_ARB
;
1795 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
:
1796 *datatype
= GL_FLOAT
;
1799 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
:
1800 *datatype
= GL_HALF_FLOAT_ARB
;
1803 case MESA_FORMAT_ALPHA_FLOAT32
:
1804 case MESA_FORMAT_LUMINANCE_FLOAT32
:
1805 case MESA_FORMAT_INTENSITY_FLOAT32
:
1806 *datatype
= GL_FLOAT
;
1809 case MESA_FORMAT_ALPHA_FLOAT16
:
1810 case MESA_FORMAT_LUMINANCE_FLOAT16
:
1811 case MESA_FORMAT_INTENSITY_FLOAT16
:
1812 *datatype
= GL_HALF_FLOAT_ARB
;
1817 _mesa_problem(NULL
, "bad format in _mesa_format_to_type_and_comps");