1 /*
2  * Mesa 3-D graphics library
3  *
4  * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
5  * Copyright (c) 2008-2009  VMware, Inc.
6  *
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:
13  *
14  * The above copyright notice and this permission notice shall be included
15  * in all copies or substantial portions of the Software.
16  *
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.
24  */
25 
26 /*
27  * Authors:
28  *   Brian Paul
29  */
30 
31 
32 #ifndef FORMATS_H
33 #define FORMATS_H
34 
35 
36 #include <GL/gl.h>
37 #include <stdbool.h>
38 #include <stdint.h>
39 #include "gallium/include/pipe/p_format.h"
40 #include "util/u_endian.h"
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 
47 /**
48  * OpenGL doesn't have GL_UNSIGNED_BYTE_4_4, so we must define our own type
49  * for GL_LUMINANCE4_ALPHA4.
50  */
51 #define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1)
52 
53 
54 /**
55  * Max number of bytes for any non-compressed pixel format below, or for
56  * intermediate pixel storage in Mesa.  This should never be less than
57  * 16.  Maybe 32 someday?
58  */
59 #define MAX_PIXEL_BYTES 16
60 
61 /**
62  * Specifies the layout of a pixel format.  See the MESA_FORMAT
63  * documentation below.
64  */
65 enum mesa_format_layout {
66    MESA_FORMAT_LAYOUT_ARRAY,
67    MESA_FORMAT_LAYOUT_PACKED,
68    MESA_FORMAT_LAYOUT_S3TC,
69    MESA_FORMAT_LAYOUT_RGTC,
70    MESA_FORMAT_LAYOUT_LATC,
71    MESA_FORMAT_LAYOUT_FXT1,
72    MESA_FORMAT_LAYOUT_ETC1,
73    MESA_FORMAT_LAYOUT_ETC2,
74    MESA_FORMAT_LAYOUT_BPTC,
75    MESA_FORMAT_LAYOUT_ASTC,
76    MESA_FORMAT_LAYOUT_ATC,
77    MESA_FORMAT_LAYOUT_OTHER,
78 };
79 
80 /**
81  * An enum representing different possible swizzling values.  This is used
82  * to interpret the output of _mesa_get_format_swizzle
83  */
84 enum {
85    MESA_FORMAT_SWIZZLE_X = 0,
86    MESA_FORMAT_SWIZZLE_Y = 1,
87    MESA_FORMAT_SWIZZLE_Z = 2,
88    MESA_FORMAT_SWIZZLE_W = 3,
89    MESA_FORMAT_SWIZZLE_ZERO = 4,
90    MESA_FORMAT_SWIZZLE_ONE = 5,
91    MESA_FORMAT_SWIZZLE_NONE = 6,
92 };
93 
94 /**
95  * An uint32_t that encodes the information necessary to represent an
96  * array format
97  */
98 typedef uint32_t mesa_array_format;
99 
100 /**
101  * Encoding for valid array format data types
102  */
103 enum mesa_array_format_datatype {
104    MESA_ARRAY_FORMAT_TYPE_UBYTE = 0x0,
105    MESA_ARRAY_FORMAT_TYPE_USHORT = 0x1,
106    MESA_ARRAY_FORMAT_TYPE_UINT = 0x2,
107    MESA_ARRAY_FORMAT_TYPE_BYTE = 0x4,
108    MESA_ARRAY_FORMAT_TYPE_SHORT = 0x5,
109    MESA_ARRAY_FORMAT_TYPE_INT = 0x6,
110    MESA_ARRAY_FORMAT_TYPE_HALF = 0xd,
111    MESA_ARRAY_FORMAT_TYPE_FLOAT = 0xe,
112 };
113 
114 enum mesa_array_format_base_format {
115    MESA_ARRAY_FORMAT_BASE_FORMAT_RGBA_VARIANTS = 0x0,
116    MESA_ARRAY_FORMAT_BASE_FORMAT_DEPTH = 0x1,
117    MESA_ARRAY_FORMAT_BASE_FORMAT_STENCIL = 0x2,
118 };
119 
120 /**
121  * An enum useful to encode/decode information stored in a mesa_array_format
122  */
123 enum {
124    MESA_ARRAY_FORMAT_TYPE_IS_SIGNED = 0x4,
125    MESA_ARRAY_FORMAT_TYPE_IS_FLOAT = 0x8,
126    MESA_ARRAY_FORMAT_TYPE_NORMALIZED = 0x10,
127    MESA_ARRAY_FORMAT_DATATYPE_MASK = 0xf,
128    MESA_ARRAY_FORMAT_TYPE_MASK = 0x1f,
129    MESA_ARRAY_FORMAT_TYPE_SIZE_MASK = 0x3,
130    MESA_ARRAY_FORMAT_NUM_CHANS_MASK = 0xe0,
131    MESA_ARRAY_FORMAT_SWIZZLE_X_MASK = 0x00700,
132    MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK = 0x03800,
133    MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK = 0x1c000,
134    MESA_ARRAY_FORMAT_SWIZZLE_W_MASK = 0xe0000,
135    MESA_ARRAY_FORMAT_BASE_FORMAT_MASK = 0x300000,
136    MESA_ARRAY_FORMAT_BIT = 0x80000000
137 };
138 
139 #define MESA_ARRAY_FORMAT(BASE_FORMAT, SIZE, SIGNED, IS_FLOAT, NORM, NUM_CHANS, \
140                           SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W) ( \
141    (((SIZE >> 1)      ) & MESA_ARRAY_FORMAT_TYPE_SIZE_MASK) |      \
142    (((SIGNED)    << 2 ) & MESA_ARRAY_FORMAT_TYPE_IS_SIGNED) |      \
143    (((IS_FLOAT)  << 3 ) & MESA_ARRAY_FORMAT_TYPE_IS_FLOAT) |       \
144    (((NORM)      << 4 ) & MESA_ARRAY_FORMAT_TYPE_NORMALIZED) |     \
145    (((NUM_CHANS) << 5 ) & MESA_ARRAY_FORMAT_NUM_CHANS_MASK) |      \
146    (((SWIZZLE_X) << 8 ) & MESA_ARRAY_FORMAT_SWIZZLE_X_MASK) |      \
147    (((SWIZZLE_Y) << 11) & MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK) |      \
148    (((SWIZZLE_Z) << 14) & MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK) |      \
149    (((SWIZZLE_W) << 17) & MESA_ARRAY_FORMAT_SWIZZLE_W_MASK) |      \
150    (((BASE_FORMAT) << 20) & MESA_ARRAY_FORMAT_BASE_FORMAT_MASK) |  \
151    MESA_ARRAY_FORMAT_BIT)
152 
153 /**
154  * Various helpers to access the data encoded in a mesa_array_format
155  */
156 static inline bool
_mesa_array_format_is_signed(mesa_array_format f)157 _mesa_array_format_is_signed(mesa_array_format f)
158 {
159    return (f & MESA_ARRAY_FORMAT_TYPE_IS_SIGNED) != 0;
160 }
161 
162 static inline bool
_mesa_array_format_is_float(mesa_array_format f)163 _mesa_array_format_is_float(mesa_array_format f)
164 {
165    return (f & MESA_ARRAY_FORMAT_TYPE_IS_FLOAT) != 0;
166 }
167 
168 static inline bool
_mesa_array_format_is_normalized(mesa_array_format f)169 _mesa_array_format_is_normalized(mesa_array_format f)
170 {
171    return (f & MESA_ARRAY_FORMAT_TYPE_NORMALIZED) !=0;
172 }
173 
174 static inline enum mesa_array_format_base_format
_mesa_array_format_get_base_format(mesa_array_format f)175 _mesa_array_format_get_base_format(mesa_array_format f)
176 {
177    return (enum mesa_array_format_base_format)
178       ((f & MESA_ARRAY_FORMAT_BASE_FORMAT_MASK) >> 20);
179 }
180 
181 static inline enum mesa_array_format_datatype
_mesa_array_format_get_datatype(mesa_array_format f)182 _mesa_array_format_get_datatype(mesa_array_format f)
183 {
184    return (enum mesa_array_format_datatype)
185             (f & MESA_ARRAY_FORMAT_DATATYPE_MASK);
186 }
187 
188 static inline int
_mesa_array_format_datatype_get_size(enum mesa_array_format_datatype type)189 _mesa_array_format_datatype_get_size(enum mesa_array_format_datatype type)
190 {
191    return 1 << (type & MESA_ARRAY_FORMAT_TYPE_SIZE_MASK);
192 }
193 
194 static inline int
_mesa_array_format_get_type_size(mesa_array_format f)195 _mesa_array_format_get_type_size(mesa_array_format f)
196 {
197    return 1 << (f & MESA_ARRAY_FORMAT_TYPE_SIZE_MASK);
198 }
199 
200 static inline int
_mesa_array_format_get_num_channels(mesa_array_format f)201 _mesa_array_format_get_num_channels(mesa_array_format f)
202 {
203    return (f & MESA_ARRAY_FORMAT_NUM_CHANS_MASK) >> 5;
204 }
205 
206 static inline void
_mesa_array_format_get_swizzle(mesa_array_format f,uint8_t * swizzle)207 _mesa_array_format_get_swizzle(mesa_array_format f, uint8_t *swizzle)
208 {
209    swizzle[0] = (f & MESA_ARRAY_FORMAT_SWIZZLE_X_MASK) >> 8;
210    swizzle[1] = (f & MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK) >> 11;
211    swizzle[2] = (f & MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK) >> 14;
212    swizzle[3] = (f & MESA_ARRAY_FORMAT_SWIZZLE_W_MASK) >> 17;
213 }
214 
215 static inline void
_mesa_array_format_set_swizzle(mesa_array_format * f,int32_t x,int32_t y,int32_t z,int32_t w)216 _mesa_array_format_set_swizzle(mesa_array_format *f,
217                                int32_t x, int32_t y, int32_t z, int32_t w)
218 {
219    *f &= ~(MESA_ARRAY_FORMAT_SWIZZLE_X_MASK |
220            MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK |
221            MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK |
222            MESA_ARRAY_FORMAT_SWIZZLE_W_MASK);
223 
224    *f |= ((x << 8 ) & MESA_ARRAY_FORMAT_SWIZZLE_X_MASK) |
225          ((y << 11) & MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK) |
226          ((z << 14) & MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK) |
227          ((w << 17) & MESA_ARRAY_FORMAT_SWIZZLE_W_MASK);
228 }
229 
230 /**
231  * A helper to know if the format stored in a uint32_t is a mesa_format
232  * or a mesa_array_format
233  */
234 static inline bool
_mesa_format_is_mesa_array_format(uint32_t f)235 _mesa_format_is_mesa_array_format(uint32_t f)
236 {
237    return (f & MESA_ARRAY_FORMAT_BIT) != 0;
238 }
239 
240 /**
241  * Mesa texture/renderbuffer image formats.  These are just other names of the
242  * gallium p_format.h formats.
243  */
244 typedef enum pipe_format mesa_format;
245 
246    /**
247     * \name Basic hardware formats
248     *
249     * The mesa format name specification is as follows:
250     *
251     *  There shall be 3 naming format base types: those for component array
252     *  formats (type A); those for compressed formats (type C); and those for
253     *  packed component formats (type P). With type A formats, color component
254     *  order does not change with endianess. Each format name shall begin with
255     *  MESA_FORMAT_, followed by a component label (from the Component Label
256     *  list below) for each component in the order that the component(s) occur
257     *  in the format, except for non-linear color formats where the first
258     *  letter shall be 'S'. For type P formats, each component label is
259     *  followed by the number of bits that represent it in the fundamental
260     *  data type used by the format.
261     *
262     *  Following the listing of the component labels shall be an underscore; a
263     *  compression type followed by an underscore for Type C formats only; a
264     *  storage type from the list below; and a bit with for type A formats,
265     *  which is the bit width for each array element.
266     *
267     *
268     *  ----------    Format Base Type A: Array ----------
269     *  MESA_FORMAT_[component list]_[storage type][array element bit width]
270     *
271     *  examples:
272     *  MESA_FORMAT_A_SNORM8     - uchar[i] = A
273     *  MESA_FORMAT_RGBA_16 - ushort[i * 4 + 0] = R, ushort[i * 4 + 1] = G,
274     *                             ushort[i * 4 + 2] = B, ushort[i * 4 + 3] = A
275     *  MESA_FORMAT_Z_UNORM32    - float[i] = Z
276     *
277     *
278     *
279     *  ----------    Format Base Type C: Compressed ----------
280     *  MESA_FORMAT_[component list*][_*][compression type][storage type*]
281     *  * where required
282     *
283     *  examples:
284     *  MESA_FORMAT_RGB_ETC1
285     *  MESA_FORMAT_RGBA_ETC2
286     *  MESA_FORMAT_LATC1_UNORM
287     *  MESA_FORMAT_RGBA_FXT1
288     *
289     *
290     *
291     *  ----------    Format Base Type P: Packed  ----------
292     *  MESA_FORMAT_[[component list,bit width][storage type*][_]][_][storage type**]
293     *   * when type differs between component
294     *   ** when type applies to all components
295     *
296     *  examples:                   msb <------ TEXEL BITS -----------> lsb
297     *  MESA_FORMAT_A8B8G8R8_UNORM, RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA
298     *  MESA_FORMAT_R5G6B5_UNORM                        BBBB BGGG GGGR RRRR
299     *  MESA_FORMAT_B4G4R4X4_UNORM                      XXXX RRRR GGGG BBBB
300     *  MESA_FORMAT_Z32_FLOAT_S8X24_UINT
301     *  MESA_FORMAT_R10G10B10A2_UINT
302     *  MESA_FORMAT_R9G9B9E5_FLOAT
303     *
304     *
305     *
306     *  ----------    Component Labels: ----------
307     *  A - Alpha
308     *  B - Blue
309     *  DU - Delta U
310     *  DV - Delta V
311     *  E - Shared Exponent
312     *  G - Green
313     *  I - Intensity
314     *  L - Luminance
315     *  R - Red
316     *  S - Stencil (when not followed by RGB or RGBA)
317     *  U - Chrominance
318     *  V - Chrominance
319     *  Y - Luma
320     *  X - Packing bits
321     *  Z - Depth
322     *
323     *
324     *
325     *  ----------    Type C Compression Types: ----------
326     *  DXT1 - Color component labels shall be given
327     *  DXT3 - Color component labels shall be given
328     *  DXT5 - Color component labels shall be given
329     *  ETC1 - No other information required
330     *  ETC2 - No other information required
331     *  FXT1 - Color component labels shall be given
332     *  FXT3 - Color component labels shall be given
333     *  LATC1 - Fundamental data type shall be given
334     *  LATC2 - Fundamental data type shall be given
335     *  RGTC1 - Color component labels and data type shall be given
336     *  RGTC2 - Color component labels and data type shall be given
337     *
338     *
339     *
340     *  ----------    Storage Types: ----------
341     *  FLOAT
342     *  SINT
343     *  UINT
344     *  SNORM
345     *  UNORM
346     *  SRGB - RGB components, or L are UNORMs in sRGB color space.
347     *         Alpha, if present is linear.
348     *
349     */
350 
351 #define MESA_FORMAT_NONE                         PIPE_FORMAT_NONE
352 #define MESA_FORMAT_A8B8G8R8_UNORM               PIPE_FORMAT_ABGR8888_UNORM
353 #define MESA_FORMAT_X8B8G8R8_UNORM               PIPE_FORMAT_XBGR8888_UNORM
354 #define MESA_FORMAT_R8G8B8A8_UNORM               PIPE_FORMAT_RGBA8888_UNORM
355 #define MESA_FORMAT_R8G8B8X8_UNORM               PIPE_FORMAT_RGBX8888_UNORM
356 #define MESA_FORMAT_B8G8R8A8_UNORM               PIPE_FORMAT_BGRA8888_UNORM
357 #define MESA_FORMAT_B8G8R8X8_UNORM               PIPE_FORMAT_BGRX8888_UNORM
358 #define MESA_FORMAT_A8R8G8B8_UNORM               PIPE_FORMAT_ARGB8888_UNORM
359 #define MESA_FORMAT_X8R8G8B8_UNORM               PIPE_FORMAT_XRGB8888_UNORM
360 #define MESA_FORMAT_B5G6R5_UNORM                 PIPE_FORMAT_B5G6R5_UNORM
361 #define MESA_FORMAT_R5G6B5_UNORM                 PIPE_FORMAT_R5G6B5_UNORM
362 #define MESA_FORMAT_B4G4R4A4_UNORM               PIPE_FORMAT_B4G4R4A4_UNORM
363 #define MESA_FORMAT_B4G4R4X4_UNORM               PIPE_FORMAT_B4G4R4X4_UNORM
364 #define MESA_FORMAT_A4R4G4B4_UNORM               PIPE_FORMAT_A4R4G4B4_UNORM
365 #define MESA_FORMAT_A1B5G5R5_UNORM               PIPE_FORMAT_A1B5G5R5_UNORM
366 #define MESA_FORMAT_X1B5G5R5_UNORM               PIPE_FORMAT_X1B5G5R5_UNORM
367 #define MESA_FORMAT_B5G5R5A1_UNORM               PIPE_FORMAT_B5G5R5A1_UNORM
368 #define MESA_FORMAT_B5G5R5X1_UNORM               PIPE_FORMAT_B5G5R5X1_UNORM
369 #define MESA_FORMAT_A1R5G5B5_UNORM               PIPE_FORMAT_A1R5G5B5_UNORM
370 #define MESA_FORMAT_L4A4_UNORM                   PIPE_FORMAT_L4A4_UNORM
371 #define MESA_FORMAT_B2G3R3_UNORM                 PIPE_FORMAT_B2G3R3_UNORM
372 #define MESA_FORMAT_B10G10R10A2_UNORM            PIPE_FORMAT_B10G10R10A2_UNORM
373 #define MESA_FORMAT_B10G10R10X2_UNORM            PIPE_FORMAT_B10G10R10X2_UNORM
374 #define MESA_FORMAT_R10G10B10A2_UNORM            PIPE_FORMAT_R10G10B10A2_UNORM
375 #define MESA_FORMAT_R10G10B10X2_UNORM            PIPE_FORMAT_R10G10B10X2_UNORM
376 #define MESA_FORMAT_S8_UINT_Z24_UNORM            PIPE_FORMAT_S8_UINT_Z24_UNORM
377 #define MESA_FORMAT_X8_UINT_Z24_UNORM            PIPE_FORMAT_X8Z24_UNORM
378 #define MESA_FORMAT_Z24_UNORM_S8_UINT            PIPE_FORMAT_Z24_UNORM_S8_UINT
379 #define MESA_FORMAT_Z24_UNORM_X8_UINT            PIPE_FORMAT_Z24X8_UNORM
380 #define MESA_FORMAT_R3G3B2_UNORM                 PIPE_FORMAT_R3G3B2_UNORM
381 #define MESA_FORMAT_A4B4G4R4_UNORM               PIPE_FORMAT_A4B4G4R4_UNORM
382 #define MESA_FORMAT_R4G4B4A4_UNORM               PIPE_FORMAT_R4G4B4A4_UNORM
383 #define MESA_FORMAT_R5G5B5A1_UNORM               PIPE_FORMAT_R5G5B5A1_UNORM
384 #define MESA_FORMAT_A2B10G10R10_UNORM            PIPE_FORMAT_A2B10G10R10_UNORM
385 #define MESA_FORMAT_A2R10G10B10_UNORM            PIPE_FORMAT_A2R10G10B10_UNORM
386 #define MESA_FORMAT_YCBCR                        PIPE_FORMAT_UYVY
387 #define MESA_FORMAT_YCBCR_REV                    PIPE_FORMAT_YUYV
388 #define MESA_FORMAT_A_UNORM8                     PIPE_FORMAT_A8_UNORM
389 #define MESA_FORMAT_A_UNORM16                    PIPE_FORMAT_A16_UNORM
390 #define MESA_FORMAT_L_UNORM8                     PIPE_FORMAT_L8_UNORM
391 #define MESA_FORMAT_L_UNORM16                    PIPE_FORMAT_L16_UNORM
392 #define MESA_FORMAT_LA_UNORM8                    PIPE_FORMAT_L8A8_UNORM
393 #define MESA_FORMAT_LA_UNORM16                   PIPE_FORMAT_L16A16_UNORM
394 #define MESA_FORMAT_I_UNORM8                     PIPE_FORMAT_I8_UNORM
395 #define MESA_FORMAT_I_UNORM16                    PIPE_FORMAT_I16_UNORM
396 #define MESA_FORMAT_R_UNORM8                     PIPE_FORMAT_R8_UNORM
397 #define MESA_FORMAT_R_UNORM16                    PIPE_FORMAT_R16_UNORM
398 #define MESA_FORMAT_RG_UNORM8                    PIPE_FORMAT_R8G8_UNORM
399 #define MESA_FORMAT_RG_UNORM16                   PIPE_FORMAT_R16G16_UNORM
400 #define MESA_FORMAT_BGR_UNORM8                   PIPE_FORMAT_B8G8R8_UNORM
401 #define MESA_FORMAT_RGB_UNORM8                   PIPE_FORMAT_R8G8B8_UNORM
402 #define MESA_FORMAT_RGBA_UNORM16                 PIPE_FORMAT_R16G16B16A16_UNORM
403 #define MESA_FORMAT_RGBX_UNORM16                 PIPE_FORMAT_R16G16B16X16_UNORM
404 #define MESA_FORMAT_Z_UNORM16                    PIPE_FORMAT_Z16_UNORM
405 #define MESA_FORMAT_Z_UNORM32                    PIPE_FORMAT_Z32_UNORM
406 #define MESA_FORMAT_S_UINT8                      PIPE_FORMAT_S8_UINT
407 #define MESA_FORMAT_A8B8G8R8_SNORM               PIPE_FORMAT_ABGR8888_SNORM
408 #define MESA_FORMAT_X8B8G8R8_SNORM               PIPE_FORMAT_XBGR8888_SNORM
409 #define MESA_FORMAT_R8G8B8A8_SNORM               PIPE_FORMAT_RGBA8888_SNORM
410 #define MESA_FORMAT_R8G8B8X8_SNORM               PIPE_FORMAT_RGBX8888_SNORM
411 #define MESA_FORMAT_A_SNORM8                     PIPE_FORMAT_A8_SNORM
412 #define MESA_FORMAT_A_SNORM16                    PIPE_FORMAT_A16_SNORM
413 #define MESA_FORMAT_L_SNORM8                     PIPE_FORMAT_L8_SNORM
414 #define MESA_FORMAT_L_SNORM16                    PIPE_FORMAT_L16_SNORM
415 #define MESA_FORMAT_I_SNORM8                     PIPE_FORMAT_I8_SNORM
416 #define MESA_FORMAT_I_SNORM16                    PIPE_FORMAT_I16_SNORM
417 #define MESA_FORMAT_R_SNORM8                     PIPE_FORMAT_R8_SNORM
418 #define MESA_FORMAT_R_SNORM16                    PIPE_FORMAT_R16_SNORM
419 #define MESA_FORMAT_LA_SNORM8                    PIPE_FORMAT_L8A8_SNORM
420 #define MESA_FORMAT_LA_SNORM16                   PIPE_FORMAT_L16A16_SNORM
421 #define MESA_FORMAT_RG_SNORM8                    PIPE_FORMAT_R8G8_SNORM
422 #define MESA_FORMAT_RG_SNORM16                   PIPE_FORMAT_R16G16_SNORM
423 #define MESA_FORMAT_RGB_SNORM16                  PIPE_FORMAT_R16G16B16_SNORM
424 #define MESA_FORMAT_RGBA_SNORM16                 PIPE_FORMAT_R16G16B16A16_SNORM
425 #define MESA_FORMAT_RGBX_SNORM16                 PIPE_FORMAT_R16G16B16X16_SNORM
426 #define MESA_FORMAT_A8B8G8R8_SRGB                PIPE_FORMAT_ABGR8888_SRGB
427 #define MESA_FORMAT_B8G8R8A8_SRGB                PIPE_FORMAT_BGRA8888_SRGB
428 #define MESA_FORMAT_A8R8G8B8_SRGB                PIPE_FORMAT_ARGB8888_SRGB
429 #define MESA_FORMAT_B8G8R8X8_SRGB                PIPE_FORMAT_BGRX8888_SRGB
430 #define MESA_FORMAT_X8R8G8B8_SRGB                PIPE_FORMAT_XRGB8888_SRGB
431 #define MESA_FORMAT_R8G8B8A8_SRGB                PIPE_FORMAT_RGBA8888_SRGB
432 #define MESA_FORMAT_R8G8B8X8_SRGB                PIPE_FORMAT_RGBX8888_SRGB
433 #define MESA_FORMAT_X8B8G8R8_SRGB                PIPE_FORMAT_XBGR8888_SRGB
434 #define MESA_FORMAT_R_SRGB8                      PIPE_FORMAT_R8_SRGB
435 #define MESA_FORMAT_L_SRGB8                      PIPE_FORMAT_L8_SRGB
436 #define MESA_FORMAT_LA_SRGB8                     PIPE_FORMAT_L8A8_SRGB
437 #define MESA_FORMAT_BGR_SRGB8                    PIPE_FORMAT_R8G8B8_SRGB
438 #define MESA_FORMAT_R9G9B9E5_FLOAT               PIPE_FORMAT_R9G9B9E5_FLOAT
439 #define MESA_FORMAT_R11G11B10_FLOAT              PIPE_FORMAT_R11G11B10_FLOAT
440 #define MESA_FORMAT_Z32_FLOAT_S8X24_UINT         PIPE_FORMAT_Z32_FLOAT_S8X24_UINT
441 #define MESA_FORMAT_A_FLOAT16                    PIPE_FORMAT_A16_FLOAT
442 #define MESA_FORMAT_A_FLOAT32                    PIPE_FORMAT_A32_FLOAT
443 #define MESA_FORMAT_L_FLOAT16                    PIPE_FORMAT_L16_FLOAT
444 #define MESA_FORMAT_L_FLOAT32                    PIPE_FORMAT_L32_FLOAT
445 #define MESA_FORMAT_LA_FLOAT16                   PIPE_FORMAT_L16A16_FLOAT
446 #define MESA_FORMAT_LA_FLOAT32                   PIPE_FORMAT_L32A32_FLOAT
447 #define MESA_FORMAT_I_FLOAT16                    PIPE_FORMAT_I16_FLOAT
448 #define MESA_FORMAT_I_FLOAT32                    PIPE_FORMAT_I32_FLOAT
449 #define MESA_FORMAT_R_FLOAT16                    PIPE_FORMAT_R16_FLOAT
450 #define MESA_FORMAT_R_FLOAT32                    PIPE_FORMAT_R32_FLOAT
451 #define MESA_FORMAT_RG_FLOAT16                   PIPE_FORMAT_R16G16_FLOAT
452 #define MESA_FORMAT_RG_FLOAT32                   PIPE_FORMAT_R32G32_FLOAT
453 #define MESA_FORMAT_RGB_FLOAT16                  PIPE_FORMAT_R16G16B16_FLOAT
454 #define MESA_FORMAT_RGB_FLOAT32                  PIPE_FORMAT_R32G32B32_FLOAT
455 #define MESA_FORMAT_RGBA_FLOAT16                 PIPE_FORMAT_R16G16B16A16_FLOAT
456 #define MESA_FORMAT_RGBA_FLOAT32                 PIPE_FORMAT_R32G32B32A32_FLOAT
457 #define MESA_FORMAT_RGBX_FLOAT16                 PIPE_FORMAT_R16G16B16X16_FLOAT
458 #define MESA_FORMAT_RGBX_FLOAT32                 PIPE_FORMAT_R32G32B32X32_FLOAT
459 #define MESA_FORMAT_Z_FLOAT32                    PIPE_FORMAT_Z32_FLOAT
460 #define MESA_FORMAT_A8B8G8R8_UINT                PIPE_FORMAT_ABGR8888_UINT
461 #define MESA_FORMAT_A8R8G8B8_UINT                PIPE_FORMAT_ARGB8888_UINT
462 #define MESA_FORMAT_R8G8B8A8_UINT                PIPE_FORMAT_RGBA8888_UINT
463 #define MESA_FORMAT_B8G8R8A8_UINT                PIPE_FORMAT_BGRA8888_UINT
464 #define MESA_FORMAT_B10G10R10A2_UINT             PIPE_FORMAT_B10G10R10A2_UINT
465 #define MESA_FORMAT_R10G10B10A2_UINT             PIPE_FORMAT_R10G10B10A2_UINT
466 #define MESA_FORMAT_A2B10G10R10_UINT             PIPE_FORMAT_A2B10G10R10_UINT
467 #define MESA_FORMAT_A2R10G10B10_UINT             PIPE_FORMAT_A2R10G10B10_UINT
468 #define MESA_FORMAT_B5G6R5_UINT                  PIPE_FORMAT_B5G6R5_UINT
469 #define MESA_FORMAT_R5G6B5_UINT                  PIPE_FORMAT_R5G6B5_UINT
470 #define MESA_FORMAT_B2G3R3_UINT                  PIPE_FORMAT_B2G3R3_UINT
471 #define MESA_FORMAT_R3G3B2_UINT                  PIPE_FORMAT_R3G3B2_UINT
472 #define MESA_FORMAT_A4B4G4R4_UINT                PIPE_FORMAT_A4B4G4R4_UINT
473 #define MESA_FORMAT_R4G4B4A4_UINT                PIPE_FORMAT_R4G4B4A4_UINT
474 #define MESA_FORMAT_B4G4R4A4_UINT                PIPE_FORMAT_B4G4R4A4_UINT
475 #define MESA_FORMAT_A4R4G4B4_UINT                PIPE_FORMAT_A4R4G4B4_UINT
476 #define MESA_FORMAT_A1B5G5R5_UINT                PIPE_FORMAT_A1B5G5R5_UINT
477 #define MESA_FORMAT_B5G5R5A1_UINT                PIPE_FORMAT_B5G5R5A1_UINT
478 #define MESA_FORMAT_A1R5G5B5_UINT                PIPE_FORMAT_A1R5G5B5_UINT
479 #define MESA_FORMAT_R5G5B5A1_UINT                PIPE_FORMAT_R5G5B5A1_UINT
480 #define MESA_FORMAT_A_UINT8                      PIPE_FORMAT_A8_UINT
481 #define MESA_FORMAT_A_UINT16                     PIPE_FORMAT_A16_UINT
482 #define MESA_FORMAT_A_UINT32                     PIPE_FORMAT_A32_UINT
483 #define MESA_FORMAT_A_SINT8                      PIPE_FORMAT_A8_SINT
484 #define MESA_FORMAT_A_SINT16                     PIPE_FORMAT_A16_SINT
485 #define MESA_FORMAT_A_SINT32                     PIPE_FORMAT_A32_SINT
486 #define MESA_FORMAT_I_UINT8                      PIPE_FORMAT_I8_UINT
487 #define MESA_FORMAT_I_UINT16                     PIPE_FORMAT_I16_UINT
488 #define MESA_FORMAT_I_UINT32                     PIPE_FORMAT_I32_UINT
489 #define MESA_FORMAT_I_SINT8                      PIPE_FORMAT_I8_SINT
490 #define MESA_FORMAT_I_SINT16                     PIPE_FORMAT_I16_SINT
491 #define MESA_FORMAT_I_SINT32                     PIPE_FORMAT_I32_SINT
492 #define MESA_FORMAT_L_UINT8                      PIPE_FORMAT_L8_UINT
493 #define MESA_FORMAT_L_UINT16                     PIPE_FORMAT_L16_UINT
494 #define MESA_FORMAT_L_UINT32                     PIPE_FORMAT_L32_UINT
495 #define MESA_FORMAT_L_SINT8                      PIPE_FORMAT_L8_SINT
496 #define MESA_FORMAT_L_SINT16                     PIPE_FORMAT_L16_SINT
497 #define MESA_FORMAT_L_SINT32                     PIPE_FORMAT_L32_SINT
498 #define MESA_FORMAT_LA_UINT8                     PIPE_FORMAT_L8A8_UINT
499 #define MESA_FORMAT_LA_UINT16                    PIPE_FORMAT_L16A16_UINT
500 #define MESA_FORMAT_LA_UINT32                    PIPE_FORMAT_L32A32_UINT
501 #define MESA_FORMAT_LA_SINT8                     PIPE_FORMAT_L8A8_SINT
502 #define MESA_FORMAT_LA_SINT16                    PIPE_FORMAT_L16A16_SINT
503 #define MESA_FORMAT_LA_SINT32                    PIPE_FORMAT_L32A32_SINT
504 #define MESA_FORMAT_R_UINT8                      PIPE_FORMAT_R8_UINT
505 #define MESA_FORMAT_R_UINT16                     PIPE_FORMAT_R16_UINT
506 #define MESA_FORMAT_R_UINT32                     PIPE_FORMAT_R32_UINT
507 #define MESA_FORMAT_R_SINT8                      PIPE_FORMAT_R8_SINT
508 #define MESA_FORMAT_R_SINT16                     PIPE_FORMAT_R16_SINT
509 #define MESA_FORMAT_R_SINT32                     PIPE_FORMAT_R32_SINT
510 #define MESA_FORMAT_RG_UINT8                     PIPE_FORMAT_R8G8_UINT
511 #define MESA_FORMAT_RG_UINT16                    PIPE_FORMAT_R16G16_UINT
512 #define MESA_FORMAT_RG_UINT32                    PIPE_FORMAT_R32G32_UINT
513 #define MESA_FORMAT_RG_SINT8                     PIPE_FORMAT_R8G8_SINT
514 #define MESA_FORMAT_RG_SINT16                    PIPE_FORMAT_R16G16_SINT
515 #define MESA_FORMAT_RG_SINT32                    PIPE_FORMAT_R32G32_SINT
516 #define MESA_FORMAT_RGB_UINT8                    PIPE_FORMAT_R8G8B8_UINT
517 #define MESA_FORMAT_RGB_UINT16                   PIPE_FORMAT_R16G16B16_UINT
518 #define MESA_FORMAT_RGB_UINT32                   PIPE_FORMAT_R32G32B32_UINT
519 #define MESA_FORMAT_RGB_SINT8                    PIPE_FORMAT_R8G8B8_SINT
520 #define MESA_FORMAT_RGB_SINT16                   PIPE_FORMAT_R16G16B16_SINT
521 #define MESA_FORMAT_RGB_SINT32                   PIPE_FORMAT_R32G32B32_SINT
522 #define MESA_FORMAT_RGBA_UINT16                  PIPE_FORMAT_R16G16B16A16_UINT
523 #define MESA_FORMAT_RGBA_UINT32                  PIPE_FORMAT_R32G32B32A32_UINT
524 #define MESA_FORMAT_RGBA_SINT8                   PIPE_FORMAT_R8G8B8A8_SINT
525 #define MESA_FORMAT_RGBA_SINT16                  PIPE_FORMAT_R16G16B16A16_SINT
526 #define MESA_FORMAT_RGBA_SINT32                  PIPE_FORMAT_R32G32B32A32_SINT
527 #define MESA_FORMAT_RGBX_UINT8                   PIPE_FORMAT_R8G8B8X8_UINT
528 #define MESA_FORMAT_RGBX_UINT16                  PIPE_FORMAT_R16G16B16X16_UINT
529 #define MESA_FORMAT_RGBX_UINT32                  PIPE_FORMAT_R32G32B32X32_UINT
530 #define MESA_FORMAT_RGBX_SINT8                   PIPE_FORMAT_R8G8B8X8_SINT
531 #define MESA_FORMAT_RGBX_SINT16                  PIPE_FORMAT_R16G16B16X16_SINT
532 #define MESA_FORMAT_RGBX_SINT32                  PIPE_FORMAT_R32G32B32X32_SINT
533 #define MESA_FORMAT_RGB_DXT1                     PIPE_FORMAT_DXT1_RGB
534 #define MESA_FORMAT_RGBA_DXT1                    PIPE_FORMAT_DXT1_RGBA
535 #define MESA_FORMAT_RGBA_DXT3                    PIPE_FORMAT_DXT3_RGBA
536 #define MESA_FORMAT_RGBA_DXT5                    PIPE_FORMAT_DXT5_RGBA
537 #define MESA_FORMAT_SRGB_DXT1                    PIPE_FORMAT_DXT1_SRGB
538 #define MESA_FORMAT_SRGBA_DXT1                   PIPE_FORMAT_DXT1_SRGBA
539 #define MESA_FORMAT_SRGBA_DXT3                   PIPE_FORMAT_DXT3_SRGBA
540 #define MESA_FORMAT_SRGBA_DXT5                   PIPE_FORMAT_DXT5_SRGBA
541 #define MESA_FORMAT_RGB_FXT1                     PIPE_FORMAT_FXT1_RGB
542 #define MESA_FORMAT_RGBA_FXT1                    PIPE_FORMAT_FXT1_RGBA
543 #define MESA_FORMAT_R_RGTC1_UNORM                PIPE_FORMAT_RGTC1_UNORM
544 #define MESA_FORMAT_R_RGTC1_SNORM                PIPE_FORMAT_RGTC1_SNORM
545 #define MESA_FORMAT_RG_RGTC2_UNORM               PIPE_FORMAT_RGTC2_UNORM
546 #define MESA_FORMAT_RG_RGTC2_SNORM               PIPE_FORMAT_RGTC2_SNORM
547 #define MESA_FORMAT_L_LATC1_UNORM                PIPE_FORMAT_LATC1_UNORM
548 #define MESA_FORMAT_L_LATC1_SNORM                PIPE_FORMAT_LATC1_SNORM
549 #define MESA_FORMAT_LA_LATC2_UNORM               PIPE_FORMAT_LATC2_UNORM
550 #define MESA_FORMAT_LA_LATC2_SNORM               PIPE_FORMAT_LATC2_SNORM
551 #define MESA_FORMAT_ETC1_RGB8                    PIPE_FORMAT_ETC1_RGB8
552 #define MESA_FORMAT_ETC2_RGB8                    PIPE_FORMAT_ETC2_RGB8
553 #define MESA_FORMAT_ETC2_SRGB8                   PIPE_FORMAT_ETC2_SRGB8
554 #define MESA_FORMAT_ETC2_RGBA8_EAC               PIPE_FORMAT_ETC2_RGBA8
555 #define MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC        PIPE_FORMAT_ETC2_SRGBA8
556 #define MESA_FORMAT_ETC2_R11_EAC                 PIPE_FORMAT_ETC2_R11_UNORM
557 #define MESA_FORMAT_ETC2_RG11_EAC                PIPE_FORMAT_ETC2_RG11_UNORM
558 #define MESA_FORMAT_ETC2_SIGNED_R11_EAC          PIPE_FORMAT_ETC2_R11_SNORM
559 #define MESA_FORMAT_ETC2_SIGNED_RG11_EAC         PIPE_FORMAT_ETC2_RG11_SNORM
560 #define MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1 PIPE_FORMAT_ETC2_RGB8A1
561 #define MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1 PIPE_FORMAT_ETC2_SRGB8A1
562 #define MESA_FORMAT_BPTC_RGBA_UNORM              PIPE_FORMAT_BPTC_RGBA_UNORM
563 #define MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM        PIPE_FORMAT_BPTC_SRGBA
564 #define MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT        PIPE_FORMAT_BPTC_RGB_FLOAT
565 #define MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT      PIPE_FORMAT_BPTC_RGB_UFLOAT
566 #define MESA_FORMAT_RGBA_ASTC_4x4                PIPE_FORMAT_ASTC_4x4
567 #define MESA_FORMAT_RGBA_ASTC_5x4                PIPE_FORMAT_ASTC_5x4
568 #define MESA_FORMAT_RGBA_ASTC_5x5                PIPE_FORMAT_ASTC_5x5
569 #define MESA_FORMAT_RGBA_ASTC_6x5                PIPE_FORMAT_ASTC_6x5
570 #define MESA_FORMAT_RGBA_ASTC_6x6                PIPE_FORMAT_ASTC_6x6
571 #define MESA_FORMAT_RGBA_ASTC_8x5                PIPE_FORMAT_ASTC_8x5
572 #define MESA_FORMAT_RGBA_ASTC_8x6                PIPE_FORMAT_ASTC_8x6
573 #define MESA_FORMAT_RGBA_ASTC_8x8                PIPE_FORMAT_ASTC_8x8
574 #define MESA_FORMAT_RGBA_ASTC_10x5               PIPE_FORMAT_ASTC_10x5
575 #define MESA_FORMAT_RGBA_ASTC_10x6               PIPE_FORMAT_ASTC_10x6
576 #define MESA_FORMAT_RGBA_ASTC_10x8               PIPE_FORMAT_ASTC_10x8
577 #define MESA_FORMAT_RGBA_ASTC_10x10              PIPE_FORMAT_ASTC_10x10
578 #define MESA_FORMAT_RGBA_ASTC_12x10              PIPE_FORMAT_ASTC_12x10
579 #define MESA_FORMAT_RGBA_ASTC_12x12              PIPE_FORMAT_ASTC_12x12
580 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4        PIPE_FORMAT_ASTC_4x4_SRGB
581 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x4        PIPE_FORMAT_ASTC_5x4_SRGB
582 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5        PIPE_FORMAT_ASTC_5x5_SRGB
583 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x5        PIPE_FORMAT_ASTC_6x5_SRGB
584 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6        PIPE_FORMAT_ASTC_6x6_SRGB
585 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x5        PIPE_FORMAT_ASTC_8x5_SRGB
586 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x6        PIPE_FORMAT_ASTC_8x6_SRGB
587 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x8        PIPE_FORMAT_ASTC_8x8_SRGB
588 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x5       PIPE_FORMAT_ASTC_10x5_SRGB
589 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x6       PIPE_FORMAT_ASTC_10x6_SRGB
590 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x8       PIPE_FORMAT_ASTC_10x8_SRGB
591 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x10      PIPE_FORMAT_ASTC_10x10_SRGB
592 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_12x10      PIPE_FORMAT_ASTC_12x10_SRGB
593 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_12x12      PIPE_FORMAT_ASTC_12x12_SRGB
594 #define MESA_FORMAT_RGBA_ASTC_3x3x3              PIPE_FORMAT_ASTC_3x3x3
595 #define MESA_FORMAT_RGBA_ASTC_4x3x3              PIPE_FORMAT_ASTC_4x3x3
596 #define MESA_FORMAT_RGBA_ASTC_4x4x3              PIPE_FORMAT_ASTC_4x4x3
597 #define MESA_FORMAT_RGBA_ASTC_4x4x4              PIPE_FORMAT_ASTC_4x4x4
598 #define MESA_FORMAT_RGBA_ASTC_5x4x4              PIPE_FORMAT_ASTC_5x4x4
599 #define MESA_FORMAT_RGBA_ASTC_5x5x4              PIPE_FORMAT_ASTC_5x5x4
600 #define MESA_FORMAT_RGBA_ASTC_5x5x5              PIPE_FORMAT_ASTC_5x5x5
601 #define MESA_FORMAT_RGBA_ASTC_6x5x5              PIPE_FORMAT_ASTC_6x5x5
602 #define MESA_FORMAT_RGBA_ASTC_6x6x5              PIPE_FORMAT_ASTC_6x6x5
603 #define MESA_FORMAT_RGBA_ASTC_6x6x6              PIPE_FORMAT_ASTC_6x6x6
604 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_3x3x3      PIPE_FORMAT_ASTC_3x3x3_SRGB
605 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x3x3      PIPE_FORMAT_ASTC_4x3x3_SRGB
606 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4x3      PIPE_FORMAT_ASTC_4x4x3_SRGB
607 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4x4      PIPE_FORMAT_ASTC_4x4x4_SRGB
608 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x4x4      PIPE_FORMAT_ASTC_5x4x4_SRGB
609 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5x4      PIPE_FORMAT_ASTC_5x5x4_SRGB
610 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5x5      PIPE_FORMAT_ASTC_5x5x5_SRGB
611 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x5x5      PIPE_FORMAT_ASTC_6x5x5_SRGB
612 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x5      PIPE_FORMAT_ASTC_6x6x5_SRGB
613 #define MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x6      PIPE_FORMAT_ASTC_6x6x6_SRGB
614 #define MESA_FORMAT_ATC_RGB                      PIPE_FORMAT_ATC_RGB
615 #define MESA_FORMAT_ATC_RGBA_EXPLICIT            PIPE_FORMAT_ATC_RGBA_EXPLICIT
616 #define MESA_FORMAT_ATC_RGBA_INTERPOLATED        PIPE_FORMAT_ATC_RGBA_INTERPOLATED
617 #define MESA_FORMAT_COUNT                        PIPE_FORMAT_COUNT
618 
619 /* Packed to array format adapters */
620 #if UTIL_ARCH_LITTLE_ENDIAN
621 #define MESA_FORMAT_RGBA_UINT8 MESA_FORMAT_R8G8B8A8_UINT
622 #define MESA_FORMAT_RGBA_UNORM8 MESA_FORMAT_R8G8B8A8_UNORM
623 #define MESA_FORMAT_RGBA_SNORM8 MESA_FORMAT_R8G8B8A8_SNORM
624 #else
625 #define MESA_FORMAT_RGBA_UINT8 MESA_FORMAT_A8B8G8R8_UINT
626 #define MESA_FORMAT_RGBA_UNORM8 MESA_FORMAT_A8B8G8R8_UNORM
627 #define MESA_FORMAT_RGBA_SNORM8 MESA_FORMAT_A8B8G8R8_SNORM
628 #endif
629 
630 extern const char *
631 _mesa_get_format_name(mesa_format format);
632 
633 extern int
634 _mesa_get_format_bytes(mesa_format format);
635 
636 extern GLint
637 _mesa_get_format_bits(mesa_format format, GLenum pname);
638 
639 extern unsigned int
640 _mesa_get_format_max_bits(mesa_format format);
641 
642 extern enum mesa_format_layout
643 _mesa_get_format_layout(mesa_format format);
644 
645 extern GLenum
646 _mesa_get_format_datatype(mesa_format format);
647 
648 extern GLenum
649 _mesa_get_format_base_format(uint32_t format);
650 
651 extern void
652 _mesa_get_format_block_size(mesa_format format,
653                             unsigned int *bw, unsigned int *bh);
654 
655 extern void
656 _mesa_get_format_block_size_3d(mesa_format format, unsigned int *bw,
657                                unsigned int *bh, unsigned int *bd);
658 
659 extern mesa_array_format
660 _mesa_array_format_flip_channels(mesa_array_format format);
661 
662 extern void
663 _mesa_get_format_swizzle(mesa_format format, uint8_t swizzle_out[4]);
664 
665 extern uint32_t
666 _mesa_format_to_array_format(mesa_format format);
667 
668 extern mesa_format
669 _mesa_format_from_array_format(uint32_t array_format);
670 
671 extern bool
672 _mesa_is_format_compressed(mesa_format format);
673 
674 extern bool
675 _mesa_is_format_packed_depth_stencil(mesa_format format);
676 
677 extern bool
678 _mesa_is_format_integer_color(mesa_format format);
679 
680 extern bool
681 _mesa_is_format_unsigned(mesa_format format);
682 
683 extern bool
684 _mesa_is_format_signed(mesa_format format);
685 
686 extern bool
687 _mesa_is_format_integer(mesa_format format);
688 
689 extern bool
690 _mesa_is_format_etc2(mesa_format format);
691 
692 bool
693 _mesa_is_format_astc_2d(mesa_format format);
694 
695 bool
696 _mesa_is_format_color_format(mesa_format format);
697 
698 bool
699 _mesa_is_format_srgb(mesa_format format);
700 
701 extern uint32_t
702 _mesa_format_image_size(mesa_format format, int width,
703                         int height, int depth);
704 
705 extern uint64_t
706 _mesa_format_image_size64(mesa_format format, int width,
707                           int height, int depth);
708 
709 extern int32_t
710 _mesa_format_row_stride(mesa_format format, int width);
711 
712 extern void
713 _mesa_uncompressed_format_to_type_and_comps(mesa_format format,
714                                GLenum *datatype, GLuint *comps);
715 
716 extern void
717 _mesa_test_formats(void);
718 
719 extern mesa_format
720 _mesa_get_srgb_format_linear(mesa_format format);
721 
722 extern mesa_format
723 _mesa_get_linear_format_srgb(mesa_format format);
724 
725 extern mesa_format
726 _mesa_get_intensity_format_red(mesa_format format);
727 
728 extern mesa_format
729 _mesa_get_uncompressed_format(mesa_format format);
730 
731 extern unsigned int
732 _mesa_format_num_components(mesa_format format);
733 
734 extern bool
735 _mesa_format_has_color_component(mesa_format format, int component);
736 
737 bool
738 _mesa_format_matches_format_and_type(mesa_format mesa_format,
739 				     GLenum format, GLenum type,
740 				     bool swapBytes, GLenum *error);
741 
742 mesa_format
743 _mesa_format_fallback_rgbx_to_rgba(mesa_format format);
744 
745 #ifdef __cplusplus
746 }
747 #endif
748 
749 #endif /* FORMATS_H */
750