• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**************************************************************************
2  *
3  * Copyright 2007 VMware, Inc.
4  * Copyright (c) 2008 VMware, Inc.
5  * All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sub license, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to
13  * the following conditions:
14  *
15  * The above copyright notice and this permission notice (including the
16  * next paragraph) shall be included in all copies or substantial portions
17  * of the Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
22  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
23  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
24  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
25  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26  *
27  **************************************************************************/
28 
29 #ifndef U_FORMATS_H_
30 #define U_FORMATS_H_
31 
32 #include "util/detect.h"
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 /**
39  * Formats for textures, surfaces and vertex data
40  */
41 enum pipe_format {
42    PIPE_FORMAT_NONE,
43    /* Vertex formats must be first and must be <= 255. */
44    PIPE_FORMAT_R64_UINT,    /**< raw doubles (ARB_vertex_attrib_64bit) */
45    PIPE_FORMAT_R64G64_UINT,
46    PIPE_FORMAT_R64G64B64_UINT,
47    PIPE_FORMAT_R64G64B64A64_UINT,
48    PIPE_FORMAT_R64_SINT,
49    PIPE_FORMAT_R64G64_SINT,
50    PIPE_FORMAT_R64G64B64_SINT,
51    PIPE_FORMAT_R64G64B64A64_SINT,
52    PIPE_FORMAT_R64_FLOAT,   /**< doubles converted to float */
53    PIPE_FORMAT_R64G64_FLOAT,
54    PIPE_FORMAT_R64G64B64_FLOAT,
55    PIPE_FORMAT_R64G64B64A64_FLOAT,
56    PIPE_FORMAT_R32_FLOAT,
57    PIPE_FORMAT_R32G32_FLOAT,
58    PIPE_FORMAT_R32G32B32_FLOAT,
59    PIPE_FORMAT_R32G32B32A32_FLOAT,
60    PIPE_FORMAT_R32_UNORM,
61    PIPE_FORMAT_R32G32_UNORM,
62    PIPE_FORMAT_R32G32B32_UNORM,
63    PIPE_FORMAT_R32G32B32A32_UNORM,
64    PIPE_FORMAT_R32_USCALED,
65    PIPE_FORMAT_R32G32_USCALED,
66    PIPE_FORMAT_R32G32B32_USCALED,
67    PIPE_FORMAT_R32G32B32A32_USCALED,
68    PIPE_FORMAT_R32_SNORM,
69    PIPE_FORMAT_R32G32_SNORM,
70    PIPE_FORMAT_R32G32B32_SNORM,
71    PIPE_FORMAT_R32G32B32A32_SNORM,
72    PIPE_FORMAT_R32_SSCALED,
73    PIPE_FORMAT_R32G32_SSCALED,
74    PIPE_FORMAT_R32G32B32_SSCALED,
75    PIPE_FORMAT_R32G32B32A32_SSCALED,
76    PIPE_FORMAT_R16_UNORM,
77    PIPE_FORMAT_R16G16_UNORM,
78    PIPE_FORMAT_R16G16B16_UNORM,
79    PIPE_FORMAT_R16G16B16A16_UNORM,
80    PIPE_FORMAT_R16_USCALED,
81    PIPE_FORMAT_R16G16_USCALED,
82    PIPE_FORMAT_R16G16B16_USCALED,
83    PIPE_FORMAT_R16G16B16A16_USCALED,
84    PIPE_FORMAT_R16_SNORM,
85    PIPE_FORMAT_R16G16_SNORM,
86    PIPE_FORMAT_R16G16B16_SNORM,
87    PIPE_FORMAT_R16G16B16A16_SNORM,
88    PIPE_FORMAT_R16_SSCALED,
89    PIPE_FORMAT_R16G16_SSCALED,
90    PIPE_FORMAT_R16G16B16_SSCALED,
91    PIPE_FORMAT_R16G16B16A16_SSCALED,
92    PIPE_FORMAT_R8_UNORM,
93    PIPE_FORMAT_R8G8_UNORM,
94    PIPE_FORMAT_R8G8B8_UNORM,
95    PIPE_FORMAT_B8G8R8_UNORM,
96    PIPE_FORMAT_R8G8B8A8_UNORM,
97    PIPE_FORMAT_B8G8R8A8_UNORM,
98    PIPE_FORMAT_R8_USCALED,
99    PIPE_FORMAT_R8G8_USCALED,
100    PIPE_FORMAT_R8G8B8_USCALED,
101    PIPE_FORMAT_B8G8R8_USCALED,
102    PIPE_FORMAT_R8G8B8A8_USCALED,
103    PIPE_FORMAT_B8G8R8A8_USCALED,
104    PIPE_FORMAT_A8B8G8R8_USCALED,
105    PIPE_FORMAT_R8_SNORM,
106    PIPE_FORMAT_R8G8_SNORM,
107    PIPE_FORMAT_R8G8B8_SNORM,
108    PIPE_FORMAT_B8G8R8_SNORM,
109    PIPE_FORMAT_R8G8B8A8_SNORM,
110    PIPE_FORMAT_B8G8R8A8_SNORM,
111    PIPE_FORMAT_R8_SSCALED,
112    PIPE_FORMAT_R8G8_SSCALED,
113    PIPE_FORMAT_R8G8B8_SSCALED,
114    PIPE_FORMAT_B8G8R8_SSCALED,
115    PIPE_FORMAT_R8G8B8A8_SSCALED,
116    PIPE_FORMAT_B8G8R8A8_SSCALED,
117    PIPE_FORMAT_A8B8G8R8_SSCALED,
118    PIPE_FORMAT_A8R8G8B8_UNORM,
119    PIPE_FORMAT_R32_FIXED,
120    PIPE_FORMAT_R32G32_FIXED,
121    PIPE_FORMAT_R32G32B32_FIXED,
122    PIPE_FORMAT_R32G32B32A32_FIXED,
123    PIPE_FORMAT_R16_FLOAT,
124    PIPE_FORMAT_R16G16_FLOAT,
125    PIPE_FORMAT_R16G16B16_FLOAT,
126    PIPE_FORMAT_R16G16B16A16_FLOAT,
127    PIPE_FORMAT_R8_UINT,
128    PIPE_FORMAT_R8G8_UINT,
129    PIPE_FORMAT_R8G8B8_UINT,
130    PIPE_FORMAT_B8G8R8_UINT,
131    PIPE_FORMAT_R8G8B8A8_UINT,
132    PIPE_FORMAT_B8G8R8A8_UINT,
133    PIPE_FORMAT_R8_SINT,
134    PIPE_FORMAT_R8G8_SINT,
135    PIPE_FORMAT_R8G8B8_SINT,
136    PIPE_FORMAT_B8G8R8_SINT,
137    PIPE_FORMAT_R8G8B8A8_SINT,
138    PIPE_FORMAT_B8G8R8A8_SINT,
139    PIPE_FORMAT_R16_UINT,
140    PIPE_FORMAT_R16G16_UINT,
141    PIPE_FORMAT_R16G16B16_UINT,
142    PIPE_FORMAT_R16G16B16A16_UINT,
143    PIPE_FORMAT_R16_SINT,
144    PIPE_FORMAT_R16G16_SINT,
145    PIPE_FORMAT_R16G16B16_SINT,
146    PIPE_FORMAT_R16G16B16A16_SINT,
147    PIPE_FORMAT_R32_UINT,
148    PIPE_FORMAT_R32G32_UINT,
149    PIPE_FORMAT_R32G32B32_UINT,
150    PIPE_FORMAT_R32G32B32A32_UINT,
151    PIPE_FORMAT_R32_SINT,
152    PIPE_FORMAT_R32G32_SINT,
153    PIPE_FORMAT_R32G32B32_SINT,
154    PIPE_FORMAT_R32G32B32A32_SINT,
155 
156    PIPE_FORMAT_R10G10B10A2_UNORM,
157    PIPE_FORMAT_R10G10B10A2_SNORM,
158    PIPE_FORMAT_R10G10B10A2_USCALED,
159    PIPE_FORMAT_R10G10B10A2_SSCALED,
160 
161    PIPE_FORMAT_B10G10R10A2_UNORM,
162    PIPE_FORMAT_B10G10R10A2_SNORM,
163    PIPE_FORMAT_B10G10R10A2_USCALED,
164    PIPE_FORMAT_B10G10R10A2_SSCALED,
165 
166    PIPE_FORMAT_R11G11B10_FLOAT,
167 
168    PIPE_FORMAT_R10G10B10A2_UINT,
169    PIPE_FORMAT_R10G10B10A2_SINT,
170 
171    PIPE_FORMAT_B10G10R10A2_UINT,
172    PIPE_FORMAT_B10G10R10A2_SINT,
173 
174    /* End of vertex formats. */
175 
176    /* Texture-only formats are below. */
177    PIPE_FORMAT_B8G8R8X8_UNORM,
178    PIPE_FORMAT_X8B8G8R8_UNORM,
179    PIPE_FORMAT_X8R8G8B8_UNORM,
180    PIPE_FORMAT_B5G5R5A1_UNORM,
181    PIPE_FORMAT_R4G4B4A4_UNORM,
182    PIPE_FORMAT_B4G4R4A4_UNORM,
183    PIPE_FORMAT_R5G6B5_UNORM,
184    PIPE_FORMAT_B5G6R5_UNORM,
185    PIPE_FORMAT_L8_UNORM,    /**< ubyte luminance */
186    PIPE_FORMAT_A8_UNORM,    /**< ubyte alpha */
187    PIPE_FORMAT_I8_UNORM,    /**< ubyte intensity */
188    PIPE_FORMAT_L8A8_UNORM,  /**< ubyte alpha, luminance */
189    PIPE_FORMAT_L16_UNORM,   /**< ushort luminance */
190    PIPE_FORMAT_UYVY,
191    PIPE_FORMAT_VYUY,
192    PIPE_FORMAT_YUYV,
193    PIPE_FORMAT_YVYU,
194    PIPE_FORMAT_Z16_UNORM,
195    PIPE_FORMAT_Z16_UNORM_S8_UINT,
196    PIPE_FORMAT_Z32_UNORM,
197    PIPE_FORMAT_Z32_FLOAT,
198    PIPE_FORMAT_Z24_UNORM_S8_UINT,
199    PIPE_FORMAT_S8_UINT_Z24_UNORM,
200    PIPE_FORMAT_Z24X8_UNORM,
201    PIPE_FORMAT_X8Z24_UNORM,
202    PIPE_FORMAT_S8_UINT,     /**< ubyte stencil */
203 
204    /* sRGB formats */
205    PIPE_FORMAT_L8_SRGB,
206    PIPE_FORMAT_R8_SRGB,
207    PIPE_FORMAT_L8A8_SRGB,
208    PIPE_FORMAT_R8G8_SRGB,
209    PIPE_FORMAT_R8G8B8_SRGB,
210    PIPE_FORMAT_B8G8R8_SRGB,
211    PIPE_FORMAT_A8B8G8R8_SRGB,
212    PIPE_FORMAT_X8B8G8R8_SRGB,
213    PIPE_FORMAT_B8G8R8A8_SRGB,
214    PIPE_FORMAT_B8G8R8X8_SRGB,
215    PIPE_FORMAT_A8R8G8B8_SRGB,
216    PIPE_FORMAT_X8R8G8B8_SRGB,
217    PIPE_FORMAT_R8G8B8A8_SRGB,
218 
219    /* compressed formats */
220    PIPE_FORMAT_DXT1_RGB,
221    PIPE_FORMAT_DXT1_RGBA,
222    PIPE_FORMAT_DXT3_RGBA,
223    PIPE_FORMAT_DXT5_RGBA,
224 
225    /* sRGB, compressed */
226    PIPE_FORMAT_DXT1_SRGB,
227    PIPE_FORMAT_DXT1_SRGBA,
228    PIPE_FORMAT_DXT3_SRGBA,
229    PIPE_FORMAT_DXT5_SRGBA,
230 
231    /* rgtc compressed */
232    PIPE_FORMAT_RGTC1_UNORM,
233    PIPE_FORMAT_RGTC1_SNORM,
234    PIPE_FORMAT_RGTC2_UNORM,
235    PIPE_FORMAT_RGTC2_SNORM,
236 
237    PIPE_FORMAT_R8G8_B8G8_UNORM,
238    PIPE_FORMAT_G8R8_G8B8_UNORM,
239 
240    /* mixed formats */
241    PIPE_FORMAT_R8SG8SB8UX8U_NORM,
242    PIPE_FORMAT_R5SG5SB6U_NORM,
243 
244    /* TODO: re-order these */
245    PIPE_FORMAT_A8B8G8R8_UNORM,
246    PIPE_FORMAT_B5G5R5X1_UNORM,
247    PIPE_FORMAT_R9G9B9E5_FLOAT,
248    PIPE_FORMAT_Z32_FLOAT_S8X24_UINT,
249    PIPE_FORMAT_R1_UNORM,
250    PIPE_FORMAT_R10G10B10X2_USCALED,
251    PIPE_FORMAT_R10G10B10X2_SNORM,
252    PIPE_FORMAT_L4A4_UNORM,
253    PIPE_FORMAT_A2R10G10B10_UNORM,
254    PIPE_FORMAT_A2B10G10R10_UNORM,
255    PIPE_FORMAT_R10SG10SB10SA2U_NORM,
256    PIPE_FORMAT_R8G8Bx_SNORM,
257    PIPE_FORMAT_R8G8B8X8_UNORM,
258    PIPE_FORMAT_B4G4R4X4_UNORM,
259 
260    /* some stencil samplers formats */
261    PIPE_FORMAT_X24S8_UINT,
262    PIPE_FORMAT_S8X24_UINT,
263    PIPE_FORMAT_X32_S8X24_UINT,
264 
265    PIPE_FORMAT_R3G3B2_UNORM,
266    PIPE_FORMAT_B2G3R3_UNORM,
267    PIPE_FORMAT_L16A16_UNORM,
268    PIPE_FORMAT_A16_UNORM,
269    PIPE_FORMAT_I16_UNORM,
270 
271    PIPE_FORMAT_LATC1_UNORM,
272    PIPE_FORMAT_LATC1_SNORM,
273    PIPE_FORMAT_LATC2_UNORM,
274    PIPE_FORMAT_LATC2_SNORM,
275 
276    PIPE_FORMAT_A8_SNORM,
277    PIPE_FORMAT_L8_SNORM,
278    PIPE_FORMAT_L8A8_SNORM,
279    PIPE_FORMAT_I8_SNORM,
280    PIPE_FORMAT_A16_SNORM,
281    PIPE_FORMAT_L16_SNORM,
282    PIPE_FORMAT_L16A16_SNORM,
283    PIPE_FORMAT_I16_SNORM,
284 
285    PIPE_FORMAT_A16_FLOAT,
286    PIPE_FORMAT_L16_FLOAT,
287    PIPE_FORMAT_L16A16_FLOAT,
288    PIPE_FORMAT_I16_FLOAT,
289    PIPE_FORMAT_A32_FLOAT,
290    PIPE_FORMAT_L32_FLOAT,
291    PIPE_FORMAT_L32A32_FLOAT,
292    PIPE_FORMAT_I32_FLOAT,
293 
294    PIPE_FORMAT_YV12,
295    PIPE_FORMAT_YV16,
296    PIPE_FORMAT_IYUV,  /**< aka I420 */
297    PIPE_FORMAT_NV12,
298    PIPE_FORMAT_NV21,
299 
300    PIPE_FORMAT_Y8_400_UNORM,
301    /* PIPE_FORMAT_Y8_U8_V8_420_UNORM = IYUV */
302    /* PIPE_FORMAT_Y8_U8V8_420_UNORM = NV12 */
303    PIPE_FORMAT_Y8_U8_V8_422_UNORM,
304    PIPE_FORMAT_Y8_U8V8_422_UNORM,
305    PIPE_FORMAT_Y8_U8_V8_444_UNORM,
306 
307    PIPE_FORMAT_Y16_U16_V16_420_UNORM,
308     /* PIPE_FORMAT_Y16_U16V16_420_UNORM */
309    PIPE_FORMAT_Y16_U16_V16_422_UNORM,
310    PIPE_FORMAT_Y16_U16V16_422_UNORM,
311    PIPE_FORMAT_Y16_U16_V16_444_UNORM,
312 
313    PIPE_FORMAT_A4R4_UNORM,
314    PIPE_FORMAT_R4A4_UNORM,
315    PIPE_FORMAT_R8A8_UNORM,
316    PIPE_FORMAT_A8R8_UNORM,
317 
318    PIPE_FORMAT_A8_UINT,
319    PIPE_FORMAT_I8_UINT,
320    PIPE_FORMAT_L8_UINT,
321    PIPE_FORMAT_L8A8_UINT,
322 
323    PIPE_FORMAT_A8_SINT,
324    PIPE_FORMAT_I8_SINT,
325    PIPE_FORMAT_L8_SINT,
326    PIPE_FORMAT_L8A8_SINT,
327 
328    PIPE_FORMAT_A16_UINT,
329    PIPE_FORMAT_I16_UINT,
330    PIPE_FORMAT_L16_UINT,
331    PIPE_FORMAT_L16A16_UINT,
332 
333    PIPE_FORMAT_A16_SINT,
334    PIPE_FORMAT_I16_SINT,
335    PIPE_FORMAT_L16_SINT,
336    PIPE_FORMAT_L16A16_SINT,
337 
338    PIPE_FORMAT_A32_UINT,
339    PIPE_FORMAT_I32_UINT,
340    PIPE_FORMAT_L32_UINT,
341    PIPE_FORMAT_L32A32_UINT,
342 
343    PIPE_FORMAT_A32_SINT,
344    PIPE_FORMAT_I32_SINT,
345    PIPE_FORMAT_L32_SINT,
346    PIPE_FORMAT_L32A32_SINT,
347 
348    PIPE_FORMAT_A8R8G8B8_UINT,
349    PIPE_FORMAT_A8B8G8R8_UINT,
350    PIPE_FORMAT_A2R10G10B10_UINT,
351    PIPE_FORMAT_A2B10G10R10_UINT,
352    PIPE_FORMAT_R5G6B5_UINT,
353    PIPE_FORMAT_B5G6R5_UINT,
354    PIPE_FORMAT_R5G5B5A1_UINT,
355    PIPE_FORMAT_B5G5R5A1_UINT,
356    PIPE_FORMAT_A1R5G5B5_UINT,
357    PIPE_FORMAT_A1B5G5R5_UINT,
358    PIPE_FORMAT_R4G4B4A4_UINT,
359    PIPE_FORMAT_B4G4R4A4_UINT,
360    PIPE_FORMAT_A4R4G4B4_UINT,
361    PIPE_FORMAT_A4B4G4R4_UINT,
362    PIPE_FORMAT_R3G3B2_UINT,
363    PIPE_FORMAT_B2G3R3_UINT,
364 
365    PIPE_FORMAT_ETC1_RGB8,
366 
367    PIPE_FORMAT_R8G8_R8B8_UNORM,
368    PIPE_FORMAT_R8B8_R8G8_UNORM,
369    PIPE_FORMAT_G8R8_B8R8_UNORM,
370    PIPE_FORMAT_B8R8_G8R8_UNORM,
371    PIPE_FORMAT_G8B8_G8R8_UNORM,
372    PIPE_FORMAT_B8G8_R8G8_UNORM,
373 
374    PIPE_FORMAT_R8G8B8X8_SNORM,
375    PIPE_FORMAT_R8G8B8X8_SRGB,
376    PIPE_FORMAT_R8G8B8X8_UINT,
377    PIPE_FORMAT_R8G8B8X8_SINT,
378    PIPE_FORMAT_B10G10R10X2_UNORM,
379    PIPE_FORMAT_R16G16B16X16_UNORM,
380    PIPE_FORMAT_R16G16B16X16_SNORM,
381    PIPE_FORMAT_R16G16B16X16_FLOAT,
382    PIPE_FORMAT_R16G16B16X16_UINT,
383    PIPE_FORMAT_R16G16B16X16_SINT,
384    PIPE_FORMAT_R32G32B32X32_FLOAT,
385    PIPE_FORMAT_R32G32B32X32_UINT,
386    PIPE_FORMAT_R32G32B32X32_SINT,
387 
388    PIPE_FORMAT_R8A8_SNORM,
389    PIPE_FORMAT_R16A16_UNORM,
390    PIPE_FORMAT_R16A16_SNORM,
391    PIPE_FORMAT_R16A16_FLOAT,
392    PIPE_FORMAT_R32A32_FLOAT,
393    PIPE_FORMAT_R8A8_UINT,
394    PIPE_FORMAT_R8A8_SINT,
395    PIPE_FORMAT_R16A16_UINT,
396    PIPE_FORMAT_R16A16_SINT,
397    PIPE_FORMAT_R32A32_UINT,
398    PIPE_FORMAT_R32A32_SINT,
399 
400    PIPE_FORMAT_B5G6R5_SRGB,
401 
402    PIPE_FORMAT_BPTC_RGBA_UNORM,
403    PIPE_FORMAT_BPTC_SRGBA,
404    PIPE_FORMAT_BPTC_RGB_FLOAT,
405    PIPE_FORMAT_BPTC_RGB_UFLOAT,
406 
407    PIPE_FORMAT_G8R8_UNORM,
408    PIPE_FORMAT_G8R8_SNORM,
409    PIPE_FORMAT_G16R16_UNORM,
410    PIPE_FORMAT_G16R16_SNORM,
411 
412    PIPE_FORMAT_A8B8G8R8_SNORM,
413    PIPE_FORMAT_X8B8G8R8_SNORM,
414 
415    PIPE_FORMAT_ETC2_RGB8,
416    PIPE_FORMAT_ETC2_SRGB8,
417    PIPE_FORMAT_ETC2_RGB8A1,
418    PIPE_FORMAT_ETC2_SRGB8A1,
419    PIPE_FORMAT_ETC2_RGBA8,
420    PIPE_FORMAT_ETC2_SRGBA8,
421    PIPE_FORMAT_ETC2_R11_UNORM,
422    PIPE_FORMAT_ETC2_R11_SNORM,
423    PIPE_FORMAT_ETC2_RG11_UNORM,
424    PIPE_FORMAT_ETC2_RG11_SNORM,
425 
426    PIPE_FORMAT_ASTC_4x4,
427    PIPE_FORMAT_ASTC_5x4,
428    PIPE_FORMAT_ASTC_5x5,
429    PIPE_FORMAT_ASTC_6x5,
430    PIPE_FORMAT_ASTC_6x6,
431    PIPE_FORMAT_ASTC_8x5,
432    PIPE_FORMAT_ASTC_8x6,
433    PIPE_FORMAT_ASTC_8x8,
434    PIPE_FORMAT_ASTC_10x5,
435    PIPE_FORMAT_ASTC_10x6,
436    PIPE_FORMAT_ASTC_10x8,
437    PIPE_FORMAT_ASTC_10x10,
438    PIPE_FORMAT_ASTC_12x10,
439    PIPE_FORMAT_ASTC_12x12,
440 
441    PIPE_FORMAT_ASTC_4x4_SRGB,
442    PIPE_FORMAT_ASTC_5x4_SRGB,
443    PIPE_FORMAT_ASTC_5x5_SRGB,
444    PIPE_FORMAT_ASTC_6x5_SRGB,
445    PIPE_FORMAT_ASTC_6x6_SRGB,
446    PIPE_FORMAT_ASTC_8x5_SRGB,
447    PIPE_FORMAT_ASTC_8x6_SRGB,
448    PIPE_FORMAT_ASTC_8x8_SRGB,
449    PIPE_FORMAT_ASTC_10x5_SRGB,
450    PIPE_FORMAT_ASTC_10x6_SRGB,
451    PIPE_FORMAT_ASTC_10x8_SRGB,
452    PIPE_FORMAT_ASTC_10x10_SRGB,
453    PIPE_FORMAT_ASTC_12x10_SRGB,
454    PIPE_FORMAT_ASTC_12x12_SRGB,
455 
456    PIPE_FORMAT_ASTC_3x3x3,
457    PIPE_FORMAT_ASTC_4x3x3,
458    PIPE_FORMAT_ASTC_4x4x3,
459    PIPE_FORMAT_ASTC_4x4x4,
460    PIPE_FORMAT_ASTC_5x4x4,
461    PIPE_FORMAT_ASTC_5x5x4,
462    PIPE_FORMAT_ASTC_5x5x5,
463    PIPE_FORMAT_ASTC_6x5x5,
464    PIPE_FORMAT_ASTC_6x6x5,
465    PIPE_FORMAT_ASTC_6x6x6,
466 
467    PIPE_FORMAT_ASTC_3x3x3_SRGB,
468    PIPE_FORMAT_ASTC_4x3x3_SRGB,
469    PIPE_FORMAT_ASTC_4x4x3_SRGB,
470    PIPE_FORMAT_ASTC_4x4x4_SRGB,
471    PIPE_FORMAT_ASTC_5x4x4_SRGB,
472    PIPE_FORMAT_ASTC_5x5x4_SRGB,
473    PIPE_FORMAT_ASTC_5x5x5_SRGB,
474    PIPE_FORMAT_ASTC_6x5x5_SRGB,
475    PIPE_FORMAT_ASTC_6x6x5_SRGB,
476    PIPE_FORMAT_ASTC_6x6x6_SRGB,
477 
478    PIPE_FORMAT_FXT1_RGB,
479    PIPE_FORMAT_FXT1_RGBA,
480 
481    PIPE_FORMAT_P010,
482    PIPE_FORMAT_P012,
483    PIPE_FORMAT_P016,
484    PIPE_FORMAT_P030,
485 
486    PIPE_FORMAT_Y210,
487    PIPE_FORMAT_Y212,
488    PIPE_FORMAT_Y216,
489 
490    PIPE_FORMAT_Y410,
491    PIPE_FORMAT_Y412,
492    PIPE_FORMAT_Y416,
493 
494    PIPE_FORMAT_R10G10B10X2_UNORM,
495    PIPE_FORMAT_A1R5G5B5_UNORM,
496    PIPE_FORMAT_A1B5G5R5_UNORM,
497    PIPE_FORMAT_X1B5G5R5_UNORM,
498    PIPE_FORMAT_R5G5B5A1_UNORM,
499    PIPE_FORMAT_A4R4G4B4_UNORM,
500    PIPE_FORMAT_A4B4G4R4_UNORM,
501 
502    PIPE_FORMAT_G8R8_SINT,
503    PIPE_FORMAT_A8B8G8R8_SINT,
504    PIPE_FORMAT_X8B8G8R8_SINT,
505 
506    PIPE_FORMAT_ATC_RGB,
507    PIPE_FORMAT_ATC_RGBA_EXPLICIT,
508    PIPE_FORMAT_ATC_RGBA_INTERPOLATED,
509 
510    PIPE_FORMAT_Z24_UNORM_S8_UINT_AS_R8G8B8A8,
511 
512    PIPE_FORMAT_AYUV,
513    PIPE_FORMAT_XYUV,
514 
515    PIPE_FORMAT_R8_G8B8_420_UNORM,
516    PIPE_FORMAT_R8_B8G8_420_UNORM,
517    PIPE_FORMAT_G8_B8R8_420_UNORM,
518    PIPE_FORMAT_R8_G8_B8_420_UNORM,
519    PIPE_FORMAT_R8_B8_G8_420_UNORM,
520    PIPE_FORMAT_G8_B8_R8_420_UNORM,
521    PIPE_FORMAT_R8_G8_B8_UNORM,
522    PIPE_FORMAT_Y8_UNORM,
523 
524    PIPE_FORMAT_B8G8R8X8_SNORM,
525    PIPE_FORMAT_B8G8R8X8_UINT,
526    PIPE_FORMAT_B8G8R8X8_SINT,
527    PIPE_FORMAT_A8R8G8B8_SNORM,
528    PIPE_FORMAT_A8R8G8B8_SINT,
529    PIPE_FORMAT_X8R8G8B8_SNORM,
530    PIPE_FORMAT_X8R8G8B8_SINT,
531    PIPE_FORMAT_R5G5B5X1_UNORM,
532    PIPE_FORMAT_X1R5G5B5_UNORM,
533    PIPE_FORMAT_R4G4B4X4_UNORM,
534    PIPE_FORMAT_B10G10R10X2_SNORM,
535    PIPE_FORMAT_R5G6B5_SRGB,
536    PIPE_FORMAT_R10G10B10X2_SINT,
537    PIPE_FORMAT_B10G10R10X2_SINT,
538    PIPE_FORMAT_G16R16_SINT,
539 
540    PIPE_FORMAT_COUNT
541 };
542 
543 #if UTIL_ARCH_LITTLE_ENDIAN
544 #define PIPE_FORMAT_RGBA8888_UNORM PIPE_FORMAT_R8G8B8A8_UNORM
545 #define PIPE_FORMAT_RGBX8888_UNORM PIPE_FORMAT_R8G8B8X8_UNORM
546 #define PIPE_FORMAT_BGRA8888_UNORM PIPE_FORMAT_B8G8R8A8_UNORM
547 #define PIPE_FORMAT_BGRX8888_UNORM PIPE_FORMAT_B8G8R8X8_UNORM
548 #define PIPE_FORMAT_ARGB8888_UNORM PIPE_FORMAT_A8R8G8B8_UNORM
549 #define PIPE_FORMAT_XRGB8888_UNORM PIPE_FORMAT_X8R8G8B8_UNORM
550 #define PIPE_FORMAT_ABGR8888_UNORM PIPE_FORMAT_A8B8G8R8_UNORM
551 #define PIPE_FORMAT_XBGR8888_UNORM PIPE_FORMAT_X8B8G8R8_UNORM
552 #define PIPE_FORMAT_RGBA8888_SNORM PIPE_FORMAT_R8G8B8A8_SNORM
553 #define PIPE_FORMAT_RGBX8888_SNORM PIPE_FORMAT_R8G8B8X8_SNORM
554 #define PIPE_FORMAT_ABGR8888_SNORM PIPE_FORMAT_A8B8G8R8_SNORM
555 #define PIPE_FORMAT_XBGR8888_SNORM PIPE_FORMAT_X8B8G8R8_SNORM
556 #define PIPE_FORMAT_RGBA8888_SRGB PIPE_FORMAT_R8G8B8A8_SRGB
557 #define PIPE_FORMAT_RGBX8888_SRGB PIPE_FORMAT_R8G8B8X8_SRGB
558 #define PIPE_FORMAT_BGRA8888_SRGB PIPE_FORMAT_B8G8R8A8_SRGB
559 #define PIPE_FORMAT_BGRX8888_SRGB PIPE_FORMAT_B8G8R8X8_SRGB
560 #define PIPE_FORMAT_ARGB8888_SRGB PIPE_FORMAT_A8R8G8B8_SRGB
561 #define PIPE_FORMAT_XRGB8888_SRGB PIPE_FORMAT_X8R8G8B8_SRGB
562 #define PIPE_FORMAT_ABGR8888_SRGB PIPE_FORMAT_A8B8G8R8_SRGB
563 #define PIPE_FORMAT_XBGR8888_SRGB PIPE_FORMAT_X8B8G8R8_SRGB
564 #define PIPE_FORMAT_RGBA8888_USCALED PIPE_FORMAT_R8G8B8A8_USCALED
565 #define PIPE_FORMAT_RGBA8888_SSCALED PIPE_FORMAT_R8G8B8A8_SSCALED
566 #define PIPE_FORMAT_RGBA8888_UINT PIPE_FORMAT_R8G8B8A8_UINT
567 #define PIPE_FORMAT_BGRA8888_UINT PIPE_FORMAT_B8G8R8A8_UINT
568 #define PIPE_FORMAT_ARGB8888_UINT PIPE_FORMAT_A8R8G8B8_UINT
569 #define PIPE_FORMAT_ABGR8888_UINT PIPE_FORMAT_A8B8G8R8_UINT
570 #define PIPE_FORMAT_RGBA8888_SINT PIPE_FORMAT_R8G8B8A8_SINT
571 #define PIPE_FORMAT_RG88_UNORM PIPE_FORMAT_R8G8_UNORM
572 #define PIPE_FORMAT_GR88_UNORM PIPE_FORMAT_G8R8_UNORM
573 #define PIPE_FORMAT_RG88_SNORM PIPE_FORMAT_R8G8_SNORM
574 #define PIPE_FORMAT_GR88_SNORM PIPE_FORMAT_G8R8_SNORM
575 #define PIPE_FORMAT_RG1616_UNORM PIPE_FORMAT_R16G16_UNORM
576 #define PIPE_FORMAT_GR1616_UNORM PIPE_FORMAT_G16R16_UNORM
577 #define PIPE_FORMAT_RG1616_SNORM PIPE_FORMAT_R16G16_SNORM
578 #define PIPE_FORMAT_GR1616_SNORM PIPE_FORMAT_G16R16_SNORM
579 #elif UTIL_ARCH_BIG_ENDIAN
580 #define PIPE_FORMAT_ABGR8888_UNORM PIPE_FORMAT_R8G8B8A8_UNORM
581 #define PIPE_FORMAT_XBGR8888_UNORM PIPE_FORMAT_R8G8B8X8_UNORM
582 #define PIPE_FORMAT_ARGB8888_UNORM PIPE_FORMAT_B8G8R8A8_UNORM
583 #define PIPE_FORMAT_XRGB8888_UNORM PIPE_FORMAT_B8G8R8X8_UNORM
584 #define PIPE_FORMAT_BGRA8888_UNORM PIPE_FORMAT_A8R8G8B8_UNORM
585 #define PIPE_FORMAT_BGRX8888_UNORM PIPE_FORMAT_X8R8G8B8_UNORM
586 #define PIPE_FORMAT_RGBA8888_UNORM PIPE_FORMAT_A8B8G8R8_UNORM
587 #define PIPE_FORMAT_RGBX8888_UNORM PIPE_FORMAT_X8B8G8R8_UNORM
588 #define PIPE_FORMAT_ABGR8888_SNORM PIPE_FORMAT_R8G8B8A8_SNORM
589 #define PIPE_FORMAT_XBGR8888_SNORM PIPE_FORMAT_R8G8B8X8_SNORM
590 #define PIPE_FORMAT_RGBA8888_SNORM PIPE_FORMAT_A8B8G8R8_SNORM
591 #define PIPE_FORMAT_RGBX8888_SNORM PIPE_FORMAT_X8B8G8R8_SNORM
592 #define PIPE_FORMAT_ABGR8888_SRGB PIPE_FORMAT_R8G8B8A8_SRGB
593 #define PIPE_FORMAT_XBGR8888_SRGB PIPE_FORMAT_R8G8B8X8_SRGB
594 #define PIPE_FORMAT_ARGB8888_SRGB PIPE_FORMAT_B8G8R8A8_SRGB
595 #define PIPE_FORMAT_XRGB8888_SRGB PIPE_FORMAT_B8G8R8X8_SRGB
596 #define PIPE_FORMAT_BGRA8888_SRGB PIPE_FORMAT_A8R8G8B8_SRGB
597 #define PIPE_FORMAT_BGRX8888_SRGB PIPE_FORMAT_X8R8G8B8_SRGB
598 #define PIPE_FORMAT_RGBA8888_SRGB PIPE_FORMAT_A8B8G8R8_SRGB
599 #define PIPE_FORMAT_RGBX8888_SRGB PIPE_FORMAT_X8B8G8R8_SRGB
600 #define PIPE_FORMAT_RGBA8888_USCALED PIPE_FORMAT_A8B8G8R8_USCALED
601 #define PIPE_FORMAT_RGBA8888_SSCALED PIPE_FORMAT_A8B8G8R8_SSCALED
602 #define PIPE_FORMAT_RGBA8888_UINT PIPE_FORMAT_A8B8G8R8_UINT
603 #define PIPE_FORMAT_BGRA8888_UINT PIPE_FORMAT_A8R8G8B8_UINT
604 #define PIPE_FORMAT_ARGB8888_UINT PIPE_FORMAT_B8G8R8A8_UINT
605 #define PIPE_FORMAT_ABGR8888_UINT PIPE_FORMAT_R8G8B8A8_UINT
606 #define PIPE_FORMAT_RGBA8888_SINT PIPE_FORMAT_A8B8G8R8_SINT
607 #define PIPE_FORMAT_RG88_UNORM PIPE_FORMAT_G8R8_UNORM
608 #define PIPE_FORMAT_GR88_UNORM PIPE_FORMAT_R8G8_UNORM
609 #define PIPE_FORMAT_RG88_SNORM PIPE_FORMAT_G8R8_SNORM
610 #define PIPE_FORMAT_GR88_SNORM PIPE_FORMAT_R8G8_SNORM
611 #define PIPE_FORMAT_RG1616_UNORM PIPE_FORMAT_G16R16_UNORM
612 #define PIPE_FORMAT_GR1616_UNORM PIPE_FORMAT_R16G16_UNORM
613 #define PIPE_FORMAT_RG1616_SNORM PIPE_FORMAT_G16R16_SNORM
614 #define PIPE_FORMAT_GR1616_SNORM PIPE_FORMAT_R16G16_SNORM
615 #endif
616 
617 enum pipe_video_chroma_format
618 {
619    PIPE_VIDEO_CHROMA_FORMAT_400,
620    PIPE_VIDEO_CHROMA_FORMAT_420,
621    PIPE_VIDEO_CHROMA_FORMAT_422,
622    PIPE_VIDEO_CHROMA_FORMAT_444,
623    PIPE_VIDEO_CHROMA_FORMAT_NONE
624 };
625 
626 static inline enum pipe_video_chroma_format
pipe_format_to_chroma_format(enum pipe_format format)627 pipe_format_to_chroma_format(enum pipe_format format)
628 {
629    switch (format) {
630       case PIPE_FORMAT_NV12:
631       case PIPE_FORMAT_NV21:
632       case PIPE_FORMAT_YV12:
633       case PIPE_FORMAT_IYUV:
634       case PIPE_FORMAT_P010:
635       case PIPE_FORMAT_P012:
636       case PIPE_FORMAT_P016:
637       case PIPE_FORMAT_P030:
638       case PIPE_FORMAT_Y16_U16_V16_420_UNORM:
639          return PIPE_VIDEO_CHROMA_FORMAT_420;
640       case PIPE_FORMAT_UYVY:
641       case PIPE_FORMAT_VYUY:
642       case PIPE_FORMAT_YUYV:
643       case PIPE_FORMAT_YVYU:
644       case PIPE_FORMAT_YV16:
645       case PIPE_FORMAT_Y8_U8_V8_422_UNORM:
646       case PIPE_FORMAT_Y8_U8V8_422_UNORM:
647       case PIPE_FORMAT_Y16_U16_V16_422_UNORM:
648       case PIPE_FORMAT_Y16_U16V16_422_UNORM:
649          return PIPE_VIDEO_CHROMA_FORMAT_422;
650       case PIPE_FORMAT_Y8_U8_V8_444_UNORM:
651       case PIPE_FORMAT_Y16_U16_V16_444_UNORM:
652          return PIPE_VIDEO_CHROMA_FORMAT_444;
653       case PIPE_FORMAT_Y8_400_UNORM:
654          return PIPE_VIDEO_CHROMA_FORMAT_400;
655       default:
656          return PIPE_VIDEO_CHROMA_FORMAT_NONE;
657    }
658 }
659 
660 /**
661  * Texture & format swizzles
662  */
663 enum pipe_swizzle {
664    PIPE_SWIZZLE_X,
665    PIPE_SWIZZLE_Y,
666    PIPE_SWIZZLE_Z,
667    PIPE_SWIZZLE_W,
668    PIPE_SWIZZLE_0,
669    PIPE_SWIZZLE_1,
670    PIPE_SWIZZLE_NONE,
671    PIPE_SWIZZLE_MAX, /**< Number of enums counter (must be last) */
672 };
673 
674 #define PIPE_MASK_R  0x1
675 #define PIPE_MASK_G  0x2
676 #define PIPE_MASK_B  0x4
677 #define PIPE_MASK_A  0x8
678 #define PIPE_MASK_RGBA 0xf
679 #define PIPE_MASK_Z  0x10
680 #define PIPE_MASK_S  0x20
681 #define PIPE_MASK_ZS 0x30
682 #define PIPE_MASK_RGBAZS (PIPE_MASK_RGBA|PIPE_MASK_ZS)
683 
684 union pipe_color_union
685 {
686    float f[4];
687    int i[4];
688    unsigned int ui[4];
689 };
690 
691 #ifdef __cplusplus
692 }
693 #endif
694 
695 #endif /* U_FORMATS_H_ */
696