2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
6 * Copyright (c) 2008-2009 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.
34 * Info about each format.
35 * These must be in the same order as the MESA_FORMAT_* enums so that
36 * we can do lookups without searching.
38 static struct gl_format_info format_info
[MESA_FORMAT_COUNT
] =
41 MESA_FORMAT_NONE
, /* Name */
42 GL_NONE
, /* BaseFormat */
43 GL_NONE
, /* DataType */
44 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
45 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
46 0, 0, 0 /* BlockWidth/Height,Bytes */
49 MESA_FORMAT_RGBA8888
, /* Name */
50 GL_RGBA
, /* BaseFormat */
51 GL_UNSIGNED_NORMALIZED
, /* DataType */
52 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
53 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
54 1, 1, 4 /* BlockWidth/Height,Bytes */
57 MESA_FORMAT_RGBA8888_REV
, /* Name */
58 GL_RGBA
, /* BaseFormat */
59 GL_UNSIGNED_NORMALIZED
, /* DataType */
60 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
61 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
62 1, 1, 4 /* BlockWidth/Height,Bytes */
65 MESA_FORMAT_ARGB8888
, /* Name */
66 GL_RGBA
, /* BaseFormat */
67 GL_UNSIGNED_NORMALIZED
, /* DataType */
68 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
69 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
70 1, 1, 4 /* BlockWidth/Height,Bytes */
73 MESA_FORMAT_ARGB8888_REV
, /* Name */
74 GL_RGBA
, /* BaseFormat */
75 GL_UNSIGNED_NORMALIZED
, /* DataType */
76 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
77 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
78 1, 1, 4 /* BlockWidth/Height,Bytes */
81 MESA_FORMAT_RGB888
, /* Name */
82 GL_RGB
, /* BaseFormat */
83 GL_UNSIGNED_NORMALIZED
, /* DataType */
84 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
85 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
86 1, 1, 3 /* BlockWidth/Height,Bytes */
89 MESA_FORMAT_BGR888
, /* Name */
90 GL_RGB
, /* BaseFormat */
91 GL_UNSIGNED_NORMALIZED
, /* DataType */
92 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
93 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
94 1, 1, 3 /* BlockWidth/Height,Bytes */
97 MESA_FORMAT_RGB565
, /* Name */
98 GL_RGB
, /* BaseFormat */
99 GL_UNSIGNED_NORMALIZED
, /* DataType */
100 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */
101 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
102 1, 1, 2 /* BlockWidth/Height,Bytes */
105 MESA_FORMAT_RGB565_REV
, /* Name */
106 GL_RGB
, /* BaseFormat */
107 GL_UNSIGNED_NORMALIZED
, /* DataType */
108 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */
109 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
110 1, 1, 2 /* BlockWidth/Height,Bytes */
113 MESA_FORMAT_RGBA4444
, /* Name */
114 GL_RGBA
, /* BaseFormat */
115 GL_UNSIGNED_NORMALIZED
, /* DataType */
116 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */
117 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
118 1, 1, 2 /* BlockWidth/Height,Bytes */
121 MESA_FORMAT_ARGB4444
, /* Name */
122 GL_RGBA
, /* BaseFormat */
123 GL_UNSIGNED_NORMALIZED
, /* DataType */
124 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */
125 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
126 1, 1, 2 /* BlockWidth/Height,Bytes */
129 MESA_FORMAT_ARGB4444_REV
, /* Name */
130 GL_RGBA
, /* BaseFormat */
131 GL_UNSIGNED_NORMALIZED
, /* DataType */
132 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */
133 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
134 1, 1, 2 /* BlockWidth/Height,Bytes */
137 MESA_FORMAT_RGBA5551
, /* Name */
138 GL_RGBA
, /* BaseFormat */
139 GL_UNSIGNED_NORMALIZED
, /* DataType */
140 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */
141 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
142 1, 1, 2 /* BlockWidth/Height,Bytes */
145 MESA_FORMAT_ARGB1555
, /* Name */
146 GL_RGBA
, /* BaseFormat */
147 GL_UNSIGNED_NORMALIZED
, /* DataType */
148 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */
149 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
150 1, 1, 2 /* BlockWidth/Height,Bytes */
153 MESA_FORMAT_ARGB1555_REV
, /* Name */
154 GL_RGBA
, /* BaseFormat */
155 GL_UNSIGNED_NORMALIZED
, /* DataType */
156 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */
157 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
158 1, 1, 2 /* BlockWidth/Height,Bytes */
161 MESA_FORMAT_AL88
, /* Name */
162 GL_LUMINANCE_ALPHA
, /* BaseFormat */
163 GL_UNSIGNED_NORMALIZED
, /* DataType */
164 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */
165 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
166 1, 1, 2 /* BlockWidth/Height,Bytes */
169 MESA_FORMAT_AL88_REV
, /* Name */
170 GL_LUMINANCE_ALPHA
, /* BaseFormat */
171 GL_UNSIGNED_NORMALIZED
, /* DataType */
172 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */
173 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
174 1, 1, 2 /* BlockWidth/Height,Bytes */
177 MESA_FORMAT_RGB332
, /* Name */
178 GL_RGB
, /* BaseFormat */
179 GL_UNSIGNED_NORMALIZED
, /* DataType */
180 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */
181 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
182 1, 1, 1 /* BlockWidth/Height,Bytes */
185 MESA_FORMAT_A8
, /* Name */
186 GL_ALPHA
, /* BaseFormat */
187 GL_UNSIGNED_NORMALIZED
, /* DataType */
188 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */
189 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
190 1, 1, 1 /* BlockWidth/Height,Bytes */
193 MESA_FORMAT_L8
, /* Name */
194 GL_LUMINANCE
, /* BaseFormat */
195 GL_UNSIGNED_NORMALIZED
, /* DataType */
196 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
197 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
198 1, 1, 1 /* BlockWidth/Height,Bytes */
201 MESA_FORMAT_I8
, /* Name */
202 GL_INTENSITY
, /* BaseFormat */
203 GL_UNSIGNED_NORMALIZED
, /* DataType */
204 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
205 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
206 1, 1, 1 /* BlockWidth/Height,Bytes */
209 MESA_FORMAT_CI8
, /* Name */
210 GL_COLOR_INDEX
, /* BaseFormat */
211 GL_UNSIGNED_INT
, /* DataType */
212 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
213 0, 0, 8, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
214 1, 1, 1 /* BlockWidth/Height,Bytes */
217 MESA_FORMAT_YCBCR
, /* Name */
218 GL_YCBCR_MESA
, /* BaseFormat */
219 GL_UNSIGNED_NORMALIZED
, /* DataType */
220 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
221 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
222 1, 1, 2 /* BlockWidth/Height,Bytes */
225 MESA_FORMAT_YCBCR_REV
, /* Name */
226 GL_YCBCR_MESA
, /* BaseFormat */
227 GL_UNSIGNED_NORMALIZED
, /* DataType */
228 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
229 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
230 1, 1, 2 /* BlockWidth/Height,Bytes */
233 MESA_FORMAT_Z24_S8
, /* Name */
234 GL_DEPTH_STENCIL
, /* BaseFormat */
235 GL_UNSIGNED_INT
, /* DataType */
236 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
237 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */
238 1, 1, 4 /* BlockWidth/Height,Bytes */
241 MESA_FORMAT_S8_Z24
, /* Name */
242 GL_DEPTH_STENCIL
, /* BaseFormat */
243 GL_UNSIGNED_INT
, /* DataType */
244 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
245 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */
246 1, 1, 4 /* BlockWidth/Height,Bytes */
249 MESA_FORMAT_Z16
, /* Name */
250 GL_DEPTH_COMPONENT
, /* BaseFormat */
251 GL_UNSIGNED_INT
, /* DataType */
252 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
253 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */
254 1, 1, 2 /* BlockWidth/Height,Bytes */
257 MESA_FORMAT_Z32
, /* Name */
258 GL_DEPTH_COMPONENT
, /* BaseFormat */
259 GL_UNSIGNED_INT
, /* DataType */
260 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
261 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */
262 1, 1, 4 /* BlockWidth/Height,Bytes */
265 MESA_FORMAT_S8
, /* Name */
266 GL_STENCIL_INDEX
, /* BaseFormat */
267 GL_UNSIGNED_INT
, /* DataType */
268 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
269 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */
270 1, 1, 1 /* BlockWidth/Height,Bytes */
273 #if FEATURE_EXT_texture_sRGB
277 GL_UNSIGNED_NORMALIZED
,
285 GL_UNSIGNED_NORMALIZED
,
293 GL_UNSIGNED_NORMALIZED
,
301 GL_UNSIGNED_NORMALIZED
,
309 GL_UNSIGNED_NORMALIZED
,
314 #if FEATURE_texture_s3tc
316 MESA_FORMAT_SRGB_DXT1
, /* Name */
317 GL_RGB
, /* BaseFormat */
318 GL_UNSIGNED_NORMALIZED
, /* DataType */
319 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */
320 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
321 4, 4, 8 /* 8 bytes per 4x4 block */
324 MESA_FORMAT_SRGBA_DXT1
,
326 GL_UNSIGNED_NORMALIZED
,
329 4, 4, 8 /* 8 bytes per 4x4 block */
332 MESA_FORMAT_SRGBA_DXT3
,
334 GL_UNSIGNED_NORMALIZED
,
337 4, 4, 16 /* 16 bytes per 4x4 block */
340 MESA_FORMAT_SRGBA_DXT5
,
342 GL_UNSIGNED_NORMALIZED
,
345 4, 4, 16 /* 16 bytes per 4x4 block */
350 #if FEATURE_texture_fxt1
352 MESA_FORMAT_RGB_FXT1
,
354 GL_UNSIGNED_NORMALIZED
,
357 8, 4, 16 /* 16 bytes per 8x4 block */
360 MESA_FORMAT_RGBA_FXT1
,
362 GL_UNSIGNED_NORMALIZED
,
365 8, 4, 16 /* 16 bytes per 8x4 block */
369 #if FEATURE_texture_s3tc
371 MESA_FORMAT_RGB_DXT1
, /* Name */
372 GL_RGB
, /* BaseFormat */
373 GL_UNSIGNED_NORMALIZED
, /* DataType */
374 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */
375 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
376 4, 4, 8 /* 8 bytes per 4x4 block */
379 MESA_FORMAT_RGBA_DXT1
,
381 GL_UNSIGNED_NORMALIZED
,
384 4, 4, 8 /* 8 bytes per 4x4 block */
387 MESA_FORMAT_RGBA_DXT3
,
389 GL_UNSIGNED_NORMALIZED
,
392 4, 4, 16 /* 16 bytes per 4x4 block */
395 MESA_FORMAT_RGBA_DXT5
,
397 GL_UNSIGNED_NORMALIZED
,
400 4, 4, 16 /* 16 bytes per 4x4 block */
407 GL_UNSIGNED_NORMALIZED
,
408 CHAN_BITS
, CHAN_BITS
, CHAN_BITS
, CHAN_BITS
,
410 1, 1, 4 * CHAN_BITS
/ 8
415 GL_UNSIGNED_NORMALIZED
,
416 CHAN_BITS
, CHAN_BITS
, CHAN_BITS
, 0,
418 1, 1, 3 * CHAN_BITS
/ 8
423 GL_UNSIGNED_NORMALIZED
,
426 1, 1, 1 * CHAN_BITS
/ 8
429 MESA_FORMAT_LUMINANCE
,
431 GL_UNSIGNED_NORMALIZED
,
433 CHAN_BITS
, 0, 0, 0, 0,
434 1, 1, 1 * CHAN_BITS
/ 8
437 MESA_FORMAT_LUMINANCE_ALPHA
,
439 GL_UNSIGNED_NORMALIZED
,
441 CHAN_BITS
, 0, 0, 0, 0,
442 1, 1, 2 * CHAN_BITS
/ 8
445 MESA_FORMAT_INTENSITY
,
447 GL_UNSIGNED_NORMALIZED
,
449 0, CHAN_BITS
, 0, 0, 0,
450 1, 1, 1 * CHAN_BITS
/ 8
453 MESA_FORMAT_RGBA_FLOAT32
,
461 MESA_FORMAT_RGBA_FLOAT16
,
469 MESA_FORMAT_RGB_FLOAT32
,
477 MESA_FORMAT_RGB_FLOAT16
,
485 MESA_FORMAT_ALPHA_FLOAT32
,
493 MESA_FORMAT_ALPHA_FLOAT16
,
501 MESA_FORMAT_LUMINANCE_FLOAT32
,
509 MESA_FORMAT_LUMINANCE_FLOAT16
,
517 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
,
525 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
,
533 MESA_FORMAT_INTENSITY_FLOAT32
,
541 MESA_FORMAT_INTENSITY_FLOAT16
,
552 GL_SIGNED_NORMALIZED
,
559 MESA_FORMAT_SIGNED_RGBA8888
,
561 GL_SIGNED_NORMALIZED
,
567 MESA_FORMAT_SIGNED_RGBA8888_REV
,
569 GL_SIGNED_NORMALIZED
,
579 static const struct gl_format_info
*
580 _mesa_get_format_info(gl_format format
)
582 const struct gl_format_info
*info
= &format_info
[format
];
583 assert(info
->Name
== format
);
589 _mesa_get_format_bytes(gl_format format
)
591 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
592 ASSERT(info
->BytesPerBlock
);
593 return info
->BytesPerBlock
;
598 _mesa_get_format_base_format(gl_format format
)
600 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
601 return info
->BaseFormat
;
606 _mesa_is_format_compressed(gl_format format
)
608 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
609 return info
->BlockWidth
> 1 || info
->BlockHeight
> 1;
614 * Do sanity checking of the format info table.
617 _mesa_test_formats(void)
621 assert(Elements(format_info
) == MESA_FORMAT_COUNT
);
623 for (i
= 0; i
< MESA_FORMAT_COUNT
; i
++) {
624 const struct gl_format_info
*info
= _mesa_get_format_info(i
);
627 assert(info
->Name
== i
);
629 if (info
->Name
== MESA_FORMAT_NONE
)
632 if (info
->BlockWidth
== 1 && info
->BlockHeight
== 1) {
633 if (info
->RedBits
> 0) {
634 GLuint t
= info
->RedBits
+ info
->GreenBits
635 + info
->BlueBits
+ info
->AlphaBits
;
636 assert(t
/ 8 == info
->BytesPerBlock
);
640 assert(info
->DataType
== GL_UNSIGNED_NORMALIZED
||
641 info
->DataType
== GL_SIGNED_NORMALIZED
||
642 info
->DataType
== GL_UNSIGNED_INT
||
643 info
->DataType
== GL_FLOAT
);
645 if (info
->BaseFormat
== GL_RGB
) {
646 assert(info
->RedBits
> 0);
647 assert(info
->GreenBits
> 0);
648 assert(info
->BlueBits
> 0);
649 assert(info
->AlphaBits
== 0);
650 assert(info
->LuminanceBits
== 0);
651 assert(info
->IntensityBits
== 0);
653 else if (info
->BaseFormat
== GL_RGBA
) {
654 assert(info
->RedBits
> 0);
655 assert(info
->GreenBits
> 0);
656 assert(info
->BlueBits
> 0);
657 assert(info
->AlphaBits
> 0);
658 assert(info
->LuminanceBits
== 0);
659 assert(info
->IntensityBits
== 0);
661 else if (info
->BaseFormat
== GL_LUMINANCE
) {
662 assert(info
->RedBits
== 0);
663 assert(info
->GreenBits
== 0);
664 assert(info
->BlueBits
== 0);
665 assert(info
->AlphaBits
== 0);
666 assert(info
->LuminanceBits
> 0);
667 assert(info
->IntensityBits
== 0);
669 else if (info
->BaseFormat
== GL_INTENSITY
) {
670 assert(info
->RedBits
== 0);
671 assert(info
->GreenBits
== 0);
672 assert(info
->BlueBits
== 0);
673 assert(info
->AlphaBits
== 0);
674 assert(info
->LuminanceBits
== 0);
675 assert(info
->IntensityBits
> 0);
683 * XXX possible replacement for _mesa_format_to_type_and_comps()
684 * Used for mipmap generation.
687 _mesa_format_to_type_and_comps2(gl_format format
,
688 GLenum
*datatype
, GLuint
*comps
)
690 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
692 /* We use a bunch of heuristics here. If this gets too ugly we could
693 * just encode the info the in the gl_format_info structures.
695 if (info
->BaseFormat
== GL_RGB
||
696 info
->BaseFormat
== GL_RGBA
||
697 info
->BaseFormat
== GL_ALPHA
) {
698 *comps
= ((info
->RedBits
> 0) +
699 (info
->GreenBits
> 0) +
700 (info
->BlueBits
> 0) +
701 (info
->AlphaBits
> 0));
703 if (info
->DataType
== GL_FLOAT
) {
704 if (info
->RedBits
== 32)
705 *datatype
= GL_FLOAT
;
707 *datatype
= GL_HALF_FLOAT
;
709 else if (info
->GreenBits
== 3) {
710 *datatype
= GL_UNSIGNED_BYTE_3_3_2
;
712 else if (info
->GreenBits
== 4) {
713 *datatype
= GL_UNSIGNED_SHORT_4_4_4_4
;
715 else if (info
->GreenBits
== 6) {
716 *datatype
= GL_UNSIGNED_SHORT_5_6_5
;
718 else if (info
->GreenBits
== 5) {
719 *datatype
= GL_UNSIGNED_SHORT_1_5_5_5_REV
;
721 else if (info
->RedBits
== 8) {
722 *datatype
= GL_UNSIGNED_BYTE
;
725 ASSERT(info
->RedBits
== 16);
726 *datatype
= GL_UNSIGNED_SHORT
;
729 else if (info
->BaseFormat
== GL_LUMINANCE
||
730 info
->BaseFormat
== GL_LUMINANCE_ALPHA
) {
731 *comps
= ((info
->LuminanceBits
> 0) +
732 (info
->AlphaBits
> 0));
733 if (info
->LuminanceBits
== 8) {
734 *datatype
= GL_UNSIGNED_BYTE
;
736 else if (info
->LuminanceBits
== 16) {
737 *datatype
= GL_UNSIGNED_SHORT
;
740 *datatype
= GL_FLOAT
;
743 else if (info
->BaseFormat
== GL_INTENSITY
) {
745 if (info
->IntensityBits
== 8) {
746 *datatype
= GL_UNSIGNED_BYTE
;
748 else if (info
->IntensityBits
== 16) {
749 *datatype
= GL_UNSIGNED_SHORT
;
752 *datatype
= GL_FLOAT
;
755 else if (info
->BaseFormat
== GL_COLOR_INDEX
) {
757 *datatype
= GL_UNSIGNED_BYTE
;
759 else if (info
->BaseFormat
== GL_DEPTH_COMPONENT
) {
761 if (info
->DepthBits
== 16) {
762 *datatype
= GL_UNSIGNED_SHORT
;
765 ASSERT(info
->DepthBits
== 32);
766 *datatype
= GL_UNSIGNED_INT
;
769 else if (info
->BaseFormat
== GL_DEPTH_STENCIL
) {
771 *datatype
= GL_UNSIGNED_INT
;
773 else if (info
->BaseFormat
== GL_YCBCR_MESA
) {
775 *datatype
= GL_UNSIGNED_SHORT
;
777 else if (info
->BaseFormat
== GL_DUDV_ATI
) {
782 /* any other formats? */
785 *datatype
= GL_UNSIGNED_BYTE
;
791 _mesa_get_format_bits(gl_format format
, GLenum pname
)
793 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
796 case GL_TEXTURE_RED_SIZE
:
797 return info
->RedBits
;
798 case GL_TEXTURE_GREEN_SIZE
:
799 return info
->GreenBits
;
800 case GL_TEXTURE_BLUE_SIZE
:
801 return info
->BlueBits
;
802 case GL_TEXTURE_ALPHA_SIZE
:
803 return info
->AlphaBits
;
804 case GL_TEXTURE_INTENSITY_SIZE
:
805 return info
->IntensityBits
;
806 case GL_TEXTURE_LUMINANCE_SIZE
:
807 return info
->LuminanceBits
;
808 case GL_TEXTURE_INDEX_SIZE_EXT
:
809 return info
->IndexBits
;
810 case GL_TEXTURE_DEPTH_SIZE_ARB
:
811 return info
->DepthBits
;
812 case GL_TEXTURE_STENCIL_SIZE_EXT
:
813 return info
->StencilBits
;
815 _mesa_problem(NULL
, "bad pname in _mesa_get_format_bits()");
822 _mesa_get_format_datatype(gl_format format
)
824 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
825 return info
->DataType
;