blob: b6c0a252d366a01a9967982728874a509487c218 [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.
Roland Scheidegger5bd093b2008-12-12 05:06:48 +01006 * Copyright (c) 2008 VMware, Inc.
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00007 *
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
14 *
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000024 */
25
Keith Whitwell6dc85572003-07-17 13:43:59 +000026
Brian Paulf959f6e2004-04-22 00:27:31 +000027/**
28 * \file texformat.c
29 * Texture formats.
30 *
31 * \author Gareth Hughes
32 */
33
34
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000035#include "colormac.h"
36#include "context.h"
Brian Paulda5722b2009-09-27 18:09:23 -060037#include "texcompress.h"
38#include "texcompress_fxt1.h"
39#include "texcompress_s3tc.h"
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000040#include "texformat.h"
Brian Paul36237332004-04-22 00:54:53 +000041#include "texstore.h"
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000042
Brian Paulf959f6e2004-04-22 00:27:31 +000043
Brian Paul8d214bc2006-08-03 03:20:52 +000044#if FEATURE_EXT_texture_sRGB
45
46/**
47 * Convert an 8-bit sRGB value from non-linear space to a
48 * linear RGB value in [0, 1].
49 * Implemented with a 256-entry lookup table.
50 */
51static INLINE GLfloat
52nonlinear_to_linear(GLubyte cs8)
53{
54 static GLfloat table[256];
55 static GLboolean tableReady = GL_FALSE;
56 if (!tableReady) {
57 /* compute lookup table now */
58 GLuint i;
59 for (i = 0; i < 256; i++) {
60 const GLfloat cs = UBYTE_TO_FLOAT(i);
61 if (cs <= 0.04045) {
Michal Krol9614eac2008-07-15 11:15:27 +020062 table[i] = cs / 12.92f;
Brian Paul8d214bc2006-08-03 03:20:52 +000063 }
64 else {
Michal Krol9614eac2008-07-15 11:15:27 +020065 table[i] = (GLfloat) _mesa_pow((cs + 0.055) / 1.055, 2.4);
Brian Paul8d214bc2006-08-03 03:20:52 +000066 }
67 }
68 tableReady = GL_TRUE;
69 }
70 return table[cs8];
71}
72
73
74#endif /* FEATURE_EXT_texture_sRGB */
75
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000076
Keith Whitwell6dc85572003-07-17 13:43:59 +000077/* Texel fetch routines for all supported formats
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000078 */
79#define DIM 1
80#include "texformat_tmp.h"
81
82#define DIM 2
83#include "texformat_tmp.h"
84
85#define DIM 3
86#include "texformat_tmp.h"
87
Keith Whitwell6dc85572003-07-17 13:43:59 +000088/**
89 * Null texel fetch function.
90 *
91 * Have to have this so the FetchTexel function pointer is never NULL.
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000092 */
93static void fetch_null_texel( const struct gl_texture_image *texImage,
Brian Paul4f295ce2004-01-23 01:59:54 +000094 GLint i, GLint j, GLint k, GLchan *texel )
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000095{
Brian Paula6c423d2004-08-25 15:59:48 +000096 (void) texImage; (void) i; (void) j; (void) k;
Brian Paul4f295ce2004-01-23 01:59:54 +000097 texel[RCOMP] = 0;
98 texel[GCOMP] = 0;
99 texel[BCOMP] = 0;
100 texel[ACOMP] = 0;
101 _mesa_warning(NULL, "fetch_null_texel() called!");
102}
103
104static void fetch_null_texelf( const struct gl_texture_image *texImage,
105 GLint i, GLint j, GLint k, GLfloat *texel )
106{
Brian Paula6c423d2004-08-25 15:59:48 +0000107 (void) texImage; (void) i; (void) j; (void) k;
Brian Paul4f295ce2004-01-23 01:59:54 +0000108 texel[RCOMP] = 0.0;
109 texel[GCOMP] = 0.0;
110 texel[BCOMP] = 0.0;
111 texel[ACOMP] = 0.0;
112 _mesa_warning(NULL, "fetch_null_texelf() called!");
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000113}
114
Brian Paule4b23562005-05-04 20:11:35 +0000115static void store_null_texel(struct gl_texture_image *texImage,
116 GLint i, GLint j, GLint k, const void *texel)
117{
Brian Paula9bcf752006-04-06 04:23:58 +0000118 (void) texImage;
119 (void) i;
120 (void) j;
121 (void) k;
122 (void) texel;
Brian Paule4b23562005-05-04 20:11:35 +0000123 /* no-op */
124}
125
126
Brian Paul63b5b8e2005-09-15 01:55:40 +0000127/**
128 * Notes about the predefined gl_texture_formats:
129 *
130 * 1. There are 1D, 2D and 3D functions for fetching texels from texture
131 * images, returning both GLchan values and GLfloat values. (six
132 * functions in total)
133 * You don't have to provide both the GLchan and GLfloat functions;
134 * just one or the other is OK. Mesa will use an "adaptor" to convert
135 * between GLchan/GLfloat when needed.
136 * Since the adaptors have small performance penalty, we provide both
137 * GLchan and GLfloat functions for some common formats like RGB, RGBA.
138 */
139
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000140
Keith Whitwell6dc85572003-07-17 13:43:59 +0000141/***************************************************************/
142/** \name Default GLchan-based formats */
143/*@{*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000144
145const struct gl_texture_format _mesa_texformat_rgba = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000146 MESA_FORMAT_RGBA, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000147 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000148 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000149 CHAN_BITS, /* RedBits */
150 CHAN_BITS, /* GreenBits */
151 CHAN_BITS, /* BlueBits */
152 CHAN_BITS, /* AlphaBits */
153 0, /* LuminanceBits */
154 0, /* IntensityBits */
155 0, /* IndexBits */
156 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000157 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000158 4 * sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000159 _mesa_texstore_rgba, /* StoreTexImageFunc */
Brian Paul61112832009-03-09 20:34:24 -0600160 NULL, /* FetchTexel1D */
161 NULL, /* FetchTexel2D */
162 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600163 NULL, /* FetchTexel1Df */
164 NULL, /* FetchTexel2Df */
165 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000166 store_texel_rgba /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000167};
168
169const struct gl_texture_format _mesa_texformat_rgb = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000170 MESA_FORMAT_RGB, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000171 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000172 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000173 CHAN_BITS, /* RedBits */
174 CHAN_BITS, /* GreenBits */
175 CHAN_BITS, /* BlueBits */
176 0, /* AlphaBits */
177 0, /* LuminanceBits */
178 0, /* IntensityBits */
179 0, /* IndexBits */
180 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000181 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000182 3 * sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000183 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul61112832009-03-09 20:34:24 -0600184 NULL, /* FetchTexel1D */
185 NULL, /* FetchTexel2D */
186 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600187 NULL, /* FetchTexel1Df */
188 NULL, /* FetchTexel2Df */
189 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000190 store_texel_rgb /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000191};
192
193const struct gl_texture_format _mesa_texformat_alpha = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000194 MESA_FORMAT_ALPHA, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000195 GL_ALPHA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000196 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000197 0, /* RedBits */
198 0, /* GreenBits */
199 0, /* BlueBits */
200 CHAN_BITS, /* AlphaBits */
201 0, /* LuminanceBits */
202 0, /* IntensityBits */
203 0, /* IndexBits */
204 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000205 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000206 sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000207 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul61112832009-03-09 20:34:24 -0600208 NULL, /* FetchTexel1D */
209 NULL, /* FetchTexel2D */
210 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600211 NULL, /* FetchTexel1Df */
212 NULL, /* FetchTexel2Df */
213 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000214 store_texel_alpha /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000215};
216
217const struct gl_texture_format _mesa_texformat_luminance = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000218 MESA_FORMAT_LUMINANCE, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000219 GL_LUMINANCE, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000220 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000221 0, /* RedBits */
222 0, /* GreenBits */
223 0, /* BlueBits */
224 0, /* AlphaBits */
225 CHAN_BITS, /* LuminanceBits */
226 0, /* IntensityBits */
227 0, /* IndexBits */
228 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000229 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000230 sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000231 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul61112832009-03-09 20:34:24 -0600232 NULL, /* FetchTexel1D */
233 NULL, /* FetchTexel2D */
234 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600235 NULL, /* FetchTexel1Df */
236 NULL, /* FetchTexel2Df */
237 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000238 store_texel_luminance /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000239};
240
241const struct gl_texture_format _mesa_texformat_luminance_alpha = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000242 MESA_FORMAT_LUMINANCE_ALPHA, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000243 GL_LUMINANCE_ALPHA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000244 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000245 0, /* RedBits */
246 0, /* GreenBits */
247 0, /* BlueBits */
248 CHAN_BITS, /* AlphaBits */
249 CHAN_BITS, /* LuminanceBits */
250 0, /* IntensityBits */
251 0, /* IndexBits */
252 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000253 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000254 2 * sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000255 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul61112832009-03-09 20:34:24 -0600256 NULL, /* FetchTexel1D */
257 NULL, /* FetchTexel2D */
258 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600259 NULL, /* FetchTexel1Df */
260 NULL, /* FetchTexel2Df */
261 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000262 store_texel_luminance_alpha /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000263};
264
265const struct gl_texture_format _mesa_texformat_intensity = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000266 MESA_FORMAT_INTENSITY, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000267 GL_INTENSITY, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000268 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000269 0, /* RedBits */
270 0, /* GreenBits */
271 0, /* BlueBits */
272 0, /* AlphaBits */
273 0, /* LuminanceBits */
274 CHAN_BITS, /* IntensityBits */
275 0, /* IndexBits */
276 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000277 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000278 sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000279 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul61112832009-03-09 20:34:24 -0600280 NULL, /* FetchTexel1D */
281 NULL, /* FetchTexel2D */
282 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600283 NULL, /* FetchTexel1Df */
284 NULL, /* FetchTexel2Df */
285 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000286 store_texel_intensity /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000287};
288
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000289
Brian Paul8d214bc2006-08-03 03:20:52 +0000290#if FEATURE_EXT_texture_sRGB
291
292const struct gl_texture_format _mesa_texformat_srgb8 = {
293 MESA_FORMAT_SRGB8, /* MesaFormat */
294 GL_RGB, /* BaseFormat */
295 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
296 8, /* RedBits */
297 8, /* GreenBits */
298 8, /* BlueBits */
299 0, /* AlphaBits */
300 0, /* LuminanceBits */
301 0, /* IntensityBits */
302 0, /* IndexBits */
303 0, /* DepthBits */
304 0, /* StencilBits */
305 3, /* TexelBytes */
306 _mesa_texstore_srgb8, /* StoreTexImageFunc */
307 NULL, /* FetchTexel1D */
308 NULL, /* FetchTexel2D */
309 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600310 NULL, /* FetchTexel1Df */
311 NULL, /* FetchTexel2Df */
312 NULL, /* FetchTexel3Df */
Brian Paul8d214bc2006-08-03 03:20:52 +0000313 store_texel_srgb8 /* StoreTexel */
314};
315
316const struct gl_texture_format _mesa_texformat_srgba8 = {
317 MESA_FORMAT_SRGBA8, /* MesaFormat */
318 GL_RGBA, /* BaseFormat */
319 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
320 8, /* RedBits */
321 8, /* GreenBits */
322 8, /* BlueBits */
323 8, /* AlphaBits */
324 0, /* LuminanceBits */
325 0, /* IntensityBits */
326 0, /* IndexBits */
327 0, /* DepthBits */
328 0, /* StencilBits */
329 4, /* TexelBytes */
330 _mesa_texstore_srgba8, /* StoreTexImageFunc */
331 NULL, /* FetchTexel1D */
332 NULL, /* FetchTexel2D */
333 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600334 NULL, /* FetchTexel1Df */
335 NULL, /* FetchTexel2Df */
336 NULL, /* FetchTexel3Df */
Brian Paul8d214bc2006-08-03 03:20:52 +0000337 store_texel_srgba8 /* StoreTexel */
338};
339
Roland Scheidegger5bd093b2008-12-12 05:06:48 +0100340const struct gl_texture_format _mesa_texformat_sargb8 = {
341 MESA_FORMAT_SARGB8, /* MesaFormat */
342 GL_RGBA, /* BaseFormat */
343 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
344 8, /* RedBits */
345 8, /* GreenBits */
346 8, /* BlueBits */
347 8, /* AlphaBits */
348 0, /* LuminanceBits */
349 0, /* IntensityBits */
350 0, /* IndexBits */
351 0, /* DepthBits */
352 0, /* StencilBits */
353 4, /* TexelBytes */
354 _mesa_texstore_sargb8, /* StoreTexImageFunc */
355 NULL, /* FetchTexel1D */
356 NULL, /* FetchTexel2D */
357 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600358 NULL, /* FetchTexel1Df */
359 NULL, /* FetchTexel2Df */
360 NULL, /* FetchTexel3Df */
Roland Scheidegger5bd093b2008-12-12 05:06:48 +0100361 store_texel_sargb8 /* StoreTexel */
362};
363
Brian Paul8d214bc2006-08-03 03:20:52 +0000364const struct gl_texture_format _mesa_texformat_sl8 = {
365 MESA_FORMAT_SL8, /* MesaFormat */
366 GL_LUMINANCE, /* BaseFormat */
367 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
368 0, /* RedBits */
369 0, /* GreenBits */
370 0, /* BlueBits */
371 0, /* AlphaBits */
372 8, /* LuminanceBits */
373 0, /* IntensityBits */
374 0, /* IndexBits */
375 0, /* DepthBits */
376 0, /* StencilBits */
377 1, /* TexelBytes */
378 _mesa_texstore_sl8, /* StoreTexImageFunc */
379 NULL, /* FetchTexel1D */
380 NULL, /* FetchTexel2D */
381 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600382 NULL, /* FetchTexel1Df */
383 NULL, /* FetchTexel2Df */
384 NULL, /* FetchTexel3Df */
Brian Paul8d214bc2006-08-03 03:20:52 +0000385 store_texel_sl8 /* StoreTexel */
386};
387
Roland Scheidegger02a579f2009-03-28 01:19:49 +0100388/* Note: this format name looks like a misnomer, make it sal8? */
Brian Paul8d214bc2006-08-03 03:20:52 +0000389const struct gl_texture_format _mesa_texformat_sla8 = {
390 MESA_FORMAT_SLA8, /* MesaFormat */
391 GL_LUMINANCE_ALPHA, /* BaseFormat */
392 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
393 0, /* RedBits */
394 0, /* GreenBits */
395 0, /* BlueBits */
396 8, /* AlphaBits */
397 8, /* LuminanceBits */
398 0, /* IntensityBits */
399 0, /* IndexBits */
400 0, /* DepthBits */
401 0, /* StencilBits */
402 2, /* TexelBytes */
403 _mesa_texstore_sla8, /* StoreTexImageFunc */
404 NULL, /* FetchTexel1D */
405 NULL, /* FetchTexel2D */
406 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600407 NULL, /* FetchTexel1Df */
408 NULL, /* FetchTexel2Df */
409 NULL, /* FetchTexel3Df */
Brian Paul8d214bc2006-08-03 03:20:52 +0000410 store_texel_sla8 /* StoreTexel */
411};
412
413#endif /* FEATURE_EXT_texture_sRGB */
414
Brian Paulfe031082004-01-24 17:02:19 +0000415const struct gl_texture_format _mesa_texformat_rgba_float32 = {
416 MESA_FORMAT_RGBA_FLOAT32, /* MesaFormat */
417 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000418 GL_FLOAT, /* DataType */
Brian Paulfe031082004-01-24 17:02:19 +0000419 8 * sizeof(GLfloat), /* RedBits */
420 8 * sizeof(GLfloat), /* GreenBits */
421 8 * sizeof(GLfloat), /* BlueBits */
422 8 * sizeof(GLfloat), /* AlphaBits */
423 0, /* LuminanceBits */
424 0, /* IntensityBits */
425 0, /* IndexBits */
426 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000427 0, /* StencilBits */
Brian Paulfe031082004-01-24 17:02:19 +0000428 4 * sizeof(GLfloat), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000429 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000430 NULL, /* FetchTexel1D */
431 NULL, /* FetchTexel1D */
432 NULL, /* FetchTexel1D */
Brian Paulda5722b2009-09-27 18:09:23 -0600433 NULL, /* FetchTexel1Df */
434 NULL, /* FetchTexel1Df */
435 NULL, /* FetchTexel1Df */
Brian Paule4b23562005-05-04 20:11:35 +0000436 store_texel_rgba_f32 /* StoreTexel */
Brian Paulfe031082004-01-24 17:02:19 +0000437};
438
439const struct gl_texture_format _mesa_texformat_rgba_float16 = {
440 MESA_FORMAT_RGBA_FLOAT16, /* MesaFormat */
441 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000442 GL_FLOAT, /* DataType */
443 8 * sizeof(GLhalfARB), /* RedBits */
444 8 * sizeof(GLhalfARB), /* GreenBits */
445 8 * sizeof(GLhalfARB), /* BlueBits */
446 8 * sizeof(GLhalfARB), /* AlphaBits */
Brian Paulfe031082004-01-24 17:02:19 +0000447 0, /* LuminanceBits */
448 0, /* IntensityBits */
449 0, /* IndexBits */
450 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000451 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000452 4 * sizeof(GLhalfARB), /* TexelBytes */
453 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000454 NULL, /* FetchTexel1D */
455 NULL, /* FetchTexel1D */
456 NULL, /* FetchTexel1D */
Brian Paulda5722b2009-09-27 18:09:23 -0600457 NULL, /* FetchTexel1Df */
458 NULL, /* FetchTexel1Df */
459 NULL, /* FetchTexel1Df */
Brian Paule4b23562005-05-04 20:11:35 +0000460 store_texel_rgba_f16 /* StoreTexel */
Brian Paulfe031082004-01-24 17:02:19 +0000461};
462
463const struct gl_texture_format _mesa_texformat_rgb_float32 = {
464 MESA_FORMAT_RGB_FLOAT32, /* MesaFormat */
465 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000466 GL_FLOAT, /* DataType */
Brian Paulfe031082004-01-24 17:02:19 +0000467 8 * sizeof(GLfloat), /* RedBits */
468 8 * sizeof(GLfloat), /* GreenBits */
469 8 * sizeof(GLfloat), /* BlueBits */
470 0, /* AlphaBits */
471 0, /* LuminanceBits */
472 0, /* IntensityBits */
473 0, /* IndexBits */
474 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000475 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000476 3 * sizeof(GLfloat), /* TexelBytes */
477 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000478 NULL, /* FetchTexel1D */
479 NULL, /* FetchTexel1D */
480 NULL, /* FetchTexel1D */
Brian Paulda5722b2009-09-27 18:09:23 -0600481 NULL, /* FetchTexel1Df */
482 NULL, /* FetchTexel1Df */
483 NULL, /* FetchTexel1Df */
Brian Paule4b23562005-05-04 20:11:35 +0000484 store_texel_rgb_f32 /* StoreTexel */
Brian Paulfe031082004-01-24 17:02:19 +0000485};
486
487const struct gl_texture_format _mesa_texformat_rgb_float16 = {
488 MESA_FORMAT_RGB_FLOAT16, /* MesaFormat */
489 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000490 GL_FLOAT, /* DataType */
491 8 * sizeof(GLhalfARB), /* RedBits */
492 8 * sizeof(GLhalfARB), /* GreenBits */
493 8 * sizeof(GLhalfARB), /* BlueBits */
Brian Paulfe031082004-01-24 17:02:19 +0000494 0, /* AlphaBits */
495 0, /* LuminanceBits */
496 0, /* IntensityBits */
497 0, /* IndexBits */
498 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000499 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000500 3 * sizeof(GLhalfARB), /* TexelBytes */
501 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000502 NULL, /* FetchTexel1D */
503 NULL, /* FetchTexel1D */
504 NULL, /* FetchTexel1D */
Brian Paulda5722b2009-09-27 18:09:23 -0600505 NULL, /* FetchTexel1Df */
506 NULL, /* FetchTexel1Df */
507 NULL, /* FetchTexel1Df */
Brian Paule4b23562005-05-04 20:11:35 +0000508 store_texel_rgb_f16 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000509};
510
511const struct gl_texture_format _mesa_texformat_alpha_float32 = {
512 MESA_FORMAT_ALPHA_FLOAT32, /* MesaFormat */
513 GL_ALPHA, /* BaseFormat */
514 GL_FLOAT, /* DataType */
515 0, /* RedBits */
516 0, /* GreenBits */
517 0, /* BlueBits */
518 8 * sizeof(GLfloat), /* AlphaBits */
519 0, /* LuminanceBits */
520 0, /* IntensityBits */
521 0, /* IndexBits */
522 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000523 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000524 1 * sizeof(GLfloat), /* TexelBytes */
525 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000526 NULL, /* FetchTexel1D */
527 NULL, /* FetchTexel1D */
528 NULL, /* FetchTexel1D */
Brian Paulda5722b2009-09-27 18:09:23 -0600529 NULL, /* FetchTexel1Df */
530 NULL, /* FetchTexel1Df */
531 NULL, /* FetchTexel1Df */
Brian Paule4b23562005-05-04 20:11:35 +0000532 store_texel_alpha_f32 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000533};
534
535const struct gl_texture_format _mesa_texformat_alpha_float16 = {
536 MESA_FORMAT_ALPHA_FLOAT16, /* MesaFormat */
537 GL_ALPHA, /* BaseFormat */
538 GL_FLOAT, /* DataType */
539 0, /* RedBits */
540 0, /* GreenBits */
541 0, /* BlueBits */
542 8 * sizeof(GLhalfARB), /* AlphaBits */
543 0, /* LuminanceBits */
544 0, /* IntensityBits */
545 0, /* IndexBits */
546 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000547 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000548 1 * sizeof(GLhalfARB), /* TexelBytes */
549 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000550 NULL, /* FetchTexel1D */
551 NULL, /* FetchTexel1D */
552 NULL, /* FetchTexel1D */
Brian Paulda5722b2009-09-27 18:09:23 -0600553 NULL, /* FetchTexel1Df */
554 NULL, /* FetchTexel1Df */
555 NULL, /* FetchTexel1Df */
Brian Paule4b23562005-05-04 20:11:35 +0000556 store_texel_alpha_f16 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000557};
558
559const struct gl_texture_format _mesa_texformat_luminance_float32 = {
560 MESA_FORMAT_LUMINANCE_FLOAT32, /* MesaFormat */
561 GL_LUMINANCE, /* BaseFormat */
562 GL_FLOAT, /* DataType */
563 0, /* RedBits */
564 0, /* GreenBits */
565 0, /* BlueBits */
566 0, /* AlphaBits */
567 8 * sizeof(GLfloat), /* LuminanceBits */
568 0, /* IntensityBits */
569 0, /* IndexBits */
570 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000571 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000572 1 * sizeof(GLfloat), /* TexelBytes */
573 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000574 NULL, /* FetchTexel1D */
575 NULL, /* FetchTexel2D */
576 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600577 NULL, /* FetchTexel1Df */
578 NULL, /* FetchTexel2Df */
579 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000580 store_texel_luminance_f32 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000581};
582
583const struct gl_texture_format _mesa_texformat_luminance_float16 = {
584 MESA_FORMAT_LUMINANCE_FLOAT16, /* MesaFormat */
585 GL_LUMINANCE, /* BaseFormat */
586 GL_FLOAT, /* DataType */
587 0, /* RedBits */
588 0, /* GreenBits */
589 0, /* BlueBits */
590 0, /* AlphaBits */
591 8 * sizeof(GLhalfARB), /* LuminanceBits */
592 0, /* IntensityBits */
593 0, /* IndexBits */
594 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000595 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000596 1 * sizeof(GLhalfARB), /* TexelBytes */
597 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000598 NULL, /* FetchTexel1D */
599 NULL, /* FetchTexel2D */
600 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600601 NULL, /* FetchTexel1Df */
602 NULL, /* FetchTexel2Df */
603 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000604 store_texel_luminance_f16 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000605};
606
607const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
608 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, /* MesaFormat */
609 GL_LUMINANCE_ALPHA, /* BaseFormat */
610 GL_FLOAT, /* DataType */
611 0, /* RedBits */
612 0, /* GreenBits */
613 0, /* BlueBits */
614 8 * sizeof(GLfloat), /* AlphaBits */
615 8 * sizeof(GLfloat), /* LuminanceBits */
616 0, /* IntensityBits */
617 0, /* IndexBits */
618 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000619 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000620 2 * sizeof(GLfloat), /* TexelBytes */
621 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000622 NULL, /* FetchTexel1D */
623 NULL, /* FetchTexel2D */
624 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600625 NULL, /* FetchTexel1Df */
626 NULL, /* FetchTexel2Df */
627 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000628 store_texel_luminance_alpha_f32 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000629};
630
631const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
632 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, /* MesaFormat */
633 GL_LUMINANCE_ALPHA, /* BaseFormat */
634 GL_FLOAT, /* DataType */
635 0, /* RedBits */
636 0, /* GreenBits */
637 0, /* BlueBits */
638 8 * sizeof(GLhalfARB), /* AlphaBits */
639 8 * sizeof(GLhalfARB), /* LuminanceBits */
640 0, /* IntensityBits */
641 0, /* IndexBits */
642 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000643 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000644 2 * sizeof(GLhalfARB), /* TexelBytes */
645 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000646 NULL, /* FetchTexel1D */
647 NULL, /* FetchTexel2D */
648 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600649 NULL, /* FetchTexel1Df */
650 NULL, /* FetchTexel2Df */
651 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000652 store_texel_luminance_alpha_f16 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000653};
654
655const struct gl_texture_format _mesa_texformat_intensity_float32 = {
656 MESA_FORMAT_INTENSITY_FLOAT32, /* MesaFormat */
657 GL_INTENSITY, /* BaseFormat */
658 GL_FLOAT, /* DataType */
659 0, /* RedBits */
660 0, /* GreenBits */
661 0, /* BlueBits */
662 0, /* AlphaBits */
663 0, /* LuminanceBits */
664 8 * sizeof(GLfloat), /* IntensityBits */
665 0, /* IndexBits */
666 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000667 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000668 1 * sizeof(GLfloat), /* TexelBytes */
669 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000670 NULL, /* FetchTexel1D */
671 NULL, /* FetchTexel2D */
672 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600673 NULL, /* FetchTexel1Df */
674 NULL, /* FetchTexel2Df */
675 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000676 store_texel_intensity_f32 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000677};
678
679const struct gl_texture_format _mesa_texformat_intensity_float16 = {
680 MESA_FORMAT_INTENSITY_FLOAT16, /* MesaFormat */
681 GL_INTENSITY, /* BaseFormat */
682 GL_FLOAT, /* DataType */
683 0, /* RedBits */
684 0, /* GreenBits */
685 0, /* BlueBits */
686 0, /* AlphaBits */
687 0, /* LuminanceBits */
688 8 * sizeof(GLhalfARB), /* IntensityBits */
689 0, /* IndexBits */
690 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000691 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000692 1 * sizeof(GLhalfARB), /* TexelBytes */
693 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000694 NULL, /* FetchTexel1D */
695 NULL, /* FetchTexel2D */
696 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600697 NULL, /* FetchTexel1Df */
698 NULL, /* FetchTexel2Df */
699 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000700 store_texel_intensity_f16 /* StoreTexel */
Brian Paulfe031082004-01-24 17:02:19 +0000701};
702
Roland Scheidegger114152e2009-03-12 15:01:16 +0100703const struct gl_texture_format _mesa_texformat_dudv8 = {
704 MESA_FORMAT_DUDV8, /* MesaFormat */
705 GL_DUDV_ATI, /* BaseFormat */
Roland Scheideggerc6a6cc12009-03-27 19:39:52 +0100706 GL_SIGNED_NORMALIZED, /* DataType */
Roland Scheidegger114152e2009-03-12 15:01:16 +0100707 /* maybe should add dudvBits field, but spec seems to be
708 lacking the ability to query with GetTexLevelParameter anyway */
709 0, /* RedBits */
710 0, /* GreenBits */
711 0, /* BlueBits */
712 0, /* AlphaBits */
713 0, /* LuminanceBits */
714 0, /* IntensityBits */
715 0, /* IndexBits */
716 0, /* DepthBits */
717 0, /* StencilBits */
718 2, /* TexelBytes */
719 _mesa_texstore_dudv8, /* StoreTexImageFunc */
720 NULL, /* FetchTexel1D */
Brian Paul4681a1d2009-03-13 08:36:51 -0600721 NULL, /* FetchTexel2D */
Roland Scheidegger114152e2009-03-12 15:01:16 +0100722 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600723 NULL, /* FetchTexel1Df */
724 NULL, /* FetchTexel2Df */
725 NULL, /* FetchTexel3Df */
Roland Scheidegger114152e2009-03-12 15:01:16 +0100726 NULL /* StoreTexel */
727};
Brian Paulfe031082004-01-24 17:02:19 +0000728
Roland Scheideggerc6a6cc12009-03-27 19:39:52 +0100729const struct gl_texture_format _mesa_texformat_signed_rgba8888 = {
730 MESA_FORMAT_SIGNED_RGBA8888, /* MesaFormat */
731 GL_RGBA, /* BaseFormat */
732 GL_SIGNED_NORMALIZED, /* DataType */
733 8, /* RedBits */
734 8, /* GreenBits */
735 8, /* BlueBits */
736 8, /* AlphaBits */
737 0, /* LuminanceBits */
738 0, /* IntensityBits */
739 0, /* IndexBits */
740 0, /* DepthBits */
741 0, /* StencilBits */
742 4, /* TexelBytes */
743 _mesa_texstore_signed_rgba8888, /* StoreTexImageFunc */
744 NULL, /* FetchTexel1D */
745 NULL, /* FetchTexel2D */
746 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600747 NULL, /* FetchTexel1Df */
748 NULL, /* FetchTexel2Df */
749 NULL, /* FetchTexel3Df */
Roland Scheideggerc6a6cc12009-03-27 19:39:52 +0100750 store_texel_signed_rgba8888 /* StoreTexel */
751};
752
Roland Scheideggerbb386a12009-03-27 21:59:33 +0100753const struct gl_texture_format _mesa_texformat_signed_rgba8888_rev = {
754 MESA_FORMAT_SIGNED_RGBA8888_REV, /* MesaFormat */
755 GL_RGBA, /* BaseFormat */
756 GL_SIGNED_NORMALIZED, /* DataType */
757 8, /* RedBits */
758 8, /* GreenBits */
759 8, /* BlueBits */
760 8, /* AlphaBits */
761 0, /* LuminanceBits */
762 0, /* IntensityBits */
763 0, /* IndexBits */
764 0, /* DepthBits */
765 0, /* StencilBits */
766 4, /* TexelBytes */
767 _mesa_texstore_signed_rgba8888, /* StoreTexImageFunc */
768 NULL, /* FetchTexel1D */
769 NULL, /* FetchTexel2D */
770 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600771 NULL, /* FetchTexel1Df */
772 NULL, /* FetchTexel2Df */
773 NULL, /* FetchTexel3Df */
Roland Scheideggerbb386a12009-03-27 21:59:33 +0100774 store_texel_signed_rgba8888_rev /* StoreTexel */
775};
776
Keith Whitwell6dc85572003-07-17 13:43:59 +0000777/*@}*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000778
Keith Whitwell6dc85572003-07-17 13:43:59 +0000779
780/***************************************************************/
781/** \name Hardware formats */
782/*@{*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000783
784const struct gl_texture_format _mesa_texformat_rgba8888 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000785 MESA_FORMAT_RGBA8888, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000786 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000787 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000788 8, /* RedBits */
789 8, /* GreenBits */
790 8, /* BlueBits */
791 8, /* AlphaBits */
792 0, /* LuminanceBits */
793 0, /* IntensityBits */
794 0, /* IndexBits */
795 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000796 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000797 4, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000798 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -0600799 NULL, /* FetchTexel1D */
800 NULL, /* FetchTexel2D */
801 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600802 NULL, /* FetchTexel1Df */
803 NULL, /* FetchTexel2Df */
804 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000805 store_texel_rgba8888 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000806};
807
Brian Pauldefb0352004-05-13 15:26:51 +0000808const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
809 MESA_FORMAT_RGBA8888_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000810 GL_RGBA, /* BaseFormat */
811 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
812 8, /* RedBits */
813 8, /* GreenBits */
814 8, /* BlueBits */
815 8, /* AlphaBits */
816 0, /* LuminanceBits */
817 0, /* IntensityBits */
818 0, /* IndexBits */
819 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000820 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000821 4, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000822 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -0600823 NULL, /* FetchTexel1D */
824 NULL, /* FetchTexel2D */
825 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600826 NULL, /* FetchTexel1Df */
827 NULL, /* FetchTexel2Df */
828 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000829 store_texel_rgba8888_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000830};
831
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000832const struct gl_texture_format _mesa_texformat_argb8888 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000833 MESA_FORMAT_ARGB8888, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000834 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000835 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000836 8, /* RedBits */
837 8, /* GreenBits */
838 8, /* BlueBits */
839 8, /* AlphaBits */
840 0, /* LuminanceBits */
841 0, /* IntensityBits */
842 0, /* IndexBits */
843 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000844 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000845 4, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000846 _mesa_texstore_argb8888, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -0600847 NULL, /* FetchTexel1D */
848 NULL, /* FetchTexel2D */
849 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600850 NULL, /* FetchTexel1Df */
851 NULL, /* FetchTexel2Df */
852 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000853 store_texel_argb8888 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000854};
855
Brian Pauldefb0352004-05-13 15:26:51 +0000856const struct gl_texture_format _mesa_texformat_argb8888_rev = {
857 MESA_FORMAT_ARGB8888_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000858 GL_RGBA, /* BaseFormat */
859 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
860 8, /* RedBits */
861 8, /* GreenBits */
862 8, /* BlueBits */
863 8, /* AlphaBits */
864 0, /* LuminanceBits */
865 0, /* IntensityBits */
866 0, /* IndexBits */
867 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000868 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000869 4, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000870 _mesa_texstore_argb8888, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -0600871 NULL, /* FetchTexel1D */
872 NULL, /* FetchTexel2D */
873 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600874 NULL, /* FetchTexel1Df */
875 NULL, /* FetchTexel2Df */
876 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000877 store_texel_argb8888_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000878};
879
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000880const struct gl_texture_format _mesa_texformat_rgb888 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000881 MESA_FORMAT_RGB888, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000882 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000883 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000884 8, /* RedBits */
885 8, /* GreenBits */
886 8, /* BlueBits */
887 0, /* AlphaBits */
888 0, /* LuminanceBits */
889 0, /* IntensityBits */
890 0, /* IndexBits */
891 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000892 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000893 3, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000894 _mesa_texstore_rgb888, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -0600895 NULL, /* FetchTexel1D */
896 NULL, /* FetchTexel2D */
897 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600898 NULL, /* FetchTexel1Df */
899 NULL, /* FetchTexel2Df */
900 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000901 store_texel_rgb888 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000902};
903
Brian Paula156b492004-05-12 01:50:30 +0000904const struct gl_texture_format _mesa_texformat_bgr888 = {
905 MESA_FORMAT_BGR888, /* MesaFormat */
906 GL_RGB, /* BaseFormat */
907 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
908 8, /* RedBits */
909 8, /* GreenBits */
910 8, /* BlueBits */
911 0, /* AlphaBits */
912 0, /* LuminanceBits */
913 0, /* IntensityBits */
914 0, /* IndexBits */
915 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000916 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000917 3, /* TexelBytes */
918 _mesa_texstore_bgr888, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -0600919 NULL, /* FetchTexel1D */
920 NULL, /* FetchTexel2D */
921 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600922 NULL, /* FetchTexel1Df */
923 NULL, /* FetchTexel2Df */
924 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000925 store_texel_bgr888 /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000926};
927
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000928const struct gl_texture_format _mesa_texformat_rgb565 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000929 MESA_FORMAT_RGB565, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000930 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000931 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000932 5, /* RedBits */
933 6, /* GreenBits */
934 5, /* BlueBits */
935 0, /* AlphaBits */
936 0, /* LuminanceBits */
937 0, /* IntensityBits */
938 0, /* IndexBits */
939 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000940 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000941 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000942 _mesa_texstore_rgb565, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -0600943 NULL, /* FetchTexel1D */
944 NULL, /* FetchTexel2D */
945 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600946 NULL, /* FetchTexel1Df */
947 NULL, /* FetchTexel2Df */
948 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000949 store_texel_rgb565 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000950};
951
Brian Pauldefb0352004-05-13 15:26:51 +0000952const struct gl_texture_format _mesa_texformat_rgb565_rev = {
953 MESA_FORMAT_RGB565_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000954 GL_RGB, /* BaseFormat */
955 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
956 5, /* RedBits */
957 6, /* GreenBits */
958 5, /* BlueBits */
959 0, /* AlphaBits */
960 0, /* LuminanceBits */
961 0, /* IntensityBits */
962 0, /* IndexBits */
963 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000964 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000965 2, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000966 _mesa_texstore_rgb565, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -0600967 NULL, /* FetchTexel1D */
968 NULL, /* FetchTexel2D */
969 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600970 NULL, /* FetchTexel1Df */
971 NULL, /* FetchTexel2Df */
972 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000973 store_texel_rgb565_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000974};
975
Thomas Hellstromdbda49a2009-01-20 11:12:17 +0100976const struct gl_texture_format _mesa_texformat_rgba4444 = {
977 MESA_FORMAT_RGBA4444, /* MesaFormat */
978 GL_RGBA, /* BaseFormat */
979 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
980 4, /* RedBits */
981 4, /* GreenBits */
982 4, /* BlueBits */
983 4, /* AlphaBits */
984 0, /* LuminanceBits */
985 0, /* IntensityBits */
986 0, /* IndexBits */
987 0, /* DepthBits */
988 0, /* StencilBits */
989 2, /* TexelBytes */
990 _mesa_texstore_rgba4444, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -0600991 NULL, /* FetchTexel1D */
992 NULL, /* FetchTexel2D */
993 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -0600994 NULL, /* FetchTexel1Df */
995 NULL, /* FetchTexel2Df */
996 NULL, /* FetchTexel3Df */
Thomas Hellstromdbda49a2009-01-20 11:12:17 +0100997 store_texel_rgba4444 /* StoreTexel */
998};
999
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001000const struct gl_texture_format _mesa_texformat_argb4444 = {
Gareth Hughes38f28662001-03-28 20:40:51 +00001001 MESA_FORMAT_ARGB4444, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +00001002 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001003 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001004 4, /* RedBits */
1005 4, /* GreenBits */
1006 4, /* BlueBits */
1007 4, /* AlphaBits */
1008 0, /* LuminanceBits */
1009 0, /* IntensityBits */
1010 0, /* IndexBits */
1011 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001012 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001013 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001014 _mesa_texstore_argb4444, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -06001015 NULL, /* FetchTexel1D */
1016 NULL, /* FetchTexel2D */
1017 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001018 NULL, /* FetchTexel1Df */
1019 NULL, /* FetchTexel2Df */
1020 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001021 store_texel_argb4444 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001022};
1023
Brian Pauldefb0352004-05-13 15:26:51 +00001024const struct gl_texture_format _mesa_texformat_argb4444_rev = {
1025 MESA_FORMAT_ARGB4444_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +00001026 GL_RGBA, /* BaseFormat */
1027 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1028 4, /* RedBits */
1029 4, /* GreenBits */
1030 4, /* BlueBits */
1031 4, /* AlphaBits */
1032 0, /* LuminanceBits */
1033 0, /* IntensityBits */
1034 0, /* IndexBits */
1035 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001036 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +00001037 2, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +00001038 _mesa_texstore_argb4444, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -06001039 NULL, /* FetchTexel1D */
1040 NULL, /* FetchTexel2D */
1041 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001042 NULL, /* FetchTexel1Df */
1043 NULL, /* FetchTexel2Df */
1044 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001045 store_texel_argb4444_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +00001046};
1047
Thomas Hellstromdbda49a2009-01-20 11:12:17 +01001048const struct gl_texture_format _mesa_texformat_rgba5551 = {
1049 MESA_FORMAT_RGBA5551, /* MesaFormat */
1050 GL_RGBA, /* BaseFormat */
1051 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1052 5, /* RedBits */
1053 5, /* GreenBits */
1054 5, /* BlueBits */
1055 1, /* AlphaBits */
1056 0, /* LuminanceBits */
1057 0, /* IntensityBits */
1058 0, /* IndexBits */
1059 0, /* DepthBits */
1060 0, /* StencilBits */
1061 2, /* TexelBytes */
1062 _mesa_texstore_rgba5551, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -06001063 NULL, /* FetchTexel1D */
1064 NULL, /* FetchTexel2D */
1065 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001066 NULL, /* FetchTexel1Df */
1067 NULL, /* FetchTexel2Df */
1068 NULL, /* FetchTexel3Df */
Thomas Hellstromdbda49a2009-01-20 11:12:17 +01001069 store_texel_rgba5551 /* StoreTexel */
1070};
1071
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001072const struct gl_texture_format _mesa_texformat_argb1555 = {
Gareth Hughes38f28662001-03-28 20:40:51 +00001073 MESA_FORMAT_ARGB1555, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +00001074 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001075 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001076 5, /* RedBits */
1077 5, /* GreenBits */
1078 5, /* BlueBits */
1079 1, /* AlphaBits */
1080 0, /* LuminanceBits */
1081 0, /* IntensityBits */
1082 0, /* IndexBits */
1083 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001084 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001085 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001086 _mesa_texstore_argb1555, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -06001087 NULL, /* FetchTexel1D */
1088 NULL, /* FetchTexel2D */
1089 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001090 NULL, /* FetchTexel1Df */
1091 NULL, /* FetchTexel2Df */
1092 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001093 store_texel_argb1555 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001094};
1095
Brian Pauldefb0352004-05-13 15:26:51 +00001096const struct gl_texture_format _mesa_texformat_argb1555_rev = {
1097 MESA_FORMAT_ARGB1555_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +00001098 GL_RGBA, /* BaseFormat */
1099 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1100 5, /* RedBits */
1101 5, /* GreenBits */
1102 5, /* BlueBits */
1103 1, /* AlphaBits */
1104 0, /* LuminanceBits */
1105 0, /* IntensityBits */
1106 0, /* IndexBits */
1107 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001108 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +00001109 2, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +00001110 _mesa_texstore_argb1555, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -06001111 NULL, /* FetchTexel1D */
1112 NULL, /* FetchTexel2D */
1113 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001114 NULL, /* FetchTexel1Df */
1115 NULL, /* FetchTexel2Df */
1116 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001117 store_texel_argb1555_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +00001118};
1119
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001120const struct gl_texture_format _mesa_texformat_al88 = {
Gareth Hughes38f28662001-03-28 20:40:51 +00001121 MESA_FORMAT_AL88, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +00001122 GL_LUMINANCE_ALPHA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001123 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001124 0, /* RedBits */
1125 0, /* GreenBits */
1126 0, /* BlueBits */
1127 8, /* AlphaBits */
1128 8, /* LuminanceBits */
1129 0, /* IntensityBits */
1130 0, /* IndexBits */
1131 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001132 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001133 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001134 _mesa_texstore_al88, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -06001135 NULL, /* FetchTexel1D */
1136 NULL, /* FetchTexel2D */
1137 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001138 NULL, /* FetchTexel1Df */
1139 NULL, /* FetchTexel2Df */
1140 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001141 store_texel_al88 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001142};
1143
Brian Pauldefb0352004-05-13 15:26:51 +00001144const struct gl_texture_format _mesa_texformat_al88_rev = {
1145 MESA_FORMAT_AL88_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +00001146 GL_LUMINANCE_ALPHA, /* BaseFormat */
1147 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1148 0, /* RedBits */
1149 0, /* GreenBits */
1150 0, /* BlueBits */
1151 8, /* AlphaBits */
1152 8, /* LuminanceBits */
1153 0, /* IntensityBits */
1154 0, /* IndexBits */
1155 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001156 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +00001157 2, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +00001158 _mesa_texstore_al88, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -06001159 NULL, /* FetchTexel1D */
1160 NULL, /* FetchTexel2D */
1161 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001162 NULL, /* FetchTexel1Df */
1163 NULL, /* FetchTexel2Df */
1164 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001165 store_texel_al88_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +00001166};
1167
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001168const struct gl_texture_format _mesa_texformat_rgb332 = {
Gareth Hughes38f28662001-03-28 20:40:51 +00001169 MESA_FORMAT_RGB332, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +00001170 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001171 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001172 3, /* RedBits */
1173 3, /* GreenBits */
1174 2, /* BlueBits */
1175 0, /* AlphaBits */
1176 0, /* LuminanceBits */
1177 0, /* IntensityBits */
1178 0, /* IndexBits */
1179 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001180 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001181 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001182 _mesa_texstore_rgb332, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -06001183 NULL, /* FetchTexel1D */
1184 NULL, /* FetchTexel2D */
1185 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001186 NULL, /* FetchTexel1Df */
1187 NULL, /* FetchTexel2Df */
1188 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001189 store_texel_rgb332 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001190};
1191
1192const struct gl_texture_format _mesa_texformat_a8 = {
Gareth Hughes38f28662001-03-28 20:40:51 +00001193 MESA_FORMAT_A8, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +00001194 GL_ALPHA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001195 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001196 0, /* RedBits */
1197 0, /* GreenBits */
1198 0, /* BlueBits */
1199 8, /* AlphaBits */
1200 0, /* LuminanceBits */
1201 0, /* IntensityBits */
1202 0, /* IndexBits */
1203 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001204 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001205 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001206 _mesa_texstore_a8, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -06001207 NULL, /* FetchTexel1D */
1208 NULL, /* FetchTexel2D */
1209 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001210 NULL, /* FetchTexel1Df */
1211 NULL, /* FetchTexel2Df */
1212 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001213 store_texel_a8 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001214};
1215
1216const struct gl_texture_format _mesa_texformat_l8 = {
Gareth Hughes38f28662001-03-28 20:40:51 +00001217 MESA_FORMAT_L8, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +00001218 GL_LUMINANCE, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001219 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001220 0, /* RedBits */
1221 0, /* GreenBits */
1222 0, /* BlueBits */
1223 0, /* AlphaBits */
1224 8, /* LuminanceBits */
1225 0, /* IntensityBits */
1226 0, /* IndexBits */
1227 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001228 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001229 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001230 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -06001231 NULL, /* FetchTexel1D */
1232 NULL, /* FetchTexel2D */
1233 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001234 NULL, /* FetchTexel1Df */
1235 NULL, /* FetchTexel2Df */
1236 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001237 store_texel_l8 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001238};
1239
1240const struct gl_texture_format _mesa_texformat_i8 = {
Gareth Hughes38f28662001-03-28 20:40:51 +00001241 MESA_FORMAT_I8, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +00001242 GL_INTENSITY, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001243 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001244 0, /* RedBits */
1245 0, /* GreenBits */
1246 0, /* BlueBits */
1247 0, /* AlphaBits */
1248 0, /* LuminanceBits */
1249 8, /* IntensityBits */
1250 0, /* IndexBits */
1251 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001252 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001253 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001254 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -06001255 NULL, /* FetchTexel1D */
1256 NULL, /* FetchTexel2D */
1257 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001258 NULL, /* FetchTexel1Df */
1259 NULL, /* FetchTexel2Df */
1260 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001261 store_texel_i8 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001262};
1263
1264const struct gl_texture_format _mesa_texformat_ci8 = {
Gareth Hughes38f28662001-03-28 20:40:51 +00001265 MESA_FORMAT_CI8, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +00001266 GL_COLOR_INDEX, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001267 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001268 0, /* RedBits */
1269 0, /* GreenBits */
1270 0, /* BlueBits */
1271 0, /* AlphaBits */
1272 0, /* LuminanceBits */
1273 0, /* IntensityBits */
1274 8, /* IndexBits */
1275 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001276 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001277 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001278 _mesa_texstore_ci8, /* StoreTexImageFunc */
Brian Paulcb5bd7d2009-03-08 20:53:41 -06001279 NULL, /* FetchTexel1D */
1280 NULL, /* FetchTexel2D */
1281 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001282 NULL, /* FetchTexel1Df */
1283 NULL, /* FetchTexel2Df */
1284 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001285 store_texel_ci8 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001286};
1287
Brian Paulc5b99502002-09-21 16:51:25 +00001288const struct gl_texture_format _mesa_texformat_ycbcr = {
1289 MESA_FORMAT_YCBCR, /* MesaFormat */
1290 GL_YCBCR_MESA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001291 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Brian Paulc5b99502002-09-21 16:51:25 +00001292 0, /* RedBits */
1293 0, /* GreenBits */
1294 0, /* BlueBits */
1295 0, /* AlphaBits */
1296 0, /* LuminanceBits */
1297 0, /* IntensityBits */
1298 0, /* IndexBits */
1299 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001300 0, /* StencilBits */
Brian Paulc5b99502002-09-21 16:51:25 +00001301 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001302 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
Brian Paul61112832009-03-09 20:34:24 -06001303 NULL, /* FetchTexel1D */
1304 NULL, /* FetchTexel2D */
1305 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001306 NULL, /* FetchTexel1Df */
1307 NULL, /* FetchTexel2Df */
1308 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001309 store_texel_ycbcr /* StoreTexel */
Brian Paulc5b99502002-09-21 16:51:25 +00001310};
1311
Brian Paulc5b99502002-09-21 16:51:25 +00001312const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
1313 MESA_FORMAT_YCBCR_REV, /* MesaFormat */
1314 GL_YCBCR_MESA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001315 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Brian Paulc5b99502002-09-21 16:51:25 +00001316 0, /* RedBits */
1317 0, /* GreenBits */
1318 0, /* BlueBits */
1319 0, /* AlphaBits */
1320 0, /* LuminanceBits */
1321 0, /* IntensityBits */
1322 0, /* IndexBits */
1323 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001324 0, /* StencilBits */
Brian Paulc5b99502002-09-21 16:51:25 +00001325 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001326 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
Brian Paul61112832009-03-09 20:34:24 -06001327 NULL, /* FetchTexel1D */
1328 NULL, /* FetchTexel2D */
1329 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001330 NULL, /* FetchTexel1Df */
1331 NULL, /* FetchTexel2Df */
1332 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001333 store_texel_ycbcr_rev /* StoreTexel */
Brian Paulc5b99502002-09-21 16:51:25 +00001334};
1335
Brian Paul1ad7b992005-09-28 02:29:50 +00001336const struct gl_texture_format _mesa_texformat_z24_s8 = {
1337 MESA_FORMAT_Z24_S8, /* MesaFormat */
1338 GL_DEPTH_STENCIL_EXT, /* BaseFormat */
1339 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1340 0, /* RedBits */
1341 0, /* GreenBits */
1342 0, /* BlueBits */
1343 0, /* AlphaBits */
1344 0, /* LuminanceBits */
1345 0, /* IntensityBits */
1346 0, /* IndexBits */
1347 24, /* DepthBits */
1348 8, /* StencilBits */
1349 4, /* TexelBytes */
Brian Paul27945072005-10-01 16:09:26 +00001350 _mesa_texstore_z24_s8, /* StoreTexImageFunc */
Brian Paul1ad7b992005-09-28 02:29:50 +00001351 NULL, /* FetchTexel1D */
1352 NULL, /* FetchTexel2D */
1353 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001354 NULL, /* FetchTexel1Df */
1355 NULL, /* FetchTexel2Df */
1356 NULL, /* FetchTexel3Df */
Brian Paul1ad7b992005-09-28 02:29:50 +00001357 store_texel_z24_s8 /* StoreTexel */
1358};
1359
Jakob Bornecrantzdc44bb82008-09-04 10:35:01 +08001360const struct gl_texture_format _mesa_texformat_s8_z24 = {
1361 MESA_FORMAT_S8_Z24, /* MesaFormat */
1362 GL_DEPTH_STENCIL_EXT, /* BaseFormat */
1363 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1364 0, /* RedBits */
1365 0, /* GreenBits */
1366 0, /* BlueBits */
1367 0, /* AlphaBits */
1368 0, /* LuminanceBits */
1369 0, /* IntensityBits */
1370 0, /* IndexBits */
1371 24, /* DepthBits */
1372 8, /* StencilBits */
1373 4, /* TexelBytes */
1374 _mesa_texstore_s8_z24, /* StoreTexImageFunc */
1375 NULL, /* FetchTexel1D */
1376 NULL, /* FetchTexel2D */
1377 NULL, /* FetchTexel3D */
Brian Paulda5722b2009-09-27 18:09:23 -06001378 NULL, /* FetchTexel1Df */
1379 NULL, /* FetchTexel2Df */
1380 NULL, /* FetchTexel3Df */
Jakob Bornecrantzdc44bb82008-09-04 10:35:01 +08001381 store_texel_s8_z24 /* StoreTexel */
1382};
1383
Brian Paula9bcf752006-04-06 04:23:58 +00001384const struct gl_texture_format _mesa_texformat_z16 = {
1385 MESA_FORMAT_Z16, /* MesaFormat */
1386 GL_DEPTH_COMPONENT, /* BaseFormat */
1387 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1388 0, /* RedBits */
1389 0, /* GreenBits */
1390 0, /* BlueBits */
1391 0, /* AlphaBits */
1392 0, /* LuminanceBits */
1393 0, /* IntensityBits */
1394 0, /* IndexBits */
1395 sizeof(GLushort) * 8, /* DepthBits */
1396 0, /* StencilBits */
1397 sizeof(GLushort), /* TexelBytes */
1398 _mesa_texstore_z16, /* StoreTexImageFunc */
1399 NULL, /* FetchTexel1D */
1400 NULL, /* FetchTexel1D */
1401 NULL, /* FetchTexel1D */
Brian Paulda5722b2009-09-27 18:09:23 -06001402 NULL, /* FetchTexel1Df */
1403 NULL, /* FetchTexel1Df */
1404 NULL, /* FetchTexel1Df */
Brian Paula9bcf752006-04-06 04:23:58 +00001405 store_texel_z16 /* StoreTexel */
1406};
1407
1408const struct gl_texture_format _mesa_texformat_z32 = {
1409 MESA_FORMAT_Z32, /* MesaFormat */
1410 GL_DEPTH_COMPONENT, /* BaseFormat */
1411 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1412 0, /* RedBits */
1413 0, /* GreenBits */
1414 0, /* BlueBits */
1415 0, /* AlphaBits */
1416 0, /* LuminanceBits */
1417 0, /* IntensityBits */
1418 0, /* IndexBits */
1419 sizeof(GLuint) * 8, /* DepthBits */
1420 0, /* StencilBits */
1421 sizeof(GLuint), /* TexelBytes */
1422 _mesa_texstore_z32, /* StoreTexImageFunc */
1423 NULL, /* FetchTexel1D */
1424 NULL, /* FetchTexel1D */
1425 NULL, /* FetchTexel1D */
Brian Paulda5722b2009-09-27 18:09:23 -06001426 NULL, /* FetchTexel1Df */
1427 NULL, /* FetchTexel1Df */
1428 NULL, /* FetchTexel1Df */
Brian Paula9bcf752006-04-06 04:23:58 +00001429 store_texel_z32 /* StoreTexel */
1430};
1431
Keith Whitwell6dc85572003-07-17 13:43:59 +00001432/*@}*/
1433
1434
1435/***************************************************************/
1436/** \name Null format (useful for proxy textures) */
1437/*@{*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001438
1439const struct gl_texture_format _mesa_null_texformat = {
Gareth Hughes38f28662001-03-28 20:40:51 +00001440 -1, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +00001441 0, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001442 GL_NONE, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001443 0, /* RedBits */
1444 0, /* GreenBits */
1445 0, /* BlueBits */
1446 0, /* AlphaBits */
1447 0, /* LuminanceBits */
1448 0, /* IntensityBits */
1449 0, /* IndexBits */
1450 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001451 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001452 0, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001453 NULL, /* StoreTexImageFunc */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001454 fetch_null_texel, /* FetchTexel1D */
Brian Paulda5722b2009-09-27 18:09:23 -06001455 fetch_null_texel, /* FetchTexel1D */
1456 fetch_null_texel, /* FetchTexel1D */
Brian Paul4f295ce2004-01-23 01:59:54 +00001457 fetch_null_texelf, /* FetchTexel1Df */
Brian Paulda5722b2009-09-27 18:09:23 -06001458 fetch_null_texelf, /* FetchTexel1Df */
1459 fetch_null_texelf, /* FetchTexel1Df */
Brian Paule4b23562005-05-04 20:11:35 +00001460 store_null_texel /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001461};
1462
Keith Whitwell6dc85572003-07-17 13:43:59 +00001463/*@}*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001464
Keith Whitwell6dc85572003-07-17 13:43:59 +00001465
Keith Whitwell6dc85572003-07-17 13:43:59 +00001466/**
Brian Paulfe031082004-01-24 17:02:19 +00001467 * Choose an appropriate texture format given the format, type and
1468 * internalFormat parameters passed to glTexImage().
Keith Whitwell6dc85572003-07-17 13:43:59 +00001469 *
Brian Paulfe031082004-01-24 17:02:19 +00001470 * \param ctx the GL context.
1471 * \param internalFormat user's prefered internal texture format.
1472 * \param format incoming image pixel format.
1473 * \param type incoming image data type.
Keith Whitwell6dc85572003-07-17 13:43:59 +00001474 *
Brian Paulfe031082004-01-24 17:02:19 +00001475 * \return a pointer to a gl_texture_format object which describes the
1476 * choosen texture format, or NULL on failure.
Keith Whitwell6dc85572003-07-17 13:43:59 +00001477 *
1478 * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers
Brian Paulf959f6e2004-04-22 00:27:31 +00001479 * will typically override this function with a specialized version.
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001480 */
Brian Paul7d58f442001-04-04 21:54:20 +00001481const struct gl_texture_format *
1482_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
1483 GLenum format, GLenum type )
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001484{
Brian Paul7d58f442001-04-04 21:54:20 +00001485 (void) format;
1486 (void) type;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001487
Brian Paulf959f6e2004-04-22 00:27:31 +00001488 switch (internalFormat) {
1489 /* RGBA formats */
1490 case 4:
1491 case GL_RGBA:
Brian Paulf959f6e2004-04-22 00:27:31 +00001492 case GL_RGB10_A2:
1493 case GL_RGBA12:
1494 case GL_RGBA16:
1495 return &_mesa_texformat_rgba;
Brian Paula156b492004-05-12 01:50:30 +00001496 case GL_RGBA8:
1497 return &_mesa_texformat_rgba8888;
Brian Paulf959f6e2004-04-22 00:27:31 +00001498 case GL_RGB5_A1:
1499 return &_mesa_texformat_argb1555;
1500 case GL_RGBA2:
Brian Pauldefb0352004-05-13 15:26:51 +00001501 return &_mesa_texformat_argb4444_rev; /* just to test another format*/
Brian Paulf959f6e2004-04-22 00:27:31 +00001502 case GL_RGBA4:
1503 return &_mesa_texformat_argb4444;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001504
Brian Paulf959f6e2004-04-22 00:27:31 +00001505 /* RGB formats */
1506 case 3:
1507 case GL_RGB:
Brian Paulf959f6e2004-04-22 00:27:31 +00001508 case GL_RGB10:
1509 case GL_RGB12:
1510 case GL_RGB16:
1511 return &_mesa_texformat_rgb;
Brian Pauldefb0352004-05-13 15:26:51 +00001512 case GL_RGB8:
1513 return &_mesa_texformat_rgb888;
Brian Paulf959f6e2004-04-22 00:27:31 +00001514 case GL_R3_G3_B2:
1515 return &_mesa_texformat_rgb332;
1516 case GL_RGB4:
Brian Pauldefb0352004-05-13 15:26:51 +00001517 return &_mesa_texformat_rgb565_rev; /* just to test another format */
Brian Paulf959f6e2004-04-22 00:27:31 +00001518 case GL_RGB5:
1519 return &_mesa_texformat_rgb565;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001520
Brian Paulf959f6e2004-04-22 00:27:31 +00001521 /* Alpha formats */
1522 case GL_ALPHA:
1523 case GL_ALPHA4:
Brian Paulf959f6e2004-04-22 00:27:31 +00001524 case GL_ALPHA12:
1525 case GL_ALPHA16:
1526 return &_mesa_texformat_alpha;
Brian Paula156b492004-05-12 01:50:30 +00001527 case GL_ALPHA8:
1528 return &_mesa_texformat_a8;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001529
Brian Paulf959f6e2004-04-22 00:27:31 +00001530 /* Luminance formats */
1531 case 1:
1532 case GL_LUMINANCE:
1533 case GL_LUMINANCE4:
1534 case GL_LUMINANCE12:
1535 case GL_LUMINANCE16:
1536 return &_mesa_texformat_luminance;
1537 case GL_LUMINANCE8:
1538 return &_mesa_texformat_l8;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001539
Brian Paulf959f6e2004-04-22 00:27:31 +00001540 /* Luminance/Alpha formats */
1541 case 2:
1542 case GL_LUMINANCE_ALPHA:
1543 case GL_LUMINANCE4_ALPHA4:
1544 case GL_LUMINANCE6_ALPHA2:
1545 case GL_LUMINANCE12_ALPHA4:
1546 case GL_LUMINANCE12_ALPHA12:
1547 case GL_LUMINANCE16_ALPHA16:
1548 return &_mesa_texformat_luminance_alpha;
1549 case GL_LUMINANCE8_ALPHA8:
1550 return &_mesa_texformat_al88;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001551
Brian Paulf959f6e2004-04-22 00:27:31 +00001552 case GL_INTENSITY:
1553 case GL_INTENSITY4:
1554 case GL_INTENSITY12:
1555 case GL_INTENSITY16:
1556 return &_mesa_texformat_intensity;
1557 case GL_INTENSITY8:
1558 return &_mesa_texformat_i8;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001559
Brian Paulf959f6e2004-04-22 00:27:31 +00001560 case GL_COLOR_INDEX:
1561 case GL_COLOR_INDEX1_EXT:
1562 case GL_COLOR_INDEX2_EXT:
1563 case GL_COLOR_INDEX4_EXT:
1564 case GL_COLOR_INDEX12_EXT:
1565 case GL_COLOR_INDEX16_EXT:
Brian Paulf959f6e2004-04-22 00:27:31 +00001566 case GL_COLOR_INDEX8_EXT:
1567 return &_mesa_texformat_ci8;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001568
Brian Paulf959f6e2004-04-22 00:27:31 +00001569 default:
1570 ; /* fallthrough */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001571 }
Brian Paulf959f6e2004-04-22 00:27:31 +00001572
Ian Romanick4741dbc2008-10-01 15:51:56 -07001573 if (ctx->Extensions.ARB_depth_texture) {
Brian Paulf959f6e2004-04-22 00:27:31 +00001574 switch (internalFormat) {
1575 case GL_DEPTH_COMPONENT:
Ian Romanick4741dbc2008-10-01 15:51:56 -07001576 case GL_DEPTH_COMPONENT24:
1577 case GL_DEPTH_COMPONENT32:
Brian Paula9bcf752006-04-06 04:23:58 +00001578 return &_mesa_texformat_z32;
Ian Romanick4741dbc2008-10-01 15:51:56 -07001579 case GL_DEPTH_COMPONENT16:
Brian Paula9bcf752006-04-06 04:23:58 +00001580 return &_mesa_texformat_z16;
Brian Paulf959f6e2004-04-22 00:27:31 +00001581 default:
1582 ; /* fallthrough */
1583 }
1584 }
1585
Ian Romanick33fa5e42009-01-27 17:36:03 -08001586 switch (internalFormat) {
1587 case GL_COMPRESSED_ALPHA_ARB:
1588 return &_mesa_texformat_alpha;
1589 case GL_COMPRESSED_LUMINANCE_ARB:
1590 return &_mesa_texformat_luminance;
1591 case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
1592 return &_mesa_texformat_luminance_alpha;
1593 case GL_COMPRESSED_INTENSITY_ARB:
1594 return &_mesa_texformat_intensity;
1595 case GL_COMPRESSED_RGB_ARB:
Keith Whitwell34a61c62008-09-21 19:29:15 -07001596#if FEATURE_texture_fxt1
Ian Romanick33fa5e42009-01-27 17:36:03 -08001597 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1598 return &_mesa_texformat_rgb_fxt1;
Keith Whitwell34a61c62008-09-21 19:29:15 -07001599#endif
1600#if FEATURE_texture_s3tc
Ian Romanick33fa5e42009-01-27 17:36:03 -08001601 if (ctx->Extensions.EXT_texture_compression_s3tc ||
1602 ctx->Extensions.S3_s3tc)
1603 return &_mesa_texformat_rgb_dxt1;
Keith Whitwell34a61c62008-09-21 19:29:15 -07001604#endif
Ian Romanick33fa5e42009-01-27 17:36:03 -08001605 return &_mesa_texformat_rgb;
1606 case GL_COMPRESSED_RGBA_ARB:
Keith Whitwell34a61c62008-09-21 19:29:15 -07001607#if FEATURE_texture_fxt1
Ian Romanick33fa5e42009-01-27 17:36:03 -08001608 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1609 return &_mesa_texformat_rgba_fxt1;
Keith Whitwell34a61c62008-09-21 19:29:15 -07001610#endif
1611#if FEATURE_texture_s3tc
Ian Romanick33fa5e42009-01-27 17:36:03 -08001612 if (ctx->Extensions.EXT_texture_compression_s3tc ||
1613 ctx->Extensions.S3_s3tc)
1614 return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
Keith Whitwell34a61c62008-09-21 19:29:15 -07001615#endif
Ian Romanick33fa5e42009-01-27 17:36:03 -08001616 return &_mesa_texformat_rgba;
1617 default:
1618 ; /* fallthrough */
Brian Paulf959f6e2004-04-22 00:27:31 +00001619 }
1620
1621 if (ctx->Extensions.MESA_ycbcr_texture) {
1622 if (internalFormat == GL_YCBCR_MESA) {
1623 if (type == GL_UNSIGNED_SHORT_8_8_MESA)
1624 return &_mesa_texformat_ycbcr;
1625 else
1626 return &_mesa_texformat_ycbcr_rev;
1627 }
1628 }
1629
Keith Whitwell34a61c62008-09-21 19:29:15 -07001630#if FEATURE_texture_fxt1
Brian Paulf959f6e2004-04-22 00:27:31 +00001631 if (ctx->Extensions.TDFX_texture_compression_FXT1) {
1632 switch (internalFormat) {
1633 case GL_COMPRESSED_RGB_FXT1_3DFX:
1634 return &_mesa_texformat_rgb_fxt1;
1635 case GL_COMPRESSED_RGBA_FXT1_3DFX:
1636 return &_mesa_texformat_rgba_fxt1;
1637 default:
1638 ; /* fallthrough */
1639 }
1640 }
Keith Whitwell34a61c62008-09-21 19:29:15 -07001641#endif
Brian Paulf959f6e2004-04-22 00:27:31 +00001642
Keith Whitwell34a61c62008-09-21 19:29:15 -07001643#if FEATURE_texture_s3tc
Brian Paulf959f6e2004-04-22 00:27:31 +00001644 if (ctx->Extensions.EXT_texture_compression_s3tc) {
1645 switch (internalFormat) {
1646 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1647 return &_mesa_texformat_rgb_dxt1;
1648 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1649 return &_mesa_texformat_rgba_dxt1;
1650 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
1651 return &_mesa_texformat_rgba_dxt3;
1652 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
1653 return &_mesa_texformat_rgba_dxt5;
1654 default:
1655 ; /* fallthrough */
1656 }
1657 }
1658
1659 if (ctx->Extensions.S3_s3tc) {
1660 switch (internalFormat) {
1661 case GL_RGB_S3TC:
1662 case GL_RGB4_S3TC:
1663 return &_mesa_texformat_rgb_dxt1;
1664 case GL_RGBA_S3TC:
1665 case GL_RGBA4_S3TC:
1666 return &_mesa_texformat_rgba_dxt3;
1667 default:
1668 ; /* fallthrough */
1669 }
1670 }
Keith Whitwell34a61c62008-09-21 19:29:15 -07001671#endif
Brian Paulf959f6e2004-04-22 00:27:31 +00001672
1673 if (ctx->Extensions.ARB_texture_float) {
1674 switch (internalFormat) {
1675 case GL_ALPHA16F_ARB:
1676 return &_mesa_texformat_alpha_float16;
1677 case GL_ALPHA32F_ARB:
1678 return &_mesa_texformat_alpha_float32;
1679 case GL_LUMINANCE16F_ARB:
1680 return &_mesa_texformat_luminance_float16;
1681 case GL_LUMINANCE32F_ARB:
1682 return &_mesa_texformat_luminance_float32;
1683 case GL_LUMINANCE_ALPHA16F_ARB:
1684 return &_mesa_texformat_luminance_alpha_float16;
1685 case GL_LUMINANCE_ALPHA32F_ARB:
1686 return &_mesa_texformat_luminance_alpha_float32;
1687 case GL_INTENSITY16F_ARB:
1688 return &_mesa_texformat_intensity_float16;
1689 case GL_INTENSITY32F_ARB:
1690 return &_mesa_texformat_intensity_float32;
1691 case GL_RGB16F_ARB:
1692 return &_mesa_texformat_rgb_float16;
1693 case GL_RGB32F_ARB:
1694 return &_mesa_texformat_rgb_float32;
1695 case GL_RGBA16F_ARB:
1696 return &_mesa_texformat_rgba_float16;
1697 case GL_RGBA32F_ARB:
1698 return &_mesa_texformat_rgba_float32;
1699 default:
1700 ; /* fallthrough */
1701 }
1702 }
1703
Brian Paul1ad7b992005-09-28 02:29:50 +00001704 if (ctx->Extensions.EXT_packed_depth_stencil) {
1705 switch (internalFormat) {
1706 case GL_DEPTH_STENCIL_EXT:
1707 case GL_DEPTH24_STENCIL8_EXT:
1708 return &_mesa_texformat_z24_s8;
1709 default:
1710 ; /* fallthrough */
1711 }
1712 }
1713
Roland Scheidegger114152e2009-03-12 15:01:16 +01001714 if (ctx->Extensions.ATI_envmap_bumpmap) {
1715 switch (internalFormat) {
1716 case GL_DUDV_ATI:
1717 case GL_DU8DV8_ATI:
1718 return &_mesa_texformat_dudv8;
1719 default:
1720 ; /* fallthrough */
1721 }
1722 }
1723
Roland Scheideggerc6a6cc12009-03-27 19:39:52 +01001724 if (ctx->Extensions.MESA_texture_signed_rgba) {
1725 switch (internalFormat) {
1726 case GL_RGBA_SNORM:
1727 case GL_RGBA8_SNORM:
1728 return &_mesa_texformat_signed_rgba8888;
1729 default:
1730 ; /* fallthrough */
1731 }
1732 }
1733
1734
Brian Paul8d214bc2006-08-03 03:20:52 +00001735#if FEATURE_EXT_texture_sRGB
1736 if (ctx->Extensions.EXT_texture_sRGB) {
1737 switch (internalFormat) {
1738 case GL_SRGB_EXT:
1739 case GL_SRGB8_EXT:
1740 return &_mesa_texformat_srgb8;
1741 case GL_SRGB_ALPHA_EXT:
1742 case GL_SRGB8_ALPHA8_EXT:
1743 return &_mesa_texformat_srgba8;
1744 case GL_SLUMINANCE_EXT:
1745 case GL_SLUMINANCE8_EXT:
1746 return &_mesa_texformat_sl8;
1747 case GL_SLUMINANCE_ALPHA_EXT:
1748 case GL_SLUMINANCE8_ALPHA8_EXT:
1749 return &_mesa_texformat_sla8;
Brian Paul8d214bc2006-08-03 03:20:52 +00001750 case GL_COMPRESSED_SLUMINANCE_EXT:
1751 return &_mesa_texformat_sl8;
1752 case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT:
1753 return &_mesa_texformat_sla8;
Roland Scheidegger5bd093b2008-12-12 05:06:48 +01001754 case GL_COMPRESSED_SRGB_EXT:
1755#if FEATURE_texture_s3tc
1756 if (ctx->Extensions.EXT_texture_compression_s3tc)
1757 return &_mesa_texformat_srgb_dxt1;
1758#endif
Brian Paul8d214bc2006-08-03 03:20:52 +00001759 return &_mesa_texformat_srgb8;
Roland Scheidegger5bd093b2008-12-12 05:06:48 +01001760 case GL_COMPRESSED_SRGB_ALPHA_EXT:
1761#if FEATURE_texture_s3tc
1762 if (ctx->Extensions.EXT_texture_compression_s3tc)
1763 return &_mesa_texformat_srgba_dxt3; /* Not srgba_dxt1, see spec */
1764#endif
Brian Paul8d214bc2006-08-03 03:20:52 +00001765 return &_mesa_texformat_srgba8;
Roland Scheidegger5bd093b2008-12-12 05:06:48 +01001766#if FEATURE_texture_s3tc
1767 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT:
1768 if (ctx->Extensions.EXT_texture_compression_s3tc)
1769 return &_mesa_texformat_srgb_dxt1;
1770 break;
1771 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT:
1772 if (ctx->Extensions.EXT_texture_compression_s3tc)
1773 return &_mesa_texformat_srgba_dxt1;
1774 break;
1775 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT:
1776 if (ctx->Extensions.EXT_texture_compression_s3tc)
1777 return &_mesa_texformat_srgba_dxt3;
1778 break;
1779 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT:
1780 if (ctx->Extensions.EXT_texture_compression_s3tc)
1781 return &_mesa_texformat_srgba_dxt5;
1782 break;
1783#endif
Brian Paul8d214bc2006-08-03 03:20:52 +00001784 default:
1785 ; /* fallthrough */
1786 }
1787 }
1788#endif /* FEATURE_EXT_texture_sRGB */
1789
Brian Paulf959f6e2004-04-22 00:27:31 +00001790 _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
1791 return NULL;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001792}
Brian12dc9c92008-02-08 16:46:12 -07001793
1794
1795
1796/**
1797 * Return datatype and number of components per texel for the
1798 * given gl_texture_format.
1799 */
1800void
1801_mesa_format_to_type_and_comps(const struct gl_texture_format *format,
1802 GLenum *datatype, GLuint *comps)
1803{
1804 switch (format->MesaFormat) {
1805 case MESA_FORMAT_RGBA8888:
1806 case MESA_FORMAT_RGBA8888_REV:
1807 case MESA_FORMAT_ARGB8888:
1808 case MESA_FORMAT_ARGB8888_REV:
1809 *datatype = CHAN_TYPE;
1810 *comps = 4;
1811 return;
1812 case MESA_FORMAT_RGB888:
1813 case MESA_FORMAT_BGR888:
1814 *datatype = GL_UNSIGNED_BYTE;
1815 *comps = 3;
1816 return;
1817 case MESA_FORMAT_RGB565:
1818 case MESA_FORMAT_RGB565_REV:
1819 *datatype = GL_UNSIGNED_SHORT_5_6_5;
1820 *comps = 3;
1821 return;
1822
1823 case MESA_FORMAT_ARGB4444:
1824 case MESA_FORMAT_ARGB4444_REV:
1825 *datatype = GL_UNSIGNED_SHORT_4_4_4_4;
1826 *comps = 4;
1827 return;
1828
1829 case MESA_FORMAT_ARGB1555:
1830 case MESA_FORMAT_ARGB1555_REV:
1831 *datatype = GL_UNSIGNED_SHORT_1_5_5_5_REV;
Xiang, Haihao241c0bf2009-01-06 15:30:34 +08001832 *comps = 4;
Brian12dc9c92008-02-08 16:46:12 -07001833 return;
1834
1835 case MESA_FORMAT_AL88:
1836 case MESA_FORMAT_AL88_REV:
1837 *datatype = GL_UNSIGNED_BYTE;
1838 *comps = 2;
1839 return;
1840 case MESA_FORMAT_RGB332:
1841 *datatype = GL_UNSIGNED_BYTE_3_3_2;
1842 *comps = 3;
1843 return;
1844
1845 case MESA_FORMAT_A8:
1846 case MESA_FORMAT_L8:
1847 case MESA_FORMAT_I8:
1848 case MESA_FORMAT_CI8:
1849 *datatype = GL_UNSIGNED_BYTE;
1850 *comps = 1;
1851 return;
1852
1853 case MESA_FORMAT_YCBCR:
1854 case MESA_FORMAT_YCBCR_REV:
1855 *datatype = GL_UNSIGNED_SHORT;
1856 *comps = 2;
1857 return;
1858
1859 case MESA_FORMAT_Z24_S8:
1860 *datatype = GL_UNSIGNED_INT;
1861 *comps = 1; /* XXX OK? */
1862 return;
1863
Jakob Bornecrantz2e3e5182008-06-09 16:29:57 +02001864 case MESA_FORMAT_S8_Z24:
1865 *datatype = GL_UNSIGNED_INT;
1866 *comps = 1; /* XXX OK? */
1867 return;
1868
Brian12dc9c92008-02-08 16:46:12 -07001869 case MESA_FORMAT_Z16:
1870 *datatype = GL_UNSIGNED_SHORT;
1871 *comps = 1;
1872 return;
1873
1874 case MESA_FORMAT_Z32:
1875 *datatype = GL_UNSIGNED_INT;
1876 *comps = 1;
1877 return;
1878
Roland Scheidegger114152e2009-03-12 15:01:16 +01001879 case MESA_FORMAT_DUDV8:
1880 *datatype = GL_BYTE;
1881 *comps = 2;
1882 return;
1883
Roland Scheideggerc6a6cc12009-03-27 19:39:52 +01001884 case MESA_FORMAT_SIGNED_RGBA8888:
Roland Scheideggerbb386a12009-03-27 21:59:33 +01001885 case MESA_FORMAT_SIGNED_RGBA8888_REV:
Roland Scheideggerc6a6cc12009-03-27 19:39:52 +01001886 *datatype = GL_BYTE;
1887 *comps = 4;
1888 return;
1889
Brian Paule961a5d2008-06-12 16:55:28 -06001890#if FEATURE_EXT_texture_sRGB
Brian12dc9c92008-02-08 16:46:12 -07001891 case MESA_FORMAT_SRGB8:
1892 *datatype = GL_UNSIGNED_BYTE;
1893 *comps = 3;
1894 return;
1895 case MESA_FORMAT_SRGBA8:
Roland Scheidegger5bd093b2008-12-12 05:06:48 +01001896 case MESA_FORMAT_SARGB8:
Brian12dc9c92008-02-08 16:46:12 -07001897 *datatype = GL_UNSIGNED_BYTE;
1898 *comps = 4;
1899 return;
1900 case MESA_FORMAT_SL8:
1901 *datatype = GL_UNSIGNED_BYTE;
1902 *comps = 1;
1903 return;
1904 case MESA_FORMAT_SLA8:
1905 *datatype = GL_UNSIGNED_BYTE;
1906 *comps = 2;
1907 return;
Brian Paule961a5d2008-06-12 16:55:28 -06001908#endif
Brian12dc9c92008-02-08 16:46:12 -07001909
Brian Paule961a5d2008-06-12 16:55:28 -06001910#if FEATURE_texture_fxt1
Brian12dc9c92008-02-08 16:46:12 -07001911 case MESA_FORMAT_RGB_FXT1:
1912 case MESA_FORMAT_RGBA_FXT1:
Brian Paule961a5d2008-06-12 16:55:28 -06001913#endif
1914#if FEATURE_texture_s3tc
Brian12dc9c92008-02-08 16:46:12 -07001915 case MESA_FORMAT_RGB_DXT1:
1916 case MESA_FORMAT_RGBA_DXT1:
1917 case MESA_FORMAT_RGBA_DXT3:
1918 case MESA_FORMAT_RGBA_DXT5:
Roland Scheidegger5bd093b2008-12-12 05:06:48 +01001919#if FEATURE_EXT_texture_sRGB
1920 case MESA_FORMAT_SRGB_DXT1:
1921 case MESA_FORMAT_SRGBA_DXT1:
1922 case MESA_FORMAT_SRGBA_DXT3:
1923 case MESA_FORMAT_SRGBA_DXT5:
1924#endif
Brian12dc9c92008-02-08 16:46:12 -07001925 /* XXX generate error instead? */
1926 *datatype = GL_UNSIGNED_BYTE;
1927 *comps = 0;
1928 return;
Brian Paule961a5d2008-06-12 16:55:28 -06001929#endif
Brian12dc9c92008-02-08 16:46:12 -07001930
1931 case MESA_FORMAT_RGBA:
1932 *datatype = CHAN_TYPE;
1933 *comps = 4;
1934 return;
1935 case MESA_FORMAT_RGB:
1936 *datatype = CHAN_TYPE;
1937 *comps = 3;
1938 return;
1939 case MESA_FORMAT_LUMINANCE_ALPHA:
1940 *datatype = CHAN_TYPE;
1941 *comps = 2;
1942 return;
1943 case MESA_FORMAT_ALPHA:
1944 case MESA_FORMAT_LUMINANCE:
1945 case MESA_FORMAT_INTENSITY:
1946 *datatype = CHAN_TYPE;
1947 *comps = 1;
1948 return;
1949
1950 case MESA_FORMAT_RGBA_FLOAT32:
1951 *datatype = GL_FLOAT;
1952 *comps = 4;
1953 return;
1954 case MESA_FORMAT_RGBA_FLOAT16:
1955 *datatype = GL_HALF_FLOAT_ARB;
1956 *comps = 4;
1957 return;
1958 case MESA_FORMAT_RGB_FLOAT32:
1959 *datatype = GL_FLOAT;
1960 *comps = 3;
1961 return;
1962 case MESA_FORMAT_RGB_FLOAT16:
1963 *datatype = GL_HALF_FLOAT_ARB;
1964 *comps = 3;
1965 return;
1966 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32:
1967 *datatype = GL_FLOAT;
1968 *comps = 2;
1969 return;
1970 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16:
1971 *datatype = GL_HALF_FLOAT_ARB;
1972 *comps = 2;
1973 return;
1974 case MESA_FORMAT_ALPHA_FLOAT32:
1975 case MESA_FORMAT_LUMINANCE_FLOAT32:
1976 case MESA_FORMAT_INTENSITY_FLOAT32:
1977 *datatype = GL_FLOAT;
1978 *comps = 1;
1979 return;
1980 case MESA_FORMAT_ALPHA_FLOAT16:
1981 case MESA_FORMAT_LUMINANCE_FLOAT16:
1982 case MESA_FORMAT_INTENSITY_FLOAT16:
1983 *datatype = GL_HALF_FLOAT_ARB;
1984 *comps = 1;
1985 return;
1986
1987 default:
1988 _mesa_problem(NULL, "bad format in _mesa_format_to_type_and_comps");
1989 *datatype = 0;
1990 *comps = 1;
1991 }
1992}
Brian Paulda5722b2009-09-27 18:09:23 -06001993
1994
1995
1996/**
1997 * Table to map MESA_FORMAT_ to texel fetch/store funcs.
1998 * XXX this is somewhat temporary.
1999 */
2000static struct {
2001 GLuint Name;
2002 FetchTexelFuncF Fetch1D;
2003 FetchTexelFuncF Fetch2D;
2004 FetchTexelFuncF Fetch3D;
2005 StoreTexelFunc StoreTexel;
2006}
2007texfetch_funcs[MESA_FORMAT_COUNT] =
2008{
2009 {
2010 MESA_FORMAT_RGBA,
2011 fetch_texel_1d_f_rgba,
2012 fetch_texel_2d_f_rgba,
2013 fetch_texel_3d_f_rgba,
2014 store_texel_rgba
2015 },
2016 {
2017 MESA_FORMAT_RGB,
2018 fetch_texel_1d_f_rgb,
2019 fetch_texel_2d_f_rgb,
2020 fetch_texel_3d_f_rgb,
2021 store_texel_rgb
2022 },
2023 {
2024 MESA_FORMAT_ALPHA,
2025 fetch_texel_1d_f_alpha,
2026 fetch_texel_2d_f_alpha,
2027 fetch_texel_3d_f_alpha,
2028 store_texel_alpha
2029 },
2030 {
2031 MESA_FORMAT_LUMINANCE,
2032 fetch_texel_1d_f_luminance,
2033 fetch_texel_2d_f_luminance,
2034 fetch_texel_3d_f_luminance,
2035 store_texel_luminance
2036 },
2037 {
2038 MESA_FORMAT_LUMINANCE_ALPHA,
2039 fetch_texel_1d_f_luminance_alpha,
2040 fetch_texel_2d_f_luminance_alpha,
2041 fetch_texel_3d_f_luminance_alpha,
2042 store_texel_luminance_alpha
2043 },
2044 {
2045 MESA_FORMAT_INTENSITY,
2046 fetch_texel_1d_f_intensity,
2047 fetch_texel_2d_f_intensity,
2048 fetch_texel_3d_f_intensity,
2049 store_texel_intensity
2050 },
2051 {
2052 MESA_FORMAT_SRGB8,
2053 fetch_texel_1d_srgb8,
2054 fetch_texel_2d_srgb8,
2055 fetch_texel_3d_srgb8,
2056 store_texel_srgb8
2057 },
2058 {
2059 MESA_FORMAT_SRGBA8,
2060 fetch_texel_1d_srgba8,
2061 fetch_texel_2d_srgba8,
2062 fetch_texel_3d_srgba8,
2063 store_texel_srgba8
2064 },
2065 {
2066 MESA_FORMAT_SARGB8,
2067 fetch_texel_1d_sargb8,
2068 fetch_texel_2d_sargb8,
2069 fetch_texel_3d_sargb8,
2070 store_texel_sargb8
2071 },
2072 {
2073 MESA_FORMAT_SL8,
2074 fetch_texel_1d_sl8,
2075 fetch_texel_2d_sl8,
2076 fetch_texel_3d_sl8,
2077 store_texel_sl8
2078 },
2079 {
2080 MESA_FORMAT_SLA8,
2081 fetch_texel_1d_sla8,
2082 fetch_texel_2d_sla8,
2083 fetch_texel_3d_sla8,
2084 store_texel_sla8
2085 },
2086 {
2087 MESA_FORMAT_RGB_FXT1,
2088 NULL,
2089 _mesa_fetch_texel_2d_f_rgb_fxt1,
2090 NULL,
2091 NULL
2092 },
2093 {
2094 MESA_FORMAT_RGBA_FXT1,
2095 NULL,
2096 _mesa_fetch_texel_2d_f_rgba_fxt1,
2097 NULL,
2098 NULL
2099 },
2100 {
2101 MESA_FORMAT_RGB_DXT1,
2102 NULL,
2103 _mesa_fetch_texel_2d_f_rgb_dxt1,
2104 NULL,
2105 NULL
2106 },
2107 {
2108 MESA_FORMAT_RGBA_DXT1,
2109 NULL,
2110 _mesa_fetch_texel_2d_f_rgba_dxt1,
2111 NULL,
2112 NULL
2113 },
2114 {
2115 MESA_FORMAT_RGBA_DXT3,
2116 NULL,
2117 _mesa_fetch_texel_2d_f_rgba_dxt3,
2118 NULL,
2119 NULL
2120 },
2121 {
2122 MESA_FORMAT_RGBA_DXT5,
2123 NULL,
2124 _mesa_fetch_texel_2d_f_rgba_dxt5,
2125 NULL,
2126 NULL
2127 },
2128 {
2129 MESA_FORMAT_SRGB_DXT1,
2130 NULL,
2131 _mesa_fetch_texel_2d_f_srgb_dxt1,
2132 NULL,
2133 NULL
2134 },
2135 {
2136 MESA_FORMAT_SRGBA_DXT1,
2137 NULL,
2138 _mesa_fetch_texel_2d_f_srgba_dxt1,
2139 NULL,
2140 NULL
2141 },
2142 {
2143 MESA_FORMAT_SRGBA_DXT3,
2144 NULL,
2145 _mesa_fetch_texel_2d_f_srgba_dxt3,
2146 NULL,
2147 NULL
2148 },
2149 {
2150 MESA_FORMAT_SRGBA_DXT5,
2151 NULL,
2152 _mesa_fetch_texel_2d_f_srgba_dxt5,
2153 NULL,
2154 NULL
2155 },
2156 {
2157 MESA_FORMAT_RGBA_FLOAT32,
2158 fetch_texel_1d_f_rgba_f32,
2159 fetch_texel_2d_f_rgba_f32,
2160 fetch_texel_3d_f_rgba_f32,
2161 store_texel_rgba_f32
2162 },
2163 {
2164 MESA_FORMAT_RGBA_FLOAT16,
2165 fetch_texel_1d_f_rgba_f16,
2166 fetch_texel_2d_f_rgba_f16,
2167 fetch_texel_3d_f_rgba_f16,
2168 store_texel_rgba_f16
2169 },
2170 {
2171 MESA_FORMAT_RGB_FLOAT32,
2172 fetch_texel_1d_f_rgb_f32,
2173 fetch_texel_2d_f_rgb_f32,
2174 fetch_texel_3d_f_rgb_f32,
2175 store_texel_rgb_f32
2176 },
2177 {
2178 MESA_FORMAT_RGB_FLOAT16,
2179 fetch_texel_1d_f_rgb_f16,
2180 fetch_texel_2d_f_rgb_f16,
2181 fetch_texel_3d_f_rgb_f16,
2182 store_texel_rgb_f16
2183 },
2184 {
2185 MESA_FORMAT_ALPHA_FLOAT32,
2186 fetch_texel_1d_f_alpha_f32,
2187 fetch_texel_2d_f_alpha_f32,
2188 fetch_texel_3d_f_alpha_f32,
2189 store_texel_alpha_f32
2190 },
2191 {
2192 MESA_FORMAT_ALPHA_FLOAT16,
2193 fetch_texel_1d_f_alpha_f16,
2194 fetch_texel_2d_f_alpha_f16,
2195 fetch_texel_3d_f_alpha_f16,
2196 store_texel_alpha_f16
2197 },
2198 {
2199 MESA_FORMAT_LUMINANCE_FLOAT32,
2200 fetch_texel_1d_f_luminance_f32,
2201 fetch_texel_2d_f_luminance_f32,
2202 fetch_texel_3d_f_luminance_f32,
2203 store_texel_luminance_f32
2204 },
2205 {
2206 MESA_FORMAT_LUMINANCE_FLOAT16,
2207 fetch_texel_1d_f_luminance_f16,
2208 fetch_texel_2d_f_luminance_f16,
2209 fetch_texel_3d_f_luminance_f16,
2210 store_texel_luminance_f16
2211 },
2212 {
2213 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32,
2214 fetch_texel_1d_f_luminance_alpha_f32,
2215 fetch_texel_2d_f_luminance_alpha_f32,
2216 fetch_texel_3d_f_luminance_alpha_f32,
2217 store_texel_luminance_alpha_f32
2218 },
2219 {
2220 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16,
2221 fetch_texel_1d_f_luminance_alpha_f16,
2222 fetch_texel_2d_f_luminance_alpha_f16,
2223 fetch_texel_3d_f_luminance_alpha_f16,
2224 store_texel_luminance_alpha_f16
2225 },
2226 {
2227 MESA_FORMAT_INTENSITY_FLOAT32,
2228 fetch_texel_1d_f_intensity_f32,
2229 fetch_texel_2d_f_intensity_f32,
2230 fetch_texel_3d_f_intensity_f32,
2231 store_texel_intensity_f32
2232 },
2233 {
2234 MESA_FORMAT_INTENSITY_FLOAT16,
2235 fetch_texel_1d_f_intensity_f16,
2236 fetch_texel_2d_f_intensity_f16,
2237 fetch_texel_3d_f_intensity_f16,
2238 store_texel_intensity_f16
2239 },
2240 {
2241 MESA_FORMAT_DUDV8,
2242 fetch_texel_1d_dudv8,
2243 fetch_texel_2d_dudv8,
2244 fetch_texel_3d_dudv8,
2245 NULL
2246 },
2247 {
2248 MESA_FORMAT_SIGNED_RGBA8888,
2249 fetch_texel_1d_signed_rgba8888,
2250 fetch_texel_2d_signed_rgba8888,
2251 fetch_texel_3d_signed_rgba8888,
2252 store_texel_signed_rgba8888
2253 },
2254 {
2255 MESA_FORMAT_SIGNED_RGBA8888_REV,
2256 fetch_texel_1d_signed_rgba8888_rev,
2257 fetch_texel_2d_signed_rgba8888_rev,
2258 fetch_texel_3d_signed_rgba8888_rev,
2259 store_texel_signed_rgba8888_rev
2260 },
2261 {
2262 MESA_FORMAT_RGBA8888,
2263 fetch_texel_1d_f_rgba8888,
2264 fetch_texel_2d_f_rgba8888,
2265 fetch_texel_3d_f_rgba8888,
2266 store_texel_rgba8888
2267 },
2268 {
2269 MESA_FORMAT_RGBA8888_REV,
2270 fetch_texel_1d_f_rgba8888_rev,
2271 fetch_texel_2d_f_rgba8888_rev,
2272 fetch_texel_3d_f_rgba8888_rev,
2273 store_texel_rgba8888_rev
2274 },
2275 {
2276 MESA_FORMAT_ARGB8888,
2277 fetch_texel_1d_f_argb8888,
2278 fetch_texel_2d_f_argb8888,
2279 fetch_texel_3d_f_argb8888,
2280 store_texel_argb8888
2281 },
2282 {
2283 MESA_FORMAT_ARGB8888_REV,
2284 fetch_texel_1d_f_argb8888_rev,
2285 fetch_texel_2d_f_argb8888_rev,
2286 fetch_texel_3d_f_argb8888_rev,
2287 store_texel_argb8888_rev
2288 },
2289 {
2290 MESA_FORMAT_RGB888,
2291 fetch_texel_1d_f_rgb888,
2292 fetch_texel_2d_f_rgb888,
2293 fetch_texel_3d_f_rgb888,
2294 store_texel_rgb888
2295 },
2296 {
2297 MESA_FORMAT_BGR888,
2298 fetch_texel_1d_f_bgr888,
2299 fetch_texel_2d_f_bgr888,
2300 fetch_texel_3d_f_bgr888,
2301 store_texel_bgr888
2302 },
2303 {
2304 MESA_FORMAT_RGB565,
2305 fetch_texel_1d_f_rgb565,
2306 fetch_texel_2d_f_rgb565,
2307 fetch_texel_3d_f_rgb565,
2308 store_texel_rgb565
2309 },
2310 {
2311 MESA_FORMAT_RGB565_REV,
2312 fetch_texel_1d_f_rgb565_rev,
2313 fetch_texel_2d_f_rgb565_rev,
2314 fetch_texel_3d_f_rgb565_rev,
2315 store_texel_rgb565_rev
2316 },
2317 {
2318 MESA_FORMAT_RGBA4444,
2319 fetch_texel_1d_f_rgba4444,
2320 fetch_texel_2d_f_rgba4444,
2321 fetch_texel_3d_f_rgba4444,
2322 store_texel_rgba4444
2323 },
2324 {
2325 MESA_FORMAT_ARGB4444,
2326 fetch_texel_1d_f_argb4444,
2327 fetch_texel_2d_f_argb4444,
2328 fetch_texel_3d_f_argb4444,
2329 store_texel_argb4444
2330 },
2331 {
2332 MESA_FORMAT_ARGB4444_REV,
2333 fetch_texel_1d_f_argb4444_rev,
2334 fetch_texel_2d_f_argb4444_rev,
2335 fetch_texel_3d_f_argb4444_rev,
2336 store_texel_argb4444_rev
2337 },
2338 {
2339 MESA_FORMAT_RGBA5551,
2340 fetch_texel_1d_f_rgba5551,
2341 fetch_texel_2d_f_rgba5551,
2342 fetch_texel_3d_f_rgba5551,
2343 store_texel_rgba5551
2344 },
2345 {
2346 MESA_FORMAT_ARGB1555,
2347 fetch_texel_1d_f_argb1555,
2348 fetch_texel_2d_f_argb1555,
2349 fetch_texel_3d_f_argb1555,
2350 store_texel_argb1555
2351 },
2352 {
2353 MESA_FORMAT_ARGB1555_REV,
2354 fetch_texel_1d_f_argb1555_rev,
2355 fetch_texel_2d_f_argb1555_rev,
2356 fetch_texel_3d_f_argb1555_rev,
2357 store_texel_argb1555_rev
2358 },
2359 {
2360 MESA_FORMAT_AL88,
2361 fetch_texel_1d_f_al88,
2362 fetch_texel_2d_f_al88,
2363 fetch_texel_3d_f_al88,
2364 store_texel_al88
2365 },
2366 {
2367 MESA_FORMAT_AL88_REV,
2368 fetch_texel_1d_f_al88_rev,
2369 fetch_texel_2d_f_al88_rev,
2370 fetch_texel_3d_f_al88_rev,
2371 store_texel_al88_rev
2372 },
2373 {
2374 MESA_FORMAT_RGB332,
2375 fetch_texel_1d_f_rgb332,
2376 fetch_texel_2d_f_rgb332,
2377 fetch_texel_3d_f_rgb332,
2378 store_texel_rgb332
2379 },
2380 {
2381 MESA_FORMAT_A8,
2382 fetch_texel_1d_f_a8,
2383 fetch_texel_2d_f_a8,
2384 fetch_texel_3d_f_a8,
2385 store_texel_a8
2386 },
2387 {
2388 MESA_FORMAT_L8,
2389 fetch_texel_1d_f_l8,
2390 fetch_texel_2d_f_l8,
2391 fetch_texel_3d_f_l8,
2392 store_texel_l8
2393 },
2394 {
2395 MESA_FORMAT_I8,
2396 fetch_texel_1d_f_i8,
2397 fetch_texel_2d_f_i8,
2398 fetch_texel_3d_f_i8,
2399 store_texel_i8
2400 },
2401 {
2402 MESA_FORMAT_CI8,
2403 fetch_texel_1d_f_ci8,
2404 fetch_texel_2d_f_ci8,
2405 fetch_texel_3d_f_ci8,
2406 store_texel_ci8
2407 },
2408 {
2409 MESA_FORMAT_YCBCR,
2410 fetch_texel_1d_f_ycbcr,
2411 fetch_texel_2d_f_ycbcr,
2412 fetch_texel_3d_f_ycbcr,
2413 store_texel_ycbcr
2414 },
2415 {
2416 MESA_FORMAT_YCBCR_REV,
2417 fetch_texel_1d_f_ycbcr_rev,
2418 fetch_texel_2d_f_ycbcr_rev,
2419 fetch_texel_3d_f_ycbcr_rev,
2420 store_texel_ycbcr_rev
2421 },
2422 {
2423 MESA_FORMAT_Z24_S8,
2424 fetch_texel_1d_f_z24_s8,
2425 fetch_texel_2d_f_z24_s8,
2426 fetch_texel_3d_f_z24_s8,
2427 store_texel_z24_s8
2428 },
2429 {
2430 MESA_FORMAT_S8_Z24,
2431 fetch_texel_1d_f_s8_z24,
2432 fetch_texel_2d_f_s8_z24,
2433 fetch_texel_3d_f_s8_z24,
2434 store_texel_s8_z24
2435 },
2436 {
2437 MESA_FORMAT_Z16,
2438 fetch_texel_1d_f_z16,
2439 fetch_texel_2d_f_z16,
2440 fetch_texel_3d_f_z16,
2441 store_texel_z16
2442 },
2443 {
2444 MESA_FORMAT_Z32,
2445 fetch_texel_1d_f_z32,
2446 fetch_texel_2d_f_z32,
2447 fetch_texel_3d_f_z32,
2448 store_texel_z32
2449 }
2450};
2451
2452
2453FetchTexelFuncF
2454_mesa_get_texel_fetch_func(GLuint format, GLuint dims)
2455{
2456 GLuint i;
2457 /* XXX replace loop with direct table lookup */
2458 for (i = 0; i < MESA_FORMAT_COUNT; i++) {
2459 if (texfetch_funcs[i].Name == format) {
2460 switch (dims) {
2461 case 1:
2462 return texfetch_funcs[i].Fetch1D;
2463 case 2:
2464 return texfetch_funcs[i].Fetch2D;
2465 case 3:
2466 return texfetch_funcs[i].Fetch3D;
2467 }
2468 }
2469 }
2470 return NULL;
2471}
2472
2473
2474StoreTexelFunc
2475_mesa_get_texel_store_func(GLuint format)
2476{
2477 GLuint i;
2478 /* XXX replace loop with direct table lookup */
2479 for (i = 0; i < MESA_FORMAT_COUNT; i++) {
2480 if (texfetch_funcs[i].Name == format) {
2481 return texfetch_funcs[i].StoreTexel;
2482 }
2483 }
2484 return NULL;
2485}