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
169 /** GLchan-valued formats */
170 /*@{*/
171 extern const struct gl_texture_format _mesa_texformat_rgba;
172 extern const struct gl_texture_format _mesa_texformat_rgb;
173 extern const struct gl_texture_format _mesa_texformat_alpha;
174 extern const struct gl_texture_format _mesa_texformat_luminance;
175 extern const struct gl_texture_format _mesa_texformat_luminance_alpha;
176 extern const struct gl_texture_format _mesa_texformat_intensity;
177 /*@}*/
178
179 #if FEATURE_EXT_texture_sRGB
180 /** sRGB (nonlinear) formats */
181 /*@{*/
182 extern const struct gl_texture_format _mesa_texformat_srgb8;
183 extern const struct gl_texture_format _mesa_texformat_srgba8;
184 extern const struct gl_texture_format _mesa_texformat_sargb8;
185 extern const struct gl_texture_format _mesa_texformat_sl8;
186 extern const struct gl_texture_format _mesa_texformat_sla8;
187 #if FEATURE_texture_s3tc
188 extern const struct gl_texture_format _mesa_texformat_srgb_dxt1;
189 extern const struct gl_texture_format _mesa_texformat_srgba_dxt1;
190 extern const struct gl_texture_format _mesa_texformat_srgba_dxt3;
191 extern const struct gl_texture_format _mesa_texformat_srgba_dxt5;
192 #endif
193 /*@}*/
194 #endif
195
196 /** Floating point texture formats */
197 /*@{*/
198 extern const struct gl_texture_format _mesa_texformat_rgba_float32;
199 extern const struct gl_texture_format _mesa_texformat_rgba_float16;
200 extern const struct gl_texture_format _mesa_texformat_rgb_float32;
201 extern const struct gl_texture_format _mesa_texformat_rgb_float16;
202 extern const struct gl_texture_format _mesa_texformat_alpha_float32;
203 extern const struct gl_texture_format _mesa_texformat_alpha_float16;
204 extern const struct gl_texture_format _mesa_texformat_luminance_float32;
205 extern const struct gl_texture_format _mesa_texformat_luminance_float16;
206 extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float32;
207 extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float16;
208 extern const struct gl_texture_format _mesa_texformat_intensity_float32;
209 extern const struct gl_texture_format _mesa_texformat_intensity_float16;
210 /*@}*/
211
212 /** \name Assorted hardware-friendly formats */
213 /*@{*/
214 extern const struct gl_texture_format _mesa_texformat_rgba8888;
215 extern const struct gl_texture_format _mesa_texformat_rgba8888_rev;
216 extern const struct gl_texture_format _mesa_texformat_argb8888;
217 extern const struct gl_texture_format _mesa_texformat_argb8888_rev;
218 extern const struct gl_texture_format _mesa_texformat_rgb888;
219 extern const struct gl_texture_format _mesa_texformat_bgr888;
220 extern const struct gl_texture_format _mesa_texformat_rgb565;
221 extern const struct gl_texture_format _mesa_texformat_rgb565_rev;
222 extern const struct gl_texture_format _mesa_texformat_rgba4444;
223 extern const struct gl_texture_format _mesa_texformat_argb4444;
224 extern const struct gl_texture_format _mesa_texformat_argb4444_rev;
225 extern const struct gl_texture_format _mesa_texformat_argb1555;
226 extern const struct gl_texture_format _mesa_texformat_argb1555_rev;
227 extern const struct gl_texture_format _mesa_texformat_rgba5551;
228 extern const struct gl_texture_format _mesa_texformat_al88;
229 extern const struct gl_texture_format _mesa_texformat_al88_rev;
230 extern const struct gl_texture_format _mesa_texformat_rgb332;
231 extern const struct gl_texture_format _mesa_texformat_a8;
232 extern const struct gl_texture_format _mesa_texformat_l8;
233 extern const struct gl_texture_format _mesa_texformat_i8;
234 extern const struct gl_texture_format _mesa_texformat_ci8;
235 extern const struct gl_texture_format _mesa_texformat_z24_s8;
236 extern const struct gl_texture_format _mesa_texformat_s8_z24;
237 extern const struct gl_texture_format _mesa_texformat_z16;
238 extern const struct gl_texture_format _mesa_texformat_z32;
239 /*@}*/
240
241 /** \name YCbCr formats */
242 /*@{*/
243 extern const struct gl_texture_format _mesa_texformat_ycbcr;
244 extern const struct gl_texture_format _mesa_texformat_ycbcr_rev;
245 /*@}*/
246
247 /** \name Compressed formats */
248 /*@{*/
249 #if FEATURE_texture_fxt1
250 extern const struct gl_texture_format _mesa_texformat_rgb_fxt1;
251 extern const struct gl_texture_format _mesa_texformat_rgba_fxt1;
252 #endif
253 #if FEATURE_texture_s3tc
254 extern const struct gl_texture_format _mesa_texformat_rgb_dxt1;
255 extern const struct gl_texture_format _mesa_texformat_rgba_dxt1;
256 extern const struct gl_texture_format _mesa_texformat_rgba_dxt3;
257 extern const struct gl_texture_format _mesa_texformat_rgba_dxt5;
258 #endif
259 /*@}*/
260
261 /** \name The null format */
262 /*@{*/
263 extern const struct gl_texture_format _mesa_null_texformat;
264 /*@}*/
265
266
267 extern const struct gl_texture_format *
268 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
269 GLenum format, GLenum type );
270
271
272 extern void
273 _mesa_format_to_type_and_comps(const struct gl_texture_format *format,
274 GLenum *datatype, GLuint *comps);
275
276
277 #endif