1 /* $Id: texformat.h,v 1.9 2002/06/15 02:38:16 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2002 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
27 * Gareth Hughes <gareth@valinux.com>
37 * The Mesa internal texture image types.
38 * All texture images must be stored in one of these formats.
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
45 * These formats are all little endian, as shown below. They will be
46 * most useful for x86-based PC graphics card drivers.
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.
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 */
69 /* upcoming little-endian formats: */
71 /* msb <------ TEXEL BITS -----------> lsb */
72 /* ---- ---- ---- ---- ---- ---- ---- ---- */
73 MESA_FORMAT_ABGR8888
, /* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
74 MESA_FORMAT_BGRA8888
, /* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
75 MESA_FORMAT_BGR888
, /* BBBB BBBB GGGG GGGG RRRR RRRR */
76 MESA_FORMAT_BGR565
, /* BBBB BGGG GGGR RRRR */
77 MESA_FORMAT_BGRA4444
, /* BBBB GGGG RRRR AAAA */
78 MESA_FORMAT_BGRA5551
, /* BBBB BGGG GGRR RRRA */
79 MESA_FORMAT_LA88
, /* LLLL LLLL AAAA AAAA */
80 MESA_FORMAT_BGR233
, /* BBGG GRRR */
83 /* Generic GLchan-based formats. These are the default formats used
84 * by the software rasterizer and, unless the driver overrides the
85 * texture image functions, incoming images will be converted to one
86 * of these formats. Components are arrays of GLchan values, so
87 * there will be no big/little endian issues.
89 * NOTE: Because these are based on the GLchan datatype, one cannot
90 * assume 8 bits per channel with these formats. If you require
91 * GLubyte channels, use one of the hardware formats above.
96 MESA_FORMAT_LUMINANCE
,
97 MESA_FORMAT_LUMINANCE_ALPHA
,
98 MESA_FORMAT_INTENSITY
,
99 MESA_FORMAT_COLOR_INDEX
,
100 MESA_FORMAT_DEPTH_COMPONENT
105 _mesa_is_hardware_tex_format( const struct gl_texture_format
*format
);
107 extern const struct gl_texture_format
*
108 _mesa_choose_tex_format( GLcontext
*ctx
, GLint internalFormat
,
109 GLenum format
, GLenum type
);
112 _mesa_base_compressed_texformat(GLcontext
*ctx
, GLint intFormat
);
115 _mesa_compressed_texture_size(GLcontext
*ctx
,
116 const struct gl_texture_image
*texImage
);
119 /* The default formats, GLchan per component:
121 extern const struct gl_texture_format _mesa_texformat_rgba
;
122 extern const struct gl_texture_format _mesa_texformat_rgb
;
123 extern const struct gl_texture_format _mesa_texformat_alpha
;
124 extern const struct gl_texture_format _mesa_texformat_luminance
;
125 extern const struct gl_texture_format _mesa_texformat_luminance_alpha
;
126 extern const struct gl_texture_format _mesa_texformat_intensity
;
127 extern const struct gl_texture_format _mesa_texformat_color_index
;
128 extern const struct gl_texture_format _mesa_texformat_depth_component
;
130 /* The hardware-friendly formats:
132 extern const struct gl_texture_format _mesa_texformat_rgba8888
;
133 extern const struct gl_texture_format _mesa_texformat_argb8888
;
134 extern const struct gl_texture_format _mesa_texformat_rgb888
;
135 extern const struct gl_texture_format _mesa_texformat_rgb565
;
136 extern const struct gl_texture_format _mesa_texformat_argb4444
;
137 extern const struct gl_texture_format _mesa_texformat_argb1555
;
138 extern const struct gl_texture_format _mesa_texformat_al88
;
139 extern const struct gl_texture_format _mesa_texformat_rgb332
;
140 extern const struct gl_texture_format _mesa_texformat_a8
;
141 extern const struct gl_texture_format _mesa_texformat_l8
;
142 extern const struct gl_texture_format _mesa_texformat_i8
;
143 extern const struct gl_texture_format _mesa_texformat_ci8
;
147 extern const struct gl_texture_format _mesa_null_texformat
;