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