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.
29 #include "mfeatures.h"
33 * Information about texture formats.
39 /** text name for debugging */
43 * Base format is one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_ALPHA,
44 * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA,
45 * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL, GL_DUDV_ATI.
50 * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALIZED,
51 * GL_UNSIGNED_INT, GL_INT, GL_FLOAT.
59 GLubyte LuminanceBits
;
60 GLubyte IntensityBits
;
66 * To describe compressed formats. If not compressed, Width=Height=1.
68 GLubyte BlockWidth
, BlockHeight
;
69 GLubyte BytesPerBlock
;
74 * Info about each format.
75 * These must be in the same order as the MESA_FORMAT_* enums so that
76 * we can do lookups without searching.
78 static struct gl_format_info format_info
[MESA_FORMAT_COUNT
] =
81 MESA_FORMAT_NONE
, /* Name */
82 "MESA_FORMAT_NONE", /* StrName */
83 GL_NONE
, /* BaseFormat */
84 GL_NONE
, /* DataType */
85 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
86 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
87 0, 0, 0 /* BlockWidth/Height,Bytes */
90 MESA_FORMAT_RGBA8888
, /* Name */
91 "MESA_FORMAT_RGBA8888", /* StrName */
92 GL_RGBA
, /* BaseFormat */
93 GL_UNSIGNED_NORMALIZED
, /* DataType */
94 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
95 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
96 1, 1, 4 /* BlockWidth/Height,Bytes */
99 MESA_FORMAT_RGBA8888_REV
, /* Name */
100 "MESA_FORMAT_RGBA8888_REV", /* StrName */
101 GL_RGBA
, /* BaseFormat */
102 GL_UNSIGNED_NORMALIZED
, /* DataType */
103 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
104 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
105 1, 1, 4 /* BlockWidth/Height,Bytes */
108 MESA_FORMAT_ARGB8888
, /* Name */
109 "MESA_FORMAT_ARGB8888", /* StrName */
110 GL_RGBA
, /* BaseFormat */
111 GL_UNSIGNED_NORMALIZED
, /* DataType */
112 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
113 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
114 1, 1, 4 /* BlockWidth/Height,Bytes */
117 MESA_FORMAT_ARGB8888_REV
, /* Name */
118 "MESA_FORMAT_ARGB8888_REV", /* StrName */
119 GL_RGBA
, /* BaseFormat */
120 GL_UNSIGNED_NORMALIZED
, /* DataType */
121 8, 8, 8, 8, /* Red/Green/Blue/AlphaBits */
122 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
123 1, 1, 4 /* BlockWidth/Height,Bytes */
126 MESA_FORMAT_XRGB8888
, /* Name */
127 "MESA_FORMAT_XRGB8888", /* StrName */
128 GL_RGB
, /* BaseFormat */
129 GL_UNSIGNED_NORMALIZED
, /* DataType */
130 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
131 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
132 1, 1, 4 /* BlockWidth/Height,Bytes */
135 MESA_FORMAT_XRGB8888_REV
, /* Name */
136 "MESA_FORMAT_XRGB8888_REV", /* StrName */
137 GL_RGB
, /* BaseFormat */
138 GL_UNSIGNED_NORMALIZED
, /* DataType */
139 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
140 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
141 1, 1, 4 /* BlockWidth/Height,Bytes */
144 MESA_FORMAT_RGB888
, /* Name */
145 "MESA_FORMAT_RGB888", /* StrName */
146 GL_RGB
, /* BaseFormat */
147 GL_UNSIGNED_NORMALIZED
, /* DataType */
148 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
149 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
150 1, 1, 3 /* BlockWidth/Height,Bytes */
153 MESA_FORMAT_BGR888
, /* Name */
154 "MESA_FORMAT_BGR888", /* StrName */
155 GL_RGB
, /* BaseFormat */
156 GL_UNSIGNED_NORMALIZED
, /* DataType */
157 8, 8, 8, 0, /* Red/Green/Blue/AlphaBits */
158 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
159 1, 1, 3 /* BlockWidth/Height,Bytes */
162 MESA_FORMAT_RGB565
, /* Name */
163 "MESA_FORMAT_RGB565", /* StrName */
164 GL_RGB
, /* BaseFormat */
165 GL_UNSIGNED_NORMALIZED
, /* DataType */
166 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */
167 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
168 1, 1, 2 /* BlockWidth/Height,Bytes */
171 MESA_FORMAT_RGB565_REV
, /* Name */
172 "MESA_FORMAT_RGB565_REV", /* StrName */
173 GL_RGB
, /* BaseFormat */
174 GL_UNSIGNED_NORMALIZED
, /* DataType */
175 5, 6, 5, 0, /* Red/Green/Blue/AlphaBits */
176 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
177 1, 1, 2 /* BlockWidth/Height,Bytes */
180 MESA_FORMAT_ARGB4444
, /* Name */
181 "MESA_FORMAT_ARGB4444", /* StrName */
182 GL_RGBA
, /* BaseFormat */
183 GL_UNSIGNED_NORMALIZED
, /* DataType */
184 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */
185 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
186 1, 1, 2 /* BlockWidth/Height,Bytes */
189 MESA_FORMAT_ARGB4444_REV
, /* Name */
190 "MESA_FORMAT_ARGB4444_REV", /* StrName */
191 GL_RGBA
, /* BaseFormat */
192 GL_UNSIGNED_NORMALIZED
, /* DataType */
193 4, 4, 4, 4, /* Red/Green/Blue/AlphaBits */
194 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
195 1, 1, 2 /* BlockWidth/Height,Bytes */
198 MESA_FORMAT_RGBA5551
, /* Name */
199 "MESA_FORMAT_RGBA5551", /* StrName */
200 GL_RGBA
, /* BaseFormat */
201 GL_UNSIGNED_NORMALIZED
, /* DataType */
202 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */
203 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
204 1, 1, 2 /* BlockWidth/Height,Bytes */
207 MESA_FORMAT_ARGB1555
, /* Name */
208 "MESA_FORMAT_ARGB1555", /* StrName */
209 GL_RGBA
, /* BaseFormat */
210 GL_UNSIGNED_NORMALIZED
, /* DataType */
211 5, 5, 5, 1, /* Red/Green/Blue/AlphaBits */
212 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
213 1, 1, 2 /* BlockWidth/Height,Bytes */
216 MESA_FORMAT_ARGB1555_REV
, /* Name */
217 "MESA_FORMAT_ARGB1555_REV", /* StrName */
218 GL_RGBA
, /* BaseFormat */
219 GL_UNSIGNED_NORMALIZED
, /* DataType */
220 5, 5, 5, 1, /* 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_AL44
, /* Name */
226 "MESA_FORMAT_AL44", /* StrName */
227 GL_LUMINANCE_ALPHA
, /* BaseFormat */
228 GL_UNSIGNED_NORMALIZED
, /* DataType */
229 0, 0, 0, 4, /* Red/Green/Blue/AlphaBits */
230 4, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
231 1, 1, 1 /* BlockWidth/Height,Bytes */
234 MESA_FORMAT_AL88
, /* Name */
235 "MESA_FORMAT_AL88", /* StrName */
236 GL_LUMINANCE_ALPHA
, /* BaseFormat */
237 GL_UNSIGNED_NORMALIZED
, /* DataType */
238 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */
239 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
240 1, 1, 2 /* BlockWidth/Height,Bytes */
243 MESA_FORMAT_AL88_REV
, /* Name */
244 "MESA_FORMAT_AL88_REV", /* StrName */
245 GL_LUMINANCE_ALPHA
, /* BaseFormat */
246 GL_UNSIGNED_NORMALIZED
, /* DataType */
247 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */
248 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
249 1, 1, 2 /* BlockWidth/Height,Bytes */
252 MESA_FORMAT_AL1616
, /* Name */
253 "MESA_FORMAT_AL1616", /* StrName */
254 GL_LUMINANCE_ALPHA
, /* BaseFormat */
255 GL_UNSIGNED_NORMALIZED
, /* DataType */
256 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */
257 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
258 1, 1, 4 /* BlockWidth/Height,Bytes */
261 MESA_FORMAT_AL1616_REV
, /* Name */
262 "MESA_FORMAT_AL1616_REV", /* StrName */
263 GL_LUMINANCE_ALPHA
, /* BaseFormat */
264 GL_UNSIGNED_NORMALIZED
, /* DataType */
265 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */
266 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
267 1, 1, 4 /* BlockWidth/Height,Bytes */
270 MESA_FORMAT_RGB332
, /* Name */
271 "MESA_FORMAT_RGB332", /* StrName */
272 GL_RGB
, /* BaseFormat */
273 GL_UNSIGNED_NORMALIZED
, /* DataType */
274 3, 3, 2, 0, /* Red/Green/Blue/AlphaBits */
275 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
276 1, 1, 1 /* BlockWidth/Height,Bytes */
279 MESA_FORMAT_A8
, /* Name */
280 "MESA_FORMAT_A8", /* StrName */
281 GL_ALPHA
, /* BaseFormat */
282 GL_UNSIGNED_NORMALIZED
, /* DataType */
283 0, 0, 0, 8, /* Red/Green/Blue/AlphaBits */
284 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
285 1, 1, 1 /* BlockWidth/Height,Bytes */
288 MESA_FORMAT_A16
, /* Name */
289 "MESA_FORMAT_A16", /* StrName */
290 GL_ALPHA
, /* BaseFormat */
291 GL_UNSIGNED_NORMALIZED
, /* DataType */
292 0, 0, 0, 16, /* Red/Green/Blue/AlphaBits */
293 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
294 1, 1, 2 /* BlockWidth/Height,Bytes */
297 MESA_FORMAT_L8
, /* Name */
298 "MESA_FORMAT_L8", /* StrName */
299 GL_LUMINANCE
, /* BaseFormat */
300 GL_UNSIGNED_NORMALIZED
, /* DataType */
301 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
302 8, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
303 1, 1, 1 /* BlockWidth/Height,Bytes */
306 MESA_FORMAT_L16
, /* Name */
307 "MESA_FORMAT_L16", /* StrName */
308 GL_LUMINANCE
, /* BaseFormat */
309 GL_UNSIGNED_NORMALIZED
, /* DataType */
310 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
311 16, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
312 1, 1, 2 /* BlockWidth/Height,Bytes */
315 MESA_FORMAT_I8
, /* Name */
316 "MESA_FORMAT_I8", /* StrName */
317 GL_INTENSITY
, /* BaseFormat */
318 GL_UNSIGNED_NORMALIZED
, /* DataType */
319 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
320 0, 8, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
321 1, 1, 1 /* BlockWidth/Height,Bytes */
324 MESA_FORMAT_I16
, /* Name */
325 "MESA_FORMAT_I16", /* StrName */
326 GL_INTENSITY
, /* BaseFormat */
327 GL_UNSIGNED_NORMALIZED
, /* DataType */
328 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
329 0, 16, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
330 1, 1, 2 /* BlockWidth/Height,Bytes */
333 MESA_FORMAT_YCBCR
, /* Name */
334 "MESA_FORMAT_YCBCR", /* StrName */
335 GL_YCBCR_MESA
, /* BaseFormat */
336 GL_UNSIGNED_NORMALIZED
, /* DataType */
337 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
338 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
339 1, 1, 2 /* BlockWidth/Height,Bytes */
342 MESA_FORMAT_YCBCR_REV
, /* Name */
343 "MESA_FORMAT_YCBCR_REV", /* StrName */
344 GL_YCBCR_MESA
, /* BaseFormat */
345 GL_UNSIGNED_NORMALIZED
, /* DataType */
346 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
347 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
348 1, 1, 2 /* BlockWidth/Height,Bytes */
354 GL_UNSIGNED_NORMALIZED
,
363 GL_UNSIGNED_NORMALIZED
,
369 MESA_FORMAT_RG88_REV
,
370 "MESA_FORMAT_RG88_REV",
372 GL_UNSIGNED_NORMALIZED
,
381 GL_UNSIGNED_NORMALIZED
,
388 "MESA_FORMAT_RG1616",
390 GL_UNSIGNED_NORMALIZED
,
396 MESA_FORMAT_RG1616_REV
,
397 "MESA_FORMAT_RG1616_REV",
399 GL_UNSIGNED_NORMALIZED
,
405 MESA_FORMAT_ARGB2101010
,
406 "MESA_FORMAT_ARGB2101010",
408 GL_UNSIGNED_NORMALIZED
,
414 MESA_FORMAT_Z24_S8
, /* Name */
415 "MESA_FORMAT_Z24_S8", /* StrName */
416 GL_DEPTH_STENCIL
, /* BaseFormat */
417 GL_UNSIGNED_INT
, /* DataType */
418 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
419 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */
420 1, 1, 4 /* BlockWidth/Height,Bytes */
423 MESA_FORMAT_S8_Z24
, /* Name */
424 "MESA_FORMAT_S8_Z24", /* StrName */
425 GL_DEPTH_STENCIL
, /* BaseFormat */
426 GL_UNSIGNED_INT
, /* DataType */
427 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
428 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */
429 1, 1, 4 /* BlockWidth/Height,Bytes */
432 MESA_FORMAT_Z16
, /* Name */
433 "MESA_FORMAT_Z16", /* StrName */
434 GL_DEPTH_COMPONENT
, /* BaseFormat */
435 GL_UNSIGNED_INT
, /* DataType */
436 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
437 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */
438 1, 1, 2 /* BlockWidth/Height,Bytes */
441 MESA_FORMAT_X8_Z24
, /* Name */
442 "MESA_FORMAT_X8_Z24", /* StrName */
443 GL_DEPTH_COMPONENT
, /* BaseFormat */
444 GL_UNSIGNED_INT
, /* DataType */
445 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
446 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */
447 1, 1, 4 /* BlockWidth/Height,Bytes */
450 MESA_FORMAT_Z24_X8
, /* Name */
451 "MESA_FORMAT_Z24_X8", /* StrName */
452 GL_DEPTH_COMPONENT
, /* BaseFormat */
453 GL_UNSIGNED_INT
, /* DataType */
454 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
455 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */
456 1, 1, 4 /* BlockWidth/Height,Bytes */
459 MESA_FORMAT_Z32
, /* Name */
460 "MESA_FORMAT_Z32", /* StrName */
461 GL_DEPTH_COMPONENT
, /* BaseFormat */
462 GL_UNSIGNED_INT
, /* DataType */
463 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
464 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */
465 1, 1, 4 /* BlockWidth/Height,Bytes */
468 MESA_FORMAT_S8
, /* Name */
469 "MESA_FORMAT_S8", /* StrName */
470 GL_STENCIL_INDEX
, /* BaseFormat */
471 GL_UNSIGNED_INT
, /* DataType */
472 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
473 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */
474 1, 1, 1 /* BlockWidth/Height,Bytes */
480 GL_UNSIGNED_NORMALIZED
,
487 "MESA_FORMAT_SRGBA8",
489 GL_UNSIGNED_NORMALIZED
,
496 "MESA_FORMAT_SARGB8",
498 GL_UNSIGNED_NORMALIZED
,
507 GL_UNSIGNED_NORMALIZED
,
516 GL_UNSIGNED_NORMALIZED
,
522 MESA_FORMAT_SRGB_DXT1
, /* Name */
523 "MESA_FORMAT_SRGB_DXT1", /* StrName */
524 GL_RGB
, /* BaseFormat */
525 GL_UNSIGNED_NORMALIZED
, /* DataType */
526 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */
527 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
528 4, 4, 8 /* 8 bytes per 4x4 block */
531 MESA_FORMAT_SRGBA_DXT1
,
532 "MESA_FORMAT_SRGBA_DXT1",
534 GL_UNSIGNED_NORMALIZED
,
537 4, 4, 8 /* 8 bytes per 4x4 block */
540 MESA_FORMAT_SRGBA_DXT3
,
541 "MESA_FORMAT_SRGBA_DXT3",
543 GL_UNSIGNED_NORMALIZED
,
546 4, 4, 16 /* 16 bytes per 4x4 block */
549 MESA_FORMAT_SRGBA_DXT5
,
550 "MESA_FORMAT_SRGBA_DXT5",
552 GL_UNSIGNED_NORMALIZED
,
555 4, 4, 16 /* 16 bytes per 4x4 block */
559 MESA_FORMAT_RGB_FXT1
,
560 "MESA_FORMAT_RGB_FXT1",
562 GL_UNSIGNED_NORMALIZED
,
563 4, 4, 4, 0, /* approx Red/Green/BlueBits */
565 8, 4, 16 /* 16 bytes per 8x4 block */
568 MESA_FORMAT_RGBA_FXT1
,
569 "MESA_FORMAT_RGBA_FXT1",
571 GL_UNSIGNED_NORMALIZED
,
572 4, 4, 4, 1, /* approx Red/Green/Blue/AlphaBits */
574 8, 4, 16 /* 16 bytes per 8x4 block */
578 MESA_FORMAT_RGB_DXT1
, /* Name */
579 "MESA_FORMAT_RGB_DXT1", /* StrName */
580 GL_RGB
, /* BaseFormat */
581 GL_UNSIGNED_NORMALIZED
, /* DataType */
582 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */
583 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
584 4, 4, 8 /* 8 bytes per 4x4 block */
587 MESA_FORMAT_RGBA_DXT1
,
588 "MESA_FORMAT_RGBA_DXT1",
590 GL_UNSIGNED_NORMALIZED
,
593 4, 4, 8 /* 8 bytes per 4x4 block */
596 MESA_FORMAT_RGBA_DXT3
,
597 "MESA_FORMAT_RGBA_DXT3",
599 GL_UNSIGNED_NORMALIZED
,
602 4, 4, 16 /* 16 bytes per 4x4 block */
605 MESA_FORMAT_RGBA_DXT5
,
606 "MESA_FORMAT_RGBA_DXT5",
608 GL_UNSIGNED_NORMALIZED
,
611 4, 4, 16 /* 16 bytes per 4x4 block */
614 MESA_FORMAT_RGBA_FLOAT32
,
615 "MESA_FORMAT_RGBA_FLOAT32",
623 MESA_FORMAT_RGBA_FLOAT16
,
624 "MESA_FORMAT_RGBA_FLOAT16",
632 MESA_FORMAT_RGB_FLOAT32
,
633 "MESA_FORMAT_RGB_FLOAT32",
641 MESA_FORMAT_RGB_FLOAT16
,
642 "MESA_FORMAT_RGB_FLOAT16",
650 MESA_FORMAT_ALPHA_FLOAT32
,
651 "MESA_FORMAT_ALPHA_FLOAT32",
659 MESA_FORMAT_ALPHA_FLOAT16
,
660 "MESA_FORMAT_ALPHA_FLOAT16",
668 MESA_FORMAT_LUMINANCE_FLOAT32
,
669 "MESA_FORMAT_LUMINANCE_FLOAT32",
677 MESA_FORMAT_LUMINANCE_FLOAT16
,
678 "MESA_FORMAT_LUMINANCE_FLOAT16",
686 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
,
687 "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32",
695 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
,
696 "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16",
704 MESA_FORMAT_INTENSITY_FLOAT32
,
705 "MESA_FORMAT_INTENSITY_FLOAT32",
713 MESA_FORMAT_INTENSITY_FLOAT16
,
714 "MESA_FORMAT_INTENSITY_FLOAT16",
722 MESA_FORMAT_R_FLOAT32
,
723 "MESA_FORMAT_R_FLOAT32",
731 MESA_FORMAT_R_FLOAT16
,
732 "MESA_FORMAT_R_FLOAT16",
740 MESA_FORMAT_RG_FLOAT32
,
741 "MESA_FORMAT_RG_FLOAT32",
749 MESA_FORMAT_RG_FLOAT16
,
750 "MESA_FORMAT_RG_FLOAT16",
758 /* unnormalized signed int formats */
760 MESA_FORMAT_RGBA_INT8
,
761 "MESA_FORMAT_RGBA_INT8",
769 MESA_FORMAT_RGBA_INT16
,
770 "MESA_FORMAT_RGBA_INT16",
778 MESA_FORMAT_RGBA_INT32
,
779 "MESA_FORMAT_RGBA_INT32",
787 /* unnormalized unsigned int formats */
789 MESA_FORMAT_RGBA_UINT8
,
790 "MESA_FORMAT_RGBA_UINT8",
798 MESA_FORMAT_RGBA_UINT16
,
799 "MESA_FORMAT_RGBA_UINT16",
807 MESA_FORMAT_RGBA_UINT32
,
808 "MESA_FORMAT_RGBA_UINT32",
821 GL_SIGNED_NORMALIZED
,
827 /* Signed 8 bits / channel */
829 MESA_FORMAT_SIGNED_R8
, /* Name */
830 "MESA_FORMAT_SIGNED_R8", /* StrName */
831 GL_RED
, /* BaseFormat */
832 GL_SIGNED_NORMALIZED
, /* DataType */
833 8, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
834 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
835 1, 1, 1 /* BlockWidth/Height,Bytes */
838 MESA_FORMAT_SIGNED_RG88_REV
,
839 "MESA_FORMAT_SIGNED_RG88_REV",
841 GL_SIGNED_NORMALIZED
,
847 MESA_FORMAT_SIGNED_RGBX8888
,
848 "MESA_FORMAT_SIGNED_RGBX8888",
850 GL_SIGNED_NORMALIZED
,
853 1, 1, 4 /* 4 bpp, but no alpha */
856 MESA_FORMAT_SIGNED_RGBA8888
,
857 "MESA_FORMAT_SIGNED_RGBA8888",
859 GL_SIGNED_NORMALIZED
,
865 MESA_FORMAT_SIGNED_RGBA8888_REV
,
866 "MESA_FORMAT_SIGNED_RGBA8888_REV",
868 GL_SIGNED_NORMALIZED
,
874 /* Signed 16 bits / channel */
876 MESA_FORMAT_SIGNED_R16
,
877 "MESA_FORMAT_SIGNED_R16",
879 GL_SIGNED_NORMALIZED
,
885 MESA_FORMAT_SIGNED_GR1616
,
886 "MESA_FORMAT_SIGNED_GR1616",
888 GL_SIGNED_NORMALIZED
,
894 MESA_FORMAT_SIGNED_RGB_16
,
895 "MESA_FORMAT_SIGNED_RGB_16",
897 GL_SIGNED_NORMALIZED
,
903 MESA_FORMAT_SIGNED_RGBA_16
,
904 "MESA_FORMAT_SIGNED_RGBA_16",
906 GL_SIGNED_NORMALIZED
,
913 "MESA_FORMAT_RGBA_16",
915 GL_UNSIGNED_NORMALIZED
,
921 MESA_FORMAT_RED_RGTC1
,
922 "MESA_FORMAT_RED_RGTC1",
924 GL_UNSIGNED_NORMALIZED
,
927 4, 4, 8 /* 8 bytes per 4x4 block */
930 MESA_FORMAT_SIGNED_RED_RGTC1
,
931 "MESA_FORMAT_SIGNED_RED_RGTC1",
933 GL_SIGNED_NORMALIZED
,
936 4, 4, 8 /* 8 bytes per 4x4 block */
939 MESA_FORMAT_RG_RGTC2
,
940 "MESA_FORMAT_RG_RGTC2",
942 GL_UNSIGNED_NORMALIZED
,
945 4, 4, 16 /* 16 bytes per 4x4 block */
948 MESA_FORMAT_SIGNED_RG_RGTC2
,
949 "MESA_FORMAT_SIGNED_RG_RGTC2",
951 GL_SIGNED_NORMALIZED
,
954 4, 4, 16 /* 16 bytes per 4x4 block */
958 "MESA_FORMAT_L_LATC1",
960 GL_UNSIGNED_NORMALIZED
,
963 4, 4, 8 /* 8 bytes per 4x4 block */
966 MESA_FORMAT_SIGNED_L_LATC1
,
967 "MESA_FORMAT_SIGNED_L_LATC1",
969 GL_SIGNED_NORMALIZED
,
972 4, 4, 8 /* 8 bytes per 4x4 block */
975 MESA_FORMAT_LA_LATC2
,
976 "MESA_FORMAT_LA_LATC2",
978 GL_UNSIGNED_NORMALIZED
,
981 4, 4, 16 /* 16 bytes per 4x4 block */
984 MESA_FORMAT_SIGNED_LA_LATC2
,
985 "MESA_FORMAT_SIGNED_LA_LATC2",
987 GL_SIGNED_NORMALIZED
,
990 4, 4, 16 /* 16 bytes per 4x4 block */
993 /* Signed formats from EXT_texture_snorm that are not in GL3.1 */
995 MESA_FORMAT_SIGNED_A8
,
996 "MESA_FORMAT_SIGNED_A8",
998 GL_SIGNED_NORMALIZED
,
1004 MESA_FORMAT_SIGNED_L8
,
1005 "MESA_FORMAT_SIGNED_L8",
1007 GL_SIGNED_NORMALIZED
,
1013 MESA_FORMAT_SIGNED_AL88
,
1014 "MESA_FORMAT_SIGNED_AL88",
1016 GL_SIGNED_NORMALIZED
,
1022 MESA_FORMAT_SIGNED_I8
,
1023 "MESA_FORMAT_SIGNED_I8",
1025 GL_SIGNED_NORMALIZED
,
1031 MESA_FORMAT_SIGNED_A16
,
1032 "MESA_FORMAT_SIGNED_A16",
1034 GL_SIGNED_NORMALIZED
,
1040 MESA_FORMAT_SIGNED_L16
,
1041 "MESA_FORMAT_SIGNED_L16",
1043 GL_SIGNED_NORMALIZED
,
1049 MESA_FORMAT_SIGNED_AL1616
,
1050 "MESA_FORMAT_SIGNED_AL1616",
1052 GL_SIGNED_NORMALIZED
,
1058 MESA_FORMAT_SIGNED_I16
,
1059 "MESA_FORMAT_SIGNED_I16",
1061 GL_SIGNED_NORMALIZED
,
1067 MESA_FORMAT_RGB9_E5_FLOAT
,
1068 "MESA_FORMAT_RGB9_E5",
1076 MESA_FORMAT_R11_G11_B10_FLOAT
,
1077 "MESA_FORMAT_R11_G11_B10_FLOAT",
1084 /* ARB_depth_buffer_float */
1086 MESA_FORMAT_Z32_FLOAT
, /* Name */
1087 "MESA_FORMAT_Z32_FLOAT", /* StrName */
1088 GL_DEPTH_COMPONENT
, /* BaseFormat */
1089 GL_FLOAT
, /* DataType */
1090 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
1091 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */
1092 1, 1, 4 /* BlockWidth/Height,Bytes */
1095 MESA_FORMAT_Z32_FLOAT_X24S8
, /* Name */
1096 "MESA_FORMAT_Z32_FLOAT_X24S8", /* StrName */
1097 GL_DEPTH_STENCIL
, /* BaseFormat */
1098 GL_NONE
/* XXX */, /* DataType */
1099 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
1100 0, 0, 0, 32, 8, /* Lum/Int/Index/Depth/StencilBits */
1101 1, 1, 8 /* BlockWidth/Height,Bytes */
1107 static const struct gl_format_info
*
1108 _mesa_get_format_info(gl_format format
)
1110 const struct gl_format_info
*info
= &format_info
[format
];
1111 assert(info
->Name
== format
);
1116 /** Return string name of format (for debugging) */
1118 _mesa_get_format_name(gl_format format
)
1120 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1121 return info
->StrName
;
1127 * Return bytes needed to store a block of pixels in the given format.
1128 * Normally, a block is 1x1 (a single pixel). But for compressed formats
1129 * a block may be 4x4 or 8x4, etc.
1131 * Note: not GLuint, so as not to coerce math to unsigned. cf. fdo #37351
1134 _mesa_get_format_bytes(gl_format format
)
1136 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1137 ASSERT(info
->BytesPerBlock
);
1138 return info
->BytesPerBlock
;
1143 * Return bits per component for the given format.
1144 * \param format one of MESA_FORMAT_x
1145 * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc.
1148 _mesa_get_format_bits(gl_format format
, GLenum pname
)
1150 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1154 case GL_TEXTURE_RED_SIZE
:
1155 case GL_RENDERBUFFER_RED_SIZE_EXT
:
1156 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
:
1157 return info
->RedBits
;
1159 case GL_TEXTURE_GREEN_SIZE
:
1160 case GL_RENDERBUFFER_GREEN_SIZE_EXT
:
1161 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
:
1162 return info
->GreenBits
;
1164 case GL_TEXTURE_BLUE_SIZE
:
1165 case GL_RENDERBUFFER_BLUE_SIZE_EXT
:
1166 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
:
1167 return info
->BlueBits
;
1169 case GL_TEXTURE_ALPHA_SIZE
:
1170 case GL_RENDERBUFFER_ALPHA_SIZE_EXT
:
1171 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
:
1172 return info
->AlphaBits
;
1173 case GL_TEXTURE_INTENSITY_SIZE
:
1174 return info
->IntensityBits
;
1175 case GL_TEXTURE_LUMINANCE_SIZE
:
1176 return info
->LuminanceBits
;
1178 return info
->IndexBits
;
1180 case GL_TEXTURE_DEPTH_SIZE_ARB
:
1181 case GL_RENDERBUFFER_DEPTH_SIZE_EXT
:
1182 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
:
1183 return info
->DepthBits
;
1184 case GL_STENCIL_BITS
:
1185 case GL_TEXTURE_STENCIL_SIZE_EXT
:
1186 case GL_RENDERBUFFER_STENCIL_SIZE_EXT
:
1187 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
:
1188 return info
->StencilBits
;
1190 _mesa_problem(NULL
, "bad pname in _mesa_get_format_bits()");
1197 * Return the data type (or more specifically, the data representation)
1198 * for the given format.
1199 * The return value will be one of:
1200 * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1]
1201 * GL_SIGNED_NORMALIZED = signed int representing [-1, 1]
1202 * GL_UNSIGNED_INT = an ordinary unsigned integer
1203 * GL_INT = an ordinary signed integer
1204 * GL_FLOAT = an ordinary float
1207 _mesa_get_format_datatype(gl_format format
)
1209 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1210 return info
->DataType
;
1215 * Return the basic format for the given type. The result will be one of
1216 * GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY,
1217 * GL_YCBCR_MESA, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL.
1220 _mesa_get_format_base_format(gl_format format
)
1222 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1223 return info
->BaseFormat
;
1228 * Return the block size (in pixels) for the given format. Normally
1229 * the block size is 1x1. But compressed formats will have block sizes
1230 * of 4x4 or 8x4 pixels, etc.
1231 * \param bw returns block width in pixels
1232 * \param bh returns block height in pixels
1235 _mesa_get_format_block_size(gl_format format
, GLuint
*bw
, GLuint
*bh
)
1237 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1238 *bw
= info
->BlockWidth
;
1239 *bh
= info
->BlockHeight
;
1243 /** Is the given format a compressed format? */
1245 _mesa_is_format_compressed(gl_format format
)
1247 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1248 return info
->BlockWidth
> 1 || info
->BlockHeight
> 1;
1253 * Determine if the given format represents a packed depth/stencil buffer.
1256 _mesa_is_format_packed_depth_stencil(gl_format format
)
1258 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1260 return info
->BaseFormat
== GL_DEPTH_STENCIL
;
1265 * Is the given format a signed/unsigned integer color format?
1268 _mesa_is_format_integer_color(gl_format format
)
1270 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1271 return (info
->DataType
== GL_INT
|| info
->DataType
== GL_UNSIGNED_INT
) &&
1272 info
->BaseFormat
!= GL_DEPTH_COMPONENT
&&
1273 info
->BaseFormat
!= GL_DEPTH_STENCIL
&&
1274 info
->BaseFormat
!= GL_STENCIL_INDEX
;
1279 * Return color encoding for given format.
1280 * \return GL_LINEAR or GL_SRGB
1283 _mesa_get_format_color_encoding(gl_format format
)
1285 /* XXX this info should be encoded in gl_format_info */
1287 case MESA_FORMAT_SRGB8
:
1288 case MESA_FORMAT_SRGBA8
:
1289 case MESA_FORMAT_SARGB8
:
1290 case MESA_FORMAT_SL8
:
1291 case MESA_FORMAT_SLA8
:
1292 case MESA_FORMAT_SRGB_DXT1
:
1293 case MESA_FORMAT_SRGBA_DXT1
:
1294 case MESA_FORMAT_SRGBA_DXT3
:
1295 case MESA_FORMAT_SRGBA_DXT5
:
1304 * For an sRGB format, return the corresponding linear color space format.
1305 * For non-sRGB formats, return the format as-is.
1308 _mesa_get_srgb_format_linear(gl_format format
)
1311 case MESA_FORMAT_SRGB8
:
1312 format
= MESA_FORMAT_RGB888
;
1314 case MESA_FORMAT_SRGBA8
:
1315 format
= MESA_FORMAT_RGBA8888
;
1317 case MESA_FORMAT_SARGB8
:
1318 format
= MESA_FORMAT_ARGB8888
;
1320 case MESA_FORMAT_SL8
:
1321 format
= MESA_FORMAT_L8
;
1323 case MESA_FORMAT_SLA8
:
1324 format
= MESA_FORMAT_AL88
;
1326 case MESA_FORMAT_SRGB_DXT1
:
1327 format
= MESA_FORMAT_RGB_DXT1
;
1329 case MESA_FORMAT_SRGBA_DXT1
:
1330 format
= MESA_FORMAT_RGBA_DXT1
;
1332 case MESA_FORMAT_SRGBA_DXT3
:
1333 format
= MESA_FORMAT_RGBA_DXT3
;
1335 case MESA_FORMAT_SRGBA_DXT5
:
1336 format
= MESA_FORMAT_RGBA_DXT5
;
1346 * If the given format is a compressed format, return a corresponding
1347 * uncompressed format.
1350 _mesa_get_uncompressed_format(gl_format format
)
1353 case MESA_FORMAT_RGB_FXT1
:
1354 return MESA_FORMAT_RGB888
;
1355 case MESA_FORMAT_RGBA_FXT1
:
1356 return MESA_FORMAT_RGBA8888
;
1357 case MESA_FORMAT_RGB_DXT1
:
1358 case MESA_FORMAT_SRGB_DXT1
:
1359 return MESA_FORMAT_RGB888
;
1360 case MESA_FORMAT_RGBA_DXT1
:
1361 case MESA_FORMAT_SRGBA_DXT1
:
1362 return MESA_FORMAT_RGBA8888
;
1363 case MESA_FORMAT_RGBA_DXT3
:
1364 case MESA_FORMAT_SRGBA_DXT3
:
1365 return MESA_FORMAT_RGBA8888
;
1366 case MESA_FORMAT_RGBA_DXT5
:
1367 case MESA_FORMAT_SRGBA_DXT5
:
1368 return MESA_FORMAT_RGBA8888
;
1369 case MESA_FORMAT_RED_RGTC1
:
1370 return MESA_FORMAT_R8
;
1371 case MESA_FORMAT_SIGNED_RED_RGTC1
:
1372 return MESA_FORMAT_SIGNED_R8
;
1373 case MESA_FORMAT_RG_RGTC2
:
1374 return MESA_FORMAT_RG88
;
1375 case MESA_FORMAT_SIGNED_RG_RGTC2
:
1376 return MESA_FORMAT_SIGNED_RG88_REV
;
1377 case MESA_FORMAT_L_LATC1
:
1378 return MESA_FORMAT_L8
;
1379 case MESA_FORMAT_SIGNED_L_LATC1
:
1380 return MESA_FORMAT_SIGNED_L8
;
1381 case MESA_FORMAT_LA_LATC2
:
1382 return MESA_FORMAT_AL88
;
1383 case MESA_FORMAT_SIGNED_LA_LATC2
:
1384 return MESA_FORMAT_SIGNED_AL88
;
1387 assert(!_mesa_is_format_compressed(format
));
1395 _mesa_format_num_components(gl_format format
)
1397 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1398 return ((info
->RedBits
> 0) +
1399 (info
->GreenBits
> 0) +
1400 (info
->BlueBits
> 0) +
1401 (info
->AlphaBits
> 0) +
1402 (info
->LuminanceBits
> 0) +
1403 (info
->IntensityBits
> 0) +
1404 (info
->DepthBits
> 0) +
1405 (info
->StencilBits
> 0));
1410 * Return number of bytes needed to store an image of the given size
1411 * in the given format.
1414 _mesa_format_image_size(gl_format format
, GLsizei width
,
1415 GLsizei height
, GLsizei depth
)
1417 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1418 /* Strictly speaking, a conditional isn't needed here */
1419 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
1420 /* compressed format (2D only for now) */
1421 const GLuint bw
= info
->BlockWidth
, bh
= info
->BlockHeight
;
1422 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
1423 const GLuint hblocks
= (height
+ bh
- 1) / bh
;
1424 const GLuint sz
= wblocks
* hblocks
* info
->BytesPerBlock
;
1429 /* non-compressed */
1430 const GLuint sz
= width
* height
* depth
* info
->BytesPerBlock
;
1437 * Same as _mesa_format_image_size() but returns a 64-bit value to
1438 * accomodate very large textures.
1441 _mesa_format_image_size64(gl_format format
, GLsizei width
,
1442 GLsizei height
, GLsizei depth
)
1444 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1445 /* Strictly speaking, a conditional isn't needed here */
1446 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
1447 /* compressed format (2D only for now) */
1448 const uint64_t bw
= info
->BlockWidth
, bh
= info
->BlockHeight
;
1449 const uint64_t wblocks
= (width
+ bw
- 1) / bw
;
1450 const uint64_t hblocks
= (height
+ bh
- 1) / bh
;
1451 const uint64_t sz
= wblocks
* hblocks
* info
->BytesPerBlock
;
1456 /* non-compressed */
1457 const uint64_t sz
= ((uint64_t) width
*
1460 info
->BytesPerBlock
);
1468 _mesa_format_row_stride(gl_format format
, GLsizei width
)
1470 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1471 /* Strictly speaking, a conditional isn't needed here */
1472 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
1473 /* compressed format */
1474 const GLuint bw
= info
->BlockWidth
;
1475 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
1476 const GLint stride
= wblocks
* info
->BytesPerBlock
;
1480 const GLint stride
= width
* info
->BytesPerBlock
;
1487 * Debug/test: check that all formats are handled in the
1488 * _mesa_format_to_type_and_comps() function. When new pixel formats
1489 * are added to Mesa, that function needs to be updated.
1490 * This is a no-op after the first call.
1493 check_format_to_type_and_comps(void)
1497 for (f
= MESA_FORMAT_NONE
+ 1; f
< MESA_FORMAT_COUNT
; f
++) {
1498 GLenum datatype
= 0;
1500 /* This function will emit a problem/warning if the format is
1503 _mesa_format_to_type_and_comps(f
, &datatype
, &comps
);
1509 * Do sanity checking of the format info table.
1512 _mesa_test_formats(void)
1516 assert(Elements(format_info
) == MESA_FORMAT_COUNT
);
1518 for (i
= 0; i
< MESA_FORMAT_COUNT
; i
++) {
1519 const struct gl_format_info
*info
= _mesa_get_format_info(i
);
1522 assert(info
->Name
== i
);
1524 if (info
->Name
== MESA_FORMAT_NONE
)
1527 if (info
->BlockWidth
== 1 && info
->BlockHeight
== 1) {
1528 if (info
->RedBits
> 0) {
1529 GLuint t
= info
->RedBits
+ info
->GreenBits
1530 + info
->BlueBits
+ info
->AlphaBits
;
1531 assert(t
/ 8 <= info
->BytesPerBlock
);
1536 assert(info
->DataType
== GL_UNSIGNED_NORMALIZED
||
1537 info
->DataType
== GL_SIGNED_NORMALIZED
||
1538 info
->DataType
== GL_UNSIGNED_INT
||
1539 info
->DataType
== GL_INT
||
1540 info
->DataType
== GL_FLOAT
||
1541 /* Z32_FLOAT_X24S8 has DataType of GL_NONE */
1542 info
->DataType
== GL_NONE
);
1544 if (info
->BaseFormat
== GL_RGB
) {
1545 assert(info
->RedBits
> 0);
1546 assert(info
->GreenBits
> 0);
1547 assert(info
->BlueBits
> 0);
1548 assert(info
->AlphaBits
== 0);
1549 assert(info
->LuminanceBits
== 0);
1550 assert(info
->IntensityBits
== 0);
1552 else if (info
->BaseFormat
== GL_RGBA
) {
1553 assert(info
->RedBits
> 0);
1554 assert(info
->GreenBits
> 0);
1555 assert(info
->BlueBits
> 0);
1556 assert(info
->AlphaBits
> 0);
1557 assert(info
->LuminanceBits
== 0);
1558 assert(info
->IntensityBits
== 0);
1560 else if (info
->BaseFormat
== GL_RG
) {
1561 assert(info
->RedBits
> 0);
1562 assert(info
->GreenBits
> 0);
1563 assert(info
->BlueBits
== 0);
1564 assert(info
->AlphaBits
== 0);
1565 assert(info
->LuminanceBits
== 0);
1566 assert(info
->IntensityBits
== 0);
1568 else if (info
->BaseFormat
== GL_RED
) {
1569 assert(info
->RedBits
> 0);
1570 assert(info
->GreenBits
== 0);
1571 assert(info
->BlueBits
== 0);
1572 assert(info
->AlphaBits
== 0);
1573 assert(info
->LuminanceBits
== 0);
1574 assert(info
->IntensityBits
== 0);
1576 else if (info
->BaseFormat
== GL_LUMINANCE
) {
1577 assert(info
->RedBits
== 0);
1578 assert(info
->GreenBits
== 0);
1579 assert(info
->BlueBits
== 0);
1580 assert(info
->AlphaBits
== 0);
1581 assert(info
->LuminanceBits
> 0);
1582 assert(info
->IntensityBits
== 0);
1584 else if (info
->BaseFormat
== GL_INTENSITY
) {
1585 assert(info
->RedBits
== 0);
1586 assert(info
->GreenBits
== 0);
1587 assert(info
->BlueBits
== 0);
1588 assert(info
->AlphaBits
== 0);
1589 assert(info
->LuminanceBits
== 0);
1590 assert(info
->IntensityBits
> 0);
1594 check_format_to_type_and_comps();
1600 * Return datatype and number of components per texel for the given gl_format.
1601 * Only used for mipmap generation code.
1604 _mesa_format_to_type_and_comps(gl_format format
,
1605 GLenum
*datatype
, GLuint
*comps
)
1608 case MESA_FORMAT_RGBA8888
:
1609 case MESA_FORMAT_RGBA8888_REV
:
1610 case MESA_FORMAT_ARGB8888
:
1611 case MESA_FORMAT_ARGB8888_REV
:
1612 case MESA_FORMAT_XRGB8888
:
1613 case MESA_FORMAT_XRGB8888_REV
:
1614 *datatype
= GL_UNSIGNED_BYTE
;
1617 case MESA_FORMAT_RGB888
:
1618 case MESA_FORMAT_BGR888
:
1619 *datatype
= GL_UNSIGNED_BYTE
;
1622 case MESA_FORMAT_RGB565
:
1623 case MESA_FORMAT_RGB565_REV
:
1624 *datatype
= GL_UNSIGNED_SHORT_5_6_5
;
1628 case MESA_FORMAT_ARGB4444
:
1629 case MESA_FORMAT_ARGB4444_REV
:
1630 *datatype
= GL_UNSIGNED_SHORT_4_4_4_4
;
1634 case MESA_FORMAT_ARGB1555
:
1635 case MESA_FORMAT_ARGB1555_REV
:
1636 *datatype
= GL_UNSIGNED_SHORT_1_5_5_5_REV
;
1640 case MESA_FORMAT_ARGB2101010
:
1641 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1645 case MESA_FORMAT_RGBA5551
:
1646 *datatype
= GL_UNSIGNED_SHORT_5_5_5_1
;
1650 case MESA_FORMAT_AL44
:
1651 *datatype
= MESA_UNSIGNED_BYTE_4_4
;
1655 case MESA_FORMAT_AL88
:
1656 case MESA_FORMAT_AL88_REV
:
1657 case MESA_FORMAT_RG88
:
1658 case MESA_FORMAT_RG88_REV
:
1659 *datatype
= GL_UNSIGNED_BYTE
;
1663 case MESA_FORMAT_AL1616
:
1664 case MESA_FORMAT_AL1616_REV
:
1665 case MESA_FORMAT_RG1616
:
1666 case MESA_FORMAT_RG1616_REV
:
1667 *datatype
= GL_UNSIGNED_SHORT
;
1671 case MESA_FORMAT_R16
:
1672 case MESA_FORMAT_A16
:
1673 case MESA_FORMAT_L16
:
1674 case MESA_FORMAT_I16
:
1675 *datatype
= GL_UNSIGNED_SHORT
;
1679 case MESA_FORMAT_RGB332
:
1680 *datatype
= GL_UNSIGNED_BYTE_3_3_2
;
1684 case MESA_FORMAT_A8
:
1685 case MESA_FORMAT_L8
:
1686 case MESA_FORMAT_I8
:
1687 case MESA_FORMAT_R8
:
1688 case MESA_FORMAT_S8
:
1689 *datatype
= GL_UNSIGNED_BYTE
;
1693 case MESA_FORMAT_YCBCR
:
1694 case MESA_FORMAT_YCBCR_REV
:
1695 *datatype
= GL_UNSIGNED_SHORT
;
1699 case MESA_FORMAT_Z24_S8
:
1700 *datatype
= GL_UNSIGNED_INT
;
1701 *comps
= 1; /* XXX OK? */
1704 case MESA_FORMAT_S8_Z24
:
1705 *datatype
= GL_UNSIGNED_INT
;
1706 *comps
= 1; /* XXX OK? */
1709 case MESA_FORMAT_Z16
:
1710 *datatype
= GL_UNSIGNED_SHORT
;
1714 case MESA_FORMAT_X8_Z24
:
1715 *datatype
= GL_UNSIGNED_INT
;
1719 case MESA_FORMAT_Z24_X8
:
1720 *datatype
= GL_UNSIGNED_INT
;
1724 case MESA_FORMAT_Z32
:
1725 *datatype
= GL_UNSIGNED_INT
;
1729 case MESA_FORMAT_Z32_FLOAT
:
1730 *datatype
= GL_FLOAT
;
1734 case MESA_FORMAT_Z32_FLOAT_X24S8
:
1735 *datatype
= GL_FLOAT_32_UNSIGNED_INT_24_8_REV
;
1739 case MESA_FORMAT_DUDV8
:
1740 *datatype
= GL_BYTE
;
1744 case MESA_FORMAT_SIGNED_R8
:
1745 case MESA_FORMAT_SIGNED_A8
:
1746 case MESA_FORMAT_SIGNED_L8
:
1747 case MESA_FORMAT_SIGNED_I8
:
1748 *datatype
= GL_BYTE
;
1751 case MESA_FORMAT_SIGNED_RG88_REV
:
1752 case MESA_FORMAT_SIGNED_AL88
:
1753 *datatype
= GL_BYTE
;
1756 case MESA_FORMAT_SIGNED_RGBA8888
:
1757 case MESA_FORMAT_SIGNED_RGBA8888_REV
:
1758 case MESA_FORMAT_SIGNED_RGBX8888
:
1759 *datatype
= GL_BYTE
;
1763 case MESA_FORMAT_RGBA_16
:
1764 *datatype
= GL_UNSIGNED_SHORT
;
1768 case MESA_FORMAT_SIGNED_R16
:
1769 case MESA_FORMAT_SIGNED_A16
:
1770 case MESA_FORMAT_SIGNED_L16
:
1771 case MESA_FORMAT_SIGNED_I16
:
1772 *datatype
= GL_SHORT
;
1775 case MESA_FORMAT_SIGNED_GR1616
:
1776 case MESA_FORMAT_SIGNED_AL1616
:
1777 *datatype
= GL_SHORT
;
1780 case MESA_FORMAT_SIGNED_RGB_16
:
1781 *datatype
= GL_SHORT
;
1784 case MESA_FORMAT_SIGNED_RGBA_16
:
1785 *datatype
= GL_SHORT
;
1789 #if FEATURE_EXT_texture_sRGB
1790 case MESA_FORMAT_SRGB8
:
1791 *datatype
= GL_UNSIGNED_BYTE
;
1794 case MESA_FORMAT_SRGBA8
:
1795 case MESA_FORMAT_SARGB8
:
1796 *datatype
= GL_UNSIGNED_BYTE
;
1799 case MESA_FORMAT_SL8
:
1800 *datatype
= GL_UNSIGNED_BYTE
;
1803 case MESA_FORMAT_SLA8
:
1804 *datatype
= GL_UNSIGNED_BYTE
;
1809 #if FEATURE_texture_fxt1
1810 case MESA_FORMAT_RGB_FXT1
:
1811 case MESA_FORMAT_RGBA_FXT1
:
1813 #if FEATURE_texture_s3tc
1814 case MESA_FORMAT_RGB_DXT1
:
1815 case MESA_FORMAT_RGBA_DXT1
:
1816 case MESA_FORMAT_RGBA_DXT3
:
1817 case MESA_FORMAT_RGBA_DXT5
:
1818 #if FEATURE_EXT_texture_sRGB
1819 case MESA_FORMAT_SRGB_DXT1
:
1820 case MESA_FORMAT_SRGBA_DXT1
:
1821 case MESA_FORMAT_SRGBA_DXT3
:
1822 case MESA_FORMAT_SRGBA_DXT5
:
1825 case MESA_FORMAT_RED_RGTC1
:
1826 case MESA_FORMAT_SIGNED_RED_RGTC1
:
1827 case MESA_FORMAT_RG_RGTC2
:
1828 case MESA_FORMAT_SIGNED_RG_RGTC2
:
1829 case MESA_FORMAT_L_LATC1
:
1830 case MESA_FORMAT_SIGNED_L_LATC1
:
1831 case MESA_FORMAT_LA_LATC2
:
1832 case MESA_FORMAT_SIGNED_LA_LATC2
:
1833 /* XXX generate error instead? */
1834 *datatype
= GL_UNSIGNED_BYTE
;
1838 case MESA_FORMAT_RGBA_FLOAT32
:
1839 *datatype
= GL_FLOAT
;
1842 case MESA_FORMAT_RGBA_FLOAT16
:
1843 *datatype
= GL_HALF_FLOAT_ARB
;
1846 case MESA_FORMAT_RGB_FLOAT32
:
1847 *datatype
= GL_FLOAT
;
1850 case MESA_FORMAT_RGB_FLOAT16
:
1851 *datatype
= GL_HALF_FLOAT_ARB
;
1854 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
:
1855 case MESA_FORMAT_RG_FLOAT32
:
1856 *datatype
= GL_FLOAT
;
1859 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
:
1860 case MESA_FORMAT_RG_FLOAT16
:
1861 *datatype
= GL_HALF_FLOAT_ARB
;
1864 case MESA_FORMAT_ALPHA_FLOAT32
:
1865 case MESA_FORMAT_LUMINANCE_FLOAT32
:
1866 case MESA_FORMAT_INTENSITY_FLOAT32
:
1867 case MESA_FORMAT_R_FLOAT32
:
1868 *datatype
= GL_FLOAT
;
1871 case MESA_FORMAT_ALPHA_FLOAT16
:
1872 case MESA_FORMAT_LUMINANCE_FLOAT16
:
1873 case MESA_FORMAT_INTENSITY_FLOAT16
:
1874 case MESA_FORMAT_R_FLOAT16
:
1875 *datatype
= GL_HALF_FLOAT_ARB
;
1879 case MESA_FORMAT_RGBA_INT8
:
1880 *datatype
= GL_BYTE
;
1883 case MESA_FORMAT_RGBA_INT16
:
1884 *datatype
= GL_SHORT
;
1887 case MESA_FORMAT_RGBA_INT32
:
1893 * \name Non-normalized unsigned integer formats.
1895 case MESA_FORMAT_RGBA_UINT8
:
1896 *datatype
= GL_UNSIGNED_BYTE
;
1899 case MESA_FORMAT_RGBA_UINT16
:
1900 *datatype
= GL_UNSIGNED_SHORT
;
1903 case MESA_FORMAT_RGBA_UINT32
:
1904 *datatype
= GL_UNSIGNED_INT
;
1908 case MESA_FORMAT_RGB9_E5_FLOAT
:
1909 *datatype
= GL_UNSIGNED_INT_5_9_9_9_REV
;
1913 case MESA_FORMAT_R11_G11_B10_FLOAT
:
1914 *datatype
= GL_UNSIGNED_INT_10F_11F_11F_REV
;
1918 case MESA_FORMAT_COUNT
:
1922 case MESA_FORMAT_NONE
:
1923 /* For debug builds, warn if any formats are not handled */
1927 _mesa_problem(NULL
, "bad format %s in _mesa_format_to_type_and_comps",
1928 _mesa_get_format_name(format
));