New glTexImage code.
[mesa.git] / src / mesa / main / texformat.h
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.1
4 *
5 * Copyright (C) 1999-2004 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 #define NEWTEXSTORE 1
38
39
40 #include "mtypes.h"
41
42
43 /**
44 * Mesa internal texture image formats.
45 * All texture images are stored in one of these formats.
46 *
47 * NOTE: when you add a new format, be sure to update the do_row()
48 * function in texstore.c used for auto mipmap generation.
49 */
50 enum _format {
51 /**
52 * \name Hardware-friendly formats.
53 *
54 * Drivers can override the default formats and convert texture images to
55 * one of these as required. The driver's
56 * dd_function_table::ChooseTextureFormat function will choose one of these
57 * formats. These formats are all little endian, as shown below. They will
58 * be most useful for x86-based PC graphics card drivers.
59 *
60 * \note In the default case, some of these formats will be duplicates of
61 * the generic formats listed below. However, these formats guarantee their
62 * internal component sizes, while GLchan may vary between GLubyte, GLushort
63 * and GLfloat.
64 */
65 /*@{*/
66 /* msb <------ TEXEL BITS -----------> lsb */
67 /* ---- ---- ---- ---- ---- ---- ---- ---- */
68 MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
69 MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
70 MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */
71 MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */
72 MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */
73 MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */
74 MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */
75 MESA_FORMAT_RGB332, /* RRRG GGBB */
76 MESA_FORMAT_A8, /* AAAA AAAA */
77 MESA_FORMAT_L8, /* LLLL LLLL */
78 MESA_FORMAT_I8, /* IIII IIII */
79 MESA_FORMAT_CI8, /* CCCC CCCC */
80 MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */
81 MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */
82 /*@}*/
83
84 /**
85 * \name Compressed texture formats.
86 */
87 /*@{*/
88 MESA_FORMAT_RGB_FXT1,
89 MESA_FORMAT_RGBA_FXT1,
90 MESA_FORMAT_RGB_DXT1,
91 MESA_FORMAT_RGBA_DXT1,
92 MESA_FORMAT_RGBA_DXT3,
93 MESA_FORMAT_RGBA_DXT5,
94 /*@}*/
95
96 #if 0
97 /**
98 * \name Upcoming little-endian formats
99 */
100 /*@{*/
101 /* msb <------ TEXEL BITS -----------> lsb */
102 /* ---- ---- ---- ---- ---- ---- ---- ---- */
103 MESA_FORMAT_ABGR8888, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
104 MESA_FORMAT_BGRA8888, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
105 MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */
106 MESA_FORMAT_BGR565, /* BBBB BGGG GGGR RRRR */
107 MESA_FORMAT_BGRA4444, /* BBBB GGGG RRRR AAAA */
108 MESA_FORMAT_BGRA5551, /* BBBB BGGG GGRR RRRA */
109 MESA_FORMAT_LA88, /* LLLL LLLL AAAA AAAA */
110 MESA_FORMAT_BGR233, /* BBGG GRRR */
111 /*@}*/
112 #endif
113
114 /**
115 * \name Generic GLchan-based formats.
116 *
117 * Software-oriented texture formats. Texels are arrays of GLchan
118 * values so there will be no big/little endian issues.
119 *
120 * \note Because these are based on the GLchan data type, one cannot assume
121 * 8 bits per channel with these formats. If you require GLubyte channels,
122 * use one of the hardware formats above.
123 */
124 /*@{*/
125 MESA_FORMAT_RGBA,
126 MESA_FORMAT_RGB,
127 MESA_FORMAT_ALPHA,
128 MESA_FORMAT_LUMINANCE,
129 MESA_FORMAT_LUMINANCE_ALPHA,
130 MESA_FORMAT_INTENSITY,
131 MESA_FORMAT_COLOR_INDEX,
132 /*@}*/
133
134 /**
135 * Depth textures
136 */
137 /*@{*/
138 MESA_FORMAT_DEPTH_COMPONENT_FLOAT32,
139 MESA_FORMAT_DEPTH_COMPONENT16,
140 /*@}*/
141
142 /**
143 * \name Floating point texture formats.
144 */
145 /*@{*/
146 MESA_FORMAT_RGBA_FLOAT32,
147 MESA_FORMAT_RGBA_FLOAT16,
148 MESA_FORMAT_RGB_FLOAT32,
149 MESA_FORMAT_RGB_FLOAT16,
150 MESA_FORMAT_ALPHA_FLOAT32,
151 MESA_FORMAT_ALPHA_FLOAT16,
152 MESA_FORMAT_LUMINANCE_FLOAT32,
153 MESA_FORMAT_LUMINANCE_FLOAT16,
154 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
155 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
156 MESA_FORMAT_INTENSITY_FLOAT32,
157 MESA_FORMAT_INTENSITY_FLOAT16
158 /*@}*/
159 };
160
161
162 /** The default formats, GLchan per component */
163 /*@{*/
164 extern const struct gl_texture_format _mesa_texformat_rgba;
165 extern const struct gl_texture_format _mesa_texformat_rgb;
166 extern const struct gl_texture_format _mesa_texformat_alpha;
167 extern const struct gl_texture_format _mesa_texformat_luminance;
168 extern const struct gl_texture_format _mesa_texformat_luminance_alpha;
169 extern const struct gl_texture_format _mesa_texformat_intensity;
170 extern const struct gl_texture_format _mesa_texformat_color_index;
171 /*@}*/
172
173 /** Depth textures */
174 /*@{*/
175 extern const struct gl_texture_format _mesa_texformat_depth_component_float32;
176 extern const struct gl_texture_format _mesa_texformat_depth_component16;
177 /*@}*/
178
179 /** Floating point texture formats */
180 /*@{*/
181 extern const struct gl_texture_format _mesa_texformat_rgba_float32;
182 extern const struct gl_texture_format _mesa_texformat_rgba_float16;
183 extern const struct gl_texture_format _mesa_texformat_rgb_float32;
184 extern const struct gl_texture_format _mesa_texformat_rgb_float16;
185 extern const struct gl_texture_format _mesa_texformat_alpha_float32;
186 extern const struct gl_texture_format _mesa_texformat_alpha_float16;
187 extern const struct gl_texture_format _mesa_texformat_luminance_float32;
188 extern const struct gl_texture_format _mesa_texformat_luminance_float16;
189 extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float32;
190 extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float16;
191 extern const struct gl_texture_format _mesa_texformat_intensity_float32;
192 extern const struct gl_texture_format _mesa_texformat_intensity_float16;
193 /*@}*/
194
195 /** \name The hardware-friendly formats */
196 /*@{*/
197 extern const struct gl_texture_format _mesa_texformat_rgba8888;
198 extern const struct gl_texture_format _mesa_texformat_argb8888;
199 extern const struct gl_texture_format _mesa_texformat_rgb888;
200 extern const struct gl_texture_format _mesa_texformat_rgb565;
201 extern const struct gl_texture_format _mesa_texformat_argb4444;
202 extern const struct gl_texture_format _mesa_texformat_argb1555;
203 extern const struct gl_texture_format _mesa_texformat_al88;
204 extern const struct gl_texture_format _mesa_texformat_rgb332;
205 extern const struct gl_texture_format _mesa_texformat_a8;
206 extern const struct gl_texture_format _mesa_texformat_l8;
207 extern const struct gl_texture_format _mesa_texformat_i8;
208 extern const struct gl_texture_format _mesa_texformat_ci8;
209 extern const struct gl_texture_format _mesa_texformat_ycbcr;
210 extern const struct gl_texture_format _mesa_texformat_ycbcr_rev;
211 extern const struct gl_texture_format _mesa_texformat_rgb_fxt1;
212 extern const struct gl_texture_format _mesa_texformat_rgba_fxt1;
213 extern const struct gl_texture_format _mesa_texformat_rgb_dxt1;
214 extern const struct gl_texture_format _mesa_texformat_rgba_dxt1;
215 extern const struct gl_texture_format _mesa_texformat_rgba_dxt3;
216 extern const struct gl_texture_format _mesa_texformat_rgba_dxt5;
217 /*@}*/
218
219 /** \name The null format */
220 /*@{*/
221 extern const struct gl_texture_format _mesa_null_texformat;
222 /*@}*/
223
224
225 #if !NEWTEXSTORE
226 extern GLboolean
227 _mesa_is_hardware_tex_format( const struct gl_texture_format *format );
228 #endif
229
230 extern const struct gl_texture_format *
231 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
232 GLenum format, GLenum type );
233
234 extern GLint
235 _mesa_base_compressed_texformat(GLcontext *ctx, GLint intFormat);
236
237
238 #endif