2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2008 Brian Paul All Rights Reserved.
5 * Copyright (c) 2008-2009 VMware, Inc.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23 * OTHER DEALINGS IN THE SOFTWARE.
30 #include "glformats.h"
34 * Information about texture formats.
40 /** text name for debugging */
43 enum mesa_format_layout Layout
;
46 * Base format is one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_ALPHA,
47 * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA,
48 * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL.
53 * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALIZED,
54 * GL_UNSIGNED_INT, GL_INT, GL_FLOAT.
62 GLubyte LuminanceBits
;
63 GLubyte IntensityBits
;
68 * To describe compressed formats. If not compressed, Width=Height=1.
70 GLubyte BlockWidth
, BlockHeight
;
71 GLubyte BytesPerBlock
;
76 #include "format_info.c"
78 static const struct gl_format_info
*
79 _mesa_get_format_info(mesa_format format
)
81 const struct gl_format_info
*info
= &format_info
[format
];
82 assert(info
->Name
== format
);
87 /** Return string name of format (for debugging) */
89 _mesa_get_format_name(mesa_format format
)
91 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
98 * Return bytes needed to store a block of pixels in the given format.
99 * Normally, a block is 1x1 (a single pixel). But for compressed formats
100 * a block may be 4x4 or 8x4, etc.
102 * Note: not GLuint, so as not to coerce math to unsigned. cf. fdo #37351
105 _mesa_get_format_bytes(mesa_format format
)
107 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
108 ASSERT(info
->BytesPerBlock
);
109 ASSERT(info
->BytesPerBlock
<= MAX_PIXEL_BYTES
||
110 _mesa_is_format_compressed(format
));
111 return info
->BytesPerBlock
;
116 * Return bits per component for the given format.
117 * \param format one of MESA_FORMAT_x
118 * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc.
121 _mesa_get_format_bits(mesa_format format
, GLenum pname
)
123 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
127 case GL_TEXTURE_RED_SIZE
:
128 case GL_RENDERBUFFER_RED_SIZE_EXT
:
129 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
:
130 return info
->RedBits
;
132 case GL_TEXTURE_GREEN_SIZE
:
133 case GL_RENDERBUFFER_GREEN_SIZE_EXT
:
134 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
:
135 return info
->GreenBits
;
137 case GL_TEXTURE_BLUE_SIZE
:
138 case GL_RENDERBUFFER_BLUE_SIZE_EXT
:
139 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
:
140 return info
->BlueBits
;
142 case GL_TEXTURE_ALPHA_SIZE
:
143 case GL_RENDERBUFFER_ALPHA_SIZE_EXT
:
144 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
:
145 return info
->AlphaBits
;
146 case GL_TEXTURE_INTENSITY_SIZE
:
147 return info
->IntensityBits
;
148 case GL_TEXTURE_LUMINANCE_SIZE
:
149 return info
->LuminanceBits
;
153 case GL_TEXTURE_DEPTH_SIZE_ARB
:
154 case GL_RENDERBUFFER_DEPTH_SIZE_EXT
:
155 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
:
156 return info
->DepthBits
;
157 case GL_STENCIL_BITS
:
158 case GL_TEXTURE_STENCIL_SIZE_EXT
:
159 case GL_RENDERBUFFER_STENCIL_SIZE_EXT
:
160 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
:
161 return info
->StencilBits
;
163 _mesa_problem(NULL
, "bad pname in _mesa_get_format_bits()");
170 _mesa_get_format_max_bits(mesa_format format
)
172 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
173 GLuint max
= MAX2(info
->RedBits
, info
->GreenBits
);
174 max
= MAX2(max
, info
->BlueBits
);
175 max
= MAX2(max
, info
->AlphaBits
);
176 max
= MAX2(max
, info
->LuminanceBits
);
177 max
= MAX2(max
, info
->IntensityBits
);
178 max
= MAX2(max
, info
->DepthBits
);
179 max
= MAX2(max
, info
->StencilBits
);
185 * Return the layout type of the given format.
186 * The return value will be one of:
187 * MESA_FORMAT_LAYOUT_ARRAY
188 * MESA_FORMAT_LAYOUT_PACKED
189 * MESA_FORMAT_LAYOUT_OTHER
191 extern enum mesa_format_layout
192 _mesa_get_format_layout(mesa_format format
)
194 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
200 * Return the data type (or more specifically, the data representation)
201 * for the given format.
202 * The return value will be one of:
203 * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1]
204 * GL_SIGNED_NORMALIZED = signed int representing [-1, 1]
205 * GL_UNSIGNED_INT = an ordinary unsigned integer
206 * GL_INT = an ordinary signed integer
207 * GL_FLOAT = an ordinary float
210 _mesa_get_format_datatype(mesa_format format
)
212 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
213 return info
->DataType
;
218 * Return the basic format for the given type. The result will be one of
219 * GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY,
220 * GL_YCBCR_MESA, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL.
223 _mesa_get_format_base_format(mesa_format format
)
225 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
226 return info
->BaseFormat
;
231 * Return the block size (in pixels) for the given format. Normally
232 * the block size is 1x1. But compressed formats will have block sizes
233 * of 4x4 or 8x4 pixels, etc.
234 * \param bw returns block width in pixels
235 * \param bh returns block height in pixels
238 _mesa_get_format_block_size(mesa_format format
, GLuint
*bw
, GLuint
*bh
)
240 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
241 *bw
= info
->BlockWidth
;
242 *bh
= info
->BlockHeight
;
247 * Returns the an array of four numbers representing the transformation
248 * from the RGBA or SZ colorspace to the given format. For array formats,
249 * the i'th RGBA component is given by:
251 * if (swizzle[i] <= MESA_FORMAT_SWIZZLE_W)
252 * comp = data[swizzle[i]];
253 * else if (swizzle[i] == MESA_FORMAT_SWIZZLE_ZERO)
255 * else if (swizzle[i] == MESA_FORMAT_SWIZZLE_ONE)
257 * else if (swizzle[i] == MESA_FORMAT_SWIZZLE_NONE)
258 * // data does not contain a channel of this format
260 * For packed formats, the swizzle gives the number of components left of
261 * the least significant bit.
263 * Compressed formats have no swizzle.
266 _mesa_get_format_swizzle(mesa_format format
, uint8_t swizzle_out
[4])
268 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
269 memcpy(swizzle_out
, info
->Swizzle
, sizeof(info
->Swizzle
));
273 /** Is the given format a compressed format? */
275 _mesa_is_format_compressed(mesa_format format
)
277 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
278 return info
->BlockWidth
> 1 || info
->BlockHeight
> 1;
283 * Determine if the given format represents a packed depth/stencil buffer.
286 _mesa_is_format_packed_depth_stencil(mesa_format format
)
288 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
290 return info
->BaseFormat
== GL_DEPTH_STENCIL
;
295 * Is the given format a signed/unsigned integer color format?
298 _mesa_is_format_integer_color(mesa_format format
)
300 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
301 return (info
->DataType
== GL_INT
|| info
->DataType
== GL_UNSIGNED_INT
) &&
302 info
->BaseFormat
!= GL_DEPTH_COMPONENT
&&
303 info
->BaseFormat
!= GL_DEPTH_STENCIL
&&
304 info
->BaseFormat
!= GL_STENCIL_INDEX
;
309 * Is the given format an unsigned integer format?
312 _mesa_is_format_unsigned(mesa_format format
)
314 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
315 return _mesa_is_type_unsigned(info
->DataType
);
320 * Does the given format store signed values?
323 _mesa_is_format_signed(mesa_format format
)
325 if (format
== MESA_FORMAT_R11G11B10_FLOAT
||
326 format
== MESA_FORMAT_R9G9B9E5_FLOAT
) {
327 /* these packed float formats only store unsigned values */
331 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
332 return (info
->DataType
== GL_SIGNED_NORMALIZED
||
333 info
->DataType
== GL_INT
||
334 info
->DataType
== GL_FLOAT
);
339 * Is the given format an integer format?
342 _mesa_is_format_integer(mesa_format format
)
344 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
345 return (info
->DataType
== GL_INT
|| info
->DataType
== GL_UNSIGNED_INT
);
349 * Return color encoding for given format.
350 * \return GL_LINEAR or GL_SRGB
353 _mesa_get_format_color_encoding(mesa_format format
)
355 /* XXX this info should be encoded in gl_format_info */
357 case MESA_FORMAT_BGR_SRGB8
:
358 case MESA_FORMAT_A8B8G8R8_SRGB
:
359 case MESA_FORMAT_B8G8R8A8_SRGB
:
360 case MESA_FORMAT_R8G8B8A8_SRGB
:
361 case MESA_FORMAT_L_SRGB8
:
362 case MESA_FORMAT_L8A8_SRGB
:
363 case MESA_FORMAT_SRGB_DXT1
:
364 case MESA_FORMAT_SRGBA_DXT1
:
365 case MESA_FORMAT_SRGBA_DXT3
:
366 case MESA_FORMAT_SRGBA_DXT5
:
367 case MESA_FORMAT_R8G8B8X8_SRGB
:
368 case MESA_FORMAT_ETC2_SRGB8
:
369 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
370 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
371 case MESA_FORMAT_B8G8R8X8_SRGB
:
372 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
381 * Return TRUE if format is an ETC2 compressed format specified
382 * by GL_ARB_ES3_compatibility.
385 _mesa_is_format_etc2(mesa_format format
)
388 case MESA_FORMAT_ETC2_RGB8
:
389 case MESA_FORMAT_ETC2_SRGB8
:
390 case MESA_FORMAT_ETC2_RGBA8_EAC
:
391 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
392 case MESA_FORMAT_ETC2_R11_EAC
:
393 case MESA_FORMAT_ETC2_RG11_EAC
:
394 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
395 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
396 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
397 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
406 * For an sRGB format, return the corresponding linear color space format.
407 * For non-sRGB formats, return the format as-is.
410 _mesa_get_srgb_format_linear(mesa_format format
)
413 case MESA_FORMAT_BGR_SRGB8
:
414 format
= MESA_FORMAT_BGR_UNORM8
;
416 case MESA_FORMAT_A8B8G8R8_SRGB
:
417 format
= MESA_FORMAT_A8B8G8R8_UNORM
;
419 case MESA_FORMAT_B8G8R8A8_SRGB
:
420 format
= MESA_FORMAT_B8G8R8A8_UNORM
;
422 case MESA_FORMAT_R8G8B8A8_SRGB
:
423 format
= MESA_FORMAT_R8G8B8A8_UNORM
;
425 case MESA_FORMAT_L_SRGB8
:
426 format
= MESA_FORMAT_L_UNORM8
;
428 case MESA_FORMAT_L8A8_SRGB
:
429 format
= MESA_FORMAT_L8A8_UNORM
;
431 case MESA_FORMAT_SRGB_DXT1
:
432 format
= MESA_FORMAT_RGB_DXT1
;
434 case MESA_FORMAT_SRGBA_DXT1
:
435 format
= MESA_FORMAT_RGBA_DXT1
;
437 case MESA_FORMAT_SRGBA_DXT3
:
438 format
= MESA_FORMAT_RGBA_DXT3
;
440 case MESA_FORMAT_SRGBA_DXT5
:
441 format
= MESA_FORMAT_RGBA_DXT5
;
443 case MESA_FORMAT_R8G8B8X8_SRGB
:
444 format
= MESA_FORMAT_R8G8B8X8_UNORM
;
446 case MESA_FORMAT_ETC2_SRGB8
:
447 format
= MESA_FORMAT_ETC2_RGB8
;
449 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
450 format
= MESA_FORMAT_ETC2_RGBA8_EAC
;
452 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
453 format
= MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
;
455 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
456 format
= MESA_FORMAT_BPTC_RGBA_UNORM
;
458 case MESA_FORMAT_B8G8R8X8_SRGB
:
459 format
= MESA_FORMAT_B8G8R8X8_UNORM
;
469 * If the given format is a compressed format, return a corresponding
470 * uncompressed format.
473 _mesa_get_uncompressed_format(mesa_format format
)
476 case MESA_FORMAT_RGB_FXT1
:
477 return MESA_FORMAT_BGR_UNORM8
;
478 case MESA_FORMAT_RGBA_FXT1
:
479 return MESA_FORMAT_A8B8G8R8_UNORM
;
480 case MESA_FORMAT_RGB_DXT1
:
481 case MESA_FORMAT_SRGB_DXT1
:
482 return MESA_FORMAT_BGR_UNORM8
;
483 case MESA_FORMAT_RGBA_DXT1
:
484 case MESA_FORMAT_SRGBA_DXT1
:
485 return MESA_FORMAT_A8B8G8R8_UNORM
;
486 case MESA_FORMAT_RGBA_DXT3
:
487 case MESA_FORMAT_SRGBA_DXT3
:
488 return MESA_FORMAT_A8B8G8R8_UNORM
;
489 case MESA_FORMAT_RGBA_DXT5
:
490 case MESA_FORMAT_SRGBA_DXT5
:
491 return MESA_FORMAT_A8B8G8R8_UNORM
;
492 case MESA_FORMAT_R_RGTC1_UNORM
:
493 return MESA_FORMAT_R_UNORM8
;
494 case MESA_FORMAT_R_RGTC1_SNORM
:
495 return MESA_FORMAT_R_SNORM8
;
496 case MESA_FORMAT_RG_RGTC2_UNORM
:
497 return MESA_FORMAT_R8G8_UNORM
;
498 case MESA_FORMAT_RG_RGTC2_SNORM
:
499 return MESA_FORMAT_R8G8_SNORM
;
500 case MESA_FORMAT_L_LATC1_UNORM
:
501 return MESA_FORMAT_L_UNORM8
;
502 case MESA_FORMAT_L_LATC1_SNORM
:
503 return MESA_FORMAT_L_SNORM8
;
504 case MESA_FORMAT_LA_LATC2_UNORM
:
505 return MESA_FORMAT_L8A8_UNORM
;
506 case MESA_FORMAT_LA_LATC2_SNORM
:
507 return MESA_FORMAT_L8A8_SNORM
;
508 case MESA_FORMAT_ETC1_RGB8
:
509 case MESA_FORMAT_ETC2_RGB8
:
510 case MESA_FORMAT_ETC2_SRGB8
:
511 return MESA_FORMAT_BGR_UNORM8
;
512 case MESA_FORMAT_ETC2_RGBA8_EAC
:
513 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
514 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
515 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
516 return MESA_FORMAT_A8B8G8R8_UNORM
;
517 case MESA_FORMAT_ETC2_R11_EAC
:
518 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
519 return MESA_FORMAT_R_UNORM16
;
520 case MESA_FORMAT_ETC2_RG11_EAC
:
521 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
522 return MESA_FORMAT_R16G16_UNORM
;
523 case MESA_FORMAT_BPTC_RGBA_UNORM
:
524 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
525 return MESA_FORMAT_A8B8G8R8_UNORM
;
526 case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
:
527 case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
:
528 return MESA_FORMAT_RGB_FLOAT32
;
531 assert(!_mesa_is_format_compressed(format
));
539 _mesa_format_num_components(mesa_format format
)
541 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
542 return ((info
->RedBits
> 0) +
543 (info
->GreenBits
> 0) +
544 (info
->BlueBits
> 0) +
545 (info
->AlphaBits
> 0) +
546 (info
->LuminanceBits
> 0) +
547 (info
->IntensityBits
> 0) +
548 (info
->DepthBits
> 0) +
549 (info
->StencilBits
> 0));
554 * Returns true if a color format has data stored in the R/G/B/A channels,
555 * given an index from 0 to 3.
558 _mesa_format_has_color_component(mesa_format format
, int component
)
560 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
562 assert(info
->BaseFormat
!= GL_DEPTH_COMPONENT
&&
563 info
->BaseFormat
!= GL_DEPTH_STENCIL
&&
564 info
->BaseFormat
!= GL_STENCIL_INDEX
);
568 return (info
->RedBits
+ info
->IntensityBits
+ info
->LuminanceBits
) > 0;
570 return (info
->GreenBits
+ info
->IntensityBits
+ info
->LuminanceBits
) > 0;
572 return (info
->BlueBits
+ info
->IntensityBits
+ info
->LuminanceBits
) > 0;
574 return (info
->AlphaBits
+ info
->IntensityBits
) > 0;
576 assert(!"Invalid color component: must be 0..3");
583 * Return number of bytes needed to store an image of the given size
584 * in the given format.
587 _mesa_format_image_size(mesa_format format
, GLsizei width
,
588 GLsizei height
, GLsizei depth
)
590 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
591 /* Strictly speaking, a conditional isn't needed here */
592 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
593 /* compressed format (2D only for now) */
594 const GLuint bw
= info
->BlockWidth
, bh
= info
->BlockHeight
;
595 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
596 const GLuint hblocks
= (height
+ bh
- 1) / bh
;
597 const GLuint sz
= wblocks
* hblocks
* info
->BytesPerBlock
;
602 const GLuint sz
= width
* height
* depth
* info
->BytesPerBlock
;
609 * Same as _mesa_format_image_size() but returns a 64-bit value to
610 * accomodate very large textures.
613 _mesa_format_image_size64(mesa_format format
, GLsizei width
,
614 GLsizei height
, GLsizei depth
)
616 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
617 /* Strictly speaking, a conditional isn't needed here */
618 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
619 /* compressed format (2D only for now) */
620 const uint64_t bw
= info
->BlockWidth
, bh
= info
->BlockHeight
;
621 const uint64_t wblocks
= (width
+ bw
- 1) / bw
;
622 const uint64_t hblocks
= (height
+ bh
- 1) / bh
;
623 const uint64_t sz
= wblocks
* hblocks
* info
->BytesPerBlock
;
628 const uint64_t sz
= ((uint64_t) width
*
631 info
->BytesPerBlock
);
639 _mesa_format_row_stride(mesa_format format
, GLsizei width
)
641 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
642 /* Strictly speaking, a conditional isn't needed here */
643 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
644 /* compressed format */
645 const GLuint bw
= info
->BlockWidth
;
646 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
647 const GLint stride
= wblocks
* info
->BytesPerBlock
;
651 const GLint stride
= width
* info
->BytesPerBlock
;
658 * Debug/test: check that all formats are handled in the
659 * _mesa_format_to_type_and_comps() function. When new pixel formats
660 * are added to Mesa, that function needs to be updated.
661 * This is a no-op after the first call.
664 check_format_to_type_and_comps(void)
668 for (f
= MESA_FORMAT_NONE
+ 1; f
< MESA_FORMAT_COUNT
; f
++) {
671 /* This function will emit a problem/warning if the format is
674 _mesa_format_to_type_and_comps(f
, &datatype
, &comps
);
679 * Do sanity checking of the format info table.
682 _mesa_test_formats(void)
686 STATIC_ASSERT(Elements(format_info
) == MESA_FORMAT_COUNT
);
688 for (i
= 0; i
< MESA_FORMAT_COUNT
; i
++) {
689 const struct gl_format_info
*info
= _mesa_get_format_info(i
);
692 assert(info
->Name
== i
);
694 if (info
->Name
== MESA_FORMAT_NONE
)
697 if (info
->BlockWidth
== 1 && info
->BlockHeight
== 1) {
698 if (info
->RedBits
> 0) {
699 GLuint t
= info
->RedBits
+ info
->GreenBits
700 + info
->BlueBits
+ info
->AlphaBits
;
701 assert(t
/ 8 <= info
->BytesPerBlock
);
706 assert(info
->DataType
== GL_UNSIGNED_NORMALIZED
||
707 info
->DataType
== GL_SIGNED_NORMALIZED
||
708 info
->DataType
== GL_UNSIGNED_INT
||
709 info
->DataType
== GL_INT
||
710 info
->DataType
== GL_FLOAT
||
711 /* Z32_FLOAT_X24S8 has DataType of GL_NONE */
712 info
->DataType
== GL_NONE
);
714 if (info
->BaseFormat
== GL_RGB
) {
715 assert(info
->RedBits
> 0);
716 assert(info
->GreenBits
> 0);
717 assert(info
->BlueBits
> 0);
718 assert(info
->AlphaBits
== 0);
719 assert(info
->LuminanceBits
== 0);
720 assert(info
->IntensityBits
== 0);
722 else if (info
->BaseFormat
== GL_RGBA
) {
723 assert(info
->RedBits
> 0);
724 assert(info
->GreenBits
> 0);
725 assert(info
->BlueBits
> 0);
726 assert(info
->AlphaBits
> 0);
727 assert(info
->LuminanceBits
== 0);
728 assert(info
->IntensityBits
== 0);
730 else if (info
->BaseFormat
== GL_RG
) {
731 assert(info
->RedBits
> 0);
732 assert(info
->GreenBits
> 0);
733 assert(info
->BlueBits
== 0);
734 assert(info
->AlphaBits
== 0);
735 assert(info
->LuminanceBits
== 0);
736 assert(info
->IntensityBits
== 0);
738 else if (info
->BaseFormat
== GL_RED
) {
739 assert(info
->RedBits
> 0);
740 assert(info
->GreenBits
== 0);
741 assert(info
->BlueBits
== 0);
742 assert(info
->AlphaBits
== 0);
743 assert(info
->LuminanceBits
== 0);
744 assert(info
->IntensityBits
== 0);
746 else if (info
->BaseFormat
== GL_LUMINANCE
) {
747 assert(info
->RedBits
== 0);
748 assert(info
->GreenBits
== 0);
749 assert(info
->BlueBits
== 0);
750 assert(info
->AlphaBits
== 0);
751 assert(info
->LuminanceBits
> 0);
752 assert(info
->IntensityBits
== 0);
754 else if (info
->BaseFormat
== GL_INTENSITY
) {
755 assert(info
->RedBits
== 0);
756 assert(info
->GreenBits
== 0);
757 assert(info
->BlueBits
== 0);
758 assert(info
->AlphaBits
== 0);
759 assert(info
->LuminanceBits
== 0);
760 assert(info
->IntensityBits
> 0);
764 check_format_to_type_and_comps();
770 * Return datatype and number of components per texel for the given mesa_format.
771 * Only used for mipmap generation code.
774 _mesa_format_to_type_and_comps(mesa_format format
,
775 GLenum
*datatype
, GLuint
*comps
)
778 case MESA_FORMAT_A8B8G8R8_UNORM
:
779 case MESA_FORMAT_R8G8B8A8_UNORM
:
780 case MESA_FORMAT_B8G8R8A8_UNORM
:
781 case MESA_FORMAT_A8R8G8B8_UNORM
:
782 case MESA_FORMAT_X8B8G8R8_UNORM
:
783 case MESA_FORMAT_R8G8B8X8_UNORM
:
784 case MESA_FORMAT_B8G8R8X8_UNORM
:
785 case MESA_FORMAT_X8R8G8B8_UNORM
:
786 *datatype
= GL_UNSIGNED_BYTE
;
789 case MESA_FORMAT_BGR_UNORM8
:
790 case MESA_FORMAT_RGB_UNORM8
:
791 *datatype
= GL_UNSIGNED_BYTE
;
794 case MESA_FORMAT_B5G6R5_UNORM
:
795 case MESA_FORMAT_R5G6B5_UNORM
:
796 *datatype
= GL_UNSIGNED_SHORT_5_6_5
;
800 case MESA_FORMAT_B4G4R4A4_UNORM
:
801 case MESA_FORMAT_A4R4G4B4_UNORM
:
802 case MESA_FORMAT_B4G4R4X4_UNORM
:
803 *datatype
= GL_UNSIGNED_SHORT_4_4_4_4
;
807 case MESA_FORMAT_B5G5R5A1_UNORM
:
808 case MESA_FORMAT_A1R5G5B5_UNORM
:
809 case MESA_FORMAT_B5G5R5X1_UNORM
:
810 *datatype
= GL_UNSIGNED_SHORT_1_5_5_5_REV
;
814 case MESA_FORMAT_B10G10R10A2_UNORM
:
815 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
819 case MESA_FORMAT_A1B5G5R5_UNORM
:
820 *datatype
= GL_UNSIGNED_SHORT_5_5_5_1
;
824 case MESA_FORMAT_L4A4_UNORM
:
825 *datatype
= MESA_UNSIGNED_BYTE_4_4
;
829 case MESA_FORMAT_L8A8_UNORM
:
830 case MESA_FORMAT_A8L8_UNORM
:
831 case MESA_FORMAT_R8G8_UNORM
:
832 case MESA_FORMAT_G8R8_UNORM
:
833 *datatype
= GL_UNSIGNED_BYTE
;
837 case MESA_FORMAT_L16A16_UNORM
:
838 case MESA_FORMAT_A16L16_UNORM
:
839 case MESA_FORMAT_R16G16_UNORM
:
840 case MESA_FORMAT_G16R16_UNORM
:
841 *datatype
= GL_UNSIGNED_SHORT
;
845 case MESA_FORMAT_R_UNORM16
:
846 case MESA_FORMAT_A_UNORM16
:
847 case MESA_FORMAT_L_UNORM16
:
848 case MESA_FORMAT_I_UNORM16
:
849 *datatype
= GL_UNSIGNED_SHORT
;
853 case MESA_FORMAT_B2G3R3_UNORM
:
854 *datatype
= GL_UNSIGNED_BYTE_3_3_2
;
858 case MESA_FORMAT_A_UNORM8
:
859 case MESA_FORMAT_L_UNORM8
:
860 case MESA_FORMAT_I_UNORM8
:
861 case MESA_FORMAT_R_UNORM8
:
862 case MESA_FORMAT_S_UINT8
:
863 *datatype
= GL_UNSIGNED_BYTE
;
867 case MESA_FORMAT_YCBCR
:
868 case MESA_FORMAT_YCBCR_REV
:
869 *datatype
= GL_UNSIGNED_SHORT
;
873 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
874 *datatype
= GL_UNSIGNED_INT_24_8_MESA
;
878 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
879 *datatype
= GL_UNSIGNED_INT_8_24_REV_MESA
;
883 case MESA_FORMAT_Z_UNORM16
:
884 *datatype
= GL_UNSIGNED_SHORT
;
888 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
889 *datatype
= GL_UNSIGNED_INT
;
893 case MESA_FORMAT_X8_UINT_Z24_UNORM
:
894 *datatype
= GL_UNSIGNED_INT
;
898 case MESA_FORMAT_Z_UNORM32
:
899 *datatype
= GL_UNSIGNED_INT
;
903 case MESA_FORMAT_Z_FLOAT32
:
904 *datatype
= GL_FLOAT
;
908 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
909 *datatype
= GL_FLOAT_32_UNSIGNED_INT_24_8_REV
;
913 case MESA_FORMAT_R_SNORM8
:
914 case MESA_FORMAT_A_SNORM8
:
915 case MESA_FORMAT_L_SNORM8
:
916 case MESA_FORMAT_I_SNORM8
:
920 case MESA_FORMAT_R8G8_SNORM
:
921 case MESA_FORMAT_L8A8_SNORM
:
925 case MESA_FORMAT_A8B8G8R8_SNORM
:
926 case MESA_FORMAT_R8G8B8A8_SNORM
:
927 case MESA_FORMAT_X8B8G8R8_SNORM
:
932 case MESA_FORMAT_RGBA_UNORM16
:
933 *datatype
= GL_UNSIGNED_SHORT
;
937 case MESA_FORMAT_R_SNORM16
:
938 case MESA_FORMAT_A_SNORM16
:
939 case MESA_FORMAT_L_SNORM16
:
940 case MESA_FORMAT_I_SNORM16
:
941 *datatype
= GL_SHORT
;
944 case MESA_FORMAT_R16G16_SNORM
:
945 case MESA_FORMAT_LA_SNORM16
:
946 *datatype
= GL_SHORT
;
949 case MESA_FORMAT_RGB_SNORM16
:
950 *datatype
= GL_SHORT
;
953 case MESA_FORMAT_RGBA_SNORM16
:
954 *datatype
= GL_SHORT
;
958 case MESA_FORMAT_BGR_SRGB8
:
959 *datatype
= GL_UNSIGNED_BYTE
;
962 case MESA_FORMAT_A8B8G8R8_SRGB
:
963 case MESA_FORMAT_B8G8R8A8_SRGB
:
964 case MESA_FORMAT_R8G8B8A8_SRGB
:
965 *datatype
= GL_UNSIGNED_BYTE
;
968 case MESA_FORMAT_L_SRGB8
:
969 *datatype
= GL_UNSIGNED_BYTE
;
972 case MESA_FORMAT_L8A8_SRGB
:
973 *datatype
= GL_UNSIGNED_BYTE
;
977 case MESA_FORMAT_RGB_FXT1
:
978 case MESA_FORMAT_RGBA_FXT1
:
979 case MESA_FORMAT_RGB_DXT1
:
980 case MESA_FORMAT_RGBA_DXT1
:
981 case MESA_FORMAT_RGBA_DXT3
:
982 case MESA_FORMAT_RGBA_DXT5
:
983 case MESA_FORMAT_SRGB_DXT1
:
984 case MESA_FORMAT_SRGBA_DXT1
:
985 case MESA_FORMAT_SRGBA_DXT3
:
986 case MESA_FORMAT_SRGBA_DXT5
:
987 case MESA_FORMAT_R_RGTC1_UNORM
:
988 case MESA_FORMAT_R_RGTC1_SNORM
:
989 case MESA_FORMAT_RG_RGTC2_UNORM
:
990 case MESA_FORMAT_RG_RGTC2_SNORM
:
991 case MESA_FORMAT_L_LATC1_UNORM
:
992 case MESA_FORMAT_L_LATC1_SNORM
:
993 case MESA_FORMAT_LA_LATC2_UNORM
:
994 case MESA_FORMAT_LA_LATC2_SNORM
:
995 case MESA_FORMAT_ETC1_RGB8
:
996 case MESA_FORMAT_ETC2_RGB8
:
997 case MESA_FORMAT_ETC2_SRGB8
:
998 case MESA_FORMAT_ETC2_RGBA8_EAC
:
999 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
1000 case MESA_FORMAT_ETC2_R11_EAC
:
1001 case MESA_FORMAT_ETC2_RG11_EAC
:
1002 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
1003 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
1004 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
1005 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
1006 case MESA_FORMAT_BPTC_RGBA_UNORM
:
1007 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
1008 case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
:
1009 case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
:
1010 /* XXX generate error instead? */
1011 *datatype
= GL_UNSIGNED_BYTE
;
1015 case MESA_FORMAT_RGBA_FLOAT32
:
1016 *datatype
= GL_FLOAT
;
1019 case MESA_FORMAT_RGBA_FLOAT16
:
1020 *datatype
= GL_HALF_FLOAT_ARB
;
1023 case MESA_FORMAT_RGB_FLOAT32
:
1024 *datatype
= GL_FLOAT
;
1027 case MESA_FORMAT_RGB_FLOAT16
:
1028 *datatype
= GL_HALF_FLOAT_ARB
;
1031 case MESA_FORMAT_LA_FLOAT32
:
1032 case MESA_FORMAT_RG_FLOAT32
:
1033 *datatype
= GL_FLOAT
;
1036 case MESA_FORMAT_LA_FLOAT16
:
1037 case MESA_FORMAT_RG_FLOAT16
:
1038 *datatype
= GL_HALF_FLOAT_ARB
;
1041 case MESA_FORMAT_A_FLOAT32
:
1042 case MESA_FORMAT_L_FLOAT32
:
1043 case MESA_FORMAT_I_FLOAT32
:
1044 case MESA_FORMAT_R_FLOAT32
:
1045 *datatype
= GL_FLOAT
;
1048 case MESA_FORMAT_A_FLOAT16
:
1049 case MESA_FORMAT_L_FLOAT16
:
1050 case MESA_FORMAT_I_FLOAT16
:
1051 case MESA_FORMAT_R_FLOAT16
:
1052 *datatype
= GL_HALF_FLOAT_ARB
;
1056 case MESA_FORMAT_A_UINT8
:
1057 case MESA_FORMAT_L_UINT8
:
1058 case MESA_FORMAT_I_UINT8
:
1059 *datatype
= GL_UNSIGNED_BYTE
;
1062 case MESA_FORMAT_LA_UINT8
:
1063 *datatype
= GL_UNSIGNED_BYTE
;
1067 case MESA_FORMAT_A_UINT16
:
1068 case MESA_FORMAT_L_UINT16
:
1069 case MESA_FORMAT_I_UINT16
:
1070 *datatype
= GL_UNSIGNED_SHORT
;
1073 case MESA_FORMAT_LA_UINT16
:
1074 *datatype
= GL_UNSIGNED_SHORT
;
1077 case MESA_FORMAT_A_UINT32
:
1078 case MESA_FORMAT_L_UINT32
:
1079 case MESA_FORMAT_I_UINT32
:
1080 *datatype
= GL_UNSIGNED_INT
;
1083 case MESA_FORMAT_LA_UINT32
:
1084 *datatype
= GL_UNSIGNED_INT
;
1087 case MESA_FORMAT_A_SINT8
:
1088 case MESA_FORMAT_L_SINT8
:
1089 case MESA_FORMAT_I_SINT8
:
1090 *datatype
= GL_BYTE
;
1093 case MESA_FORMAT_LA_SINT8
:
1094 *datatype
= GL_BYTE
;
1098 case MESA_FORMAT_A_SINT16
:
1099 case MESA_FORMAT_L_SINT16
:
1100 case MESA_FORMAT_I_SINT16
:
1101 *datatype
= GL_SHORT
;
1104 case MESA_FORMAT_LA_SINT16
:
1105 *datatype
= GL_SHORT
;
1109 case MESA_FORMAT_A_SINT32
:
1110 case MESA_FORMAT_L_SINT32
:
1111 case MESA_FORMAT_I_SINT32
:
1115 case MESA_FORMAT_LA_SINT32
:
1120 case MESA_FORMAT_R_SINT8
:
1121 *datatype
= GL_BYTE
;
1124 case MESA_FORMAT_RG_SINT8
:
1125 *datatype
= GL_BYTE
;
1128 case MESA_FORMAT_RGB_SINT8
:
1129 *datatype
= GL_BYTE
;
1132 case MESA_FORMAT_RGBA_SINT8
:
1133 *datatype
= GL_BYTE
;
1136 case MESA_FORMAT_R_SINT16
:
1137 *datatype
= GL_SHORT
;
1140 case MESA_FORMAT_RG_SINT16
:
1141 *datatype
= GL_SHORT
;
1144 case MESA_FORMAT_RGB_SINT16
:
1145 *datatype
= GL_SHORT
;
1148 case MESA_FORMAT_RGBA_SINT16
:
1149 *datatype
= GL_SHORT
;
1152 case MESA_FORMAT_R_SINT32
:
1156 case MESA_FORMAT_RG_SINT32
:
1160 case MESA_FORMAT_RGB_SINT32
:
1164 case MESA_FORMAT_RGBA_SINT32
:
1170 * \name Non-normalized unsigned integer formats.
1172 case MESA_FORMAT_R_UINT8
:
1173 *datatype
= GL_UNSIGNED_BYTE
;
1176 case MESA_FORMAT_RG_UINT8
:
1177 *datatype
= GL_UNSIGNED_BYTE
;
1180 case MESA_FORMAT_RGB_UINT8
:
1181 *datatype
= GL_UNSIGNED_BYTE
;
1184 case MESA_FORMAT_RGBA_UINT8
:
1185 *datatype
= GL_UNSIGNED_BYTE
;
1188 case MESA_FORMAT_R_UINT16
:
1189 *datatype
= GL_UNSIGNED_SHORT
;
1192 case MESA_FORMAT_RG_UINT16
:
1193 *datatype
= GL_UNSIGNED_SHORT
;
1196 case MESA_FORMAT_RGB_UINT16
:
1197 *datatype
= GL_UNSIGNED_SHORT
;
1200 case MESA_FORMAT_RGBA_UINT16
:
1201 *datatype
= GL_UNSIGNED_SHORT
;
1204 case MESA_FORMAT_R_UINT32
:
1205 *datatype
= GL_UNSIGNED_INT
;
1208 case MESA_FORMAT_RG_UINT32
:
1209 *datatype
= GL_UNSIGNED_INT
;
1212 case MESA_FORMAT_RGB_UINT32
:
1213 *datatype
= GL_UNSIGNED_INT
;
1216 case MESA_FORMAT_RGBA_UINT32
:
1217 *datatype
= GL_UNSIGNED_INT
;
1221 case MESA_FORMAT_R9G9B9E5_FLOAT
:
1222 *datatype
= GL_UNSIGNED_INT_5_9_9_9_REV
;
1226 case MESA_FORMAT_R11G11B10_FLOAT
:
1227 *datatype
= GL_UNSIGNED_INT_10F_11F_11F_REV
;
1231 case MESA_FORMAT_B10G10R10A2_UINT
:
1232 case MESA_FORMAT_R10G10B10A2_UINT
:
1233 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1237 case MESA_FORMAT_R8G8B8X8_SRGB
:
1238 case MESA_FORMAT_RGBX_UINT8
:
1239 *datatype
= GL_UNSIGNED_BYTE
;
1243 case MESA_FORMAT_R8G8B8X8_SNORM
:
1244 case MESA_FORMAT_RGBX_SINT8
:
1245 *datatype
= GL_BYTE
;
1249 case MESA_FORMAT_B10G10R10X2_UNORM
:
1250 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1254 case MESA_FORMAT_RGBX_UNORM16
:
1255 case MESA_FORMAT_RGBX_UINT16
:
1256 *datatype
= GL_UNSIGNED_SHORT
;
1260 case MESA_FORMAT_RGBX_SNORM16
:
1261 case MESA_FORMAT_RGBX_SINT16
:
1262 *datatype
= GL_SHORT
;
1266 case MESA_FORMAT_RGBX_FLOAT16
:
1267 *datatype
= GL_HALF_FLOAT
;
1271 case MESA_FORMAT_RGBX_FLOAT32
:
1272 *datatype
= GL_FLOAT
;
1276 case MESA_FORMAT_RGBX_UINT32
:
1277 *datatype
= GL_UNSIGNED_INT
;
1281 case MESA_FORMAT_RGBX_SINT32
:
1286 case MESA_FORMAT_R10G10B10A2_UNORM
:
1287 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1291 case MESA_FORMAT_G8R8_SNORM
:
1292 *datatype
= GL_BYTE
;
1296 case MESA_FORMAT_G16R16_SNORM
:
1297 *datatype
= GL_SHORT
;
1301 case MESA_FORMAT_B8G8R8X8_SRGB
:
1302 *datatype
= GL_UNSIGNED_BYTE
;
1306 case MESA_FORMAT_COUNT
:
1310 case MESA_FORMAT_NONE
:
1311 /* For debug builds, warn if any formats are not handled */
1315 _mesa_problem(NULL
, "bad format %s in _mesa_format_to_type_and_comps",
1316 _mesa_get_format_name(format
));
1323 * Check if a mesa_format exactly matches a GL format/type combination
1324 * such that we can use memcpy() from one to the other.
1325 * \param mesa_format a MESA_FORMAT_x value
1326 * \param format the user-specified image format
1327 * \param type the user-specified image datatype
1328 * \param swapBytes typically the current pixel pack/unpack byteswap state
1329 * \return GL_TRUE if the formats match, GL_FALSE otherwise.
1332 _mesa_format_matches_format_and_type(mesa_format mesa_format
,
1333 GLenum format
, GLenum type
,
1334 GLboolean swapBytes
)
1336 const GLboolean littleEndian
= _mesa_little_endian();
1338 /* Note: When reading a GL format/type combination, the format lists channel
1339 * assignments from most significant channel in the type to least
1340 * significant. A type with _REV indicates that the assignments are
1341 * swapped, so they are listed from least significant to most significant.
1343 * For sanity, please keep this switch statement ordered the same as the
1344 * enums in formats.h.
1347 switch (mesa_format
) {
1349 case MESA_FORMAT_NONE
:
1350 case MESA_FORMAT_COUNT
:
1353 case MESA_FORMAT_A8B8G8R8_UNORM
:
1354 case MESA_FORMAT_A8B8G8R8_SRGB
:
1355 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& !swapBytes
)
1358 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&& swapBytes
)
1361 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_BYTE
&& !littleEndian
)
1364 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
1368 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8
1372 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
)
1377 case MESA_FORMAT_R8G8B8A8_UNORM
:
1378 case MESA_FORMAT_R8G8B8A8_SRGB
:
1379 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1383 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& swapBytes
)
1386 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
)
1389 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8
&&
1393 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1397 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_BYTE
&& !littleEndian
)
1402 case MESA_FORMAT_B8G8R8A8_UNORM
:
1403 case MESA_FORMAT_B8G8R8A8_SRGB
:
1404 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1408 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& swapBytes
)
1411 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
)
1416 case MESA_FORMAT_A8R8G8B8_UNORM
:
1417 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& !swapBytes
)
1420 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1424 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_BYTE
&& !littleEndian
)
1429 case MESA_FORMAT_X8B8G8R8_UNORM
:
1430 case MESA_FORMAT_R8G8B8X8_UNORM
:
1433 case MESA_FORMAT_B8G8R8X8_UNORM
:
1434 case MESA_FORMAT_X8R8G8B8_UNORM
:
1437 case MESA_FORMAT_BGR_UNORM8
:
1438 case MESA_FORMAT_BGR_SRGB8
:
1439 return format
== GL_BGR
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1441 case MESA_FORMAT_RGB_UNORM8
:
1442 return format
== GL_RGB
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1444 case MESA_FORMAT_B5G6R5_UNORM
:
1445 return format
== GL_RGB
&& type
== GL_UNSIGNED_SHORT_5_6_5
&& !swapBytes
;
1447 case MESA_FORMAT_R5G6B5_UNORM
:
1448 /* Some of the 16-bit MESA_FORMATs that would seem to correspond to
1449 * GL_UNSIGNED_SHORT_* are byte-swapped instead of channel-reversed,
1450 * according to formats.h, so they can't be matched.
1454 case MESA_FORMAT_B4G4R4A4_UNORM
:
1455 return format
== GL_BGRA
&& type
== GL_UNSIGNED_SHORT_4_4_4_4_REV
&&
1458 case MESA_FORMAT_A4R4G4B4_UNORM
:
1461 case MESA_FORMAT_A1B5G5R5_UNORM
:
1462 return format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT_5_5_5_1
&&
1465 case MESA_FORMAT_B5G5R5A1_UNORM
:
1466 return format
== GL_BGRA
&& type
== GL_UNSIGNED_SHORT_1_5_5_5_REV
&&
1469 case MESA_FORMAT_A1R5G5B5_UNORM
:
1472 case MESA_FORMAT_L4A4_UNORM
:
1474 case MESA_FORMAT_L8A8_UNORM
:
1475 case MESA_FORMAT_L8A8_SRGB
:
1476 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1477 case MESA_FORMAT_A8L8_UNORM
:
1480 case MESA_FORMAT_L16A16_UNORM
:
1481 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_UNSIGNED_SHORT
&& littleEndian
&& !swapBytes
;
1482 case MESA_FORMAT_A16L16_UNORM
:
1485 case MESA_FORMAT_B2G3R3_UNORM
:
1486 return format
== GL_RGB
&& type
== GL_UNSIGNED_BYTE_3_3_2
;
1488 case MESA_FORMAT_A_UNORM8
:
1489 return format
== GL_ALPHA
&& type
== GL_UNSIGNED_BYTE
;
1490 case MESA_FORMAT_A_UNORM16
:
1491 return format
== GL_ALPHA
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1492 case MESA_FORMAT_L_UNORM8
:
1493 case MESA_FORMAT_L_SRGB8
:
1494 return format
== GL_LUMINANCE
&& type
== GL_UNSIGNED_BYTE
;
1495 case MESA_FORMAT_L_UNORM16
:
1496 return format
== GL_LUMINANCE
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1497 case MESA_FORMAT_I_UNORM8
:
1498 return format
== GL_RED
&& type
== GL_UNSIGNED_BYTE
;
1499 case MESA_FORMAT_I_UNORM16
:
1500 return format
== GL_RED
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1502 case MESA_FORMAT_YCBCR
:
1503 return format
== GL_YCBCR_MESA
&&
1504 ((type
== GL_UNSIGNED_SHORT_8_8_MESA
&& littleEndian
!= swapBytes
) ||
1505 (type
== GL_UNSIGNED_SHORT_8_8_REV_MESA
&& littleEndian
== swapBytes
));
1506 case MESA_FORMAT_YCBCR_REV
:
1507 return format
== GL_YCBCR_MESA
&&
1508 ((type
== GL_UNSIGNED_SHORT_8_8_MESA
&& littleEndian
== swapBytes
) ||
1509 (type
== GL_UNSIGNED_SHORT_8_8_REV_MESA
&& littleEndian
!= swapBytes
));
1511 case MESA_FORMAT_R_UNORM8
:
1512 return format
== GL_RED
&& type
== GL_UNSIGNED_BYTE
;
1513 case MESA_FORMAT_R8G8_UNORM
:
1514 return format
== GL_RG
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1515 case MESA_FORMAT_G8R8_UNORM
:
1518 case MESA_FORMAT_R_UNORM16
:
1519 return format
== GL_RED
&& type
== GL_UNSIGNED_SHORT
&&
1521 case MESA_FORMAT_R16G16_UNORM
:
1522 return format
== GL_RG
&& type
== GL_UNSIGNED_SHORT
&& littleEndian
&&
1524 case MESA_FORMAT_G16R16_UNORM
:
1527 case MESA_FORMAT_B10G10R10A2_UNORM
:
1528 return format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1531 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
1532 return format
== GL_DEPTH_STENCIL
&& type
== GL_UNSIGNED_INT_24_8
&&
1534 case MESA_FORMAT_X8_UINT_Z24_UNORM
:
1535 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
1538 case MESA_FORMAT_Z_UNORM16
:
1539 return format
== GL_DEPTH_COMPONENT
&& type
== GL_UNSIGNED_SHORT
&&
1542 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
1545 case MESA_FORMAT_Z_UNORM32
:
1546 return format
== GL_DEPTH_COMPONENT
&& type
== GL_UNSIGNED_INT
&&
1549 case MESA_FORMAT_S_UINT8
:
1550 return format
== GL_STENCIL_INDEX
&& type
== GL_UNSIGNED_BYTE
;
1552 case MESA_FORMAT_SRGB_DXT1
:
1553 case MESA_FORMAT_SRGBA_DXT1
:
1554 case MESA_FORMAT_SRGBA_DXT3
:
1555 case MESA_FORMAT_SRGBA_DXT5
:
1558 case MESA_FORMAT_RGB_FXT1
:
1559 case MESA_FORMAT_RGBA_FXT1
:
1560 case MESA_FORMAT_RGB_DXT1
:
1561 case MESA_FORMAT_RGBA_DXT1
:
1562 case MESA_FORMAT_RGBA_DXT3
:
1563 case MESA_FORMAT_RGBA_DXT5
:
1566 case MESA_FORMAT_BPTC_RGBA_UNORM
:
1567 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
1568 case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
:
1569 case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
:
1572 case MESA_FORMAT_RGBA_FLOAT32
:
1573 return format
== GL_RGBA
&& type
== GL_FLOAT
&& !swapBytes
;
1574 case MESA_FORMAT_RGBA_FLOAT16
:
1575 return format
== GL_RGBA
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1577 case MESA_FORMAT_RGB_FLOAT32
:
1578 return format
== GL_RGB
&& type
== GL_FLOAT
&& !swapBytes
;
1579 case MESA_FORMAT_RGB_FLOAT16
:
1580 return format
== GL_RGB
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1582 case MESA_FORMAT_A_FLOAT32
:
1583 return format
== GL_ALPHA
&& type
== GL_FLOAT
&& !swapBytes
;
1584 case MESA_FORMAT_A_FLOAT16
:
1585 return format
== GL_ALPHA
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1587 case MESA_FORMAT_L_FLOAT32
:
1588 return format
== GL_LUMINANCE
&& type
== GL_FLOAT
&& !swapBytes
;
1589 case MESA_FORMAT_L_FLOAT16
:
1590 return format
== GL_LUMINANCE
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1592 case MESA_FORMAT_LA_FLOAT32
:
1593 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_FLOAT
&& !swapBytes
;
1594 case MESA_FORMAT_LA_FLOAT16
:
1595 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1597 case MESA_FORMAT_I_FLOAT32
:
1598 return format
== GL_RED
&& type
== GL_FLOAT
&& !swapBytes
;
1599 case MESA_FORMAT_I_FLOAT16
:
1600 return format
== GL_RED
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1602 case MESA_FORMAT_R_FLOAT32
:
1603 return format
== GL_RED
&& type
== GL_FLOAT
&& !swapBytes
;
1604 case MESA_FORMAT_R_FLOAT16
:
1605 return format
== GL_RED
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1607 case MESA_FORMAT_RG_FLOAT32
:
1608 return format
== GL_RG
&& type
== GL_FLOAT
&& !swapBytes
;
1609 case MESA_FORMAT_RG_FLOAT16
:
1610 return format
== GL_RG
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1612 case MESA_FORMAT_A_UINT8
:
1613 return format
== GL_ALPHA_INTEGER
&& type
== GL_UNSIGNED_BYTE
;
1614 case MESA_FORMAT_A_UINT16
:
1615 return format
== GL_ALPHA_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1617 case MESA_FORMAT_A_UINT32
:
1618 return format
== GL_ALPHA_INTEGER
&& type
== GL_UNSIGNED_INT
&&
1620 case MESA_FORMAT_A_SINT8
:
1621 return format
== GL_ALPHA_INTEGER
&& type
== GL_BYTE
;
1622 case MESA_FORMAT_A_SINT16
:
1623 return format
== GL_ALPHA_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1624 case MESA_FORMAT_A_SINT32
:
1625 return format
== GL_ALPHA_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1627 case MESA_FORMAT_I_UINT8
:
1628 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_BYTE
;
1629 case MESA_FORMAT_I_UINT16
:
1630 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1631 case MESA_FORMAT_I_UINT32
:
1632 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1633 case MESA_FORMAT_I_SINT8
:
1634 return format
== GL_RED_INTEGER
&& type
== GL_BYTE
;
1635 case MESA_FORMAT_I_SINT16
:
1636 return format
== GL_RED_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1637 case MESA_FORMAT_I_SINT32
:
1638 return format
== GL_RED_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1640 case MESA_FORMAT_L_UINT8
:
1641 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_UNSIGNED_BYTE
;
1642 case MESA_FORMAT_L_UINT16
:
1643 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_UNSIGNED_SHORT
&&
1645 case MESA_FORMAT_L_UINT32
:
1646 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_UNSIGNED_INT
&&
1648 case MESA_FORMAT_L_SINT8
:
1649 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_BYTE
;
1650 case MESA_FORMAT_L_SINT16
:
1651 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_SHORT
&&
1653 case MESA_FORMAT_L_SINT32
:
1654 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_INT
&& !swapBytes
;
1656 case MESA_FORMAT_LA_UINT8
:
1657 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&&
1658 type
== GL_UNSIGNED_BYTE
&& !swapBytes
;
1659 case MESA_FORMAT_LA_UINT16
:
1660 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&&
1661 type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1662 case MESA_FORMAT_LA_UINT32
:
1663 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&&
1664 type
== GL_UNSIGNED_INT
&& !swapBytes
;
1665 case MESA_FORMAT_LA_SINT8
:
1666 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&& type
== GL_BYTE
&&
1668 case MESA_FORMAT_LA_SINT16
:
1669 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&& type
== GL_SHORT
&&
1671 case MESA_FORMAT_LA_SINT32
:
1672 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&& type
== GL_INT
&&
1675 case MESA_FORMAT_R_SINT8
:
1676 return format
== GL_RED_INTEGER
&& type
== GL_BYTE
;
1677 case MESA_FORMAT_RG_SINT8
:
1678 return format
== GL_RG_INTEGER
&& type
== GL_BYTE
&& !swapBytes
;
1679 case MESA_FORMAT_RGB_SINT8
:
1680 return format
== GL_RGB_INTEGER
&& type
== GL_BYTE
&& !swapBytes
;
1681 case MESA_FORMAT_RGBA_SINT8
:
1682 return format
== GL_RGBA_INTEGER
&& type
== GL_BYTE
&& !swapBytes
;
1683 case MESA_FORMAT_R_SINT16
:
1684 return format
== GL_RED_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1685 case MESA_FORMAT_RG_SINT16
:
1686 return format
== GL_RG_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1687 case MESA_FORMAT_RGB_SINT16
:
1688 return format
== GL_RGB_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1689 case MESA_FORMAT_RGBA_SINT16
:
1690 return format
== GL_RGBA_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1691 case MESA_FORMAT_R_SINT32
:
1692 return format
== GL_RED_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1693 case MESA_FORMAT_RG_SINT32
:
1694 return format
== GL_RG_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1695 case MESA_FORMAT_RGB_SINT32
:
1696 return format
== GL_RGB_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1697 case MESA_FORMAT_RGBA_SINT32
:
1698 return format
== GL_RGBA_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1700 case MESA_FORMAT_R_UINT8
:
1701 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_BYTE
;
1702 case MESA_FORMAT_RG_UINT8
:
1703 return format
== GL_RG_INTEGER
&& type
== GL_UNSIGNED_BYTE
&& !swapBytes
;
1704 case MESA_FORMAT_RGB_UINT8
:
1705 return format
== GL_RGB_INTEGER
&& type
== GL_UNSIGNED_BYTE
&& !swapBytes
;
1706 case MESA_FORMAT_RGBA_UINT8
:
1707 return format
== GL_RGBA_INTEGER
&& type
== GL_UNSIGNED_BYTE
&&
1709 case MESA_FORMAT_R_UINT16
:
1710 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1712 case MESA_FORMAT_RG_UINT16
:
1713 return format
== GL_RG_INTEGER
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1714 case MESA_FORMAT_RGB_UINT16
:
1715 return format
== GL_RGB_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1717 case MESA_FORMAT_RGBA_UINT16
:
1718 return format
== GL_RGBA_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1720 case MESA_FORMAT_R_UINT32
:
1721 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1722 case MESA_FORMAT_RG_UINT32
:
1723 return format
== GL_RG_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1724 case MESA_FORMAT_RGB_UINT32
:
1725 return format
== GL_RGB_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1726 case MESA_FORMAT_RGBA_UINT32
:
1727 return format
== GL_RGBA_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1729 case MESA_FORMAT_R_SNORM8
:
1730 return format
== GL_RED
&& type
== GL_BYTE
;
1731 case MESA_FORMAT_R8G8_SNORM
:
1732 return format
== GL_RG
&& type
== GL_BYTE
&& littleEndian
&&
1734 case MESA_FORMAT_X8B8G8R8_SNORM
:
1737 case MESA_FORMAT_A8B8G8R8_SNORM
:
1738 if (format
== GL_RGBA
&& type
== GL_BYTE
&& !littleEndian
)
1741 if (format
== GL_ABGR_EXT
&& type
== GL_BYTE
&& littleEndian
)
1746 case MESA_FORMAT_R8G8B8A8_SNORM
:
1747 if (format
== GL_RGBA
&& type
== GL_BYTE
&& littleEndian
)
1750 if (format
== GL_ABGR_EXT
&& type
== GL_BYTE
&& !littleEndian
)
1755 case MESA_FORMAT_R_SNORM16
:
1756 return format
== GL_RED
&& type
== GL_SHORT
&&
1758 case MESA_FORMAT_R16G16_SNORM
:
1759 return format
== GL_RG
&& type
== GL_SHORT
&& littleEndian
&& !swapBytes
;
1760 case MESA_FORMAT_RGB_SNORM16
:
1761 return format
== GL_RGB
&& type
== GL_SHORT
&& !swapBytes
;
1762 case MESA_FORMAT_RGBA_SNORM16
:
1763 return format
== GL_RGBA
&& type
== GL_SHORT
&& !swapBytes
;
1764 case MESA_FORMAT_RGBA_UNORM16
:
1765 return format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT
&&
1768 case MESA_FORMAT_R_RGTC1_UNORM
:
1769 case MESA_FORMAT_R_RGTC1_SNORM
:
1770 case MESA_FORMAT_RG_RGTC2_UNORM
:
1771 case MESA_FORMAT_RG_RGTC2_SNORM
:
1774 case MESA_FORMAT_L_LATC1_UNORM
:
1775 case MESA_FORMAT_L_LATC1_SNORM
:
1776 case MESA_FORMAT_LA_LATC2_UNORM
:
1777 case MESA_FORMAT_LA_LATC2_SNORM
:
1780 case MESA_FORMAT_ETC1_RGB8
:
1781 case MESA_FORMAT_ETC2_RGB8
:
1782 case MESA_FORMAT_ETC2_SRGB8
:
1783 case MESA_FORMAT_ETC2_RGBA8_EAC
:
1784 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
1785 case MESA_FORMAT_ETC2_R11_EAC
:
1786 case MESA_FORMAT_ETC2_RG11_EAC
:
1787 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
1788 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
1789 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
1790 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
1793 case MESA_FORMAT_A_SNORM8
:
1794 return format
== GL_ALPHA
&& type
== GL_BYTE
;
1795 case MESA_FORMAT_L_SNORM8
:
1796 return format
== GL_LUMINANCE
&& type
== GL_BYTE
;
1797 case MESA_FORMAT_L8A8_SNORM
:
1798 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_BYTE
&&
1799 littleEndian
&& !swapBytes
;
1800 case MESA_FORMAT_I_SNORM8
:
1801 return format
== GL_RED
&& type
== GL_BYTE
;
1802 case MESA_FORMAT_A_SNORM16
:
1803 return format
== GL_ALPHA
&& type
== GL_SHORT
&& !swapBytes
;
1804 case MESA_FORMAT_L_SNORM16
:
1805 return format
== GL_LUMINANCE
&& type
== GL_SHORT
&& !swapBytes
;
1806 case MESA_FORMAT_LA_SNORM16
:
1807 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_SHORT
&&
1808 littleEndian
&& !swapBytes
;
1809 case MESA_FORMAT_I_SNORM16
:
1810 return format
== GL_RED
&& type
== GL_SHORT
&& littleEndian
&&
1813 case MESA_FORMAT_B10G10R10A2_UINT
:
1814 return (format
== GL_BGRA_INTEGER_EXT
&&
1815 type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1818 case MESA_FORMAT_R10G10B10A2_UINT
:
1819 return (format
== GL_RGBA_INTEGER_EXT
&&
1820 type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1823 case MESA_FORMAT_R9G9B9E5_FLOAT
:
1824 return format
== GL_RGB
&& type
== GL_UNSIGNED_INT_5_9_9_9_REV
&&
1827 case MESA_FORMAT_R11G11B10_FLOAT
:
1828 return format
== GL_RGB
&& type
== GL_UNSIGNED_INT_10F_11F_11F_REV
&&
1831 case MESA_FORMAT_Z_FLOAT32
:
1832 return format
== GL_DEPTH_COMPONENT
&& type
== GL_FLOAT
&& !swapBytes
;
1834 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
1835 return format
== GL_DEPTH_STENCIL
&&
1836 type
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
&& !swapBytes
;
1838 case MESA_FORMAT_B4G4R4X4_UNORM
:
1839 case MESA_FORMAT_B5G5R5X1_UNORM
:
1840 case MESA_FORMAT_R8G8B8X8_SNORM
:
1841 case MESA_FORMAT_R8G8B8X8_SRGB
:
1842 case MESA_FORMAT_RGBX_UINT8
:
1843 case MESA_FORMAT_RGBX_SINT8
:
1844 case MESA_FORMAT_B10G10R10X2_UNORM
:
1845 case MESA_FORMAT_RGBX_UNORM16
:
1846 case MESA_FORMAT_RGBX_SNORM16
:
1847 case MESA_FORMAT_RGBX_FLOAT16
:
1848 case MESA_FORMAT_RGBX_UINT16
:
1849 case MESA_FORMAT_RGBX_SINT16
:
1850 case MESA_FORMAT_RGBX_FLOAT32
:
1851 case MESA_FORMAT_RGBX_UINT32
:
1852 case MESA_FORMAT_RGBX_SINT32
:
1855 case MESA_FORMAT_R10G10B10A2_UNORM
:
1856 return format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1859 case MESA_FORMAT_G8R8_SNORM
:
1860 return format
== GL_RG
&& type
== GL_BYTE
&& !littleEndian
&&
1863 case MESA_FORMAT_G16R16_SNORM
:
1864 return format
== GL_RG
&& type
== GL_SHORT
&& !littleEndian
&&
1867 case MESA_FORMAT_B8G8R8X8_SRGB
: