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_A8L8_SRGB
:
364 case MESA_FORMAT_SRGB_DXT1
:
365 case MESA_FORMAT_SRGBA_DXT1
:
366 case MESA_FORMAT_SRGBA_DXT3
:
367 case MESA_FORMAT_SRGBA_DXT5
:
368 case MESA_FORMAT_R8G8B8X8_SRGB
:
369 case MESA_FORMAT_ETC2_SRGB8
:
370 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
371 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
372 case MESA_FORMAT_B8G8R8X8_SRGB
:
373 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
382 * Return TRUE if format is an ETC2 compressed format specified
383 * by GL_ARB_ES3_compatibility.
386 _mesa_is_format_etc2(mesa_format format
)
389 case MESA_FORMAT_ETC2_RGB8
:
390 case MESA_FORMAT_ETC2_SRGB8
:
391 case MESA_FORMAT_ETC2_RGBA8_EAC
:
392 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
393 case MESA_FORMAT_ETC2_R11_EAC
:
394 case MESA_FORMAT_ETC2_RG11_EAC
:
395 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
396 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
397 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
398 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
407 * For an sRGB format, return the corresponding linear color space format.
408 * For non-sRGB formats, return the format as-is.
411 _mesa_get_srgb_format_linear(mesa_format format
)
414 case MESA_FORMAT_BGR_SRGB8
:
415 format
= MESA_FORMAT_BGR_UNORM8
;
417 case MESA_FORMAT_A8B8G8R8_SRGB
:
418 format
= MESA_FORMAT_A8B8G8R8_UNORM
;
420 case MESA_FORMAT_B8G8R8A8_SRGB
:
421 format
= MESA_FORMAT_B8G8R8A8_UNORM
;
423 case MESA_FORMAT_R8G8B8A8_SRGB
:
424 format
= MESA_FORMAT_R8G8B8A8_UNORM
;
426 case MESA_FORMAT_L_SRGB8
:
427 format
= MESA_FORMAT_L_UNORM8
;
429 case MESA_FORMAT_L8A8_SRGB
:
430 format
= MESA_FORMAT_L8A8_UNORM
;
432 case MESA_FORMAT_A8L8_SRGB
:
433 format
= MESA_FORMAT_A8L8_UNORM
;
435 case MESA_FORMAT_SRGB_DXT1
:
436 format
= MESA_FORMAT_RGB_DXT1
;
438 case MESA_FORMAT_SRGBA_DXT1
:
439 format
= MESA_FORMAT_RGBA_DXT1
;
441 case MESA_FORMAT_SRGBA_DXT3
:
442 format
= MESA_FORMAT_RGBA_DXT3
;
444 case MESA_FORMAT_SRGBA_DXT5
:
445 format
= MESA_FORMAT_RGBA_DXT5
;
447 case MESA_FORMAT_R8G8B8X8_SRGB
:
448 format
= MESA_FORMAT_R8G8B8X8_UNORM
;
450 case MESA_FORMAT_ETC2_SRGB8
:
451 format
= MESA_FORMAT_ETC2_RGB8
;
453 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
454 format
= MESA_FORMAT_ETC2_RGBA8_EAC
;
456 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
457 format
= MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
;
459 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
460 format
= MESA_FORMAT_BPTC_RGBA_UNORM
;
462 case MESA_FORMAT_B8G8R8X8_SRGB
:
463 format
= MESA_FORMAT_B8G8R8X8_UNORM
;
473 * If the given format is a compressed format, return a corresponding
474 * uncompressed format.
477 _mesa_get_uncompressed_format(mesa_format format
)
480 case MESA_FORMAT_RGB_FXT1
:
481 return MESA_FORMAT_BGR_UNORM8
;
482 case MESA_FORMAT_RGBA_FXT1
:
483 return MESA_FORMAT_A8B8G8R8_UNORM
;
484 case MESA_FORMAT_RGB_DXT1
:
485 case MESA_FORMAT_SRGB_DXT1
:
486 return MESA_FORMAT_BGR_UNORM8
;
487 case MESA_FORMAT_RGBA_DXT1
:
488 case MESA_FORMAT_SRGBA_DXT1
:
489 return MESA_FORMAT_A8B8G8R8_UNORM
;
490 case MESA_FORMAT_RGBA_DXT3
:
491 case MESA_FORMAT_SRGBA_DXT3
:
492 return MESA_FORMAT_A8B8G8R8_UNORM
;
493 case MESA_FORMAT_RGBA_DXT5
:
494 case MESA_FORMAT_SRGBA_DXT5
:
495 return MESA_FORMAT_A8B8G8R8_UNORM
;
496 case MESA_FORMAT_R_RGTC1_UNORM
:
497 return MESA_FORMAT_R_UNORM8
;
498 case MESA_FORMAT_R_RGTC1_SNORM
:
499 return MESA_FORMAT_R_SNORM8
;
500 case MESA_FORMAT_RG_RGTC2_UNORM
:
501 return MESA_FORMAT_R8G8_UNORM
;
502 case MESA_FORMAT_RG_RGTC2_SNORM
:
503 return MESA_FORMAT_R8G8_SNORM
;
504 case MESA_FORMAT_L_LATC1_UNORM
:
505 return MESA_FORMAT_L_UNORM8
;
506 case MESA_FORMAT_L_LATC1_SNORM
:
507 return MESA_FORMAT_L_SNORM8
;
508 case MESA_FORMAT_LA_LATC2_UNORM
:
509 return MESA_FORMAT_L8A8_UNORM
;
510 case MESA_FORMAT_LA_LATC2_SNORM
:
511 return MESA_FORMAT_L8A8_SNORM
;
512 case MESA_FORMAT_ETC1_RGB8
:
513 case MESA_FORMAT_ETC2_RGB8
:
514 case MESA_FORMAT_ETC2_SRGB8
:
515 return MESA_FORMAT_BGR_UNORM8
;
516 case MESA_FORMAT_ETC2_RGBA8_EAC
:
517 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
518 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
519 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
520 return MESA_FORMAT_A8B8G8R8_UNORM
;
521 case MESA_FORMAT_ETC2_R11_EAC
:
522 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
523 return MESA_FORMAT_R_UNORM16
;
524 case MESA_FORMAT_ETC2_RG11_EAC
:
525 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
526 return MESA_FORMAT_R16G16_UNORM
;
527 case MESA_FORMAT_BPTC_RGBA_UNORM
:
528 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
529 return MESA_FORMAT_A8B8G8R8_UNORM
;
530 case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
:
531 case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
:
532 return MESA_FORMAT_RGB_FLOAT32
;
535 assert(!_mesa_is_format_compressed(format
));
543 _mesa_format_num_components(mesa_format format
)
545 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
546 return ((info
->RedBits
> 0) +
547 (info
->GreenBits
> 0) +
548 (info
->BlueBits
> 0) +
549 (info
->AlphaBits
> 0) +
550 (info
->LuminanceBits
> 0) +
551 (info
->IntensityBits
> 0) +
552 (info
->DepthBits
> 0) +
553 (info
->StencilBits
> 0));
558 * Returns true if a color format has data stored in the R/G/B/A channels,
559 * given an index from 0 to 3.
562 _mesa_format_has_color_component(mesa_format format
, int component
)
564 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
566 assert(info
->BaseFormat
!= GL_DEPTH_COMPONENT
&&
567 info
->BaseFormat
!= GL_DEPTH_STENCIL
&&
568 info
->BaseFormat
!= GL_STENCIL_INDEX
);
572 return (info
->RedBits
+ info
->IntensityBits
+ info
->LuminanceBits
) > 0;
574 return (info
->GreenBits
+ info
->IntensityBits
+ info
->LuminanceBits
) > 0;
576 return (info
->BlueBits
+ info
->IntensityBits
+ info
->LuminanceBits
) > 0;
578 return (info
->AlphaBits
+ info
->IntensityBits
) > 0;
580 assert(!"Invalid color component: must be 0..3");
587 * Return number of bytes needed to store an image of the given size
588 * in the given format.
591 _mesa_format_image_size(mesa_format format
, GLsizei width
,
592 GLsizei height
, GLsizei depth
)
594 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
595 /* Strictly speaking, a conditional isn't needed here */
596 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
597 /* compressed format (2D only for now) */
598 const GLuint bw
= info
->BlockWidth
, bh
= info
->BlockHeight
;
599 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
600 const GLuint hblocks
= (height
+ bh
- 1) / bh
;
601 const GLuint sz
= wblocks
* hblocks
* info
->BytesPerBlock
;
606 const GLuint sz
= width
* height
* depth
* info
->BytesPerBlock
;
613 * Same as _mesa_format_image_size() but returns a 64-bit value to
614 * accomodate very large textures.
617 _mesa_format_image_size64(mesa_format format
, GLsizei width
,
618 GLsizei height
, GLsizei depth
)
620 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
621 /* Strictly speaking, a conditional isn't needed here */
622 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
623 /* compressed format (2D only for now) */
624 const uint64_t bw
= info
->BlockWidth
, bh
= info
->BlockHeight
;
625 const uint64_t wblocks
= (width
+ bw
- 1) / bw
;
626 const uint64_t hblocks
= (height
+ bh
- 1) / bh
;
627 const uint64_t sz
= wblocks
* hblocks
* info
->BytesPerBlock
;
632 const uint64_t sz
= ((uint64_t) width
*
635 info
->BytesPerBlock
);
643 _mesa_format_row_stride(mesa_format format
, GLsizei width
)
645 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
646 /* Strictly speaking, a conditional isn't needed here */
647 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
648 /* compressed format */
649 const GLuint bw
= info
->BlockWidth
;
650 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
651 const GLint stride
= wblocks
* info
->BytesPerBlock
;
655 const GLint stride
= width
* info
->BytesPerBlock
;
662 * Debug/test: check that all formats are handled in the
663 * _mesa_format_to_type_and_comps() function. When new pixel formats
664 * are added to Mesa, that function needs to be updated.
665 * This is a no-op after the first call.
668 check_format_to_type_and_comps(void)
672 for (f
= MESA_FORMAT_NONE
+ 1; f
< MESA_FORMAT_COUNT
; f
++) {
675 /* This function will emit a problem/warning if the format is
678 _mesa_format_to_type_and_comps(f
, &datatype
, &comps
);
683 * Do sanity checking of the format info table.
686 _mesa_test_formats(void)
690 STATIC_ASSERT(Elements(format_info
) == MESA_FORMAT_COUNT
);
692 for (i
= 0; i
< MESA_FORMAT_COUNT
; i
++) {
693 const struct gl_format_info
*info
= _mesa_get_format_info(i
);
696 assert(info
->Name
== i
);
698 if (info
->Name
== MESA_FORMAT_NONE
)
701 if (info
->BlockWidth
== 1 && info
->BlockHeight
== 1) {
702 if (info
->RedBits
> 0) {
703 GLuint t
= info
->RedBits
+ info
->GreenBits
704 + info
->BlueBits
+ info
->AlphaBits
;
705 assert(t
/ 8 <= info
->BytesPerBlock
);
710 assert(info
->DataType
== GL_UNSIGNED_NORMALIZED
||
711 info
->DataType
== GL_SIGNED_NORMALIZED
||
712 info
->DataType
== GL_UNSIGNED_INT
||
713 info
->DataType
== GL_INT
||
714 info
->DataType
== GL_FLOAT
||
715 /* Z32_FLOAT_X24S8 has DataType of GL_NONE */
716 info
->DataType
== GL_NONE
);
718 if (info
->BaseFormat
== GL_RGB
) {
719 assert(info
->RedBits
> 0);
720 assert(info
->GreenBits
> 0);
721 assert(info
->BlueBits
> 0);
722 assert(info
->AlphaBits
== 0);
723 assert(info
->LuminanceBits
== 0);
724 assert(info
->IntensityBits
== 0);
726 else if (info
->BaseFormat
== GL_RGBA
) {
727 assert(info
->RedBits
> 0);
728 assert(info
->GreenBits
> 0);
729 assert(info
->BlueBits
> 0);
730 assert(info
->AlphaBits
> 0);
731 assert(info
->LuminanceBits
== 0);
732 assert(info
->IntensityBits
== 0);
734 else if (info
->BaseFormat
== GL_RG
) {
735 assert(info
->RedBits
> 0);
736 assert(info
->GreenBits
> 0);
737 assert(info
->BlueBits
== 0);
738 assert(info
->AlphaBits
== 0);
739 assert(info
->LuminanceBits
== 0);
740 assert(info
->IntensityBits
== 0);
742 else if (info
->BaseFormat
== GL_RED
) {
743 assert(info
->RedBits
> 0);
744 assert(info
->GreenBits
== 0);
745 assert(info
->BlueBits
== 0);
746 assert(info
->AlphaBits
== 0);
747 assert(info
->LuminanceBits
== 0);
748 assert(info
->IntensityBits
== 0);
750 else if (info
->BaseFormat
== GL_LUMINANCE
) {
751 assert(info
->RedBits
== 0);
752 assert(info
->GreenBits
== 0);
753 assert(info
->BlueBits
== 0);
754 assert(info
->AlphaBits
== 0);
755 assert(info
->LuminanceBits
> 0);
756 assert(info
->IntensityBits
== 0);
758 else if (info
->BaseFormat
== GL_INTENSITY
) {
759 assert(info
->RedBits
== 0);
760 assert(info
->GreenBits
== 0);
761 assert(info
->BlueBits
== 0);
762 assert(info
->AlphaBits
== 0);
763 assert(info
->LuminanceBits
== 0);
764 assert(info
->IntensityBits
> 0);
768 check_format_to_type_and_comps();
774 * Return datatype and number of components per texel for the given mesa_format.
775 * Only used for mipmap generation code.
778 _mesa_format_to_type_and_comps(mesa_format format
,
779 GLenum
*datatype
, GLuint
*comps
)
782 case MESA_FORMAT_A8B8G8R8_UNORM
:
783 case MESA_FORMAT_R8G8B8A8_UNORM
:
784 case MESA_FORMAT_B8G8R8A8_UNORM
:
785 case MESA_FORMAT_A8R8G8B8_UNORM
:
786 case MESA_FORMAT_X8B8G8R8_UNORM
:
787 case MESA_FORMAT_R8G8B8X8_UNORM
:
788 case MESA_FORMAT_B8G8R8X8_UNORM
:
789 case MESA_FORMAT_X8R8G8B8_UNORM
:
790 *datatype
= GL_UNSIGNED_BYTE
;
793 case MESA_FORMAT_BGR_UNORM8
:
794 case MESA_FORMAT_RGB_UNORM8
:
795 *datatype
= GL_UNSIGNED_BYTE
;
798 case MESA_FORMAT_B5G6R5_UNORM
:
799 case MESA_FORMAT_R5G6B5_UNORM
:
800 *datatype
= GL_UNSIGNED_SHORT_5_6_5
;
804 case MESA_FORMAT_B4G4R4A4_UNORM
:
805 case MESA_FORMAT_A4R4G4B4_UNORM
:
806 case MESA_FORMAT_B4G4R4X4_UNORM
:
807 *datatype
= GL_UNSIGNED_SHORT_4_4_4_4
;
811 case MESA_FORMAT_B5G5R5A1_UNORM
:
812 case MESA_FORMAT_A1R5G5B5_UNORM
:
813 case MESA_FORMAT_B5G5R5X1_UNORM
:
814 *datatype
= GL_UNSIGNED_SHORT_1_5_5_5_REV
;
818 case MESA_FORMAT_B10G10R10A2_UNORM
:
819 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
823 case MESA_FORMAT_A1B5G5R5_UNORM
:
824 *datatype
= GL_UNSIGNED_SHORT_5_5_5_1
;
828 case MESA_FORMAT_L4A4_UNORM
:
829 *datatype
= MESA_UNSIGNED_BYTE_4_4
;
833 case MESA_FORMAT_L8A8_UNORM
:
834 case MESA_FORMAT_A8L8_UNORM
:
835 case MESA_FORMAT_R8G8_UNORM
:
836 case MESA_FORMAT_G8R8_UNORM
:
837 *datatype
= GL_UNSIGNED_BYTE
;
841 case MESA_FORMAT_L16A16_UNORM
:
842 case MESA_FORMAT_A16L16_UNORM
:
843 case MESA_FORMAT_R16G16_UNORM
:
844 case MESA_FORMAT_G16R16_UNORM
:
845 *datatype
= GL_UNSIGNED_SHORT
;
849 case MESA_FORMAT_R_UNORM16
:
850 case MESA_FORMAT_A_UNORM16
:
851 case MESA_FORMAT_L_UNORM16
:
852 case MESA_FORMAT_I_UNORM16
:
853 *datatype
= GL_UNSIGNED_SHORT
;
857 case MESA_FORMAT_B2G3R3_UNORM
:
858 *datatype
= GL_UNSIGNED_BYTE_3_3_2
;
862 case MESA_FORMAT_A_UNORM8
:
863 case MESA_FORMAT_L_UNORM8
:
864 case MESA_FORMAT_I_UNORM8
:
865 case MESA_FORMAT_R_UNORM8
:
866 case MESA_FORMAT_S_UINT8
:
867 *datatype
= GL_UNSIGNED_BYTE
;
871 case MESA_FORMAT_YCBCR
:
872 case MESA_FORMAT_YCBCR_REV
:
873 *datatype
= GL_UNSIGNED_SHORT
;
877 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
878 *datatype
= GL_UNSIGNED_INT_24_8_MESA
;
882 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
883 *datatype
= GL_UNSIGNED_INT_8_24_REV_MESA
;
887 case MESA_FORMAT_Z_UNORM16
:
888 *datatype
= GL_UNSIGNED_SHORT
;
892 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
893 *datatype
= GL_UNSIGNED_INT
;
897 case MESA_FORMAT_X8_UINT_Z24_UNORM
:
898 *datatype
= GL_UNSIGNED_INT
;
902 case MESA_FORMAT_Z_UNORM32
:
903 *datatype
= GL_UNSIGNED_INT
;
907 case MESA_FORMAT_Z_FLOAT32
:
908 *datatype
= GL_FLOAT
;
912 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
913 *datatype
= GL_FLOAT_32_UNSIGNED_INT_24_8_REV
;
917 case MESA_FORMAT_R_SNORM8
:
918 case MESA_FORMAT_A_SNORM8
:
919 case MESA_FORMAT_L_SNORM8
:
920 case MESA_FORMAT_I_SNORM8
:
924 case MESA_FORMAT_R8G8_SNORM
:
925 case MESA_FORMAT_L8A8_SNORM
:
926 case MESA_FORMAT_A8L8_SNORM
:
930 case MESA_FORMAT_A8B8G8R8_SNORM
:
931 case MESA_FORMAT_R8G8B8A8_SNORM
:
932 case MESA_FORMAT_X8B8G8R8_SNORM
:
937 case MESA_FORMAT_RGBA_UNORM16
:
938 *datatype
= GL_UNSIGNED_SHORT
;
942 case MESA_FORMAT_R_SNORM16
:
943 case MESA_FORMAT_A_SNORM16
:
944 case MESA_FORMAT_L_SNORM16
:
945 case MESA_FORMAT_I_SNORM16
:
946 *datatype
= GL_SHORT
;
949 case MESA_FORMAT_R16G16_SNORM
:
950 case MESA_FORMAT_LA_SNORM16
:
951 *datatype
= GL_SHORT
;
954 case MESA_FORMAT_RGB_SNORM16
:
955 *datatype
= GL_SHORT
;
958 case MESA_FORMAT_RGBA_SNORM16
:
959 *datatype
= GL_SHORT
;
963 case MESA_FORMAT_BGR_SRGB8
:
964 *datatype
= GL_UNSIGNED_BYTE
;
967 case MESA_FORMAT_A8B8G8R8_SRGB
:
968 case MESA_FORMAT_B8G8R8A8_SRGB
:
969 case MESA_FORMAT_R8G8B8A8_SRGB
:
970 *datatype
= GL_UNSIGNED_BYTE
;
973 case MESA_FORMAT_L_SRGB8
:
974 *datatype
= GL_UNSIGNED_BYTE
;
977 case MESA_FORMAT_L8A8_SRGB
:
978 case MESA_FORMAT_A8L8_SRGB
:
979 *datatype
= GL_UNSIGNED_BYTE
;
983 case MESA_FORMAT_RGB_FXT1
:
984 case MESA_FORMAT_RGBA_FXT1
:
985 case MESA_FORMAT_RGB_DXT1
:
986 case MESA_FORMAT_RGBA_DXT1
:
987 case MESA_FORMAT_RGBA_DXT3
:
988 case MESA_FORMAT_RGBA_DXT5
:
989 case MESA_FORMAT_SRGB_DXT1
:
990 case MESA_FORMAT_SRGBA_DXT1
:
991 case MESA_FORMAT_SRGBA_DXT3
:
992 case MESA_FORMAT_SRGBA_DXT5
:
993 case MESA_FORMAT_R_RGTC1_UNORM
:
994 case MESA_FORMAT_R_RGTC1_SNORM
:
995 case MESA_FORMAT_RG_RGTC2_UNORM
:
996 case MESA_FORMAT_RG_RGTC2_SNORM
:
997 case MESA_FORMAT_L_LATC1_UNORM
:
998 case MESA_FORMAT_L_LATC1_SNORM
:
999 case MESA_FORMAT_LA_LATC2_UNORM
:
1000 case MESA_FORMAT_LA_LATC2_SNORM
:
1001 case MESA_FORMAT_ETC1_RGB8
:
1002 case MESA_FORMAT_ETC2_RGB8
:
1003 case MESA_FORMAT_ETC2_SRGB8
:
1004 case MESA_FORMAT_ETC2_RGBA8_EAC
:
1005 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
1006 case MESA_FORMAT_ETC2_R11_EAC
:
1007 case MESA_FORMAT_ETC2_RG11_EAC
:
1008 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
1009 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
1010 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
1011 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
1012 case MESA_FORMAT_BPTC_RGBA_UNORM
:
1013 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
1014 case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
:
1015 case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
:
1016 /* XXX generate error instead? */
1017 *datatype
= GL_UNSIGNED_BYTE
;
1021 case MESA_FORMAT_RGBA_FLOAT32
:
1022 *datatype
= GL_FLOAT
;
1025 case MESA_FORMAT_RGBA_FLOAT16
:
1026 *datatype
= GL_HALF_FLOAT_ARB
;
1029 case MESA_FORMAT_RGB_FLOAT32
:
1030 *datatype
= GL_FLOAT
;
1033 case MESA_FORMAT_RGB_FLOAT16
:
1034 *datatype
= GL_HALF_FLOAT_ARB
;
1037 case MESA_FORMAT_LA_FLOAT32
:
1038 case MESA_FORMAT_RG_FLOAT32
:
1039 *datatype
= GL_FLOAT
;
1042 case MESA_FORMAT_LA_FLOAT16
:
1043 case MESA_FORMAT_RG_FLOAT16
:
1044 *datatype
= GL_HALF_FLOAT_ARB
;
1047 case MESA_FORMAT_A_FLOAT32
:
1048 case MESA_FORMAT_L_FLOAT32
:
1049 case MESA_FORMAT_I_FLOAT32
:
1050 case MESA_FORMAT_R_FLOAT32
:
1051 *datatype
= GL_FLOAT
;
1054 case MESA_FORMAT_A_FLOAT16
:
1055 case MESA_FORMAT_L_FLOAT16
:
1056 case MESA_FORMAT_I_FLOAT16
:
1057 case MESA_FORMAT_R_FLOAT16
:
1058 *datatype
= GL_HALF_FLOAT_ARB
;
1062 case MESA_FORMAT_A_UINT8
:
1063 case MESA_FORMAT_L_UINT8
:
1064 case MESA_FORMAT_I_UINT8
:
1065 *datatype
= GL_UNSIGNED_BYTE
;
1068 case MESA_FORMAT_LA_UINT8
:
1069 *datatype
= GL_UNSIGNED_BYTE
;
1073 case MESA_FORMAT_A_UINT16
:
1074 case MESA_FORMAT_L_UINT16
:
1075 case MESA_FORMAT_I_UINT16
:
1076 *datatype
= GL_UNSIGNED_SHORT
;
1079 case MESA_FORMAT_LA_UINT16
:
1080 *datatype
= GL_UNSIGNED_SHORT
;
1083 case MESA_FORMAT_A_UINT32
:
1084 case MESA_FORMAT_L_UINT32
:
1085 case MESA_FORMAT_I_UINT32
:
1086 *datatype
= GL_UNSIGNED_INT
;
1089 case MESA_FORMAT_LA_UINT32
:
1090 *datatype
= GL_UNSIGNED_INT
;
1093 case MESA_FORMAT_A_SINT8
:
1094 case MESA_FORMAT_L_SINT8
:
1095 case MESA_FORMAT_I_SINT8
:
1096 *datatype
= GL_BYTE
;
1099 case MESA_FORMAT_LA_SINT8
:
1100 *datatype
= GL_BYTE
;
1104 case MESA_FORMAT_A_SINT16
:
1105 case MESA_FORMAT_L_SINT16
:
1106 case MESA_FORMAT_I_SINT16
:
1107 *datatype
= GL_SHORT
;
1110 case MESA_FORMAT_LA_SINT16
:
1111 *datatype
= GL_SHORT
;
1115 case MESA_FORMAT_A_SINT32
:
1116 case MESA_FORMAT_L_SINT32
:
1117 case MESA_FORMAT_I_SINT32
:
1121 case MESA_FORMAT_LA_SINT32
:
1126 case MESA_FORMAT_R_SINT8
:
1127 *datatype
= GL_BYTE
;
1130 case MESA_FORMAT_RG_SINT8
:
1131 *datatype
= GL_BYTE
;
1134 case MESA_FORMAT_RGB_SINT8
:
1135 *datatype
= GL_BYTE
;
1138 case MESA_FORMAT_RGBA_SINT8
:
1139 *datatype
= GL_BYTE
;
1142 case MESA_FORMAT_R_SINT16
:
1143 *datatype
= GL_SHORT
;
1146 case MESA_FORMAT_RG_SINT16
:
1147 *datatype
= GL_SHORT
;
1150 case MESA_FORMAT_RGB_SINT16
:
1151 *datatype
= GL_SHORT
;
1154 case MESA_FORMAT_RGBA_SINT16
:
1155 *datatype
= GL_SHORT
;
1158 case MESA_FORMAT_R_SINT32
:
1162 case MESA_FORMAT_RG_SINT32
:
1166 case MESA_FORMAT_RGB_SINT32
:
1170 case MESA_FORMAT_RGBA_SINT32
:
1176 * \name Non-normalized unsigned integer formats.
1178 case MESA_FORMAT_R_UINT8
:
1179 *datatype
= GL_UNSIGNED_BYTE
;
1182 case MESA_FORMAT_RG_UINT8
:
1183 *datatype
= GL_UNSIGNED_BYTE
;
1186 case MESA_FORMAT_RGB_UINT8
:
1187 *datatype
= GL_UNSIGNED_BYTE
;
1190 case MESA_FORMAT_RGBA_UINT8
:
1191 *datatype
= GL_UNSIGNED_BYTE
;
1194 case MESA_FORMAT_R_UINT16
:
1195 *datatype
= GL_UNSIGNED_SHORT
;
1198 case MESA_FORMAT_RG_UINT16
:
1199 *datatype
= GL_UNSIGNED_SHORT
;
1202 case MESA_FORMAT_RGB_UINT16
:
1203 *datatype
= GL_UNSIGNED_SHORT
;
1206 case MESA_FORMAT_RGBA_UINT16
:
1207 *datatype
= GL_UNSIGNED_SHORT
;
1210 case MESA_FORMAT_R_UINT32
:
1211 *datatype
= GL_UNSIGNED_INT
;
1214 case MESA_FORMAT_RG_UINT32
:
1215 *datatype
= GL_UNSIGNED_INT
;
1218 case MESA_FORMAT_RGB_UINT32
:
1219 *datatype
= GL_UNSIGNED_INT
;
1222 case MESA_FORMAT_RGBA_UINT32
:
1223 *datatype
= GL_UNSIGNED_INT
;
1227 case MESA_FORMAT_R9G9B9E5_FLOAT
:
1228 *datatype
= GL_UNSIGNED_INT_5_9_9_9_REV
;
1232 case MESA_FORMAT_R11G11B10_FLOAT
:
1233 *datatype
= GL_UNSIGNED_INT_10F_11F_11F_REV
;
1237 case MESA_FORMAT_B10G10R10A2_UINT
:
1238 case MESA_FORMAT_R10G10B10A2_UINT
:
1239 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1243 case MESA_FORMAT_R8G8B8X8_SRGB
:
1244 case MESA_FORMAT_RGBX_UINT8
:
1245 *datatype
= GL_UNSIGNED_BYTE
;
1249 case MESA_FORMAT_R8G8B8X8_SNORM
:
1250 case MESA_FORMAT_RGBX_SINT8
:
1251 *datatype
= GL_BYTE
;
1255 case MESA_FORMAT_B10G10R10X2_UNORM
:
1256 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1260 case MESA_FORMAT_RGBX_UNORM16
:
1261 case MESA_FORMAT_RGBX_UINT16
:
1262 *datatype
= GL_UNSIGNED_SHORT
;
1266 case MESA_FORMAT_RGBX_SNORM16
:
1267 case MESA_FORMAT_RGBX_SINT16
:
1268 *datatype
= GL_SHORT
;
1272 case MESA_FORMAT_RGBX_FLOAT16
:
1273 *datatype
= GL_HALF_FLOAT
;
1277 case MESA_FORMAT_RGBX_FLOAT32
:
1278 *datatype
= GL_FLOAT
;
1282 case MESA_FORMAT_RGBX_UINT32
:
1283 *datatype
= GL_UNSIGNED_INT
;
1287 case MESA_FORMAT_RGBX_SINT32
:
1292 case MESA_FORMAT_R10G10B10A2_UNORM
:
1293 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1297 case MESA_FORMAT_G8R8_SNORM
:
1298 *datatype
= GL_BYTE
;
1302 case MESA_FORMAT_G16R16_SNORM
:
1303 *datatype
= GL_SHORT
;
1307 case MESA_FORMAT_B8G8R8X8_SRGB
:
1308 *datatype
= GL_UNSIGNED_BYTE
;
1312 case MESA_FORMAT_COUNT
:
1316 case MESA_FORMAT_NONE
:
1317 /* For debug builds, warn if any formats are not handled */
1321 _mesa_problem(NULL
, "bad format %s in _mesa_format_to_type_and_comps",
1322 _mesa_get_format_name(format
));
1329 * Check if a mesa_format exactly matches a GL format/type combination
1330 * such that we can use memcpy() from one to the other.
1331 * \param mesa_format a MESA_FORMAT_x value
1332 * \param format the user-specified image format
1333 * \param type the user-specified image datatype
1334 * \param swapBytes typically the current pixel pack/unpack byteswap state
1335 * \return GL_TRUE if the formats match, GL_FALSE otherwise.
1338 _mesa_format_matches_format_and_type(mesa_format mesa_format
,
1339 GLenum format
, GLenum type
,
1340 GLboolean swapBytes
)
1342 const GLboolean littleEndian
= _mesa_little_endian();
1344 /* Note: When reading a GL format/type combination, the format lists channel
1345 * assignments from most significant channel in the type to least
1346 * significant. A type with _REV indicates that the assignments are
1347 * swapped, so they are listed from least significant to most significant.
1349 * For sanity, please keep this switch statement ordered the same as the
1350 * enums in formats.h.
1353 switch (mesa_format
) {
1355 case MESA_FORMAT_NONE
:
1356 case MESA_FORMAT_COUNT
:
1359 case MESA_FORMAT_A8B8G8R8_UNORM
:
1360 case MESA_FORMAT_A8B8G8R8_SRGB
:
1361 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& !swapBytes
)
1364 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&& swapBytes
)
1367 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_BYTE
&& !littleEndian
)
1370 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
1374 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8
1378 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
)
1383 case MESA_FORMAT_R8G8B8A8_UNORM
:
1384 case MESA_FORMAT_R8G8B8A8_SRGB
:
1385 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1389 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& swapBytes
)
1392 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
)
1395 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8
&&
1399 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1403 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_BYTE
&& !littleEndian
)
1408 case MESA_FORMAT_B8G8R8A8_UNORM
:
1409 case MESA_FORMAT_B8G8R8A8_SRGB
:
1410 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1414 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& swapBytes
)
1417 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
)
1422 case MESA_FORMAT_A8R8G8B8_UNORM
:
1423 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& !swapBytes
)
1426 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1430 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_BYTE
&& !littleEndian
)
1435 case MESA_FORMAT_X8B8G8R8_UNORM
:
1436 case MESA_FORMAT_R8G8B8X8_UNORM
:
1439 case MESA_FORMAT_B8G8R8X8_UNORM
:
1440 case MESA_FORMAT_X8R8G8B8_UNORM
:
1443 case MESA_FORMAT_BGR_UNORM8
:
1444 case MESA_FORMAT_BGR_SRGB8
:
1445 return format
== GL_BGR
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1447 case MESA_FORMAT_RGB_UNORM8
:
1448 return format
== GL_RGB
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1450 case MESA_FORMAT_B5G6R5_UNORM
:
1451 return format
== GL_RGB
&& type
== GL_UNSIGNED_SHORT_5_6_5
&& !swapBytes
;
1453 case MESA_FORMAT_R5G6B5_UNORM
:
1454 /* Some of the 16-bit MESA_FORMATs that would seem to correspond to
1455 * GL_UNSIGNED_SHORT_* are byte-swapped instead of channel-reversed,
1456 * according to formats.h, so they can't be matched.
1460 case MESA_FORMAT_B4G4R4A4_UNORM
:
1461 return format
== GL_BGRA
&& type
== GL_UNSIGNED_SHORT_4_4_4_4_REV
&&
1464 case MESA_FORMAT_A4R4G4B4_UNORM
:
1467 case MESA_FORMAT_A1B5G5R5_UNORM
:
1468 return format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT_5_5_5_1
&&
1471 case MESA_FORMAT_B5G5R5A1_UNORM
:
1472 return format
== GL_BGRA
&& type
== GL_UNSIGNED_SHORT_1_5_5_5_REV
&&
1475 case MESA_FORMAT_A1R5G5B5_UNORM
:
1478 case MESA_FORMAT_L4A4_UNORM
:
1480 case MESA_FORMAT_L8A8_UNORM
:
1481 case MESA_FORMAT_L8A8_SRGB
:
1482 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1483 case MESA_FORMAT_A8L8_UNORM
:
1484 case MESA_FORMAT_A8L8_SRGB
:
1487 case MESA_FORMAT_L16A16_UNORM
:
1488 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_UNSIGNED_SHORT
&& littleEndian
&& !swapBytes
;
1489 case MESA_FORMAT_A16L16_UNORM
:
1492 case MESA_FORMAT_B2G3R3_UNORM
:
1493 return format
== GL_RGB
&& type
== GL_UNSIGNED_BYTE_3_3_2
;
1495 case MESA_FORMAT_A_UNORM8
:
1496 return format
== GL_ALPHA
&& type
== GL_UNSIGNED_BYTE
;
1497 case MESA_FORMAT_A_UNORM16
:
1498 return format
== GL_ALPHA
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1499 case MESA_FORMAT_L_UNORM8
:
1500 case MESA_FORMAT_L_SRGB8
:
1501 return format
== GL_LUMINANCE
&& type
== GL_UNSIGNED_BYTE
;
1502 case MESA_FORMAT_L_UNORM16
:
1503 return format
== GL_LUMINANCE
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1504 case MESA_FORMAT_I_UNORM8
:
1505 return format
== GL_RED
&& type
== GL_UNSIGNED_BYTE
;
1506 case MESA_FORMAT_I_UNORM16
:
1507 return format
== GL_RED
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1509 case MESA_FORMAT_YCBCR
:
1510 return format
== GL_YCBCR_MESA
&&
1511 ((type
== GL_UNSIGNED_SHORT_8_8_MESA
&& littleEndian
!= swapBytes
) ||
1512 (type
== GL_UNSIGNED_SHORT_8_8_REV_MESA
&& littleEndian
== swapBytes
));
1513 case MESA_FORMAT_YCBCR_REV
:
1514 return format
== GL_YCBCR_MESA
&&
1515 ((type
== GL_UNSIGNED_SHORT_8_8_MESA
&& littleEndian
== swapBytes
) ||
1516 (type
== GL_UNSIGNED_SHORT_8_8_REV_MESA
&& littleEndian
!= swapBytes
));
1518 case MESA_FORMAT_R_UNORM8
:
1519 return format
== GL_RED
&& type
== GL_UNSIGNED_BYTE
;
1520 case MESA_FORMAT_R8G8_UNORM
:
1521 return format
== GL_RG
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1522 case MESA_FORMAT_G8R8_UNORM
:
1525 case MESA_FORMAT_R_UNORM16
:
1526 return format
== GL_RED
&& type
== GL_UNSIGNED_SHORT
&&
1528 case MESA_FORMAT_R16G16_UNORM
:
1529 return format
== GL_RG
&& type
== GL_UNSIGNED_SHORT
&& littleEndian
&&
1531 case MESA_FORMAT_G16R16_UNORM
:
1534 case MESA_FORMAT_B10G10R10A2_UNORM
:
1535 return format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1538 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
1539 return format
== GL_DEPTH_STENCIL
&& type
== GL_UNSIGNED_INT_24_8
&&
1541 case MESA_FORMAT_X8_UINT_Z24_UNORM
:
1542 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
1545 case MESA_FORMAT_Z_UNORM16
:
1546 return format
== GL_DEPTH_COMPONENT
&& type
== GL_UNSIGNED_SHORT
&&
1549 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
1552 case MESA_FORMAT_Z_UNORM32
:
1553 return format
== GL_DEPTH_COMPONENT
&& type
== GL_UNSIGNED_INT
&&
1556 case MESA_FORMAT_S_UINT8
:
1557 return format
== GL_STENCIL_INDEX
&& type
== GL_UNSIGNED_BYTE
;
1559 case MESA_FORMAT_SRGB_DXT1
:
1560 case MESA_FORMAT_SRGBA_DXT1
:
1561 case MESA_FORMAT_SRGBA_DXT3
:
1562 case MESA_FORMAT_SRGBA_DXT5
:
1565 case MESA_FORMAT_RGB_FXT1
:
1566 case MESA_FORMAT_RGBA_FXT1
:
1567 case MESA_FORMAT_RGB_DXT1
:
1568 case MESA_FORMAT_RGBA_DXT1
:
1569 case MESA_FORMAT_RGBA_DXT3
:
1570 case MESA_FORMAT_RGBA_DXT5
:
1573 case MESA_FORMAT_BPTC_RGBA_UNORM
:
1574 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
1575 case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
:
1576 case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
:
1579 case MESA_FORMAT_RGBA_FLOAT32
:
1580 return format
== GL_RGBA
&& type
== GL_FLOAT
&& !swapBytes
;
1581 case MESA_FORMAT_RGBA_FLOAT16
:
1582 return format
== GL_RGBA
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1584 case MESA_FORMAT_RGB_FLOAT32
:
1585 return format
== GL_RGB
&& type
== GL_FLOAT
&& !swapBytes
;
1586 case MESA_FORMAT_RGB_FLOAT16
:
1587 return format
== GL_RGB
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1589 case MESA_FORMAT_A_FLOAT32
:
1590 return format
== GL_ALPHA
&& type
== GL_FLOAT
&& !swapBytes
;
1591 case MESA_FORMAT_A_FLOAT16
:
1592 return format
== GL_ALPHA
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1594 case MESA_FORMAT_L_FLOAT32
:
1595 return format
== GL_LUMINANCE
&& type
== GL_FLOAT
&& !swapBytes
;
1596 case MESA_FORMAT_L_FLOAT16
:
1597 return format
== GL_LUMINANCE
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1599 case MESA_FORMAT_LA_FLOAT32
:
1600 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_FLOAT
&& !swapBytes
;
1601 case MESA_FORMAT_LA_FLOAT16
:
1602 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1604 case MESA_FORMAT_I_FLOAT32
:
1605 return format
== GL_RED
&& type
== GL_FLOAT
&& !swapBytes
;
1606 case MESA_FORMAT_I_FLOAT16
:
1607 return format
== GL_RED
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1609 case MESA_FORMAT_R_FLOAT32
:
1610 return format
== GL_RED
&& type
== GL_FLOAT
&& !swapBytes
;
1611 case MESA_FORMAT_R_FLOAT16
:
1612 return format
== GL_RED
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1614 case MESA_FORMAT_RG_FLOAT32
:
1615 return format
== GL_RG
&& type
== GL_FLOAT
&& !swapBytes
;
1616 case MESA_FORMAT_RG_FLOAT16
:
1617 return format
== GL_RG
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1619 case MESA_FORMAT_A_UINT8
:
1620 return format
== GL_ALPHA_INTEGER
&& type
== GL_UNSIGNED_BYTE
;
1621 case MESA_FORMAT_A_UINT16
:
1622 return format
== GL_ALPHA_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1624 case MESA_FORMAT_A_UINT32
:
1625 return format
== GL_ALPHA_INTEGER
&& type
== GL_UNSIGNED_INT
&&
1627 case MESA_FORMAT_A_SINT8
:
1628 return format
== GL_ALPHA_INTEGER
&& type
== GL_BYTE
;
1629 case MESA_FORMAT_A_SINT16
:
1630 return format
== GL_ALPHA_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1631 case MESA_FORMAT_A_SINT32
:
1632 return format
== GL_ALPHA_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1634 case MESA_FORMAT_I_UINT8
:
1635 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_BYTE
;
1636 case MESA_FORMAT_I_UINT16
:
1637 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1638 case MESA_FORMAT_I_UINT32
:
1639 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1640 case MESA_FORMAT_I_SINT8
:
1641 return format
== GL_RED_INTEGER
&& type
== GL_BYTE
;
1642 case MESA_FORMAT_I_SINT16
:
1643 return format
== GL_RED_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1644 case MESA_FORMAT_I_SINT32
:
1645 return format
== GL_RED_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1647 case MESA_FORMAT_L_UINT8
:
1648 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_UNSIGNED_BYTE
;
1649 case MESA_FORMAT_L_UINT16
:
1650 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_UNSIGNED_SHORT
&&
1652 case MESA_FORMAT_L_UINT32
:
1653 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_UNSIGNED_INT
&&
1655 case MESA_FORMAT_L_SINT8
:
1656 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_BYTE
;
1657 case MESA_FORMAT_L_SINT16
:
1658 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_SHORT
&&
1660 case MESA_FORMAT_L_SINT32
:
1661 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_INT
&& !swapBytes
;
1663 case MESA_FORMAT_LA_UINT8
:
1664 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&&
1665 type
== GL_UNSIGNED_BYTE
&& !swapBytes
;
1666 case MESA_FORMAT_LA_UINT16
:
1667 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&&
1668 type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1669 case MESA_FORMAT_LA_UINT32
:
1670 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&&
1671 type
== GL_UNSIGNED_INT
&& !swapBytes
;
1672 case MESA_FORMAT_LA_SINT8
:
1673 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&& type
== GL_BYTE
&&
1675 case MESA_FORMAT_LA_SINT16
:
1676 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&& type
== GL_SHORT
&&
1678 case MESA_FORMAT_LA_SINT32
:
1679 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&& type
== GL_INT
&&
1682 case MESA_FORMAT_R_SINT8
:
1683 return format
== GL_RED_INTEGER
&& type
== GL_BYTE
;
1684 case MESA_FORMAT_RG_SINT8
:
1685 return format
== GL_RG_INTEGER
&& type
== GL_BYTE
&& !swapBytes
;
1686 case MESA_FORMAT_RGB_SINT8
:
1687 return format
== GL_RGB_INTEGER
&& type
== GL_BYTE
&& !swapBytes
;
1688 case MESA_FORMAT_RGBA_SINT8
:
1689 return format
== GL_RGBA_INTEGER
&& type
== GL_BYTE
&& !swapBytes
;
1690 case MESA_FORMAT_R_SINT16
:
1691 return format
== GL_RED_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1692 case MESA_FORMAT_RG_SINT16
:
1693 return format
== GL_RG_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1694 case MESA_FORMAT_RGB_SINT16
:
1695 return format
== GL_RGB_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1696 case MESA_FORMAT_RGBA_SINT16
:
1697 return format
== GL_RGBA_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1698 case MESA_FORMAT_R_SINT32
:
1699 return format
== GL_RED_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1700 case MESA_FORMAT_RG_SINT32
:
1701 return format
== GL_RG_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1702 case MESA_FORMAT_RGB_SINT32
:
1703 return format
== GL_RGB_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1704 case MESA_FORMAT_RGBA_SINT32
:
1705 return format
== GL_RGBA_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1707 case MESA_FORMAT_R_UINT8
:
1708 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_BYTE
;
1709 case MESA_FORMAT_RG_UINT8
:
1710 return format
== GL_RG_INTEGER
&& type
== GL_UNSIGNED_BYTE
&& !swapBytes
;
1711 case MESA_FORMAT_RGB_UINT8
:
1712 return format
== GL_RGB_INTEGER
&& type
== GL_UNSIGNED_BYTE
&& !swapBytes
;
1713 case MESA_FORMAT_RGBA_UINT8
:
1714 return format
== GL_RGBA_INTEGER
&& type
== GL_UNSIGNED_BYTE
&&
1716 case MESA_FORMAT_R_UINT16
:
1717 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1719 case MESA_FORMAT_RG_UINT16
:
1720 return format
== GL_RG_INTEGER
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1721 case MESA_FORMAT_RGB_UINT16
:
1722 return format
== GL_RGB_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1724 case MESA_FORMAT_RGBA_UINT16
:
1725 return format
== GL_RGBA_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1727 case MESA_FORMAT_R_UINT32
:
1728 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1729 case MESA_FORMAT_RG_UINT32
:
1730 return format
== GL_RG_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1731 case MESA_FORMAT_RGB_UINT32
:
1732 return format
== GL_RGB_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1733 case MESA_FORMAT_RGBA_UINT32
:
1734 return format
== GL_RGBA_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1736 case MESA_FORMAT_R_SNORM8
:
1737 return format
== GL_RED
&& type
== GL_BYTE
;
1738 case MESA_FORMAT_R8G8_SNORM
:
1739 return format
== GL_RG
&& type
== GL_BYTE
&& littleEndian
&&
1741 case MESA_FORMAT_X8B8G8R8_SNORM
:
1744 case MESA_FORMAT_A8B8G8R8_SNORM
:
1745 if (format
== GL_RGBA
&& type
== GL_BYTE
&& !littleEndian
)
1748 if (format
== GL_ABGR_EXT
&& type
== GL_BYTE
&& littleEndian
)
1753 case MESA_FORMAT_R8G8B8A8_SNORM
:
1754 if (format
== GL_RGBA
&& type
== GL_BYTE
&& littleEndian
)
1757 if (format
== GL_ABGR_EXT
&& type
== GL_BYTE
&& !littleEndian
)
1762 case MESA_FORMAT_R_SNORM16
:
1763 return format
== GL_RED
&& type
== GL_SHORT
&&
1765 case MESA_FORMAT_R16G16_SNORM
:
1766 return format
== GL_RG
&& type
== GL_SHORT
&& littleEndian
&& !swapBytes
;
1767 case MESA_FORMAT_RGB_SNORM16
:
1768 return format
== GL_RGB
&& type
== GL_SHORT
&& !swapBytes
;
1769 case MESA_FORMAT_RGBA_SNORM16
:
1770 return format
== GL_RGBA
&& type
== GL_SHORT
&& !swapBytes
;
1771 case MESA_FORMAT_RGBA_UNORM16
:
1772 return format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT
&&
1775 case MESA_FORMAT_R_RGTC1_UNORM
:
1776 case MESA_FORMAT_R_RGTC1_SNORM
:
1777 case MESA_FORMAT_RG_RGTC2_UNORM
:
1778 case MESA_FORMAT_RG_RGTC2_SNORM
:
1781 case MESA_FORMAT_L_LATC1_UNORM
:
1782 case MESA_FORMAT_L_LATC1_SNORM
:
1783 case MESA_FORMAT_LA_LATC2_UNORM
:
1784 case MESA_FORMAT_LA_LATC2_SNORM
:
1787 case MESA_FORMAT_ETC1_RGB8
:
1788 case MESA_FORMAT_ETC2_RGB8
:
1789 case MESA_FORMAT_ETC2_SRGB8
:
1790 case MESA_FORMAT_ETC2_RGBA8_EAC
:
1791 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
1792 case MESA_FORMAT_ETC2_R11_EAC
:
1793 case MESA_FORMAT_ETC2_RG11_EAC
:
1794 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
1795 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
1796 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
1797 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
1800 case MESA_FORMAT_A_SNORM8
:
1801 return format
== GL_ALPHA
&& type
== GL_BYTE
;
1802 case MESA_FORMAT_L_SNORM8
:
1803 return format
== GL_LUMINANCE
&& type
== GL_BYTE
;
1804 case MESA_FORMAT_L8A8_SNORM
:
1805 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_BYTE
&&
1806 littleEndian
&& !swapBytes
;
1807 case MESA_FORMAT_A8L8_SNORM
:
1808 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_BYTE
&&
1809 !littleEndian
&& !swapBytes
;
1810 case MESA_FORMAT_I_SNORM8
:
1811 return format
== GL_RED
&& type
== GL_BYTE
;
1812 case MESA_FORMAT_A_SNORM16
:
1813 return format
== GL_ALPHA
&& type
== GL_SHORT
&& !swapBytes
;
1814 case MESA_FORMAT_L_SNORM16
:
1815 return format
== GL_LUMINANCE
&& type
== GL_SHORT
&& !swapBytes
;
1816 case MESA_FORMAT_LA_SNORM16
:
1817 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_SHORT
&&
1818 littleEndian
&& !swapBytes
;
1819 case MESA_FORMAT_I_SNORM16
:
1820 return format
== GL_RED
&& type
== GL_SHORT
&& littleEndian
&&
1823 case MESA_FORMAT_B10G10R10A2_UINT
:
1824 return (format
== GL_BGRA_INTEGER_EXT
&&
1825 type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1828 case MESA_FORMAT_R10G10B10A2_UINT
:
1829 return (format
== GL_RGBA_INTEGER_EXT
&&
1830 type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1833 case MESA_FORMAT_R9G9B9E5_FLOAT
:
1834 return format
== GL_RGB
&& type
== GL_UNSIGNED_INT_5_9_9_9_REV
&&
1837 case MESA_FORMAT_R11G11B10_FLOAT
:
1838 return format
== GL_RGB
&& type
== GL_UNSIGNED_INT_10F_11F_11F_REV
&&
1841 case MESA_FORMAT_Z_FLOAT32
:
1842 return format
== GL_DEPTH_COMPONENT
&& type
== GL_FLOAT
&& !swapBytes
;
1844 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
1845 return format
== GL_DEPTH_STENCIL
&&
1846 type
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
&& !swapBytes
;
1848 case MESA_FORMAT_B4G4R4X4_UNORM
:
1849 case MESA_FORMAT_B5G5R5X1_UNORM
:
1850 case MESA_FORMAT_R8G8B8X8_SNORM
:
1851 case MESA_FORMAT_R8G8B8X8_SRGB
:
1852 case MESA_FORMAT_RGBX_UINT8
:
1853 case MESA_FORMAT_RGBX_SINT8
:
1854 case MESA_FORMAT_B10G10R10X2_UNORM
:
1855 case MESA_FORMAT_RGBX_UNORM16
:
1856 case MESA_FORMAT_RGBX_SNORM16
:
1857 case MESA_FORMAT_RGBX_FLOAT16
:
1858 case MESA_FORMAT_RGBX_UINT16
:
1859 case MESA_FORMAT_RGBX_SINT16
:
1860 case MESA_FORMAT_RGBX_FLOAT32
:
1861 case MESA_FORMAT_RGBX_UINT32
:
1862 case MESA_FORMAT_RGBX_SINT32
:
1865 case MESA_FORMAT_R10G10B10A2_UNORM
:
1866 return format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1869 case MESA_FORMAT_G8R8_SNORM
:
1870 return format
== GL_RG
&& type
== GL_BYTE
&& !littleEndian
&&
1873 case MESA_FORMAT_G16R16_SNORM
:
1874 return format
== GL_RG
&& type
== GL_SHORT
&& !littleEndian
&&
1877 case MESA_FORMAT_B8G8R8X8_SRGB
: