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
;
74 mesa_array_format ArrayFormat
;
77 #include "format_info.c"
79 static const struct gl_format_info
*
80 _mesa_get_format_info(mesa_format format
)
82 const struct gl_format_info
*info
= &format_info
[format
];
83 assert(info
->Name
== format
);
88 /** Return string name of format (for debugging) */
90 _mesa_get_format_name(mesa_format format
)
92 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
99 * Return bytes needed to store a block of pixels in the given format.
100 * Normally, a block is 1x1 (a single pixel). But for compressed formats
101 * a block may be 4x4 or 8x4, etc.
103 * Note: not GLuint, so as not to coerce math to unsigned. cf. fdo #37351
106 _mesa_get_format_bytes(mesa_format format
)
108 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
109 ASSERT(info
->BytesPerBlock
);
110 ASSERT(info
->BytesPerBlock
<= MAX_PIXEL_BYTES
||
111 _mesa_is_format_compressed(format
));
112 return info
->BytesPerBlock
;
117 * Return bits per component for the given format.
118 * \param format one of MESA_FORMAT_x
119 * \param pname the component, such as GL_RED_BITS, GL_TEXTURE_BLUE_BITS, etc.
122 _mesa_get_format_bits(mesa_format format
, GLenum pname
)
124 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
128 case GL_TEXTURE_RED_SIZE
:
129 case GL_RENDERBUFFER_RED_SIZE_EXT
:
130 case GL_FRAMEBUFFER_ATTACHMENT_RED_SIZE
:
131 return info
->RedBits
;
133 case GL_TEXTURE_GREEN_SIZE
:
134 case GL_RENDERBUFFER_GREEN_SIZE_EXT
:
135 case GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZE
:
136 return info
->GreenBits
;
138 case GL_TEXTURE_BLUE_SIZE
:
139 case GL_RENDERBUFFER_BLUE_SIZE_EXT
:
140 case GL_FRAMEBUFFER_ATTACHMENT_BLUE_SIZE
:
141 return info
->BlueBits
;
143 case GL_TEXTURE_ALPHA_SIZE
:
144 case GL_RENDERBUFFER_ALPHA_SIZE_EXT
:
145 case GL_FRAMEBUFFER_ATTACHMENT_ALPHA_SIZE
:
146 return info
->AlphaBits
;
147 case GL_TEXTURE_INTENSITY_SIZE
:
148 return info
->IntensityBits
;
149 case GL_TEXTURE_LUMINANCE_SIZE
:
150 return info
->LuminanceBits
;
154 case GL_TEXTURE_DEPTH_SIZE_ARB
:
155 case GL_RENDERBUFFER_DEPTH_SIZE_EXT
:
156 case GL_FRAMEBUFFER_ATTACHMENT_DEPTH_SIZE
:
157 return info
->DepthBits
;
158 case GL_STENCIL_BITS
:
159 case GL_TEXTURE_STENCIL_SIZE_EXT
:
160 case GL_RENDERBUFFER_STENCIL_SIZE_EXT
:
161 case GL_FRAMEBUFFER_ATTACHMENT_STENCIL_SIZE
:
162 return info
->StencilBits
;
164 _mesa_problem(NULL
, "bad pname in _mesa_get_format_bits()");
171 _mesa_get_format_max_bits(mesa_format format
)
173 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
174 GLuint max
= MAX2(info
->RedBits
, info
->GreenBits
);
175 max
= MAX2(max
, info
->BlueBits
);
176 max
= MAX2(max
, info
->AlphaBits
);
177 max
= MAX2(max
, info
->LuminanceBits
);
178 max
= MAX2(max
, info
->IntensityBits
);
179 max
= MAX2(max
, info
->DepthBits
);
180 max
= MAX2(max
, info
->StencilBits
);
186 * Return the layout type of the given format.
187 * The return value will be one of:
188 * MESA_FORMAT_LAYOUT_ARRAY
189 * MESA_FORMAT_LAYOUT_PACKED
190 * MESA_FORMAT_LAYOUT_OTHER
192 extern enum mesa_format_layout
193 _mesa_get_format_layout(mesa_format format
)
195 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
201 * Return the data type (or more specifically, the data representation)
202 * for the given format.
203 * The return value will be one of:
204 * GL_UNSIGNED_NORMALIZED = unsigned int representing [0,1]
205 * GL_SIGNED_NORMALIZED = signed int representing [-1, 1]
206 * GL_UNSIGNED_INT = an ordinary unsigned integer
207 * GL_INT = an ordinary signed integer
208 * GL_FLOAT = an ordinary float
211 _mesa_get_format_datatype(mesa_format format
)
213 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
214 return info
->DataType
;
219 * Return the basic format for the given type. The result will be one of
220 * GL_RGB, GL_RGBA, GL_ALPHA, GL_LUMINANCE, GL_LUMINANCE_ALPHA, GL_INTENSITY,
221 * GL_YCBCR_MESA, GL_DEPTH_COMPONENT, GL_STENCIL_INDEX, GL_DEPTH_STENCIL.
224 _mesa_get_format_base_format(mesa_format format
)
226 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
227 return info
->BaseFormat
;
232 * Return the block size (in pixels) for the given format. Normally
233 * the block size is 1x1. But compressed formats will have block sizes
234 * of 4x4 or 8x4 pixels, etc.
235 * \param bw returns block width in pixels
236 * \param bh returns block height in pixels
239 _mesa_get_format_block_size(mesa_format format
, GLuint
*bw
, GLuint
*bh
)
241 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
242 *bw
= info
->BlockWidth
;
243 *bh
= info
->BlockHeight
;
248 * Returns the an array of four numbers representing the transformation
249 * from the RGBA or SZ colorspace to the given format. For array formats,
250 * the i'th RGBA component is given by:
252 * if (swizzle[i] <= MESA_FORMAT_SWIZZLE_W)
253 * comp = data[swizzle[i]];
254 * else if (swizzle[i] == MESA_FORMAT_SWIZZLE_ZERO)
256 * else if (swizzle[i] == MESA_FORMAT_SWIZZLE_ONE)
258 * else if (swizzle[i] == MESA_FORMAT_SWIZZLE_NONE)
259 * // data does not contain a channel of this format
261 * For packed formats, the swizzle gives the number of components left of
262 * the least significant bit.
264 * Compressed formats have no swizzle.
267 _mesa_get_format_swizzle(mesa_format format
, uint8_t swizzle_out
[4])
269 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
270 memcpy(swizzle_out
, info
->Swizzle
, sizeof(info
->Swizzle
));
274 _mesa_array_format_flip_channels(mesa_array_format format
)
279 num_channels
= _mesa_array_format_get_num_channels(format
);
280 _mesa_array_format_get_swizzle(format
, swizzle
);
282 if (num_channels
== 1)
285 if (num_channels
== 2) {
286 _mesa_array_format_set_swizzle(&format
, swizzle
[1], swizzle
[0],
287 swizzle
[2], swizzle
[3]);
291 if (num_channels
== 4) {
292 _mesa_array_format_set_swizzle(&format
, swizzle
[3], swizzle
[2],
293 swizzle
[1], swizzle
[0]);
297 unreachable("Invalid array format");
301 _mesa_format_to_array_format(mesa_format format
)
303 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
304 if (_mesa_little_endian())
305 return info
->ArrayFormat
;
307 return _mesa_array_format_flip_channels(info
->ArrayFormat
);
311 _mesa_format_from_array_format(uint32_t array_format
)
313 mesa_array_format af
;
316 assert(_mesa_format_is_mesa_array_format(array_format
));
318 if (_mesa_little_endian())
321 af
= _mesa_array_format_flip_channels(array_format
);
323 for (f
= 1; f
< MESA_FORMAT_COUNT
; ++f
)
324 if (_mesa_get_format_info(f
)->ArrayFormat
== af
)
327 return MESA_FORMAT_NONE
;
330 /** Is the given format a compressed format? */
332 _mesa_is_format_compressed(mesa_format format
)
334 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
335 return info
->BlockWidth
> 1 || info
->BlockHeight
> 1;
340 * Determine if the given format represents a packed depth/stencil buffer.
343 _mesa_is_format_packed_depth_stencil(mesa_format format
)
345 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
347 return info
->BaseFormat
== GL_DEPTH_STENCIL
;
352 * Is the given format a signed/unsigned integer color format?
355 _mesa_is_format_integer_color(mesa_format format
)
357 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
358 return (info
->DataType
== GL_INT
|| info
->DataType
== GL_UNSIGNED_INT
) &&
359 info
->BaseFormat
!= GL_DEPTH_COMPONENT
&&
360 info
->BaseFormat
!= GL_DEPTH_STENCIL
&&
361 info
->BaseFormat
!= GL_STENCIL_INDEX
;
366 * Is the given format an unsigned integer format?
369 _mesa_is_format_unsigned(mesa_format format
)
371 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
372 return _mesa_is_type_unsigned(info
->DataType
);
377 * Does the given format store signed values?
380 _mesa_is_format_signed(mesa_format format
)
382 if (format
== MESA_FORMAT_R11G11B10_FLOAT
||
383 format
== MESA_FORMAT_R9G9B9E5_FLOAT
) {
384 /* these packed float formats only store unsigned values */
388 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
389 return (info
->DataType
== GL_SIGNED_NORMALIZED
||
390 info
->DataType
== GL_INT
||
391 info
->DataType
== GL_FLOAT
);
396 * Is the given format an integer format?
399 _mesa_is_format_integer(mesa_format format
)
401 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
402 return (info
->DataType
== GL_INT
|| info
->DataType
== GL_UNSIGNED_INT
);
406 * Return color encoding for given format.
407 * \return GL_LINEAR or GL_SRGB
410 _mesa_get_format_color_encoding(mesa_format format
)
412 /* XXX this info should be encoded in gl_format_info */
414 case MESA_FORMAT_BGR_SRGB8
:
415 case MESA_FORMAT_A8B8G8R8_SRGB
:
416 case MESA_FORMAT_B8G8R8A8_SRGB
:
417 case MESA_FORMAT_A8R8G8B8_SRGB
:
418 case MESA_FORMAT_R8G8B8A8_SRGB
:
419 case MESA_FORMAT_L_SRGB8
:
420 case MESA_FORMAT_L8A8_SRGB
:
421 case MESA_FORMAT_A8L8_SRGB
:
422 case MESA_FORMAT_SRGB_DXT1
:
423 case MESA_FORMAT_SRGBA_DXT1
:
424 case MESA_FORMAT_SRGBA_DXT3
:
425 case MESA_FORMAT_SRGBA_DXT5
:
426 case MESA_FORMAT_R8G8B8X8_SRGB
:
427 case MESA_FORMAT_ETC2_SRGB8
:
428 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
429 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
430 case MESA_FORMAT_B8G8R8X8_SRGB
:
431 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
440 * Return TRUE if format is an ETC2 compressed format specified
441 * by GL_ARB_ES3_compatibility.
444 _mesa_is_format_etc2(mesa_format format
)
447 case MESA_FORMAT_ETC2_RGB8
:
448 case MESA_FORMAT_ETC2_SRGB8
:
449 case MESA_FORMAT_ETC2_RGBA8_EAC
:
450 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
451 case MESA_FORMAT_ETC2_R11_EAC
:
452 case MESA_FORMAT_ETC2_RG11_EAC
:
453 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
454 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
455 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
456 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
465 * For an sRGB format, return the corresponding linear color space format.
466 * For non-sRGB formats, return the format as-is.
469 _mesa_get_srgb_format_linear(mesa_format format
)
472 case MESA_FORMAT_BGR_SRGB8
:
473 format
= MESA_FORMAT_BGR_UNORM8
;
475 case MESA_FORMAT_A8B8G8R8_SRGB
:
476 format
= MESA_FORMAT_A8B8G8R8_UNORM
;
478 case MESA_FORMAT_B8G8R8A8_SRGB
:
479 format
= MESA_FORMAT_B8G8R8A8_UNORM
;
481 case MESA_FORMAT_A8R8G8B8_SRGB
:
482 format
= MESA_FORMAT_A8R8G8B8_UNORM
;
484 case MESA_FORMAT_R8G8B8A8_SRGB
:
485 format
= MESA_FORMAT_R8G8B8A8_UNORM
;
487 case MESA_FORMAT_L_SRGB8
:
488 format
= MESA_FORMAT_L_UNORM8
;
490 case MESA_FORMAT_L8A8_SRGB
:
491 format
= MESA_FORMAT_L8A8_UNORM
;
493 case MESA_FORMAT_A8L8_SRGB
:
494 format
= MESA_FORMAT_A8L8_UNORM
;
496 case MESA_FORMAT_SRGB_DXT1
:
497 format
= MESA_FORMAT_RGB_DXT1
;
499 case MESA_FORMAT_SRGBA_DXT1
:
500 format
= MESA_FORMAT_RGBA_DXT1
;
502 case MESA_FORMAT_SRGBA_DXT3
:
503 format
= MESA_FORMAT_RGBA_DXT3
;
505 case MESA_FORMAT_SRGBA_DXT5
:
506 format
= MESA_FORMAT_RGBA_DXT5
;
508 case MESA_FORMAT_R8G8B8X8_SRGB
:
509 format
= MESA_FORMAT_R8G8B8X8_UNORM
;
511 case MESA_FORMAT_X8B8G8R8_SRGB
:
512 format
= MESA_FORMAT_X8B8G8R8_UNORM
;
514 case MESA_FORMAT_ETC2_SRGB8
:
515 format
= MESA_FORMAT_ETC2_RGB8
;
517 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
518 format
= MESA_FORMAT_ETC2_RGBA8_EAC
;
520 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
521 format
= MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
;
523 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
524 format
= MESA_FORMAT_BPTC_RGBA_UNORM
;
526 case MESA_FORMAT_B8G8R8X8_SRGB
:
527 format
= MESA_FORMAT_B8G8R8X8_UNORM
;
529 case MESA_FORMAT_X8R8G8B8_SRGB
:
530 format
= MESA_FORMAT_X8R8G8B8_UNORM
;
540 * If the given format is a compressed format, return a corresponding
541 * uncompressed format.
544 _mesa_get_uncompressed_format(mesa_format format
)
547 case MESA_FORMAT_RGB_FXT1
:
548 return MESA_FORMAT_BGR_UNORM8
;
549 case MESA_FORMAT_RGBA_FXT1
:
550 return MESA_FORMAT_A8B8G8R8_UNORM
;
551 case MESA_FORMAT_RGB_DXT1
:
552 case MESA_FORMAT_SRGB_DXT1
:
553 return MESA_FORMAT_BGR_UNORM8
;
554 case MESA_FORMAT_RGBA_DXT1
:
555 case MESA_FORMAT_SRGBA_DXT1
:
556 return MESA_FORMAT_A8B8G8R8_UNORM
;
557 case MESA_FORMAT_RGBA_DXT3
:
558 case MESA_FORMAT_SRGBA_DXT3
:
559 return MESA_FORMAT_A8B8G8R8_UNORM
;
560 case MESA_FORMAT_RGBA_DXT5
:
561 case MESA_FORMAT_SRGBA_DXT5
:
562 return MESA_FORMAT_A8B8G8R8_UNORM
;
563 case MESA_FORMAT_R_RGTC1_UNORM
:
564 return MESA_FORMAT_R_UNORM8
;
565 case MESA_FORMAT_R_RGTC1_SNORM
:
566 return MESA_FORMAT_R_SNORM8
;
567 case MESA_FORMAT_RG_RGTC2_UNORM
:
568 return MESA_FORMAT_R8G8_UNORM
;
569 case MESA_FORMAT_RG_RGTC2_SNORM
:
570 return MESA_FORMAT_R8G8_SNORM
;
571 case MESA_FORMAT_L_LATC1_UNORM
:
572 return MESA_FORMAT_L_UNORM8
;
573 case MESA_FORMAT_L_LATC1_SNORM
:
574 return MESA_FORMAT_L_SNORM8
;
575 case MESA_FORMAT_LA_LATC2_UNORM
:
576 return MESA_FORMAT_L8A8_UNORM
;
577 case MESA_FORMAT_LA_LATC2_SNORM
:
578 return MESA_FORMAT_L8A8_SNORM
;
579 case MESA_FORMAT_ETC1_RGB8
:
580 case MESA_FORMAT_ETC2_RGB8
:
581 case MESA_FORMAT_ETC2_SRGB8
:
582 return MESA_FORMAT_BGR_UNORM8
;
583 case MESA_FORMAT_ETC2_RGBA8_EAC
:
584 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
585 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
586 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
587 return MESA_FORMAT_A8B8G8R8_UNORM
;
588 case MESA_FORMAT_ETC2_R11_EAC
:
589 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
590 return MESA_FORMAT_R_UNORM16
;
591 case MESA_FORMAT_ETC2_RG11_EAC
:
592 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
593 return MESA_FORMAT_R16G16_UNORM
;
594 case MESA_FORMAT_BPTC_RGBA_UNORM
:
595 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
596 return MESA_FORMAT_A8B8G8R8_UNORM
;
597 case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
:
598 case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
:
599 return MESA_FORMAT_RGB_FLOAT32
;
602 assert(!_mesa_is_format_compressed(format
));
610 _mesa_format_num_components(mesa_format format
)
612 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
613 return ((info
->RedBits
> 0) +
614 (info
->GreenBits
> 0) +
615 (info
->BlueBits
> 0) +
616 (info
->AlphaBits
> 0) +
617 (info
->LuminanceBits
> 0) +
618 (info
->IntensityBits
> 0) +
619 (info
->DepthBits
> 0) +
620 (info
->StencilBits
> 0));
625 * Returns true if a color format has data stored in the R/G/B/A channels,
626 * given an index from 0 to 3.
629 _mesa_format_has_color_component(mesa_format format
, int component
)
631 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
633 assert(info
->BaseFormat
!= GL_DEPTH_COMPONENT
&&
634 info
->BaseFormat
!= GL_DEPTH_STENCIL
&&
635 info
->BaseFormat
!= GL_STENCIL_INDEX
);
639 return (info
->RedBits
+ info
->IntensityBits
+ info
->LuminanceBits
) > 0;
641 return (info
->GreenBits
+ info
->IntensityBits
+ info
->LuminanceBits
) > 0;
643 return (info
->BlueBits
+ info
->IntensityBits
+ info
->LuminanceBits
) > 0;
645 return (info
->AlphaBits
+ info
->IntensityBits
) > 0;
647 assert(!"Invalid color component: must be 0..3");
654 * Return number of bytes needed to store an image of the given size
655 * in the given format.
658 _mesa_format_image_size(mesa_format format
, GLsizei width
,
659 GLsizei height
, GLsizei depth
)
661 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
662 /* Strictly speaking, a conditional isn't needed here */
663 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
664 /* compressed format (2D only for now) */
665 const GLuint bw
= info
->BlockWidth
, bh
= info
->BlockHeight
;
666 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
667 const GLuint hblocks
= (height
+ bh
- 1) / bh
;
668 const GLuint sz
= wblocks
* hblocks
* info
->BytesPerBlock
;
673 const GLuint sz
= width
* height
* depth
* info
->BytesPerBlock
;
680 * Same as _mesa_format_image_size() but returns a 64-bit value to
681 * accomodate very large textures.
684 _mesa_format_image_size64(mesa_format format
, GLsizei width
,
685 GLsizei height
, GLsizei depth
)
687 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
688 /* Strictly speaking, a conditional isn't needed here */
689 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
690 /* compressed format (2D only for now) */
691 const uint64_t bw
= info
->BlockWidth
, bh
= info
->BlockHeight
;
692 const uint64_t wblocks
= (width
+ bw
- 1) / bw
;
693 const uint64_t hblocks
= (height
+ bh
- 1) / bh
;
694 const uint64_t sz
= wblocks
* hblocks
* info
->BytesPerBlock
;
699 const uint64_t sz
= ((uint64_t) width
*
702 info
->BytesPerBlock
);
710 _mesa_format_row_stride(mesa_format format
, GLsizei width
)
712 const struct gl_format_info
*info
= _mesa_get_format_info(format
);
713 /* Strictly speaking, a conditional isn't needed here */
714 if (info
->BlockWidth
> 1 || info
->BlockHeight
> 1) {
715 /* compressed format */
716 const GLuint bw
= info
->BlockWidth
;
717 const GLuint wblocks
= (width
+ bw
- 1) / bw
;
718 const GLint stride
= wblocks
* info
->BytesPerBlock
;
722 const GLint stride
= width
* info
->BytesPerBlock
;
729 * Debug/test: check that all formats are handled in the
730 * _mesa_format_to_type_and_comps() function. When new pixel formats
731 * are added to Mesa, that function needs to be updated.
732 * This is a no-op after the first call.
735 check_format_to_type_and_comps(void)
739 for (f
= MESA_FORMAT_NONE
+ 1; f
< MESA_FORMAT_COUNT
; f
++) {
742 /* This function will emit a problem/warning if the format is
745 _mesa_format_to_type_and_comps(f
, &datatype
, &comps
);
750 * Do sanity checking of the format info table.
753 _mesa_test_formats(void)
757 STATIC_ASSERT(Elements(format_info
) == MESA_FORMAT_COUNT
);
759 for (i
= 0; i
< MESA_FORMAT_COUNT
; i
++) {
760 const struct gl_format_info
*info
= _mesa_get_format_info(i
);
763 assert(info
->Name
== i
);
765 if (info
->Name
== MESA_FORMAT_NONE
)
768 if (info
->BlockWidth
== 1 && info
->BlockHeight
== 1) {
769 if (info
->RedBits
> 0) {
770 GLuint t
= info
->RedBits
+ info
->GreenBits
771 + info
->BlueBits
+ info
->AlphaBits
;
772 assert(t
/ 8 <= info
->BytesPerBlock
);
777 assert(info
->DataType
== GL_UNSIGNED_NORMALIZED
||
778 info
->DataType
== GL_SIGNED_NORMALIZED
||
779 info
->DataType
== GL_UNSIGNED_INT
||
780 info
->DataType
== GL_INT
||
781 info
->DataType
== GL_FLOAT
||
782 /* Z32_FLOAT_X24S8 has DataType of GL_NONE */
783 info
->DataType
== GL_NONE
);
785 if (info
->BaseFormat
== GL_RGB
) {
786 assert(info
->RedBits
> 0);
787 assert(info
->GreenBits
> 0);
788 assert(info
->BlueBits
> 0);
789 assert(info
->AlphaBits
== 0);
790 assert(info
->LuminanceBits
== 0);
791 assert(info
->IntensityBits
== 0);
793 else if (info
->BaseFormat
== GL_RGBA
) {
794 assert(info
->RedBits
> 0);
795 assert(info
->GreenBits
> 0);
796 assert(info
->BlueBits
> 0);
797 assert(info
->AlphaBits
> 0);
798 assert(info
->LuminanceBits
== 0);
799 assert(info
->IntensityBits
== 0);
801 else if (info
->BaseFormat
== GL_RG
) {
802 assert(info
->RedBits
> 0);
803 assert(info
->GreenBits
> 0);
804 assert(info
->BlueBits
== 0);
805 assert(info
->AlphaBits
== 0);
806 assert(info
->LuminanceBits
== 0);
807 assert(info
->IntensityBits
== 0);
809 else if (info
->BaseFormat
== GL_RED
) {
810 assert(info
->RedBits
> 0);
811 assert(info
->GreenBits
== 0);
812 assert(info
->BlueBits
== 0);
813 assert(info
->AlphaBits
== 0);
814 assert(info
->LuminanceBits
== 0);
815 assert(info
->IntensityBits
== 0);
817 else if (info
->BaseFormat
== GL_LUMINANCE
) {
818 assert(info
->RedBits
== 0);
819 assert(info
->GreenBits
== 0);
820 assert(info
->BlueBits
== 0);
821 assert(info
->AlphaBits
== 0);
822 assert(info
->LuminanceBits
> 0);
823 assert(info
->IntensityBits
== 0);
825 else if (info
->BaseFormat
== GL_INTENSITY
) {
826 assert(info
->RedBits
== 0);
827 assert(info
->GreenBits
== 0);
828 assert(info
->BlueBits
== 0);
829 assert(info
->AlphaBits
== 0);
830 assert(info
->LuminanceBits
== 0);
831 assert(info
->IntensityBits
> 0);
835 check_format_to_type_and_comps();
841 * Return datatype and number of components per texel for the given mesa_format.
842 * Only used for mipmap generation code.
845 _mesa_format_to_type_and_comps(mesa_format format
,
846 GLenum
*datatype
, GLuint
*comps
)
849 case MESA_FORMAT_A8B8G8R8_UNORM
:
850 case MESA_FORMAT_R8G8B8A8_UNORM
:
851 case MESA_FORMAT_B8G8R8A8_UNORM
:
852 case MESA_FORMAT_A8R8G8B8_UNORM
:
853 case MESA_FORMAT_X8B8G8R8_UNORM
:
854 case MESA_FORMAT_R8G8B8X8_UNORM
:
855 case MESA_FORMAT_B8G8R8X8_UNORM
:
856 case MESA_FORMAT_X8R8G8B8_UNORM
:
857 *datatype
= GL_UNSIGNED_BYTE
;
860 case MESA_FORMAT_BGR_UNORM8
:
861 case MESA_FORMAT_RGB_UNORM8
:
862 *datatype
= GL_UNSIGNED_BYTE
;
865 case MESA_FORMAT_B5G6R5_UNORM
:
866 case MESA_FORMAT_R5G6B5_UNORM
:
867 *datatype
= GL_UNSIGNED_SHORT_5_6_5
;
871 case MESA_FORMAT_B4G4R4A4_UNORM
:
872 case MESA_FORMAT_A4R4G4B4_UNORM
:
873 case MESA_FORMAT_B4G4R4X4_UNORM
:
874 *datatype
= GL_UNSIGNED_SHORT_4_4_4_4
;
878 case MESA_FORMAT_B5G5R5A1_UNORM
:
879 case MESA_FORMAT_A1R5G5B5_UNORM
:
880 case MESA_FORMAT_B5G5R5X1_UNORM
:
881 *datatype
= GL_UNSIGNED_SHORT_1_5_5_5_REV
;
885 case MESA_FORMAT_B10G10R10A2_UNORM
:
886 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
890 case MESA_FORMAT_A1B5G5R5_UNORM
:
891 *datatype
= GL_UNSIGNED_SHORT_5_5_5_1
;
895 case MESA_FORMAT_L4A4_UNORM
:
896 *datatype
= MESA_UNSIGNED_BYTE_4_4
;
900 case MESA_FORMAT_L8A8_UNORM
:
901 case MESA_FORMAT_A8L8_UNORM
:
902 case MESA_FORMAT_R8G8_UNORM
:
903 case MESA_FORMAT_G8R8_UNORM
:
904 *datatype
= GL_UNSIGNED_BYTE
;
908 case MESA_FORMAT_L16A16_UNORM
:
909 case MESA_FORMAT_A16L16_UNORM
:
910 case MESA_FORMAT_R16G16_UNORM
:
911 case MESA_FORMAT_G16R16_UNORM
:
912 *datatype
= GL_UNSIGNED_SHORT
;
916 case MESA_FORMAT_R_UNORM16
:
917 case MESA_FORMAT_A_UNORM16
:
918 case MESA_FORMAT_L_UNORM16
:
919 case MESA_FORMAT_I_UNORM16
:
920 *datatype
= GL_UNSIGNED_SHORT
;
924 case MESA_FORMAT_B2G3R3_UNORM
:
925 *datatype
= GL_UNSIGNED_BYTE_3_3_2
;
929 case MESA_FORMAT_A_UNORM8
:
930 case MESA_FORMAT_L_UNORM8
:
931 case MESA_FORMAT_I_UNORM8
:
932 case MESA_FORMAT_R_UNORM8
:
933 case MESA_FORMAT_S_UINT8
:
934 *datatype
= GL_UNSIGNED_BYTE
;
938 case MESA_FORMAT_YCBCR
:
939 case MESA_FORMAT_YCBCR_REV
:
940 *datatype
= GL_UNSIGNED_SHORT
;
944 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
945 *datatype
= GL_UNSIGNED_INT_24_8_MESA
;
949 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
950 *datatype
= GL_UNSIGNED_INT_8_24_REV_MESA
;
954 case MESA_FORMAT_Z_UNORM16
:
955 *datatype
= GL_UNSIGNED_SHORT
;
959 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
960 *datatype
= GL_UNSIGNED_INT
;
964 case MESA_FORMAT_X8_UINT_Z24_UNORM
:
965 *datatype
= GL_UNSIGNED_INT
;
969 case MESA_FORMAT_Z_UNORM32
:
970 *datatype
= GL_UNSIGNED_INT
;
974 case MESA_FORMAT_Z_FLOAT32
:
975 *datatype
= GL_FLOAT
;
979 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
980 *datatype
= GL_FLOAT_32_UNSIGNED_INT_24_8_REV
;
984 case MESA_FORMAT_R_SNORM8
:
985 case MESA_FORMAT_A_SNORM8
:
986 case MESA_FORMAT_L_SNORM8
:
987 case MESA_FORMAT_I_SNORM8
:
991 case MESA_FORMAT_R8G8_SNORM
:
992 case MESA_FORMAT_L8A8_SNORM
:
993 case MESA_FORMAT_A8L8_SNORM
:
997 case MESA_FORMAT_A8B8G8R8_SNORM
:
998 case MESA_FORMAT_R8G8B8A8_SNORM
:
999 case MESA_FORMAT_X8B8G8R8_SNORM
:
1000 *datatype
= GL_BYTE
;
1004 case MESA_FORMAT_RGBA_UNORM16
:
1005 *datatype
= GL_UNSIGNED_SHORT
;
1009 case MESA_FORMAT_R_SNORM16
:
1010 case MESA_FORMAT_A_SNORM16
:
1011 case MESA_FORMAT_L_SNORM16
:
1012 case MESA_FORMAT_I_SNORM16
:
1013 *datatype
= GL_SHORT
;
1016 case MESA_FORMAT_R16G16_SNORM
:
1017 case MESA_FORMAT_LA_SNORM16
:
1018 *datatype
= GL_SHORT
;
1021 case MESA_FORMAT_RGB_SNORM16
:
1022 *datatype
= GL_SHORT
;
1025 case MESA_FORMAT_RGBA_SNORM16
:
1026 *datatype
= GL_SHORT
;
1030 case MESA_FORMAT_BGR_SRGB8
:
1031 *datatype
= GL_UNSIGNED_BYTE
;
1034 case MESA_FORMAT_A8B8G8R8_SRGB
:
1035 case MESA_FORMAT_B8G8R8A8_SRGB
:
1036 case MESA_FORMAT_A8R8G8B8_SRGB
:
1037 case MESA_FORMAT_R8G8B8A8_SRGB
:
1038 *datatype
= GL_UNSIGNED_BYTE
;
1041 case MESA_FORMAT_L_SRGB8
:
1042 *datatype
= GL_UNSIGNED_BYTE
;
1045 case MESA_FORMAT_L8A8_SRGB
:
1046 case MESA_FORMAT_A8L8_SRGB
:
1047 *datatype
= GL_UNSIGNED_BYTE
;
1051 case MESA_FORMAT_RGB_FXT1
:
1052 case MESA_FORMAT_RGBA_FXT1
:
1053 case MESA_FORMAT_RGB_DXT1
:
1054 case MESA_FORMAT_RGBA_DXT1
:
1055 case MESA_FORMAT_RGBA_DXT3
:
1056 case MESA_FORMAT_RGBA_DXT5
:
1057 case MESA_FORMAT_SRGB_DXT1
:
1058 case MESA_FORMAT_SRGBA_DXT1
:
1059 case MESA_FORMAT_SRGBA_DXT3
:
1060 case MESA_FORMAT_SRGBA_DXT5
:
1061 case MESA_FORMAT_R_RGTC1_UNORM
:
1062 case MESA_FORMAT_R_RGTC1_SNORM
:
1063 case MESA_FORMAT_RG_RGTC2_UNORM
:
1064 case MESA_FORMAT_RG_RGTC2_SNORM
:
1065 case MESA_FORMAT_L_LATC1_UNORM
:
1066 case MESA_FORMAT_L_LATC1_SNORM
:
1067 case MESA_FORMAT_LA_LATC2_UNORM
:
1068 case MESA_FORMAT_LA_LATC2_SNORM
:
1069 case MESA_FORMAT_ETC1_RGB8
:
1070 case MESA_FORMAT_ETC2_RGB8
:
1071 case MESA_FORMAT_ETC2_SRGB8
:
1072 case MESA_FORMAT_ETC2_RGBA8_EAC
:
1073 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
1074 case MESA_FORMAT_ETC2_R11_EAC
:
1075 case MESA_FORMAT_ETC2_RG11_EAC
:
1076 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
1077 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
1078 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
1079 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
1080 case MESA_FORMAT_BPTC_RGBA_UNORM
:
1081 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
1082 case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
:
1083 case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
:
1084 /* XXX generate error instead? */
1085 *datatype
= GL_UNSIGNED_BYTE
;
1089 case MESA_FORMAT_RGBA_FLOAT32
:
1090 *datatype
= GL_FLOAT
;
1093 case MESA_FORMAT_RGBA_FLOAT16
:
1094 *datatype
= GL_HALF_FLOAT_ARB
;
1097 case MESA_FORMAT_RGB_FLOAT32
:
1098 *datatype
= GL_FLOAT
;
1101 case MESA_FORMAT_RGB_FLOAT16
:
1102 *datatype
= GL_HALF_FLOAT_ARB
;
1105 case MESA_FORMAT_LA_FLOAT32
:
1106 case MESA_FORMAT_RG_FLOAT32
:
1107 *datatype
= GL_FLOAT
;
1110 case MESA_FORMAT_LA_FLOAT16
:
1111 case MESA_FORMAT_RG_FLOAT16
:
1112 *datatype
= GL_HALF_FLOAT_ARB
;
1115 case MESA_FORMAT_A_FLOAT32
:
1116 case MESA_FORMAT_L_FLOAT32
:
1117 case MESA_FORMAT_I_FLOAT32
:
1118 case MESA_FORMAT_R_FLOAT32
:
1119 *datatype
= GL_FLOAT
;
1122 case MESA_FORMAT_A_FLOAT16
:
1123 case MESA_FORMAT_L_FLOAT16
:
1124 case MESA_FORMAT_I_FLOAT16
:
1125 case MESA_FORMAT_R_FLOAT16
:
1126 *datatype
= GL_HALF_FLOAT_ARB
;
1130 case MESA_FORMAT_A_UINT8
:
1131 case MESA_FORMAT_L_UINT8
:
1132 case MESA_FORMAT_I_UINT8
:
1133 *datatype
= GL_UNSIGNED_BYTE
;
1136 case MESA_FORMAT_LA_UINT8
:
1137 *datatype
= GL_UNSIGNED_BYTE
;
1141 case MESA_FORMAT_A_UINT16
:
1142 case MESA_FORMAT_L_UINT16
:
1143 case MESA_FORMAT_I_UINT16
:
1144 *datatype
= GL_UNSIGNED_SHORT
;
1147 case MESA_FORMAT_LA_UINT16
:
1148 *datatype
= GL_UNSIGNED_SHORT
;
1151 case MESA_FORMAT_A_UINT32
:
1152 case MESA_FORMAT_L_UINT32
:
1153 case MESA_FORMAT_I_UINT32
:
1154 *datatype
= GL_UNSIGNED_INT
;
1157 case MESA_FORMAT_LA_UINT32
:
1158 *datatype
= GL_UNSIGNED_INT
;
1161 case MESA_FORMAT_A_SINT8
:
1162 case MESA_FORMAT_L_SINT8
:
1163 case MESA_FORMAT_I_SINT8
:
1164 *datatype
= GL_BYTE
;
1167 case MESA_FORMAT_LA_SINT8
:
1168 *datatype
= GL_BYTE
;
1172 case MESA_FORMAT_A_SINT16
:
1173 case MESA_FORMAT_L_SINT16
:
1174 case MESA_FORMAT_I_SINT16
:
1175 *datatype
= GL_SHORT
;
1178 case MESA_FORMAT_LA_SINT16
:
1179 *datatype
= GL_SHORT
;
1183 case MESA_FORMAT_A_SINT32
:
1184 case MESA_FORMAT_L_SINT32
:
1185 case MESA_FORMAT_I_SINT32
:
1189 case MESA_FORMAT_LA_SINT32
:
1194 case MESA_FORMAT_R_SINT8
:
1195 *datatype
= GL_BYTE
;
1198 case MESA_FORMAT_RG_SINT8
:
1199 *datatype
= GL_BYTE
;
1202 case MESA_FORMAT_RGB_SINT8
:
1203 *datatype
= GL_BYTE
;
1206 case MESA_FORMAT_RGBA_SINT8
:
1207 *datatype
= GL_BYTE
;
1210 case MESA_FORMAT_R_SINT16
:
1211 *datatype
= GL_SHORT
;
1214 case MESA_FORMAT_RG_SINT16
:
1215 *datatype
= GL_SHORT
;
1218 case MESA_FORMAT_RGB_SINT16
:
1219 *datatype
= GL_SHORT
;
1222 case MESA_FORMAT_RGBA_SINT16
:
1223 *datatype
= GL_SHORT
;
1226 case MESA_FORMAT_R_SINT32
:
1230 case MESA_FORMAT_RG_SINT32
:
1234 case MESA_FORMAT_RGB_SINT32
:
1238 case MESA_FORMAT_RGBA_SINT32
:
1244 * \name Non-normalized unsigned integer formats.
1246 case MESA_FORMAT_R_UINT8
:
1247 *datatype
= GL_UNSIGNED_BYTE
;
1250 case MESA_FORMAT_RG_UINT8
:
1251 *datatype
= GL_UNSIGNED_BYTE
;
1254 case MESA_FORMAT_RGB_UINT8
:
1255 *datatype
= GL_UNSIGNED_BYTE
;
1258 case MESA_FORMAT_RGBA_UINT8
:
1259 *datatype
= GL_UNSIGNED_BYTE
;
1262 case MESA_FORMAT_R_UINT16
:
1263 *datatype
= GL_UNSIGNED_SHORT
;
1266 case MESA_FORMAT_RG_UINT16
:
1267 *datatype
= GL_UNSIGNED_SHORT
;
1270 case MESA_FORMAT_RGB_UINT16
:
1271 *datatype
= GL_UNSIGNED_SHORT
;
1274 case MESA_FORMAT_RGBA_UINT16
:
1275 *datatype
= GL_UNSIGNED_SHORT
;
1278 case MESA_FORMAT_R_UINT32
:
1279 *datatype
= GL_UNSIGNED_INT
;
1282 case MESA_FORMAT_RG_UINT32
:
1283 *datatype
= GL_UNSIGNED_INT
;
1286 case MESA_FORMAT_RGB_UINT32
:
1287 *datatype
= GL_UNSIGNED_INT
;
1290 case MESA_FORMAT_RGBA_UINT32
:
1291 *datatype
= GL_UNSIGNED_INT
;
1295 case MESA_FORMAT_R9G9B9E5_FLOAT
:
1296 *datatype
= GL_UNSIGNED_INT_5_9_9_9_REV
;
1300 case MESA_FORMAT_R11G11B10_FLOAT
:
1301 *datatype
= GL_UNSIGNED_INT_10F_11F_11F_REV
;
1305 case MESA_FORMAT_B10G10R10A2_UINT
:
1306 case MESA_FORMAT_R10G10B10A2_UINT
:
1307 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1311 case MESA_FORMAT_R8G8B8X8_SRGB
:
1312 case MESA_FORMAT_X8B8G8R8_SRGB
:
1313 case MESA_FORMAT_RGBX_UINT8
:
1314 *datatype
= GL_UNSIGNED_BYTE
;
1318 case MESA_FORMAT_R8G8B8X8_SNORM
:
1319 case MESA_FORMAT_RGBX_SINT8
:
1320 *datatype
= GL_BYTE
;
1324 case MESA_FORMAT_B10G10R10X2_UNORM
:
1325 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1329 case MESA_FORMAT_RGBX_UNORM16
:
1330 case MESA_FORMAT_RGBX_UINT16
:
1331 *datatype
= GL_UNSIGNED_SHORT
;
1335 case MESA_FORMAT_RGBX_SNORM16
:
1336 case MESA_FORMAT_RGBX_SINT16
:
1337 *datatype
= GL_SHORT
;
1341 case MESA_FORMAT_RGBX_FLOAT16
:
1342 *datatype
= GL_HALF_FLOAT
;
1346 case MESA_FORMAT_RGBX_FLOAT32
:
1347 *datatype
= GL_FLOAT
;
1351 case MESA_FORMAT_RGBX_UINT32
:
1352 *datatype
= GL_UNSIGNED_INT
;
1356 case MESA_FORMAT_RGBX_SINT32
:
1361 case MESA_FORMAT_R10G10B10A2_UNORM
:
1362 *datatype
= GL_UNSIGNED_INT_2_10_10_10_REV
;
1366 case MESA_FORMAT_G8R8_SNORM
:
1367 *datatype
= GL_BYTE
;
1371 case MESA_FORMAT_G16R16_SNORM
:
1372 *datatype
= GL_SHORT
;
1376 case MESA_FORMAT_B8G8R8X8_SRGB
:
1377 case MESA_FORMAT_X8R8G8B8_SRGB
:
1378 *datatype
= GL_UNSIGNED_BYTE
;
1382 case MESA_FORMAT_COUNT
:
1386 case MESA_FORMAT_NONE
:
1387 /* For debug builds, warn if any formats are not handled */
1391 _mesa_problem(NULL
, "bad format %s in _mesa_format_to_type_and_comps",
1392 _mesa_get_format_name(format
));
1399 * Check if a mesa_format exactly matches a GL format/type combination
1400 * such that we can use memcpy() from one to the other.
1401 * \param mesa_format a MESA_FORMAT_x value
1402 * \param format the user-specified image format
1403 * \param type the user-specified image datatype
1404 * \param swapBytes typically the current pixel pack/unpack byteswap state
1405 * \return GL_TRUE if the formats match, GL_FALSE otherwise.
1408 _mesa_format_matches_format_and_type(mesa_format mesa_format
,
1409 GLenum format
, GLenum type
,
1410 GLboolean swapBytes
)
1412 const GLboolean littleEndian
= _mesa_little_endian();
1414 /* Note: When reading a GL format/type combination, the format lists channel
1415 * assignments from most significant channel in the type to least
1416 * significant. A type with _REV indicates that the assignments are
1417 * swapped, so they are listed from least significant to most significant.
1419 * For sanity, please keep this switch statement ordered the same as the
1420 * enums in formats.h.
1423 switch (mesa_format
) {
1425 case MESA_FORMAT_NONE
:
1426 case MESA_FORMAT_COUNT
:
1429 case MESA_FORMAT_A8B8G8R8_UNORM
:
1430 case MESA_FORMAT_A8B8G8R8_SRGB
:
1431 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& !swapBytes
)
1434 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&& swapBytes
)
1437 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_BYTE
&& !littleEndian
)
1440 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
1444 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8
1448 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
)
1453 case MESA_FORMAT_R8G8B8A8_UNORM
:
1454 case MESA_FORMAT_R8G8B8A8_SRGB
:
1455 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1459 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& swapBytes
)
1462 if (format
== GL_RGBA
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
)
1465 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8
&&
1469 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1473 if (format
== GL_ABGR_EXT
&& type
== GL_UNSIGNED_BYTE
&& !littleEndian
)
1478 case MESA_FORMAT_B8G8R8A8_UNORM
:
1479 case MESA_FORMAT_B8G8R8A8_SRGB
:
1480 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1484 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& swapBytes
)
1487 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
)
1492 case MESA_FORMAT_A8R8G8B8_UNORM
:
1493 case MESA_FORMAT_A8R8G8B8_SRGB
:
1494 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8
&& !swapBytes
)
1497 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_8_8_8_8_REV
&&
1501 if (format
== GL_BGRA
&& type
== GL_UNSIGNED_BYTE
&& !littleEndian
)
1506 case MESA_FORMAT_X8B8G8R8_UNORM
:
1507 case MESA_FORMAT_R8G8B8X8_UNORM
:
1510 case MESA_FORMAT_B8G8R8X8_UNORM
:
1511 case MESA_FORMAT_X8R8G8B8_UNORM
:
1514 case MESA_FORMAT_BGR_UNORM8
:
1515 case MESA_FORMAT_BGR_SRGB8
:
1516 return format
== GL_BGR
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1518 case MESA_FORMAT_RGB_UNORM8
:
1519 return format
== GL_RGB
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1521 case MESA_FORMAT_B5G6R5_UNORM
:
1522 return ((format
== GL_RGB
&& type
== GL_UNSIGNED_SHORT_5_6_5
) ||
1523 (format
== GL_BGR
&& type
== GL_UNSIGNED_SHORT_5_6_5_REV
)) &&
1526 case MESA_FORMAT_R5G6B5_UNORM
:
1527 return ((format
== GL_BGR
&& type
== GL_UNSIGNED_SHORT_5_6_5
) ||
1528 (format
== GL_RGB
&& type
== GL_UNSIGNED_SHORT_5_6_5_REV
)) &&
1531 case MESA_FORMAT_B4G4R4A4_UNORM
:
1532 return format
== GL_BGRA
&& type
== GL_UNSIGNED_SHORT_4_4_4_4_REV
&&
1535 case MESA_FORMAT_A4R4G4B4_UNORM
:
1538 case MESA_FORMAT_A1B5G5R5_UNORM
:
1539 return format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT_5_5_5_1
&&
1542 case MESA_FORMAT_B5G5R5A1_UNORM
:
1543 return format
== GL_BGRA
&& type
== GL_UNSIGNED_SHORT_1_5_5_5_REV
&&
1546 case MESA_FORMAT_A1R5G5B5_UNORM
:
1547 return format
== GL_BGRA
&& type
== GL_UNSIGNED_SHORT_5_5_5_1
&&
1550 case MESA_FORMAT_L4A4_UNORM
:
1552 case MESA_FORMAT_L8A8_UNORM
:
1553 case MESA_FORMAT_L8A8_SRGB
:
1554 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1555 case MESA_FORMAT_A8L8_UNORM
:
1556 case MESA_FORMAT_A8L8_SRGB
:
1559 case MESA_FORMAT_L16A16_UNORM
:
1560 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_UNSIGNED_SHORT
&& littleEndian
&& !swapBytes
;
1561 case MESA_FORMAT_A16L16_UNORM
:
1564 case MESA_FORMAT_B2G3R3_UNORM
:
1565 return format
== GL_RGB
&& type
== GL_UNSIGNED_BYTE_3_3_2
;
1567 case MESA_FORMAT_A_UNORM8
:
1568 return format
== GL_ALPHA
&& type
== GL_UNSIGNED_BYTE
;
1569 case MESA_FORMAT_A_UNORM16
:
1570 return format
== GL_ALPHA
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1571 case MESA_FORMAT_L_UNORM8
:
1572 case MESA_FORMAT_L_SRGB8
:
1573 return format
== GL_LUMINANCE
&& type
== GL_UNSIGNED_BYTE
;
1574 case MESA_FORMAT_L_UNORM16
:
1575 return format
== GL_LUMINANCE
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1576 case MESA_FORMAT_I_UNORM8
:
1577 return format
== GL_RED
&& type
== GL_UNSIGNED_BYTE
;
1578 case MESA_FORMAT_I_UNORM16
:
1579 return format
== GL_RED
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1581 case MESA_FORMAT_YCBCR
:
1582 return format
== GL_YCBCR_MESA
&&
1583 ((type
== GL_UNSIGNED_SHORT_8_8_MESA
&& littleEndian
!= swapBytes
) ||
1584 (type
== GL_UNSIGNED_SHORT_8_8_REV_MESA
&& littleEndian
== swapBytes
));
1585 case MESA_FORMAT_YCBCR_REV
:
1586 return format
== GL_YCBCR_MESA
&&
1587 ((type
== GL_UNSIGNED_SHORT_8_8_MESA
&& littleEndian
== swapBytes
) ||
1588 (type
== GL_UNSIGNED_SHORT_8_8_REV_MESA
&& littleEndian
!= swapBytes
));
1590 case MESA_FORMAT_R_UNORM8
:
1591 return format
== GL_RED
&& type
== GL_UNSIGNED_BYTE
;
1592 case MESA_FORMAT_R8G8_UNORM
:
1593 return format
== GL_RG
&& type
== GL_UNSIGNED_BYTE
&& littleEndian
;
1594 case MESA_FORMAT_G8R8_UNORM
:
1597 case MESA_FORMAT_R_UNORM16
:
1598 return format
== GL_RED
&& type
== GL_UNSIGNED_SHORT
&&
1600 case MESA_FORMAT_R16G16_UNORM
:
1601 return format
== GL_RG
&& type
== GL_UNSIGNED_SHORT
&& littleEndian
&&
1603 case MESA_FORMAT_G16R16_UNORM
:
1606 case MESA_FORMAT_B10G10R10A2_UNORM
:
1607 return format
== GL_BGRA
&& type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1610 case MESA_FORMAT_S8_UINT_Z24_UNORM
:
1611 return format
== GL_DEPTH_STENCIL
&& type
== GL_UNSIGNED_INT_24_8
&&
1613 case MESA_FORMAT_X8_UINT_Z24_UNORM
:
1614 case MESA_FORMAT_Z24_UNORM_S8_UINT
:
1617 case MESA_FORMAT_Z_UNORM16
:
1618 return format
== GL_DEPTH_COMPONENT
&& type
== GL_UNSIGNED_SHORT
&&
1621 case MESA_FORMAT_Z24_UNORM_X8_UINT
:
1624 case MESA_FORMAT_Z_UNORM32
:
1625 return format
== GL_DEPTH_COMPONENT
&& type
== GL_UNSIGNED_INT
&&
1628 case MESA_FORMAT_S_UINT8
:
1629 return format
== GL_STENCIL_INDEX
&& type
== GL_UNSIGNED_BYTE
;
1631 case MESA_FORMAT_SRGB_DXT1
:
1632 case MESA_FORMAT_SRGBA_DXT1
:
1633 case MESA_FORMAT_SRGBA_DXT3
:
1634 case MESA_FORMAT_SRGBA_DXT5
:
1637 case MESA_FORMAT_RGB_FXT1
:
1638 case MESA_FORMAT_RGBA_FXT1
:
1639 case MESA_FORMAT_RGB_DXT1
:
1640 case MESA_FORMAT_RGBA_DXT1
:
1641 case MESA_FORMAT_RGBA_DXT3
:
1642 case MESA_FORMAT_RGBA_DXT5
:
1645 case MESA_FORMAT_BPTC_RGBA_UNORM
:
1646 case MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM
:
1647 case MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT
:
1648 case MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT
:
1651 case MESA_FORMAT_RGBA_FLOAT32
:
1652 return format
== GL_RGBA
&& type
== GL_FLOAT
&& !swapBytes
;
1653 case MESA_FORMAT_RGBA_FLOAT16
:
1654 return format
== GL_RGBA
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1656 case MESA_FORMAT_RGB_FLOAT32
:
1657 return format
== GL_RGB
&& type
== GL_FLOAT
&& !swapBytes
;
1658 case MESA_FORMAT_RGB_FLOAT16
:
1659 return format
== GL_RGB
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1661 case MESA_FORMAT_A_FLOAT32
:
1662 return format
== GL_ALPHA
&& type
== GL_FLOAT
&& !swapBytes
;
1663 case MESA_FORMAT_A_FLOAT16
:
1664 return format
== GL_ALPHA
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1666 case MESA_FORMAT_L_FLOAT32
:
1667 return format
== GL_LUMINANCE
&& type
== GL_FLOAT
&& !swapBytes
;
1668 case MESA_FORMAT_L_FLOAT16
:
1669 return format
== GL_LUMINANCE
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1671 case MESA_FORMAT_LA_FLOAT32
:
1672 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_FLOAT
&& !swapBytes
;
1673 case MESA_FORMAT_LA_FLOAT16
:
1674 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1676 case MESA_FORMAT_I_FLOAT32
:
1677 return format
== GL_RED
&& type
== GL_FLOAT
&& !swapBytes
;
1678 case MESA_FORMAT_I_FLOAT16
:
1679 return format
== GL_RED
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1681 case MESA_FORMAT_R_FLOAT32
:
1682 return format
== GL_RED
&& type
== GL_FLOAT
&& !swapBytes
;
1683 case MESA_FORMAT_R_FLOAT16
:
1684 return format
== GL_RED
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1686 case MESA_FORMAT_RG_FLOAT32
:
1687 return format
== GL_RG
&& type
== GL_FLOAT
&& !swapBytes
;
1688 case MESA_FORMAT_RG_FLOAT16
:
1689 return format
== GL_RG
&& type
== GL_HALF_FLOAT
&& !swapBytes
;
1691 case MESA_FORMAT_A_UINT8
:
1692 return format
== GL_ALPHA_INTEGER
&& type
== GL_UNSIGNED_BYTE
;
1693 case MESA_FORMAT_A_UINT16
:
1694 return format
== GL_ALPHA_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1696 case MESA_FORMAT_A_UINT32
:
1697 return format
== GL_ALPHA_INTEGER
&& type
== GL_UNSIGNED_INT
&&
1699 case MESA_FORMAT_A_SINT8
:
1700 return format
== GL_ALPHA_INTEGER
&& type
== GL_BYTE
;
1701 case MESA_FORMAT_A_SINT16
:
1702 return format
== GL_ALPHA_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1703 case MESA_FORMAT_A_SINT32
:
1704 return format
== GL_ALPHA_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1706 case MESA_FORMAT_I_UINT8
:
1707 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_BYTE
;
1708 case MESA_FORMAT_I_UINT16
:
1709 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1710 case MESA_FORMAT_I_UINT32
:
1711 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1712 case MESA_FORMAT_I_SINT8
:
1713 return format
== GL_RED_INTEGER
&& type
== GL_BYTE
;
1714 case MESA_FORMAT_I_SINT16
:
1715 return format
== GL_RED_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1716 case MESA_FORMAT_I_SINT32
:
1717 return format
== GL_RED_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1719 case MESA_FORMAT_L_UINT8
:
1720 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_UNSIGNED_BYTE
;
1721 case MESA_FORMAT_L_UINT16
:
1722 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_UNSIGNED_SHORT
&&
1724 case MESA_FORMAT_L_UINT32
:
1725 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_UNSIGNED_INT
&&
1727 case MESA_FORMAT_L_SINT8
:
1728 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_BYTE
;
1729 case MESA_FORMAT_L_SINT16
:
1730 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_SHORT
&&
1732 case MESA_FORMAT_L_SINT32
:
1733 return format
== GL_LUMINANCE_INTEGER_EXT
&& type
== GL_INT
&& !swapBytes
;
1735 case MESA_FORMAT_LA_UINT8
:
1736 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&&
1737 type
== GL_UNSIGNED_BYTE
&& !swapBytes
;
1738 case MESA_FORMAT_LA_UINT16
:
1739 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&&
1740 type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1741 case MESA_FORMAT_LA_UINT32
:
1742 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&&
1743 type
== GL_UNSIGNED_INT
&& !swapBytes
;
1744 case MESA_FORMAT_LA_SINT8
:
1745 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&& type
== GL_BYTE
&&
1747 case MESA_FORMAT_LA_SINT16
:
1748 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&& type
== GL_SHORT
&&
1750 case MESA_FORMAT_LA_SINT32
:
1751 return format
== GL_LUMINANCE_ALPHA_INTEGER_EXT
&& type
== GL_INT
&&
1754 case MESA_FORMAT_R_SINT8
:
1755 return format
== GL_RED_INTEGER
&& type
== GL_BYTE
;
1756 case MESA_FORMAT_RG_SINT8
:
1757 return format
== GL_RG_INTEGER
&& type
== GL_BYTE
&& !swapBytes
;
1758 case MESA_FORMAT_RGB_SINT8
:
1759 return format
== GL_RGB_INTEGER
&& type
== GL_BYTE
&& !swapBytes
;
1760 case MESA_FORMAT_RGBA_SINT8
:
1761 return format
== GL_RGBA_INTEGER
&& type
== GL_BYTE
&& !swapBytes
;
1762 case MESA_FORMAT_R_SINT16
:
1763 return format
== GL_RED_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1764 case MESA_FORMAT_RG_SINT16
:
1765 return format
== GL_RG_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1766 case MESA_FORMAT_RGB_SINT16
:
1767 return format
== GL_RGB_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1768 case MESA_FORMAT_RGBA_SINT16
:
1769 return format
== GL_RGBA_INTEGER
&& type
== GL_SHORT
&& !swapBytes
;
1770 case MESA_FORMAT_R_SINT32
:
1771 return format
== GL_RED_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1772 case MESA_FORMAT_RG_SINT32
:
1773 return format
== GL_RG_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1774 case MESA_FORMAT_RGB_SINT32
:
1775 return format
== GL_RGB_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1776 case MESA_FORMAT_RGBA_SINT32
:
1777 return format
== GL_RGBA_INTEGER
&& type
== GL_INT
&& !swapBytes
;
1779 case MESA_FORMAT_R_UINT8
:
1780 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_BYTE
;
1781 case MESA_FORMAT_RG_UINT8
:
1782 return format
== GL_RG_INTEGER
&& type
== GL_UNSIGNED_BYTE
&& !swapBytes
;
1783 case MESA_FORMAT_RGB_UINT8
:
1784 return format
== GL_RGB_INTEGER
&& type
== GL_UNSIGNED_BYTE
&& !swapBytes
;
1785 case MESA_FORMAT_RGBA_UINT8
:
1786 return format
== GL_RGBA_INTEGER
&& type
== GL_UNSIGNED_BYTE
&&
1788 case MESA_FORMAT_R_UINT16
:
1789 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1791 case MESA_FORMAT_RG_UINT16
:
1792 return format
== GL_RG_INTEGER
&& type
== GL_UNSIGNED_SHORT
&& !swapBytes
;
1793 case MESA_FORMAT_RGB_UINT16
:
1794 return format
== GL_RGB_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1796 case MESA_FORMAT_RGBA_UINT16
:
1797 return format
== GL_RGBA_INTEGER
&& type
== GL_UNSIGNED_SHORT
&&
1799 case MESA_FORMAT_R_UINT32
:
1800 return format
== GL_RED_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1801 case MESA_FORMAT_RG_UINT32
:
1802 return format
== GL_RG_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1803 case MESA_FORMAT_RGB_UINT32
:
1804 return format
== GL_RGB_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1805 case MESA_FORMAT_RGBA_UINT32
:
1806 return format
== GL_RGBA_INTEGER
&& type
== GL_UNSIGNED_INT
&& !swapBytes
;
1808 case MESA_FORMAT_R_SNORM8
:
1809 return format
== GL_RED
&& type
== GL_BYTE
;
1810 case MESA_FORMAT_R8G8_SNORM
:
1811 return format
== GL_RG
&& type
== GL_BYTE
&& littleEndian
&&
1813 case MESA_FORMAT_X8B8G8R8_SNORM
:
1816 case MESA_FORMAT_A8B8G8R8_SNORM
:
1817 if (format
== GL_RGBA
&& type
== GL_BYTE
&& !littleEndian
)
1820 if (format
== GL_ABGR_EXT
&& type
== GL_BYTE
&& littleEndian
)
1825 case MESA_FORMAT_R8G8B8A8_SNORM
:
1826 if (format
== GL_RGBA
&& type
== GL_BYTE
&& littleEndian
)
1829 if (format
== GL_ABGR_EXT
&& type
== GL_BYTE
&& !littleEndian
)
1834 case MESA_FORMAT_R_SNORM16
:
1835 return format
== GL_RED
&& type
== GL_SHORT
&&
1837 case MESA_FORMAT_R16G16_SNORM
:
1838 return format
== GL_RG
&& type
== GL_SHORT
&& littleEndian
&& !swapBytes
;
1839 case MESA_FORMAT_RGB_SNORM16
:
1840 return format
== GL_RGB
&& type
== GL_SHORT
&& !swapBytes
;
1841 case MESA_FORMAT_RGBA_SNORM16
:
1842 return format
== GL_RGBA
&& type
== GL_SHORT
&& !swapBytes
;
1843 case MESA_FORMAT_RGBA_UNORM16
:
1844 return format
== GL_RGBA
&& type
== GL_UNSIGNED_SHORT
&&
1847 case MESA_FORMAT_R_RGTC1_UNORM
:
1848 case MESA_FORMAT_R_RGTC1_SNORM
:
1849 case MESA_FORMAT_RG_RGTC2_UNORM
:
1850 case MESA_FORMAT_RG_RGTC2_SNORM
:
1853 case MESA_FORMAT_L_LATC1_UNORM
:
1854 case MESA_FORMAT_L_LATC1_SNORM
:
1855 case MESA_FORMAT_LA_LATC2_UNORM
:
1856 case MESA_FORMAT_LA_LATC2_SNORM
:
1859 case MESA_FORMAT_ETC1_RGB8
:
1860 case MESA_FORMAT_ETC2_RGB8
:
1861 case MESA_FORMAT_ETC2_SRGB8
:
1862 case MESA_FORMAT_ETC2_RGBA8_EAC
:
1863 case MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC
:
1864 case MESA_FORMAT_ETC2_R11_EAC
:
1865 case MESA_FORMAT_ETC2_RG11_EAC
:
1866 case MESA_FORMAT_ETC2_SIGNED_R11_EAC
:
1867 case MESA_FORMAT_ETC2_SIGNED_RG11_EAC
:
1868 case MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1
:
1869 case MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1
:
1872 case MESA_FORMAT_A_SNORM8
:
1873 return format
== GL_ALPHA
&& type
== GL_BYTE
;
1874 case MESA_FORMAT_L_SNORM8
:
1875 return format
== GL_LUMINANCE
&& type
== GL_BYTE
;
1876 case MESA_FORMAT_L8A8_SNORM
:
1877 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_BYTE
&&
1878 littleEndian
&& !swapBytes
;
1879 case MESA_FORMAT_A8L8_SNORM
:
1880 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_BYTE
&&
1881 !littleEndian
&& !swapBytes
;
1882 case MESA_FORMAT_I_SNORM8
:
1883 return format
== GL_RED
&& type
== GL_BYTE
;
1884 case MESA_FORMAT_A_SNORM16
:
1885 return format
== GL_ALPHA
&& type
== GL_SHORT
&& !swapBytes
;
1886 case MESA_FORMAT_L_SNORM16
:
1887 return format
== GL_LUMINANCE
&& type
== GL_SHORT
&& !swapBytes
;
1888 case MESA_FORMAT_LA_SNORM16
:
1889 return format
== GL_LUMINANCE_ALPHA
&& type
== GL_SHORT
&&
1890 littleEndian
&& !swapBytes
;
1891 case MESA_FORMAT_I_SNORM16
:
1892 return format
== GL_RED
&& type
== GL_SHORT
&& littleEndian
&&
1895 case MESA_FORMAT_B10G10R10A2_UINT
:
1896 return (format
== GL_BGRA_INTEGER_EXT
&&
1897 type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1900 case MESA_FORMAT_R10G10B10A2_UINT
:
1901 return (format
== GL_RGBA_INTEGER_EXT
&&
1902 type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1905 case MESA_FORMAT_R9G9B9E5_FLOAT
:
1906 return format
== GL_RGB
&& type
== GL_UNSIGNED_INT_5_9_9_9_REV
&&
1909 case MESA_FORMAT_R11G11B10_FLOAT
:
1910 return format
== GL_RGB
&& type
== GL_UNSIGNED_INT_10F_11F_11F_REV
&&
1913 case MESA_FORMAT_Z_FLOAT32
:
1914 return format
== GL_DEPTH_COMPONENT
&& type
== GL_FLOAT
&& !swapBytes
;
1916 case MESA_FORMAT_Z32_FLOAT_S8X24_UINT
:
1917 return format
== GL_DEPTH_STENCIL
&&
1918 type
== GL_FLOAT_32_UNSIGNED_INT_24_8_REV
&& !swapBytes
;
1920 case MESA_FORMAT_B4G4R4X4_UNORM
:
1921 case MESA_FORMAT_B5G5R5X1_UNORM
:
1922 case MESA_FORMAT_R8G8B8X8_SNORM
:
1923 case MESA_FORMAT_R8G8B8X8_SRGB
:
1924 case MESA_FORMAT_X8B8G8R8_SRGB
:
1925 case MESA_FORMAT_RGBX_UINT8
:
1926 case MESA_FORMAT_RGBX_SINT8
:
1927 case MESA_FORMAT_B10G10R10X2_UNORM
:
1928 case MESA_FORMAT_RGBX_UNORM16
:
1929 case MESA_FORMAT_RGBX_SNORM16
:
1930 case MESA_FORMAT_RGBX_FLOAT16
:
1931 case MESA_FORMAT_RGBX_UINT16
:
1932 case MESA_FORMAT_RGBX_SINT16
:
1933 case MESA_FORMAT_RGBX_FLOAT32
:
1934 case MESA_FORMAT_RGBX_UINT32
:
1935 case MESA_FORMAT_RGBX_SINT32
:
1938 case MESA_FORMAT_R10G10B10A2_UNORM
:
1939 return format
== GL_RGBA
&& type
== GL_UNSIGNED_INT_2_10_10_10_REV
&&
1942 case MESA_FORMAT_G8R8_SNORM
:
1943 return format
== GL_RG
&& type
== GL_BYTE
&& !littleEndian
&&
1946 case MESA_FORMAT_G16R16_SNORM
:
1947 return format
== GL_RG
&& type
== GL_SHORT
&& !littleEndian
&&
1950 case MESA_FORMAT_B8G8R8X8_SRGB
:
1951 case MESA_FORMAT_X8R8G8B8_SRGB
: