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_ARGB4444
, /* 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_REV
, /* 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_RGBA5551
, /* Name */
130 GL_RGBA
, /* BaseFormat */
131 GL_UNSIGNED_NORMALIZED
, /* DataType */
132 5, 5, 5, 1, /* 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_ARGB1555
, /* 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_REV
, /* 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_AL88
, /* Name */
154 GL_LUMINANCE_ALPHA
, /* BaseFormat */
155 GL_UNSIGNED_NORMALIZED
, /* DataType */
156 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */
157 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
158 1, 1, 2 /* BlockWidth/Height,Bytes */
161 MESA_FORMAT_AL88_REV
, /* 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_RGB332
, /* Name */
170 GL_RGB
, /* BaseFormat */
171 GL_UNSIGNED_NORMALIZED
, /* DataType */
172 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */
173 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
174 1, 1, 1 /* BlockWidth/Height,Bytes */
177 MESA_FORMAT_A8
, /* Name */
178 GL_ALPHA
, /* BaseFormat */
179 GL_UNSIGNED_NORMALIZED
, /* DataType */
180 0, 0, 0, 8, /* 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_L8
, /* Name */
186 GL_LUMINANCE
, /* BaseFormat */
187 GL_UNSIGNED_NORMALIZED
, /* DataType */
188 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
189 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
190 1, 1, 1 /* BlockWidth/Height,Bytes */
193 MESA_FORMAT_I8
, /* Name */
194 GL_INTENSITY
, /* BaseFormat */
195 GL_UNSIGNED_NORMALIZED
, /* DataType */
196 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
197 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
198 1, 1, 1 /* BlockWidth/Height,Bytes */
201 MESA_FORMAT_CI8
, /* Name */
202 GL_COLOR_INDEX
, /* BaseFormat */
203 GL_UNSIGNED_INT
, /* DataType */
204 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
205 0, 0, 8, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
206 1, 1, 1 /* BlockWidth/Height,Bytes */
209 MESA_FORMAT_YCBCR
, /* Name */
210 GL_YCBCR_MESA
, /* BaseFormat */
211 GL_UNSIGNED_NORMALIZED
, /* DataType */
212 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
213 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
214 1, 1, 2 /* BlockWidth/Height,Bytes */
217 MESA_FORMAT_YCBCR_REV
, /* 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_Z24_S8
, /* Name */
226 GL_DEPTH_STENCIL
, /* BaseFormat */
227 GL_UNSIGNED_INT
, /* DataType */
228 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
229 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */
230 1, 1, 4 /* BlockWidth/Height,Bytes */
233 MESA_FORMAT_S8_Z24
, /* 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_Z16
, /* Name */
242 GL_DEPTH_COMPONENT
, /* BaseFormat */
243 GL_UNSIGNED_INT
, /* DataType */
244 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
245 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */
246 1, 1, 2 /* BlockWidth/Height,Bytes */
249 MESA_FORMAT_Z32
, /* Name */
250 GL_DEPTH_COMPONENT
, /* BaseFormat */
251 GL_UNSIGNED_INT
, /* DataType */
252 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
253 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */
254 1, 1, 4 /* BlockWidth/Height,Bytes */
257 MESA_FORMAT_S8
, /* Name */
258 GL_STENCIL_INDEX
, /* BaseFormat */
259 GL_UNSIGNED_INT
, /* DataType */
260 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
261 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */
262 1, 1, 1 /* BlockWidth/Height,Bytes */
267 GL_UNSIGNED_NORMALIZED
,
275 GL_UNSIGNED_NORMALIZED
,
283 GL_UNSIGNED_NORMALIZED
,
291 GL_UNSIGNED_NORMALIZED
,
299 GL_UNSIGNED_NORMALIZED
,
305 MESA_FORMAT_SRGB_DXT1
, /* Name */
306 GL_RGB
, /* BaseFormat */
307 GL_UNSIGNED_NORMALIZED
, /* DataType */
308 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */
309 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
310 4, 4, 8 /* 8 bytes per 4x4 block */
313 MESA_FORMAT_SRGBA_DXT1
,
315 GL_UNSIGNED_NORMALIZED
,
318 4, 4, 8 /* 8 bytes per 4x4 block */
321 MESA_FORMAT_SRGBA_DXT3
,
323 GL_UNSIGNED_NORMALIZED
,
326 4, 4, 16 /* 16 bytes per 4x4 block */
329 MESA_FORMAT_SRGBA_DXT5
,
331 GL_UNSIGNED_NORMALIZED
,
334 4, 4, 16 /* 16 bytes per 4x4 block */
338 MESA_FORMAT_RGB_FXT1
,
340 GL_UNSIGNED_NORMALIZED
,
343 8, 4, 16 /* 16 bytes per 8x4 block */
346 MESA_FORMAT_RGBA_FXT1
,
348 GL_UNSIGNED_NORMALIZED
,
351 8, 4, 16 /* 16 bytes per 8x4 block */
355 MESA_FORMAT_RGB_DXT1
, /* Name */
356 GL_RGB
, /* BaseFormat */
357 GL_UNSIGNED_NORMALIZED
, /* DataType */
358 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */
359 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
360 4, 4, 8 /* 8 bytes per 4x4 block */
363 MESA_FORMAT_RGBA_DXT1
,
365 GL_UNSIGNED_NORMALIZED
,
368 4, 4, 8 /* 8 bytes per 4x4 block */
371 MESA_FORMAT_RGBA_DXT3
,
373 GL_UNSIGNED_NORMALIZED
,
376 4, 4, 16 /* 16 bytes per 4x4 block */
379 MESA_FORMAT_RGBA_DXT5
,
381 GL_UNSIGNED_NORMALIZED
,
384 4, 4, 16 /* 16 bytes per 4x4 block */
387 MESA_FORMAT_RGBA_FLOAT32
,
395 MESA_FORMAT_RGBA_FLOAT16
,
403 MESA_FORMAT_RGB_FLOAT32
,
411 MESA_FORMAT_RGB_FLOAT16
,
419 MESA_FORMAT_ALPHA_FLOAT32
,
427 MESA_FORMAT_ALPHA_FLOAT16
,
435 MESA_FORMAT_LUMINANCE_FLOAT32
,
443 MESA_FORMAT_LUMINANCE_FLOAT16
,
451 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
,
459 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
,
467 MESA_FORMAT_INTENSITY_FLOAT32
,
475 MESA_FORMAT_INTENSITY_FLOAT16
,
485 GL_SIGNED_NORMALIZED
,
491 MESA_FORMAT_SIGNED_RGBA8888
,
493 GL_SIGNED_NORMALIZED
,
499 MESA_FORMAT_SIGNED_RGBA8888_REV
,
501 GL_SIGNED_NORMALIZED
,
511 static const struct gl_format_info
*
512 _mesa_get_format_info(gl_format format
)
514 const struct gl_format_info
*info
= &format_info
[format
];
515 assert(info
->Name
== format
);
521 _mesa_get_format_bytes(gl_format format
)
523 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
524 ASSERT(info
->BytesPerBlock
);
525 return info
->BytesPerBlock
;
530 _mesa_get_format_bits(gl_format format
, GLenum pname
)
532 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
535 case GL_TEXTURE_RED_SIZE
:
536 return info
->RedBits
;
537 case GL_TEXTURE_GREEN_SIZE
:
538 return info
->GreenBits
;
539 case GL_TEXTURE_BLUE_SIZE
:
540 return info
->BlueBits
;
541 case GL_TEXTURE_ALPHA_SIZE
:
542 return info
->AlphaBits
;
543 case GL_TEXTURE_INTENSITY_SIZE
:
544 return info
->IntensityBits
;
545 case GL_TEXTURE_LUMINANCE_SIZE
:
546 return info
->LuminanceBits
;
547 case GL_TEXTURE_INDEX_SIZE_EXT
:
548 return info
->IndexBits
;
549 case GL_TEXTURE_DEPTH_SIZE_ARB
:
550 return info
->DepthBits
;
551 case GL_TEXTURE_STENCIL_SIZE_EXT
:
552 return info
->StencilBits
;
554 _mesa_problem(NULL
, "bad pname in _mesa_get_format_bits()");
561 _mesa_get_format_datatype(gl_format format
)
563 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
564 return info
->DataType
;
569 _mesa_get_format_base_format(gl_format format
)
571 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
572 return info
->BaseFormat
;
577 _mesa_is_format_compressed(gl_format format
)
579 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
580 return info
->BlockWidth
> 1 || info
->BlockHeight
> 1;
585 * Return number of bytes needed to store an image of the given size
586 * in the given format.
589 _mesa_format_image_size(gl_format format
, GLsizei width
,
590 GLsizei height
, GLsizei depth
)
592 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
593 /* Strictly speaking, a conditional isn't needed here */
594 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
595 /* compressed format */
596 const GLuint bw
= info
->BlockWidth
, bh
= info
->BlockHeight
;
597 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
598 const GLuint hblocks
= (height
+ bh
- 1) / bh
;
599 const GLuint sz
= wblocks
* hblocks
* info
->BytesPerBlock
;
604 const GLuint sz
= width
* height
* depth
* info
->BytesPerBlock
;
612 _mesa_format_row_stride(gl_format format
, GLsizei width
)
614 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
615 /* Strictly speaking, a conditional isn't needed here */
616 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
617 /* compressed format */
618 const GLuint bw
= info
->BlockWidth
;
619 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
620 const GLint stride
= wblocks
* info
->BytesPerBlock
;
624 const GLint stride
= width
* info
->BytesPerBlock
;
632 * Do sanity checking of the format info table.
635 _mesa_test_formats(void)
639 assert(Elements(format_info
) == MESA_FORMAT_COUNT
);
641 for (i
= 0; i
< MESA_FORMAT_COUNT
; i
++) {
642 const struct gl_format_info
*info
= _mesa_get_format_info(i
);
645 assert(info
->Name
== i
);
647 if (info
->Name
== MESA_FORMAT_NONE
)
650 if (info
->BlockWidth
== 1 && info
->BlockHeight
== 1) {
651 if (info
->RedBits
> 0) {
652 GLuint t
= info
->RedBits
+ info
->GreenBits
653 + info
->BlueBits
+ info
->AlphaBits
;
654 assert(t
/ 8 == info
->BytesPerBlock
);
658 assert(info
->DataType
== GL_UNSIGNED_NORMALIZED
||
659 info
->DataType
== GL_SIGNED_NORMALIZED
||
660 info
->DataType
== GL_UNSIGNED_INT
||
661 info
->DataType
== GL_FLOAT
);
663 if (info
->BaseFormat
== GL_RGB
) {
664 assert(info
->RedBits
> 0);
665 assert(info
->GreenBits
> 0);
666 assert(info
->BlueBits
> 0);
667 assert(info
->AlphaBits
== 0);
668 assert(info
->LuminanceBits
== 0);
669 assert(info
->IntensityBits
== 0);
671 else if (info
->BaseFormat
== GL_RGBA
) {
672 assert(info
->RedBits
> 0);
673 assert(info
->GreenBits
> 0);
674 assert(info
->BlueBits
> 0);
675 assert(info
->AlphaBits
> 0);
676 assert(info
->LuminanceBits
== 0);
677 assert(info
->IntensityBits
== 0);
679 else if (info
->BaseFormat
== GL_LUMINANCE
) {
680 assert(info
->RedBits
== 0);
681 assert(info
->GreenBits
== 0);
682 assert(info
->BlueBits
== 0);
683 assert(info
->AlphaBits
== 0);
684 assert(info
->LuminanceBits
> 0);
685 assert(info
->IntensityBits
== 0);
687 else if (info
->BaseFormat
== GL_INTENSITY
) {
688 assert(info
->RedBits
== 0);
689 assert(info
->GreenBits
== 0);
690 assert(info
->BlueBits
== 0);
691 assert(info
->AlphaBits
== 0);
692 assert(info
->LuminanceBits
== 0);
693 assert(info
->IntensityBits
> 0);
701 * XXX possible replacement for _mesa_format_to_type_and_comps()
702 * Used for mipmap generation.
705 _mesa_format_to_type_and_comps2(gl_format format
,
706 GLenum
*datatype
, GLuint
*comps
)
708 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
710 /* We use a bunch of heuristics here. If this gets too ugly we could
711 * just encode the info the in the gl_format_info structures.
713 if (info
->BaseFormat
== GL_RGB
||
714 info
->BaseFormat
== GL_RGBA
||
715 info
->BaseFormat
== GL_ALPHA
) {
716 *comps
= ((info
->RedBits
> 0) +
717 (info
->GreenBits
> 0) +
718 (info
->BlueBits
> 0) +
719 (info
->AlphaBits
> 0));
721 if (info
->DataType
== GL_FLOAT
) {
722 if (info
->RedBits
== 32)
723 *datatype
= GL_FLOAT
;
725 *datatype
= GL_HALF_FLOAT
;
727 else if (info
->GreenBits
== 3) {
728 *datatype
= GL_UNSIGNED_BYTE_3_3_2
;
730 else if (info
->GreenBits
== 4) {
731 *datatype
= GL_UNSIGNED_SHORT_4_4_4_4
;
733 else if (info
->GreenBits
== 6) {
734 *datatype
= GL_UNSIGNED_SHORT_5_6_5
;
736 else if (info
->GreenBits
== 5) {
737 *datatype
= GL_UNSIGNED_SHORT_1_5_5_5_REV
;
739 else if (info
->RedBits
== 8) {
740 *datatype
= GL_UNSIGNED_BYTE
;
743 ASSERT(info
->RedBits
== 16);
744 *datatype
= GL_UNSIGNED_SHORT
;
747 else if (info
->BaseFormat
== GL_LUMINANCE
||
748 info
->BaseFormat
== GL_LUMINANCE_ALPHA
) {
749 *comps
= ((info
->LuminanceBits
> 0) +
750 (info
->AlphaBits
> 0));
751 if (info
->LuminanceBits
== 8) {
752 *datatype
= GL_UNSIGNED_BYTE
;
754 else if (info
->LuminanceBits
== 16) {
755 *datatype
= GL_UNSIGNED_SHORT
;
758 *datatype
= GL_FLOAT
;
761 else if (info
->BaseFormat
== GL_INTENSITY
) {
763 if (info
->IntensityBits
== 8) {
764 *datatype
= GL_UNSIGNED_BYTE
;
766 else if (info
->IntensityBits
== 16) {
767 *datatype
= GL_UNSIGNED_SHORT
;
770 *datatype
= GL_FLOAT
;
773 else if (info
->BaseFormat
== GL_COLOR_INDEX
) {
775 *datatype
= GL_UNSIGNED_BYTE
;
777 else if (info
->BaseFormat
== GL_DEPTH_COMPONENT
) {
779 if (info
->DepthBits
== 16) {
780 *datatype
= GL_UNSIGNED_SHORT
;
783 ASSERT(info
->DepthBits
== 32);
784 *datatype
= GL_UNSIGNED_INT
;
787 else if (info
->BaseFormat
== GL_DEPTH_STENCIL
) {
789 *datatype
= GL_UNSIGNED_INT
;
791 else if (info
->BaseFormat
== GL_YCBCR_MESA
) {
793 *datatype
= GL_UNSIGNED_SHORT
;
795 else if (info
->BaseFormat
== GL_DUDV_ATI
) {
800 /* any other formats? */
803 *datatype
= GL_UNSIGNED_BYTE
;