1848b8605Smrg/*
2848b8605Smrg * Mesa 3-D graphics library
3848b8605Smrg *
4848b8605Smrg * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
5848b8605Smrg * Copyright (c) 2008-2009  VMware, Inc.
6848b8605Smrg *
7848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a
8848b8605Smrg * copy of this software and associated documentation files (the "Software"),
9848b8605Smrg * to deal in the Software without restriction, including without limitation
10848b8605Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11848b8605Smrg * and/or sell copies of the Software, and to permit persons to whom the
12848b8605Smrg * Software is furnished to do so, subject to the following conditions:
13848b8605Smrg *
14848b8605Smrg * The above copyright notice and this permission notice shall be included
15848b8605Smrg * in all copies or substantial portions of the Software.
16848b8605Smrg *
17848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20848b8605Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21848b8605Smrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22848b8605Smrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23848b8605Smrg * OTHER DEALINGS IN THE SOFTWARE.
24848b8605Smrg */
25848b8605Smrg
26848b8605Smrg/*
27848b8605Smrg * Authors:
28848b8605Smrg *   Brian Paul
29848b8605Smrg */
30848b8605Smrg
31848b8605Smrg
32848b8605Smrg#ifndef FORMATS_H
33848b8605Smrg#define FORMATS_H
34848b8605Smrg
35848b8605Smrg
36848b8605Smrg#include <GL/gl.h>
37848b8605Smrg#include <stdbool.h>
38848b8605Smrg#include <stdint.h>
39848b8605Smrg
40848b8605Smrg#ifdef __cplusplus
41848b8605Smrgextern "C" {
42848b8605Smrg#endif
43848b8605Smrg
44848b8605Smrg
45848b8605Smrg/**
46848b8605Smrg * OpenGL doesn't have GL_UNSIGNED_BYTE_4_4, so we must define our own type
47848b8605Smrg * for GL_LUMINANCE4_ALPHA4.
48848b8605Smrg */
49848b8605Smrg#define MESA_UNSIGNED_BYTE_4_4 (GL_UNSIGNED_BYTE<<1)
50848b8605Smrg
51848b8605Smrg
52848b8605Smrg/**
53848b8605Smrg * Max number of bytes for any non-compressed pixel format below, or for
54848b8605Smrg * intermediate pixel storage in Mesa.  This should never be less than
55848b8605Smrg * 16.  Maybe 32 someday?
56848b8605Smrg */
57848b8605Smrg#define MAX_PIXEL_BYTES 16
58848b8605Smrg
59848b8605Smrg/**
60848b8605Smrg * Specifies the layout of a pixel format.  See the MESA_FORMAT
61848b8605Smrg * documentation below.
62848b8605Smrg */
63848b8605Smrgenum mesa_format_layout {
64848b8605Smrg   MESA_FORMAT_LAYOUT_ARRAY,
65848b8605Smrg   MESA_FORMAT_LAYOUT_PACKED,
66b8e80941Smrg   MESA_FORMAT_LAYOUT_S3TC,
67b8e80941Smrg   MESA_FORMAT_LAYOUT_RGTC,
68b8e80941Smrg   MESA_FORMAT_LAYOUT_LATC,
69b8e80941Smrg   MESA_FORMAT_LAYOUT_FXT1,
70b8e80941Smrg   MESA_FORMAT_LAYOUT_ETC1,
71b8e80941Smrg   MESA_FORMAT_LAYOUT_ETC2,
72b8e80941Smrg   MESA_FORMAT_LAYOUT_BPTC,
73b8e80941Smrg   MESA_FORMAT_LAYOUT_ASTC,
74b8e80941Smrg   MESA_FORMAT_LAYOUT_ATC,
75848b8605Smrg   MESA_FORMAT_LAYOUT_OTHER,
76848b8605Smrg};
77848b8605Smrg
78848b8605Smrg/**
79848b8605Smrg * An enum representing different possible swizzling values.  This is used
80848b8605Smrg * to interpret the output of _mesa_get_format_swizzle
81848b8605Smrg */
82848b8605Smrgenum {
83848b8605Smrg   MESA_FORMAT_SWIZZLE_X = 0,
84848b8605Smrg   MESA_FORMAT_SWIZZLE_Y = 1,
85848b8605Smrg   MESA_FORMAT_SWIZZLE_Z = 2,
86848b8605Smrg   MESA_FORMAT_SWIZZLE_W = 3,
87848b8605Smrg   MESA_FORMAT_SWIZZLE_ZERO = 4,
88848b8605Smrg   MESA_FORMAT_SWIZZLE_ONE = 5,
89848b8605Smrg   MESA_FORMAT_SWIZZLE_NONE = 6,
90848b8605Smrg};
91848b8605Smrg
92b8e80941Smrg/**
93b8e80941Smrg * An uint32_t that encodes the information necessary to represent an
94b8e80941Smrg * array format
95b8e80941Smrg */
96b8e80941Smrgtypedef uint32_t mesa_array_format;
97b8e80941Smrg
98b8e80941Smrg/**
99b8e80941Smrg * Encoding for valid array format data types
100b8e80941Smrg */
101b8e80941Smrgenum mesa_array_format_datatype {
102b8e80941Smrg   MESA_ARRAY_FORMAT_TYPE_UBYTE = 0x0,
103b8e80941Smrg   MESA_ARRAY_FORMAT_TYPE_USHORT = 0x1,
104b8e80941Smrg   MESA_ARRAY_FORMAT_TYPE_UINT = 0x2,
105b8e80941Smrg   MESA_ARRAY_FORMAT_TYPE_BYTE = 0x4,
106b8e80941Smrg   MESA_ARRAY_FORMAT_TYPE_SHORT = 0x5,
107b8e80941Smrg   MESA_ARRAY_FORMAT_TYPE_INT = 0x6,
108b8e80941Smrg   MESA_ARRAY_FORMAT_TYPE_HALF = 0xd,
109b8e80941Smrg   MESA_ARRAY_FORMAT_TYPE_FLOAT = 0xe,
110b8e80941Smrg};
111b8e80941Smrg
112b8e80941Smrg/**
113b8e80941Smrg * An enum useful to encode/decode information stored in a mesa_array_format
114b8e80941Smrg */
115b8e80941Smrgenum {
116b8e80941Smrg   MESA_ARRAY_FORMAT_TYPE_IS_SIGNED = 0x4,
117b8e80941Smrg   MESA_ARRAY_FORMAT_TYPE_IS_FLOAT = 0x8,
118b8e80941Smrg   MESA_ARRAY_FORMAT_TYPE_NORMALIZED = 0x10,
119b8e80941Smrg   MESA_ARRAY_FORMAT_DATATYPE_MASK = 0xf,
120b8e80941Smrg   MESA_ARRAY_FORMAT_TYPE_MASK = 0x1f,
121b8e80941Smrg   MESA_ARRAY_FORMAT_TYPE_SIZE_MASK = 0x3,
122b8e80941Smrg   MESA_ARRAY_FORMAT_NUM_CHANS_MASK = 0xe0,
123b8e80941Smrg   MESA_ARRAY_FORMAT_SWIZZLE_X_MASK = 0x00700,
124b8e80941Smrg   MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK = 0x03800,
125b8e80941Smrg   MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK = 0x1c000,
126b8e80941Smrg   MESA_ARRAY_FORMAT_SWIZZLE_W_MASK = 0xe0000,
127b8e80941Smrg   MESA_ARRAY_FORMAT_BIT = 0x80000000
128b8e80941Smrg};
129b8e80941Smrg
130b8e80941Smrg#define MESA_ARRAY_FORMAT(SIZE, SIGNED, IS_FLOAT, NORM, NUM_CHANS, \
131b8e80941Smrg      SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_W) (                \
132b8e80941Smrg   (((SIZE >> 1)      ) & MESA_ARRAY_FORMAT_TYPE_SIZE_MASK) |      \
133b8e80941Smrg   (((SIGNED)    << 2 ) & MESA_ARRAY_FORMAT_TYPE_IS_SIGNED) |      \
134b8e80941Smrg   (((IS_FLOAT)  << 3 ) & MESA_ARRAY_FORMAT_TYPE_IS_FLOAT) |       \
135b8e80941Smrg   (((NORM)      << 4 ) & MESA_ARRAY_FORMAT_TYPE_NORMALIZED) |     \
136b8e80941Smrg   (((NUM_CHANS) << 5 ) & MESA_ARRAY_FORMAT_NUM_CHANS_MASK) |      \
137b8e80941Smrg   (((SWIZZLE_X) << 8 ) & MESA_ARRAY_FORMAT_SWIZZLE_X_MASK) |      \
138b8e80941Smrg   (((SWIZZLE_Y) << 11) & MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK) |      \
139b8e80941Smrg   (((SWIZZLE_Z) << 14) & MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK) |      \
140b8e80941Smrg   (((SWIZZLE_W) << 17) & MESA_ARRAY_FORMAT_SWIZZLE_W_MASK) |      \
141b8e80941Smrg   MESA_ARRAY_FORMAT_BIT)
142b8e80941Smrg
143b8e80941Smrg/**
144b8e80941Smrg * Various helpers to access the data encoded in a mesa_array_format
145b8e80941Smrg */
146b8e80941Smrgstatic inline bool
147b8e80941Smrg_mesa_array_format_is_signed(mesa_array_format f)
148b8e80941Smrg{
149b8e80941Smrg   return (f & MESA_ARRAY_FORMAT_TYPE_IS_SIGNED) != 0;
150b8e80941Smrg}
151b8e80941Smrg
152b8e80941Smrgstatic inline bool
153b8e80941Smrg_mesa_array_format_is_float(mesa_array_format f)
154b8e80941Smrg{
155b8e80941Smrg   return (f & MESA_ARRAY_FORMAT_TYPE_IS_FLOAT) != 0;
156b8e80941Smrg}
157b8e80941Smrg
158b8e80941Smrgstatic inline bool
159b8e80941Smrg_mesa_array_format_is_normalized(mesa_array_format f)
160b8e80941Smrg{
161b8e80941Smrg   return (f & MESA_ARRAY_FORMAT_TYPE_NORMALIZED) !=0;
162b8e80941Smrg}
163b8e80941Smrg
164b8e80941Smrgstatic inline enum mesa_array_format_datatype
165b8e80941Smrg_mesa_array_format_get_datatype(mesa_array_format f)
166b8e80941Smrg{
167b8e80941Smrg   return (enum mesa_array_format_datatype)
168b8e80941Smrg            (f & MESA_ARRAY_FORMAT_DATATYPE_MASK);
169b8e80941Smrg}
170b8e80941Smrg
171b8e80941Smrgstatic inline int
172b8e80941Smrg_mesa_array_format_datatype_get_size(enum mesa_array_format_datatype type)
173b8e80941Smrg{
174b8e80941Smrg   return 1 << (type & MESA_ARRAY_FORMAT_TYPE_SIZE_MASK);
175b8e80941Smrg}
176b8e80941Smrg
177b8e80941Smrgstatic inline int
178b8e80941Smrg_mesa_array_format_get_type_size(mesa_array_format f)
179b8e80941Smrg{
180b8e80941Smrg   return 1 << (f & MESA_ARRAY_FORMAT_TYPE_SIZE_MASK);
181b8e80941Smrg}
182b8e80941Smrg
183b8e80941Smrgstatic inline int
184b8e80941Smrg_mesa_array_format_get_num_channels(mesa_array_format f)
185b8e80941Smrg{
186b8e80941Smrg   return (f & MESA_ARRAY_FORMAT_NUM_CHANS_MASK) >> 5;
187b8e80941Smrg}
188b8e80941Smrg
189b8e80941Smrgstatic inline void
190b8e80941Smrg_mesa_array_format_get_swizzle(mesa_array_format f, uint8_t *swizzle)
191b8e80941Smrg{
192b8e80941Smrg   swizzle[0] = (f & MESA_ARRAY_FORMAT_SWIZZLE_X_MASK) >> 8;
193b8e80941Smrg   swizzle[1] = (f & MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK) >> 11;
194b8e80941Smrg   swizzle[2] = (f & MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK) >> 14;
195b8e80941Smrg   swizzle[3] = (f & MESA_ARRAY_FORMAT_SWIZZLE_W_MASK) >> 17;
196b8e80941Smrg}
197b8e80941Smrg
198b8e80941Smrgstatic inline void
199b8e80941Smrg_mesa_array_format_set_swizzle(mesa_array_format *f,
200b8e80941Smrg                               int32_t x, int32_t y, int32_t z, int32_t w)
201b8e80941Smrg{
202b8e80941Smrg   *f &= ~(MESA_ARRAY_FORMAT_SWIZZLE_X_MASK |
203b8e80941Smrg           MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK |
204b8e80941Smrg           MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK |
205b8e80941Smrg           MESA_ARRAY_FORMAT_SWIZZLE_W_MASK);
206b8e80941Smrg
207b8e80941Smrg   *f |= ((x << 8 ) & MESA_ARRAY_FORMAT_SWIZZLE_X_MASK) |
208b8e80941Smrg         ((y << 11) & MESA_ARRAY_FORMAT_SWIZZLE_Y_MASK) |
209b8e80941Smrg         ((z << 14) & MESA_ARRAY_FORMAT_SWIZZLE_Z_MASK) |
210b8e80941Smrg         ((w << 17) & MESA_ARRAY_FORMAT_SWIZZLE_W_MASK);
211b8e80941Smrg}
212b8e80941Smrg
213b8e80941Smrg/**
214b8e80941Smrg * A helper to know if the format stored in a uint32_t is a mesa_format
215b8e80941Smrg * or a mesa_array_format
216b8e80941Smrg */
217b8e80941Smrgstatic inline bool
218b8e80941Smrg_mesa_format_is_mesa_array_format(uint32_t f)
219b8e80941Smrg{
220b8e80941Smrg   return (f & MESA_ARRAY_FORMAT_BIT) != 0;
221b8e80941Smrg}
222b8e80941Smrg
223848b8605Smrg/**
224848b8605Smrg * Mesa texture/renderbuffer image formats.
225848b8605Smrg */
226848b8605Smrgtypedef enum
227848b8605Smrg{
228848b8605Smrg   MESA_FORMAT_NONE = 0,
229848b8605Smrg
230848b8605Smrg   /**
231848b8605Smrg    * \name Basic hardware formats
232848b8605Smrg    *
233848b8605Smrg    * The mesa format name specification is as follows:
234848b8605Smrg    *
235848b8605Smrg    *  There shall be 3 naming format base types: those for component array
236848b8605Smrg    *  formats (type A); those for compressed formats (type C); and those for
237848b8605Smrg    *  packed component formats (type P). With type A formats, color component
238848b8605Smrg    *  order does not change with endianess. Each format name shall begin with
239848b8605Smrg    *  MESA_FORMAT_, followed by a component label (from the Component Label
240848b8605Smrg    *  list below) for each component in the order that the component(s) occur
241848b8605Smrg    *  in the format, except for non-linear color formats where the first
242848b8605Smrg    *  letter shall be 'S'. For type P formats, each component label is
243848b8605Smrg    *  followed by the number of bits that represent it in the fundamental
244848b8605Smrg    *  data type used by the format.
245848b8605Smrg    *
246848b8605Smrg    *  Following the listing of the component labels shall be an underscore; a
247848b8605Smrg    *  compression type followed by an underscore for Type C formats only; a
248848b8605Smrg    *  storage type from the list below; and a bit with for type A formats,
249848b8605Smrg    *  which is the bit width for each array element.
250848b8605Smrg    *
251848b8605Smrg    *
252848b8605Smrg    *  ----------    Format Base Type A: Array ----------
253848b8605Smrg    *  MESA_FORMAT_[component list]_[storage type][array element bit width]
254848b8605Smrg    *
255848b8605Smrg    *  examples:
256848b8605Smrg    *  MESA_FORMAT_A_SNORM8     - uchar[i] = A
257848b8605Smrg    *  MESA_FORMAT_RGBA_16 - ushort[i * 4 + 0] = R, ushort[i * 4 + 1] = G,
258848b8605Smrg    *                             ushort[i * 4 + 2] = B, ushort[i * 4 + 3] = A
259848b8605Smrg    *  MESA_FORMAT_Z_UNORM32    - float[i] = Z
260848b8605Smrg    *
261848b8605Smrg    *
262848b8605Smrg    *
263848b8605Smrg    *  ----------    Format Base Type C: Compressed ----------
264848b8605Smrg    *  MESA_FORMAT_[component list*][_*][compression type][storage type*]
265848b8605Smrg    *  * where required
266848b8605Smrg    *
267848b8605Smrg    *  examples:
268848b8605Smrg    *  MESA_FORMAT_RGB_ETC1
269848b8605Smrg    *  MESA_FORMAT_RGBA_ETC2
270848b8605Smrg    *  MESA_FORMAT_LATC1_UNORM
271848b8605Smrg    *  MESA_FORMAT_RGBA_FXT1
272848b8605Smrg    *
273848b8605Smrg    *
274848b8605Smrg    *
275848b8605Smrg    *  ----------    Format Base Type P: Packed  ----------
276848b8605Smrg    *  MESA_FORMAT_[[component list,bit width][storage type*][_]][_][storage type**]
277848b8605Smrg    *   * when type differs between component
278848b8605Smrg    *   ** when type applies to all components
279848b8605Smrg    *
280848b8605Smrg    *  examples:                   msb <------ TEXEL BITS -----------> lsb
281b8e80941Smrg    *  MESA_FORMAT_A8B8G8R8_UNORM, RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA
282b8e80941Smrg    *  MESA_FORMAT_R5G6B5_UNORM                        BBBB BGGG GGGR RRRR
283b8e80941Smrg    *  MESA_FORMAT_B4G4R4X4_UNORM                      XXXX RRRR GGGG BBBB
284848b8605Smrg    *  MESA_FORMAT_Z32_FLOAT_S8X24_UINT
285848b8605Smrg    *  MESA_FORMAT_R10G10B10A2_UINT
286848b8605Smrg    *  MESA_FORMAT_R9G9B9E5_FLOAT
287848b8605Smrg    *
288848b8605Smrg    *
289848b8605Smrg    *
290848b8605Smrg    *  ----------    Component Labels: ----------
291848b8605Smrg    *  A - Alpha
292848b8605Smrg    *  B - Blue
293848b8605Smrg    *  DU - Delta U
294848b8605Smrg    *  DV - Delta V
295848b8605Smrg    *  E - Shared Exponent
296848b8605Smrg    *  G - Green
297848b8605Smrg    *  I - Intensity
298848b8605Smrg    *  L - Luminance
299848b8605Smrg    *  R - Red
300848b8605Smrg    *  S - Stencil (when not followed by RGB or RGBA)
301848b8605Smrg    *  U - Chrominance
302848b8605Smrg    *  V - Chrominance
303848b8605Smrg    *  Y - Luma
304848b8605Smrg    *  X - Packing bits
305848b8605Smrg    *  Z - Depth
306848b8605Smrg    *
307848b8605Smrg    *
308848b8605Smrg    *
309848b8605Smrg    *  ----------    Type C Compression Types: ----------
310848b8605Smrg    *  DXT1 - Color component labels shall be given
311848b8605Smrg    *  DXT3 - Color component labels shall be given
312848b8605Smrg    *  DXT5 - Color component labels shall be given
313848b8605Smrg    *  ETC1 - No other information required
314848b8605Smrg    *  ETC2 - No other information required
315848b8605Smrg    *  FXT1 - Color component labels shall be given
316848b8605Smrg    *  FXT3 - Color component labels shall be given
317848b8605Smrg    *  LATC1 - Fundamental data type shall be given
318848b8605Smrg    *  LATC2 - Fundamental data type shall be given
319848b8605Smrg    *  RGTC1 - Color component labels and data type shall be given
320848b8605Smrg    *  RGTC2 - Color component labels and data type shall be given
321848b8605Smrg    *
322848b8605Smrg    *
323848b8605Smrg    *
324848b8605Smrg    *  ----------    Storage Types: ----------
325848b8605Smrg    *  FLOAT
326848b8605Smrg    *  SINT
327848b8605Smrg    *  UINT
328848b8605Smrg    *  SNORM
329848b8605Smrg    *  UNORM
330848b8605Smrg    *  SRGB - RGB components, or L are UNORMs in sRGB color space.
331848b8605Smrg    *         Alpha, if present is linear.
332848b8605Smrg    *
333848b8605Smrg    */
334848b8605Smrg
335848b8605Smrg   /* Packed unorm formats */    /* msb <------ TEXEL BITS -----------> lsb */
336848b8605Smrg                                 /* ---- ---- ---- ---- ---- ---- ---- ---- */
337848b8605Smrg   MESA_FORMAT_A8B8G8R8_UNORM,   /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
338848b8605Smrg   MESA_FORMAT_X8B8G8R8_UNORM,   /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */
339848b8605Smrg   MESA_FORMAT_R8G8B8A8_UNORM,   /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
340848b8605Smrg   MESA_FORMAT_R8G8B8X8_UNORM,   /* xxxx xxxx BBBB BBBB GGGG GGGG RRRR RRRR */
341848b8605Smrg   MESA_FORMAT_B8G8R8A8_UNORM,   /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
342848b8605Smrg   MESA_FORMAT_B8G8R8X8_UNORM,   /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */
343848b8605Smrg   MESA_FORMAT_A8R8G8B8_UNORM,   /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
344848b8605Smrg   MESA_FORMAT_X8R8G8B8_UNORM,   /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */
345848b8605Smrg   MESA_FORMAT_L16A16_UNORM,     /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */
346848b8605Smrg   MESA_FORMAT_A16L16_UNORM,     /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */
347848b8605Smrg   MESA_FORMAT_B5G6R5_UNORM,                         /* RRRR RGGG GGGB BBBB */
348848b8605Smrg   MESA_FORMAT_R5G6B5_UNORM,                         /* BBBB BGGG GGGR RRRR */
349848b8605Smrg   MESA_FORMAT_B4G4R4A4_UNORM,                       /* AAAA RRRR GGGG BBBB */
350848b8605Smrg   MESA_FORMAT_B4G4R4X4_UNORM,                       /* xxxx RRRR GGGG BBBB */
351848b8605Smrg   MESA_FORMAT_A4R4G4B4_UNORM,                       /* BBBB GGGG RRRR AAAA */
352848b8605Smrg   MESA_FORMAT_A1B5G5R5_UNORM,                       /* RRRR RGGG GGBB BBBA */
353b8e80941Smrg   MESA_FORMAT_X1B5G5R5_UNORM,                       /* BBBB BGGG GGRR RRRX */
354848b8605Smrg   MESA_FORMAT_B5G5R5A1_UNORM,                       /* ARRR RRGG GGGB BBBB */
355848b8605Smrg   MESA_FORMAT_B5G5R5X1_UNORM,                       /* xRRR RRGG GGGB BBBB */
356848b8605Smrg   MESA_FORMAT_A1R5G5B5_UNORM,                       /* BBBB BGGG GGRR RRRA */
357848b8605Smrg   MESA_FORMAT_L8A8_UNORM,                           /* AAAA AAAA LLLL LLLL */
358848b8605Smrg   MESA_FORMAT_A8L8_UNORM,                           /* LLLL LLLL AAAA AAAA */
359848b8605Smrg   MESA_FORMAT_R8G8_UNORM,                           /* GGGG GGGG RRRR RRRR */
360848b8605Smrg   MESA_FORMAT_G8R8_UNORM,                           /* RRRR RRRR GGGG GGGG */
361848b8605Smrg   MESA_FORMAT_L4A4_UNORM,                                     /* AAAA LLLL */
362848b8605Smrg   MESA_FORMAT_B2G3R3_UNORM,                                   /* RRRG GGBB */
363848b8605Smrg
364848b8605Smrg   MESA_FORMAT_R16G16_UNORM,     /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */
365848b8605Smrg   MESA_FORMAT_G16R16_UNORM,     /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */
366848b8605Smrg   MESA_FORMAT_B10G10R10A2_UNORM,/* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */
367848b8605Smrg   MESA_FORMAT_B10G10R10X2_UNORM,/* xxRR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */
368848b8605Smrg   MESA_FORMAT_R10G10B10A2_UNORM,/* AABB BBBB BBBB GGGG GGGG GGRR RRRR RRRR */
369b8e80941Smrg   MESA_FORMAT_R10G10B10X2_UNORM,/* xxBB BBBB BBBB GGGG GGGG GGRR RRRR RRRR */
370848b8605Smrg
371848b8605Smrg   MESA_FORMAT_S8_UINT_Z24_UNORM,/* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */
372848b8605Smrg   MESA_FORMAT_X8_UINT_Z24_UNORM,/* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ xxxx xxxx */
373848b8605Smrg   MESA_FORMAT_Z24_UNORM_S8_UINT,/* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
374848b8605Smrg   MESA_FORMAT_Z24_UNORM_X8_UINT,/* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
375848b8605Smrg
376b8e80941Smrg   /* Other formats */
377b8e80941Smrg   MESA_FORMAT_R3G3B2_UNORM,                                   /* BBGG GRRR */
378b8e80941Smrg   MESA_FORMAT_A4B4G4R4_UNORM,                       /* RRRR GGGG BBBB AAAA */
379b8e80941Smrg   MESA_FORMAT_R4G4B4A4_UNORM,                       /* AAAA BBBB GGGG RRRR */
380b8e80941Smrg   MESA_FORMAT_R5G5B5A1_UNORM,                       /* ABBB BBGG GGGR RRRR */
381b8e80941Smrg   MESA_FORMAT_A2B10G10R10_UNORM,/* RRRR RRRR RRGG GGGG GGGG BBBB BBBB BBAA */
382b8e80941Smrg   MESA_FORMAT_A2R10G10B10_UNORM,/* BBBB BBBB BBGG GGGG GGGG RRRR RRRR RRAA */
383b8e80941Smrg
384848b8605Smrg   MESA_FORMAT_YCBCR,            /*                     YYYY YYYY UorV UorV */
385848b8605Smrg   MESA_FORMAT_YCBCR_REV,        /*                     UorV UorV YYYY YYYY */
386848b8605Smrg
387848b8605Smrg   /* Array unorm formats */
388848b8605Smrg   MESA_FORMAT_A_UNORM8,      /* ubyte[i] = A */
389848b8605Smrg   MESA_FORMAT_A_UNORM16,     /* ushort[i] = A */
390848b8605Smrg   MESA_FORMAT_L_UNORM8,      /* ubyte[i] = L */
391848b8605Smrg   MESA_FORMAT_L_UNORM16,     /* ushort[i] = L */
392848b8605Smrg   MESA_FORMAT_I_UNORM8,      /* ubyte[i] = I */
393848b8605Smrg   MESA_FORMAT_I_UNORM16,     /* ushort[i] = I */
394848b8605Smrg   MESA_FORMAT_R_UNORM8,      /* ubyte[i] = R */
395848b8605Smrg   MESA_FORMAT_R_UNORM16,     /* ushort[i] = R */
396848b8605Smrg   MESA_FORMAT_BGR_UNORM8,    /* ubyte[i*3] = B, [i*3+1] = G, [i*3+2] = R */
397848b8605Smrg   MESA_FORMAT_RGB_UNORM8,    /* ubyte[i*3] = R, [i*3+1] = G, [i*3+2] = B */
398848b8605Smrg   MESA_FORMAT_RGBA_UNORM16,  /* ushort[i] = R, [1] = G, [2] = B, [3] = A */
399848b8605Smrg   MESA_FORMAT_RGBX_UNORM16,
400848b8605Smrg
401848b8605Smrg   MESA_FORMAT_Z_UNORM16,     /* ushort[i] = Z */
402848b8605Smrg   MESA_FORMAT_Z_UNORM32,     /* uint[i] = Z */
403848b8605Smrg   MESA_FORMAT_S_UINT8,       /* ubyte[i] = S */
404848b8605Smrg
405848b8605Smrg   /* Packed signed/normalized formats */
406848b8605Smrg                                 /* msb <------ TEXEL BITS -----------> lsb */
407848b8605Smrg                                 /* ---- ---- ---- ---- ---- ---- ---- ---- */
408848b8605Smrg   MESA_FORMAT_A8B8G8R8_SNORM,   /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
409848b8605Smrg   MESA_FORMAT_X8B8G8R8_SNORM,   /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */
410848b8605Smrg   MESA_FORMAT_R8G8B8A8_SNORM,   /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
411848b8605Smrg   MESA_FORMAT_R8G8B8X8_SNORM,   /* xxxx xxxx BBBB BBBB GGGG GGGG RRRR RRRR */
412848b8605Smrg   MESA_FORMAT_R16G16_SNORM,     /* GGGG GGGG GGGG GGGG RRRR RRRR RRRR RRRR */
413848b8605Smrg   MESA_FORMAT_G16R16_SNORM,     /* RRRR RRRR RRRR RRRR GGGG GGGG GGGG GGGG */
414848b8605Smrg   MESA_FORMAT_R8G8_SNORM,       /*                     GGGG GGGG RRRR RRRR */
415848b8605Smrg   MESA_FORMAT_G8R8_SNORM,       /*                     RRRR RRRR GGGG GGGG */
416848b8605Smrg   MESA_FORMAT_L8A8_SNORM,       /*                     AAAA AAAA LLLL LLLL */
417b8e80941Smrg   MESA_FORMAT_A8L8_SNORM,       /*                     LLLL LLLL AAAA AAAA */
418848b8605Smrg
419848b8605Smrg   /* Array signed/normalized formats */
420848b8605Smrg   MESA_FORMAT_A_SNORM8,      /* byte[i] = A */
421848b8605Smrg   MESA_FORMAT_A_SNORM16,     /* short[i] = A */
422848b8605Smrg   MESA_FORMAT_L_SNORM8,      /* byte[i] = L */
423848b8605Smrg   MESA_FORMAT_L_SNORM16,     /* short[i] = L */
424848b8605Smrg   MESA_FORMAT_I_SNORM8,      /* byte[i] = I */
425848b8605Smrg   MESA_FORMAT_I_SNORM16,     /* short[i] = I */
426848b8605Smrg   MESA_FORMAT_R_SNORM8,      /* byte[i] = R */
427848b8605Smrg   MESA_FORMAT_R_SNORM16,     /* short[i] = R */
428848b8605Smrg   MESA_FORMAT_LA_SNORM16,    /* short[i * 2] = L, [i * 2 + 1] = A */
429848b8605Smrg   MESA_FORMAT_RGB_SNORM16,   /* short[i*3] = R, [i*3+1] = G, [i*3+2] = B */
430848b8605Smrg   MESA_FORMAT_RGBA_SNORM16,  /* ... */
431848b8605Smrg   MESA_FORMAT_RGBX_SNORM16,  /* ... */
432848b8605Smrg
433848b8605Smrg   /* Packed sRGB formats */
434848b8605Smrg   MESA_FORMAT_A8B8G8R8_SRGB,    /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
435848b8605Smrg   MESA_FORMAT_B8G8R8A8_SRGB,    /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
436b8e80941Smrg   MESA_FORMAT_A8R8G8B8_SRGB,    /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
437848b8605Smrg   MESA_FORMAT_B8G8R8X8_SRGB,    /* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */
438b8e80941Smrg   MESA_FORMAT_X8R8G8B8_SRGB,    /* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */
439848b8605Smrg   MESA_FORMAT_R8G8B8A8_SRGB,    /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
440848b8605Smrg   MESA_FORMAT_R8G8B8X8_SRGB,    /* xxxx xxxx BBBB BBBB GGGG GGGG RRRR RRRR */
441b8e80941Smrg   MESA_FORMAT_X8B8G8R8_SRGB,    /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */
442848b8605Smrg   MESA_FORMAT_L8A8_SRGB,                            /* AAAA AAAA LLLL LLLL */
443b8e80941Smrg   MESA_FORMAT_A8L8_SRGB,                            /* LLLL LLLL AAAA AAAA */
444b8e80941Smrg   MESA_FORMAT_R_SRGB8,          /* RRRR RRRR */
445848b8605Smrg
446848b8605Smrg   /* Array sRGB formats */
447848b8605Smrg   MESA_FORMAT_L_SRGB8,       /* ubyte[i] = L */
448848b8605Smrg   MESA_FORMAT_BGR_SRGB8,     /* ubyte[i*3] = B, [i*3+1] = G, [i*3+2] = R */
449848b8605Smrg
450848b8605Smrg   /* Packed float formats */
451848b8605Smrg   MESA_FORMAT_R9G9B9E5_FLOAT,
452848b8605Smrg   MESA_FORMAT_R11G11B10_FLOAT,   /* BBBB BBBB BBGG GGGG GGGG GRRR RRRR RRRR */
453848b8605Smrg   MESA_FORMAT_Z32_FLOAT_S8X24_UINT, /* (float, x24s8) */
454848b8605Smrg
455848b8605Smrg   /* Array float formats */
456848b8605Smrg   MESA_FORMAT_A_FLOAT16,
457848b8605Smrg   MESA_FORMAT_A_FLOAT32,
458848b8605Smrg   MESA_FORMAT_L_FLOAT16,
459848b8605Smrg   MESA_FORMAT_L_FLOAT32,
460848b8605Smrg   MESA_FORMAT_LA_FLOAT16,
461848b8605Smrg   MESA_FORMAT_LA_FLOAT32,
462848b8605Smrg   MESA_FORMAT_I_FLOAT16,
463848b8605Smrg   MESA_FORMAT_I_FLOAT32,
464848b8605Smrg   MESA_FORMAT_R_FLOAT16,
465848b8605Smrg   MESA_FORMAT_R_FLOAT32,
466848b8605Smrg   MESA_FORMAT_RG_FLOAT16,
467848b8605Smrg   MESA_FORMAT_RG_FLOAT32,
468848b8605Smrg   MESA_FORMAT_RGB_FLOAT16,
469848b8605Smrg   MESA_FORMAT_RGB_FLOAT32,
470848b8605Smrg   MESA_FORMAT_RGBA_FLOAT16,
471848b8605Smrg   MESA_FORMAT_RGBA_FLOAT32,  /* float[0] = R, [1] = G, [2] = B, [3] = A */
472848b8605Smrg   MESA_FORMAT_RGBX_FLOAT16,
473848b8605Smrg   MESA_FORMAT_RGBX_FLOAT32,
474848b8605Smrg   MESA_FORMAT_Z_FLOAT32,
475848b8605Smrg
476848b8605Smrg   /* Packed signed/unsigned non-normalized integer formats */
477b8e80941Smrg
478b8e80941Smrg   MESA_FORMAT_A8B8G8R8_UINT,    /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
479b8e80941Smrg   MESA_FORMAT_A8R8G8B8_UINT,    /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
480b8e80941Smrg   MESA_FORMAT_R8G8B8A8_UINT,    /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
481b8e80941Smrg   MESA_FORMAT_B8G8R8A8_UINT,    /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
482848b8605Smrg   MESA_FORMAT_B10G10R10A2_UINT, /* AARR RRRR RRRR GGGG GGGG GGBB BBBB BBBB */
483848b8605Smrg   MESA_FORMAT_R10G10B10A2_UINT, /* AABB BBBB BBBB GGGG GGGG GGRR RRRR RRRR */
484b8e80941Smrg   MESA_FORMAT_A2B10G10R10_UINT, /* RRRR RRRR RRGG GGGG GGGG BBBB BBBB BBAA */
485b8e80941Smrg   MESA_FORMAT_A2R10G10B10_UINT, /* BBBB BBBB BBGG GGGG GGGG RRRR RRRR RRAA */
486b8e80941Smrg   MESA_FORMAT_B5G6R5_UINT,                          /* RRRR RGGG GGGB BBBB */
487b8e80941Smrg   MESA_FORMAT_R5G6B5_UINT,                          /* BBBB BGGG GGGR RRRR */
488b8e80941Smrg   MESA_FORMAT_B2G3R3_UINT,                                    /* RRRG GGBB */
489b8e80941Smrg   MESA_FORMAT_R3G3B2_UINT,                                    /* BBGG GRRR */
490b8e80941Smrg   MESA_FORMAT_A4B4G4R4_UINT,                        /* RRRR GGGG BBBB AAAA */
491b8e80941Smrg   MESA_FORMAT_R4G4B4A4_UINT,                        /* AAAA BBBB GGGG RRRR */
492b8e80941Smrg   MESA_FORMAT_B4G4R4A4_UINT,                        /* AAAA RRRR GGGG BBBB */
493b8e80941Smrg   MESA_FORMAT_A4R4G4B4_UINT,                        /* BBBB GGGG RRRR AAAA */
494b8e80941Smrg   MESA_FORMAT_A1B5G5R5_UINT,                        /* RRRR RGGG GGBB BBBA */
495b8e80941Smrg   MESA_FORMAT_B5G5R5A1_UINT,                        /* ARRR RRGG GGGB BBBB */
496b8e80941Smrg   MESA_FORMAT_A1R5G5B5_UINT,                        /* BBBB BGGG GGRR RRRA */
497b8e80941Smrg   MESA_FORMAT_R5G5B5A1_UINT,                        /* ABBB BBGG GGGR RRRR */
498848b8605Smrg
499848b8605Smrg   /* Array signed/unsigned non-normalized integer formats */
500848b8605Smrg   MESA_FORMAT_A_UINT8,
501848b8605Smrg   MESA_FORMAT_A_UINT16,
502848b8605Smrg   MESA_FORMAT_A_UINT32,
503848b8605Smrg   MESA_FORMAT_A_SINT8,
504848b8605Smrg   MESA_FORMAT_A_SINT16,
505848b8605Smrg   MESA_FORMAT_A_SINT32,
506848b8605Smrg
507848b8605Smrg   MESA_FORMAT_I_UINT8,
508848b8605Smrg   MESA_FORMAT_I_UINT16,
509848b8605Smrg   MESA_FORMAT_I_UINT32,
510848b8605Smrg   MESA_FORMAT_I_SINT8,
511848b8605Smrg   MESA_FORMAT_I_SINT16,
512848b8605Smrg   MESA_FORMAT_I_SINT32,
513848b8605Smrg
514848b8605Smrg   MESA_FORMAT_L_UINT8,
515848b8605Smrg   MESA_FORMAT_L_UINT16,
516848b8605Smrg   MESA_FORMAT_L_UINT32,
517848b8605Smrg   MESA_FORMAT_L_SINT8,
518848b8605Smrg   MESA_FORMAT_L_SINT16,
519848b8605Smrg   MESA_FORMAT_L_SINT32,
520848b8605Smrg
521848b8605Smrg   MESA_FORMAT_LA_UINT8,
522848b8605Smrg   MESA_FORMAT_LA_UINT16,
523848b8605Smrg   MESA_FORMAT_LA_UINT32,
524848b8605Smrg   MESA_FORMAT_LA_SINT8,
525848b8605Smrg   MESA_FORMAT_LA_SINT16,
526848b8605Smrg   MESA_FORMAT_LA_SINT32,
527848b8605Smrg
528848b8605Smrg   MESA_FORMAT_R_UINT8,
529848b8605Smrg   MESA_FORMAT_R_UINT16,
530848b8605Smrg   MESA_FORMAT_R_UINT32,
531848b8605Smrg   MESA_FORMAT_R_SINT8,
532848b8605Smrg   MESA_FORMAT_R_SINT16,
533848b8605Smrg   MESA_FORMAT_R_SINT32,
534848b8605Smrg
535848b8605Smrg   MESA_FORMAT_RG_UINT8,
536848b8605Smrg   MESA_FORMAT_RG_UINT16,
537848b8605Smrg   MESA_FORMAT_RG_UINT32,
538848b8605Smrg   MESA_FORMAT_RG_SINT8,
539848b8605Smrg   MESA_FORMAT_RG_SINT16,
540848b8605Smrg   MESA_FORMAT_RG_SINT32,
541848b8605Smrg
542848b8605Smrg   MESA_FORMAT_RGB_UINT8,
543848b8605Smrg   MESA_FORMAT_RGB_UINT16,
544848b8605Smrg   MESA_FORMAT_RGB_UINT32,
545848b8605Smrg   MESA_FORMAT_RGB_SINT8,
546848b8605Smrg   MESA_FORMAT_RGB_SINT16,
547848b8605Smrg   MESA_FORMAT_RGB_SINT32,
548848b8605Smrg
549848b8605Smrg   MESA_FORMAT_RGBA_UINT8,
550848b8605Smrg   MESA_FORMAT_RGBA_UINT16,
551848b8605Smrg   MESA_FORMAT_RGBA_UINT32,
552848b8605Smrg   MESA_FORMAT_RGBA_SINT8,
553848b8605Smrg   MESA_FORMAT_RGBA_SINT16,
554848b8605Smrg   MESA_FORMAT_RGBA_SINT32,
555848b8605Smrg
556848b8605Smrg   MESA_FORMAT_RGBX_UINT8,
557848b8605Smrg   MESA_FORMAT_RGBX_UINT16,
558848b8605Smrg   MESA_FORMAT_RGBX_UINT32,
559848b8605Smrg   MESA_FORMAT_RGBX_SINT8,
560848b8605Smrg   MESA_FORMAT_RGBX_SINT16,
561848b8605Smrg   MESA_FORMAT_RGBX_SINT32,
562848b8605Smrg
563848b8605Smrg   /* DXT compressed formats */
564848b8605Smrg   MESA_FORMAT_RGB_DXT1,
565848b8605Smrg   MESA_FORMAT_RGBA_DXT1,
566848b8605Smrg   MESA_FORMAT_RGBA_DXT3,
567848b8605Smrg   MESA_FORMAT_RGBA_DXT5,
568848b8605Smrg
569848b8605Smrg   /* DXT sRGB compressed formats */
570848b8605Smrg   MESA_FORMAT_SRGB_DXT1,
571848b8605Smrg   MESA_FORMAT_SRGBA_DXT1,
572848b8605Smrg   MESA_FORMAT_SRGBA_DXT3,
573848b8605Smrg   MESA_FORMAT_SRGBA_DXT5,
574848b8605Smrg
575848b8605Smrg   /* FXT1 compressed formats */
576848b8605Smrg   MESA_FORMAT_RGB_FXT1,
577848b8605Smrg   MESA_FORMAT_RGBA_FXT1,
578848b8605Smrg
579848b8605Smrg   /* RGTC compressed formats */
580848b8605Smrg   MESA_FORMAT_R_RGTC1_UNORM,
581848b8605Smrg   MESA_FORMAT_R_RGTC1_SNORM,
582848b8605Smrg   MESA_FORMAT_RG_RGTC2_UNORM,
583848b8605Smrg   MESA_FORMAT_RG_RGTC2_SNORM,
584848b8605Smrg
585848b8605Smrg   /* LATC1/2 compressed formats */
586848b8605Smrg   MESA_FORMAT_L_LATC1_UNORM,
587848b8605Smrg   MESA_FORMAT_L_LATC1_SNORM,
588848b8605Smrg   MESA_FORMAT_LA_LATC2_UNORM,
589848b8605Smrg   MESA_FORMAT_LA_LATC2_SNORM,
590848b8605Smrg
591848b8605Smrg   /* ETC1/2 compressed formats */
592848b8605Smrg   MESA_FORMAT_ETC1_RGB8,
593848b8605Smrg   MESA_FORMAT_ETC2_RGB8,
594848b8605Smrg   MESA_FORMAT_ETC2_SRGB8,
595848b8605Smrg   MESA_FORMAT_ETC2_RGBA8_EAC,
596848b8605Smrg   MESA_FORMAT_ETC2_SRGB8_ALPHA8_EAC,
597848b8605Smrg   MESA_FORMAT_ETC2_R11_EAC,
598848b8605Smrg   MESA_FORMAT_ETC2_RG11_EAC,
599848b8605Smrg   MESA_FORMAT_ETC2_SIGNED_R11_EAC,
600848b8605Smrg   MESA_FORMAT_ETC2_SIGNED_RG11_EAC,
601848b8605Smrg   MESA_FORMAT_ETC2_RGB8_PUNCHTHROUGH_ALPHA1,
602848b8605Smrg   MESA_FORMAT_ETC2_SRGB8_PUNCHTHROUGH_ALPHA1,
603848b8605Smrg
604848b8605Smrg   /* BPTC compressed formats */
605848b8605Smrg   MESA_FORMAT_BPTC_RGBA_UNORM,
606848b8605Smrg   MESA_FORMAT_BPTC_SRGB_ALPHA_UNORM,
607848b8605Smrg   MESA_FORMAT_BPTC_RGB_SIGNED_FLOAT,
608848b8605Smrg   MESA_FORMAT_BPTC_RGB_UNSIGNED_FLOAT,
609848b8605Smrg
610b8e80941Smrg   /* ASTC compressed formats */
611b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_4x4,
612b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_5x4,
613b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_5x5,
614b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_6x5,
615b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_6x6,
616b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_8x5,
617b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_8x6,
618b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_8x8,
619b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_10x5,
620b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_10x6,
621b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_10x8,
622b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_10x10,
623b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_12x10,
624b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_12x12,
625b8e80941Smrg
626b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4,
627b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x4,
628b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5,
629b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x5,
630b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6,
631b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x5,
632b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x6,
633b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_8x8,
634b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x5,
635b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x6,
636b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x8,
637b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_10x10,
638b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_12x10,
639b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_12x12,
640b8e80941Smrg
641b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_3x3x3,
642b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_4x3x3,
643b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_4x4x3,
644b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_4x4x4,
645b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_5x4x4,
646b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_5x5x4,
647b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_5x5x5,
648b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_6x5x5,
649b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_6x6x5,
650b8e80941Smrg   MESA_FORMAT_RGBA_ASTC_6x6x6,
651b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_3x3x3,
652b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x3x3,
653b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4x3,
654b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_4x4x4,
655b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x4x4,
656b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5x4,
657b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_5x5x5,
658b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x5x5,
659b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x5,
660b8e80941Smrg   MESA_FORMAT_SRGB8_ALPHA8_ASTC_6x6x6,
661b8e80941Smrg
662b8e80941Smrg   /* ATC compressed formats */
663b8e80941Smrg   MESA_FORMAT_ATC_RGB,
664b8e80941Smrg   MESA_FORMAT_ATC_RGBA_EXPLICIT,
665b8e80941Smrg   MESA_FORMAT_ATC_RGBA_INTERPOLATED,
666b8e80941Smrg
667848b8605Smrg   MESA_FORMAT_COUNT
668848b8605Smrg} mesa_format;
669848b8605Smrg
670848b8605Smrg
671848b8605Smrgextern const char *
672848b8605Smrg_mesa_get_format_name(mesa_format format);
673848b8605Smrg
674848b8605Smrgextern GLint
675848b8605Smrg_mesa_get_format_bytes(mesa_format format);
676848b8605Smrg
677848b8605Smrgextern GLint
678848b8605Smrg_mesa_get_format_bits(mesa_format format, GLenum pname);
679848b8605Smrg
680848b8605Smrgextern GLuint
681848b8605Smrg_mesa_get_format_max_bits(mesa_format format);
682848b8605Smrg
683848b8605Smrgextern enum mesa_format_layout
684848b8605Smrg_mesa_get_format_layout(mesa_format format);
685848b8605Smrg
686848b8605Smrgextern GLenum
687848b8605Smrg_mesa_get_format_datatype(mesa_format format);
688848b8605Smrg
689848b8605Smrgextern GLenum
690b8e80941Smrg_mesa_get_format_base_format(uint32_t format);
691848b8605Smrg
692848b8605Smrgextern void
693848b8605Smrg_mesa_get_format_block_size(mesa_format format, GLuint *bw, GLuint *bh);
694848b8605Smrg
695b8e80941Smrgextern void
696b8e80941Smrg_mesa_get_format_block_size_3d(mesa_format format, GLuint *bw,
697b8e80941Smrg                               GLuint *bh, GLuint *bd);
698b8e80941Smrg
699b8e80941Smrgextern mesa_array_format
700b8e80941Smrg_mesa_array_format_flip_channels(mesa_array_format format);
701b8e80941Smrg
702848b8605Smrgextern void
703848b8605Smrg_mesa_get_format_swizzle(mesa_format format, uint8_t swizzle_out[4]);
704848b8605Smrg
705b8e80941Smrgextern uint32_t
706b8e80941Smrg_mesa_format_to_array_format(mesa_format format);
707b8e80941Smrg
708b8e80941Smrgextern mesa_format
709b8e80941Smrg_mesa_format_from_array_format(uint32_t array_format);
710b8e80941Smrg
711848b8605Smrgextern GLboolean
712848b8605Smrg_mesa_is_format_compressed(mesa_format format);
713848b8605Smrg
714848b8605Smrgextern GLboolean
715848b8605Smrg_mesa_is_format_packed_depth_stencil(mesa_format format);
716848b8605Smrg
717848b8605Smrgextern GLboolean
718848b8605Smrg_mesa_is_format_integer_color(mesa_format format);
719848b8605Smrg
720848b8605Smrgextern GLboolean
721848b8605Smrg_mesa_is_format_unsigned(mesa_format format);
722848b8605Smrg
723848b8605Smrgextern GLboolean
724848b8605Smrg_mesa_is_format_signed(mesa_format format);
725848b8605Smrg
726848b8605Smrgextern GLboolean
727848b8605Smrg_mesa_is_format_integer(mesa_format format);
728848b8605Smrg
729848b8605Smrgextern bool
730848b8605Smrg_mesa_is_format_etc2(mesa_format format);
731848b8605Smrg
732b8e80941Smrgbool
733b8e80941Smrg_mesa_is_format_astc_2d(mesa_format format);
734b8e80941Smrg
735b8e80941SmrgGLenum
736b8e80941Smrg_mesa_is_format_color_format(mesa_format format);
737b8e80941Smrg
738848b8605Smrgextern GLenum
739848b8605Smrg_mesa_get_format_color_encoding(mesa_format format);
740848b8605Smrg
741848b8605Smrgextern GLuint
742848b8605Smrg_mesa_format_image_size(mesa_format format, GLsizei width,
743848b8605Smrg                        GLsizei height, GLsizei depth);
744848b8605Smrg
745848b8605Smrgextern uint64_t
746848b8605Smrg_mesa_format_image_size64(mesa_format format, GLsizei width,
747848b8605Smrg                          GLsizei height, GLsizei depth);
748848b8605Smrg
749848b8605Smrgextern GLint
750848b8605Smrg_mesa_format_row_stride(mesa_format format, GLsizei width);
751848b8605Smrg
752848b8605Smrgextern void
753b8e80941Smrg_mesa_uncompressed_format_to_type_and_comps(mesa_format format,
754848b8605Smrg                               GLenum *datatype, GLuint *comps);
755848b8605Smrg
756848b8605Smrgextern void
757848b8605Smrg_mesa_test_formats(void);
758848b8605Smrg
759848b8605Smrgextern mesa_format
760848b8605Smrg_mesa_get_srgb_format_linear(mesa_format format);
761848b8605Smrg
762b8e80941Smrgextern mesa_format
763b8e80941Smrg_mesa_get_linear_format_srgb(mesa_format format);
764b8e80941Smrg
765848b8605Smrgextern mesa_format
766848b8605Smrg_mesa_get_uncompressed_format(mesa_format format);
767848b8605Smrg
768848b8605Smrgextern GLuint
769848b8605Smrg_mesa_format_num_components(mesa_format format);
770848b8605Smrg
771848b8605Smrgextern bool
772848b8605Smrg_mesa_format_has_color_component(mesa_format format, int component);
773848b8605Smrg
774848b8605SmrgGLboolean
775848b8605Smrg_mesa_format_matches_format_and_type(mesa_format mesa_format,
776848b8605Smrg				     GLenum format, GLenum type,
777b8e80941Smrg				     GLboolean swapBytes, GLenum *error);
778b8e80941Smrg
779b8e80941Smrgmesa_format
780b8e80941Smrg_mesa_format_fallback_rgbx_to_rgba(mesa_format format);
781848b8605Smrg
782848b8605Smrg#ifdef __cplusplus
783848b8605Smrg}
784848b8605Smrg#endif
785848b8605Smrg
786848b8605Smrg#endif /* FORMATS_H */
787