Some initial RGB and RGBA floating point texture formats.
[mesa.git] / src / mesa / main / texformat.h
1 /**
2 * \file texformat.h
3 * Texture formats definitions.
4 *
5 * \author Gareth Hughes
6 */
7
8 /*
9 * Mesa 3-D graphics library
10 * Version: 5.1
11 *
12 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
13 *
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
20 *
21 * The above copyright notice and this permission notice shall be included
22 * in all copies or substantial portions of the Software.
23 *
24 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
28 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
29 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 */
31
32
33 #ifndef TEXFORMAT_H
34 #define TEXFORMAT_H
35
36 #include "mtypes.h"
37
38
39 /**
40 * Mesa internal texture image types.
41 *
42 * All texture images must be stored in one of these formats.
43 */
44 enum _format {
45 /**
46 * \name Hardware-friendly formats.
47 *
48 * Drivers can override the default formats and convert texture images to
49 * one of these as required. The driver's
50 * dd_function_table::ChooseTextureFormat function will choose one of these
51 * formats. These formats are all little endian, as shown below. They will
52 * be most useful for x86-based PC graphics card drivers.
53 *
54 * \note In the default case, some of these formats will be duplicates of
55 * the generic formats listed below. However, these formats guarantee their
56 * internal component sizes, while GLchan may vary between GLubyte, GLushort
57 * and GLfloat.
58 */
59 /*@{*/
60 /* msb <------ TEXEL BITS -----------> lsb */
61 /* ---- ---- ---- ---- ---- ---- ---- ---- */
62 MESA_FORMAT_RGBA8888, /* RRRR RRRR GGGG GGGG BBBB BBBB AAAA AAAA */
63 MESA_FORMAT_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
64 MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */
65 MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */
66 MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */
67 MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */
68 MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */
69 MESA_FORMAT_RGB332, /* RRRG GGBB */
70 MESA_FORMAT_A8, /* AAAA AAAA */
71 MESA_FORMAT_L8, /* LLLL LLLL */
72 MESA_FORMAT_I8, /* IIII IIII */
73 MESA_FORMAT_CI8, /* CCCC CCCC */
74 MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */
75 MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */
76 /*@}*/
77
78 /**
79 * \name Compressed texture formats.
80 */
81 /*@{*/
82 MESA_FORMAT_RGB_FXT1,
83 MESA_FORMAT_RGBA_FXT1,
84 MESA_FORMAT_RGB_DXT1,
85 MESA_FORMAT_RGBA_DXT1,
86 MESA_FORMAT_RGBA_DXT3,
87 MESA_FORMAT_RGBA_DXT5,
88 /*@}*/
89
90 #if 0
91 /**
92 * \name Upcoming little-endian formats
93 */
94 /*@{*/
95 /* msb <------ TEXEL BITS -----------> lsb */
96 /* ---- ---- ---- ---- ---- ---- ---- ---- */
97 MESA_FORMAT_ABGR8888, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
98 MESA_FORMAT_BGRA8888, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
99 MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */
100 MESA_FORMAT_BGR565, /* BBBB BGGG GGGR RRRR */
101 MESA_FORMAT_BGRA4444, /* BBBB GGGG RRRR AAAA */
102 MESA_FORMAT_BGRA5551, /* BBBB BGGG GGRR RRRA */
103 MESA_FORMAT_LA88, /* LLLL LLLL AAAA AAAA */
104 MESA_FORMAT_BGR233, /* BBGG GRRR */
105 /*@}*/
106 #endif
107
108 /**
109 * \name Generic GLchan-based formats.
110 *
111 * These are the default formats used by the software rasterizer and, unless
112 * the driver overrides the texture image functions, incoming images will be
113 * converted to one of these formats. Components are arrays of GLchan
114 * values, so there will be no big/little endian issues.
115 *
116 * \note Because these are based on the GLchan data type, one cannot assume
117 * 8 bits per channel with these formats. If you require GLubyte channels,
118 * use one of the hardware formats above.
119 */
120 /*@{*/
121 MESA_FORMAT_RGBA,
122 MESA_FORMAT_RGB,
123 MESA_FORMAT_ALPHA,
124 MESA_FORMAT_LUMINANCE,
125 MESA_FORMAT_LUMINANCE_ALPHA,
126 MESA_FORMAT_INTENSITY,
127 MESA_FORMAT_COLOR_INDEX,
128 /*@}*/
129
130 /**
131 * \name Floating point texture formats.
132 */
133 /*@{*/
134 MESA_FORMAT_DEPTH_COMPONENT,
135 MESA_FORMAT_RGBA_FLOAT32,
136 MESA_FORMAT_RGBA_FLOAT16,
137 MESA_FORMAT_RGB_FLOAT32,
138 MESA_FORMAT_RGB_FLOAT16
139 /*@}*/
140 };
141
142
143 extern GLboolean
144 _mesa_is_hardware_tex_format( const struct gl_texture_format *format );
145
146 extern const struct gl_texture_format *
147 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
148 GLenum format, GLenum type );
149
150 extern GLint
151 _mesa_base_compressed_texformat(GLcontext *ctx, GLint intFormat);
152
153
154 /** The default formats, GLchan per component */
155 /*@{*/
156 extern const struct gl_texture_format _mesa_texformat_rgba;
157 extern const struct gl_texture_format _mesa_texformat_rgb;
158 extern const struct gl_texture_format _mesa_texformat_alpha;
159 extern const struct gl_texture_format _mesa_texformat_luminance;
160 extern const struct gl_texture_format _mesa_texformat_luminance_alpha;
161 extern const struct gl_texture_format _mesa_texformat_intensity;
162 extern const struct gl_texture_format _mesa_texformat_color_index;
163 /*@}*/
164
165 /** Floating point texture formats */
166 /*@{*/
167 extern const struct gl_texture_format _mesa_texformat_depth_component;
168 extern const struct gl_texture_format _mesa_texformat_rgba_float32;
169 extern const struct gl_texture_format _mesa_texformat_rgba_float16;
170 extern const struct gl_texture_format _mesa_texformat_rgb_float32;
171 extern const struct gl_texture_format _mesa_texformat_rgb_float16;
172 /*@}*/
173
174 /** \name The hardware-friendly formats */
175 /*@{*/
176 extern const struct gl_texture_format _mesa_texformat_rgba8888;
177 extern const struct gl_texture_format _mesa_texformat_argb8888;
178 extern const struct gl_texture_format _mesa_texformat_rgb888;
179 extern const struct gl_texture_format _mesa_texformat_rgb565;
180 extern const struct gl_texture_format _mesa_texformat_argb4444;
181 extern const struct gl_texture_format _mesa_texformat_argb1555;
182 extern const struct gl_texture_format _mesa_texformat_al88;
183 extern const struct gl_texture_format _mesa_texformat_rgb332;
184 extern const struct gl_texture_format _mesa_texformat_a8;
185 extern const struct gl_texture_format _mesa_texformat_l8;
186 extern const struct gl_texture_format _mesa_texformat_i8;
187 extern const struct gl_texture_format _mesa_texformat_ci8;
188 extern const struct gl_texture_format _mesa_texformat_ycbcr;
189 extern const struct gl_texture_format _mesa_texformat_ycbcr_rev;
190 extern const struct gl_texture_format _mesa_texformat_rgb_fxt1;
191 extern const struct gl_texture_format _mesa_texformat_rgba_fxt1;
192 extern const struct gl_texture_format _mesa_texformat_rgb_dxt1;
193 extern const struct gl_texture_format _mesa_texformat_rgba_dxt1;
194 extern const struct gl_texture_format _mesa_texformat_rgba_dxt3;
195 extern const struct gl_texture_format _mesa_texformat_rgba_dxt5;
196 /*@}*/
197
198 /** \name The null format */
199 /*@{*/
200 extern const struct gl_texture_format _mesa_null_texformat;
201 /*@}*/
202
203 #endif