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"
31 #include "c11/threads.h"
32 #include "util/hash_table.h"
35 * Information about texture formats.
41 /** text name for debugging */
44 enum mesa_format_layout Layout
;
47 * Base format is one of GL_RED, GL_RG, GL_RGB, GL_RGBA, GL_ALPHA,
48 * GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY, GL_YCBCR_MESA,
49 * GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL.
54 * Logical data type: one of GL_UNSIGNED_NORMALIZED, GL_SIGNED_NORMALIZED,
55 * GL_UNSIGNED_INT, GL_INT, GL_FLOAT.
63 GLubyte LuminanceBits
;
64 GLubyte IntensityBits
;
71 * To describe compressed formats. If not compressed, Width=Height=1.
73 GLubyte BlockWidth
, BlockHeight
;
74 GLubyte BytesPerBlock
;
77 mesa_array_format ArrayFormat
;
80 #include "format_info.h"
82 static const struct gl_format_info
*
83 _mesa_get_format_info(mesa_format format
)
85 const struct gl_format_info
*info
= &format_info
[format
];
86 STATIC_ASSERT(ARRAY_SIZE(format_info
) == MESA_FORMAT_COUNT
);
87 assert(info
->Name
== format
);
92 /** Return string name of format (for debugging) */
94 _mesa_get_format_name(mesa_format format
)
96 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
103 * Return bytes needed to store a block of pixels in the given format.
104 * Normally, a block is 1x1 (a single pixel). But for compressed formats
105 * a block may be 4x4 or 8x4, etc.
107 * Note: not GLuint, so as not to coerce math to unsigned. cf. fdo #37351
110 _mesa_get_format_bytes(mesa_format format
)
112 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
113 assert(info
->BytesPerBlock
);
114 assert(info
->BytesPerBlock
<= MAX_PIXEL_BYTES
||
115 _mesa_is_format_compressed(format
));
116 return info
->BytesPerBlock
;
121 * Return bits per component for the given format.
122 * \param format one of MESA_FORMAT_x
123 * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc.
126 _mesa_get_format_bits(mesa_format format
, GLenum pname
)
128 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
132 case GL_TEXTURE_RED_SIZE
:
133 case GL_RENDERBUFFER_RED_SIZE_EXT
:
134 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
:
135 return info
->RedBits
;
137 case GL_TEXTURE_GREEN_SIZE
:
138 case GL_RENDERBUFFER_GREEN_SIZE_EXT
:
139 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
:
140 return info
->GreenBits
;
142 case GL_TEXTURE_BLUE_SIZE
:
143 case GL_RENDERBUFFER_BLUE_SIZE_EXT
:
144 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
:
145 return info
->BlueBits
;
147 case GL_TEXTURE_ALPHA_SIZE
:
148 case GL_RENDERBUFFER_ALPHA_SIZE_EXT
:
149 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
:
150 return info
->AlphaBits
;
151 case GL_TEXTURE_INTENSITY_SIZE
:
152 return info
->IntensityBits
;
153 case GL_TEXTURE_LUMINANCE_SIZE
:
154 return info
->LuminanceBits
;
158 case GL_TEXTURE_DEPTH_SIZE_ARB
:
159 case GL_RENDERBUFFER_DEPTH_SIZE_EXT
:
160 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
:
161 return info
->DepthBits
;
162 case GL_STENCIL_BITS
:
163 case GL_TEXTURE_STENCIL_SIZE_EXT
:
164 case GL_RENDERBUFFER_STENCIL_SIZE_EXT
:
165 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
:
166 return info
->StencilBits
;
168 _mesa_problem(NULL
, "bad pname in _mesa_get_format_bits()");
175 _mesa_get_format_max_bits(mesa_format format
)
177 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
178 GLuint max
= MAX2(info
->RedBits
, info
->GreenBits
);
179 max
= MAX2(max
, info
->BlueBits
);
180 max
= MAX2(max
, info
->AlphaBits
);
181 max
= MAX2(max
, info
->LuminanceBits
);
182 max
= MAX2(max
, info
->IntensityBits
);
183 max
= MAX2(max
, info
->DepthBits
);
184 max
= MAX2(max
, info
->StencilBits
);
190 * Return the layout type of the given format.
191 * The return value will be one of:
192 * MESA_FORMAT_LAYOUT_ARRAY
193 * MESA_FORMAT_LAYOUT_PACKED
194 * MESA_FORMAT_LAYOUT_S3TC
195 * MESA_FORMAT_LAYOUT_RGTC
196 * MESA_FORMAT_LAYOUT_FXT1
197 * MESA_FORMAT_LAYOUT_ETC1
198 * MESA_FORMAT_LAYOUT_ETC2
199 * MESA_FORMAT_LAYOUT_BPTC
200 * MESA_FORMAT_LAYOUT_OTHER
202 extern enum mesa_format_layout
203 _mesa_get_format_layout(mesa_format format
)
205 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
211 * Return the data type (or more specifically, the data representation)
212 * for the given format.
213 * The return value will be one of:
214 * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1]
215 * GL_SIGNED_NORMALIZED = signed int representing [-1, 1]
216 * GL_UNSIGNED_INT = an ordinary unsigned integer
217 * GL_INT = an ordinary signed integer
218 * GL_FLOAT = an ordinary float
221 _mesa_get_format_datatype(mesa_format format
)
223 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
224 return info
->DataType
;
228 get_base_format_for_array_format(mesa_array_format format
)
233 _mesa_array_format_get_swizzle(format
, swizzle
);
234 num_channels
= _mesa_array_format_get_num_channels(format
);
236 switch (num_channels
) {
238 /* FIXME: RGBX formats have 4 channels, but their base format is GL_RGB.
239 * This is not really a problem for now because we only create array
240 * formats from GL format/type combinations, and these cannot specify
247 if (swizzle
[0] == 0 &&
251 return GL_LUMINANCE_ALPHA
;
252 if (swizzle
[0] == 1 &&
256 return GL_LUMINANCE_ALPHA
;
257 if (swizzle
[0] == 0 &&
262 if (swizzle
[0] == 1 &&
269 if (swizzle
[0] == 0 &&
274 if (swizzle
[0] == 0 &&
279 if (swizzle
[0] <= MESA_FORMAT_SWIZZLE_W
)
281 if (swizzle
[1] <= MESA_FORMAT_SWIZZLE_W
)
283 if (swizzle
[2] <= MESA_FORMAT_SWIZZLE_W
)
285 if (swizzle
[3] <= MESA_FORMAT_SWIZZLE_W
)
290 unreachable("Unsupported format");
294 * Return the basic format for the given type. The result will be one of
295 * GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY,
296 * GL_YCBCR_MESA, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL.
297 * This functions accepts a mesa_format or a mesa_array_format.
300 _mesa_get_format_base_format(uint32_t format
)
302 if (!_mesa_format_is_mesa_array_format(format
)) {
303 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
304 return info
->BaseFormat
;
306 return get_base_format_for_array_format(format
);
312 * Return the block size (in pixels) for the given format. Normally
313 * the block size is 1x1. But compressed formats will have block sizes
314 * of 4x4 or 8x4 pixels, etc.
315 * \param bw returns block width in pixels
316 * \param bh returns block height in pixels
319 _mesa_get_format_block_size(mesa_format format
, GLuint
*bw
, GLuint
*bh
)
321 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
322 *bw
= info
->BlockWidth
;
323 *bh
= info
->BlockHeight
;
328 * Returns the an array of four numbers representing the transformation
329 * from the RGBA or SZ colorspace to the given format. For array formats,
330 * the i'th RGBA component is given by:
332 * if (swizzle[i] <= MESA_FORMAT_SWIZZLE_W)
333 * comp = data[swizzle[i]];
334 * else if (swizzle[i] == MESA_FORMAT_SWIZZLE_ZERO)
336 * else if (swizzle[i] == MESA_FORMAT_SWIZZLE_ONE)
338 * else if (swizzle[i] == MESA_FORMAT_SWIZZLE_NONE)
339 * // data does not contain a channel of this format
341 * For packed formats, the swizzle gives the number of components left of
342 * the least significant bit.
344 * Compressed formats have no swizzle.
347 _mesa_get_format_swizzle(mesa_format format
, uint8_t swizzle_out
[4])
349 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
350 memcpy(swizzle_out
, info
->Swizzle
, sizeof(info
->Swizzle
));
354 _mesa_array_format_flip_channels(mesa_array_format format
)
359 num_channels
= _mesa_array_format_get_num_channels(format
);
360 _mesa_array_format_get_swizzle(format
, swizzle
);
362 if (num_channels
== 1)
365 if (num_channels
== 2) {
366 /* Assert that the swizzle makes sense for 2 channels */
367 for (unsigned i
= 0; i
< 4; i
++)
368 assert(swizzle
[i
] != 2 && swizzle
[i
] != 3);
370 static const uint8_t flip_xy
[6] = { 1, 0, 2, 3, 4, 5 };
371 _mesa_array_format_set_swizzle(&format
,
372 flip_xy
[swizzle
[0]], flip_xy
[swizzle
[1]],
373 flip_xy
[swizzle
[2]], flip_xy
[swizzle
[3]]);
377 if (num_channels
== 4) {
378 static const uint8_t flip
[6] = { 3, 2, 1, 0, 4, 5 };
379 _mesa_array_format_set_swizzle(&format
,
380 flip
[swizzle
[0]], flip
[swizzle
[1]],
381 flip
[swizzle
[2]], flip
[swizzle
[3]]);
385 unreachable("Invalid array format");
389 _mesa_format_to_array_format(mesa_format format
)
391 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
392 if (info
->ArrayFormat
&& !_mesa_little_endian() &&
393 info
->Layout
== MESA_FORMAT_LAYOUT_PACKED
)
394 return _mesa_array_format_flip_channels(info
->ArrayFormat
);
396 return info
->ArrayFormat
;
399 static struct hash_table
*format_array_format_table
;
400 static once_flag format_array_format_table_exists
= ONCE_FLAG_INIT
;
403 array_formats_equal(const void *a
, const void *b
)
405 return (intptr_t)a
== (intptr_t)b
;
409 format_array_format_table_init(void)
411 const struct gl_format_info
*info
;
412 mesa_array_format array_format
;
415 format_array_format_table
= _mesa_hash_table_create(NULL
, NULL
,
416 array_formats_equal
);
418 if (!format_array_format_table
) {
419 _mesa_error_no_memory(__func__
);
423 for (f
= 1; f
< MESA_FORMAT_COUNT
; ++f
) {
424 info
= _mesa_get_format_info(f
);
425 if (!info
->ArrayFormat
)
428 if (_mesa_little_endian()) {
429 array_format
= info
->ArrayFormat
;
431 array_format
= _mesa_array_format_flip_channels(info
->ArrayFormat
);
434 /* This can happen and does for some of the BGR formats. Let's take
435 * the first one in the list.
437 if (_mesa_hash_table_search_pre_hashed(format_array_format_table
,
439 (void *)(intptr_t)array_format
))
442 _mesa_hash_table_insert_pre_hashed(format_array_format_table
,
444 (void *)(intptr_t)array_format
,
445 (void *)(intptr_t)f
);
450 _mesa_format_from_array_format(uint32_t array_format
)
452 struct hash_entry
*entry
;
454 assert(_mesa_format_is_mesa_array_format(array_format
));
456 call_once(&format_array_format_table_exists
, format_array_format_table_init
);
458 if (!format_array_format_table
) {
459 static const once_flag once_flag_init
= ONCE_FLAG_INIT
;
460 format_array_format_table_exists
= once_flag_init
;
461 return MESA_FORMAT_NONE
;
464 entry
= _mesa_hash_table_search_pre_hashed(format_array_format_table
,
466 (void *)(intptr_t)array_format
);
468 return (intptr_t)entry
->data
;
470 return MESA_FORMAT_NONE
;
473 /** Is the given format a compressed format? */
475 _mesa_is_format_compressed(mesa_format format
)
477 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
478 return info
->BlockWidth
> 1 || info
->BlockHeight
> 1;
483 * Determine if the given format represents a packed depth/stencil buffer.
486 _mesa_is_format_packed_depth_stencil(mesa_format format
)
488 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
490 return info
->BaseFormat
== GL_DEPTH_STENCIL
;
495 * Is the given format a signed/unsigned integer color format?
498 _mesa_is_format_integer_color(mesa_format format
)
500 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
501 return (info
->DataType
== GL_INT
|| info
->DataType
== GL_UNSIGNED_INT
) &&
502 info
->BaseFormat
!= GL_DEPTH_COMPONENT
&&
503 info
->BaseFormat
!= GL_DEPTH_STENCIL
&&
504 info
->BaseFormat
!= GL_STENCIL_INDEX
;
509 * Is the given format an unsigned integer format?
512 _mesa_is_format_unsigned(mesa_format format
)
514 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
515 return _mesa_is_type_unsigned(info
->DataType
);
520 * Does the given format store signed values?
523 _mesa_is_format_signed(mesa_format format
)
525 if (format
== MESA_FORMAT_R11G11B10_FLOAT
||
526 format
== MESA_FORMAT_R9G9B9E5_FLOAT
) {
527 /* these packed float formats only store unsigned values */
531 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
532 return (info
->DataType
== GL_SIGNED_NORMALIZED
||
533 info
->DataType
== GL_INT
||
534 info
->DataType
== GL_FLOAT
);
539 * Is the given format an integer format?
542 _mesa_is_format_integer(mesa_format format
)
544 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
545 return (info
->DataType
== GL_INT
|| info
->DataType
== GL_UNSIGNED_INT
);
550 * Return true if the given format is a color format.
553 _mesa_is_format_color_format(mesa_format format
)
555 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
556 switch (info
->BaseFormat
) {
557 case GL_DEPTH_COMPONENT
:
558 case GL_STENCIL_INDEX
:
559 case GL_DEPTH_STENCIL
:
568 * Return color encoding for given format.
569 * \return GL_LINEAR or GL_SRGB
572 _mesa_get_format_color_encoding(mesa_format format
)
574 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
575 return info
->IsSRGBFormat
? GL_SRGB
: GL_LINEAR
;
580 * Return TRUE if format is an ETC2 compressed format specified
581 * by GL_ARB_ES3_compatibility.
584 _mesa_is_format_etc2(mesa_format format
)
587 case MESA_FORMAT_ETC2_RGB8
:
588 case MESA_FORMAT_ETC2_SRGB8
:
589 case MESA_FORMAT_ETC2_RGBA8_EAC
:
590 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
591 case MESA_FORMAT_ETC2_R11_EAC
:
592 case MESA_FORMAT_ETC2_RG11_EAC
:
593 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
594 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
595 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
596 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
605 * For an sRGB format, return the corresponding linear color space format.
606 * For non-sRGB formats, return the format as-is.
609 _mesa_get_srgb_format_linear(mesa_format format
)
612 case MESA_FORMAT_BGR_SRGB8
:
613 format
= MESA_FORMAT_BGR_UNORM8
;
615 case MESA_FORMAT_A8B8G8R8_SRGB
:
616 format
= MESA_FORMAT_A8B8G8R8_UNORM
;
618 case MESA_FORMAT_B8G8R8A8_SRGB
:
619 format
= MESA_FORMAT_B8G8R8A8_UNORM
;
621 case MESA_FORMAT_A8R8G8B8_SRGB
:
622 format
= MESA_FORMAT_A8R8G8B8_UNORM
;
624 case MESA_FORMAT_R8G8B8A8_SRGB
:
625 format
= MESA_FORMAT_R8G8B8A8_UNORM
;
627 case MESA_FORMAT_L_SRGB8
:
628 format
= MESA_FORMAT_L_UNORM8
;
630 case MESA_FORMAT_L8A8_SRGB
:
631 format
= MESA_FORMAT_L8A8_UNORM
;
633 case MESA_FORMAT_A8L8_SRGB
:
634 format
= MESA_FORMAT_A8L8_UNORM
;
636 case MESA_FORMAT_SRGB_DXT1
:
637 format
= MESA_FORMAT_RGB_DXT1
;
639 case MESA_FORMAT_SRGBA_DXT1
:
640 format
= MESA_FORMAT_RGBA_DXT1
;
642 case MESA_FORMAT_SRGBA_DXT3
:
643 format
= MESA_FORMAT_RGBA_DXT3
;
645 case MESA_FORMAT_SRGBA_DXT5
:
646 format
= MESA_FORMAT_RGBA_DXT5
;
648 case MESA_FORMAT_R8G8B8X8_SRGB
:
649 format
= MESA_FORMAT_R8G8B8X8_UNORM
;
651 case MESA_FORMAT_X8B8G8R8_SRGB
:
652 format
= MESA_FORMAT_X8B8G8R8_UNORM
;
654 case MESA_FORMAT_ETC2_SRGB8
:
655 format
= MESA_FORMAT_ETC2_RGB8
;
657 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
658 format
= MESA_FORMAT_ETC2_RGBA8_EAC
;
660 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
661 format
= MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
;
663 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
664 format
= MESA_FORMAT_BPTC_RGBA_UNORM
;
666 case MESA_FORMAT_B8G8R8X8_SRGB
:
667 format
= MESA_FORMAT_B8G8R8X8_UNORM
;
669 case MESA_FORMAT_X8R8G8B8_SRGB
:
670 format
= MESA_FORMAT_X8R8G8B8_UNORM
;
680 * If the given format is a compressed format, return a corresponding
681 * uncompressed format.
684 _mesa_get_uncompressed_format(mesa_format format
)
687 case MESA_FORMAT_RGB_FXT1
:
688 return MESA_FORMAT_BGR_UNORM8
;
689 case MESA_FORMAT_RGBA_FXT1
:
690 return MESA_FORMAT_A8B8G8R8_UNORM
;
691 case MESA_FORMAT_RGB_DXT1
:
692 case MESA_FORMAT_SRGB_DXT1
:
693 return MESA_FORMAT_BGR_UNORM8
;
694 case MESA_FORMAT_RGBA_DXT1
:
695 case MESA_FORMAT_SRGBA_DXT1
:
696 return MESA_FORMAT_A8B8G8R8_UNORM
;
697 case MESA_FORMAT_RGBA_DXT3
:
698 case MESA_FORMAT_SRGBA_DXT3
:
699 return MESA_FORMAT_A8B8G8R8_UNORM
;
700 case MESA_FORMAT_RGBA_DXT5
:
701 case MESA_FORMAT_SRGBA_DXT5
:
702 return MESA_FORMAT_A8B8G8R8_UNORM
;
703 case MESA_FORMAT_R_RGTC1_UNORM
:
704 return MESA_FORMAT_R_UNORM8
;
705 case MESA_FORMAT_R_RGTC1_SNORM
:
706 return MESA_FORMAT_R_SNORM8
;
707 case MESA_FORMAT_RG_RGTC2_UNORM
:
708 return MESA_FORMAT_R8G8_UNORM
;
709 case MESA_FORMAT_RG_RGTC2_SNORM
:
710 return MESA_FORMAT_R8G8_SNORM
;
711 case MESA_FORMAT_L_LATC1_UNORM
:
712 return MESA_FORMAT_L_UNORM8
;
713 case MESA_FORMAT_L_LATC1_SNORM
:
714 return MESA_FORMAT_L_SNORM8
;
715 case MESA_FORMAT_LA_LATC2_UNORM
:
716 return MESA_FORMAT_L8A8_UNORM
;
717 case MESA_FORMAT_LA_LATC2_SNORM
:
718 return MESA_FORMAT_L8A8_SNORM
;
719 case MESA_FORMAT_ETC1_RGB8
:
720 case MESA_FORMAT_ETC2_RGB8
:
721 case MESA_FORMAT_ETC2_SRGB8
:
722 return MESA_FORMAT_BGR_UNORM8
;
723 case MESA_FORMAT_ETC2_RGBA8_EAC
:
724 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
725 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
726 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
727 return MESA_FORMAT_A8B8G8R8_UNORM
;
728 case MESA_FORMAT_ETC2_R11_EAC
:
729 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
730 return MESA_FORMAT_R_UNORM16
;
731 case MESA_FORMAT_ETC2_RG11_EAC
:
732 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
733 return MESA_FORMAT_R16G16_UNORM
;
734 case MESA_FORMAT_BPTC_RGBA_UNORM
:
735 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
736 return MESA_FORMAT_A8B8G8R8_UNORM
;
737 case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
:
738 case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
:
739 return MESA_FORMAT_RGB_FLOAT32
;
742 assert(!_mesa_is_format_compressed(format
));
750 _mesa_format_num_components(mesa_format format
)
752 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
753 return ((info
->RedBits
> 0) +
754 (info
->GreenBits
> 0) +
755 (info
->BlueBits
> 0) +
756 (info
->AlphaBits
> 0) +
757 (info
->LuminanceBits
> 0) +
758 (info
->IntensityBits
> 0) +
759 (info
->DepthBits
> 0) +
760 (info
->StencilBits
> 0));
765 * Returns true if a color format has data stored in the R/G/B/A channels,
766 * given an index from 0 to 3.
769 _mesa_format_has_color_component(mesa_format format
, int component
)
771 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
773 assert(info
->BaseFormat
!= GL_DEPTH_COMPONENT
&&
774 info
->BaseFormat
!= GL_DEPTH_STENCIL
&&
775 info
->BaseFormat
!= GL_STENCIL_INDEX
);
779 return (info
->RedBits
+ info
->IntensityBits
+ info
->LuminanceBits
) > 0;
781 return (info
->GreenBits
+ info
->IntensityBits
+ info
->LuminanceBits
) > 0;
783 return (info
->BlueBits
+ info
->IntensityBits
+ info
->LuminanceBits
) > 0;
785 return (info
->AlphaBits
+ info
->IntensityBits
) > 0;
787 assert(!"Invalid color component: must be 0..3");
794 * Return number of bytes needed to store an image of the given size
795 * in the given format.
798 _mesa_format_image_size(mesa_format format
, GLsizei width
,
799 GLsizei height
, GLsizei depth
)
801 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
802 /* Strictly speaking, a conditional isn't needed here */
803 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
804 /* compressed format (2D only for now) */
805 const GLuint bw
= info
->BlockWidth
, bh
= info
->BlockHeight
;
806 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
807 const GLuint hblocks
= (height
+ bh
- 1) / bh
;
808 const GLuint sz
= wblocks
* hblocks
* info
->BytesPerBlock
;
813 const GLuint sz
= width
* height
* depth
* info
->BytesPerBlock
;
820 * Same as _mesa_format_image_size() but returns a 64-bit value to
821 * accommodate very large textures.
824 _mesa_format_image_size64(mesa_format format
, GLsizei width
,
825 GLsizei height
, GLsizei depth
)
827 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
828 /* Strictly speaking, a conditional isn't needed here */
829 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
830 /* compressed format (2D only for now) */
831 const uint64_t bw
= info
->BlockWidth
, bh
= info
->BlockHeight
;
832 const uint64_t wblocks
= (width
+ bw
- 1) / bw
;
833 const uint64_t hblocks
= (height
+ bh
- 1) / bh
;
834 const uint64_t sz
= wblocks
* hblocks
* info
->BytesPerBlock
;
839 const uint64_t sz
= ((uint64_t) width
*
842 info
->BytesPerBlock
);
850 _mesa_format_row_stride(mesa_format format
, GLsizei width
)
852 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
853 /* Strictly speaking, a conditional isn't needed here */
854 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
855 /* compressed format */
856 const GLuint bw
= info
->BlockWidth
;
857 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
858 const GLint stride
= wblocks
* info
->BytesPerBlock
;
862 const GLint stride
= width
* info
->BytesPerBlock
;
870 * Return datatype and number of components per texel for the given
871 * uncompressed mesa_format. Only used for mipmap generation code.
874 _mesa_uncompressed_format_to_type_and_comps(mesa_format format
,
875 GLenum
*datatype
, GLuint
*comps
)
878 case MESA_FORMAT_A8B8G8R8_UNORM
:
879 case MESA_FORMAT_R8G8B8A8_UNORM
:
880 case MESA_FORMAT_B8G8R8A8_UNORM
:
881 case MESA_FORMAT_A8R8G8B8_UNORM
:
882 case MESA_FORMAT_X8B8G8R8_UNORM
:
883 case MESA_FORMAT_R8G8B8X8_UNORM
:
884 case MESA_FORMAT_B8G8R8X8_UNORM
:
885 case MESA_FORMAT_X8R8G8B8_UNORM
:
886 *datatype
= GL_UNSIGNED_BYTE
;
889 case MESA_FORMAT_BGR_UNORM8
:
890 case MESA_FORMAT_RGB_UNORM8
:
891 *datatype
= GL_UNSIGNED_BYTE
;
894 case MESA_FORMAT_B5G6R5_UNORM
:
895 case MESA_FORMAT_R5G6B5_UNORM
:
896 *datatype
= GL_UNSIGNED_SHORT_5_6_5
;
900 case MESA_FORMAT_B4G4R4A4_UNORM
:
901 case MESA_FORMAT_A4R4G4B4_UNORM
:
902 case MESA_FORMAT_B4G4R4X4_UNORM
:
903 *datatype
= GL_UNSIGNED_SHORT_4_4_4_4
;
907 case MESA_FORMAT_B5G5R5A1_UNORM
:
908 case MESA_FORMAT_A1R5G5B5_UNORM
:
909 case MESA_FORMAT_B5G5R5X1_UNORM
:
910 *datatype
= GL_UNSIGNED_SHORT_1_5_5_5_REV
;
914 case MESA_FORMAT_B10G10R10A2_UNORM
:
915 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
919 case MESA_FORMAT_A1B5G5R5_UNORM
:
920 *datatype
= GL_UNSIGNED_SHORT_5_5_5_1
;
924 case MESA_FORMAT_L4A4_UNORM
:
925 *datatype
= MESA_UNSIGNED_BYTE_4_4
;
929 case MESA_FORMAT_L8A8_UNORM
:
930 case MESA_FORMAT_A8L8_UNORM
:
931 case MESA_FORMAT_R8G8_UNORM
:
932 case MESA_FORMAT_G8R8_UNORM
:
933 *datatype
= GL_UNSIGNED_BYTE
;
937 case MESA_FORMAT_L16A16_UNORM
:
938 case MESA_FORMAT_A16L16_UNORM
:
939 case MESA_FORMAT_R16G16_UNORM
:
940 case MESA_FORMAT_G16R16_UNORM
:
941 *datatype
= GL_UNSIGNED_SHORT
;
945 case MESA_FORMAT_R_UNORM16
:
946 case MESA_FORMAT_A_UNORM16
:
947 case MESA_FORMAT_L_UNORM16
:
948 case MESA_FORMAT_I_UNORM16
:
949 *datatype
= GL_UNSIGNED_SHORT
;
953 case MESA_FORMAT_R3G3B2_UNORM
:
954 *datatype
= GL_UNSIGNED_BYTE_2_3_3_REV
;
957 case MESA_FORMAT_A4B4G4R4_UNORM
:
958 *datatype
= GL_UNSIGNED_SHORT_4_4_4_4
;
962 case MESA_FORMAT_R4G4B4A4_UNORM
:
963 *datatype
= GL_UNSIGNED_SHORT_4_4_4_4
;
966 case MESA_FORMAT_R5G5B5A1_UNORM
:
967 *datatype
= GL_UNSIGNED_SHORT_1_5_5_5_REV
;
970 case MESA_FORMAT_A2B10G10R10_UNORM
:
971 case MESA_FORMAT_A2B10G10R10_UINT
:
972 *datatype
= GL_UNSIGNED_INT_10_10_10_2
;
975 case MESA_FORMAT_A2R10G10B10_UNORM
:
976 case MESA_FORMAT_A2R10G10B10_UINT
:
977 *datatype
= GL_UNSIGNED_INT_10_10_10_2
;
981 case MESA_FORMAT_B2G3R3_UNORM
:
982 *datatype
= GL_UNSIGNED_BYTE_3_3_2
;
986 case MESA_FORMAT_A_UNORM8
:
987 case MESA_FORMAT_L_UNORM8
:
988 case MESA_FORMAT_I_UNORM8
:
989 case MESA_FORMAT_R_UNORM8
:
990 case MESA_FORMAT_S_UINT8
:
991 *datatype
= GL_UNSIGNED_BYTE
;
995 case MESA_FORMAT_YCBCR
:
996 case MESA_FORMAT_YCBCR_REV
:
997 *datatype
= GL_UNSIGNED_SHORT
;
1001 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
1002 *datatype
= GL_UNSIGNED_INT_24_8_MESA
;
1006 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
1007 *datatype
= GL_UNSIGNED_INT_8_24_REV_MESA
;
1011 case MESA_FORMAT_Z_UNORM16
:
1012 *datatype
= GL_UNSIGNED_SHORT
;
1016 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
1017 *datatype
= GL_UNSIGNED_INT
;
1021 case MESA_FORMAT_X8_UINT_Z24_UNORM
:
1022 *datatype
= GL_UNSIGNED_INT
;
1026 case MESA_FORMAT_Z_UNORM32
:
1027 *datatype
= GL_UNSIGNED_INT
;
1031 case MESA_FORMAT_Z_FLOAT32
:
1032 *datatype
= GL_FLOAT
;
1036 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
1037 *datatype
= GL_FLOAT_32_UNSIGNED_INT_24_8_REV
;
1041 case MESA_FORMAT_R_SNORM8
:
1042 case MESA_FORMAT_A_SNORM8
:
1043 case MESA_FORMAT_L_SNORM8
:
1044 case MESA_FORMAT_I_SNORM8
:
1045 *datatype
= GL_BYTE
;
1048 case MESA_FORMAT_R8G8_SNORM
:
1049 case MESA_FORMAT_L8A8_SNORM
:
1050 case MESA_FORMAT_A8L8_SNORM
:
1051 *datatype
= GL_BYTE
;
1054 case MESA_FORMAT_A8B8G8R8_SNORM
:
1055 case MESA_FORMAT_R8G8B8A8_SNORM
:
1056 case MESA_FORMAT_X8B8G8R8_SNORM
:
1057 *datatype
= GL_BYTE
;
1061 case MESA_FORMAT_RGBA_UNORM16
:
1062 *datatype
= GL_UNSIGNED_SHORT
;
1066 case MESA_FORMAT_R_SNORM16
:
1067 case MESA_FORMAT_A_SNORM16
:
1068 case MESA_FORMAT_L_SNORM16
:
1069 case MESA_FORMAT_I_SNORM16
:
1070 *datatype
= GL_SHORT
;
1073 case MESA_FORMAT_R16G16_SNORM
:
1074 case MESA_FORMAT_LA_SNORM16
:
1075 *datatype
= GL_SHORT
;
1078 case MESA_FORMAT_RGB_SNORM16
:
1079 *datatype
= GL_SHORT
;
1082 case MESA_FORMAT_RGBA_SNORM16
:
1083 *datatype
= GL_SHORT
;
1087 case MESA_FORMAT_BGR_SRGB8
:
1088 *datatype
= GL_UNSIGNED_BYTE
;
1091 case MESA_FORMAT_A8B8G8R8_SRGB
:
1092 case MESA_FORMAT_B8G8R8A8_SRGB
:
1093 case MESA_FORMAT_A8R8G8B8_SRGB
:
1094 case MESA_FORMAT_R8G8B8A8_SRGB
:
1095 *datatype
= GL_UNSIGNED_BYTE
;
1098 case MESA_FORMAT_L_SRGB8
:
1099 *datatype
= GL_UNSIGNED_BYTE
;
1102 case MESA_FORMAT_L8A8_SRGB
:
1103 case MESA_FORMAT_A8L8_SRGB
:
1104 *datatype
= GL_UNSIGNED_BYTE
;
1108 case MESA_FORMAT_RGBA_FLOAT32
:
1109 *datatype
= GL_FLOAT
;
1112 case MESA_FORMAT_RGBA_FLOAT16
:
1113 *datatype
= GL_HALF_FLOAT_ARB
;
1116 case MESA_FORMAT_RGB_FLOAT32
:
1117 *datatype
= GL_FLOAT
;
1120 case MESA_FORMAT_RGB_FLOAT16
:
1121 *datatype
= GL_HALF_FLOAT_ARB
;
1124 case MESA_FORMAT_LA_FLOAT32
:
1125 case MESA_FORMAT_RG_FLOAT32
:
1126 *datatype
= GL_FLOAT
;
1129 case MESA_FORMAT_LA_FLOAT16
:
1130 case MESA_FORMAT_RG_FLOAT16
:
1131 *datatype
= GL_HALF_FLOAT_ARB
;
1134 case MESA_FORMAT_A_FLOAT32
:
1135 case MESA_FORMAT_L_FLOAT32
:
1136 case MESA_FORMAT_I_FLOAT32
:
1137 case MESA_FORMAT_R_FLOAT32
:
1138 *datatype
= GL_FLOAT
;
1141 case MESA_FORMAT_A_FLOAT16
:
1142 case MESA_FORMAT_L_FLOAT16
:
1143 case MESA_FORMAT_I_FLOAT16
:
1144 case MESA_FORMAT_R_FLOAT16
:
1145 *datatype
= GL_HALF_FLOAT_ARB
;
1149 case MESA_FORMAT_A_UINT8
:
1150 case MESA_FORMAT_L_UINT8
:
1151 case MESA_FORMAT_I_UINT8
:
1152 *datatype
= GL_UNSIGNED_BYTE
;
1155 case MESA_FORMAT_LA_UINT8
:
1156 *datatype
= GL_UNSIGNED_BYTE
;
1160 case MESA_FORMAT_A_UINT16
:
1161 case MESA_FORMAT_L_UINT16
:
1162 case MESA_FORMAT_I_UINT16
:
1163 *datatype
= GL_UNSIGNED_SHORT
;
1166 case MESA_FORMAT_LA_UINT16
:
1167 *datatype
= GL_UNSIGNED_SHORT
;
1170 case MESA_FORMAT_A_UINT32
:
1171 case MESA_FORMAT_L_UINT32
:
1172 case MESA_FORMAT_I_UINT32
:
1173 *datatype
= GL_UNSIGNED_INT
;
1176 case MESA_FORMAT_LA_UINT32
:
1177 *datatype
= GL_UNSIGNED_INT
;
1180 case MESA_FORMAT_A_SINT8
:
1181 case MESA_FORMAT_L_SINT8
:
1182 case MESA_FORMAT_I_SINT8
:
1183 *datatype
= GL_BYTE
;
1186 case MESA_FORMAT_LA_SINT8
:
1187 *datatype
= GL_BYTE
;
1191 case MESA_FORMAT_A_SINT16
:
1192 case MESA_FORMAT_L_SINT16
:
1193 case MESA_FORMAT_I_SINT16
:
1194 *datatype
= GL_SHORT
;
1197 case MESA_FORMAT_LA_SINT16
:
1198 *datatype
= GL_SHORT
;
1202 case MESA_FORMAT_A_SINT32
:
1203 case MESA_FORMAT_L_SINT32
:
1204 case MESA_FORMAT_I_SINT32
:
1208 case MESA_FORMAT_LA_SINT32
:
1213 case MESA_FORMAT_R_SINT8
:
1214 *datatype
= GL_BYTE
;
1217 case MESA_FORMAT_RG_SINT8
:
1218 *datatype
= GL_BYTE
;
1221 case MESA_FORMAT_RGB_SINT8
:
1222 *datatype
= GL_BYTE
;
1225 case MESA_FORMAT_RGBA_SINT8
:
1226 *datatype
= GL_BYTE
;
1229 case MESA_FORMAT_R_SINT16
:
1230 *datatype
= GL_SHORT
;
1233 case MESA_FORMAT_RG_SINT16
:
1234 *datatype
= GL_SHORT
;
1237 case MESA_FORMAT_RGB_SINT16
:
1238 *datatype
= GL_SHORT
;
1241 case MESA_FORMAT_RGBA_SINT16
:
1242 *datatype
= GL_SHORT
;
1245 case MESA_FORMAT_R_SINT32
:
1249 case MESA_FORMAT_RG_SINT32
:
1253 case MESA_FORMAT_RGB_SINT32
:
1257 case MESA_FORMAT_RGBA_SINT32
:
1263 * \name Non-normalized unsigned integer formats.
1265 case MESA_FORMAT_R_UINT8
:
1266 *datatype
= GL_UNSIGNED_BYTE
;
1269 case MESA_FORMAT_RG_UINT8
:
1270 *datatype
= GL_UNSIGNED_BYTE
;
1273 case MESA_FORMAT_RGB_UINT8
:
1274 *datatype
= GL_UNSIGNED_BYTE
;
1277 case MESA_FORMAT_RGBA_UINT8
:
1278 *datatype
= GL_UNSIGNED_BYTE
;
1281 case MESA_FORMAT_R_UINT16
:
1282 *datatype
= GL_UNSIGNED_SHORT
;
1285 case MESA_FORMAT_RG_UINT16
:
1286 *datatype
= GL_UNSIGNED_SHORT
;
1289 case MESA_FORMAT_RGB_UINT16
:
1290 *datatype
= GL_UNSIGNED_SHORT
;
1293 case MESA_FORMAT_RGBA_UINT16
:
1294 *datatype
= GL_UNSIGNED_SHORT
;
1297 case MESA_FORMAT_R_UINT32
:
1298 *datatype
= GL_UNSIGNED_INT
;
1301 case MESA_FORMAT_RG_UINT32
:
1302 *datatype
= GL_UNSIGNED_INT
;
1305 case MESA_FORMAT_RGB_UINT32
:
1306 *datatype
= GL_UNSIGNED_INT
;
1309 case MESA_FORMAT_RGBA_UINT32
:
1310 *datatype
= GL_UNSIGNED_INT
;
1314 case MESA_FORMAT_R9G9B9E5_FLOAT
:
1315 *datatype
= GL_UNSIGNED_INT_5_9_9_9_REV
;
1319 case MESA_FORMAT_R11G11B10_FLOAT
:
1320 *datatype
= GL_UNSIGNED_INT_10F_11F_11F_REV
;
1324 case MESA_FORMAT_B10G10R10A2_UINT
:
1325 case MESA_FORMAT_R10G10B10A2_UINT
:
1326 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1330 case MESA_FORMAT_R8G8B8X8_SRGB
:
1331 case MESA_FORMAT_X8B8G8R8_SRGB
:
1332 case MESA_FORMAT_RGBX_UINT8
:
1333 *datatype
= GL_UNSIGNED_BYTE
;
1337 case MESA_FORMAT_R8G8B8X8_SNORM
:
1338 case MESA_FORMAT_RGBX_SINT8
:
1339 *datatype
= GL_BYTE
;
1343 case MESA_FORMAT_B10G10R10X2_UNORM
:
1344 case MESA_FORMAT_R10G10B10X2_UNORM
:
1345 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1349 case MESA_FORMAT_RGBX_UNORM16
:
1350 case MESA_FORMAT_RGBX_UINT16
:
1351 *datatype
= GL_UNSIGNED_SHORT
;
1355 case MESA_FORMAT_RGBX_SNORM16
:
1356 case MESA_FORMAT_RGBX_SINT16
:
1357 *datatype
= GL_SHORT
;
1361 case MESA_FORMAT_RGBX_FLOAT16
:
1362 *datatype
= GL_HALF_FLOAT
;
1366 case MESA_FORMAT_RGBX_FLOAT32
:
1367 *datatype
= GL_FLOAT
;
1371 case MESA_FORMAT_RGBX_UINT32
:
1372 *datatype
= GL_UNSIGNED_INT
;
1376 case MESA_FORMAT_RGBX_SINT32
:
1381 case MESA_FORMAT_R10G10B10A2_UNORM
:
1382 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1386 case MESA_FORMAT_G8R8_SNORM
:
1387 *datatype
= GL_BYTE
;
1391 case MESA_FORMAT_G16R16_SNORM
:
1392 *datatype
= GL_SHORT
;
1396 case MESA_FORMAT_B8G8R8X8_SRGB
:
1397 case MESA_FORMAT_X8R8G8B8_SRGB
:
1398 *datatype
= GL_UNSIGNED_BYTE
;
1402 case MESA_FORMAT_COUNT
:
1406 /* Warn if any formats are not handled */
1407 _mesa_problem(NULL
, "bad format %s in _mesa_uncompressed_format_to_type_and_comps",
1408 _mesa_get_format_name(format
));
1409 assert(format
== MESA_FORMAT_NONE
||
1410 _mesa_is_format_compressed(format
));
1417 * Check if a mesa_format exactly matches a GL format/type combination
1418 * such that we can use memcpy() from one to the other.
1419 * \param mesa_format a MESA_FORMAT_x value
1420 * \param format the user-specified image format
1421 * \param type the user-specified image datatype
1422 * \param swapBytes typically the current pixel pack/unpack byteswap state
1423 * \param[out] error GL_NO_ERROR if format is an expected input.
1424 * GL_INVALID_ENUM if format is an unexpected input.
1425 * \return GL_TRUE if the formats match, GL_FALSE otherwise.
1428 _mesa_format_matches_format_and_type(mesa_format mesa_format
,
1429 GLenum format
, GLenum type
,
1430 GLboolean swapBytes
, GLenum
*error
)
1432 const GLboolean littleEndian
= _mesa_little_endian();
1434 *error
= GL_NO_ERROR
;
1436 /* Note: When reading a GL format/type combination, the format lists channel
1437 * assignments from most significant channel in the type to least
1438 * significant. A type with _REV indicates that the assignments are
1439 * swapped, so they are listed from least significant to most significant.
1441 * Compressed formats will fall through and return GL_FALSE.
1443 * For sanity, please keep this switch statement ordered the same as the
1444 * enums in formats.h.
1447 switch (mesa_format
) {
1449 case MESA_FORMAT_NONE
:
1450 case MESA_FORMAT_COUNT
:
1453 case MESA_FORMAT_A8B8G8R8_UNORM
:
1454 case MESA_FORMAT_A8B8G8R8_SRGB
:
1455 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& !swapBytes
)
1458 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&& swapBytes
)
1461 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_BYTE
&& !littleEndian
)
1464 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
1468 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8
1472 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
)
1477 case MESA_FORMAT_R8G8B8A8_UNORM
:
1478 case MESA_FORMAT_R8G8B8A8_SRGB
:
1479 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1483 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& swapBytes
)
1486 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
)
1489 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8
&&
1493 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1497 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_BYTE
&& !littleEndian
)
1502 case MESA_FORMAT_B8G8R8A8_UNORM
:
1503 case MESA_FORMAT_B8G8R8A8_SRGB
:
1504 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1508 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& swapBytes
)
1511 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
)
1516 case MESA_FORMAT_A8R8G8B8_UNORM
:
1517 case MESA_FORMAT_A8R8G8B8_SRGB
:
1518 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& !swapBytes
)
1521 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1525 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_BYTE
&& !littleEndian
)
1530 case MESA_FORMAT_X8B8G8R8_UNORM
:
1531 case MESA_FORMAT_R8G8B8X8_UNORM
:
1534 case MESA_FORMAT_B8G8R8X8_UNORM
:
1535 case MESA_FORMAT_X8R8G8B8_UNORM
:
1538 case MESA_FORMAT_BGR_UNORM8
:
1539 case MESA_FORMAT_BGR_SRGB8
:
1540 return format
== GL_BGR
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1542 case MESA_FORMAT_RGB_UNORM8
:
1543 return format
== GL_RGB
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1545 case MESA_FORMAT_B5G6R5_UNORM
:
1546 return ((format
== GL_RGB
&& type
== GL_UNSIGNED_SHORT_5_6_5
) ||
1547 (format
== GL_BGR
&& type
== GL_UNSIGNED_SHORT_5_6_5_REV
)) &&
1550 case MESA_FORMAT_R5G6B5_UNORM
:
1551 return ((format
== GL_BGR
&& type
== GL_UNSIGNED_SHORT_5_6_5
) ||
1552 (format
== GL_RGB
&& type
== GL_UNSIGNED_SHORT_5_6_5_REV
)) &&
1555 case MESA_FORMAT_B4G4R4A4_UNORM
:
1556 return format
== GL_BGRA
&& type
== GL_UNSIGNED_SHORT_4_4_4_4_REV
&&
1559 case MESA_FORMAT_A4R4G4B4_UNORM
:
1562 case MESA_FORMAT_A1B5G5R5_UNORM
:
1563 return format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT_5_5_5_1
&&
1566 case MESA_FORMAT_B5G5R5A1_UNORM
:
1567 return format
== GL_BGRA
&& type
== GL_UNSIGNED_SHORT_1_5_5_5_REV
&&
1570 case MESA_FORMAT_A1R5G5B5_UNORM
:
1571 return format
== GL_BGRA
&& type
== GL_UNSIGNED_SHORT_5_5_5_1
&&
1574 case MESA_FORMAT_L4A4_UNORM
:
1576 case MESA_FORMAT_L8A8_UNORM
:
1577 case MESA_FORMAT_L8A8_SRGB
:
1578 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1579 case MESA_FORMAT_A8L8_UNORM
:
1580 case MESA_FORMAT_A8L8_SRGB
:
1583 case MESA_FORMAT_L16A16_UNORM
:
1584 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_UNSIGNED_SHORT
&& littleEndian
&& !swapBytes
;
1585 case MESA_FORMAT_A16L16_UNORM
:
1588 case MESA_FORMAT_B2G3R3_UNORM
:
1589 return format
== GL_RGB
&& type
== GL_UNSIGNED_BYTE_3_3_2
;
1591 case MESA_FORMAT_R3G3B2_UNORM
:
1592 return format
== GL_RGB
&& type
== GL_UNSIGNED_BYTE_2_3_3_REV
;
1594 case MESA_FORMAT_A4B4G4R4_UNORM
:
1595 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT_4_4_4_4
&& !swapBytes
)
1598 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT_4_4_4_4_REV
&& swapBytes
)
1601 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_SHORT_4_4_4_4_REV
&& !swapBytes
)
1604 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_SHORT_4_4_4_4
&& swapBytes
)
1609 case MESA_FORMAT_R4G4B4A4_UNORM
:
1610 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_SHORT_4_4_4_4
&& !swapBytes
)
1613 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_SHORT_4_4_4_4_REV
&& swapBytes
)
1616 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT_4_4_4_4_REV
&& !swapBytes
)
1619 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT_4_4_4_4
&& swapBytes
)
1624 case MESA_FORMAT_R5G5B5A1_UNORM
:
1625 return format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT_1_5_5_5_REV
;
1627 case MESA_FORMAT_A2B10G10R10_UNORM
:
1628 return format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_10_10_10_2
;
1630 case MESA_FORMAT_A2B10G10R10_UINT
:
1631 return format
== GL_RGBA_INTEGER_EXT
&& type
== GL_UNSIGNED_INT_10_10_10_2
;
1633 case MESA_FORMAT_A2R10G10B10_UNORM
:
1634 return format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_10_10_10_2
;
1636 case MESA_FORMAT_A2R10G10B10_UINT
:
1637 return format
== GL_BGRA_INTEGER_EXT
&& type
== GL_UNSIGNED_INT_10_10_10_2
;
1639 case MESA_FORMAT_A_UNORM8
:
1640 return format
== GL_ALPHA
&& type
== GL_UNSIGNED_BYTE
;
1641 case MESA_FORMAT_A_UNORM16
:
1642 return format
== GL_ALPHA
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1643 case MESA_FORMAT_L_UNORM8
:
1644 case MESA_FORMAT_L_SRGB8
:
1645 return format
== GL_LUMINANCE
&& type
== GL_UNSIGNED_BYTE
;
1646 case MESA_FORMAT_L_UNORM16
:
1647 return format
== GL_LUMINANCE
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1648 case MESA_FORMAT_I_UNORM8
:
1649 return format
== GL_RED
&& type
== GL_UNSIGNED_BYTE
;
1650 case MESA_FORMAT_I_UNORM16
:
1651 return format
== GL_RED
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1653 case MESA_FORMAT_YCBCR
:
1654 return format
== GL_YCBCR_MESA
&&
1655 ((type
== GL_UNSIGNED_SHORT_8_8_MESA
&& littleEndian
!= swapBytes
) ||
1656 (type
== GL_UNSIGNED_SHORT_8_8_REV_MESA
&& littleEndian
== swapBytes
));
1657 case MESA_FORMAT_YCBCR_REV
:
1658 return format
== GL_YCBCR_MESA
&&
1659 ((type
== GL_UNSIGNED_SHORT_8_8_MESA
&& littleEndian
== swapBytes
) ||
1660 (type
== GL_UNSIGNED_SHORT_8_8_REV_MESA
&& littleEndian
!= swapBytes
));
1662 case MESA_FORMAT_R_UNORM8
:
1663 return format
== GL_RED
&& type
== GL_UNSIGNED_BYTE
;
1664 case MESA_FORMAT_R8G8_UNORM
:
1665 return format
== GL_RG
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1666 case MESA_FORMAT_G8R8_UNORM
:
1669 case MESA_FORMAT_R_UNORM16
:
1670 return format
== GL_RED
&& type
== GL_UNSIGNED_SHORT
&&
1672 case MESA_FORMAT_R16G16_UNORM
:
1673 return format
== GL_RG
&& type
== GL_UNSIGNED_SHORT
&& littleEndian
&&
1675 case MESA_FORMAT_G16R16_UNORM
:
1678 case MESA_FORMAT_B10G10R10A2_UNORM
:
1679 return format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1682 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
1683 return format
== GL_DEPTH_STENCIL
&& type
== GL_UNSIGNED_INT_24_8
&&
1685 case MESA_FORMAT_X8_UINT_Z24_UNORM
:
1686 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
1689 case MESA_FORMAT_Z_UNORM16
:
1690 return format
== GL_DEPTH_COMPONENT
&& type
== GL_UNSIGNED_SHORT
&&
1693 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
1696 case MESA_FORMAT_Z_UNORM32
:
1697 return format
== GL_DEPTH_COMPONENT
&& type
== GL_UNSIGNED_INT
&&
1700 case MESA_FORMAT_S_UINT8
:
1701 return format
== GL_STENCIL_INDEX
&& type
== GL_UNSIGNED_BYTE
;
1703 case MESA_FORMAT_RGBA_FLOAT32
:
1704 return format
== GL_RGBA
&& type
== GL_FLOAT
&& !swapBytes
;
1705 case MESA_FORMAT_RGBA_FLOAT16
:
1706 return format
== GL_RGBA
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1708 case MESA_FORMAT_RGB_FLOAT32
:
1709 return format
== GL_RGB
&& type
== GL_FLOAT
&& !swapBytes
;
1710 case MESA_FORMAT_RGB_FLOAT16
:
1711 return format
== GL_RGB
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1713 case MESA_FORMAT_A_FLOAT32
:
1714 return format
== GL_ALPHA
&& type
== GL_FLOAT
&& !swapBytes
;
1715 case MESA_FORMAT_A_FLOAT16
:
1716 return format
== GL_ALPHA
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1718 case MESA_FORMAT_L_FLOAT32
:
1719 return format
== GL_LUMINANCE
&& type
== GL_FLOAT
&& !swapBytes
;
1720 case MESA_FORMAT_L_FLOAT16
:
1721 return format
== GL_LUMINANCE
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1723 case MESA_FORMAT_LA_FLOAT32
:
1724 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_FLOAT
&& !swapBytes
;
1725 case MESA_FORMAT_LA_FLOAT16
:
1726 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1728 case MESA_FORMAT_I_FLOAT32
:
1729 return format
== GL_RED
&& type
== GL_FLOAT
&& !swapBytes
;
1730 case MESA_FORMAT_I_FLOAT16
:
1731 return format
== GL_RED
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1733 case MESA_FORMAT_R_FLOAT32
:
1734 return format
== GL_RED
&& type
== GL_FLOAT
&& !swapBytes
;
1735 case MESA_FORMAT_R_FLOAT16
:
1736 return format
== GL_RED
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1738 case MESA_FORMAT_RG_FLOAT32
:
1739 return format
== GL_RG
&& type
== GL_FLOAT
&& !swapBytes
;
1740 case MESA_FORMAT_RG_FLOAT16
:
1741 return format
== GL_RG
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1743 case MESA_FORMAT_A_UINT8
:
1744 return format
== GL_ALPHA_INTEGER
&& type
== GL_UNSIGNED_BYTE
;
1745 case MESA_FORMAT_A_UINT16
:
1746 return format
== GL_ALPHA_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1748 case MESA_FORMAT_A_UINT32
:
1749 return format
== GL_ALPHA_INTEGER
&& type
== GL_UNSIGNED_INT
&&
1751 case MESA_FORMAT_A_SINT8
:
1752 return format
== GL_ALPHA_INTEGER
&& type
== GL_BYTE
;
1753 case MESA_FORMAT_A_SINT16
:
1754 return format
== GL_ALPHA_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1755 case MESA_FORMAT_A_SINT32
:
1756 return format
== GL_ALPHA_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1758 case MESA_FORMAT_I_UINT8
:
1759 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_BYTE
;
1760 case MESA_FORMAT_I_UINT16
:
1761 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1762 case MESA_FORMAT_I_UINT32
:
1763 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1764 case MESA_FORMAT_I_SINT8
:
1765 return format
== GL_RED_INTEGER
&& type
== GL_BYTE
;
1766 case MESA_FORMAT_I_SINT16
:
1767 return format
== GL_RED_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1768 case MESA_FORMAT_I_SINT32
:
1769 return format
== GL_RED_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1771 case MESA_FORMAT_L_UINT8
:
1772 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_UNSIGNED_BYTE
;
1773 case MESA_FORMAT_L_UINT16
:
1774 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_UNSIGNED_SHORT
&&
1776 case MESA_FORMAT_L_UINT32
:
1777 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_UNSIGNED_INT
&&
1779 case MESA_FORMAT_L_SINT8
:
1780 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_BYTE
;
1781 case MESA_FORMAT_L_SINT16
:
1782 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_SHORT
&&
1784 case MESA_FORMAT_L_SINT32
:
1785 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_INT
&& !swapBytes
;
1787 case MESA_FORMAT_LA_UINT8
:
1788 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&&
1789 type
== GL_UNSIGNED_BYTE
&& !swapBytes
;
1790 case MESA_FORMAT_LA_UINT16
:
1791 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&&
1792 type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1793 case MESA_FORMAT_LA_UINT32
:
1794 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&&
1795 type
== GL_UNSIGNED_INT
&& !swapBytes
;
1796 case MESA_FORMAT_LA_SINT8
:
1797 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&& type
== GL_BYTE
&&
1799 case MESA_FORMAT_LA_SINT16
:
1800 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&& type
== GL_SHORT
&&
1802 case MESA_FORMAT_LA_SINT32
:
1803 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&& type
== GL_INT
&&
1806 case MESA_FORMAT_R_SINT8
:
1807 return format
== GL_RED_INTEGER
&& type
== GL_BYTE
;
1808 case MESA_FORMAT_RG_SINT8
:
1809 return format
== GL_RG_INTEGER
&& type
== GL_BYTE
&& !swapBytes
;
1810 case MESA_FORMAT_RGB_SINT8
:
1811 return format
== GL_RGB_INTEGER
&& type
== GL_BYTE
&& !swapBytes
;
1812 case MESA_FORMAT_RGBA_SINT8
:
1813 return format
== GL_RGBA_INTEGER
&& type
== GL_BYTE
&& !swapBytes
;
1814 case MESA_FORMAT_R_SINT16
:
1815 return format
== GL_RED_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1816 case MESA_FORMAT_RG_SINT16
:
1817 return format
== GL_RG_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1818 case MESA_FORMAT_RGB_SINT16
:
1819 return format
== GL_RGB_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1820 case MESA_FORMAT_RGBA_SINT16
:
1821 return format
== GL_RGBA_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1822 case MESA_FORMAT_R_SINT32
:
1823 return format
== GL_RED_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1824 case MESA_FORMAT_RG_SINT32
:
1825 return format
== GL_RG_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1826 case MESA_FORMAT_RGB_SINT32
:
1827 return format
== GL_RGB_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1828 case MESA_FORMAT_RGBA_SINT32
:
1829 return format
== GL_RGBA_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1831 case MESA_FORMAT_R_UINT8
:
1832 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_BYTE
;
1833 case MESA_FORMAT_RG_UINT8
:
1834 return format
== GL_RG_INTEGER
&& type
== GL_UNSIGNED_BYTE
&& !swapBytes
;
1835 case MESA_FORMAT_RGB_UINT8
:
1836 return format
== GL_RGB_INTEGER
&& type
== GL_UNSIGNED_BYTE
&& !swapBytes
;
1837 case MESA_FORMAT_RGBA_UINT8
:
1838 return format
== GL_RGBA_INTEGER
&& type
== GL_UNSIGNED_BYTE
&&
1840 case MESA_FORMAT_R_UINT16
:
1841 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1843 case MESA_FORMAT_RG_UINT16
:
1844 return format
== GL_RG_INTEGER
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1845 case MESA_FORMAT_RGB_UINT16
:
1846 return format
== GL_RGB_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1848 case MESA_FORMAT_RGBA_UINT16
:
1849 return format
== GL_RGBA_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1851 case MESA_FORMAT_R_UINT32
:
1852 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1853 case MESA_FORMAT_RG_UINT32
:
1854 return format
== GL_RG_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1855 case MESA_FORMAT_RGB_UINT32
:
1856 return format
== GL_RGB_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1857 case MESA_FORMAT_RGBA_UINT32
:
1858 return format
== GL_RGBA_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1860 case MESA_FORMAT_R_SNORM8
:
1861 return format
== GL_RED
&& type
== GL_BYTE
;
1862 case MESA_FORMAT_R8G8_SNORM
:
1863 return format
== GL_RG
&& type
== GL_BYTE
&& littleEndian
&&
1865 case MESA_FORMAT_X8B8G8R8_SNORM
:
1868 case MESA_FORMAT_A8B8G8R8_SNORM
:
1869 if (format
== GL_RGBA
&& type
== GL_BYTE
&& !littleEndian
)
1872 if (format
== GL_ABGR_EXT
&& type
== GL_BYTE
&& littleEndian
)
1877 case MESA_FORMAT_R8G8B8A8_SNORM
:
1878 if (format
== GL_RGBA
&& type
== GL_BYTE
&& littleEndian
)
1881 if (format
== GL_ABGR_EXT
&& type
== GL_BYTE
&& !littleEndian
)
1886 case MESA_FORMAT_R_SNORM16
:
1887 return format
== GL_RED
&& type
== GL_SHORT
&&
1889 case MESA_FORMAT_R16G16_SNORM
:
1890 return format
== GL_RG
&& type
== GL_SHORT
&& littleEndian
&& !swapBytes
;
1891 case MESA_FORMAT_RGB_SNORM16
:
1892 return format
== GL_RGB
&& type
== GL_SHORT
&& !swapBytes
;
1893 case MESA_FORMAT_RGBA_SNORM16
:
1894 return format
== GL_RGBA
&& type
== GL_SHORT
&& !swapBytes
;
1895 case MESA_FORMAT_RGBA_UNORM16
:
1896 return format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT
&&
1899 case MESA_FORMAT_A_SNORM8
:
1900 return format
== GL_ALPHA
&& type
== GL_BYTE
;
1901 case MESA_FORMAT_L_SNORM8
:
1902 return format
== GL_LUMINANCE
&& type
== GL_BYTE
;
1903 case MESA_FORMAT_L8A8_SNORM
:
1904 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_BYTE
&&
1905 littleEndian
&& !swapBytes
;
1906 case MESA_FORMAT_A8L8_SNORM
:
1907 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_BYTE
&&
1908 !littleEndian
&& !swapBytes
;
1909 case MESA_FORMAT_I_SNORM8
:
1910 return format
== GL_RED
&& type
== GL_BYTE
;
1911 case MESA_FORMAT_A_SNORM16
:
1912 return format
== GL_ALPHA
&& type
== GL_SHORT
&& !swapBytes
;
1913 case MESA_FORMAT_L_SNORM16
:
1914 return format
== GL_LUMINANCE
&& type
== GL_SHORT
&& !swapBytes
;
1915 case MESA_FORMAT_LA_SNORM16
:
1916 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_SHORT
&&
1917 littleEndian
&& !swapBytes
;
1918 case MESA_FORMAT_I_SNORM16
:
1919 return format
== GL_RED
&& type
== GL_SHORT
&& littleEndian
&&
1922 case MESA_FORMAT_B10G10R10A2_UINT
:
1923 return (format
== GL_BGRA_INTEGER_EXT
&&
1924 type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1927 case MESA_FORMAT_R10G10B10A2_UINT
:
1928 return (format
== GL_RGBA_INTEGER_EXT
&&
1929 type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1932 case MESA_FORMAT_R9G9B9E5_FLOAT
:
1933 return format
== GL_RGB
&& type
== GL_UNSIGNED_INT_5_9_9_9_REV
&&
1936 case MESA_FORMAT_R11G11B10_FLOAT
:
1937 return format
== GL_RGB
&& type
== GL_UNSIGNED_INT_10F_11F_11F_REV
&&
1940 case MESA_FORMAT_Z_FLOAT32
:
1941 return format
== GL_DEPTH_COMPONENT
&& type
== GL_FLOAT
&& !swapBytes
;
1943 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
1944 return format
== GL_DEPTH_STENCIL
&&
1945 type
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
&& !swapBytes
;
1947 case MESA_FORMAT_B4G4R4X4_UNORM
:
1948 case MESA_FORMAT_B5G5R5X1_UNORM
:
1949 case MESA_FORMAT_R8G8B8X8_SNORM
:
1950 case MESA_FORMAT_R8G8B8X8_SRGB
:
1951 case MESA_FORMAT_X8B8G8R8_SRGB
:
1952 case MESA_FORMAT_RGBX_UINT8
:
1953 case MESA_FORMAT_RGBX_SINT8
:
1954 case MESA_FORMAT_B10G10R10X2_UNORM
:
1955 case MESA_FORMAT_R10G10B10X2_UNORM
:
1956 case MESA_FORMAT_RGBX_UNORM16
:
1957 case MESA_FORMAT_RGBX_SNORM16
:
1958 case MESA_FORMAT_RGBX_FLOAT16
:
1959 case MESA_FORMAT_RGBX_UINT16
:
1960 case MESA_FORMAT_RGBX_SINT16
:
1961 case MESA_FORMAT_RGBX_FLOAT32
:
1962 case MESA_FORMAT_RGBX_UINT32
:
1963 case MESA_FORMAT_RGBX_SINT32
:
1966 case MESA_FORMAT_R10G10B10A2_UNORM
:
1967 return format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1970 case MESA_FORMAT_G8R8_SNORM
:
1971 return format
== GL_RG
&& type
== GL_BYTE
&& !littleEndian
&&
1974 case MESA_FORMAT_G16R16_SNORM
:
1975 return format
== GL_RG
&& type
== GL_SHORT
&& !littleEndian
&&
1978 case MESA_FORMAT_B8G8R8X8_SRGB
:
1979 case MESA_FORMAT_X8R8G8B8_SRGB
:
1982 assert(_mesa_is_format_compressed(mesa_format
));
1984 *error
= GL_INVALID_ENUM
;