texformat.h revision 7117f1b4
1/*
2 * Mesa 3-D graphics library
3 * Version:  6.5.1
4 *
5 * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26/**
27 * \file texformat.h
28 * Texture formats definitions.
29 *
30 * \author Gareth Hughes
31 */
32
33
34#ifndef TEXFORMAT_H
35#define TEXFORMAT_H
36
37
38#include "mtypes.h"
39
40
41/**
42 * Mesa internal texture image formats.
43 * All texture images are stored in one of these formats.
44 *
45 * NOTE: when you add a new format, be sure to update the do_row()
46 * function in texstore.c used for auto mipmap generation.
47 */
48enum _format {
49   /**
50    * \name Hardware-friendly formats.
51    *
52    * Drivers can override the default formats and convert texture images to
53    * one of these as required.  The driver's
54    * dd_function_table::ChooseTextureFormat function will choose one of these
55    * formats.
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_RGBA8888_REV,	/* AAAA AAAA BBBB BBBB GGGG GGGG RRRR RRRR */
67   MESA_FORMAT_ARGB8888,	/* AAAA AAAA RRRR RRRR GGGG GGGG BBBB BBBB */
68   MESA_FORMAT_ARGB8888_REV,	/* BBBB BBBB GGGG GGGG RRRR RRRR AAAA AAAA */
69   MESA_FORMAT_RGB888,		/*           RRRR RRRR GGGG GGGG BBBB BBBB */
70   MESA_FORMAT_BGR888,		/*           BBBB BBBB GGGG GGGG RRRR RRRR */
71   MESA_FORMAT_RGB565,		/*                     RRRR RGGG GGGB BBBB */
72   MESA_FORMAT_RGB565_REV,	/*                     GGGB BBBB RRRR RGGG */
73   MESA_FORMAT_ARGB4444,	/*                     AAAA RRRR GGGG BBBB */
74   MESA_FORMAT_ARGB4444_REV,	/*                     GGGG BBBB AAAA RRRR */
75   MESA_FORMAT_ARGB1555,	/*                     ARRR RRGG GGGB BBBB */
76   MESA_FORMAT_ARGB1555_REV,	/*                     GGGB BBBB ARRR RRGG */
77   MESA_FORMAT_AL88,		/*                     AAAA AAAA LLLL LLLL */
78   MESA_FORMAT_AL88_REV,	/*                     LLLL LLLL AAAA AAAA */
79   MESA_FORMAT_RGB332,		/*                               RRRG GGBB */
80   MESA_FORMAT_A8,		/*                               AAAA AAAA */
81   MESA_FORMAT_L8,		/*                               LLLL LLLL */
82   MESA_FORMAT_I8,		/*                               IIII IIII */
83   MESA_FORMAT_CI8,		/*                               CCCC CCCC */
84   MESA_FORMAT_YCBCR,		/*                     YYYY YYYY UorV UorV */
85   MESA_FORMAT_YCBCR_REV,	/*                     UorV UorV YYYY YYYY */
86   MESA_FORMAT_Z24_S8,          /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ SSSS SSSS */
87   MESA_FORMAT_Z16,             /*                     ZZZZ ZZZZ ZZZZ ZZZZ */
88   MESA_FORMAT_Z32,             /* ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ ZZZZ */
89   /*@}*/
90
91#if FEATURE_EXT_texture_sRGB
92   /**
93    * \name 8-bit/channel sRGB formats
94    */
95   /*@{*/
96   MESA_FORMAT_SRGB8,
97   MESA_FORMAT_SRGBA8,
98   MESA_FORMAT_SL8,
99   MESA_FORMAT_SLA8,
100   /*@}*/
101#endif
102
103   /**
104    * \name Compressed texture formats.
105    */
106   /*@{*/
107   MESA_FORMAT_RGB_FXT1,
108   MESA_FORMAT_RGBA_FXT1,
109   MESA_FORMAT_RGB_DXT1,
110   MESA_FORMAT_RGBA_DXT1,
111   MESA_FORMAT_RGBA_DXT3,
112   MESA_FORMAT_RGBA_DXT5,
113   /*@}*/
114
115   /**
116    * \name Generic GLchan-based formats.
117    *
118    * Software-oriented texture formats.  Texels are arrays of GLchan
119    * values so there are no byte order issues.
120    *
121    * \note Because these are based on the GLchan data type, one cannot assume
122    * 8 bits per channel with these formats.  If you require GLubyte channels,
123    * use one of the hardware formats above.
124    */
125   /*@{*/
126   MESA_FORMAT_RGBA,
127   MESA_FORMAT_RGB,
128   MESA_FORMAT_ALPHA,
129   MESA_FORMAT_LUMINANCE,
130   MESA_FORMAT_LUMINANCE_ALPHA,
131   MESA_FORMAT_INTENSITY,
132   /*@}*/
133
134   /**
135    * \name Floating point texture formats.
136    */
137   /*@{*/
138   MESA_FORMAT_RGBA_FLOAT32,
139   MESA_FORMAT_RGBA_FLOAT16,
140   MESA_FORMAT_RGB_FLOAT32,
141   MESA_FORMAT_RGB_FLOAT16,
142   MESA_FORMAT_ALPHA_FLOAT32,
143   MESA_FORMAT_ALPHA_FLOAT16,
144   MESA_FORMAT_LUMINANCE_FLOAT32,
145   MESA_FORMAT_LUMINANCE_FLOAT16,
146   MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
147   MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
148   MESA_FORMAT_INTENSITY_FLOAT32,
149   MESA_FORMAT_INTENSITY_FLOAT16
150   /*@}*/
151};
152
153
154/** GLchan-valued formats */
155/*@{*/
156extern const struct gl_texture_format _mesa_texformat_rgba;
157extern const struct gl_texture_format _mesa_texformat_rgb;
158extern const struct gl_texture_format _mesa_texformat_alpha;
159extern const struct gl_texture_format _mesa_texformat_luminance;
160extern const struct gl_texture_format _mesa_texformat_luminance_alpha;
161extern const struct gl_texture_format _mesa_texformat_intensity;
162/*@}*/
163
164#if FEATURE_EXT_texture_sRGB
165/** sRGB (nonlinear) formats */
166/*@{*/
167extern const struct gl_texture_format _mesa_texformat_srgb8;
168extern const struct gl_texture_format _mesa_texformat_srgba8;
169extern const struct gl_texture_format _mesa_texformat_sl8;
170extern const struct gl_texture_format _mesa_texformat_sla8;
171/*@}*/
172#endif
173
174/** Floating point texture formats */
175/*@{*/
176extern const struct gl_texture_format _mesa_texformat_rgba_float32;
177extern const struct gl_texture_format _mesa_texformat_rgba_float16;
178extern const struct gl_texture_format _mesa_texformat_rgb_float32;
179extern const struct gl_texture_format _mesa_texformat_rgb_float16;
180extern const struct gl_texture_format _mesa_texformat_alpha_float32;
181extern const struct gl_texture_format _mesa_texformat_alpha_float16;
182extern const struct gl_texture_format _mesa_texformat_luminance_float32;
183extern const struct gl_texture_format _mesa_texformat_luminance_float16;
184extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float32;
185extern const struct gl_texture_format _mesa_texformat_luminance_alpha_float16;
186extern const struct gl_texture_format _mesa_texformat_intensity_float32;
187extern const struct gl_texture_format _mesa_texformat_intensity_float16;
188/*@}*/
189
190/** \name Assorted hardware-friendly formats */
191/*@{*/
192extern const struct gl_texture_format _mesa_texformat_rgba8888;
193extern const struct gl_texture_format _mesa_texformat_rgba8888_rev;
194extern const struct gl_texture_format _mesa_texformat_argb8888;
195extern const struct gl_texture_format _mesa_texformat_argb8888_rev;
196extern const struct gl_texture_format _mesa_texformat_rgb888;
197extern const struct gl_texture_format _mesa_texformat_bgr888;
198extern const struct gl_texture_format _mesa_texformat_rgb565;
199extern const struct gl_texture_format _mesa_texformat_rgb565_rev;
200extern const struct gl_texture_format _mesa_texformat_argb4444;
201extern const struct gl_texture_format _mesa_texformat_argb4444_rev;
202extern const struct gl_texture_format _mesa_texformat_argb1555;
203extern const struct gl_texture_format _mesa_texformat_argb1555_rev;
204extern const struct gl_texture_format _mesa_texformat_al88;
205extern const struct gl_texture_format _mesa_texformat_al88_rev;
206extern const struct gl_texture_format _mesa_texformat_rgb332;
207extern const struct gl_texture_format _mesa_texformat_a8;
208extern const struct gl_texture_format _mesa_texformat_l8;
209extern const struct gl_texture_format _mesa_texformat_i8;
210extern const struct gl_texture_format _mesa_texformat_ci8;
211extern const struct gl_texture_format _mesa_texformat_z24_s8;
212extern const struct gl_texture_format _mesa_texformat_z16;
213extern const struct gl_texture_format _mesa_texformat_z32;
214/*@}*/
215
216/** \name YCbCr formats */
217/*@{*/
218extern const struct gl_texture_format _mesa_texformat_ycbcr;
219extern const struct gl_texture_format _mesa_texformat_ycbcr_rev;
220/*@}*/
221
222/** \name Compressed formats */
223/*@{*/
224extern const struct gl_texture_format _mesa_texformat_rgb_fxt1;
225extern const struct gl_texture_format _mesa_texformat_rgba_fxt1;
226extern const struct gl_texture_format _mesa_texformat_rgb_dxt1;
227extern const struct gl_texture_format _mesa_texformat_rgba_dxt1;
228extern const struct gl_texture_format _mesa_texformat_rgba_dxt3;
229extern const struct gl_texture_format _mesa_texformat_rgba_dxt5;
230/*@}*/
231
232/** \name The null format */
233/*@{*/
234extern const struct gl_texture_format _mesa_null_texformat;
235/*@}*/
236
237
238extern const struct gl_texture_format *
239_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
240                         GLenum format, GLenum type );
241
242#endif
243