Merge commit 'origin/gallium-0.1' into gallium-0.2
[mesa.git] / src / mesa / main / texformat.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5.1
4 *
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 * Copyright (c) 2008 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 /**
28 * \file texformat.h
29 * Texture formats definitions.
30 *
31 * \author Gareth Hughes
32 */
33
34
35 #ifndef TEXFORMAT_H
36 #define TEXFORMAT_H
37
38
39 #include "mtypes.h"
40
41
42 /**
43 * Mesa internal texture image formats.
44 * All texture images are stored in one of these formats.
45 *
46 * NOTE: when you add a new format, be sure to update the do_row()
47 * function in texstore.c used for auto mipmap generation.
48 */
49 enum _format {
50 /**
51 * \name Hardware-friendly formats.
52 *
53 * Drivers can override the default formats and convert texture images to
54 * one of these as required. The driver's
55 * dd_function_table::ChooseTextureFormat function will choose one of these
56 * formats.
57 *
58 * \note In the default case, some of these formats will be duplicates of
59 * the generic formats listed below. However, these formats guarantee their
60 * internal component sizes, while GLchan may vary between GLubyte, GLushort
61 * and GLfloat.
62 */
63 /*@{*/
64 /* msb <------ TEXEL BITS -----------> lsb */
65 /* ---- ---- ---- ---- ---- ---- ---- ---- */
66 MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
67 MESA_FORMAT_RGBA8888_REV, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
68 MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
69 MESA_FORMAT_ARGB8888_REV, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
70 MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */
71 MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */
72 MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */
73 MESA_FORMAT_RGB565_REV, /* GGGB BBBB RRRR RGGG */
74 MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */
75 MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */
76 MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */
77 MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */
78 MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */
79 MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */
80 MESA_FORMAT_RGB332, /* RRRG GGBB */
81 MESA_FORMAT_A8, /* AAAA AAAA */
82 MESA_FORMAT_L8, /* LLLL LLLL */
83 MESA_FORMAT_I8, /* IIII IIII */
84 MESA_FORMAT_CI8, /* CCCC CCCC */
85 MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */
86 MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */
87 MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */
88 MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
89 MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */
90 MESA_FORMAT_Z32, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
91 /*@}*/
92
93 #if FEATURE_EXT_texture_sRGB
94 /**
95 * \name 8-bit/channel sRGB formats
96 */
97 /*@{*/
98 MESA_FORMAT_SRGB8,
99 MESA_FORMAT_SRGBA8,
100 MESA_FORMAT_SARGB8,
101 MESA_FORMAT_SL8,
102 MESA_FORMAT_SLA8,
103 #if FEATURE_texture_s3tc
104 MESA_FORMAT_SRGB_DXT1,
105 MESA_FORMAT_SRGBA_DXT1,
106 MESA_FORMAT_SRGBA_DXT3,
107 MESA_FORMAT_SRGBA_DXT5,
108 #endif
109 /*@}*/
110 #endif
111
112 /**
113 * \name Compressed texture formats.
114 */
115 /*@{*/
116 #if FEATURE_texture_fxt1
117 MESA_FORMAT_RGB_FXT1,
118 MESA_FORMAT_RGBA_FXT1,
119 #endif
120 #if FEATURE_texture_s3tc
121 MESA_FORMAT_RGB_DXT1,
122 MESA_FORMAT_RGBA_DXT1,
123 MESA_FORMAT_RGBA_DXT3,
124 MESA_FORMAT_RGBA_DXT5,
125 #endif
126 /*@}*/
127
128 /**
129 * \name Generic GLchan-based formats.
130 *
131 * Software-oriented texture formats. Texels are arrays of GLchan
132 * values so there are no byte order issues.
133 *
134 * \note Because these are based on the GLchan data type, one cannot assume
135 * 8 bits per channel with these formats. If you require GLubyte channels,
136 * use one of the hardware formats above.
137 */
138 /*@{*/
139 MESA_FORMAT_RGBA,
140 MESA_FORMAT_RGB,
141 MESA_FORMAT_ALPHA,
142 MESA_FORMAT_LUMINANCE,
143 MESA_FORMAT_LUMINANCE_ALPHA,
144 MESA_FORMAT_INTENSITY,
145 /*@}*/
146
147 /**
148 * \name Floating point texture formats.
149 */
150 /*@{*/
151 MESA_FORMAT_RGBA_FLOAT32,
152 MESA_FORMAT_RGBA_FLOAT16,
153 MESA_FORMAT_RGB_FLOAT32,
154 MESA_FORMAT_RGB_FLOAT16,
155 MESA_FORMAT_ALPHA_FLOAT32,
156 MESA_FORMAT_ALPHA_FLOAT16,
157 MESA_FORMAT_LUMINANCE_FLOAT32,
158 MESA_FORMAT_LUMINANCE_FLOAT16,
159 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
160 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
161 MESA_FORMAT_INTENSITY_FLOAT32,
162 MESA_FORMAT_INTENSITY_FLOAT16
163 /*@}*/
164 };
165
166
167 /** GLchan-valued formats */
168 /*@{*/
169 extern const struct gl_texture_format _mesa_texformat_rgba;
170 extern const struct gl_texture_format _mesa_texformat_rgb;
171 extern const struct gl_texture_format _mesa_texformat_alpha;
172 extern const struct gl_texture_format _mesa_texformat_luminance;
173 extern const struct gl_texture_format _mesa_texformat_luminance_alpha;
174 extern const struct gl_texture_format _mesa_texformat_intensity;
175 /*@}*/
176
177 #if FEATURE_EXT_texture_sRGB
178 /** sRGB (nonlinear) formats */
179 /*@{*/
180 extern const struct gl_texture_format _mesa_texformat_srgb8;
181 extern const struct gl_texture_format _mesa_texformat_srgba8;
182 extern const struct gl_texture_format _mesa_texformat_sargb8;
183 extern const struct gl_texture_format _mesa_texformat_sl8;
184 extern const struct gl_texture_format _mesa_texformat_sla8;
185 #if FEATURE_texture_s3tc
186 extern const struct gl_texture_format _mesa_texformat_srgb_dxt1;
187 extern const struct gl_texture_format _mesa_texformat_srgba_dxt1;
188 extern const struct gl_texture_format _mesa_texformat_srgba_dxt3;
189 extern const struct gl_texture_format _mesa_texformat_srgba_dxt5;
190 #endif
191 /*@}*/
192 #endif
193
194 /** Floating point texture formats */
195 /*@{*/
196 extern const struct gl_texture_format _mesa_texformat_rgba_float32;
197 extern const struct gl_texture_format _mesa_texformat_rgba_float16;
198 extern const struct gl_texture_format _mesa_texformat_rgb_float32;
199 extern const struct gl_texture_format _mesa_texformat_rgb_float16;
200 extern const struct gl_texture_format _mesa_texformat_alpha_float32;
201 extern const struct gl_texture_format _mesa_texformat_alpha_float16;
202 extern const struct gl_texture_format _mesa_texformat_luminance_float32;
203 extern const struct gl_texture_format _mesa_texformat_luminance_float16;
204 extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float32;
205 extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float16;
206 extern const struct gl_texture_format _mesa_texformat_intensity_float32;
207 extern const struct gl_texture_format _mesa_texformat_intensity_float16;
208 /*@}*/
209
210 /** \name Assorted hardware-friendly formats */
211 /*@{*/
212 extern const struct gl_texture_format _mesa_texformat_rgba8888;
213 extern const struct gl_texture_format _mesa_texformat_rgba8888_rev;
214 extern const struct gl_texture_format _mesa_texformat_argb8888;
215 extern const struct gl_texture_format _mesa_texformat_argb8888_rev;
216 extern const struct gl_texture_format _mesa_texformat_rgb888;
217 extern const struct gl_texture_format _mesa_texformat_bgr888;
218 extern const struct gl_texture_format _mesa_texformat_rgb565;
219 extern const struct gl_texture_format _mesa_texformat_rgb565_rev;
220 extern const struct gl_texture_format _mesa_texformat_argb4444;
221 extern const struct gl_texture_format _mesa_texformat_argb4444_rev;
222 extern const struct gl_texture_format _mesa_texformat_argb1555;
223 extern const struct gl_texture_format _mesa_texformat_argb1555_rev;
224 extern const struct gl_texture_format _mesa_texformat_al88;
225 extern const struct gl_texture_format _mesa_texformat_al88_rev;
226 extern const struct gl_texture_format _mesa_texformat_rgb332;
227 extern const struct gl_texture_format _mesa_texformat_a8;
228 extern const struct gl_texture_format _mesa_texformat_l8;
229 extern const struct gl_texture_format _mesa_texformat_i8;
230 extern const struct gl_texture_format _mesa_texformat_ci8;
231 extern const struct gl_texture_format _mesa_texformat_z24_s8;
232 extern const struct gl_texture_format _mesa_texformat_s8_z24;
233 extern const struct gl_texture_format _mesa_texformat_z16;
234 extern const struct gl_texture_format _mesa_texformat_z32;
235 /*@}*/
236
237 /** \name YCbCr formats */
238 /*@{*/
239 extern const struct gl_texture_format _mesa_texformat_ycbcr;
240 extern const struct gl_texture_format _mesa_texformat_ycbcr_rev;
241 /*@}*/
242
243 /** \name Compressed formats */
244 /*@{*/
245 #if FEATURE_texture_fxt1
246 extern const struct gl_texture_format _mesa_texformat_rgb_fxt1;
247 extern const struct gl_texture_format _mesa_texformat_rgba_fxt1;
248 #endif
249 #if FEATURE_texture_s3tc
250 extern const struct gl_texture_format _mesa_texformat_rgb_dxt1;
251 extern const struct gl_texture_format _mesa_texformat_rgba_dxt1;
252 extern const struct gl_texture_format _mesa_texformat_rgba_dxt3;
253 extern const struct gl_texture_format _mesa_texformat_rgba_dxt5;
254 #endif
255 /*@}*/
256
257 /** \name The null format */
258 /*@{*/
259 extern const struct gl_texture_format _mesa_null_texformat;
260 /*@}*/
261
262
263 extern const struct gl_texture_format *
264 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
265 GLenum format, GLenum type );
266
267
268 extern void
269 _mesa_format_to_type_and_comps(const struct gl_texture_format *format,
270 GLenum *datatype, GLuint *comps);
271
272
273 #endif