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