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