blob: 792bfbc1e45f7aac1cdf5c93300419347903489f [file] [log] [blame]
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001/*
2 * Mesa 3-D graphics library
Brian Paula9bcf752006-04-06 04:23:58 +00003 * Version: 6.5.1
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00004 *
Brian Paula9bcf752006-04-06 04:23:58 +00005 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00006 *
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.
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000023 */
24
Keith Whitwell6dc85572003-07-17 13:43:59 +000025
Brian Paulf959f6e2004-04-22 00:27:31 +000026/**
27 * \file texformat.c
28 * Texture formats.
29 *
30 * \author Gareth Hughes
31 */
32
33
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000034#include "colormac.h"
35#include "context.h"
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000036#include "texformat.h"
Brian Paul36237332004-04-22 00:54:53 +000037#include "texstore.h"
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000038
Brian Paulf959f6e2004-04-22 00:27:31 +000039
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000040
Keith Whitwell6dc85572003-07-17 13:43:59 +000041/* Texel fetch routines for all supported formats
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000042 */
43#define DIM 1
44#include "texformat_tmp.h"
45
46#define DIM 2
47#include "texformat_tmp.h"
48
49#define DIM 3
50#include "texformat_tmp.h"
51
Keith Whitwell6dc85572003-07-17 13:43:59 +000052/**
53 * Null texel fetch function.
54 *
55 * Have to have this so the FetchTexel function pointer is never NULL.
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000056 */
57static void fetch_null_texel( const struct gl_texture_image *texImage,
Brian Paul4f295ce2004-01-23 01:59:54 +000058 GLint i, GLint j, GLint k, GLchan *texel )
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000059{
Brian Paula6c423d2004-08-25 15:59:48 +000060 (void) texImage; (void) i; (void) j; (void) k;
Brian Paul4f295ce2004-01-23 01:59:54 +000061 texel[RCOMP] = 0;
62 texel[GCOMP] = 0;
63 texel[BCOMP] = 0;
64 texel[ACOMP] = 0;
65 _mesa_warning(NULL, "fetch_null_texel() called!");
66}
67
68static void fetch_null_texelf( const struct gl_texture_image *texImage,
69 GLint i, GLint j, GLint k, GLfloat *texel )
70{
Brian Paula6c423d2004-08-25 15:59:48 +000071 (void) texImage; (void) i; (void) j; (void) k;
Brian Paul4f295ce2004-01-23 01:59:54 +000072 texel[RCOMP] = 0.0;
73 texel[GCOMP] = 0.0;
74 texel[BCOMP] = 0.0;
75 texel[ACOMP] = 0.0;
76 _mesa_warning(NULL, "fetch_null_texelf() called!");
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000077}
78
Brian Paule4b23562005-05-04 20:11:35 +000079static void store_null_texel(struct gl_texture_image *texImage,
80 GLint i, GLint j, GLint k, const void *texel)
81{
Brian Paula9bcf752006-04-06 04:23:58 +000082 (void) texImage;
83 (void) i;
84 (void) j;
85 (void) k;
86 (void) texel;
Brian Paule4b23562005-05-04 20:11:35 +000087 /* no-op */
88}
89
90
Brian Paul63b5b8e2005-09-15 01:55:40 +000091/**
92 * Notes about the predefined gl_texture_formats:
93 *
94 * 1. There are 1D, 2D and 3D functions for fetching texels from texture
95 * images, returning both GLchan values and GLfloat values. (six
96 * functions in total)
97 * You don't have to provide both the GLchan and GLfloat functions;
98 * just one or the other is OK. Mesa will use an "adaptor" to convert
99 * between GLchan/GLfloat when needed.
100 * Since the adaptors have small performance penalty, we provide both
101 * GLchan and GLfloat functions for some common formats like RGB, RGBA.
102 */
103
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000104
Keith Whitwell6dc85572003-07-17 13:43:59 +0000105/***************************************************************/
106/** \name Default GLchan-based formats */
107/*@{*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000108
109const struct gl_texture_format _mesa_texformat_rgba = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000110 MESA_FORMAT_RGBA, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000111 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000112 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000113 CHAN_BITS, /* RedBits */
114 CHAN_BITS, /* GreenBits */
115 CHAN_BITS, /* BlueBits */
116 CHAN_BITS, /* AlphaBits */
117 0, /* LuminanceBits */
118 0, /* IntensityBits */
119 0, /* IndexBits */
120 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000121 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000122 4 * sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000123 _mesa_texstore_rgba, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000124 fetch_texel_1d_rgba, /* FetchTexel1D */
125 fetch_texel_2d_rgba, /* FetchTexel2D */
126 fetch_texel_3d_rgba, /* FetchTexel3D */
127 fetch_texel_1d_f_rgba, /* FetchTexel1Df */
128 fetch_texel_2d_f_rgba, /* FetchTexel2Df */
129 fetch_texel_3d_f_rgba, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000130 store_texel_rgba /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000131};
132
133const struct gl_texture_format _mesa_texformat_rgb = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000134 MESA_FORMAT_RGB, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000135 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000136 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000137 CHAN_BITS, /* RedBits */
138 CHAN_BITS, /* GreenBits */
139 CHAN_BITS, /* BlueBits */
140 0, /* AlphaBits */
141 0, /* LuminanceBits */
142 0, /* IntensityBits */
143 0, /* IndexBits */
144 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000145 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000146 3 * sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000147 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000148 fetch_texel_1d_rgb, /* FetchTexel1D */
149 fetch_texel_2d_rgb, /* FetchTexel2D */
150 fetch_texel_3d_rgb, /* FetchTexel3D */
151 fetch_texel_1d_f_rgb, /* FetchTexel1Df */
152 fetch_texel_2d_f_rgb, /* FetchTexel2Df */
153 fetch_texel_3d_f_rgb, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000154 store_texel_rgb /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000155};
156
157const struct gl_texture_format _mesa_texformat_alpha = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000158 MESA_FORMAT_ALPHA, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000159 GL_ALPHA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000160 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000161 0, /* RedBits */
162 0, /* GreenBits */
163 0, /* BlueBits */
164 CHAN_BITS, /* AlphaBits */
165 0, /* LuminanceBits */
166 0, /* IntensityBits */
167 0, /* IndexBits */
168 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000169 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000170 sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000171 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000172 fetch_texel_1d_alpha, /* FetchTexel1D */
173 fetch_texel_2d_alpha, /* FetchTexel2D */
174 fetch_texel_3d_alpha, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000175 NULL, /* FetchTexel1Df */
176 NULL, /* FetchTexel2Df */
177 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000178 store_texel_alpha /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000179};
180
181const struct gl_texture_format _mesa_texformat_luminance = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000182 MESA_FORMAT_LUMINANCE, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000183 GL_LUMINANCE, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000184 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000185 0, /* RedBits */
186 0, /* GreenBits */
187 0, /* BlueBits */
188 0, /* AlphaBits */
189 CHAN_BITS, /* LuminanceBits */
190 0, /* IntensityBits */
191 0, /* IndexBits */
192 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000193 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000194 sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000195 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000196 fetch_texel_1d_luminance, /* FetchTexel1D */
197 fetch_texel_2d_luminance, /* FetchTexel2D */
198 fetch_texel_3d_luminance, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000199 NULL, /* FetchTexel1Df */
200 NULL, /* FetchTexel2Df */
201 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000202 store_texel_luminance /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000203};
204
205const struct gl_texture_format _mesa_texformat_luminance_alpha = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000206 MESA_FORMAT_LUMINANCE_ALPHA, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000207 GL_LUMINANCE_ALPHA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000208 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000209 0, /* RedBits */
210 0, /* GreenBits */
211 0, /* BlueBits */
212 CHAN_BITS, /* AlphaBits */
213 CHAN_BITS, /* LuminanceBits */
214 0, /* IntensityBits */
215 0, /* IndexBits */
216 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000217 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000218 2 * sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000219 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000220 fetch_texel_1d_luminance_alpha, /* FetchTexel1D */
221 fetch_texel_2d_luminance_alpha, /* FetchTexel2D */
222 fetch_texel_3d_luminance_alpha, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000223 NULL, /* FetchTexel1Df */
224 NULL, /* FetchTexel2Df */
225 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000226 store_texel_luminance_alpha /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000227};
228
229const struct gl_texture_format _mesa_texformat_intensity = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000230 MESA_FORMAT_INTENSITY, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000231 GL_INTENSITY, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000232 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000233 0, /* RedBits */
234 0, /* GreenBits */
235 0, /* BlueBits */
236 0, /* AlphaBits */
237 0, /* LuminanceBits */
238 CHAN_BITS, /* IntensityBits */
239 0, /* IndexBits */
240 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000241 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000242 sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000243 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000244 fetch_texel_1d_intensity, /* FetchTexel1D */
245 fetch_texel_2d_intensity, /* FetchTexel2D */
246 fetch_texel_3d_intensity, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000247 NULL, /* FetchTexel1Df */
248 NULL, /* FetchTexel2Df */
249 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000250 store_texel_intensity /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000251};
252
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000253
Brian Paulfe031082004-01-24 17:02:19 +0000254const struct gl_texture_format _mesa_texformat_rgba_float32 = {
255 MESA_FORMAT_RGBA_FLOAT32, /* MesaFormat */
256 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000257 GL_FLOAT, /* DataType */
Brian Paulfe031082004-01-24 17:02:19 +0000258 8 * sizeof(GLfloat), /* RedBits */
259 8 * sizeof(GLfloat), /* GreenBits */
260 8 * sizeof(GLfloat), /* BlueBits */
261 8 * sizeof(GLfloat), /* AlphaBits */
262 0, /* LuminanceBits */
263 0, /* IntensityBits */
264 0, /* IndexBits */
265 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000266 0, /* StencilBits */
Brian Paulfe031082004-01-24 17:02:19 +0000267 4 * sizeof(GLfloat), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000268 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000269 NULL, /* FetchTexel1D */
270 NULL, /* FetchTexel1D */
271 NULL, /* FetchTexel1D */
Brian Paulfe031082004-01-24 17:02:19 +0000272 fetch_texel_1d_f_rgba_f32, /* FetchTexel1Df */
273 fetch_texel_2d_f_rgba_f32, /* FetchTexel2Df */
274 fetch_texel_3d_f_rgba_f32, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000275 store_texel_rgba_f32 /* StoreTexel */
Brian Paulfe031082004-01-24 17:02:19 +0000276};
277
278const struct gl_texture_format _mesa_texformat_rgba_float16 = {
279 MESA_FORMAT_RGBA_FLOAT16, /* MesaFormat */
280 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000281 GL_FLOAT, /* DataType */
282 8 * sizeof(GLhalfARB), /* RedBits */
283 8 * sizeof(GLhalfARB), /* GreenBits */
284 8 * sizeof(GLhalfARB), /* BlueBits */
285 8 * sizeof(GLhalfARB), /* AlphaBits */
Brian Paulfe031082004-01-24 17:02:19 +0000286 0, /* LuminanceBits */
287 0, /* IntensityBits */
288 0, /* IndexBits */
289 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000290 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000291 4 * sizeof(GLhalfARB), /* TexelBytes */
292 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000293 NULL, /* FetchTexel1D */
294 NULL, /* FetchTexel1D */
295 NULL, /* FetchTexel1D */
Brian Paulfe031082004-01-24 17:02:19 +0000296 fetch_texel_1d_f_rgba_f16, /* FetchTexel1Df */
297 fetch_texel_2d_f_rgba_f16, /* FetchTexel2Df */
298 fetch_texel_3d_f_rgba_f16, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000299 store_texel_rgba_f16 /* StoreTexel */
Brian Paulfe031082004-01-24 17:02:19 +0000300};
301
302const struct gl_texture_format _mesa_texformat_rgb_float32 = {
303 MESA_FORMAT_RGB_FLOAT32, /* MesaFormat */
304 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000305 GL_FLOAT, /* DataType */
Brian Paulfe031082004-01-24 17:02:19 +0000306 8 * sizeof(GLfloat), /* RedBits */
307 8 * sizeof(GLfloat), /* GreenBits */
308 8 * sizeof(GLfloat), /* BlueBits */
309 0, /* AlphaBits */
310 0, /* LuminanceBits */
311 0, /* IntensityBits */
312 0, /* IndexBits */
313 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000314 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000315 3 * sizeof(GLfloat), /* TexelBytes */
316 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000317 NULL, /* FetchTexel1D */
318 NULL, /* FetchTexel1D */
319 NULL, /* FetchTexel1D */
Brian Paulfe031082004-01-24 17:02:19 +0000320 fetch_texel_1d_f_rgb_f32, /* FetchTexel1Df */
321 fetch_texel_2d_f_rgb_f32, /* FetchTexel2Df */
322 fetch_texel_3d_f_rgb_f32, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000323 store_texel_rgb_f32 /* StoreTexel */
Brian Paulfe031082004-01-24 17:02:19 +0000324};
325
326const struct gl_texture_format _mesa_texformat_rgb_float16 = {
327 MESA_FORMAT_RGB_FLOAT16, /* MesaFormat */
328 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000329 GL_FLOAT, /* DataType */
330 8 * sizeof(GLhalfARB), /* RedBits */
331 8 * sizeof(GLhalfARB), /* GreenBits */
332 8 * sizeof(GLhalfARB), /* BlueBits */
Brian Paulfe031082004-01-24 17:02:19 +0000333 0, /* AlphaBits */
334 0, /* LuminanceBits */
335 0, /* IntensityBits */
336 0, /* IndexBits */
337 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000338 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000339 3 * sizeof(GLhalfARB), /* TexelBytes */
340 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000341 NULL, /* FetchTexel1D */
342 NULL, /* FetchTexel1D */
343 NULL, /* FetchTexel1D */
Brian Paulfe031082004-01-24 17:02:19 +0000344 fetch_texel_1d_f_rgb_f16, /* FetchTexel1Df */
345 fetch_texel_2d_f_rgb_f16, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000346 fetch_texel_3d_f_rgb_f16, /* FetchTexel3Df */
347 store_texel_rgb_f16 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000348};
349
350const struct gl_texture_format _mesa_texformat_alpha_float32 = {
351 MESA_FORMAT_ALPHA_FLOAT32, /* MesaFormat */
352 GL_ALPHA, /* BaseFormat */
353 GL_FLOAT, /* DataType */
354 0, /* RedBits */
355 0, /* GreenBits */
356 0, /* BlueBits */
357 8 * sizeof(GLfloat), /* AlphaBits */
358 0, /* LuminanceBits */
359 0, /* IntensityBits */
360 0, /* IndexBits */
361 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000362 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000363 1 * sizeof(GLfloat), /* TexelBytes */
364 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000365 NULL, /* FetchTexel1D */
366 NULL, /* FetchTexel1D */
367 NULL, /* FetchTexel1D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000368 fetch_texel_1d_f_alpha_f32, /* FetchTexel1Df */
369 fetch_texel_2d_f_alpha_f32, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000370 fetch_texel_3d_f_alpha_f32, /* FetchTexel3Df */
371 store_texel_alpha_f32 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000372};
373
374const struct gl_texture_format _mesa_texformat_alpha_float16 = {
375 MESA_FORMAT_ALPHA_FLOAT16, /* MesaFormat */
376 GL_ALPHA, /* BaseFormat */
377 GL_FLOAT, /* DataType */
378 0, /* RedBits */
379 0, /* GreenBits */
380 0, /* BlueBits */
381 8 * sizeof(GLhalfARB), /* AlphaBits */
382 0, /* LuminanceBits */
383 0, /* IntensityBits */
384 0, /* IndexBits */
385 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000386 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000387 1 * sizeof(GLhalfARB), /* TexelBytes */
388 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000389 NULL, /* FetchTexel1D */
390 NULL, /* FetchTexel1D */
391 NULL, /* FetchTexel1D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000392 fetch_texel_1d_f_alpha_f16, /* FetchTexel1Df */
393 fetch_texel_2d_f_alpha_f16, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000394 fetch_texel_3d_f_alpha_f16, /* FetchTexel3Df */
395 store_texel_alpha_f16 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000396};
397
398const struct gl_texture_format _mesa_texformat_luminance_float32 = {
399 MESA_FORMAT_LUMINANCE_FLOAT32, /* MesaFormat */
400 GL_LUMINANCE, /* BaseFormat */
401 GL_FLOAT, /* DataType */
402 0, /* RedBits */
403 0, /* GreenBits */
404 0, /* BlueBits */
405 0, /* AlphaBits */
406 8 * sizeof(GLfloat), /* LuminanceBits */
407 0, /* IntensityBits */
408 0, /* IndexBits */
409 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000410 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000411 1 * sizeof(GLfloat), /* TexelBytes */
412 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000413 NULL, /* FetchTexel1D */
414 NULL, /* FetchTexel2D */
415 NULL, /* FetchTexel3D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000416 fetch_texel_1d_f_luminance_f32, /* FetchTexel1Df */
417 fetch_texel_2d_f_luminance_f32, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000418 fetch_texel_3d_f_luminance_f32, /* FetchTexel3Df */
419 store_texel_luminance_f32 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000420};
421
422const struct gl_texture_format _mesa_texformat_luminance_float16 = {
423 MESA_FORMAT_LUMINANCE_FLOAT16, /* MesaFormat */
424 GL_LUMINANCE, /* BaseFormat */
425 GL_FLOAT, /* DataType */
426 0, /* RedBits */
427 0, /* GreenBits */
428 0, /* BlueBits */
429 0, /* AlphaBits */
430 8 * sizeof(GLhalfARB), /* LuminanceBits */
431 0, /* IntensityBits */
432 0, /* IndexBits */
433 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000434 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000435 1 * sizeof(GLhalfARB), /* TexelBytes */
436 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000437 NULL, /* FetchTexel1D */
438 NULL, /* FetchTexel2D */
439 NULL, /* FetchTexel3D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000440 fetch_texel_1d_f_luminance_f16, /* FetchTexel1Df */
441 fetch_texel_2d_f_luminance_f16, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000442 fetch_texel_3d_f_luminance_f16, /* FetchTexel3Df */
443 store_texel_luminance_f16 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000444};
445
446const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
447 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, /* MesaFormat */
448 GL_LUMINANCE_ALPHA, /* BaseFormat */
449 GL_FLOAT, /* DataType */
450 0, /* RedBits */
451 0, /* GreenBits */
452 0, /* BlueBits */
453 8 * sizeof(GLfloat), /* AlphaBits */
454 8 * sizeof(GLfloat), /* LuminanceBits */
455 0, /* IntensityBits */
456 0, /* IndexBits */
457 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000458 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000459 2 * sizeof(GLfloat), /* TexelBytes */
460 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000461 NULL, /* FetchTexel1D */
462 NULL, /* FetchTexel2D */
463 NULL, /* FetchTexel3D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000464 fetch_texel_1d_f_luminance_alpha_f32,/* FetchTexel1Df */
465 fetch_texel_2d_f_luminance_alpha_f32,/* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000466 fetch_texel_3d_f_luminance_alpha_f32,/* FetchTexel3Df */
467 store_texel_luminance_alpha_f32 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000468};
469
470const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
471 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, /* MesaFormat */
472 GL_LUMINANCE_ALPHA, /* BaseFormat */
473 GL_FLOAT, /* DataType */
474 0, /* RedBits */
475 0, /* GreenBits */
476 0, /* BlueBits */
477 8 * sizeof(GLhalfARB), /* AlphaBits */
478 8 * sizeof(GLhalfARB), /* LuminanceBits */
479 0, /* IntensityBits */
480 0, /* IndexBits */
481 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000482 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000483 2 * sizeof(GLhalfARB), /* TexelBytes */
484 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000485 NULL, /* FetchTexel1D */
486 NULL, /* FetchTexel2D */
487 NULL, /* FetchTexel3D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000488 fetch_texel_1d_f_luminance_alpha_f16,/* FetchTexel1Df */
489 fetch_texel_2d_f_luminance_alpha_f16,/* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000490 fetch_texel_3d_f_luminance_alpha_f16,/* FetchTexel3Df */
491 store_texel_luminance_alpha_f16 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000492};
493
494const struct gl_texture_format _mesa_texformat_intensity_float32 = {
495 MESA_FORMAT_INTENSITY_FLOAT32, /* MesaFormat */
496 GL_INTENSITY, /* BaseFormat */
497 GL_FLOAT, /* DataType */
498 0, /* RedBits */
499 0, /* GreenBits */
500 0, /* BlueBits */
501 0, /* AlphaBits */
502 0, /* LuminanceBits */
503 8 * sizeof(GLfloat), /* IntensityBits */
504 0, /* IndexBits */
505 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000506 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000507 1 * sizeof(GLfloat), /* TexelBytes */
508 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000509 NULL, /* FetchTexel1D */
510 NULL, /* FetchTexel2D */
511 NULL, /* FetchTexel3D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000512 fetch_texel_1d_f_intensity_f32, /* FetchTexel1Df */
513 fetch_texel_2d_f_intensity_f32, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000514 fetch_texel_3d_f_intensity_f32, /* FetchTexel3Df */
515 store_texel_intensity_f32 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000516};
517
518const struct gl_texture_format _mesa_texformat_intensity_float16 = {
519 MESA_FORMAT_INTENSITY_FLOAT16, /* MesaFormat */
520 GL_INTENSITY, /* BaseFormat */
521 GL_FLOAT, /* DataType */
522 0, /* RedBits */
523 0, /* GreenBits */
524 0, /* BlueBits */
525 0, /* AlphaBits */
526 0, /* LuminanceBits */
527 8 * sizeof(GLhalfARB), /* IntensityBits */
528 0, /* IndexBits */
529 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000530 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000531 1 * sizeof(GLhalfARB), /* TexelBytes */
532 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000533 NULL, /* FetchTexel1D */
534 NULL, /* FetchTexel2D */
535 NULL, /* FetchTexel3D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000536 fetch_texel_1d_f_intensity_f16, /* FetchTexel1Df */
537 fetch_texel_2d_f_intensity_f16, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000538 fetch_texel_3d_f_intensity_f16, /* FetchTexel3Df */
539 store_texel_intensity_f16 /* StoreTexel */
Brian Paulfe031082004-01-24 17:02:19 +0000540};
541
542
Keith Whitwell6dc85572003-07-17 13:43:59 +0000543/*@}*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000544
Keith Whitwell6dc85572003-07-17 13:43:59 +0000545
546/***************************************************************/
547/** \name Hardware formats */
548/*@{*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000549
550const struct gl_texture_format _mesa_texformat_rgba8888 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000551 MESA_FORMAT_RGBA8888, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000552 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000553 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000554 8, /* RedBits */
555 8, /* GreenBits */
556 8, /* BlueBits */
557 8, /* AlphaBits */
558 0, /* LuminanceBits */
559 0, /* IntensityBits */
560 0, /* IndexBits */
561 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000562 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000563 4, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000564 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000565 fetch_texel_1d_rgba8888, /* FetchTexel1D */
566 fetch_texel_2d_rgba8888, /* FetchTexel2D */
567 fetch_texel_3d_rgba8888, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000568 NULL, /* FetchTexel1Df */
569 NULL, /* FetchTexel2Df */
570 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000571 store_texel_rgba8888 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000572};
573
Brian Pauldefb0352004-05-13 15:26:51 +0000574const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
575 MESA_FORMAT_RGBA8888_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000576 GL_RGBA, /* BaseFormat */
577 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
578 8, /* RedBits */
579 8, /* GreenBits */
580 8, /* BlueBits */
581 8, /* AlphaBits */
582 0, /* LuminanceBits */
583 0, /* IntensityBits */
584 0, /* IndexBits */
585 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000586 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000587 4, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000588 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
589 fetch_texel_1d_rgba8888_rev, /* FetchTexel1D */
590 fetch_texel_2d_rgba8888_rev, /* FetchTexel2D */
591 fetch_texel_3d_rgba8888_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000592 NULL, /* FetchTexel1Df */
593 NULL, /* FetchTexel2Df */
594 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000595 store_texel_rgba8888_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000596};
597
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000598const struct gl_texture_format _mesa_texformat_argb8888 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000599 MESA_FORMAT_ARGB8888, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000600 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000601 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000602 8, /* RedBits */
603 8, /* GreenBits */
604 8, /* BlueBits */
605 8, /* AlphaBits */
606 0, /* LuminanceBits */
607 0, /* IntensityBits */
608 0, /* IndexBits */
609 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000610 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000611 4, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000612 _mesa_texstore_argb8888, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000613 fetch_texel_1d_argb8888, /* FetchTexel1D */
614 fetch_texel_2d_argb8888, /* FetchTexel2D */
615 fetch_texel_3d_argb8888, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000616 NULL, /* FetchTexel1Df */
617 NULL, /* FetchTexel2Df */
618 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000619 store_texel_argb8888 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000620};
621
Brian Pauldefb0352004-05-13 15:26:51 +0000622const struct gl_texture_format _mesa_texformat_argb8888_rev = {
623 MESA_FORMAT_ARGB8888_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000624 GL_RGBA, /* BaseFormat */
625 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
626 8, /* RedBits */
627 8, /* GreenBits */
628 8, /* BlueBits */
629 8, /* AlphaBits */
630 0, /* LuminanceBits */
631 0, /* IntensityBits */
632 0, /* IndexBits */
633 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000634 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000635 4, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000636 _mesa_texstore_argb8888, /* StoreTexImageFunc */
637 fetch_texel_1d_argb8888_rev, /* FetchTexel1D */
638 fetch_texel_2d_argb8888_rev, /* FetchTexel2D */
639 fetch_texel_3d_argb8888_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000640 NULL, /* FetchTexel1Df */
641 NULL, /* FetchTexel2Df */
642 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000643 store_texel_argb8888_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000644};
645
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000646const struct gl_texture_format _mesa_texformat_rgb888 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000647 MESA_FORMAT_RGB888, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000648 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000649 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000650 8, /* RedBits */
651 8, /* GreenBits */
652 8, /* BlueBits */
653 0, /* AlphaBits */
654 0, /* LuminanceBits */
655 0, /* IntensityBits */
656 0, /* IndexBits */
657 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000658 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000659 3, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000660 _mesa_texstore_rgb888, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000661 fetch_texel_1d_rgb888, /* FetchTexel1D */
662 fetch_texel_2d_rgb888, /* FetchTexel2D */
663 fetch_texel_3d_rgb888, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000664 NULL, /* FetchTexel1Df */
665 NULL, /* FetchTexel2Df */
666 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000667 store_texel_rgb888 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000668};
669
Brian Paula156b492004-05-12 01:50:30 +0000670const struct gl_texture_format _mesa_texformat_bgr888 = {
671 MESA_FORMAT_BGR888, /* MesaFormat */
672 GL_RGB, /* BaseFormat */
673 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
674 8, /* RedBits */
675 8, /* GreenBits */
676 8, /* BlueBits */
677 0, /* AlphaBits */
678 0, /* LuminanceBits */
679 0, /* IntensityBits */
680 0, /* IndexBits */
681 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000682 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000683 3, /* TexelBytes */
684 _mesa_texstore_bgr888, /* StoreTexImageFunc */
685 fetch_texel_1d_bgr888, /* FetchTexel1D */
686 fetch_texel_2d_bgr888, /* FetchTexel2D */
687 fetch_texel_3d_bgr888, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000688 NULL, /* FetchTexel1Df */
689 NULL, /* FetchTexel2Df */
690 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000691 store_texel_bgr888 /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000692};
693
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000694const struct gl_texture_format _mesa_texformat_rgb565 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000695 MESA_FORMAT_RGB565, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000696 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000697 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000698 5, /* RedBits */
699 6, /* GreenBits */
700 5, /* BlueBits */
701 0, /* AlphaBits */
702 0, /* LuminanceBits */
703 0, /* IntensityBits */
704 0, /* IndexBits */
705 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000706 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000707 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000708 _mesa_texstore_rgb565, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000709 fetch_texel_1d_rgb565, /* FetchTexel1D */
710 fetch_texel_2d_rgb565, /* FetchTexel2D */
711 fetch_texel_3d_rgb565, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000712 NULL, /* FetchTexel1Df */
713 NULL, /* FetchTexel2Df */
714 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000715 store_texel_rgb565 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000716};
717
Brian Pauldefb0352004-05-13 15:26:51 +0000718const struct gl_texture_format _mesa_texformat_rgb565_rev = {
719 MESA_FORMAT_RGB565_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000720 GL_RGB, /* BaseFormat */
721 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
722 5, /* RedBits */
723 6, /* GreenBits */
724 5, /* BlueBits */
725 0, /* AlphaBits */
726 0, /* LuminanceBits */
727 0, /* IntensityBits */
728 0, /* IndexBits */
729 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000730 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000731 2, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000732 _mesa_texstore_rgb565, /* StoreTexImageFunc */
733 fetch_texel_1d_rgb565_rev, /* FetchTexel1D */
734 fetch_texel_2d_rgb565_rev, /* FetchTexel2D */
735 fetch_texel_3d_rgb565_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000736 NULL, /* FetchTexel1Df */
737 NULL, /* FetchTexel2Df */
738 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000739 store_texel_rgb565_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000740};
741
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000742const struct gl_texture_format _mesa_texformat_argb4444 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000743 MESA_FORMAT_ARGB4444, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000744 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000745 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000746 4, /* RedBits */
747 4, /* GreenBits */
748 4, /* BlueBits */
749 4, /* AlphaBits */
750 0, /* LuminanceBits */
751 0, /* IntensityBits */
752 0, /* IndexBits */
753 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000754 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000755 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000756 _mesa_texstore_argb4444, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000757 fetch_texel_1d_argb4444, /* FetchTexel1D */
758 fetch_texel_2d_argb4444, /* FetchTexel2D */
759 fetch_texel_3d_argb4444, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000760 NULL, /* FetchTexel1Df */
761 NULL, /* FetchTexel2Df */
762 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000763 store_texel_argb4444 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000764};
765
Brian Pauldefb0352004-05-13 15:26:51 +0000766const struct gl_texture_format _mesa_texformat_argb4444_rev = {
767 MESA_FORMAT_ARGB4444_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000768 GL_RGBA, /* BaseFormat */
769 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
770 4, /* RedBits */
771 4, /* GreenBits */
772 4, /* BlueBits */
773 4, /* AlphaBits */
774 0, /* LuminanceBits */
775 0, /* IntensityBits */
776 0, /* IndexBits */
777 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000778 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000779 2, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000780 _mesa_texstore_argb4444, /* StoreTexImageFunc */
781 fetch_texel_1d_argb4444_rev, /* FetchTexel1D */
782 fetch_texel_2d_argb4444_rev, /* FetchTexel2D */
783 fetch_texel_3d_argb4444_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000784 NULL, /* FetchTexel1Df */
785 NULL, /* FetchTexel2Df */
786 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000787 store_texel_argb4444_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000788};
789
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000790const struct gl_texture_format _mesa_texformat_argb1555 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000791 MESA_FORMAT_ARGB1555, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000792 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000793 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000794 5, /* RedBits */
795 5, /* GreenBits */
796 5, /* BlueBits */
797 1, /* AlphaBits */
798 0, /* LuminanceBits */
799 0, /* IntensityBits */
800 0, /* IndexBits */
801 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000802 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000803 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000804 _mesa_texstore_argb1555, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000805 fetch_texel_1d_argb1555, /* FetchTexel1D */
806 fetch_texel_2d_argb1555, /* FetchTexel2D */
807 fetch_texel_3d_argb1555, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000808 NULL, /* FetchTexel1Df */
809 NULL, /* FetchTexel2Df */
810 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000811 store_texel_argb1555 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000812};
813
Brian Pauldefb0352004-05-13 15:26:51 +0000814const struct gl_texture_format _mesa_texformat_argb1555_rev = {
815 MESA_FORMAT_ARGB1555_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000816 GL_RGBA, /* BaseFormat */
817 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
818 5, /* RedBits */
819 5, /* GreenBits */
820 5, /* BlueBits */
821 1, /* AlphaBits */
822 0, /* LuminanceBits */
823 0, /* IntensityBits */
824 0, /* IndexBits */
825 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000826 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000827 2, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000828 _mesa_texstore_argb1555, /* StoreTexImageFunc */
829 fetch_texel_1d_argb1555_rev, /* FetchTexel1D */
830 fetch_texel_2d_argb1555_rev, /* FetchTexel2D */
831 fetch_texel_3d_argb1555_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000832 NULL, /* FetchTexel1Df */
833 NULL, /* FetchTexel2Df */
834 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000835 store_texel_argb1555_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000836};
837
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000838const struct gl_texture_format _mesa_texformat_al88 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000839 MESA_FORMAT_AL88, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000840 GL_LUMINANCE_ALPHA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000841 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000842 0, /* RedBits */
843 0, /* GreenBits */
844 0, /* BlueBits */
845 8, /* AlphaBits */
846 8, /* LuminanceBits */
847 0, /* IntensityBits */
848 0, /* IndexBits */
849 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000850 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000851 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000852 _mesa_texstore_al88, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000853 fetch_texel_1d_al88, /* FetchTexel1D */
854 fetch_texel_2d_al88, /* FetchTexel2D */
855 fetch_texel_3d_al88, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000856 NULL, /* FetchTexel1Df */
857 NULL, /* FetchTexel2Df */
858 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000859 store_texel_al88 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000860};
861
Brian Pauldefb0352004-05-13 15:26:51 +0000862const struct gl_texture_format _mesa_texformat_al88_rev = {
863 MESA_FORMAT_AL88_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000864 GL_LUMINANCE_ALPHA, /* BaseFormat */
865 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
866 0, /* RedBits */
867 0, /* GreenBits */
868 0, /* BlueBits */
869 8, /* AlphaBits */
870 8, /* LuminanceBits */
871 0, /* IntensityBits */
872 0, /* IndexBits */
873 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000874 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000875 2, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000876 _mesa_texstore_al88, /* StoreTexImageFunc */
877 fetch_texel_1d_al88_rev, /* FetchTexel1D */
878 fetch_texel_2d_al88_rev, /* FetchTexel2D */
879 fetch_texel_3d_al88_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000880 NULL, /* FetchTexel1Df */
881 NULL, /* FetchTexel2Df */
882 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000883 store_texel_al88_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000884};
885
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000886const struct gl_texture_format _mesa_texformat_rgb332 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000887 MESA_FORMAT_RGB332, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000888 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000889 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000890 3, /* RedBits */
891 3, /* GreenBits */
892 2, /* BlueBits */
893 0, /* AlphaBits */
894 0, /* LuminanceBits */
895 0, /* IntensityBits */
896 0, /* IndexBits */
897 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000898 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000899 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000900 _mesa_texstore_rgb332, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000901 fetch_texel_1d_rgb332, /* FetchTexel1D */
902 fetch_texel_2d_rgb332, /* FetchTexel2D */
903 fetch_texel_3d_rgb332, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000904 NULL, /* FetchTexel1Df */
905 NULL, /* FetchTexel2Df */
906 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000907 store_texel_rgb332 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000908};
909
910const struct gl_texture_format _mesa_texformat_a8 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000911 MESA_FORMAT_A8, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000912 GL_ALPHA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000913 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000914 0, /* RedBits */
915 0, /* GreenBits */
916 0, /* BlueBits */
917 8, /* AlphaBits */
918 0, /* LuminanceBits */
919 0, /* IntensityBits */
920 0, /* IndexBits */
921 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000922 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000923 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000924 _mesa_texstore_a8, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000925 fetch_texel_1d_a8, /* FetchTexel1D */
926 fetch_texel_2d_a8, /* FetchTexel2D */
927 fetch_texel_3d_a8, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000928 NULL, /* FetchTexel1Df */
929 NULL, /* FetchTexel2Df */
930 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000931 store_texel_a8 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000932};
933
934const struct gl_texture_format _mesa_texformat_l8 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000935 MESA_FORMAT_L8, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000936 GL_LUMINANCE, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000937 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000938 0, /* RedBits */
939 0, /* GreenBits */
940 0, /* BlueBits */
941 0, /* AlphaBits */
942 8, /* LuminanceBits */
943 0, /* IntensityBits */
944 0, /* IndexBits */
945 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000946 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000947 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000948 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000949 fetch_texel_1d_l8, /* FetchTexel1D */
950 fetch_texel_2d_l8, /* FetchTexel2D */
951 fetch_texel_3d_l8, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000952 NULL, /* FetchTexel1Df */
953 NULL, /* FetchTexel2Df */
954 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000955 store_texel_l8 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000956};
957
958const struct gl_texture_format _mesa_texformat_i8 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000959 MESA_FORMAT_I8, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000960 GL_INTENSITY, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000961 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000962 0, /* RedBits */
963 0, /* GreenBits */
964 0, /* BlueBits */
965 0, /* AlphaBits */
966 0, /* LuminanceBits */
967 8, /* IntensityBits */
968 0, /* IndexBits */
969 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000970 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000971 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000972 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000973 fetch_texel_1d_i8, /* FetchTexel1D */
974 fetch_texel_2d_i8, /* FetchTexel2D */
975 fetch_texel_3d_i8, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000976 NULL, /* FetchTexel1Df */
977 NULL, /* FetchTexel2Df */
978 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000979 store_texel_i8 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000980};
981
982const struct gl_texture_format _mesa_texformat_ci8 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000983 MESA_FORMAT_CI8, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000984 GL_COLOR_INDEX, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000985 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000986 0, /* RedBits */
987 0, /* GreenBits */
988 0, /* BlueBits */
989 0, /* AlphaBits */
990 0, /* LuminanceBits */
991 0, /* IntensityBits */
992 8, /* IndexBits */
993 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000994 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000995 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000996 _mesa_texstore_ci8, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000997 fetch_texel_1d_ci8, /* FetchTexel1D */
998 fetch_texel_2d_ci8, /* FetchTexel2D */
999 fetch_texel_3d_ci8, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +00001000 NULL, /* FetchTexel1Df */
1001 NULL, /* FetchTexel2Df */
1002 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001003 store_texel_ci8 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001004};
1005
Brian Paulc5b99502002-09-21 16:51:25 +00001006const struct gl_texture_format _mesa_texformat_ycbcr = {
1007 MESA_FORMAT_YCBCR, /* MesaFormat */
1008 GL_YCBCR_MESA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001009 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Brian Paulc5b99502002-09-21 16:51:25 +00001010 0, /* RedBits */
1011 0, /* GreenBits */
1012 0, /* BlueBits */
1013 0, /* AlphaBits */
1014 0, /* LuminanceBits */
1015 0, /* IntensityBits */
1016 0, /* IndexBits */
1017 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001018 0, /* StencilBits */
Brian Paulc5b99502002-09-21 16:51:25 +00001019 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001020 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +00001021 fetch_texel_1d_ycbcr, /* FetchTexel1D */
1022 fetch_texel_2d_ycbcr, /* FetchTexel2D */
1023 fetch_texel_3d_ycbcr, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +00001024 NULL, /* FetchTexel1Df */
1025 NULL, /* FetchTexel2Df */
1026 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001027 store_texel_ycbcr /* StoreTexel */
Brian Paulc5b99502002-09-21 16:51:25 +00001028};
1029
Brian Paulc5b99502002-09-21 16:51:25 +00001030const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
1031 MESA_FORMAT_YCBCR_REV, /* MesaFormat */
1032 GL_YCBCR_MESA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001033 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Brian Paulc5b99502002-09-21 16:51:25 +00001034 0, /* RedBits */
1035 0, /* GreenBits */
1036 0, /* BlueBits */
1037 0, /* AlphaBits */
1038 0, /* LuminanceBits */
1039 0, /* IntensityBits */
1040 0, /* IndexBits */
1041 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001042 0, /* StencilBits */
Brian Paulc5b99502002-09-21 16:51:25 +00001043 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001044 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +00001045 fetch_texel_1d_ycbcr_rev, /* FetchTexel1D */
1046 fetch_texel_2d_ycbcr_rev, /* FetchTexel2D */
1047 fetch_texel_3d_ycbcr_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +00001048 NULL, /* FetchTexel1Df */
1049 NULL, /* FetchTexel2Df */
1050 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001051 store_texel_ycbcr_rev /* StoreTexel */
Brian Paulc5b99502002-09-21 16:51:25 +00001052};
1053
Brian Paul1ad7b992005-09-28 02:29:50 +00001054const struct gl_texture_format _mesa_texformat_z24_s8 = {
1055 MESA_FORMAT_Z24_S8, /* MesaFormat */
1056 GL_DEPTH_STENCIL_EXT, /* BaseFormat */
1057 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1058 0, /* RedBits */
1059 0, /* GreenBits */
1060 0, /* BlueBits */
1061 0, /* AlphaBits */
1062 0, /* LuminanceBits */
1063 0, /* IntensityBits */
1064 0, /* IndexBits */
1065 24, /* DepthBits */
1066 8, /* StencilBits */
1067 4, /* TexelBytes */
Brian Paul27945072005-10-01 16:09:26 +00001068 _mesa_texstore_z24_s8, /* StoreTexImageFunc */
Brian Paul1ad7b992005-09-28 02:29:50 +00001069 NULL, /* FetchTexel1D */
1070 NULL, /* FetchTexel2D */
1071 NULL, /* FetchTexel3D */
1072 fetch_texel_1d_f_z24_s8, /* FetchTexel1Df */
1073 fetch_texel_2d_f_z24_s8, /* FetchTexel2Df */
1074 fetch_texel_3d_f_z24_s8, /* FetchTexel3Df */
1075 store_texel_z24_s8 /* StoreTexel */
1076};
1077
Brian Paula9bcf752006-04-06 04:23:58 +00001078const struct gl_texture_format _mesa_texformat_z16 = {
1079 MESA_FORMAT_Z16, /* MesaFormat */
1080 GL_DEPTH_COMPONENT, /* BaseFormat */
1081 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1082 0, /* RedBits */
1083 0, /* GreenBits */
1084 0, /* BlueBits */
1085 0, /* AlphaBits */
1086 0, /* LuminanceBits */
1087 0, /* IntensityBits */
1088 0, /* IndexBits */
1089 sizeof(GLushort) * 8, /* DepthBits */
1090 0, /* StencilBits */
1091 sizeof(GLushort), /* TexelBytes */
1092 _mesa_texstore_z16, /* StoreTexImageFunc */
1093 NULL, /* FetchTexel1D */
1094 NULL, /* FetchTexel1D */
1095 NULL, /* FetchTexel1D */
1096 fetch_texel_1d_f_z16, /* FetchTexel1Df */
1097 fetch_texel_2d_f_z16, /* FetchTexel2Df */
1098 fetch_texel_3d_f_z16, /* FetchTexel3Df */
1099 store_texel_z16 /* StoreTexel */
1100};
1101
1102const struct gl_texture_format _mesa_texformat_z32 = {
1103 MESA_FORMAT_Z32, /* MesaFormat */
1104 GL_DEPTH_COMPONENT, /* BaseFormat */
1105 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1106 0, /* RedBits */
1107 0, /* GreenBits */
1108 0, /* BlueBits */
1109 0, /* AlphaBits */
1110 0, /* LuminanceBits */
1111 0, /* IntensityBits */
1112 0, /* IndexBits */
1113 sizeof(GLuint) * 8, /* DepthBits */
1114 0, /* StencilBits */
1115 sizeof(GLuint), /* TexelBytes */
1116 _mesa_texstore_z32, /* StoreTexImageFunc */
1117 NULL, /* FetchTexel1D */
1118 NULL, /* FetchTexel1D */
1119 NULL, /* FetchTexel1D */
1120 fetch_texel_1d_f_z32, /* FetchTexel1Df */
1121 fetch_texel_2d_f_z32, /* FetchTexel2Df */
1122 fetch_texel_3d_f_z32, /* FetchTexel3Df */
1123 store_texel_z32 /* StoreTexel */
1124};
1125
Keith Whitwell6dc85572003-07-17 13:43:59 +00001126/*@}*/
1127
1128
1129/***************************************************************/
1130/** \name Null format (useful for proxy textures) */
1131/*@{*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001132
1133const struct gl_texture_format _mesa_null_texformat = {
Gareth Hughes38f28662001-03-28 20:40:51 +00001134 -1, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +00001135 0, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001136 GL_NONE, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001137 0, /* RedBits */
1138 0, /* GreenBits */
1139 0, /* BlueBits */
1140 0, /* AlphaBits */
1141 0, /* LuminanceBits */
1142 0, /* IntensityBits */
1143 0, /* IndexBits */
1144 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001145 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001146 0, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001147 NULL, /* StoreTexImageFunc */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001148 fetch_null_texel, /* FetchTexel1D */
1149 fetch_null_texel, /* FetchTexel2D */
1150 fetch_null_texel, /* FetchTexel3D */
Brian Paul4f295ce2004-01-23 01:59:54 +00001151 fetch_null_texelf, /* FetchTexel1Df */
1152 fetch_null_texelf, /* FetchTexel2Df */
1153 fetch_null_texelf, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001154 store_null_texel /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001155};
1156
Keith Whitwell6dc85572003-07-17 13:43:59 +00001157/*@}*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001158
Keith Whitwell6dc85572003-07-17 13:43:59 +00001159
Keith Whitwell6dc85572003-07-17 13:43:59 +00001160/**
Brian Paulfe031082004-01-24 17:02:19 +00001161 * Choose an appropriate texture format given the format, type and
1162 * internalFormat parameters passed to glTexImage().
Keith Whitwell6dc85572003-07-17 13:43:59 +00001163 *
Brian Paulfe031082004-01-24 17:02:19 +00001164 * \param ctx the GL context.
1165 * \param internalFormat user's prefered internal texture format.
1166 * \param format incoming image pixel format.
1167 * \param type incoming image data type.
Keith Whitwell6dc85572003-07-17 13:43:59 +00001168 *
Brian Paulfe031082004-01-24 17:02:19 +00001169 * \return a pointer to a gl_texture_format object which describes the
1170 * choosen texture format, or NULL on failure.
Keith Whitwell6dc85572003-07-17 13:43:59 +00001171 *
1172 * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers
Brian Paulf959f6e2004-04-22 00:27:31 +00001173 * will typically override this function with a specialized version.
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001174 */
Brian Paul7d58f442001-04-04 21:54:20 +00001175const struct gl_texture_format *
1176_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
1177 GLenum format, GLenum type )
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001178{
Brian Paul7d58f442001-04-04 21:54:20 +00001179 (void) format;
1180 (void) type;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001181
Brian Paulf959f6e2004-04-22 00:27:31 +00001182 switch (internalFormat) {
1183 /* RGBA formats */
1184 case 4:
1185 case GL_RGBA:
Brian Paulf959f6e2004-04-22 00:27:31 +00001186 case GL_RGB10_A2:
1187 case GL_RGBA12:
1188 case GL_RGBA16:
1189 return &_mesa_texformat_rgba;
Brian Paula156b492004-05-12 01:50:30 +00001190 case GL_RGBA8:
1191 return &_mesa_texformat_rgba8888;
Brian Paulf959f6e2004-04-22 00:27:31 +00001192 case GL_RGB5_A1:
1193 return &_mesa_texformat_argb1555;
1194 case GL_RGBA2:
Brian Pauldefb0352004-05-13 15:26:51 +00001195 return &_mesa_texformat_argb4444_rev; /* just to test another format*/
Brian Paulf959f6e2004-04-22 00:27:31 +00001196 case GL_RGBA4:
1197 return &_mesa_texformat_argb4444;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001198
Brian Paulf959f6e2004-04-22 00:27:31 +00001199 /* RGB formats */
1200 case 3:
1201 case GL_RGB:
Brian Paulf959f6e2004-04-22 00:27:31 +00001202 case GL_RGB10:
1203 case GL_RGB12:
1204 case GL_RGB16:
1205 return &_mesa_texformat_rgb;
Brian Pauldefb0352004-05-13 15:26:51 +00001206 case GL_RGB8:
1207 return &_mesa_texformat_rgb888;
Brian Paulf959f6e2004-04-22 00:27:31 +00001208 case GL_R3_G3_B2:
1209 return &_mesa_texformat_rgb332;
1210 case GL_RGB4:
Brian Pauldefb0352004-05-13 15:26:51 +00001211 return &_mesa_texformat_rgb565_rev; /* just to test another format */
Brian Paulf959f6e2004-04-22 00:27:31 +00001212 case GL_RGB5:
1213 return &_mesa_texformat_rgb565;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001214
Brian Paulf959f6e2004-04-22 00:27:31 +00001215 /* Alpha formats */
1216 case GL_ALPHA:
1217 case GL_ALPHA4:
Brian Paulf959f6e2004-04-22 00:27:31 +00001218 case GL_ALPHA12:
1219 case GL_ALPHA16:
1220 return &_mesa_texformat_alpha;
Brian Paula156b492004-05-12 01:50:30 +00001221 case GL_ALPHA8:
1222 return &_mesa_texformat_a8;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001223
Brian Paulf959f6e2004-04-22 00:27:31 +00001224 /* Luminance formats */
1225 case 1:
1226 case GL_LUMINANCE:
1227 case GL_LUMINANCE4:
1228 case GL_LUMINANCE12:
1229 case GL_LUMINANCE16:
1230 return &_mesa_texformat_luminance;
1231 case GL_LUMINANCE8:
1232 return &_mesa_texformat_l8;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001233
Brian Paulf959f6e2004-04-22 00:27:31 +00001234 /* Luminance/Alpha formats */
1235 case 2:
1236 case GL_LUMINANCE_ALPHA:
1237 case GL_LUMINANCE4_ALPHA4:
1238 case GL_LUMINANCE6_ALPHA2:
1239 case GL_LUMINANCE12_ALPHA4:
1240 case GL_LUMINANCE12_ALPHA12:
1241 case GL_LUMINANCE16_ALPHA16:
1242 return &_mesa_texformat_luminance_alpha;
1243 case GL_LUMINANCE8_ALPHA8:
1244 return &_mesa_texformat_al88;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001245
Brian Paulf959f6e2004-04-22 00:27:31 +00001246 case GL_INTENSITY:
1247 case GL_INTENSITY4:
1248 case GL_INTENSITY12:
1249 case GL_INTENSITY16:
1250 return &_mesa_texformat_intensity;
1251 case GL_INTENSITY8:
1252 return &_mesa_texformat_i8;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001253
Brian Paulf959f6e2004-04-22 00:27:31 +00001254 case GL_COLOR_INDEX:
1255 case GL_COLOR_INDEX1_EXT:
1256 case GL_COLOR_INDEX2_EXT:
1257 case GL_COLOR_INDEX4_EXT:
1258 case GL_COLOR_INDEX12_EXT:
1259 case GL_COLOR_INDEX16_EXT:
Brian Paulf959f6e2004-04-22 00:27:31 +00001260 case GL_COLOR_INDEX8_EXT:
1261 return &_mesa_texformat_ci8;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001262
Brian Paulf959f6e2004-04-22 00:27:31 +00001263 default:
1264 ; /* fallthrough */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001265 }
Brian Paulf959f6e2004-04-22 00:27:31 +00001266
Brian Paul4618a9b2005-09-08 15:28:45 +00001267 if (ctx->Extensions.SGIX_depth_texture ||
1268 ctx->Extensions.ARB_depth_texture) {
Brian Paulf959f6e2004-04-22 00:27:31 +00001269 switch (internalFormat) {
1270 case GL_DEPTH_COMPONENT:
1271 case GL_DEPTH_COMPONENT24_SGIX:
1272 case GL_DEPTH_COMPONENT32_SGIX:
Brian Paula9bcf752006-04-06 04:23:58 +00001273 return &_mesa_texformat_z32;
Brian Paulf959f6e2004-04-22 00:27:31 +00001274 case GL_DEPTH_COMPONENT16_SGIX:
Brian Paula9bcf752006-04-06 04:23:58 +00001275 return &_mesa_texformat_z16;
Brian Paulf959f6e2004-04-22 00:27:31 +00001276 default:
1277 ; /* fallthrough */
1278 }
1279 }
1280
1281 if (ctx->Extensions.ARB_texture_compression) {
1282 switch (internalFormat) {
1283 case GL_COMPRESSED_ALPHA_ARB:
1284 return &_mesa_texformat_alpha;
1285 case GL_COMPRESSED_LUMINANCE_ARB:
1286 return &_mesa_texformat_luminance;
1287 case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
1288 return &_mesa_texformat_luminance_alpha;
1289 case GL_COMPRESSED_INTENSITY_ARB:
1290 return &_mesa_texformat_intensity;
1291 case GL_COMPRESSED_RGB_ARB:
1292 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1293 return &_mesa_texformat_rgb_fxt1;
1294 else if (ctx->Extensions.EXT_texture_compression_s3tc ||
1295 ctx->Extensions.S3_s3tc)
1296 return &_mesa_texformat_rgb_dxt1;
1297 else
1298 return &_mesa_texformat_rgb;
1299 case GL_COMPRESSED_RGBA_ARB:
1300 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1301 return &_mesa_texformat_rgba_fxt1;
1302 else if (ctx->Extensions.EXT_texture_compression_s3tc ||
1303 ctx->Extensions.S3_s3tc)
1304 return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
1305 else
1306 return &_mesa_texformat_rgba;
1307 default:
1308 ; /* fallthrough */
1309 }
1310 }
1311
1312 if (ctx->Extensions.MESA_ycbcr_texture) {
1313 if (internalFormat == GL_YCBCR_MESA) {
1314 if (type == GL_UNSIGNED_SHORT_8_8_MESA)
1315 return &_mesa_texformat_ycbcr;
1316 else
1317 return &_mesa_texformat_ycbcr_rev;
1318 }
1319 }
1320
1321 if (ctx->Extensions.TDFX_texture_compression_FXT1) {
1322 switch (internalFormat) {
1323 case GL_COMPRESSED_RGB_FXT1_3DFX:
1324 return &_mesa_texformat_rgb_fxt1;
1325 case GL_COMPRESSED_RGBA_FXT1_3DFX:
1326 return &_mesa_texformat_rgba_fxt1;
1327 default:
1328 ; /* fallthrough */
1329 }
1330 }
1331
1332 if (ctx->Extensions.EXT_texture_compression_s3tc) {
1333 switch (internalFormat) {
1334 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1335 return &_mesa_texformat_rgb_dxt1;
1336 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1337 return &_mesa_texformat_rgba_dxt1;
1338 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
1339 return &_mesa_texformat_rgba_dxt3;
1340 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
1341 return &_mesa_texformat_rgba_dxt5;
1342 default:
1343 ; /* fallthrough */
1344 }
1345 }
1346
1347 if (ctx->Extensions.S3_s3tc) {
1348 switch (internalFormat) {
1349 case GL_RGB_S3TC:
1350 case GL_RGB4_S3TC:
1351 return &_mesa_texformat_rgb_dxt1;
1352 case GL_RGBA_S3TC:
1353 case GL_RGBA4_S3TC:
1354 return &_mesa_texformat_rgba_dxt3;
1355 default:
1356 ; /* fallthrough */
1357 }
1358 }
1359
1360 if (ctx->Extensions.ARB_texture_float) {
1361 switch (internalFormat) {
1362 case GL_ALPHA16F_ARB:
1363 return &_mesa_texformat_alpha_float16;
1364 case GL_ALPHA32F_ARB:
1365 return &_mesa_texformat_alpha_float32;
1366 case GL_LUMINANCE16F_ARB:
1367 return &_mesa_texformat_luminance_float16;
1368 case GL_LUMINANCE32F_ARB:
1369 return &_mesa_texformat_luminance_float32;
1370 case GL_LUMINANCE_ALPHA16F_ARB:
1371 return &_mesa_texformat_luminance_alpha_float16;
1372 case GL_LUMINANCE_ALPHA32F_ARB:
1373 return &_mesa_texformat_luminance_alpha_float32;
1374 case GL_INTENSITY16F_ARB:
1375 return &_mesa_texformat_intensity_float16;
1376 case GL_INTENSITY32F_ARB:
1377 return &_mesa_texformat_intensity_float32;
1378 case GL_RGB16F_ARB:
1379 return &_mesa_texformat_rgb_float16;
1380 case GL_RGB32F_ARB:
1381 return &_mesa_texformat_rgb_float32;
1382 case GL_RGBA16F_ARB:
1383 return &_mesa_texformat_rgba_float16;
1384 case GL_RGBA32F_ARB:
1385 return &_mesa_texformat_rgba_float32;
1386 default:
1387 ; /* fallthrough */
1388 }
1389 }
1390
Brian Paul1ad7b992005-09-28 02:29:50 +00001391 if (ctx->Extensions.EXT_packed_depth_stencil) {
1392 switch (internalFormat) {
1393 case GL_DEPTH_STENCIL_EXT:
1394 case GL_DEPTH24_STENCIL8_EXT:
1395 return &_mesa_texformat_z24_s8;
1396 default:
1397 ; /* fallthrough */
1398 }
1399 }
1400
Brian Paulf959f6e2004-04-22 00:27:31 +00001401 _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
1402 return NULL;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001403}