5 * \author Gareth Hughes
9 * Mesa 3-D graphics library
12 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
21 * The above copyright notice and this permission notice shall be included
22 * in all copies or substantial portions of the Software.
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
28 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
39 #include "texformat.h"
44 /* Texel fetch routines for all supported formats
47 #include "texformat_tmp.h"
50 #include "texformat_tmp.h"
53 #include "texformat_tmp.h"
56 * Null texel fetch function.
58 * Have to have this so the FetchTexel function pointer is never NULL.
60 static void fetch_null_texel( const struct gl_texture_image
*texImage
,
61 GLint i
, GLint j
, GLint k
, GLvoid
*texel
)
63 GLchan
*rgba
= (GLchan
*) texel
;
71 /***************************************************************/
72 /** \name Default GLchan-based formats */
75 const struct gl_texture_format _mesa_texformat_rgba
= {
76 MESA_FORMAT_RGBA
, /* MesaFormat */
77 GL_RGBA
, /* BaseFormat */
78 CHAN_BITS
, /* RedBits */
79 CHAN_BITS
, /* GreenBits */
80 CHAN_BITS
, /* BlueBits */
81 CHAN_BITS
, /* AlphaBits */
82 0, /* LuminanceBits */
83 0, /* IntensityBits */
86 4 * CHAN_BITS
/ 8, /* TexelBytes */
87 fetch_1d_texel_rgba
, /* FetchTexel1D */
88 fetch_2d_texel_rgba
, /* FetchTexel2D */
89 fetch_3d_texel_rgba
, /* FetchTexel3D */
92 const struct gl_texture_format _mesa_texformat_rgb
= {
93 MESA_FORMAT_RGB
, /* MesaFormat */
94 GL_RGB
, /* BaseFormat */
95 CHAN_BITS
, /* RedBits */
96 CHAN_BITS
, /* GreenBits */
97 CHAN_BITS
, /* BlueBits */
99 0, /* LuminanceBits */
100 0, /* IntensityBits */
103 3 * CHAN_BITS
/ 8, /* TexelBytes */
104 fetch_1d_texel_rgb
, /* FetchTexel1D */
105 fetch_2d_texel_rgb
, /* FetchTexel2D */
106 fetch_3d_texel_rgb
, /* FetchTexel3D */
109 const struct gl_texture_format _mesa_texformat_alpha
= {
110 MESA_FORMAT_ALPHA
, /* MesaFormat */
111 GL_ALPHA
, /* BaseFormat */
115 CHAN_BITS
, /* AlphaBits */
116 0, /* LuminanceBits */
117 0, /* IntensityBits */
120 CHAN_BITS
/ 8, /* TexelBytes */
121 fetch_1d_texel_alpha
, /* FetchTexel1D */
122 fetch_2d_texel_alpha
, /* FetchTexel2D */
123 fetch_3d_texel_alpha
, /* FetchTexel3D */
126 const struct gl_texture_format _mesa_texformat_luminance
= {
127 MESA_FORMAT_LUMINANCE
, /* MesaFormat */
128 GL_LUMINANCE
, /* BaseFormat */
133 CHAN_BITS
, /* LuminanceBits */
134 0, /* IntensityBits */
137 CHAN_BITS
/ 8, /* TexelBytes */
138 fetch_1d_texel_luminance
, /* FetchTexel1D */
139 fetch_2d_texel_luminance
, /* FetchTexel2D */
140 fetch_3d_texel_luminance
, /* FetchTexel3D */
143 const struct gl_texture_format _mesa_texformat_luminance_alpha
= {
144 MESA_FORMAT_LUMINANCE_ALPHA
, /* MesaFormat */
145 GL_LUMINANCE_ALPHA
, /* BaseFormat */
149 CHAN_BITS
, /* AlphaBits */
150 CHAN_BITS
, /* LuminanceBits */
151 0, /* IntensityBits */
154 2 * CHAN_BITS
/ 8, /* TexelBytes */
155 fetch_1d_texel_luminance_alpha
, /* FetchTexel1D */
156 fetch_2d_texel_luminance_alpha
, /* FetchTexel2D */
157 fetch_3d_texel_luminance_alpha
, /* FetchTexel3D */
160 const struct gl_texture_format _mesa_texformat_intensity
= {
161 MESA_FORMAT_INTENSITY
, /* MesaFormat */
162 GL_INTENSITY
, /* BaseFormat */
167 0, /* LuminanceBits */
168 CHAN_BITS
, /* IntensityBits */
171 CHAN_BITS
/ 8, /* TexelBytes */
172 fetch_1d_texel_intensity
, /* FetchTexel1D */
173 fetch_2d_texel_intensity
, /* FetchTexel2D */
174 fetch_3d_texel_intensity
, /* FetchTexel3D */
177 const struct gl_texture_format _mesa_texformat_color_index
= {
178 MESA_FORMAT_COLOR_INDEX
, /* MesaFormat */
179 GL_COLOR_INDEX
, /* BaseFormat */
184 0, /* LuminanceBits */
185 0, /* IntensityBits */
186 CHAN_BITS
, /* IndexBits */
188 CHAN_BITS
/ 8, /* TexelBytes */
189 fetch_1d_texel_color_index
, /* FetchTexel1D */
190 fetch_2d_texel_color_index
, /* FetchTexel2D */
191 fetch_3d_texel_color_index
, /* FetchTexel3D */
194 const struct gl_texture_format _mesa_texformat_depth_component
= {
195 MESA_FORMAT_DEPTH_COMPONENT
, /* MesaFormat */
196 GL_DEPTH_COMPONENT
, /* BaseFormat */
201 0, /* LuminanceBits */
202 0, /* IntensityBits */
204 sizeof(GLfloat
) * 8, /* DepthBits */
205 sizeof(GLfloat
), /* TexelBytes */
206 fetch_1d_texel_depth_component
, /* FetchTexel1D */
207 fetch_2d_texel_depth_component
, /* FetchTexel2D */
208 fetch_3d_texel_depth_component
, /* FetchTexel3D */
214 /***************************************************************/
215 /** \name Hardware formats */
218 const struct gl_texture_format _mesa_texformat_rgba8888
= {
219 MESA_FORMAT_RGBA8888
, /* MesaFormat */
220 GL_RGBA
, /* BaseFormat */
225 0, /* LuminanceBits */
226 0, /* IntensityBits */
230 fetch_1d_texel_rgba8888
, /* FetchTexel1D */
231 fetch_2d_texel_rgba8888
, /* FetchTexel2D */
232 fetch_3d_texel_rgba8888
, /* FetchTexel3D */
235 const struct gl_texture_format _mesa_texformat_argb8888
= {
236 MESA_FORMAT_ARGB8888
, /* MesaFormat */
237 GL_RGBA
, /* BaseFormat */
242 0, /* LuminanceBits */
243 0, /* IntensityBits */
247 fetch_1d_texel_argb8888
, /* FetchTexel1D */
248 fetch_2d_texel_argb8888
, /* FetchTexel2D */
249 fetch_3d_texel_argb8888
, /* FetchTexel3D */
252 const struct gl_texture_format _mesa_texformat_rgb888
= {
253 MESA_FORMAT_RGB888
, /* MesaFormat */
254 GL_RGB
, /* BaseFormat */
259 0, /* LuminanceBits */
260 0, /* IntensityBits */
264 fetch_1d_texel_rgb888
, /* FetchTexel1D */
265 fetch_2d_texel_rgb888
, /* FetchTexel2D */
266 fetch_3d_texel_rgb888
, /* FetchTexel3D */
269 const struct gl_texture_format _mesa_texformat_rgb565
= {
270 MESA_FORMAT_RGB565
, /* MesaFormat */
271 GL_RGB
, /* BaseFormat */
276 0, /* LuminanceBits */
277 0, /* IntensityBits */
281 fetch_1d_texel_rgb565
, /* FetchTexel1D */
282 fetch_2d_texel_rgb565
, /* FetchTexel2D */
283 fetch_3d_texel_rgb565
, /* FetchTexel3D */
286 const struct gl_texture_format _mesa_texformat_argb4444
= {
287 MESA_FORMAT_ARGB4444
, /* MesaFormat */
288 GL_RGBA
, /* BaseFormat */
293 0, /* LuminanceBits */
294 0, /* IntensityBits */
298 fetch_1d_texel_argb4444
, /* FetchTexel1D */
299 fetch_2d_texel_argb4444
, /* FetchTexel2D */
300 fetch_3d_texel_argb4444
, /* FetchTexel3D */
303 const struct gl_texture_format _mesa_texformat_argb1555
= {
304 MESA_FORMAT_ARGB1555
, /* MesaFormat */
305 GL_RGBA
, /* BaseFormat */
310 0, /* LuminanceBits */
311 0, /* IntensityBits */
315 fetch_1d_texel_argb1555
, /* FetchTexel1D */
316 fetch_2d_texel_argb1555
, /* FetchTexel2D */
317 fetch_3d_texel_argb1555
, /* FetchTexel3D */
320 const struct gl_texture_format _mesa_texformat_al88
= {
321 MESA_FORMAT_AL88
, /* MesaFormat */
322 GL_LUMINANCE_ALPHA
, /* BaseFormat */
327 8, /* LuminanceBits */
328 0, /* IntensityBits */
332 fetch_1d_texel_al88
, /* FetchTexel1D */
333 fetch_2d_texel_al88
, /* FetchTexel2D */
334 fetch_3d_texel_al88
, /* FetchTexel3D */
337 const struct gl_texture_format _mesa_texformat_rgb332
= {
338 MESA_FORMAT_RGB332
, /* MesaFormat */
339 GL_RGB
, /* BaseFormat */
344 0, /* LuminanceBits */
345 0, /* IntensityBits */
349 fetch_1d_texel_rgb332
, /* FetchTexel1D */
350 fetch_2d_texel_rgb332
, /* FetchTexel2D */
351 fetch_3d_texel_rgb332
, /* FetchTexel3D */
354 const struct gl_texture_format _mesa_texformat_a8
= {
355 MESA_FORMAT_A8
, /* MesaFormat */
356 GL_ALPHA
, /* BaseFormat */
361 0, /* LuminanceBits */
362 0, /* IntensityBits */
366 fetch_1d_texel_a8
, /* FetchTexel1D */
367 fetch_2d_texel_a8
, /* FetchTexel2D */
368 fetch_3d_texel_a8
, /* FetchTexel3D */
371 const struct gl_texture_format _mesa_texformat_l8
= {
372 MESA_FORMAT_L8
, /* MesaFormat */
373 GL_LUMINANCE
, /* BaseFormat */
378 8, /* LuminanceBits */
379 0, /* IntensityBits */
383 fetch_1d_texel_l8
, /* FetchTexel1D */
384 fetch_2d_texel_l8
, /* FetchTexel2D */
385 fetch_3d_texel_l8
, /* FetchTexel3D */
388 const struct gl_texture_format _mesa_texformat_i8
= {
389 MESA_FORMAT_I8
, /* MesaFormat */
390 GL_INTENSITY
, /* BaseFormat */
395 0, /* LuminanceBits */
396 8, /* IntensityBits */
400 fetch_1d_texel_i8
, /* FetchTexel1D */
401 fetch_2d_texel_i8
, /* FetchTexel2D */
402 fetch_3d_texel_i8
, /* FetchTexel3D */
405 const struct gl_texture_format _mesa_texformat_ci8
= {
406 MESA_FORMAT_CI8
, /* MesaFormat */
407 GL_COLOR_INDEX
, /* BaseFormat */
412 0, /* LuminanceBits */
413 0, /* IntensityBits */
417 fetch_1d_texel_ci8
, /* FetchTexel1D */
418 fetch_2d_texel_ci8
, /* FetchTexel2D */
419 fetch_3d_texel_ci8
, /* FetchTexel3D */
422 const struct gl_texture_format _mesa_texformat_ycbcr
= {
423 MESA_FORMAT_YCBCR
, /* MesaFormat */
424 GL_YCBCR_MESA
, /* BaseFormat */
429 0, /* LuminanceBits */
430 0, /* IntensityBits */
434 fetch_1d_texel_ycbcr
, /* FetchTexel1D */
435 fetch_2d_texel_ycbcr
, /* FetchTexel2D */
436 fetch_3d_texel_ycbcr
, /* FetchTexel3D */
439 const struct gl_texture_format _mesa_texformat_ycbcr_rev
= {
440 MESA_FORMAT_YCBCR_REV
, /* MesaFormat */
441 GL_YCBCR_MESA
, /* BaseFormat */
446 0, /* LuminanceBits */
447 0, /* IntensityBits */
451 fetch_1d_texel_ycbcr_rev
, /* FetchTexel1D */
452 fetch_2d_texel_ycbcr_rev
, /* FetchTexel2D */
453 fetch_3d_texel_ycbcr_rev
, /* FetchTexel3D */
456 const struct gl_texture_format _mesa_texformat_rgb_dxt1
= {
457 MESA_FORMAT_RGB_DXT1
, /* MesaFormat */
458 GL_RGB
, /* BaseFormat */
459 4, /*approx*/ /* RedBits */
460 4, /*approx*/ /* GreenBits */
461 4, /*approx*/ /* BlueBits */
463 0, /* LuminanceBits */
464 0, /* IntensityBits */
468 NULL
, /*impossible*/ /* FetchTexel1D */
469 fetch_2d_texel_rgb_dxt1
, /* FetchTexel2D */
470 NULL
, /*impossible*/ /* FetchTexel3D */
473 const struct gl_texture_format _mesa_texformat_rgba_dxt1
= {
474 MESA_FORMAT_RGBA_DXT1
, /* MesaFormat */
475 GL_RGBA
, /* BaseFormat */
476 4, /*approx*/ /* RedBits */
477 4, /*approx*/ /* GreenBits */
478 4, /*approx*/ /* BlueBits */
479 1, /*approx*/ /* AlphaBits */
480 0, /* LuminanceBits */
481 0, /* IntensityBits */
485 NULL
, /*impossible*/ /* FetchTexel1D */
486 fetch_2d_texel_rgba_dxt1
, /* FetchTexel2D */
487 NULL
, /*impossible*/ /* FetchTexel3D */
490 const struct gl_texture_format _mesa_texformat_rgba_dxt3
= {
491 MESA_FORMAT_RGBA_DXT3
, /* MesaFormat */
492 GL_RGBA
, /* BaseFormat */
493 4, /*approx*/ /* RedBits */
494 4, /*approx*/ /* GreenBits */
495 4, /*approx*/ /* BlueBits */
496 4, /*approx*/ /* AlphaBits */
497 0, /* LuminanceBits */
498 0, /* IntensityBits */
502 NULL
, /*impossible*/ /* FetchTexel1D */
503 fetch_2d_texel_rgba_dxt3
, /* FetchTexel2D */
504 NULL
, /*impossible*/ /* FetchTexel3D */
507 const struct gl_texture_format _mesa_texformat_rgba_dxt5
= {
508 MESA_FORMAT_RGBA_DXT5
, /* MesaFormat */
509 GL_RGBA
, /* BaseFormat */
510 4,/*approx*/ /* RedBits */
511 4,/*approx*/ /* GreenBits */
512 4,/*approx*/ /* BlueBits */
513 4,/*approx*/ /* AlphaBits */
514 0, /* LuminanceBits */
515 0, /* IntensityBits */
519 NULL
, /*impossible*/ /* FetchTexel1D */
520 fetch_2d_texel_rgba_dxt5
, /* FetchTexel2D */
521 NULL
, /*impossible*/ /* FetchTexel3D */
527 const struct gl_texture_format _mesa_texformat_abgr8888
= {
528 MESA_FORMAT_ABGR8888
, /* MesaFormat */
529 GL_RGBA
, /* BaseFormat */
530 GL_UNSIGNED_INT_8_8_8_8
, /* Type */
535 0, /* LuminanceBits */
536 0, /* IntensityBits */
540 fetch_1d_texel_abgr8888
, /* FetchTexel1D */
541 fetch_2d_texel_abgr8888
, /* FetchTexel2D */
542 fetch_3d_texel_abgr8888
, /* FetchTexel3D */
545 const struct gl_texture_format _mesa_texformat_bgra8888
= {
546 MESA_FORMAT_BGRA8888
, /* MesaFormat */
547 GL_RGBA
, /* BaseFormat */
548 GL_UNSIGNED_INT_8_8_8_8
, /* Type */
553 0, /* LuminanceBits */
554 0, /* IntensityBits */
558 fetch_1d_texel_bgra8888
, /* FetchTexel1D */
559 fetch_2d_texel_bgra8888
, /* FetchTexel2D */
560 fetch_3d_texel_bgra8888
, /* FetchTexel3D */
563 const struct gl_texture_format _mesa_texformat_bgr888
= {
564 MESA_FORMAT_BGR888
, /* MesaFormat */
565 GL_RGB
, /* BaseFormat */
566 GL_UNSIGNED_BYTE
, /* Type */
571 0, /* LuminanceBits */
572 0, /* IntensityBits */
576 fetch_1d_texel_bgr888
, /* FetchTexel1D */
577 fetch_2d_texel_bgr888
, /* FetchTexel2D */
578 fetch_3d_texel_bgr888
, /* FetchTexel3D */
581 const struct gl_texture_format _mesa_texformat_bgr565
= {
582 MESA_FORMAT_BGR565
, /* MesaFormat */
583 GL_RGB
, /* BaseFormat */
584 GL_UNSIGNED_SHORT_5_6_5
, /* Type */
589 0, /* LuminanceBits */
590 0, /* IntensityBits */
594 fetch_1d_texel_bgr565
, /* FetchTexel1D */
595 fetch_2d_texel_bgr565
, /* FetchTexel2D */
596 fetch_3d_texel_bgr565
, /* FetchTexel3D */
599 const struct gl_texture_format _mesa_texformat_bgra4444
= {
600 MESA_FORMAT_BGRA4444
, /* MesaFormat */
601 GL_RGBA
, /* BaseFormat */
602 GL_UNSIGNED_SHORT_4_4_4_4_REV
, /* Type */
607 0, /* LuminanceBits */
608 0, /* IntensityBits */
612 fetch_1d_texel_bgra4444
, /* FetchTexel1D */
613 fetch_2d_texel_bgra4444
, /* FetchTexel2D */
614 fetch_3d_texel_bgra4444
, /* FetchTexel3D */
617 const struct gl_texture_format _mesa_texformat_bgra5551
= {
618 MESA_FORMAT_BGRA5551
, /* MesaFormat */
619 GL_RGBA
, /* BaseFormat */
620 GL_UNSIGNED_SHORT_1_5_5_5_REV
, /* Type */
625 0, /* LuminanceBits */
626 0, /* IntensityBits */
630 fetch_1d_texel_bgra1555
, /* FetchTexel1D */
631 fetch_2d_texel_bgra1555
, /* FetchTexel2D */
632 fetch_3d_texel_bgra1555
, /* FetchTexel3D */
635 const struct gl_texture_format _mesa_texformat_la88
= {
636 MESA_FORMAT_LA88
, /* MesaFormat */
637 GL_LUMINANCE_ALPHA
, /* BaseFormat */
638 GL_UNSIGNED_BYTE
, /* Type */
643 8, /* LuminanceBits */
644 0, /* IntensityBits */
648 fetch_1d_texel_la88
, /* FetchTexel1D */
649 fetch_2d_texel_la88
, /* FetchTexel2D */
650 fetch_3d_texel_la88
, /* FetchTexel3D */
653 const struct gl_texture_format _mesa_texformat_bgr233
= {
654 MESA_FORMAT_BGR233
, /* MesaFormat */
655 GL_RGB
, /* BaseFormat */
656 GL_UNSIGNED_BYTE_3_3_2
, /* Type */
661 0, /* LuminanceBits */
662 0, /* IntensityBits */
666 fetch_1d_texel_bgr233
, /* FetchTexel1D */
667 fetch_2d_texel_bgr233
, /* FetchTexel2D */
668 fetch_3d_texel_bgr233
, /* FetchTexel3D */
675 /***************************************************************/
676 /** \name Null format (useful for proxy textures) */
679 const struct gl_texture_format _mesa_null_texformat
= {
686 0, /* LuminanceBits */
687 0, /* IntensityBits */
691 fetch_null_texel
, /* FetchTexel1D */
692 fetch_null_texel
, /* FetchTexel2D */
693 fetch_null_texel
, /* FetchTexel3D */
700 * Determine whether a given texture format is a hardware texture
703 * \param format texture format.
705 * \return GL_TRUE if \p format is a hardware texture format, or GL_FALSE
708 * \p format is a hardware texture format if gl_texture_format::MesaFormat is
709 * lower than _format::MESA_FORMAT_RGBA.
712 _mesa_is_hardware_tex_format( const struct gl_texture_format
*format
)
714 return (format
->MesaFormat
< MESA_FORMAT_RGBA
);
719 * Choose an appropriate texture format.
721 * \param ctx GL context.
722 * \param internalFormat internal texture format.
723 * \param format pixel format.
724 * \param type data type.
726 * \return a pointer to a gl_texture_format in which to store the texture on
727 * success, or NULL on failure.
729 * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers
730 * typically override this function with a specialized version.
732 const struct gl_texture_format
*
733 _mesa_choose_tex_format( GLcontext
*ctx
, GLint internalFormat
,
734 GLenum format
, GLenum type
)
739 switch ( internalFormat
) {
740 /* GH: Bias towards GL_RGB, GL_RGBA texture formats. This has
741 * got to be better than sticking them way down the end of this
744 case 4: /* Quake3 uses this... */
746 return &_mesa_texformat_rgba
;
748 case 3: /* ... and this. */
750 return &_mesa_texformat_rgb
;
752 /* GH: Okay, keep checking as normal. Still test for GL_RGB,
753 * GL_RGBA formats first.
762 return &_mesa_texformat_rgba
;
771 return &_mesa_texformat_rgb
;
778 return &_mesa_texformat_alpha
;
786 return &_mesa_texformat_luminance
;
789 case GL_LUMINANCE_ALPHA
:
790 case GL_LUMINANCE4_ALPHA4
:
791 case GL_LUMINANCE6_ALPHA2
:
792 case GL_LUMINANCE8_ALPHA8
:
793 case GL_LUMINANCE12_ALPHA4
:
794 case GL_LUMINANCE12_ALPHA12
:
795 case GL_LUMINANCE16_ALPHA16
:
796 return &_mesa_texformat_luminance_alpha
;
803 return &_mesa_texformat_intensity
;
806 case GL_COLOR_INDEX1_EXT
:
807 case GL_COLOR_INDEX2_EXT
:
808 case GL_COLOR_INDEX4_EXT
:
809 case GL_COLOR_INDEX8_EXT
:
810 case GL_COLOR_INDEX12_EXT
:
811 case GL_COLOR_INDEX16_EXT
:
812 return &_mesa_texformat_color_index
;
814 case GL_DEPTH_COMPONENT
:
815 case GL_DEPTH_COMPONENT16_SGIX
:
816 case GL_DEPTH_COMPONENT24_SGIX
:
817 case GL_DEPTH_COMPONENT32_SGIX
:
818 if (!ctx
->Extensions
.SGIX_depth_texture
)
819 _mesa_problem(ctx
, "depth format without GL_SGIX_depth_texture");
820 return &_mesa_texformat_depth_component
;
822 case GL_COMPRESSED_ALPHA_ARB
:
823 if (!ctx
->Extensions
.ARB_texture_compression
)
824 _mesa_problem(ctx
, "texture compression extension not enabled");
825 return &_mesa_texformat_alpha
;
826 case GL_COMPRESSED_LUMINANCE_ARB
:
827 if (!ctx
->Extensions
.ARB_texture_compression
)
828 _mesa_problem(ctx
, "texture compression extension not enabled");
829 return &_mesa_texformat_luminance
;
830 case GL_COMPRESSED_LUMINANCE_ALPHA_ARB
:
831 if (!ctx
->Extensions
.ARB_texture_compression
)
832 _mesa_problem(ctx
, "texture compression extension not enabled");
833 return &_mesa_texformat_luminance_alpha
;
834 case GL_COMPRESSED_INTENSITY_ARB
:
835 if (!ctx
->Extensions
.ARB_texture_compression
)
836 _mesa_problem(ctx
, "texture compression extension not enabled");
837 return &_mesa_texformat_intensity
;
838 case GL_COMPRESSED_RGB_ARB
:
839 if (!ctx
->Extensions
.ARB_texture_compression
)
840 _mesa_problem(ctx
, "texture compression extension not enabled");
841 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
842 return &_mesa_texformat_rgb_dxt1
;
843 return &_mesa_texformat_rgb
;
844 case GL_COMPRESSED_RGBA_ARB
:
845 if (!ctx
->Extensions
.ARB_texture_compression
)
846 _mesa_problem(ctx
, "texture compression extension not enabled");
847 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
848 return &_mesa_texformat_rgba_dxt3
; /* Not rgba_dxt1! See the spec */
849 return &_mesa_texformat_rgba
;
851 /* GL_MESA_ycrcr_texture */
853 if (type
== GL_UNSIGNED_SHORT_8_8_MESA
)
854 return &_mesa_texformat_ycbcr
;
856 return &_mesa_texformat_ycbcr_rev
;
858 /* GL_EXT_texture_compression_s3tc */
859 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT
:
860 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
861 return &_mesa_texformat_rgb_dxt1
;
864 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
:
865 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
866 return &_mesa_texformat_rgba_dxt1
;
869 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
:
870 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
871 return &_mesa_texformat_rgba_dxt3
;
874 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
:
875 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
876 return &_mesa_texformat_rgba_dxt5
;
881 _mesa_problem(ctx
, "unexpected format in _mesa_choose_tex_format()");
888 * Return the base texture format for the given compressed format
890 * Called via dd_function_table::Driver.BaseCompressedTexFormat.
891 * This function is used by software rasterizers. Hardware drivers
892 * which support texture compression should not use this function but
893 * a specialized function instead.
896 _mesa_base_compressed_texformat(GLcontext
*ctx
, GLint intFormat
)
899 case GL_COMPRESSED_ALPHA_ARB
:
901 case GL_COMPRESSED_LUMINANCE_ARB
:
903 case GL_COMPRESSED_LUMINANCE_ALPHA_ARB
:
904 return GL_LUMINANCE_ALPHA
;
905 case GL_COMPRESSED_INTENSITY_ARB
:
907 case GL_COMPRESSED_RGB_ARB
:
909 case GL_COMPRESSED_RGBA_ARB
:
912 return -1; /* not a recognized compressed format */