2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 * Copyright (c) 2008 VMware, Inc.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 * \author Gareth Hughes
37 #include "texcompress.h"
38 #include "texcompress_fxt1.h"
39 #include "texcompress_s3tc.h"
40 #include "texformat.h"
44 #if FEATURE_EXT_texture_sRGB
47 * Convert an 8-bit sRGB value from non-linear space to a
48 * linear RGB value in [0, 1].
49 * Implemented with a 256-entry lookup table.
52 nonlinear_to_linear(GLubyte cs8
)
54 static GLfloat table
[256];
55 static GLboolean tableReady
= GL_FALSE
;
57 /* compute lookup table now */
59 for (i
= 0; i
< 256; i
++) {
60 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
62 table
[i
] = cs
/ 12.92f
;
65 table
[i
] = (GLfloat
) _mesa_pow((cs
+ 0.055) / 1.055, 2.4);
74 #endif /* FEATURE_EXT_texture_sRGB */
77 /* Texel fetch routines for all supported formats
80 #include "texformat_tmp.h"
83 #include "texformat_tmp.h"
86 #include "texformat_tmp.h"
89 * Null texel fetch function.
91 * Have to have this so the FetchTexel function pointer is never NULL.
93 static void fetch_null_texelf( const struct gl_texture_image
*texImage
,
94 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
96 (void) texImage
; (void) i
; (void) j
; (void) k
;
101 _mesa_warning(NULL
, "fetch_null_texelf() called!");
104 static void store_null_texel(struct gl_texture_image
*texImage
,
105 GLint i
, GLint j
, GLint k
, const void *texel
)
117 * Notes about the predefined gl_texture_formats:
119 * 1. There are 1D, 2D and 3D functions for fetching texels from texture
120 * images, returning both GLchan values and GLfloat values. (six
121 * functions in total)
122 * You don't have to provide both the GLchan and GLfloat functions;
123 * just one or the other is OK. Mesa will use an "adaptor" to convert
124 * between GLchan/GLfloat when needed.
125 * Since the adaptors have small performance penalty, we provide both
126 * GLchan and GLfloat functions for some common formats like RGB, RGBA.
130 /***************************************************************/
131 /** \name Default GLchan-based formats */
134 const struct gl_texture_format _mesa_texformat_rgba
= {
135 MESA_FORMAT_RGBA
, /* MesaFormat */
136 GL_RGBA
, /* BaseFormat */
137 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
138 CHAN_BITS
, /* RedBits */
139 CHAN_BITS
, /* GreenBits */
140 CHAN_BITS
, /* BlueBits */
141 CHAN_BITS
, /* AlphaBits */
142 0, /* LuminanceBits */
143 0, /* IntensityBits */
147 4 * sizeof(GLchan
), /* TexelBytes */
150 const struct gl_texture_format _mesa_texformat_rgb
= {
151 MESA_FORMAT_RGB
, /* MesaFormat */
152 GL_RGB
, /* BaseFormat */
153 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
154 CHAN_BITS
, /* RedBits */
155 CHAN_BITS
, /* GreenBits */
156 CHAN_BITS
, /* BlueBits */
158 0, /* LuminanceBits */
159 0, /* IntensityBits */
163 3 * sizeof(GLchan
), /* TexelBytes */
166 const struct gl_texture_format _mesa_texformat_alpha
= {
167 MESA_FORMAT_ALPHA
, /* MesaFormat */
168 GL_ALPHA
, /* BaseFormat */
169 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
173 CHAN_BITS
, /* AlphaBits */
174 0, /* LuminanceBits */
175 0, /* IntensityBits */
179 sizeof(GLchan
), /* TexelBytes */
182 const struct gl_texture_format _mesa_texformat_luminance
= {
183 MESA_FORMAT_LUMINANCE
, /* MesaFormat */
184 GL_LUMINANCE
, /* BaseFormat */
185 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
190 CHAN_BITS
, /* LuminanceBits */
191 0, /* IntensityBits */
195 sizeof(GLchan
), /* TexelBytes */
198 const struct gl_texture_format _mesa_texformat_luminance_alpha
= {
199 MESA_FORMAT_LUMINANCE_ALPHA
, /* MesaFormat */
200 GL_LUMINANCE_ALPHA
, /* BaseFormat */
201 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
205 CHAN_BITS
, /* AlphaBits */
206 CHAN_BITS
, /* LuminanceBits */
207 0, /* IntensityBits */
211 2 * sizeof(GLchan
), /* TexelBytes */
214 const struct gl_texture_format _mesa_texformat_intensity
= {
215 MESA_FORMAT_INTENSITY
, /* MesaFormat */
216 GL_INTENSITY
, /* BaseFormat */
217 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
222 0, /* LuminanceBits */
223 CHAN_BITS
, /* IntensityBits */
227 sizeof(GLchan
), /* TexelBytes */
231 #if FEATURE_EXT_texture_sRGB
233 const struct gl_texture_format _mesa_texformat_srgb8
= {
234 MESA_FORMAT_SRGB8
, /* MesaFormat */
235 GL_RGB
, /* BaseFormat */
236 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
241 0, /* LuminanceBits */
242 0, /* IntensityBits */
249 const struct gl_texture_format _mesa_texformat_srgba8
= {
250 MESA_FORMAT_SRGBA8
, /* MesaFormat */
251 GL_RGBA
, /* BaseFormat */
252 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
257 0, /* LuminanceBits */
258 0, /* IntensityBits */
265 const struct gl_texture_format _mesa_texformat_sargb8
= {
266 MESA_FORMAT_SARGB8
, /* MesaFormat */
267 GL_RGBA
, /* BaseFormat */
268 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
273 0, /* LuminanceBits */
274 0, /* IntensityBits */
281 const struct gl_texture_format _mesa_texformat_sl8
= {
282 MESA_FORMAT_SL8
, /* MesaFormat */
283 GL_LUMINANCE
, /* BaseFormat */
284 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
289 8, /* LuminanceBits */
290 0, /* IntensityBits */
297 /* Note: this format name looks like a misnomer, make it sal8? */
298 const struct gl_texture_format _mesa_texformat_sla8
= {
299 MESA_FORMAT_SLA8
, /* MesaFormat */
300 GL_LUMINANCE_ALPHA
, /* BaseFormat */
301 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
306 8, /* LuminanceBits */
307 0, /* IntensityBits */
314 #endif /* FEATURE_EXT_texture_sRGB */
316 const struct gl_texture_format _mesa_texformat_rgba_float32
= {
317 MESA_FORMAT_RGBA_FLOAT32
, /* MesaFormat */
318 GL_RGBA
, /* BaseFormat */
319 GL_FLOAT
, /* DataType */
320 8 * sizeof(GLfloat
), /* RedBits */
321 8 * sizeof(GLfloat
), /* GreenBits */
322 8 * sizeof(GLfloat
), /* BlueBits */
323 8 * sizeof(GLfloat
), /* AlphaBits */
324 0, /* LuminanceBits */
325 0, /* IntensityBits */
329 4 * sizeof(GLfloat
), /* TexelBytes */
332 const struct gl_texture_format _mesa_texformat_rgba_float16
= {
333 MESA_FORMAT_RGBA_FLOAT16
, /* MesaFormat */
334 GL_RGBA
, /* BaseFormat */
335 GL_FLOAT
, /* DataType */
336 8 * sizeof(GLhalfARB
), /* RedBits */
337 8 * sizeof(GLhalfARB
), /* GreenBits */
338 8 * sizeof(GLhalfARB
), /* BlueBits */
339 8 * sizeof(GLhalfARB
), /* AlphaBits */
340 0, /* LuminanceBits */
341 0, /* IntensityBits */
345 4 * sizeof(GLhalfARB
), /* TexelBytes */
348 const struct gl_texture_format _mesa_texformat_rgb_float32
= {
349 MESA_FORMAT_RGB_FLOAT32
, /* MesaFormat */
350 GL_RGB
, /* BaseFormat */
351 GL_FLOAT
, /* DataType */
352 8 * sizeof(GLfloat
), /* RedBits */
353 8 * sizeof(GLfloat
), /* GreenBits */
354 8 * sizeof(GLfloat
), /* BlueBits */
356 0, /* LuminanceBits */
357 0, /* IntensityBits */
361 3 * sizeof(GLfloat
), /* TexelBytes */
364 const struct gl_texture_format _mesa_texformat_rgb_float16
= {
365 MESA_FORMAT_RGB_FLOAT16
, /* MesaFormat */
366 GL_RGB
, /* BaseFormat */
367 GL_FLOAT
, /* DataType */
368 8 * sizeof(GLhalfARB
), /* RedBits */
369 8 * sizeof(GLhalfARB
), /* GreenBits */
370 8 * sizeof(GLhalfARB
), /* BlueBits */
372 0, /* LuminanceBits */
373 0, /* IntensityBits */
377 3 * sizeof(GLhalfARB
), /* TexelBytes */
380 const struct gl_texture_format _mesa_texformat_alpha_float32
= {
381 MESA_FORMAT_ALPHA_FLOAT32
, /* MesaFormat */
382 GL_ALPHA
, /* BaseFormat */
383 GL_FLOAT
, /* DataType */
387 8 * sizeof(GLfloat
), /* AlphaBits */
388 0, /* LuminanceBits */
389 0, /* IntensityBits */
393 1 * sizeof(GLfloat
), /* TexelBytes */
396 const struct gl_texture_format _mesa_texformat_alpha_float16
= {
397 MESA_FORMAT_ALPHA_FLOAT16
, /* MesaFormat */
398 GL_ALPHA
, /* BaseFormat */
399 GL_FLOAT
, /* DataType */
403 8 * sizeof(GLhalfARB
), /* AlphaBits */
404 0, /* LuminanceBits */
405 0, /* IntensityBits */
409 1 * sizeof(GLhalfARB
), /* TexelBytes */
412 const struct gl_texture_format _mesa_texformat_luminance_float32
= {
413 MESA_FORMAT_LUMINANCE_FLOAT32
, /* MesaFormat */
414 GL_LUMINANCE
, /* BaseFormat */
415 GL_FLOAT
, /* DataType */
420 8 * sizeof(GLfloat
), /* LuminanceBits */
421 0, /* IntensityBits */
425 1 * sizeof(GLfloat
), /* TexelBytes */
428 const struct gl_texture_format _mesa_texformat_luminance_float16
= {
429 MESA_FORMAT_LUMINANCE_FLOAT16
, /* MesaFormat */
430 GL_LUMINANCE
, /* BaseFormat */
431 GL_FLOAT
, /* DataType */
436 8 * sizeof(GLhalfARB
), /* LuminanceBits */
437 0, /* IntensityBits */
441 1 * sizeof(GLhalfARB
), /* TexelBytes */
444 const struct gl_texture_format _mesa_texformat_luminance_alpha_float32
= {
445 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
, /* MesaFormat */
446 GL_LUMINANCE_ALPHA
, /* BaseFormat */
447 GL_FLOAT
, /* DataType */
451 8 * sizeof(GLfloat
), /* AlphaBits */
452 8 * sizeof(GLfloat
), /* LuminanceBits */
453 0, /* IntensityBits */
457 2 * sizeof(GLfloat
), /* TexelBytes */
460 const struct gl_texture_format _mesa_texformat_luminance_alpha_float16
= {
461 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
, /* MesaFormat */
462 GL_LUMINANCE_ALPHA
, /* BaseFormat */
463 GL_FLOAT
, /* DataType */
467 8 * sizeof(GLhalfARB
), /* AlphaBits */
468 8 * sizeof(GLhalfARB
), /* LuminanceBits */
469 0, /* IntensityBits */
473 2 * sizeof(GLhalfARB
), /* TexelBytes */
476 const struct gl_texture_format _mesa_texformat_intensity_float32
= {
477 MESA_FORMAT_INTENSITY_FLOAT32
, /* MesaFormat */
478 GL_INTENSITY
, /* BaseFormat */
479 GL_FLOAT
, /* DataType */
484 0, /* LuminanceBits */
485 8 * sizeof(GLfloat
), /* IntensityBits */
489 1 * sizeof(GLfloat
), /* TexelBytes */
492 const struct gl_texture_format _mesa_texformat_intensity_float16
= {
493 MESA_FORMAT_INTENSITY_FLOAT16
, /* MesaFormat */
494 GL_INTENSITY
, /* BaseFormat */
495 GL_FLOAT
, /* DataType */
500 0, /* LuminanceBits */
501 8 * sizeof(GLhalfARB
), /* IntensityBits */
505 1 * sizeof(GLhalfARB
), /* TexelBytes */
508 const struct gl_texture_format _mesa_texformat_dudv8
= {
509 MESA_FORMAT_DUDV8
, /* MesaFormat */
510 GL_DUDV_ATI
, /* BaseFormat */
511 GL_SIGNED_NORMALIZED
, /* DataType */
512 /* maybe should add dudvBits field, but spec seems to be
513 lacking the ability to query with GetTexLevelParameter anyway */
518 0, /* LuminanceBits */
519 0, /* IntensityBits */
526 const struct gl_texture_format _mesa_texformat_signed_rgba8888
= {
527 MESA_FORMAT_SIGNED_RGBA8888
, /* MesaFormat */
528 GL_RGBA
, /* BaseFormat */
529 GL_SIGNED_NORMALIZED
, /* DataType */
534 0, /* LuminanceBits */
535 0, /* IntensityBits */
542 const struct gl_texture_format _mesa_texformat_signed_rgba8888_rev
= {
543 MESA_FORMAT_SIGNED_RGBA8888_REV
, /* MesaFormat */
544 GL_RGBA
, /* BaseFormat */
545 GL_SIGNED_NORMALIZED
, /* DataType */
550 0, /* LuminanceBits */
551 0, /* IntensityBits */
561 /***************************************************************/
562 /** \name Hardware formats */
565 const struct gl_texture_format _mesa_texformat_rgba8888
= {
566 MESA_FORMAT_RGBA8888
, /* MesaFormat */
567 GL_RGBA
, /* BaseFormat */
568 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
573 0, /* LuminanceBits */
574 0, /* IntensityBits */
581 const struct gl_texture_format _mesa_texformat_rgba8888_rev
= {
582 MESA_FORMAT_RGBA8888_REV
, /* MesaFormat */
583 GL_RGBA
, /* BaseFormat */
584 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
589 0, /* LuminanceBits */
590 0, /* IntensityBits */
597 const struct gl_texture_format _mesa_texformat_argb8888
= {
598 MESA_FORMAT_ARGB8888
, /* MesaFormat */
599 GL_RGBA
, /* BaseFormat */
600 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
605 0, /* LuminanceBits */
606 0, /* IntensityBits */
613 const struct gl_texture_format _mesa_texformat_argb8888_rev
= {
614 MESA_FORMAT_ARGB8888_REV
, /* MesaFormat */
615 GL_RGBA
, /* BaseFormat */
616 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
621 0, /* LuminanceBits */
622 0, /* IntensityBits */
629 const struct gl_texture_format _mesa_texformat_rgb888
= {
630 MESA_FORMAT_RGB888
, /* MesaFormat */
631 GL_RGB
, /* BaseFormat */
632 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
637 0, /* LuminanceBits */
638 0, /* IntensityBits */
645 const struct gl_texture_format _mesa_texformat_bgr888
= {
646 MESA_FORMAT_BGR888
, /* MesaFormat */
647 GL_RGB
, /* BaseFormat */
648 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
653 0, /* LuminanceBits */
654 0, /* IntensityBits */
661 const struct gl_texture_format _mesa_texformat_rgb565
= {
662 MESA_FORMAT_RGB565
, /* MesaFormat */
663 GL_RGB
, /* BaseFormat */
664 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
669 0, /* LuminanceBits */
670 0, /* IntensityBits */
677 const struct gl_texture_format _mesa_texformat_rgb565_rev
= {
678 MESA_FORMAT_RGB565_REV
, /* MesaFormat */
679 GL_RGB
, /* BaseFormat */
680 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
685 0, /* LuminanceBits */
686 0, /* IntensityBits */
693 const struct gl_texture_format _mesa_texformat_rgba4444
= {
694 MESA_FORMAT_RGBA4444
, /* MesaFormat */
695 GL_RGBA
, /* BaseFormat */
696 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
701 0, /* LuminanceBits */
702 0, /* IntensityBits */
709 const struct gl_texture_format _mesa_texformat_argb4444
= {
710 MESA_FORMAT_ARGB4444
, /* MesaFormat */
711 GL_RGBA
, /* BaseFormat */
712 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
717 0, /* LuminanceBits */
718 0, /* IntensityBits */
725 const struct gl_texture_format _mesa_texformat_argb4444_rev
= {
726 MESA_FORMAT_ARGB4444_REV
, /* MesaFormat */
727 GL_RGBA
, /* BaseFormat */
728 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
733 0, /* LuminanceBits */
734 0, /* IntensityBits */
741 const struct gl_texture_format _mesa_texformat_rgba5551
= {
742 MESA_FORMAT_RGBA5551
, /* MesaFormat */
743 GL_RGBA
, /* BaseFormat */
744 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
749 0, /* LuminanceBits */
750 0, /* IntensityBits */
757 const struct gl_texture_format _mesa_texformat_argb1555
= {
758 MESA_FORMAT_ARGB1555
, /* MesaFormat */
759 GL_RGBA
, /* BaseFormat */
760 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
765 0, /* LuminanceBits */
766 0, /* IntensityBits */
773 const struct gl_texture_format _mesa_texformat_argb1555_rev
= {
774 MESA_FORMAT_ARGB1555_REV
, /* MesaFormat */
775 GL_RGBA
, /* BaseFormat */
776 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
781 0, /* LuminanceBits */
782 0, /* IntensityBits */
789 const struct gl_texture_format _mesa_texformat_al88
= {
790 MESA_FORMAT_AL88
, /* MesaFormat */
791 GL_LUMINANCE_ALPHA
, /* BaseFormat */
792 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
797 8, /* LuminanceBits */
798 0, /* IntensityBits */
805 const struct gl_texture_format _mesa_texformat_al88_rev
= {
806 MESA_FORMAT_AL88_REV
, /* MesaFormat */
807 GL_LUMINANCE_ALPHA
, /* BaseFormat */
808 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
813 8, /* LuminanceBits */
814 0, /* IntensityBits */
821 const struct gl_texture_format _mesa_texformat_rgb332
= {
822 MESA_FORMAT_RGB332
, /* MesaFormat */
823 GL_RGB
, /* BaseFormat */
824 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
829 0, /* LuminanceBits */
830 0, /* IntensityBits */
837 const struct gl_texture_format _mesa_texformat_a8
= {
838 MESA_FORMAT_A8
, /* MesaFormat */
839 GL_ALPHA
, /* BaseFormat */
840 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
845 0, /* LuminanceBits */
846 0, /* IntensityBits */
853 const struct gl_texture_format _mesa_texformat_l8
= {
854 MESA_FORMAT_L8
, /* MesaFormat */
855 GL_LUMINANCE
, /* BaseFormat */
856 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
861 8, /* LuminanceBits */
862 0, /* IntensityBits */
869 const struct gl_texture_format _mesa_texformat_i8
= {
870 MESA_FORMAT_I8
, /* MesaFormat */
871 GL_INTENSITY
, /* BaseFormat */
872 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
877 0, /* LuminanceBits */
878 8, /* IntensityBits */
885 const struct gl_texture_format _mesa_texformat_ci8
= {
886 MESA_FORMAT_CI8
, /* MesaFormat */
887 GL_COLOR_INDEX
, /* BaseFormat */
888 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
893 0, /* LuminanceBits */
894 0, /* IntensityBits */
901 const struct gl_texture_format _mesa_texformat_ycbcr
= {
902 MESA_FORMAT_YCBCR
, /* MesaFormat */
903 GL_YCBCR_MESA
, /* BaseFormat */
904 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
909 0, /* LuminanceBits */
910 0, /* IntensityBits */
917 const struct gl_texture_format _mesa_texformat_ycbcr_rev
= {
918 MESA_FORMAT_YCBCR_REV
, /* MesaFormat */
919 GL_YCBCR_MESA
, /* BaseFormat */
920 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
925 0, /* LuminanceBits */
926 0, /* IntensityBits */
933 const struct gl_texture_format _mesa_texformat_z24_s8
= {
934 MESA_FORMAT_Z24_S8
, /* MesaFormat */
935 GL_DEPTH_STENCIL_EXT
, /* BaseFormat */
936 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
941 0, /* LuminanceBits */
942 0, /* IntensityBits */
949 const struct gl_texture_format _mesa_texformat_s8_z24
= {
950 MESA_FORMAT_S8_Z24
, /* MesaFormat */
951 GL_DEPTH_STENCIL_EXT
, /* BaseFormat */
952 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
957 0, /* LuminanceBits */
958 0, /* IntensityBits */
965 const struct gl_texture_format _mesa_texformat_z16
= {
966 MESA_FORMAT_Z16
, /* MesaFormat */
967 GL_DEPTH_COMPONENT
, /* BaseFormat */
968 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
973 0, /* LuminanceBits */
974 0, /* IntensityBits */
976 sizeof(GLushort
) * 8, /* DepthBits */
978 sizeof(GLushort
), /* TexelBytes */
981 const struct gl_texture_format _mesa_texformat_z32
= {
982 MESA_FORMAT_Z32
, /* MesaFormat */
983 GL_DEPTH_COMPONENT
, /* BaseFormat */
984 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
989 0, /* LuminanceBits */
990 0, /* IntensityBits */
992 sizeof(GLuint
) * 8, /* DepthBits */
994 sizeof(GLuint
), /* TexelBytes */
1000 /***************************************************************/
1001 /** \name Null format (useful for proxy textures) */
1004 const struct gl_texture_format _mesa_null_texformat
= {
1005 -1, /* MesaFormat */
1007 GL_NONE
, /* DataType */
1012 0, /* LuminanceBits */
1013 0, /* IntensityBits */
1016 0, /* StencilBits */
1024 * Choose an appropriate texture format given the format, type and
1025 * internalFormat parameters passed to glTexImage().
1027 * \param ctx the GL context.
1028 * \param internalFormat user's prefered internal texture format.
1029 * \param format incoming image pixel format.
1030 * \param type incoming image data type.
1032 * \return a pointer to a gl_texture_format object which describes the
1033 * choosen texture format, or NULL on failure.
1035 * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers
1036 * will typically override this function with a specialized version.
1038 const struct gl_texture_format
*
1039 _mesa_choose_tex_format( GLcontext
*ctx
, GLint internalFormat
,
1040 GLenum format
, GLenum type
)
1045 switch (internalFormat
) {
1052 return &_mesa_texformat_rgba
;
1054 return &_mesa_texformat_rgba8888
;
1056 return &_mesa_texformat_argb1555
;
1058 return &_mesa_texformat_argb4444_rev
; /* just to test another format*/
1060 return &_mesa_texformat_argb4444
;
1068 return &_mesa_texformat_rgb
;
1070 return &_mesa_texformat_rgb888
;
1072 return &_mesa_texformat_rgb332
;
1074 return &_mesa_texformat_rgb565_rev
; /* just to test another format */
1076 return &_mesa_texformat_rgb565
;
1083 return &_mesa_texformat_alpha
;
1085 return &_mesa_texformat_a8
;
1087 /* Luminance formats */
1091 case GL_LUMINANCE12
:
1092 case GL_LUMINANCE16
:
1093 return &_mesa_texformat_luminance
;
1095 return &_mesa_texformat_l8
;
1097 /* Luminance/Alpha formats */
1099 case GL_LUMINANCE_ALPHA
:
1100 case GL_LUMINANCE4_ALPHA4
:
1101 case GL_LUMINANCE6_ALPHA2
:
1102 case GL_LUMINANCE12_ALPHA4
:
1103 case GL_LUMINANCE12_ALPHA12
:
1104 case GL_LUMINANCE16_ALPHA16
:
1105 return &_mesa_texformat_luminance_alpha
;
1106 case GL_LUMINANCE8_ALPHA8
:
1107 return &_mesa_texformat_al88
;
1111 case GL_INTENSITY12
:
1112 case GL_INTENSITY16
:
1113 return &_mesa_texformat_intensity
;
1115 return &_mesa_texformat_i8
;
1117 case GL_COLOR_INDEX
:
1118 case GL_COLOR_INDEX1_EXT
:
1119 case GL_COLOR_INDEX2_EXT
:
1120 case GL_COLOR_INDEX4_EXT
:
1121 case GL_COLOR_INDEX12_EXT
:
1122 case GL_COLOR_INDEX16_EXT
:
1123 case GL_COLOR_INDEX8_EXT
:
1124 return &_mesa_texformat_ci8
;
1130 if (ctx
->Extensions
.ARB_depth_texture
) {
1131 switch (internalFormat
) {
1132 case GL_DEPTH_COMPONENT
:
1133 case GL_DEPTH_COMPONENT24
:
1134 case GL_DEPTH_COMPONENT32
:
1135 return &_mesa_texformat_z32
;
1136 case GL_DEPTH_COMPONENT16
:
1137 return &_mesa_texformat_z16
;
1143 switch (internalFormat
) {
1144 case GL_COMPRESSED_ALPHA_ARB
:
1145 return &_mesa_texformat_alpha
;
1146 case GL_COMPRESSED_LUMINANCE_ARB
:
1147 return &_mesa_texformat_luminance
;
1148 case GL_COMPRESSED_LUMINANCE_ALPHA_ARB
:
1149 return &_mesa_texformat_luminance_alpha
;
1150 case GL_COMPRESSED_INTENSITY_ARB
:
1151 return &_mesa_texformat_intensity
;
1152 case GL_COMPRESSED_RGB_ARB
:
1153 #if FEATURE_texture_fxt1
1154 if (ctx
->Extensions
.TDFX_texture_compression_FXT1
)
1155 return &_mesa_texformat_rgb_fxt1
;
1157 #if FEATURE_texture_s3tc
1158 if (ctx
->Extensions
.EXT_texture_compression_s3tc
||
1159 ctx
->Extensions
.S3_s3tc
)
1160 return &_mesa_texformat_rgb_dxt1
;
1162 return &_mesa_texformat_rgb
;
1163 case GL_COMPRESSED_RGBA_ARB
:
1164 #if FEATURE_texture_fxt1
1165 if (ctx
->Extensions
.TDFX_texture_compression_FXT1
)
1166 return &_mesa_texformat_rgba_fxt1
;
1168 #if FEATURE_texture_s3tc
1169 if (ctx
->Extensions
.EXT_texture_compression_s3tc
||
1170 ctx
->Extensions
.S3_s3tc
)
1171 return &_mesa_texformat_rgba_dxt3
; /* Not rgba_dxt1, see spec */
1173 return &_mesa_texformat_rgba
;
1178 if (ctx
->Extensions
.MESA_ycbcr_texture
) {
1179 if (internalFormat
== GL_YCBCR_MESA
) {
1180 if (type
== GL_UNSIGNED_SHORT_8_8_MESA
)
1181 return &_mesa_texformat_ycbcr
;
1183 return &_mesa_texformat_ycbcr_rev
;
1187 #if FEATURE_texture_fxt1
1188 if (ctx
->Extensions
.TDFX_texture_compression_FXT1
) {
1189 switch (internalFormat
) {
1190 case GL_COMPRESSED_RGB_FXT1_3DFX
:
1191 return &_mesa_texformat_rgb_fxt1
;
1192 case GL_COMPRESSED_RGBA_FXT1_3DFX
:
1193 return &_mesa_texformat_rgba_fxt1
;
1200 #if FEATURE_texture_s3tc
1201 if (ctx
->Extensions
.EXT_texture_compression_s3tc
) {
1202 switch (internalFormat
) {
1203 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT
:
1204 return &_mesa_texformat_rgb_dxt1
;
1205 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
:
1206 return &_mesa_texformat_rgba_dxt1
;
1207 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
:
1208 return &_mesa_texformat_rgba_dxt3
;
1209 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
:
1210 return &_mesa_texformat_rgba_dxt5
;
1216 if (ctx
->Extensions
.S3_s3tc
) {
1217 switch (internalFormat
) {
1220 return &_mesa_texformat_rgb_dxt1
;
1223 return &_mesa_texformat_rgba_dxt3
;
1230 if (ctx
->Extensions
.ARB_texture_float
) {
1231 switch (internalFormat
) {
1232 case GL_ALPHA16F_ARB
:
1233 return &_mesa_texformat_alpha_float16
;
1234 case GL_ALPHA32F_ARB
:
1235 return &_mesa_texformat_alpha_float32
;
1236 case GL_LUMINANCE16F_ARB
:
1237 return &_mesa_texformat_luminance_float16
;
1238 case GL_LUMINANCE32F_ARB
:
1239 return &_mesa_texformat_luminance_float32
;
1240 case GL_LUMINANCE_ALPHA16F_ARB
:
1241 return &_mesa_texformat_luminance_alpha_float16
;
1242 case GL_LUMINANCE_ALPHA32F_ARB
:
1243 return &_mesa_texformat_luminance_alpha_float32
;
1244 case GL_INTENSITY16F_ARB
:
1245 return &_mesa_texformat_intensity_float16
;
1246 case GL_INTENSITY32F_ARB
:
1247 return &_mesa_texformat_intensity_float32
;
1249 return &_mesa_texformat_rgb_float16
;
1251 return &_mesa_texformat_rgb_float32
;
1252 case GL_RGBA16F_ARB
:
1253 return &_mesa_texformat_rgba_float16
;
1254 case GL_RGBA32F_ARB
:
1255 return &_mesa_texformat_rgba_float32
;
1261 if (ctx
->Extensions
.EXT_packed_depth_stencil
) {
1262 switch (internalFormat
) {
1263 case GL_DEPTH_STENCIL_EXT
:
1264 case GL_DEPTH24_STENCIL8_EXT
:
1265 return &_mesa_texformat_z24_s8
;
1271 if (ctx
->Extensions
.ATI_envmap_bumpmap
) {
1272 switch (internalFormat
) {
1275 return &_mesa_texformat_dudv8
;
1281 if (ctx
->Extensions
.MESA_texture_signed_rgba
) {
1282 switch (internalFormat
) {
1284 case GL_RGBA8_SNORM
:
1285 return &_mesa_texformat_signed_rgba8888
;
1292 #if FEATURE_EXT_texture_sRGB
1293 if (ctx
->Extensions
.EXT_texture_sRGB
) {
1294 switch (internalFormat
) {
1297 return &_mesa_texformat_srgb8
;
1298 case GL_SRGB_ALPHA_EXT
:
1299 case GL_SRGB8_ALPHA8_EXT
:
1300 return &_mesa_texformat_srgba8
;
1301 case GL_SLUMINANCE_EXT
:
1302 case GL_SLUMINANCE8_EXT
:
1303 return &_mesa_texformat_sl8
;
1304 case GL_SLUMINANCE_ALPHA_EXT
:
1305 case GL_SLUMINANCE8_ALPHA8_EXT
:
1306 return &_mesa_texformat_sla8
;
1307 case GL_COMPRESSED_SLUMINANCE_EXT
:
1308 return &_mesa_texformat_sl8
;
1309 case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT
:
1310 return &_mesa_texformat_sla8
;
1311 case GL_COMPRESSED_SRGB_EXT
:
1312 #if FEATURE_texture_s3tc
1313 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
1314 return &_mesa_texformat_srgb_dxt1
;
1316 return &_mesa_texformat_srgb8
;
1317 case GL_COMPRESSED_SRGB_ALPHA_EXT
:
1318 #if FEATURE_texture_s3tc
1319 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
1320 return &_mesa_texformat_srgba_dxt3
; /* Not srgba_dxt1, see spec */
1322 return &_mesa_texformat_srgba8
;
1323 #if FEATURE_texture_s3tc
1324 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
:
1325 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
1326 return &_mesa_texformat_srgb_dxt1
;
1328 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
:
1329 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
1330 return &_mesa_texformat_srgba_dxt1
;
1332 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
:
1333 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
1334 return &_mesa_texformat_srgba_dxt3
;
1336 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
:
1337 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
1338 return &_mesa_texformat_srgba_dxt5
;
1345 #endif /* FEATURE_EXT_texture_sRGB */
1347 _mesa_problem(ctx
, "unexpected format in _mesa_choose_tex_format()");
1354 * Return datatype and number of components per texel for the
1355 * given gl_texture_format.
1358 _mesa_format_to_type_and_comps(const struct gl_texture_format
*format
,
1359 GLenum
*datatype
, GLuint
*comps
)
1361 switch (format
->MesaFormat
) {
1362 case MESA_FORMAT_RGBA8888
:
1363 case MESA_FORMAT_RGBA8888_REV
:
1364 case MESA_FORMAT_ARGB8888
:
1365 case MESA_FORMAT_ARGB8888_REV
:
1366 *datatype
= CHAN_TYPE
;
1369 case MESA_FORMAT_RGB888
:
1370 case MESA_FORMAT_BGR888
:
1371 *datatype
= GL_UNSIGNED_BYTE
;
1374 case MESA_FORMAT_RGB565
:
1375 case MESA_FORMAT_RGB565_REV
:
1376 *datatype
= GL_UNSIGNED_SHORT_5_6_5
;
1380 case MESA_FORMAT_ARGB4444
:
1381 case MESA_FORMAT_ARGB4444_REV
:
1382 *datatype
= GL_UNSIGNED_SHORT_4_4_4_4
;
1386 case MESA_FORMAT_ARGB1555
:
1387 case MESA_FORMAT_ARGB1555_REV
:
1388 *datatype
= GL_UNSIGNED_SHORT_1_5_5_5_REV
;
1392 case MESA_FORMAT_AL88
:
1393 case MESA_FORMAT_AL88_REV
:
1394 *datatype
= GL_UNSIGNED_BYTE
;
1397 case MESA_FORMAT_RGB332
:
1398 *datatype
= GL_UNSIGNED_BYTE_3_3_2
;
1402 case MESA_FORMAT_A8
:
1403 case MESA_FORMAT_L8
:
1404 case MESA_FORMAT_I8
:
1405 case MESA_FORMAT_CI8
:
1406 *datatype
= GL_UNSIGNED_BYTE
;
1410 case MESA_FORMAT_YCBCR
:
1411 case MESA_FORMAT_YCBCR_REV
:
1412 *datatype
= GL_UNSIGNED_SHORT
;
1416 case MESA_FORMAT_Z24_S8
:
1417 *datatype
= GL_UNSIGNED_INT
;
1418 *comps
= 1; /* XXX OK? */
1421 case MESA_FORMAT_S8_Z24
:
1422 *datatype
= GL_UNSIGNED_INT
;
1423 *comps
= 1; /* XXX OK? */
1426 case MESA_FORMAT_Z16
:
1427 *datatype
= GL_UNSIGNED_SHORT
;
1431 case MESA_FORMAT_Z32
:
1432 *datatype
= GL_UNSIGNED_INT
;
1436 case MESA_FORMAT_DUDV8
:
1437 *datatype
= GL_BYTE
;
1441 case MESA_FORMAT_SIGNED_RGBA8888
:
1442 case MESA_FORMAT_SIGNED_RGBA8888_REV
:
1443 *datatype
= GL_BYTE
;
1447 #if FEATURE_EXT_texture_sRGB
1448 case MESA_FORMAT_SRGB8
:
1449 *datatype
= GL_UNSIGNED_BYTE
;
1452 case MESA_FORMAT_SRGBA8
:
1453 case MESA_FORMAT_SARGB8
:
1454 *datatype
= GL_UNSIGNED_BYTE
;
1457 case MESA_FORMAT_SL8
:
1458 *datatype
= GL_UNSIGNED_BYTE
;
1461 case MESA_FORMAT_SLA8
:
1462 *datatype
= GL_UNSIGNED_BYTE
;
1467 #if FEATURE_texture_fxt1
1468 case MESA_FORMAT_RGB_FXT1
:
1469 case MESA_FORMAT_RGBA_FXT1
:
1471 #if FEATURE_texture_s3tc
1472 case MESA_FORMAT_RGB_DXT1
:
1473 case MESA_FORMAT_RGBA_DXT1
:
1474 case MESA_FORMAT_RGBA_DXT3
:
1475 case MESA_FORMAT_RGBA_DXT5
:
1476 #if FEATURE_EXT_texture_sRGB
1477 case MESA_FORMAT_SRGB_DXT1
:
1478 case MESA_FORMAT_SRGBA_DXT1
:
1479 case MESA_FORMAT_SRGBA_DXT3
:
1480 case MESA_FORMAT_SRGBA_DXT5
:
1482 /* XXX generate error instead? */
1483 *datatype
= GL_UNSIGNED_BYTE
;
1488 case MESA_FORMAT_RGBA
:
1489 *datatype
= CHAN_TYPE
;
1492 case MESA_FORMAT_RGB
:
1493 *datatype
= CHAN_TYPE
;
1496 case MESA_FORMAT_LUMINANCE_ALPHA
:
1497 *datatype
= CHAN_TYPE
;
1500 case MESA_FORMAT_ALPHA
:
1501 case MESA_FORMAT_LUMINANCE
:
1502 case MESA_FORMAT_INTENSITY
:
1503 *datatype
= CHAN_TYPE
;
1507 case MESA_FORMAT_RGBA_FLOAT32
:
1508 *datatype
= GL_FLOAT
;
1511 case MESA_FORMAT_RGBA_FLOAT16
:
1512 *datatype
= GL_HALF_FLOAT_ARB
;
1515 case MESA_FORMAT_RGB_FLOAT32
:
1516 *datatype
= GL_FLOAT
;
1519 case MESA_FORMAT_RGB_FLOAT16
:
1520 *datatype
= GL_HALF_FLOAT_ARB
;
1523 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
:
1524 *datatype
= GL_FLOAT
;
1527 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
:
1528 *datatype
= GL_HALF_FLOAT_ARB
;
1531 case MESA_FORMAT_ALPHA_FLOAT32
:
1532 case MESA_FORMAT_LUMINANCE_FLOAT32
:
1533 case MESA_FORMAT_INTENSITY_FLOAT32
:
1534 *datatype
= GL_FLOAT
;
1537 case MESA_FORMAT_ALPHA_FLOAT16
:
1538 case MESA_FORMAT_LUMINANCE_FLOAT16
:
1539 case MESA_FORMAT_INTENSITY_FLOAT16
:
1540 *datatype
= GL_HALF_FLOAT_ARB
;
1545 _mesa_problem(NULL
, "bad format in _mesa_format_to_type_and_comps");
1554 * Table to map MESA_FORMAT_ to texel fetch/store funcs.
1555 * XXX this is somewhat temporary.
1559 FetchTexelFuncF Fetch1D
;
1560 FetchTexelFuncF Fetch2D
;
1561 FetchTexelFuncF Fetch3D
;
1562 StoreTexelFunc StoreTexel
;
1564 texfetch_funcs
[MESA_FORMAT_COUNT
] =
1568 fetch_texel_1d_f_rgba
,
1569 fetch_texel_2d_f_rgba
,
1570 fetch_texel_3d_f_rgba
,
1575 fetch_texel_1d_f_rgb
,
1576 fetch_texel_2d_f_rgb
,
1577 fetch_texel_3d_f_rgb
,
1582 fetch_texel_1d_f_alpha
,
1583 fetch_texel_2d_f_alpha
,
1584 fetch_texel_3d_f_alpha
,
1588 MESA_FORMAT_LUMINANCE
,
1589 fetch_texel_1d_f_luminance
,
1590 fetch_texel_2d_f_luminance
,
1591 fetch_texel_3d_f_luminance
,
1592 store_texel_luminance
1595 MESA_FORMAT_LUMINANCE_ALPHA
,
1596 fetch_texel_1d_f_luminance_alpha
,
1597 fetch_texel_2d_f_luminance_alpha
,
1598 fetch_texel_3d_f_luminance_alpha
,
1599 store_texel_luminance_alpha
1602 MESA_FORMAT_INTENSITY
,
1603 fetch_texel_1d_f_intensity
,
1604 fetch_texel_2d_f_intensity
,
1605 fetch_texel_3d_f_intensity
,
1606 store_texel_intensity
1610 fetch_texel_1d_srgb8
,
1611 fetch_texel_2d_srgb8
,
1612 fetch_texel_3d_srgb8
,
1617 fetch_texel_1d_srgba8
,
1618 fetch_texel_2d_srgba8
,
1619 fetch_texel_3d_srgba8
,
1624 fetch_texel_1d_sargb8
,
1625 fetch_texel_2d_sargb8
,
1626 fetch_texel_3d_sargb8
,
1638 fetch_texel_1d_sla8
,
1639 fetch_texel_2d_sla8
,
1640 fetch_texel_3d_sla8
,
1644 MESA_FORMAT_RGB_FXT1
,
1646 _mesa_fetch_texel_2d_f_rgb_fxt1
,
1651 MESA_FORMAT_RGBA_FXT1
,
1653 _mesa_fetch_texel_2d_f_rgba_fxt1
,
1658 MESA_FORMAT_RGB_DXT1
,
1660 _mesa_fetch_texel_2d_f_rgb_dxt1
,
1665 MESA_FORMAT_RGBA_DXT1
,
1667 _mesa_fetch_texel_2d_f_rgba_dxt1
,
1672 MESA_FORMAT_RGBA_DXT3
,
1674 _mesa_fetch_texel_2d_f_rgba_dxt3
,
1679 MESA_FORMAT_RGBA_DXT5
,
1681 _mesa_fetch_texel_2d_f_rgba_dxt5
,
1686 MESA_FORMAT_SRGB_DXT1
,
1688 _mesa_fetch_texel_2d_f_srgb_dxt1
,
1693 MESA_FORMAT_SRGBA_DXT1
,
1695 _mesa_fetch_texel_2d_f_srgba_dxt1
,
1700 MESA_FORMAT_SRGBA_DXT3
,
1702 _mesa_fetch_texel_2d_f_srgba_dxt3
,
1707 MESA_FORMAT_SRGBA_DXT5
,
1709 _mesa_fetch_texel_2d_f_srgba_dxt5
,
1714 MESA_FORMAT_RGBA_FLOAT32
,
1715 fetch_texel_1d_f_rgba_f32
,
1716 fetch_texel_2d_f_rgba_f32
,
1717 fetch_texel_3d_f_rgba_f32
,
1718 store_texel_rgba_f32
1721 MESA_FORMAT_RGBA_FLOAT16
,
1722 fetch_texel_1d_f_rgba_f16
,
1723 fetch_texel_2d_f_rgba_f16
,
1724 fetch_texel_3d_f_rgba_f16
,
1725 store_texel_rgba_f16
1728 MESA_FORMAT_RGB_FLOAT32
,
1729 fetch_texel_1d_f_rgb_f32
,
1730 fetch_texel_2d_f_rgb_f32
,
1731 fetch_texel_3d_f_rgb_f32
,
1735 MESA_FORMAT_RGB_FLOAT16
,
1736 fetch_texel_1d_f_rgb_f16
,
1737 fetch_texel_2d_f_rgb_f16
,
1738 fetch_texel_3d_f_rgb_f16
,
1742 MESA_FORMAT_ALPHA_FLOAT32
,
1743 fetch_texel_1d_f_alpha_f32
,
1744 fetch_texel_2d_f_alpha_f32
,
1745 fetch_texel_3d_f_alpha_f32
,
1746 store_texel_alpha_f32
1749 MESA_FORMAT_ALPHA_FLOAT16
,
1750 fetch_texel_1d_f_alpha_f16
,
1751 fetch_texel_2d_f_alpha_f16
,
1752 fetch_texel_3d_f_alpha_f16
,
1753 store_texel_alpha_f16
1756 MESA_FORMAT_LUMINANCE_FLOAT32
,
1757 fetch_texel_1d_f_luminance_f32
,
1758 fetch_texel_2d_f_luminance_f32
,
1759 fetch_texel_3d_f_luminance_f32
,
1760 store_texel_luminance_f32
1763 MESA_FORMAT_LUMINANCE_FLOAT16
,
1764 fetch_texel_1d_f_luminance_f16
,
1765 fetch_texel_2d_f_luminance_f16
,
1766 fetch_texel_3d_f_luminance_f16
,
1767 store_texel_luminance_f16
1770 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
,
1771 fetch_texel_1d_f_luminance_alpha_f32
,
1772 fetch_texel_2d_f_luminance_alpha_f32
,
1773 fetch_texel_3d_f_luminance_alpha_f32
,
1774 store_texel_luminance_alpha_f32
1777 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
,
1778 fetch_texel_1d_f_luminance_alpha_f16
,
1779 fetch_texel_2d_f_luminance_alpha_f16
,
1780 fetch_texel_3d_f_luminance_alpha_f16
,
1781 store_texel_luminance_alpha_f16
1784 MESA_FORMAT_INTENSITY_FLOAT32
,
1785 fetch_texel_1d_f_intensity_f32
,
1786 fetch_texel_2d_f_intensity_f32
,
1787 fetch_texel_3d_f_intensity_f32
,
1788 store_texel_intensity_f32
1791 MESA_FORMAT_INTENSITY_FLOAT16
,
1792 fetch_texel_1d_f_intensity_f16
,
1793 fetch_texel_2d_f_intensity_f16
,
1794 fetch_texel_3d_f_intensity_f16
,
1795 store_texel_intensity_f16
1799 fetch_texel_1d_dudv8
,
1800 fetch_texel_2d_dudv8
,
1801 fetch_texel_3d_dudv8
,
1805 MESA_FORMAT_SIGNED_RGBA8888
,
1806 fetch_texel_1d_signed_rgba8888
,
1807 fetch_texel_2d_signed_rgba8888
,
1808 fetch_texel_3d_signed_rgba8888
,
1809 store_texel_signed_rgba8888
1812 MESA_FORMAT_SIGNED_RGBA8888_REV
,
1813 fetch_texel_1d_signed_rgba8888_rev
,
1814 fetch_texel_2d_signed_rgba8888_rev
,
1815 fetch_texel_3d_signed_rgba8888_rev
,
1816 store_texel_signed_rgba8888_rev
1819 MESA_FORMAT_RGBA8888
,
1820 fetch_texel_1d_f_rgba8888
,
1821 fetch_texel_2d_f_rgba8888
,
1822 fetch_texel_3d_f_rgba8888
,
1823 store_texel_rgba8888
1826 MESA_FORMAT_RGBA8888_REV
,
1827 fetch_texel_1d_f_rgba8888_rev
,
1828 fetch_texel_2d_f_rgba8888_rev
,
1829 fetch_texel_3d_f_rgba8888_rev
,
1830 store_texel_rgba8888_rev
1833 MESA_FORMAT_ARGB8888
,
1834 fetch_texel_1d_f_argb8888
,
1835 fetch_texel_2d_f_argb8888
,
1836 fetch_texel_3d_f_argb8888
,
1837 store_texel_argb8888
1840 MESA_FORMAT_ARGB8888_REV
,
1841 fetch_texel_1d_f_argb8888_rev
,
1842 fetch_texel_2d_f_argb8888_rev
,
1843 fetch_texel_3d_f_argb8888_rev
,
1844 store_texel_argb8888_rev
1848 fetch_texel_1d_f_rgb888
,
1849 fetch_texel_2d_f_rgb888
,
1850 fetch_texel_3d_f_rgb888
,
1855 fetch_texel_1d_f_bgr888
,
1856 fetch_texel_2d_f_bgr888
,
1857 fetch_texel_3d_f_bgr888
,
1862 fetch_texel_1d_f_rgb565
,
1863 fetch_texel_2d_f_rgb565
,
1864 fetch_texel_3d_f_rgb565
,
1868 MESA_FORMAT_RGB565_REV
,
1869 fetch_texel_1d_f_rgb565_rev
,
1870 fetch_texel_2d_f_rgb565_rev
,
1871 fetch_texel_3d_f_rgb565_rev
,
1872 store_texel_rgb565_rev
1875 MESA_FORMAT_RGBA4444
,
1876 fetch_texel_1d_f_rgba4444
,
1877 fetch_texel_2d_f_rgba4444
,
1878 fetch_texel_3d_f_rgba4444
,
1879 store_texel_rgba4444
1882 MESA_FORMAT_ARGB4444
,
1883 fetch_texel_1d_f_argb4444
,
1884 fetch_texel_2d_f_argb4444
,
1885 fetch_texel_3d_f_argb4444
,
1886 store_texel_argb4444
1889 MESA_FORMAT_ARGB4444_REV
,
1890 fetch_texel_1d_f_argb4444_rev
,
1891 fetch_texel_2d_f_argb4444_rev
,
1892 fetch_texel_3d_f_argb4444_rev
,
1893 store_texel_argb4444_rev
1896 MESA_FORMAT_RGBA5551
,
1897 fetch_texel_1d_f_rgba5551
,
1898 fetch_texel_2d_f_rgba5551
,
1899 fetch_texel_3d_f_rgba5551
,
1900 store_texel_rgba5551
1903 MESA_FORMAT_ARGB1555
,
1904 fetch_texel_1d_f_argb1555
,
1905 fetch_texel_2d_f_argb1555
,
1906 fetch_texel_3d_f_argb1555
,
1907 store_texel_argb1555
1910 MESA_FORMAT_ARGB1555_REV
,
1911 fetch_texel_1d_f_argb1555_rev
,
1912 fetch_texel_2d_f_argb1555_rev
,
1913 fetch_texel_3d_f_argb1555_rev
,
1914 store_texel_argb1555_rev
1918 fetch_texel_1d_f_al88
,
1919 fetch_texel_2d_f_al88
,
1920 fetch_texel_3d_f_al88
,
1924 MESA_FORMAT_AL88_REV
,
1925 fetch_texel_1d_f_al88_rev
,
1926 fetch_texel_2d_f_al88_rev
,
1927 fetch_texel_3d_f_al88_rev
,
1928 store_texel_al88_rev
1932 fetch_texel_1d_f_rgb332
,
1933 fetch_texel_2d_f_rgb332
,
1934 fetch_texel_3d_f_rgb332
,
1939 fetch_texel_1d_f_a8
,
1940 fetch_texel_2d_f_a8
,
1941 fetch_texel_3d_f_a8
,
1946 fetch_texel_1d_f_l8
,
1947 fetch_texel_2d_f_l8
,
1948 fetch_texel_3d_f_l8
,
1953 fetch_texel_1d_f_i8
,
1954 fetch_texel_2d_f_i8
,
1955 fetch_texel_3d_f_i8
,
1960 fetch_texel_1d_f_ci8
,
1961 fetch_texel_2d_f_ci8
,
1962 fetch_texel_3d_f_ci8
,
1967 fetch_texel_1d_f_ycbcr
,
1968 fetch_texel_2d_f_ycbcr
,
1969 fetch_texel_3d_f_ycbcr
,
1973 MESA_FORMAT_YCBCR_REV
,
1974 fetch_texel_1d_f_ycbcr_rev
,
1975 fetch_texel_2d_f_ycbcr_rev
,
1976 fetch_texel_3d_f_ycbcr_rev
,
1977 store_texel_ycbcr_rev
1981 fetch_texel_1d_f_z24_s8
,
1982 fetch_texel_2d_f_z24_s8
,
1983 fetch_texel_3d_f_z24_s8
,
1988 fetch_texel_1d_f_s8_z24
,
1989 fetch_texel_2d_f_s8_z24
,
1990 fetch_texel_3d_f_s8_z24
,
1995 fetch_texel_1d_f_z16
,
1996 fetch_texel_2d_f_z16
,
1997 fetch_texel_3d_f_z16
,
2002 fetch_texel_1d_f_z32
,
2003 fetch_texel_2d_f_z32
,
2004 fetch_texel_3d_f_z32
,
2011 _mesa_get_texel_fetch_func(GLuint format
, GLuint dims
)
2015 /* XXX replace loop with direct table lookup */
2016 for (i
= 0; i
< MESA_FORMAT_COUNT
; i
++) {
2017 if (texfetch_funcs
[i
].Name
== format
) {
2020 f
= texfetch_funcs
[i
].Fetch1D
;
2023 f
= texfetch_funcs
[i
].Fetch2D
;
2026 f
= texfetch_funcs
[i
].Fetch3D
;
2030 f
= fetch_null_texelf
;
2039 _mesa_get_texel_store_func(GLuint format
)
2042 /* XXX replace loop with direct table lookup */
2043 for (i
= 0; i
< MESA_FORMAT_COUNT
; i
++) {
2044 if (texfetch_funcs
[i
].Name
== format
) {
2045 if (texfetch_funcs
[i
].StoreTexel
)
2046 return texfetch_funcs
[i
].StoreTexel
;
2048 return store_null_texel
;