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_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE,
44 * GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX,
45 * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL.
50 * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALED,
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_CI8
, /* Name */
334 "MESA_FORMAT_CI8", /* StrName */
335 GL_COLOR_INDEX
, /* BaseFormat */
336 GL_UNSIGNED_INT
, /* DataType */
337 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
338 0, 0, 8, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
339 1, 1, 1 /* BlockWidth/Height,Bytes */
342 MESA_FORMAT_YCBCR
, /* Name */
343 "MESA_FORMAT_YCBCR", /* 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 */
351 MESA_FORMAT_YCBCR_REV
, /* Name */
352 "MESA_FORMAT_YCBCR_REV", /* StrName */
353 GL_YCBCR_MESA
, /* BaseFormat */
354 GL_UNSIGNED_NORMALIZED
, /* DataType */
355 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
356 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
357 1, 1, 2 /* BlockWidth/Height,Bytes */
363 GL_UNSIGNED_NORMALIZED
,
372 GL_UNSIGNED_NORMALIZED
,
378 MESA_FORMAT_RG88_REV
,
379 "MESA_FORMAT_RG88_REV",
381 GL_UNSIGNED_NORMALIZED
,
390 GL_UNSIGNED_NORMALIZED
,
397 "MESA_FORMAT_RG1616",
399 GL_UNSIGNED_NORMALIZED
,
405 MESA_FORMAT_RG1616_REV
,
406 "MESA_FORMAT_RG1616_REV",
408 GL_UNSIGNED_NORMALIZED
,
414 MESA_FORMAT_ARGB2101010
,
415 "MESA_FORMAT_ARGB2101010",
417 GL_UNSIGNED_NORMALIZED
,
423 MESA_FORMAT_Z24_S8
, /* Name */
424 "MESA_FORMAT_Z24_S8", /* 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_S8_Z24
, /* Name */
433 "MESA_FORMAT_S8_Z24", /* StrName */
434 GL_DEPTH_STENCIL
, /* BaseFormat */
435 GL_UNSIGNED_INT
, /* DataType */
436 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
437 0, 0, 0, 24, 8, /* Lum/Int/Index/Depth/StencilBits */
438 1, 1, 4 /* BlockWidth/Height,Bytes */
441 MESA_FORMAT_Z16
, /* Name */
442 "MESA_FORMAT_Z16", /* StrName */
443 GL_DEPTH_COMPONENT
, /* BaseFormat */
444 GL_UNSIGNED_INT
, /* DataType */
445 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
446 0, 0, 0, 16, 0, /* Lum/Int/Index/Depth/StencilBits */
447 1, 1, 2 /* BlockWidth/Height,Bytes */
450 MESA_FORMAT_X8_Z24
, /* Name */
451 "MESA_FORMAT_X8_Z24", /* 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_Z24_X8
, /* Name */
460 "MESA_FORMAT_Z24_X8", /* StrName */
461 GL_DEPTH_COMPONENT
, /* BaseFormat */
462 GL_UNSIGNED_INT
, /* DataType */
463 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
464 0, 0, 0, 24, 0, /* Lum/Int/Index/Depth/StencilBits */
465 1, 1, 4 /* BlockWidth/Height,Bytes */
468 MESA_FORMAT_Z32
, /* Name */
469 "MESA_FORMAT_Z32", /* StrName */
470 GL_DEPTH_COMPONENT
, /* BaseFormat */
471 GL_UNSIGNED_INT
, /* DataType */
472 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
473 0, 0, 0, 32, 0, /* Lum/Int/Index/Depth/StencilBits */
474 1, 1, 4 /* BlockWidth/Height,Bytes */
477 MESA_FORMAT_S8
, /* Name */
478 "MESA_FORMAT_S8", /* StrName */
479 GL_STENCIL_INDEX
, /* BaseFormat */
480 GL_UNSIGNED_INT
, /* DataType */
481 0, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
482 0, 0, 0, 0, 8, /* Lum/Int/Index/Depth/StencilBits */
483 1, 1, 1 /* BlockWidth/Height,Bytes */
489 GL_UNSIGNED_NORMALIZED
,
496 "MESA_FORMAT_SRGBA8",
498 GL_UNSIGNED_NORMALIZED
,
505 "MESA_FORMAT_SARGB8",
507 GL_UNSIGNED_NORMALIZED
,
516 GL_UNSIGNED_NORMALIZED
,
525 GL_UNSIGNED_NORMALIZED
,
531 MESA_FORMAT_SRGB_DXT1
, /* Name */
532 "MESA_FORMAT_SRGB_DXT1", /* StrName */
533 GL_RGB
, /* BaseFormat */
534 GL_UNSIGNED_NORMALIZED
, /* DataType */
535 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */
536 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
537 4, 4, 8 /* 8 bytes per 4x4 block */
540 MESA_FORMAT_SRGBA_DXT1
,
541 "MESA_FORMAT_SRGBA_DXT1",
543 GL_UNSIGNED_NORMALIZED
,
546 4, 4, 8 /* 8 bytes per 4x4 block */
549 MESA_FORMAT_SRGBA_DXT3
,
550 "MESA_FORMAT_SRGBA_DXT3",
552 GL_UNSIGNED_NORMALIZED
,
555 4, 4, 16 /* 16 bytes per 4x4 block */
558 MESA_FORMAT_SRGBA_DXT5
,
559 "MESA_FORMAT_SRGBA_DXT5",
561 GL_UNSIGNED_NORMALIZED
,
564 4, 4, 16 /* 16 bytes per 4x4 block */
568 MESA_FORMAT_RGB_FXT1
,
569 "MESA_FORMAT_RGB_FXT1",
571 GL_UNSIGNED_NORMALIZED
,
572 4, 4, 4, 0, /* approx Red/Green/BlueBits */
574 8, 4, 16 /* 16 bytes per 8x4 block */
577 MESA_FORMAT_RGBA_FXT1
,
578 "MESA_FORMAT_RGBA_FXT1",
580 GL_UNSIGNED_NORMALIZED
,
581 4, 4, 4, 1, /* approx Red/Green/Blue/AlphaBits */
583 8, 4, 16 /* 16 bytes per 8x4 block */
587 MESA_FORMAT_RGB_DXT1
, /* Name */
588 "MESA_FORMAT_RGB_DXT1", /* StrName */
589 GL_RGB
, /* BaseFormat */
590 GL_UNSIGNED_NORMALIZED
, /* DataType */
591 4, 4, 4, 0, /* approx Red/Green/Blue/AlphaBits */
592 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
593 4, 4, 8 /* 8 bytes per 4x4 block */
596 MESA_FORMAT_RGBA_DXT1
,
597 "MESA_FORMAT_RGBA_DXT1",
599 GL_UNSIGNED_NORMALIZED
,
602 4, 4, 8 /* 8 bytes per 4x4 block */
605 MESA_FORMAT_RGBA_DXT3
,
606 "MESA_FORMAT_RGBA_DXT3",
608 GL_UNSIGNED_NORMALIZED
,
611 4, 4, 16 /* 16 bytes per 4x4 block */
614 MESA_FORMAT_RGBA_DXT5
,
615 "MESA_FORMAT_RGBA_DXT5",
617 GL_UNSIGNED_NORMALIZED
,
620 4, 4, 16 /* 16 bytes per 4x4 block */
623 MESA_FORMAT_RGBA_FLOAT32
,
624 "MESA_FORMAT_RGBA_FLOAT32",
632 MESA_FORMAT_RGBA_FLOAT16
,
633 "MESA_FORMAT_RGBA_FLOAT16",
641 MESA_FORMAT_RGB_FLOAT32
,
642 "MESA_FORMAT_RGB_FLOAT32",
650 MESA_FORMAT_RGB_FLOAT16
,
651 "MESA_FORMAT_RGB_FLOAT16",
659 MESA_FORMAT_ALPHA_FLOAT32
,
660 "MESA_FORMAT_ALPHA_FLOAT32",
668 MESA_FORMAT_ALPHA_FLOAT16
,
669 "MESA_FORMAT_ALPHA_FLOAT16",
677 MESA_FORMAT_LUMINANCE_FLOAT32
,
678 "MESA_FORMAT_LUMINANCE_FLOAT32",
686 MESA_FORMAT_LUMINANCE_FLOAT16
,
687 "MESA_FORMAT_LUMINANCE_FLOAT16",
695 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
,
696 "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32",
704 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
,
705 "MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16",
713 MESA_FORMAT_INTENSITY_FLOAT32
,
714 "MESA_FORMAT_INTENSITY_FLOAT32",
722 MESA_FORMAT_INTENSITY_FLOAT16
,
723 "MESA_FORMAT_INTENSITY_FLOAT16",
731 /* unnormalized signed int formats */
733 MESA_FORMAT_RGBA_INT8
,
734 "MESA_FORMAT_RGBA_INT8",
742 MESA_FORMAT_RGBA_INT16
,
743 "MESA_FORMAT_RGBA_INT16",
751 MESA_FORMAT_RGBA_INT32
,
752 "MESA_FORMAT_RGBA_INT32",
760 /* unnormalized unsigned int formats */
762 MESA_FORMAT_RGBA_UINT8
,
763 "MESA_FORMAT_RGBA_UINT8",
771 MESA_FORMAT_RGBA_UINT16
,
772 "MESA_FORMAT_RGBA_UINT16",
780 MESA_FORMAT_RGBA_UINT32
,
781 "MESA_FORMAT_RGBA_UINT32",
794 GL_SIGNED_NORMALIZED
,
800 /* Signed 8 bits / channel */
802 MESA_FORMAT_SIGNED_R8
, /* Name */
803 "MESA_FORMAT_SIGNED_R8", /* StrName */
804 GL_RGBA
, /* BaseFormat */
805 GL_SIGNED_NORMALIZED
, /* DataType */
806 8, 0, 0, 0, /* Red/Green/Blue/AlphaBits */
807 0, 0, 0, 0, 0, /* Lum/Int/Index/Depth/StencilBits */
808 1, 1, 1 /* BlockWidth/Height,Bytes */
811 MESA_FORMAT_SIGNED_RG88
,
812 "MESA_FORMAT_SIGNED_RG88",
814 GL_SIGNED_NORMALIZED
,
820 MESA_FORMAT_SIGNED_RGBX8888
,
821 "MESA_FORMAT_SIGNED_RGBX8888",
823 GL_SIGNED_NORMALIZED
,
826 1, 1, 4 /* 4 bpp, but no alpha */
829 MESA_FORMAT_SIGNED_RGBA8888
,
830 "MESA_FORMAT_SIGNED_RGBA8888",
832 GL_SIGNED_NORMALIZED
,
838 MESA_FORMAT_SIGNED_RGBA8888_REV
,
839 "MESA_FORMAT_SIGNED_RGBA8888_REV",
841 GL_SIGNED_NORMALIZED
,
847 /* Signed 16 bits / channel */
849 MESA_FORMAT_SIGNED_R_16
,
850 "MESA_FORMAT_SIGNED_R_16",
852 GL_SIGNED_NORMALIZED
,
858 MESA_FORMAT_SIGNED_RG_16
,
859 "MESA_FORMAT_SIGNED_RG_16",
861 GL_SIGNED_NORMALIZED
,
867 MESA_FORMAT_SIGNED_RGB_16
,
868 "MESA_FORMAT_SIGNED_RGB_16",
870 GL_SIGNED_NORMALIZED
,
876 MESA_FORMAT_SIGNED_RGBA_16
,
877 "MESA_FORMAT_SIGNED_RGBA_16",
879 GL_SIGNED_NORMALIZED
,
886 "MESA_FORMAT_RGBA_16",
888 GL_UNSIGNED_NORMALIZED
,
897 static const struct gl_format_info
*
898 _mesa_get_format_info(gl_format format
)
900 const struct gl_format_info
*info
= &format_info
[format
];
901 assert(info
->Name
== format
);
906 /** Return string name of format (for debugging) */
908 _mesa_get_format_name(gl_format format
)
910 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
911 return info
->StrName
;
917 * Return bytes needed to store a block of pixels in the given format.
918 * Normally, a block is 1x1 (a single pixel). But for compressed formats
919 * a block may be 4x4 or 8x4, etc.
922 _mesa_get_format_bytes(gl_format format
)
924 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
925 ASSERT(info
->BytesPerBlock
);
926 return info
->BytesPerBlock
;
931 * Return bits per component for the given format.
932 * \param format one of MESA_FORMAT_x
933 * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc.
936 _mesa_get_format_bits(gl_format format
, GLenum pname
)
938 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
942 case GL_TEXTURE_RED_SIZE
:
943 case GL_RENDERBUFFER_RED_SIZE_EXT
:
944 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
:
945 return info
->RedBits
;
947 case GL_TEXTURE_GREEN_SIZE
:
948 case GL_RENDERBUFFER_GREEN_SIZE_EXT
:
949 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
:
950 return info
->GreenBits
;
952 case GL_TEXTURE_BLUE_SIZE
:
953 case GL_RENDERBUFFER_BLUE_SIZE_EXT
:
954 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
:
955 return info
->BlueBits
;
957 case GL_TEXTURE_ALPHA_SIZE
:
958 case GL_RENDERBUFFER_ALPHA_SIZE_EXT
:
959 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
:
960 return info
->AlphaBits
;
961 case GL_TEXTURE_INTENSITY_SIZE
:
962 return info
->IntensityBits
;
963 case GL_TEXTURE_LUMINANCE_SIZE
:
964 return info
->LuminanceBits
;
966 case GL_TEXTURE_INDEX_SIZE_EXT
:
967 return info
->IndexBits
;
969 case GL_TEXTURE_DEPTH_SIZE_ARB
:
970 case GL_RENDERBUFFER_DEPTH_SIZE_EXT
:
971 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
:
972 return info
->DepthBits
;
973 case GL_STENCIL_BITS
:
974 case GL_TEXTURE_STENCIL_SIZE_EXT
:
975 case GL_RENDERBUFFER_STENCIL_SIZE_EXT
:
976 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
:
977 return info
->StencilBits
;
979 _mesa_problem(NULL
, "bad pname in _mesa_get_format_bits()");
986 * Return the data type (or more specifically, the data representation)
987 * for the given format.
988 * The return value will be one of:
989 * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1]
990 * GL_SIGNED_NORMALIZED = signed int representing [-1, 1]
991 * GL_UNSIGNED_INT = an ordinary unsigned integer
992 * GL_INT = an ordinary signed integer
993 * GL_FLOAT = an ordinary float
996 _mesa_get_format_datatype(gl_format format
)
998 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
999 return info
->DataType
;
1004 * Return the basic format for the given type. The result will be
1005 * one of GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA,
1006 * GL_INTENSITY, GL_YCBCR_MESA, GL_COLOR_INDEX, GL_DEPTH_COMPONENT,
1007 * GL_STENCIL_INDEX, GL_DEPTH_STENCIL.
1010 _mesa_get_format_base_format(gl_format format
)
1012 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1013 return info
->BaseFormat
;
1018 * Return the block size (in pixels) for the given format. Normally
1019 * the block size is 1x1. But compressed formats will have block sizes
1020 * of 4x4 or 8x4 pixels, etc.
1021 * \param bw returns block width in pixels
1022 * \param bh returns block height in pixels
1025 _mesa_get_format_block_size(gl_format format
, GLuint
*bw
, GLuint
*bh
)
1027 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1028 *bw
= info
->BlockWidth
;
1029 *bh
= info
->BlockHeight
;
1033 /** Is the given format a compressed format? */
1035 _mesa_is_format_compressed(gl_format format
)
1037 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1038 return info
->BlockWidth
> 1 || info
->BlockHeight
> 1;
1043 * Determine if the given format represents a packed depth/stencil buffer.
1046 _mesa_is_format_packed_depth_stencil(gl_format format
)
1048 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1050 return info
->BaseFormat
== GL_DEPTH_STENCIL
;
1055 * Is the given format a signed/unsigned integer color format?
1058 _mesa_is_format_integer_color(gl_format format
)
1060 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1061 return (info
->DataType
== GL_INT
|| info
->DataType
== GL_UNSIGNED_INT
) &&
1062 info
->BaseFormat
!= GL_DEPTH_COMPONENT
&&
1063 info
->BaseFormat
!= GL_DEPTH_STENCIL
&&
1064 info
->BaseFormat
!= GL_STENCIL_INDEX
;
1069 * Return color encoding for given format.
1070 * \return GL_LINEAR or GL_SRGB
1073 _mesa_get_format_color_encoding(gl_format format
)
1075 /* XXX this info should be encoded in gl_format_info */
1077 case MESA_FORMAT_SRGB8
:
1078 case MESA_FORMAT_SRGBA8
:
1079 case MESA_FORMAT_SARGB8
:
1080 case MESA_FORMAT_SL8
:
1081 case MESA_FORMAT_SLA8
:
1082 case MESA_FORMAT_SRGB_DXT1
:
1083 case MESA_FORMAT_SRGBA_DXT1
:
1084 case MESA_FORMAT_SRGBA_DXT3
:
1085 case MESA_FORMAT_SRGBA_DXT5
:
1094 * Return number of bytes needed to store an image of the given size
1095 * in the given format.
1098 _mesa_format_image_size(gl_format format
, GLsizei width
,
1099 GLsizei height
, GLsizei depth
)
1101 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1102 /* Strictly speaking, a conditional isn't needed here */
1103 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
1104 /* compressed format (2D only for now) */
1105 const GLuint bw
= info
->BlockWidth
, bh
= info
->BlockHeight
;
1106 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
1107 const GLuint hblocks
= (height
+ bh
- 1) / bh
;
1108 const GLuint sz
= wblocks
* hblocks
* info
->BytesPerBlock
;
1113 /* non-compressed */
1114 const GLuint sz
= width
* height
* depth
* info
->BytesPerBlock
;
1121 * Same as _mesa_format_image_size() but returns a 64-bit value to
1122 * accomodate very large textures.
1125 _mesa_format_image_size64(gl_format format
, GLsizei width
,
1126 GLsizei height
, GLsizei depth
)
1128 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1129 /* Strictly speaking, a conditional isn't needed here */
1130 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
1131 /* compressed format (2D only for now) */
1132 const uint64_t bw
= info
->BlockWidth
, bh
= info
->BlockHeight
;
1133 const uint64_t wblocks
= (width
+ bw
- 1) / bw
;
1134 const uint64_t hblocks
= (height
+ bh
- 1) / bh
;
1135 const uint64_t sz
= wblocks
* hblocks
* info
->BytesPerBlock
;
1140 /* non-compressed */
1141 const uint64_t sz
= ((uint64_t) width
*
1144 info
->BytesPerBlock
);
1152 _mesa_format_row_stride(gl_format format
, GLsizei width
)
1154 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
1155 /* Strictly speaking, a conditional isn't needed here */
1156 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
1157 /* compressed format */
1158 const GLuint bw
= info
->BlockWidth
;
1159 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
1160 const GLint stride
= wblocks
* info
->BytesPerBlock
;
1164 const GLint stride
= width
* info
->BytesPerBlock
;
1172 * Do sanity checking of the format info table.
1175 _mesa_test_formats(void)
1179 assert(Elements(format_info
) == MESA_FORMAT_COUNT
);
1181 for (i
= 0; i
< MESA_FORMAT_COUNT
; i
++) {
1182 const struct gl_format_info
*info
= _mesa_get_format_info(i
);
1185 assert(info
->Name
== i
);
1187 if (info
->Name
== MESA_FORMAT_NONE
)
1190 if (info
->BlockWidth
== 1 && info
->BlockHeight
== 1) {
1191 if (info
->RedBits
> 0) {
1192 GLuint t
= info
->RedBits
+ info
->GreenBits
1193 + info
->BlueBits
+ info
->AlphaBits
;
1194 assert(t
/ 8 == info
->BytesPerBlock
);
1199 assert(info
->DataType
== GL_UNSIGNED_NORMALIZED
||
1200 info
->DataType
== GL_SIGNED_NORMALIZED
||
1201 info
->DataType
== GL_UNSIGNED_INT
||
1202 info
->DataType
== GL_FLOAT
);
1204 if (info
->BaseFormat
== GL_RGB
) {
1205 assert(info
->RedBits
> 0);
1206 assert(info
->GreenBits
> 0);
1207 assert(info
->BlueBits
> 0);
1208 assert(info
->AlphaBits
== 0);
1209 assert(info
->LuminanceBits
== 0);
1210 assert(info
->IntensityBits
== 0);
1212 else if (info
->BaseFormat
== GL_RGBA
) {
1213 assert(info
->RedBits
> 0);
1214 assert(info
->GreenBits
> 0);
1215 assert(info
->BlueBits
> 0);
1216 assert(info
->AlphaBits
> 0);
1217 assert(info
->LuminanceBits
== 0);
1218 assert(info
->IntensityBits
== 0);
1220 else if (info
->BaseFormat
== GL_RG
) {
1221 assert(info
->RedBits
> 0);
1222 assert(info
->GreenBits
> 0);
1223 assert(info
->BlueBits
== 0);
1224 assert(info
->AlphaBits
== 0);
1225 assert(info
->LuminanceBits
== 0);
1226 assert(info
->IntensityBits
== 0);
1228 else if (info
->BaseFormat
== GL_RED
) {
1229 assert(info
->RedBits
> 0);
1230 assert(info
->GreenBits
== 0);
1231 assert(info
->BlueBits
== 0);
1232 assert(info
->AlphaBits
== 0);
1233 assert(info
->LuminanceBits
== 0);
1234 assert(info
->IntensityBits
== 0);
1236 else if (info
->BaseFormat
== GL_LUMINANCE
) {
1237 assert(info
->RedBits
== 0);
1238 assert(info
->GreenBits
== 0);
1239 assert(info
->BlueBits
== 0);
1240 assert(info
->AlphaBits
== 0);
1241 assert(info
->LuminanceBits
> 0);
1242 assert(info
->IntensityBits
== 0);
1244 else if (info
->BaseFormat
== GL_INTENSITY
) {
1245 assert(info
->RedBits
== 0);
1246 assert(info
->GreenBits
== 0);
1247 assert(info
->BlueBits
== 0);
1248 assert(info
->AlphaBits
== 0);
1249 assert(info
->LuminanceBits
== 0);
1250 assert(info
->IntensityBits
> 0);
1259 * Return datatype and number of components per texel for the given gl_format.
1260 * Only used for mipmap generation code.
1263 _mesa_format_to_type_and_comps(gl_format format
,
1264 GLenum
*datatype
, GLuint
*comps
)
1267 case MESA_FORMAT_RGBA8888
:
1268 case MESA_FORMAT_RGBA8888_REV
:
1269 case MESA_FORMAT_ARGB8888
:
1270 case MESA_FORMAT_ARGB8888_REV
:
1271 case MESA_FORMAT_XRGB8888
:
1272 case MESA_FORMAT_XRGB8888_REV
:
1273 *datatype
= GL_UNSIGNED_BYTE
;
1276 case MESA_FORMAT_RGB888
:
1277 case MESA_FORMAT_BGR888
:
1278 *datatype
= GL_UNSIGNED_BYTE
;
1281 case MESA_FORMAT_RGB565
:
1282 case MESA_FORMAT_RGB565_REV
:
1283 *datatype
= GL_UNSIGNED_SHORT_5_6_5
;
1287 case MESA_FORMAT_ARGB4444
:
1288 case MESA_FORMAT_ARGB4444_REV
:
1289 *datatype
= GL_UNSIGNED_SHORT_4_4_4_4
;
1293 case MESA_FORMAT_ARGB1555
:
1294 case MESA_FORMAT_ARGB1555_REV
:
1295 *datatype
= GL_UNSIGNED_SHORT_1_5_5_5_REV
;
1299 case MESA_FORMAT_ARGB2101010
:
1300 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1304 case MESA_FORMAT_RGBA5551
:
1305 *datatype
= GL_UNSIGNED_SHORT_5_5_5_1
;
1309 case MESA_FORMAT_AL44
: /* XXX this isn't plain GL_UNSIGNED_BYTE */
1310 case MESA_FORMAT_AL88
:
1311 case MESA_FORMAT_AL88_REV
:
1312 case MESA_FORMAT_RG88
:
1313 case MESA_FORMAT_RG88_REV
:
1314 *datatype
= GL_UNSIGNED_BYTE
;
1318 case MESA_FORMAT_AL1616
:
1319 case MESA_FORMAT_AL1616_REV
:
1320 case MESA_FORMAT_RG1616
:
1321 case MESA_FORMAT_RG1616_REV
:
1322 *datatype
= GL_UNSIGNED_SHORT
;
1326 case MESA_FORMAT_R16
:
1327 case MESA_FORMAT_A16
:
1328 case MESA_FORMAT_L16
:
1329 case MESA_FORMAT_I16
:
1330 *datatype
= GL_UNSIGNED_SHORT
;
1334 case MESA_FORMAT_RGB332
:
1335 *datatype
= GL_UNSIGNED_BYTE_3_3_2
;
1339 case MESA_FORMAT_A8
:
1340 case MESA_FORMAT_L8
:
1341 case MESA_FORMAT_I8
:
1342 case MESA_FORMAT_CI8
:
1343 case MESA_FORMAT_R8
:
1344 case MESA_FORMAT_S8
:
1345 *datatype
= GL_UNSIGNED_BYTE
;
1349 case MESA_FORMAT_YCBCR
:
1350 case MESA_FORMAT_YCBCR_REV
:
1351 *datatype
= GL_UNSIGNED_SHORT
;
1355 case MESA_FORMAT_Z24_S8
:
1356 *datatype
= GL_UNSIGNED_INT
;
1357 *comps
= 1; /* XXX OK? */
1360 case MESA_FORMAT_S8_Z24
:
1361 *datatype
= GL_UNSIGNED_INT
;
1362 *comps
= 1; /* XXX OK? */
1365 case MESA_FORMAT_Z16
:
1366 *datatype
= GL_UNSIGNED_SHORT
;
1370 case MESA_FORMAT_X8_Z24
:
1371 *datatype
= GL_UNSIGNED_INT
;
1375 case MESA_FORMAT_Z24_X8
:
1376 *datatype
= GL_UNSIGNED_INT
;
1380 case MESA_FORMAT_Z32
:
1381 *datatype
= GL_UNSIGNED_INT
;
1385 case MESA_FORMAT_DUDV8
:
1386 *datatype
= GL_BYTE
;
1390 case MESA_FORMAT_SIGNED_R8
:
1391 *datatype
= GL_BYTE
;
1394 case MESA_FORMAT_SIGNED_RG88
:
1395 *datatype
= GL_BYTE
;
1398 case MESA_FORMAT_SIGNED_RGBA8888
:
1399 case MESA_FORMAT_SIGNED_RGBA8888_REV
:
1400 case MESA_FORMAT_SIGNED_RGBX8888
:
1401 *datatype
= GL_BYTE
;
1405 case MESA_FORMAT_RGBA_16
:
1406 *datatype
= GL_UNSIGNED_SHORT
;
1410 case MESA_FORMAT_SIGNED_R_16
:
1411 *datatype
= GL_SHORT
;
1414 case MESA_FORMAT_SIGNED_RG_16
:
1415 *datatype
= GL_SHORT
;
1418 case MESA_FORMAT_SIGNED_RGB_16
:
1419 *datatype
= GL_SHORT
;
1422 case MESA_FORMAT_SIGNED_RGBA_16
:
1423 *datatype
= GL_SHORT
;
1427 #if FEATURE_EXT_texture_sRGB
1428 case MESA_FORMAT_SRGB8
:
1429 *datatype
= GL_UNSIGNED_BYTE
;
1432 case MESA_FORMAT_SRGBA8
:
1433 case MESA_FORMAT_SARGB8
:
1434 *datatype
= GL_UNSIGNED_BYTE
;
1437 case MESA_FORMAT_SL8
:
1438 *datatype
= GL_UNSIGNED_BYTE
;
1441 case MESA_FORMAT_SLA8
:
1442 *datatype
= GL_UNSIGNED_BYTE
;
1447 #if FEATURE_texture_fxt1
1448 case MESA_FORMAT_RGB_FXT1
:
1449 case MESA_FORMAT_RGBA_FXT1
:
1451 #if FEATURE_texture_s3tc
1452 case MESA_FORMAT_RGB_DXT1
:
1453 case MESA_FORMAT_RGBA_DXT1
:
1454 case MESA_FORMAT_RGBA_DXT3
:
1455 case MESA_FORMAT_RGBA_DXT5
:
1456 #if FEATURE_EXT_texture_sRGB
1457 case MESA_FORMAT_SRGB_DXT1
:
1458 case MESA_FORMAT_SRGBA_DXT1
:
1459 case MESA_FORMAT_SRGBA_DXT3
:
1460 case MESA_FORMAT_SRGBA_DXT5
:
1463 /* XXX generate error instead? */
1464 *datatype
= GL_UNSIGNED_BYTE
;
1468 case MESA_FORMAT_RGBA_FLOAT32
:
1469 *datatype
= GL_FLOAT
;
1472 case MESA_FORMAT_RGBA_FLOAT16
:
1473 *datatype
= GL_HALF_FLOAT_ARB
;
1476 case MESA_FORMAT_RGB_FLOAT32
:
1477 *datatype
= GL_FLOAT
;
1480 case MESA_FORMAT_RGB_FLOAT16
:
1481 *datatype
= GL_HALF_FLOAT_ARB
;
1484 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
:
1485 *datatype
= GL_FLOAT
;
1488 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
:
1489 *datatype
= GL_HALF_FLOAT_ARB
;
1492 case MESA_FORMAT_ALPHA_FLOAT32
:
1493 case MESA_FORMAT_LUMINANCE_FLOAT32
:
1494 case MESA_FORMAT_INTENSITY_FLOAT32
:
1495 *datatype
= GL_FLOAT
;
1498 case MESA_FORMAT_ALPHA_FLOAT16
:
1499 case MESA_FORMAT_LUMINANCE_FLOAT16
:
1500 case MESA_FORMAT_INTENSITY_FLOAT16
:
1501 *datatype
= GL_HALF_FLOAT_ARB
;
1505 case MESA_FORMAT_RGBA_INT8
:
1506 *datatype
= GL_BYTE
;
1509 case MESA_FORMAT_RGBA_INT16
:
1510 *datatype
= GL_SHORT
;
1513 case MESA_FORMAT_RGBA_INT32
:
1519 * \name Non-normalized unsigned integer formats.
1521 case MESA_FORMAT_RGBA_UINT8
:
1522 *datatype
= GL_UNSIGNED_BYTE
;
1525 case MESA_FORMAT_RGBA_UINT16
:
1526 *datatype
= GL_UNSIGNED_SHORT
;
1529 case MESA_FORMAT_RGBA_UINT32
:
1530 *datatype
= GL_UNSIGNED_INT
;
1534 case MESA_FORMAT_NONE
:
1535 case MESA_FORMAT_COUNT
:
1536 /* For debug builds, warn if any formats are not handled */
1540 _mesa_problem(NULL
, "bad format %s in _mesa_format_to_type_and_comps",
1541 _mesa_get_format_name(format
));