formats.h revision e71a9042cb5e046072d2ea8fbd22a01de625bf8a
1/*
2 * Mesa 3-D graphics library
3 * Version:  7.7
4 *
5 * Copyright (C) 1999-2008  Brian Paul   All Rights Reserved.
6 * Copyright (c) 2008-2009  VMware, Inc.
7 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR 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
38
39
40/**
41 * Mesa texture/renderbuffer image formats.
42 */
43typedef enum
44{
45   MESA_FORMAT_NONE = 0,
46
47   /**
48    * \name Basic hardware formats
49    */
50   /*@{*/
51				/* msb <------ TEXEL BITS -----------> lsb */
52				/* ---- ---- ---- ---- ---- ---- ---- ---- */
53   MESA_FORMAT_RGBA8888,	/* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
54   MESA_FORMAT_RGBA8888_REV,	/* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
55   MESA_FORMAT_ARGB8888,	/* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
56   MESA_FORMAT_ARGB8888_REV,	/* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
57   MESA_FORMAT_XRGB8888,	/* xxxx xxxx RRRR RRRR GGGG GGGG BBBB BBBB */
58   MESA_FORMAT_XRGB8888_REV,	/* BBBB BBBB GGGG GGGG RRRR RRRR xxxx xxxx */
59   MESA_FORMAT_RGB888,		/*           RRRR RRRR GGGG GGGG BBBB BBBB */
60   MESA_FORMAT_BGR888,		/*           BBBB BBBB GGGG GGGG RRRR RRRR */
61   MESA_FORMAT_RGB565,		/*                     RRRR RGGG GGGB BBBB */
62   MESA_FORMAT_RGB565_REV,	/*                     GGGB BBBB RRRR RGGG */
63   MESA_FORMAT_ARGB4444,	/*                     AAAA RRRR GGGG BBBB */
64   MESA_FORMAT_ARGB4444_REV,	/*                     GGGG BBBB AAAA RRRR */
65   MESA_FORMAT_RGBA5551,        /*                     RRRR RGGG GGBB BBBA */
66   MESA_FORMAT_ARGB1555,	/*                     ARRR RRGG GGGB BBBB */
67   MESA_FORMAT_ARGB1555_REV,	/*                     GGGB BBBB ARRR RRGG */
68   MESA_FORMAT_AL88,		/*                     AAAA AAAA LLLL LLLL */
69   MESA_FORMAT_AL88_REV,	/*                     LLLL LLLL AAAA AAAA */
70   MESA_FORMAT_AL1616,          /* AAAA AAAA AAAA AAAA LLLL LLLL LLLL LLLL */
71   MESA_FORMAT_AL1616_REV,      /* LLLL LLLL LLLL LLLL AAAA AAAA AAAA AAAA */
72   MESA_FORMAT_RGB332,		/*                               RRRG GGBB */
73   MESA_FORMAT_A8,		/*                               AAAA AAAA */
74   MESA_FORMAT_L8,		/*                               LLLL LLLL */
75   MESA_FORMAT_I8,		/*                               IIII IIII */
76   MESA_FORMAT_CI8,		/*                               CCCC CCCC */
77   MESA_FORMAT_YCBCR,		/*                     YYYY YYYY UorV UorV */
78   MESA_FORMAT_YCBCR_REV,	/*                     UorV UorV YYYY YYYY */
79   MESA_FORMAT_Z24_S8,          /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */
80   MESA_FORMAT_S8_Z24,          /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
81   MESA_FORMAT_Z16,             /*                     ZZZZ ZZZZ ZZZZ ZZZZ */
82   MESA_FORMAT_X8_Z24,          /* xxxx xxxx ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
83   MESA_FORMAT_Z24_X8,          /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ xxxx xxxx */
84   MESA_FORMAT_Z32,             /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
85   MESA_FORMAT_S8,              /*                               SSSS SSSS */
86   /*@}*/
87
88   /**
89    * \name 8-bit/channel sRGB formats
90    */
91   /*@{*/
92   MESA_FORMAT_SRGB8,
93   MESA_FORMAT_SRGBA8,
94   MESA_FORMAT_SARGB8,
95   MESA_FORMAT_SL8,
96   MESA_FORMAT_SLA8,
97   MESA_FORMAT_SRGB_DXT1,
98   MESA_FORMAT_SRGBA_DXT1,
99   MESA_FORMAT_SRGBA_DXT3,
100   MESA_FORMAT_SRGBA_DXT5,
101   /*@}*/
102
103   /**
104    * \name Compressed texture formats.
105    */
106   /*@{*/
107   MESA_FORMAT_RGB_FXT1,
108   MESA_FORMAT_RGBA_FXT1,
109   MESA_FORMAT_RGB_DXT1,
110   MESA_FORMAT_RGBA_DXT1,
111   MESA_FORMAT_RGBA_DXT3,
112   MESA_FORMAT_RGBA_DXT5,
113   /*@}*/
114
115   /**
116    * \name Floating point texture formats.
117    */
118   /*@{*/
119   MESA_FORMAT_RGBA_FLOAT32,
120   MESA_FORMAT_RGBA_FLOAT16,
121   MESA_FORMAT_RGB_FLOAT32,
122   MESA_FORMAT_RGB_FLOAT16,
123   MESA_FORMAT_ALPHA_FLOAT32,
124   MESA_FORMAT_ALPHA_FLOAT16,
125   MESA_FORMAT_LUMINANCE_FLOAT32,
126   MESA_FORMAT_LUMINANCE_FLOAT16,
127   MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
128   MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
129   MESA_FORMAT_INTENSITY_FLOAT32,
130   MESA_FORMAT_INTENSITY_FLOAT16,
131   /*@}*/
132
133   /**
134    * \name Non-normalized signed integer formats.
135    * XXX Note: these are just stand-ins for some better hardware
136    * formats TBD such as BGRA or ARGB.
137    */
138   MESA_FORMAT_RGBA_INT8,
139   MESA_FORMAT_RGBA_INT16,
140   MESA_FORMAT_RGBA_INT32,
141
142   /**
143    * \name Non-normalized unsigned integer formats.
144    */
145   MESA_FORMAT_RGBA_UINT8,
146   MESA_FORMAT_RGBA_UINT16,
147   MESA_FORMAT_RGBA_UINT32,
148
149                                  /* msb <------ TEXEL BITS -----------> lsb */
150                                  /* ---- ---- ---- ---- ---- ---- ---- ---- */
151   /**
152    * \name Signed fixed point texture formats.
153    */
154   /*@{*/
155   MESA_FORMAT_DUDV8,             /*                     DUDU DUDU DVDV DVDV */
156   MESA_FORMAT_SIGNED_R8,         /*                               RRRR RRRR */
157   MESA_FORMAT_SIGNED_RG88,       /*                     RRRR RRRR GGGG GGGG */
158   MESA_FORMAT_SIGNED_RGBX8888,   /* RRRR RRRR GGGG GGGG BBBB BBBB xxxx xxxx */
159   MESA_FORMAT_SIGNED_RGBA8888,   /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
160   MESA_FORMAT_SIGNED_RGBA8888_REV,/*AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
161   MESA_FORMAT_SIGNED_R_16,       /* ushort[0]=R */
162   MESA_FORMAT_SIGNED_RG_16,      /* ushort[0]=R, ushort[1]=G */
163   MESA_FORMAT_SIGNED_RGB_16,     /* ushort[0]=R, ushort[1]=G, ushort[2]=B */
164   MESA_FORMAT_SIGNED_RGBA_16,    /* ... */
165   MESA_FORMAT_RGBA_16,           /* ... */
166   /*@}*/
167
168   MESA_FORMAT_COUNT
169} gl_format;
170
171
172extern const char *
173_mesa_get_format_name(gl_format format);
174
175extern GLuint
176_mesa_get_format_bytes(gl_format format);
177
178extern GLint
179_mesa_get_format_bits(gl_format format, GLenum pname);
180
181extern GLenum
182_mesa_get_format_datatype(gl_format format);
183
184extern GLenum
185_mesa_get_format_base_format(gl_format format);
186
187extern void
188_mesa_get_format_block_size(gl_format format, GLuint *bw, GLuint *bh);
189
190extern GLboolean
191_mesa_is_format_compressed(gl_format format);
192
193extern GLboolean
194_mesa_is_format_packed_depth_stencil(gl_format format);
195
196extern GLenum
197_mesa_get_format_color_encoding(gl_format format);
198
199extern GLuint
200_mesa_format_image_size(gl_format format, GLsizei width,
201                        GLsizei height, GLsizei depth);
202
203extern GLint
204_mesa_format_row_stride(gl_format format, GLsizei width);
205
206extern void
207_mesa_format_to_type_and_comps(gl_format format,
208                               GLenum *datatype, GLuint *comps);
209
210extern void
211_mesa_test_formats(void);
212
213#endif /* FORMATS_H */
214