Minor tweaks to help out at a driver level.
[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 MESA_FORMAT_RGB_FXT1,
79 MESA_FORMAT_RGBA_FXT1,
80 MESA_FORMAT_RGB_DXT1,
81 MESA_FORMAT_RGBA_DXT1,
82 MESA_FORMAT_RGBA_DXT3,
83 MESA_FORMAT_RGBA_DXT5,
84
85 #if 0
86 /**
87 * \name Upcoming little-endian formats
88 */
89 /*@{*/
90 /* msb <------ TEXEL BITS -----------> lsb */
91 /* ---- ---- ---- ---- ---- ---- ---- ---- */
92 MESA_FORMAT_ABGR8888, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
93 MESA_FORMAT_BGRA8888, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
94 MESA_FORMAT_BGR888, /* BBBB BBBB GGGG GGGG RRRR RRRR */
95 MESA_FORMAT_BGR565, /* BBBB BGGG GGGR RRRR */
96 MESA_FORMAT_BGRA4444, /* BBBB GGGG RRRR AAAA */
97 MESA_FORMAT_BGRA5551, /* BBBB BGGG GGRR RRRA */
98 MESA_FORMAT_LA88, /* LLLL LLLL AAAA AAAA */
99 MESA_FORMAT_BGR233, /* BBGG GRRR */
100 /*@}*/
101 #endif
102
103 /**
104 * \name Generic GLchan-based formats.
105 *
106 * These are the default formats used by the software rasterizer and, unless
107 * the driver overrides the texture image functions, incoming images will be
108 * converted to one of these formats. Components are arrays of GLchan
109 * values, so there will be no big/little endian issues.
110 *
111 * \note Because these are based on the GLchan data type, one cannot assume 8
112 * bits per channel with these formats. If you require GLubyte channels,
113 * use one of the hardware formats above.
114 */
115 /*@{*/
116 MESA_FORMAT_RGBA,
117 MESA_FORMAT_RGB,
118 MESA_FORMAT_ALPHA,
119 MESA_FORMAT_LUMINANCE,
120 MESA_FORMAT_LUMINANCE_ALPHA,
121 MESA_FORMAT_INTENSITY,
122 MESA_FORMAT_COLOR_INDEX,
123 MESA_FORMAT_DEPTH_COMPONENT
124 /*@}*/
125 };
126
127
128 extern GLboolean
129 _mesa_is_hardware_tex_format( const struct gl_texture_format *format );
130
131 extern const struct gl_texture_format *
132 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
133 GLenum format, GLenum type );
134
135 extern GLint
136 _mesa_base_compressed_texformat(GLcontext *ctx, GLint intFormat);
137
138
139 /** The default formats, GLchan per component */
140 /*@{*/
141 extern const struct gl_texture_format _mesa_texformat_rgba;
142 extern const struct gl_texture_format _mesa_texformat_rgb;
143 extern const struct gl_texture_format _mesa_texformat_alpha;
144 extern const struct gl_texture_format _mesa_texformat_luminance;
145 extern const struct gl_texture_format _mesa_texformat_luminance_alpha;
146 extern const struct gl_texture_format _mesa_texformat_intensity;
147 extern const struct gl_texture_format _mesa_texformat_color_index;
148 extern const struct gl_texture_format _mesa_texformat_depth_component;
149 /*@}*/
150
151 /** \name The hardware-friendly formats */
152 /*@{*/
153 extern const struct gl_texture_format _mesa_texformat_rgba8888;
154 extern const struct gl_texture_format _mesa_texformat_argb8888;
155 extern const struct gl_texture_format _mesa_texformat_rgb888;
156 extern const struct gl_texture_format _mesa_texformat_rgb565;
157 extern const struct gl_texture_format _mesa_texformat_argb4444;
158 extern const struct gl_texture_format _mesa_texformat_argb1555;
159 extern const struct gl_texture_format _mesa_texformat_al88;
160 extern const struct gl_texture_format _mesa_texformat_rgb332;
161 extern const struct gl_texture_format _mesa_texformat_a8;
162 extern const struct gl_texture_format _mesa_texformat_l8;
163 extern const struct gl_texture_format _mesa_texformat_i8;
164 extern const struct gl_texture_format _mesa_texformat_ci8;
165 extern const struct gl_texture_format _mesa_texformat_ycbcr;
166 extern const struct gl_texture_format _mesa_texformat_ycbcr_rev;
167 extern const struct gl_texture_format _mesa_texformat_rgb_fxt1;
168 extern const struct gl_texture_format _mesa_texformat_rgba_fxt1;
169 extern const struct gl_texture_format _mesa_texformat_rgb_dxt1;
170 extern const struct gl_texture_format _mesa_texformat_rgba_dxt1;
171 extern const struct gl_texture_format _mesa_texformat_rgba_dxt3;
172 extern const struct gl_texture_format _mesa_texformat_rgba_dxt5;
173 /*@}*/
174
175 /** \name The null format */
176 /*@{*/
177 extern const struct gl_texture_format _mesa_null_texformat;
178 /*@}*/
179
180 #endif