Merge remote branch 'origin/master' into radeon-rewrite
[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_RGBA4444, /* RRRR GGGG BBBB AAAA */
75 MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */
76 MESA_FORMAT_ARGB4444_REV, /* GGGG BBBB AAAA RRRR */
77 MESA_FORMAT_RGBA5551, /* RRRR RGGG GGBB BBBA */
78 MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */
79 MESA_FORMAT_ARGB1555_REV, /* GGGB BBBB ARRR RRGG */
80 MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */
81 MESA_FORMAT_AL88_REV, /* LLLL LLLL AAAA AAAA */
82 MESA_FORMAT_RGB332, /* RRRG GGBB */
83 MESA_FORMAT_A8, /* AAAA AAAA */
84 MESA_FORMAT_L8, /* LLLL LLLL */
85 MESA_FORMAT_I8, /* IIII IIII */
86 MESA_FORMAT_CI8, /* CCCC CCCC */
87 MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */
88 MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */
89 MESA_FORMAT_Z24_S8, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */
90 MESA_FORMAT_S8_Z24, /* SSSS SSSS ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
91 MESA_FORMAT_Z16, /* ZZZZ ZZZZ ZZZZ ZZZZ */
92 MESA_FORMAT_Z32, /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
93 /*@}*/
94
95 #if FEATURE_EXT_texture_sRGB
96 /**
97 * \name 8-bit/channel sRGB formats
98 */
99 /*@{*/
100 MESA_FORMAT_SRGB8,
101 MESA_FORMAT_SRGBA8,
102 MESA_FORMAT_SARGB8,
103 MESA_FORMAT_SL8,
104 MESA_FORMAT_SLA8,
105 #if FEATURE_texture_s3tc
106 MESA_FORMAT_SRGB_DXT1,
107 MESA_FORMAT_SRGBA_DXT1,
108 MESA_FORMAT_SRGBA_DXT3,
109 MESA_FORMAT_SRGBA_DXT5,
110 #endif
111 /*@}*/
112 #endif
113
114 /**
115 * \name Compressed texture formats.
116 */
117 /*@{*/
118 #if FEATURE_texture_fxt1
119 MESA_FORMAT_RGB_FXT1,
120 MESA_FORMAT_RGBA_FXT1,
121 #endif
122 #if FEATURE_texture_s3tc
123 MESA_FORMAT_RGB_DXT1,
124 MESA_FORMAT_RGBA_DXT1,
125 MESA_FORMAT_RGBA_DXT3,
126 MESA_FORMAT_RGBA_DXT5,
127 #endif
128 /*@}*/
129
130 /**
131 * \name Generic GLchan-based formats.
132 *
133 * Software-oriented texture formats. Texels are arrays of GLchan
134 * values so there are no byte order issues.
135 *
136 * \note Because these are based on the GLchan data type, one cannot assume
137 * 8 bits per channel with these formats. If you require GLubyte channels,
138 * use one of the hardware formats above.
139 */
140 /*@{*/
141 MESA_FORMAT_RGBA,
142 MESA_FORMAT_RGB,
143 MESA_FORMAT_ALPHA,
144 MESA_FORMAT_LUMINANCE,
145 MESA_FORMAT_LUMINANCE_ALPHA,
146 MESA_FORMAT_INTENSITY,
147 /*@}*/
148
149 /**
150 * \name Floating point texture formats.
151 */
152 /*@{*/
153 MESA_FORMAT_RGBA_FLOAT32,
154 MESA_FORMAT_RGBA_FLOAT16,
155 MESA_FORMAT_RGB_FLOAT32,
156 MESA_FORMAT_RGB_FLOAT16,
157 MESA_FORMAT_ALPHA_FLOAT32,
158 MESA_FORMAT_ALPHA_FLOAT16,
159 MESA_FORMAT_LUMINANCE_FLOAT32,
160 MESA_FORMAT_LUMINANCE_FLOAT16,
161 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
162 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
163 MESA_FORMAT_INTENSITY_FLOAT32,
164 MESA_FORMAT_INTENSITY_FLOAT16,
165 /*@}*/
166
167 /**
168 * \name Signed fixed point texture formats.
169 */
170 /*@{*/
171 MESA_FORMAT_DUDV8,
172 MESA_FORMAT_SIGNED_RGBA8888,
173 MESA_FORMAT_SIGNED_RGBA8888_REV
174 /*@}*/
175 };
176
177
178 /** GLchan-valued formats */
179 /*@{*/
180 extern const struct gl_texture_format _mesa_texformat_rgba;
181 extern const struct gl_texture_format _mesa_texformat_rgb;
182 extern const struct gl_texture_format _mesa_texformat_alpha;
183 extern const struct gl_texture_format _mesa_texformat_luminance;
184 extern const struct gl_texture_format _mesa_texformat_luminance_alpha;
185 extern const struct gl_texture_format _mesa_texformat_intensity;
186 /*@}*/
187
188 #if FEATURE_EXT_texture_sRGB
189 /** sRGB (nonlinear) formats */
190 /*@{*/
191 extern const struct gl_texture_format _mesa_texformat_srgb8;
192 extern const struct gl_texture_format _mesa_texformat_srgba8;
193 extern const struct gl_texture_format _mesa_texformat_sargb8;
194 extern const struct gl_texture_format _mesa_texformat_sl8;
195 extern const struct gl_texture_format _mesa_texformat_sla8;
196 #if FEATURE_texture_s3tc
197 extern const struct gl_texture_format _mesa_texformat_srgb_dxt1;
198 extern const struct gl_texture_format _mesa_texformat_srgba_dxt1;
199 extern const struct gl_texture_format _mesa_texformat_srgba_dxt3;
200 extern const struct gl_texture_format _mesa_texformat_srgba_dxt5;
201 #endif
202 /*@}*/
203 #endif
204
205 /** Floating point texture formats */
206 /*@{*/
207 extern const struct gl_texture_format _mesa_texformat_rgba_float32;
208 extern const struct gl_texture_format _mesa_texformat_rgba_float16;
209 extern const struct gl_texture_format _mesa_texformat_rgb_float32;
210 extern const struct gl_texture_format _mesa_texformat_rgb_float16;
211 extern const struct gl_texture_format _mesa_texformat_alpha_float32;
212 extern const struct gl_texture_format _mesa_texformat_alpha_float16;
213 extern const struct gl_texture_format _mesa_texformat_luminance_float32;
214 extern const struct gl_texture_format _mesa_texformat_luminance_float16;
215 extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float32;
216 extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float16;
217 extern const struct gl_texture_format _mesa_texformat_intensity_float32;
218 extern const struct gl_texture_format _mesa_texformat_intensity_float16;
219 /*@}*/
220
221 /** Signed fixed point texture formats */
222 /*@{*/
223 extern const struct gl_texture_format _mesa_texformat_dudv8;
224 extern const struct gl_texture_format _mesa_texformat_signed_rgba8888;
225 extern const struct gl_texture_format _mesa_texformat_signed_rgba8888_rev;
226 /*@}*/
227
228 /** \name Assorted hardware-friendly formats */
229 /*@{*/
230 extern const struct gl_texture_format _mesa_texformat_rgba8888;
231 extern const struct gl_texture_format _mesa_texformat_rgba8888_rev;
232 extern const struct gl_texture_format _mesa_texformat_argb8888;
233 extern const struct gl_texture_format _mesa_texformat_argb8888_rev;
234 extern const struct gl_texture_format _mesa_texformat_rgb888;
235 extern const struct gl_texture_format _mesa_texformat_bgr888;
236 extern const struct gl_texture_format _mesa_texformat_rgb565;
237 extern const struct gl_texture_format _mesa_texformat_rgb565_rev;
238 extern const struct gl_texture_format _mesa_texformat_rgba4444;
239 extern const struct gl_texture_format _mesa_texformat_argb4444;
240 extern const struct gl_texture_format _mesa_texformat_argb4444_rev;
241 extern const struct gl_texture_format _mesa_texformat_argb1555;
242 extern const struct gl_texture_format _mesa_texformat_argb1555_rev;
243 extern const struct gl_texture_format _mesa_texformat_rgba5551;
244 extern const struct gl_texture_format _mesa_texformat_al88;
245 extern const struct gl_texture_format _mesa_texformat_al88_rev;
246 extern const struct gl_texture_format _mesa_texformat_rgb332;
247 extern const struct gl_texture_format _mesa_texformat_a8;
248 extern const struct gl_texture_format _mesa_texformat_l8;
249 extern const struct gl_texture_format _mesa_texformat_i8;
250 extern const struct gl_texture_format _mesa_texformat_ci8;
251 extern const struct gl_texture_format _mesa_texformat_z24_s8;
252 extern const struct gl_texture_format _mesa_texformat_s8_z24;
253 extern const struct gl_texture_format _mesa_texformat_z16;
254 extern const struct gl_texture_format _mesa_texformat_z32;
255 /*@}*/
256
257 /** \name YCbCr formats */
258 /*@{*/
259 extern const struct gl_texture_format _mesa_texformat_ycbcr;
260 extern const struct gl_texture_format _mesa_texformat_ycbcr_rev;
261 /*@}*/
262
263 /** \name Compressed formats */
264 /*@{*/
265 #if FEATURE_texture_fxt1
266 extern const struct gl_texture_format _mesa_texformat_rgb_fxt1;
267 extern const struct gl_texture_format _mesa_texformat_rgba_fxt1;
268 #endif
269 #if FEATURE_texture_s3tc
270 extern const struct gl_texture_format _mesa_texformat_rgb_dxt1;
271 extern const struct gl_texture_format _mesa_texformat_rgba_dxt1;
272 extern const struct gl_texture_format _mesa_texformat_rgba_dxt3;
273 extern const struct gl_texture_format _mesa_texformat_rgba_dxt5;
274 #endif
275 /*@}*/
276
277 /** \name The null format */
278 /*@{*/
279 extern const struct gl_texture_format _mesa_null_texformat;
280 /*@}*/
281
282
283 extern const struct gl_texture_format *
284 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
285 GLenum format, GLenum type );
286
287
288 extern void
289 _mesa_format_to_type_and_comps(const struct gl_texture_format *format,
290 GLenum *datatype, GLuint *comps);
291
292
293 #endif