init secondary color to (0,0,0,1). remove some redundant initializations.
[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 * NOTE: when you add a new format, be sure to update the do_row()
45 * function in texstore.c used for auto mipmap generation.
46 */
47 enum _format {
48 /**
49 * \name Hardware-friendly formats.
50 *
51 * Drivers can override the default formats and convert texture images to
52 * one of these as required. The driver's
53 * dd_function_table::ChooseTextureFormat function will choose one of these
54 * formats. These formats are all little endian, as shown below. They will
55 * be most useful for x86-based PC graphics card drivers.
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_ARGB8888, /* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
67 MESA_FORMAT_RGB888, /* RRRR RRRR GGGG GGGG BBBB BBBB */
68 MESA_FORMAT_RGB565, /* RRRR RGGG GGGB BBBB */
69 MESA_FORMAT_ARGB4444, /* AAAA RRRR GGGG BBBB */
70 MESA_FORMAT_ARGB1555, /* ARRR RRGG GGGB BBBB */
71 MESA_FORMAT_AL88, /* AAAA AAAA LLLL LLLL */
72 MESA_FORMAT_RGB332, /* RRRG GGBB */
73 MESA_FORMAT_A8, /* AAAA AAAA */
74 MESA_FORMAT_L8, /* LLLL LLLL */
75 MESA_FORMAT_I8, /* IIII IIII */
76 MESA_FORMAT_CI8, /* CCCC CCCC */
77 MESA_FORMAT_YCBCR, /* YYYY YYYY UorV UorV */
78 MESA_FORMAT_YCBCR_REV, /* UorV UorV YYYY YYYY */
79 /*@}*/
80
81 /**
82 * \name Compressed texture formats.
83 */
84 /*@{*/
85 MESA_FORMAT_RGB_FXT1,
86 MESA_FORMAT_RGBA_FXT1,
87 MESA_FORMAT_RGB_DXT1,
88 MESA_FORMAT_RGBA_DXT1,
89 MESA_FORMAT_RGBA_DXT3,
90 MESA_FORMAT_RGBA_DXT5,
91 /*@}*/
92
93 #if 0
94 /**
95 * \name Upcoming little-endian formats
96 */
97 /*@{*/
98 /* msb <------ TEXEL BITS -----------> lsb */
99 /* ---- ---- ---- ---- ---- ---- ---- ---- */
100 MESA_FORMAT_ABGR8888, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
101 MESA_FORMAT_BGRA8888, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
102 MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */
103 MESA_FORMAT_BGR565, /* BBBB BGGG GGGR RRRR */
104 MESA_FORMAT_BGRA4444, /* BBBB GGGG RRRR AAAA */
105 MESA_FORMAT_BGRA5551, /* BBBB BGGG GGRR RRRA */
106 MESA_FORMAT_LA88, /* LLLL LLLL AAAA AAAA */
107 MESA_FORMAT_BGR233, /* BBGG GRRR */
108 /*@}*/
109 #endif
110
111 /**
112 * \name Generic GLchan-based formats.
113 *
114 * These are the default formats used by the software rasterizer and, unless
115 * the driver overrides the texture image functions, incoming images will be
116 * converted to one of these formats. Components are arrays of GLchan
117 * values, so there will be no big/little endian issues.
118 *
119 * \note Because these are based on the GLchan data type, one cannot assume
120 * 8 bits per channel with these formats. If you require GLubyte channels,
121 * use one of the hardware formats above.
122 */
123 /*@{*/
124 MESA_FORMAT_RGBA,
125 MESA_FORMAT_RGB,
126 MESA_FORMAT_ALPHA,
127 MESA_FORMAT_LUMINANCE,
128 MESA_FORMAT_LUMINANCE_ALPHA,
129 MESA_FORMAT_INTENSITY,
130 MESA_FORMAT_COLOR_INDEX,
131 /*@}*/
132
133 /**
134 * \name Floating point texture formats.
135 */
136 /*@{*/
137 MESA_FORMAT_DEPTH_COMPONENT,
138 MESA_FORMAT_RGBA_FLOAT32,
139 MESA_FORMAT_RGBA_FLOAT16,
140 MESA_FORMAT_RGB_FLOAT32,
141 MESA_FORMAT_RGB_FLOAT16
142 /*@}*/
143 };
144
145
146 extern GLboolean
147 _mesa_is_hardware_tex_format( const struct gl_texture_format *format );
148
149 extern const struct gl_texture_format *
150 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
151 GLenum format, GLenum type );
152
153 extern GLint
154 _mesa_base_compressed_texformat(GLcontext *ctx, GLint intFormat);
155
156
157 /** The default formats, GLchan per component */
158 /*@{*/
159 extern const struct gl_texture_format _mesa_texformat_rgba;
160 extern const struct gl_texture_format _mesa_texformat_rgb;
161 extern const struct gl_texture_format _mesa_texformat_alpha;
162 extern const struct gl_texture_format _mesa_texformat_luminance;
163 extern const struct gl_texture_format _mesa_texformat_luminance_alpha;
164 extern const struct gl_texture_format _mesa_texformat_intensity;
165 extern const struct gl_texture_format _mesa_texformat_color_index;
166 /*@}*/
167
168 /** Floating point texture formats */
169 /*@{*/
170 extern const struct gl_texture_format _mesa_texformat_depth_component;
171 extern const struct gl_texture_format _mesa_texformat_rgba_float32;
172 extern const struct gl_texture_format _mesa_texformat_rgba_float16;
173 extern const struct gl_texture_format _mesa_texformat_rgb_float32;
174 extern const struct gl_texture_format _mesa_texformat_rgb_float16;
175 /*@}*/
176
177 /** \name The hardware-friendly formats */
178 /*@{*/
179 extern const struct gl_texture_format _mesa_texformat_rgba8888;
180 extern const struct gl_texture_format _mesa_texformat_argb8888;
181 extern const struct gl_texture_format _mesa_texformat_rgb888;
182 extern const struct gl_texture_format _mesa_texformat_rgb565;
183 extern const struct gl_texture_format _mesa_texformat_argb4444;
184 extern const struct gl_texture_format _mesa_texformat_argb1555;
185 extern const struct gl_texture_format _mesa_texformat_al88;
186 extern const struct gl_texture_format _mesa_texformat_rgb332;
187 extern const struct gl_texture_format _mesa_texformat_a8;
188 extern const struct gl_texture_format _mesa_texformat_l8;
189 extern const struct gl_texture_format _mesa_texformat_i8;
190 extern const struct gl_texture_format _mesa_texformat_ci8;
191 extern const struct gl_texture_format _mesa_texformat_ycbcr;
192 extern const struct gl_texture_format _mesa_texformat_ycbcr_rev;
193 extern const struct gl_texture_format _mesa_texformat_rgb_fxt1;
194 extern const struct gl_texture_format _mesa_texformat_rgba_fxt1;
195 extern const struct gl_texture_format _mesa_texformat_rgb_dxt1;
196 extern const struct gl_texture_format _mesa_texformat_rgba_dxt1;
197 extern const struct gl_texture_format _mesa_texformat_rgba_dxt3;
198 extern const struct gl_texture_format _mesa_texformat_rgba_dxt5;
199 /*@}*/
200
201 /** \name The null format */
202 /*@{*/
203 extern const struct gl_texture_format _mesa_null_texformat;
204 /*@}*/
205
206 #endif