blob: 2cea5151f93923687829ca729f94d8a088f8fe9b [file] [log] [blame]
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001/*
2 * Mesa 3-D graphics library
Brian Paul4618a9b2005-09-08 15:28:45 +00003 * Version: 6.5
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00004 *
Brian Paul4618a9b2005-09-08 15:28:45 +00005 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00006 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000023 */
24
Keith Whitwell6dc85572003-07-17 13:43:59 +000025
Brian Paulf959f6e2004-04-22 00:27:31 +000026/**
27 * \file texformat.c
28 * Texture formats.
29 *
30 * \author Gareth Hughes
31 */
32
33
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000034#include "colormac.h"
35#include "context.h"
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000036#include "texformat.h"
Brian Paul36237332004-04-22 00:54:53 +000037#include "texstore.h"
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000038
Brian Paulf959f6e2004-04-22 00:27:31 +000039
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000040
Keith Whitwell6dc85572003-07-17 13:43:59 +000041/* Texel fetch routines for all supported formats
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000042 */
43#define DIM 1
44#include "texformat_tmp.h"
45
46#define DIM 2
47#include "texformat_tmp.h"
48
49#define DIM 3
50#include "texformat_tmp.h"
51
Keith Whitwell6dc85572003-07-17 13:43:59 +000052/**
53 * Null texel fetch function.
54 *
55 * Have to have this so the FetchTexel function pointer is never NULL.
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000056 */
57static void fetch_null_texel( const struct gl_texture_image *texImage,
Brian Paul4f295ce2004-01-23 01:59:54 +000058 GLint i, GLint j, GLint k, GLchan *texel )
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000059{
Brian Paula6c423d2004-08-25 15:59:48 +000060 (void) texImage; (void) i; (void) j; (void) k;
Brian Paul4f295ce2004-01-23 01:59:54 +000061 texel[RCOMP] = 0;
62 texel[GCOMP] = 0;
63 texel[BCOMP] = 0;
64 texel[ACOMP] = 0;
65 _mesa_warning(NULL, "fetch_null_texel() called!");
66}
67
68static void fetch_null_texelf( const struct gl_texture_image *texImage,
69 GLint i, GLint j, GLint k, GLfloat *texel )
70{
Brian Paula6c423d2004-08-25 15:59:48 +000071 (void) texImage; (void) i; (void) j; (void) k;
Brian Paul4f295ce2004-01-23 01:59:54 +000072 texel[RCOMP] = 0.0;
73 texel[GCOMP] = 0.0;
74 texel[BCOMP] = 0.0;
75 texel[ACOMP] = 0.0;
76 _mesa_warning(NULL, "fetch_null_texelf() called!");
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000077}
78
Brian Paule4b23562005-05-04 20:11:35 +000079static void store_null_texel(struct gl_texture_image *texImage,
80 GLint i, GLint j, GLint k, const void *texel)
81{
82 /* no-op */
83}
84
85
Brian Paul63b5b8e2005-09-15 01:55:40 +000086/**
87 * Notes about the predefined gl_texture_formats:
88 *
89 * 1. There are 1D, 2D and 3D functions for fetching texels from texture
90 * images, returning both GLchan values and GLfloat values. (six
91 * functions in total)
92 * You don't have to provide both the GLchan and GLfloat functions;
93 * just one or the other is OK. Mesa will use an "adaptor" to convert
94 * between GLchan/GLfloat when needed.
95 * Since the adaptors have small performance penalty, we provide both
96 * GLchan and GLfloat functions for some common formats like RGB, RGBA.
97 */
98
Gareth Hughes2c3d34c2001-03-18 08:53:49 +000099
Keith Whitwell6dc85572003-07-17 13:43:59 +0000100/***************************************************************/
101/** \name Default GLchan-based formats */
102/*@{*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000103
104const struct gl_texture_format _mesa_texformat_rgba = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000105 MESA_FORMAT_RGBA, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000106 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000107 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000108 CHAN_BITS, /* RedBits */
109 CHAN_BITS, /* GreenBits */
110 CHAN_BITS, /* BlueBits */
111 CHAN_BITS, /* AlphaBits */
112 0, /* LuminanceBits */
113 0, /* IntensityBits */
114 0, /* IndexBits */
115 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000116 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000117 4 * sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000118 _mesa_texstore_rgba, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000119 fetch_texel_1d_rgba, /* FetchTexel1D */
120 fetch_texel_2d_rgba, /* FetchTexel2D */
121 fetch_texel_3d_rgba, /* FetchTexel3D */
122 fetch_texel_1d_f_rgba, /* FetchTexel1Df */
123 fetch_texel_2d_f_rgba, /* FetchTexel2Df */
124 fetch_texel_3d_f_rgba, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000125 store_texel_rgba /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000126};
127
128const struct gl_texture_format _mesa_texformat_rgb = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000129 MESA_FORMAT_RGB, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000130 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000131 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000132 CHAN_BITS, /* RedBits */
133 CHAN_BITS, /* GreenBits */
134 CHAN_BITS, /* BlueBits */
135 0, /* AlphaBits */
136 0, /* LuminanceBits */
137 0, /* IntensityBits */
138 0, /* IndexBits */
139 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000140 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000141 3 * sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000142 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000143 fetch_texel_1d_rgb, /* FetchTexel1D */
144 fetch_texel_2d_rgb, /* FetchTexel2D */
145 fetch_texel_3d_rgb, /* FetchTexel3D */
146 fetch_texel_1d_f_rgb, /* FetchTexel1Df */
147 fetch_texel_2d_f_rgb, /* FetchTexel2Df */
148 fetch_texel_3d_f_rgb, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000149 store_texel_rgb /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000150};
151
152const struct gl_texture_format _mesa_texformat_alpha = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000153 MESA_FORMAT_ALPHA, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000154 GL_ALPHA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000155 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000156 0, /* RedBits */
157 0, /* GreenBits */
158 0, /* BlueBits */
159 CHAN_BITS, /* AlphaBits */
160 0, /* LuminanceBits */
161 0, /* IntensityBits */
162 0, /* IndexBits */
163 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000164 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000165 sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000166 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000167 fetch_texel_1d_alpha, /* FetchTexel1D */
168 fetch_texel_2d_alpha, /* FetchTexel2D */
169 fetch_texel_3d_alpha, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000170 NULL, /* FetchTexel1Df */
171 NULL, /* FetchTexel2Df */
172 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000173 store_texel_alpha /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000174};
175
176const struct gl_texture_format _mesa_texformat_luminance = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000177 MESA_FORMAT_LUMINANCE, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000178 GL_LUMINANCE, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000179 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000180 0, /* RedBits */
181 0, /* GreenBits */
182 0, /* BlueBits */
183 0, /* AlphaBits */
184 CHAN_BITS, /* LuminanceBits */
185 0, /* IntensityBits */
186 0, /* IndexBits */
187 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000188 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000189 sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000190 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000191 fetch_texel_1d_luminance, /* FetchTexel1D */
192 fetch_texel_2d_luminance, /* FetchTexel2D */
193 fetch_texel_3d_luminance, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000194 NULL, /* FetchTexel1Df */
195 NULL, /* FetchTexel2Df */
196 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000197 store_texel_luminance /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000198};
199
200const struct gl_texture_format _mesa_texformat_luminance_alpha = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000201 MESA_FORMAT_LUMINANCE_ALPHA, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000202 GL_LUMINANCE_ALPHA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000203 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000204 0, /* RedBits */
205 0, /* GreenBits */
206 0, /* BlueBits */
207 CHAN_BITS, /* AlphaBits */
208 CHAN_BITS, /* LuminanceBits */
209 0, /* IntensityBits */
210 0, /* IndexBits */
211 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000212 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000213 2 * sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000214 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000215 fetch_texel_1d_luminance_alpha, /* FetchTexel1D */
216 fetch_texel_2d_luminance_alpha, /* FetchTexel2D */
217 fetch_texel_3d_luminance_alpha, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000218 NULL, /* FetchTexel1Df */
219 NULL, /* FetchTexel2Df */
220 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000221 store_texel_luminance_alpha /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000222};
223
224const struct gl_texture_format _mesa_texformat_intensity = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000225 MESA_FORMAT_INTENSITY, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000226 GL_INTENSITY, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000227 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000228 0, /* RedBits */
229 0, /* GreenBits */
230 0, /* BlueBits */
231 0, /* AlphaBits */
232 0, /* LuminanceBits */
233 CHAN_BITS, /* IntensityBits */
234 0, /* IndexBits */
235 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000236 0, /* StencilBits */
Brian Paul6e167152004-04-22 23:51:15 +0000237 sizeof(GLchan), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000238 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000239 fetch_texel_1d_intensity, /* FetchTexel1D */
240 fetch_texel_2d_intensity, /* FetchTexel2D */
241 fetch_texel_3d_intensity, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000242 NULL, /* FetchTexel1Df */
243 NULL, /* FetchTexel2Df */
244 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000245 store_texel_intensity /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000246};
247
Brian Paulf959f6e2004-04-22 00:27:31 +0000248const struct gl_texture_format _mesa_texformat_depth_component_float32 = {
249 MESA_FORMAT_DEPTH_COMPONENT_FLOAT32, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000250 GL_DEPTH_COMPONENT, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000251 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000252 0, /* RedBits */
253 0, /* GreenBits */
254 0, /* BlueBits */
255 0, /* AlphaBits */
256 0, /* LuminanceBits */
257 0, /* IntensityBits */
258 0, /* IndexBits */
259 sizeof(GLfloat) * 8, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000260 sizeof(GLfloat) * 8, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000261 sizeof(GLfloat), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000262 _mesa_texstore_depth_component_float32,/* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000263 NULL, /* FetchTexel1D */
264 NULL, /* FetchTexel1D */
265 NULL, /* FetchTexel1D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000266 fetch_texel_1d_f_depth_component_f32,/* FetchTexel1Df */
267 fetch_texel_2d_f_depth_component_f32,/* FetchTexel2Df */
268 fetch_texel_3d_f_depth_component_f32,/* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000269 store_texel_depth_component_f32 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000270};
271
272const struct gl_texture_format _mesa_texformat_depth_component16 = {
273 MESA_FORMAT_DEPTH_COMPONENT16, /* MesaFormat */
274 GL_DEPTH_COMPONENT, /* BaseFormat */
275 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
276 0, /* RedBits */
277 0, /* GreenBits */
278 0, /* BlueBits */
279 0, /* AlphaBits */
280 0, /* LuminanceBits */
281 0, /* IntensityBits */
282 0, /* IndexBits */
283 sizeof(GLushort) * 8, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000284 sizeof(GLushort) * 8, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000285 sizeof(GLushort), /* TexelBytes */
286 _mesa_texstore_depth_component16, /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000287 NULL, /* FetchTexel1D */
288 NULL, /* FetchTexel1D */
289 NULL, /* FetchTexel1D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000290 fetch_texel_1d_f_depth_component16, /* FetchTexel1Df */
291 fetch_texel_2d_f_depth_component16, /* FetchTexel2Df */
292 fetch_texel_3d_f_depth_component16, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000293 store_texel_depth_component16 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000294};
295
Brian Paulfe031082004-01-24 17:02:19 +0000296const struct gl_texture_format _mesa_texformat_rgba_float32 = {
297 MESA_FORMAT_RGBA_FLOAT32, /* MesaFormat */
298 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000299 GL_FLOAT, /* DataType */
Brian Paulfe031082004-01-24 17:02:19 +0000300 8 * sizeof(GLfloat), /* RedBits */
301 8 * sizeof(GLfloat), /* GreenBits */
302 8 * sizeof(GLfloat), /* BlueBits */
303 8 * sizeof(GLfloat), /* AlphaBits */
304 0, /* LuminanceBits */
305 0, /* IntensityBits */
306 0, /* IndexBits */
307 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000308 0, /* StencilBits */
Brian Paulfe031082004-01-24 17:02:19 +0000309 4 * sizeof(GLfloat), /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000310 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000311 NULL, /* FetchTexel1D */
312 NULL, /* FetchTexel1D */
313 NULL, /* FetchTexel1D */
Brian Paulfe031082004-01-24 17:02:19 +0000314 fetch_texel_1d_f_rgba_f32, /* FetchTexel1Df */
315 fetch_texel_2d_f_rgba_f32, /* FetchTexel2Df */
316 fetch_texel_3d_f_rgba_f32, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000317 store_texel_rgba_f32 /* StoreTexel */
Brian Paulfe031082004-01-24 17:02:19 +0000318};
319
320const struct gl_texture_format _mesa_texformat_rgba_float16 = {
321 MESA_FORMAT_RGBA_FLOAT16, /* MesaFormat */
322 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000323 GL_FLOAT, /* DataType */
324 8 * sizeof(GLhalfARB), /* RedBits */
325 8 * sizeof(GLhalfARB), /* GreenBits */
326 8 * sizeof(GLhalfARB), /* BlueBits */
327 8 * sizeof(GLhalfARB), /* AlphaBits */
Brian Paulfe031082004-01-24 17:02:19 +0000328 0, /* LuminanceBits */
329 0, /* IntensityBits */
330 0, /* IndexBits */
331 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000332 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000333 4 * sizeof(GLhalfARB), /* TexelBytes */
334 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000335 NULL, /* FetchTexel1D */
336 NULL, /* FetchTexel1D */
337 NULL, /* FetchTexel1D */
Brian Paulfe031082004-01-24 17:02:19 +0000338 fetch_texel_1d_f_rgba_f16, /* FetchTexel1Df */
339 fetch_texel_2d_f_rgba_f16, /* FetchTexel2Df */
340 fetch_texel_3d_f_rgba_f16, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000341 store_texel_rgba_f16 /* StoreTexel */
Brian Paulfe031082004-01-24 17:02:19 +0000342};
343
344const struct gl_texture_format _mesa_texformat_rgb_float32 = {
345 MESA_FORMAT_RGB_FLOAT32, /* MesaFormat */
346 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000347 GL_FLOAT, /* DataType */
Brian Paulfe031082004-01-24 17:02:19 +0000348 8 * sizeof(GLfloat), /* RedBits */
349 8 * sizeof(GLfloat), /* GreenBits */
350 8 * sizeof(GLfloat), /* BlueBits */
351 0, /* AlphaBits */
352 0, /* LuminanceBits */
353 0, /* IntensityBits */
354 0, /* IndexBits */
355 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000356 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000357 3 * sizeof(GLfloat), /* TexelBytes */
358 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000359 NULL, /* FetchTexel1D */
360 NULL, /* FetchTexel1D */
361 NULL, /* FetchTexel1D */
Brian Paulfe031082004-01-24 17:02:19 +0000362 fetch_texel_1d_f_rgb_f32, /* FetchTexel1Df */
363 fetch_texel_2d_f_rgb_f32, /* FetchTexel2Df */
364 fetch_texel_3d_f_rgb_f32, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000365 store_texel_rgb_f32 /* StoreTexel */
Brian Paulfe031082004-01-24 17:02:19 +0000366};
367
368const struct gl_texture_format _mesa_texformat_rgb_float16 = {
369 MESA_FORMAT_RGB_FLOAT16, /* MesaFormat */
370 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000371 GL_FLOAT, /* DataType */
372 8 * sizeof(GLhalfARB), /* RedBits */
373 8 * sizeof(GLhalfARB), /* GreenBits */
374 8 * sizeof(GLhalfARB), /* BlueBits */
Brian Paulfe031082004-01-24 17:02:19 +0000375 0, /* AlphaBits */
376 0, /* LuminanceBits */
377 0, /* IntensityBits */
378 0, /* IndexBits */
379 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000380 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000381 3 * sizeof(GLhalfARB), /* TexelBytes */
382 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000383 NULL, /* FetchTexel1D */
384 NULL, /* FetchTexel1D */
385 NULL, /* FetchTexel1D */
Brian Paulfe031082004-01-24 17:02:19 +0000386 fetch_texel_1d_f_rgb_f16, /* FetchTexel1Df */
387 fetch_texel_2d_f_rgb_f16, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000388 fetch_texel_3d_f_rgb_f16, /* FetchTexel3Df */
389 store_texel_rgb_f16 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000390};
391
392const struct gl_texture_format _mesa_texformat_alpha_float32 = {
393 MESA_FORMAT_ALPHA_FLOAT32, /* MesaFormat */
394 GL_ALPHA, /* BaseFormat */
395 GL_FLOAT, /* DataType */
396 0, /* RedBits */
397 0, /* GreenBits */
398 0, /* BlueBits */
399 8 * sizeof(GLfloat), /* AlphaBits */
400 0, /* LuminanceBits */
401 0, /* IntensityBits */
402 0, /* IndexBits */
403 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000404 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000405 1 * sizeof(GLfloat), /* TexelBytes */
406 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000407 NULL, /* FetchTexel1D */
408 NULL, /* FetchTexel1D */
409 NULL, /* FetchTexel1D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000410 fetch_texel_1d_f_alpha_f32, /* FetchTexel1Df */
411 fetch_texel_2d_f_alpha_f32, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000412 fetch_texel_3d_f_alpha_f32, /* FetchTexel3Df */
413 store_texel_alpha_f32 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000414};
415
416const struct gl_texture_format _mesa_texformat_alpha_float16 = {
417 MESA_FORMAT_ALPHA_FLOAT16, /* MesaFormat */
418 GL_ALPHA, /* BaseFormat */
419 GL_FLOAT, /* DataType */
420 0, /* RedBits */
421 0, /* GreenBits */
422 0, /* BlueBits */
423 8 * sizeof(GLhalfARB), /* AlphaBits */
424 0, /* LuminanceBits */
425 0, /* IntensityBits */
426 0, /* IndexBits */
427 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000428 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000429 1 * sizeof(GLhalfARB), /* TexelBytes */
430 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000431 NULL, /* FetchTexel1D */
432 NULL, /* FetchTexel1D */
433 NULL, /* FetchTexel1D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000434 fetch_texel_1d_f_alpha_f16, /* FetchTexel1Df */
435 fetch_texel_2d_f_alpha_f16, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000436 fetch_texel_3d_f_alpha_f16, /* FetchTexel3Df */
437 store_texel_alpha_f16 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000438};
439
440const struct gl_texture_format _mesa_texformat_luminance_float32 = {
441 MESA_FORMAT_LUMINANCE_FLOAT32, /* MesaFormat */
442 GL_LUMINANCE, /* BaseFormat */
443 GL_FLOAT, /* DataType */
444 0, /* RedBits */
445 0, /* GreenBits */
446 0, /* BlueBits */
447 0, /* AlphaBits */
448 8 * sizeof(GLfloat), /* LuminanceBits */
449 0, /* IntensityBits */
450 0, /* IndexBits */
451 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000452 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000453 1 * sizeof(GLfloat), /* TexelBytes */
454 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000455 NULL, /* FetchTexel1D */
456 NULL, /* FetchTexel2D */
457 NULL, /* FetchTexel3D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000458 fetch_texel_1d_f_luminance_f32, /* FetchTexel1Df */
459 fetch_texel_2d_f_luminance_f32, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000460 fetch_texel_3d_f_luminance_f32, /* FetchTexel3Df */
461 store_texel_luminance_f32 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000462};
463
464const struct gl_texture_format _mesa_texformat_luminance_float16 = {
465 MESA_FORMAT_LUMINANCE_FLOAT16, /* MesaFormat */
466 GL_LUMINANCE, /* BaseFormat */
467 GL_FLOAT, /* DataType */
468 0, /* RedBits */
469 0, /* GreenBits */
470 0, /* BlueBits */
471 0, /* AlphaBits */
472 8 * sizeof(GLhalfARB), /* LuminanceBits */
473 0, /* IntensityBits */
474 0, /* IndexBits */
475 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000476 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000477 1 * sizeof(GLhalfARB), /* TexelBytes */
478 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000479 NULL, /* FetchTexel1D */
480 NULL, /* FetchTexel2D */
481 NULL, /* FetchTexel3D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000482 fetch_texel_1d_f_luminance_f16, /* FetchTexel1Df */
483 fetch_texel_2d_f_luminance_f16, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000484 fetch_texel_3d_f_luminance_f16, /* FetchTexel3Df */
485 store_texel_luminance_f16 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000486};
487
488const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
489 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, /* MesaFormat */
490 GL_LUMINANCE_ALPHA, /* BaseFormat */
491 GL_FLOAT, /* DataType */
492 0, /* RedBits */
493 0, /* GreenBits */
494 0, /* BlueBits */
495 8 * sizeof(GLfloat), /* AlphaBits */
496 8 * sizeof(GLfloat), /* LuminanceBits */
497 0, /* IntensityBits */
498 0, /* IndexBits */
499 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000500 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000501 2 * sizeof(GLfloat), /* TexelBytes */
502 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000503 NULL, /* FetchTexel1D */
504 NULL, /* FetchTexel2D */
505 NULL, /* FetchTexel3D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000506 fetch_texel_1d_f_luminance_alpha_f32,/* FetchTexel1Df */
507 fetch_texel_2d_f_luminance_alpha_f32,/* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000508 fetch_texel_3d_f_luminance_alpha_f32,/* FetchTexel3Df */
509 store_texel_luminance_alpha_f32 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000510};
511
512const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
513 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, /* MesaFormat */
514 GL_LUMINANCE_ALPHA, /* BaseFormat */
515 GL_FLOAT, /* DataType */
516 0, /* RedBits */
517 0, /* GreenBits */
518 0, /* BlueBits */
519 8 * sizeof(GLhalfARB), /* AlphaBits */
520 8 * sizeof(GLhalfARB), /* LuminanceBits */
521 0, /* IntensityBits */
522 0, /* IndexBits */
523 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000524 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000525 2 * sizeof(GLhalfARB), /* TexelBytes */
526 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000527 NULL, /* FetchTexel1D */
528 NULL, /* FetchTexel2D */
529 NULL, /* FetchTexel3D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000530 fetch_texel_1d_f_luminance_alpha_f16,/* FetchTexel1Df */
531 fetch_texel_2d_f_luminance_alpha_f16,/* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000532 fetch_texel_3d_f_luminance_alpha_f16,/* FetchTexel3Df */
533 store_texel_luminance_alpha_f16 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000534};
535
536const struct gl_texture_format _mesa_texformat_intensity_float32 = {
537 MESA_FORMAT_INTENSITY_FLOAT32, /* MesaFormat */
538 GL_INTENSITY, /* BaseFormat */
539 GL_FLOAT, /* DataType */
540 0, /* RedBits */
541 0, /* GreenBits */
542 0, /* BlueBits */
543 0, /* AlphaBits */
544 0, /* LuminanceBits */
545 8 * sizeof(GLfloat), /* IntensityBits */
546 0, /* IndexBits */
547 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000548 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000549 1 * sizeof(GLfloat), /* TexelBytes */
550 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000551 NULL, /* FetchTexel1D */
552 NULL, /* FetchTexel2D */
553 NULL, /* FetchTexel3D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000554 fetch_texel_1d_f_intensity_f32, /* FetchTexel1Df */
555 fetch_texel_2d_f_intensity_f32, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000556 fetch_texel_3d_f_intensity_f32, /* FetchTexel3Df */
557 store_texel_intensity_f32 /* StoreTexel */
Brian Paulf959f6e2004-04-22 00:27:31 +0000558};
559
560const struct gl_texture_format _mesa_texformat_intensity_float16 = {
561 MESA_FORMAT_INTENSITY_FLOAT16, /* MesaFormat */
562 GL_INTENSITY, /* BaseFormat */
563 GL_FLOAT, /* DataType */
564 0, /* RedBits */
565 0, /* GreenBits */
566 0, /* BlueBits */
567 0, /* AlphaBits */
568 0, /* LuminanceBits */
569 8 * sizeof(GLhalfARB), /* IntensityBits */
570 0, /* IndexBits */
571 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000572 0, /* StencilBits */
Brian Paulf959f6e2004-04-22 00:27:31 +0000573 1 * sizeof(GLhalfARB), /* TexelBytes */
574 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000575 NULL, /* FetchTexel1D */
576 NULL, /* FetchTexel2D */
577 NULL, /* FetchTexel3D */
Brian Paulf959f6e2004-04-22 00:27:31 +0000578 fetch_texel_1d_f_intensity_f16, /* FetchTexel1Df */
579 fetch_texel_2d_f_intensity_f16, /* FetchTexel2Df */
Brian Paule4b23562005-05-04 20:11:35 +0000580 fetch_texel_3d_f_intensity_f16, /* FetchTexel3Df */
581 store_texel_intensity_f16 /* StoreTexel */
Brian Paulfe031082004-01-24 17:02:19 +0000582};
583
584
Keith Whitwell6dc85572003-07-17 13:43:59 +0000585/*@}*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000586
Keith Whitwell6dc85572003-07-17 13:43:59 +0000587
588/***************************************************************/
589/** \name Hardware formats */
590/*@{*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000591
592const struct gl_texture_format _mesa_texformat_rgba8888 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000593 MESA_FORMAT_RGBA8888, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000594 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000595 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000596 8, /* RedBits */
597 8, /* GreenBits */
598 8, /* BlueBits */
599 8, /* AlphaBits */
600 0, /* LuminanceBits */
601 0, /* IntensityBits */
602 0, /* IndexBits */
603 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000604 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000605 4, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000606 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000607 fetch_texel_1d_rgba8888, /* FetchTexel1D */
608 fetch_texel_2d_rgba8888, /* FetchTexel2D */
609 fetch_texel_3d_rgba8888, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000610 NULL, /* FetchTexel1Df */
611 NULL, /* FetchTexel2Df */
612 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000613 store_texel_rgba8888 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000614};
615
Brian Pauldefb0352004-05-13 15:26:51 +0000616const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
617 MESA_FORMAT_RGBA8888_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000618 GL_RGBA, /* BaseFormat */
619 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
620 8, /* RedBits */
621 8, /* GreenBits */
622 8, /* BlueBits */
623 8, /* AlphaBits */
624 0, /* LuminanceBits */
625 0, /* IntensityBits */
626 0, /* IndexBits */
627 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000628 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000629 4, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000630 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
631 fetch_texel_1d_rgba8888_rev, /* FetchTexel1D */
632 fetch_texel_2d_rgba8888_rev, /* FetchTexel2D */
633 fetch_texel_3d_rgba8888_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000634 NULL, /* FetchTexel1Df */
635 NULL, /* FetchTexel2Df */
636 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000637 store_texel_rgba8888_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000638};
639
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000640const struct gl_texture_format _mesa_texformat_argb8888 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000641 MESA_FORMAT_ARGB8888, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000642 GL_RGBA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000643 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000644 8, /* RedBits */
645 8, /* GreenBits */
646 8, /* BlueBits */
647 8, /* AlphaBits */
648 0, /* LuminanceBits */
649 0, /* IntensityBits */
650 0, /* IndexBits */
651 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000652 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000653 4, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000654 _mesa_texstore_argb8888, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000655 fetch_texel_1d_argb8888, /* FetchTexel1D */
656 fetch_texel_2d_argb8888, /* FetchTexel2D */
657 fetch_texel_3d_argb8888, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000658 NULL, /* FetchTexel1Df */
659 NULL, /* FetchTexel2Df */
660 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000661 store_texel_argb8888 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000662};
663
Brian Pauldefb0352004-05-13 15:26:51 +0000664const struct gl_texture_format _mesa_texformat_argb8888_rev = {
665 MESA_FORMAT_ARGB8888_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000666 GL_RGBA, /* BaseFormat */
667 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
668 8, /* RedBits */
669 8, /* GreenBits */
670 8, /* BlueBits */
671 8, /* AlphaBits */
672 0, /* LuminanceBits */
673 0, /* IntensityBits */
674 0, /* IndexBits */
675 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000676 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000677 4, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000678 _mesa_texstore_argb8888, /* StoreTexImageFunc */
679 fetch_texel_1d_argb8888_rev, /* FetchTexel1D */
680 fetch_texel_2d_argb8888_rev, /* FetchTexel2D */
681 fetch_texel_3d_argb8888_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000682 NULL, /* FetchTexel1Df */
683 NULL, /* FetchTexel2Df */
684 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000685 store_texel_argb8888_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000686};
687
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000688const struct gl_texture_format _mesa_texformat_rgb888 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000689 MESA_FORMAT_RGB888, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000690 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000691 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000692 8, /* RedBits */
693 8, /* GreenBits */
694 8, /* BlueBits */
695 0, /* AlphaBits */
696 0, /* LuminanceBits */
697 0, /* IntensityBits */
698 0, /* IndexBits */
699 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000700 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000701 3, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000702 _mesa_texstore_rgb888, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000703 fetch_texel_1d_rgb888, /* FetchTexel1D */
704 fetch_texel_2d_rgb888, /* FetchTexel2D */
705 fetch_texel_3d_rgb888, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000706 NULL, /* FetchTexel1Df */
707 NULL, /* FetchTexel2Df */
708 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000709 store_texel_rgb888 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000710};
711
Brian Paula156b492004-05-12 01:50:30 +0000712const struct gl_texture_format _mesa_texformat_bgr888 = {
713 MESA_FORMAT_BGR888, /* MesaFormat */
714 GL_RGB, /* BaseFormat */
715 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
716 8, /* RedBits */
717 8, /* GreenBits */
718 8, /* BlueBits */
719 0, /* AlphaBits */
720 0, /* LuminanceBits */
721 0, /* IntensityBits */
722 0, /* IndexBits */
723 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000724 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000725 3, /* TexelBytes */
726 _mesa_texstore_bgr888, /* StoreTexImageFunc */
727 fetch_texel_1d_bgr888, /* FetchTexel1D */
728 fetch_texel_2d_bgr888, /* FetchTexel2D */
729 fetch_texel_3d_bgr888, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000730 NULL, /* FetchTexel1Df */
731 NULL, /* FetchTexel2Df */
732 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000733 store_texel_bgr888 /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000734};
735
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000736const struct gl_texture_format _mesa_texformat_rgb565 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000737 MESA_FORMAT_RGB565, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000738 GL_RGB, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000739 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000740 5, /* RedBits */
741 6, /* GreenBits */
742 5, /* BlueBits */
743 0, /* AlphaBits */
744 0, /* LuminanceBits */
745 0, /* IntensityBits */
746 0, /* IndexBits */
747 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000748 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000749 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000750 _mesa_texstore_rgb565, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000751 fetch_texel_1d_rgb565, /* FetchTexel1D */
752 fetch_texel_2d_rgb565, /* FetchTexel2D */
753 fetch_texel_3d_rgb565, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000754 NULL, /* FetchTexel1Df */
755 NULL, /* FetchTexel2Df */
756 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000757 store_texel_rgb565 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000758};
759
Brian Pauldefb0352004-05-13 15:26:51 +0000760const struct gl_texture_format _mesa_texformat_rgb565_rev = {
761 MESA_FORMAT_RGB565_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000762 GL_RGB, /* BaseFormat */
763 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
764 5, /* RedBits */
765 6, /* GreenBits */
766 5, /* BlueBits */
767 0, /* AlphaBits */
768 0, /* LuminanceBits */
769 0, /* IntensityBits */
770 0, /* IndexBits */
771 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000772 0, /* StencilBits */
Brian Paula156b492004-05-12 01:50:30 +0000773 2, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000774 _mesa_texstore_rgb565, /* StoreTexImageFunc */
775 fetch_texel_1d_rgb565_rev, /* FetchTexel1D */
776 fetch_texel_2d_rgb565_rev, /* FetchTexel2D */
777 fetch_texel_3d_rgb565_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000778 NULL, /* FetchTexel1Df */
779 NULL, /* FetchTexel2Df */
780 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000781 store_texel_rgb565_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000782};
783
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000784const struct gl_texture_format _mesa_texformat_argb4444 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000785 MESA_FORMAT_ARGB4444, /* 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 4, /* RedBits */
789 4, /* GreenBits */
790 4, /* BlueBits */
791 4, /* 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 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000798 _mesa_texstore_argb4444, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000799 fetch_texel_1d_argb4444, /* FetchTexel1D */
800 fetch_texel_2d_argb4444, /* FetchTexel2D */
801 fetch_texel_3d_argb4444, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000802 NULL, /* FetchTexel1Df */
803 NULL, /* FetchTexel2Df */
804 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000805 store_texel_argb4444 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000806};
807
Brian Pauldefb0352004-05-13 15:26:51 +0000808const struct gl_texture_format _mesa_texformat_argb4444_rev = {
809 MESA_FORMAT_ARGB4444_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000810 GL_RGBA, /* BaseFormat */
811 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
812 4, /* RedBits */
813 4, /* GreenBits */
814 4, /* BlueBits */
815 4, /* 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 2, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000822 _mesa_texstore_argb4444, /* StoreTexImageFunc */
823 fetch_texel_1d_argb4444_rev, /* FetchTexel1D */
824 fetch_texel_2d_argb4444_rev, /* FetchTexel2D */
825 fetch_texel_3d_argb4444_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000826 NULL, /* FetchTexel1Df */
827 NULL, /* FetchTexel2Df */
828 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000829 store_texel_argb4444_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_argb1555 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000833 MESA_FORMAT_ARGB1555, /* 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 5, /* RedBits */
837 5, /* GreenBits */
838 5, /* BlueBits */
839 1, /* 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 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000846 _mesa_texstore_argb1555, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000847 fetch_texel_1d_argb1555, /* FetchTexel1D */
848 fetch_texel_2d_argb1555, /* FetchTexel2D */
849 fetch_texel_3d_argb1555, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000850 NULL, /* FetchTexel1Df */
851 NULL, /* FetchTexel2Df */
852 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000853 store_texel_argb1555 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000854};
855
Brian Pauldefb0352004-05-13 15:26:51 +0000856const struct gl_texture_format _mesa_texformat_argb1555_rev = {
857 MESA_FORMAT_ARGB1555_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000858 GL_RGBA, /* BaseFormat */
859 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
860 5, /* RedBits */
861 5, /* GreenBits */
862 5, /* BlueBits */
863 1, /* 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 2, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000870 _mesa_texstore_argb1555, /* StoreTexImageFunc */
871 fetch_texel_1d_argb1555_rev, /* FetchTexel1D */
872 fetch_texel_2d_argb1555_rev, /* FetchTexel2D */
873 fetch_texel_3d_argb1555_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000874 NULL, /* FetchTexel1Df */
875 NULL, /* FetchTexel2Df */
876 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000877 store_texel_argb1555_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_al88 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000881 MESA_FORMAT_AL88, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000882 GL_LUMINANCE_ALPHA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000883 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000884 0, /* RedBits */
885 0, /* GreenBits */
886 0, /* BlueBits */
887 8, /* AlphaBits */
888 8, /* 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 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000894 _mesa_texstore_al88, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000895 fetch_texel_1d_al88, /* FetchTexel1D */
896 fetch_texel_2d_al88, /* FetchTexel2D */
897 fetch_texel_3d_al88, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000898 NULL, /* FetchTexel1Df */
899 NULL, /* FetchTexel2Df */
900 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000901 store_texel_al88 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000902};
903
Brian Pauldefb0352004-05-13 15:26:51 +0000904const struct gl_texture_format _mesa_texformat_al88_rev = {
905 MESA_FORMAT_AL88_REV, /* MesaFormat */
Brian Paula156b492004-05-12 01:50:30 +0000906 GL_LUMINANCE_ALPHA, /* BaseFormat */
907 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
908 0, /* RedBits */
909 0, /* GreenBits */
910 0, /* BlueBits */
911 8, /* AlphaBits */
912 8, /* 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 2, /* TexelBytes */
Brian Pauldefb0352004-05-13 15:26:51 +0000918 _mesa_texstore_al88, /* StoreTexImageFunc */
919 fetch_texel_1d_al88_rev, /* FetchTexel1D */
920 fetch_texel_2d_al88_rev, /* FetchTexel2D */
921 fetch_texel_3d_al88_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000922 NULL, /* FetchTexel1Df */
923 NULL, /* FetchTexel2Df */
924 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000925 store_texel_al88_rev /* StoreTexel */
Brian Paula156b492004-05-12 01:50:30 +0000926};
927
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000928const struct gl_texture_format _mesa_texformat_rgb332 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000929 MESA_FORMAT_RGB332, /* 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 3, /* RedBits */
933 3, /* GreenBits */
934 2, /* 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 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000942 _mesa_texstore_rgb332, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000943 fetch_texel_1d_rgb332, /* FetchTexel1D */
944 fetch_texel_2d_rgb332, /* FetchTexel2D */
945 fetch_texel_3d_rgb332, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000946 NULL, /* FetchTexel1Df */
947 NULL, /* FetchTexel2Df */
948 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000949 store_texel_rgb332 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000950};
951
952const struct gl_texture_format _mesa_texformat_a8 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000953 MESA_FORMAT_A8, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000954 GL_ALPHA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000955 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000956 0, /* RedBits */
957 0, /* GreenBits */
958 0, /* BlueBits */
959 8, /* AlphaBits */
960 0, /* LuminanceBits */
961 0, /* IntensityBits */
962 0, /* IndexBits */
963 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000964 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000965 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000966 _mesa_texstore_a8, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000967 fetch_texel_1d_a8, /* FetchTexel1D */
968 fetch_texel_2d_a8, /* FetchTexel2D */
969 fetch_texel_3d_a8, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000970 NULL, /* FetchTexel1Df */
971 NULL, /* FetchTexel2Df */
972 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000973 store_texel_a8 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000974};
975
976const struct gl_texture_format _mesa_texformat_l8 = {
Gareth Hughes38f28662001-03-28 20:40:51 +0000977 MESA_FORMAT_L8, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +0000978 GL_LUMINANCE, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +0000979 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000980 0, /* RedBits */
981 0, /* GreenBits */
982 0, /* BlueBits */
983 0, /* AlphaBits */
984 8, /* LuminanceBits */
985 0, /* IntensityBits */
986 0, /* IndexBits */
987 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +0000988 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000989 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +0000990 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +0000991 fetch_texel_1d_l8, /* FetchTexel1D */
992 fetch_texel_2d_l8, /* FetchTexel2D */
993 fetch_texel_3d_l8, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +0000994 NULL, /* FetchTexel1Df */
995 NULL, /* FetchTexel2Df */
996 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +0000997 store_texel_l8 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +0000998};
999
1000const struct gl_texture_format _mesa_texformat_i8 = {
Gareth Hughes38f28662001-03-28 20:40:51 +00001001 MESA_FORMAT_I8, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +00001002 GL_INTENSITY, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001003 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001004 0, /* RedBits */
1005 0, /* GreenBits */
1006 0, /* BlueBits */
1007 0, /* AlphaBits */
1008 0, /* LuminanceBits */
1009 8, /* 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 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001014 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +00001015 fetch_texel_1d_i8, /* FetchTexel1D */
1016 fetch_texel_2d_i8, /* FetchTexel2D */
1017 fetch_texel_3d_i8, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +00001018 NULL, /* FetchTexel1Df */
1019 NULL, /* FetchTexel2Df */
1020 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001021 store_texel_i8 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001022};
1023
1024const struct gl_texture_format _mesa_texformat_ci8 = {
Gareth Hughes38f28662001-03-28 20:40:51 +00001025 MESA_FORMAT_CI8, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +00001026 GL_COLOR_INDEX, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001027 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001028 0, /* RedBits */
1029 0, /* GreenBits */
1030 0, /* BlueBits */
1031 0, /* AlphaBits */
1032 0, /* LuminanceBits */
1033 0, /* IntensityBits */
1034 8, /* IndexBits */
1035 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001036 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001037 1, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001038 _mesa_texstore_ci8, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +00001039 fetch_texel_1d_ci8, /* FetchTexel1D */
1040 fetch_texel_2d_ci8, /* FetchTexel2D */
1041 fetch_texel_3d_ci8, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +00001042 NULL, /* FetchTexel1Df */
1043 NULL, /* FetchTexel2Df */
1044 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001045 store_texel_ci8 /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001046};
1047
Brian Paulc5b99502002-09-21 16:51:25 +00001048const struct gl_texture_format _mesa_texformat_ycbcr = {
1049 MESA_FORMAT_YCBCR, /* MesaFormat */
1050 GL_YCBCR_MESA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001051 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Brian Paulc5b99502002-09-21 16:51:25 +00001052 0, /* RedBits */
1053 0, /* GreenBits */
1054 0, /* BlueBits */
1055 0, /* AlphaBits */
1056 0, /* LuminanceBits */
1057 0, /* IntensityBits */
1058 0, /* IndexBits */
1059 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001060 0, /* StencilBits */
Brian Paulc5b99502002-09-21 16:51:25 +00001061 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001062 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +00001063 fetch_texel_1d_ycbcr, /* FetchTexel1D */
1064 fetch_texel_2d_ycbcr, /* FetchTexel2D */
1065 fetch_texel_3d_ycbcr, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +00001066 NULL, /* FetchTexel1Df */
1067 NULL, /* FetchTexel2Df */
1068 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001069 store_texel_ycbcr /* StoreTexel */
Brian Paulc5b99502002-09-21 16:51:25 +00001070};
1071
Brian Paulc5b99502002-09-21 16:51:25 +00001072const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
1073 MESA_FORMAT_YCBCR_REV, /* MesaFormat */
1074 GL_YCBCR_MESA, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001075 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
Brian Paulc5b99502002-09-21 16:51:25 +00001076 0, /* RedBits */
1077 0, /* GreenBits */
1078 0, /* BlueBits */
1079 0, /* AlphaBits */
1080 0, /* LuminanceBits */
1081 0, /* IntensityBits */
1082 0, /* IndexBits */
1083 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001084 0, /* StencilBits */
Brian Paulc5b99502002-09-21 16:51:25 +00001085 2, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001086 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
Brian Paul4f295ce2004-01-23 01:59:54 +00001087 fetch_texel_1d_ycbcr_rev, /* FetchTexel1D */
1088 fetch_texel_2d_ycbcr_rev, /* FetchTexel2D */
1089 fetch_texel_3d_ycbcr_rev, /* FetchTexel3D */
Brian Paul63b5b8e2005-09-15 01:55:40 +00001090 NULL, /* FetchTexel1Df */
1091 NULL, /* FetchTexel2Df */
1092 NULL, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001093 store_texel_ycbcr_rev /* StoreTexel */
Brian Paulc5b99502002-09-21 16:51:25 +00001094};
1095
Brian Paul1ad7b992005-09-28 02:29:50 +00001096const struct gl_texture_format _mesa_texformat_z24_s8 = {
1097 MESA_FORMAT_Z24_S8, /* MesaFormat */
1098 GL_DEPTH_STENCIL_EXT, /* BaseFormat */
1099 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1100 0, /* RedBits */
1101 0, /* GreenBits */
1102 0, /* BlueBits */
1103 0, /* AlphaBits */
1104 0, /* LuminanceBits */
1105 0, /* IntensityBits */
1106 0, /* IndexBits */
1107 24, /* DepthBits */
1108 8, /* StencilBits */
1109 4, /* TexelBytes */
1110 NULL/*_mesa_texstore_z24_s8*/, /* StoreTexImageFunc */
1111 NULL, /* FetchTexel1D */
1112 NULL, /* FetchTexel2D */
1113 NULL, /* FetchTexel3D */
1114 fetch_texel_1d_f_z24_s8, /* FetchTexel1Df */
1115 fetch_texel_2d_f_z24_s8, /* FetchTexel2Df */
1116 fetch_texel_3d_f_z24_s8, /* FetchTexel3Df */
1117 store_texel_z24_s8 /* StoreTexel */
1118};
1119
Keith Whitwell6dc85572003-07-17 13:43:59 +00001120/*@}*/
1121
1122
1123/***************************************************************/
1124/** \name Null format (useful for proxy textures) */
1125/*@{*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001126
1127const struct gl_texture_format _mesa_null_texformat = {
Gareth Hughes38f28662001-03-28 20:40:51 +00001128 -1, /* MesaFormat */
Brian Paul1c85aa32001-04-20 16:46:04 +00001129 0, /* BaseFormat */
Brian Paulf959f6e2004-04-22 00:27:31 +00001130 GL_NONE, /* DataType */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001131 0, /* RedBits */
1132 0, /* GreenBits */
1133 0, /* BlueBits */
1134 0, /* AlphaBits */
1135 0, /* LuminanceBits */
1136 0, /* IntensityBits */
1137 0, /* IndexBits */
1138 0, /* DepthBits */
Brian Paul1ad7b992005-09-28 02:29:50 +00001139 0, /* StencilBits */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001140 0, /* TexelBytes */
Brian Paulf959f6e2004-04-22 00:27:31 +00001141 NULL, /* StoreTexImageFunc */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001142 fetch_null_texel, /* FetchTexel1D */
1143 fetch_null_texel, /* FetchTexel2D */
1144 fetch_null_texel, /* FetchTexel3D */
Brian Paul4f295ce2004-01-23 01:59:54 +00001145 fetch_null_texelf, /* FetchTexel1Df */
1146 fetch_null_texelf, /* FetchTexel2Df */
1147 fetch_null_texelf, /* FetchTexel3Df */
Brian Paule4b23562005-05-04 20:11:35 +00001148 store_null_texel /* StoreTexel */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001149};
1150
Keith Whitwell6dc85572003-07-17 13:43:59 +00001151/*@}*/
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001152
Keith Whitwell6dc85572003-07-17 13:43:59 +00001153
Keith Whitwell6dc85572003-07-17 13:43:59 +00001154/**
Brian Paulfe031082004-01-24 17:02:19 +00001155 * Choose an appropriate texture format given the format, type and
1156 * internalFormat parameters passed to glTexImage().
Keith Whitwell6dc85572003-07-17 13:43:59 +00001157 *
Brian Paulfe031082004-01-24 17:02:19 +00001158 * \param ctx the GL context.
1159 * \param internalFormat user's prefered internal texture format.
1160 * \param format incoming image pixel format.
1161 * \param type incoming image data type.
Keith Whitwell6dc85572003-07-17 13:43:59 +00001162 *
Brian Paulfe031082004-01-24 17:02:19 +00001163 * \return a pointer to a gl_texture_format object which describes the
1164 * choosen texture format, or NULL on failure.
Keith Whitwell6dc85572003-07-17 13:43:59 +00001165 *
1166 * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers
Brian Paulf959f6e2004-04-22 00:27:31 +00001167 * will typically override this function with a specialized version.
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001168 */
Brian Paul7d58f442001-04-04 21:54:20 +00001169const struct gl_texture_format *
1170_mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
1171 GLenum format, GLenum type )
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001172{
Brian Paul7d58f442001-04-04 21:54:20 +00001173 (void) format;
1174 (void) type;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001175
Brian Paulf959f6e2004-04-22 00:27:31 +00001176 switch (internalFormat) {
1177 /* RGBA formats */
1178 case 4:
1179 case GL_RGBA:
Brian Paulf959f6e2004-04-22 00:27:31 +00001180 case GL_RGB10_A2:
1181 case GL_RGBA12:
1182 case GL_RGBA16:
1183 return &_mesa_texformat_rgba;
Brian Paula156b492004-05-12 01:50:30 +00001184 case GL_RGBA8:
1185 return &_mesa_texformat_rgba8888;
Brian Paulf959f6e2004-04-22 00:27:31 +00001186 case GL_RGB5_A1:
1187 return &_mesa_texformat_argb1555;
1188 case GL_RGBA2:
Brian Pauldefb0352004-05-13 15:26:51 +00001189 return &_mesa_texformat_argb4444_rev; /* just to test another format*/
Brian Paulf959f6e2004-04-22 00:27:31 +00001190 case GL_RGBA4:
1191 return &_mesa_texformat_argb4444;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001192
Brian Paulf959f6e2004-04-22 00:27:31 +00001193 /* RGB formats */
1194 case 3:
1195 case GL_RGB:
Brian Paulf959f6e2004-04-22 00:27:31 +00001196 case GL_RGB10:
1197 case GL_RGB12:
1198 case GL_RGB16:
1199 return &_mesa_texformat_rgb;
Brian Pauldefb0352004-05-13 15:26:51 +00001200 case GL_RGB8:
1201 return &_mesa_texformat_rgb888;
Brian Paulf959f6e2004-04-22 00:27:31 +00001202 case GL_R3_G3_B2:
1203 return &_mesa_texformat_rgb332;
1204 case GL_RGB4:
Brian Pauldefb0352004-05-13 15:26:51 +00001205 return &_mesa_texformat_rgb565_rev; /* just to test another format */
Brian Paulf959f6e2004-04-22 00:27:31 +00001206 case GL_RGB5:
1207 return &_mesa_texformat_rgb565;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001208
Brian Paulf959f6e2004-04-22 00:27:31 +00001209 /* Alpha formats */
1210 case GL_ALPHA:
1211 case GL_ALPHA4:
Brian Paulf959f6e2004-04-22 00:27:31 +00001212 case GL_ALPHA12:
1213 case GL_ALPHA16:
1214 return &_mesa_texformat_alpha;
Brian Paula156b492004-05-12 01:50:30 +00001215 case GL_ALPHA8:
1216 return &_mesa_texformat_a8;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001217
Brian Paulf959f6e2004-04-22 00:27:31 +00001218 /* Luminance formats */
1219 case 1:
1220 case GL_LUMINANCE:
1221 case GL_LUMINANCE4:
1222 case GL_LUMINANCE12:
1223 case GL_LUMINANCE16:
1224 return &_mesa_texformat_luminance;
1225 case GL_LUMINANCE8:
1226 return &_mesa_texformat_l8;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001227
Brian Paulf959f6e2004-04-22 00:27:31 +00001228 /* Luminance/Alpha formats */
1229 case 2:
1230 case GL_LUMINANCE_ALPHA:
1231 case GL_LUMINANCE4_ALPHA4:
1232 case GL_LUMINANCE6_ALPHA2:
1233 case GL_LUMINANCE12_ALPHA4:
1234 case GL_LUMINANCE12_ALPHA12:
1235 case GL_LUMINANCE16_ALPHA16:
1236 return &_mesa_texformat_luminance_alpha;
1237 case GL_LUMINANCE8_ALPHA8:
1238 return &_mesa_texformat_al88;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001239
Brian Paulf959f6e2004-04-22 00:27:31 +00001240 case GL_INTENSITY:
1241 case GL_INTENSITY4:
1242 case GL_INTENSITY12:
1243 case GL_INTENSITY16:
1244 return &_mesa_texformat_intensity;
1245 case GL_INTENSITY8:
1246 return &_mesa_texformat_i8;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001247
Brian Paulf959f6e2004-04-22 00:27:31 +00001248 case GL_COLOR_INDEX:
1249 case GL_COLOR_INDEX1_EXT:
1250 case GL_COLOR_INDEX2_EXT:
1251 case GL_COLOR_INDEX4_EXT:
1252 case GL_COLOR_INDEX12_EXT:
1253 case GL_COLOR_INDEX16_EXT:
Brian Paulf959f6e2004-04-22 00:27:31 +00001254 case GL_COLOR_INDEX8_EXT:
1255 return &_mesa_texformat_ci8;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001256
Brian Paulf959f6e2004-04-22 00:27:31 +00001257 default:
1258 ; /* fallthrough */
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001259 }
Brian Paulf959f6e2004-04-22 00:27:31 +00001260
Brian Paul4618a9b2005-09-08 15:28:45 +00001261 if (ctx->Extensions.SGIX_depth_texture ||
1262 ctx->Extensions.ARB_depth_texture) {
Brian Paulf959f6e2004-04-22 00:27:31 +00001263 switch (internalFormat) {
1264 case GL_DEPTH_COMPONENT:
1265 case GL_DEPTH_COMPONENT24_SGIX:
1266 case GL_DEPTH_COMPONENT32_SGIX:
1267 return &_mesa_texformat_depth_component_float32;
1268 case GL_DEPTH_COMPONENT16_SGIX:
1269 return &_mesa_texformat_depth_component16;
1270 default:
1271 ; /* fallthrough */
1272 }
1273 }
1274
1275 if (ctx->Extensions.ARB_texture_compression) {
1276 switch (internalFormat) {
1277 case GL_COMPRESSED_ALPHA_ARB:
1278 return &_mesa_texformat_alpha;
1279 case GL_COMPRESSED_LUMINANCE_ARB:
1280 return &_mesa_texformat_luminance;
1281 case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
1282 return &_mesa_texformat_luminance_alpha;
1283 case GL_COMPRESSED_INTENSITY_ARB:
1284 return &_mesa_texformat_intensity;
1285 case GL_COMPRESSED_RGB_ARB:
1286 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1287 return &_mesa_texformat_rgb_fxt1;
1288 else if (ctx->Extensions.EXT_texture_compression_s3tc ||
1289 ctx->Extensions.S3_s3tc)
1290 return &_mesa_texformat_rgb_dxt1;
1291 else
1292 return &_mesa_texformat_rgb;
1293 case GL_COMPRESSED_RGBA_ARB:
1294 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1295 return &_mesa_texformat_rgba_fxt1;
1296 else if (ctx->Extensions.EXT_texture_compression_s3tc ||
1297 ctx->Extensions.S3_s3tc)
1298 return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
1299 else
1300 return &_mesa_texformat_rgba;
1301 default:
1302 ; /* fallthrough */
1303 }
1304 }
1305
1306 if (ctx->Extensions.MESA_ycbcr_texture) {
1307 if (internalFormat == GL_YCBCR_MESA) {
1308 if (type == GL_UNSIGNED_SHORT_8_8_MESA)
1309 return &_mesa_texformat_ycbcr;
1310 else
1311 return &_mesa_texformat_ycbcr_rev;
1312 }
1313 }
1314
1315 if (ctx->Extensions.TDFX_texture_compression_FXT1) {
1316 switch (internalFormat) {
1317 case GL_COMPRESSED_RGB_FXT1_3DFX:
1318 return &_mesa_texformat_rgb_fxt1;
1319 case GL_COMPRESSED_RGBA_FXT1_3DFX:
1320 return &_mesa_texformat_rgba_fxt1;
1321 default:
1322 ; /* fallthrough */
1323 }
1324 }
1325
1326 if (ctx->Extensions.EXT_texture_compression_s3tc) {
1327 switch (internalFormat) {
1328 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1329 return &_mesa_texformat_rgb_dxt1;
1330 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1331 return &_mesa_texformat_rgba_dxt1;
1332 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
1333 return &_mesa_texformat_rgba_dxt3;
1334 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
1335 return &_mesa_texformat_rgba_dxt5;
1336 default:
1337 ; /* fallthrough */
1338 }
1339 }
1340
1341 if (ctx->Extensions.S3_s3tc) {
1342 switch (internalFormat) {
1343 case GL_RGB_S3TC:
1344 case GL_RGB4_S3TC:
1345 return &_mesa_texformat_rgb_dxt1;
1346 case GL_RGBA_S3TC:
1347 case GL_RGBA4_S3TC:
1348 return &_mesa_texformat_rgba_dxt3;
1349 default:
1350 ; /* fallthrough */
1351 }
1352 }
1353
1354 if (ctx->Extensions.ARB_texture_float) {
1355 switch (internalFormat) {
1356 case GL_ALPHA16F_ARB:
1357 return &_mesa_texformat_alpha_float16;
1358 case GL_ALPHA32F_ARB:
1359 return &_mesa_texformat_alpha_float32;
1360 case GL_LUMINANCE16F_ARB:
1361 return &_mesa_texformat_luminance_float16;
1362 case GL_LUMINANCE32F_ARB:
1363 return &_mesa_texformat_luminance_float32;
1364 case GL_LUMINANCE_ALPHA16F_ARB:
1365 return &_mesa_texformat_luminance_alpha_float16;
1366 case GL_LUMINANCE_ALPHA32F_ARB:
1367 return &_mesa_texformat_luminance_alpha_float32;
1368 case GL_INTENSITY16F_ARB:
1369 return &_mesa_texformat_intensity_float16;
1370 case GL_INTENSITY32F_ARB:
1371 return &_mesa_texformat_intensity_float32;
1372 case GL_RGB16F_ARB:
1373 return &_mesa_texformat_rgb_float16;
1374 case GL_RGB32F_ARB:
1375 return &_mesa_texformat_rgb_float32;
1376 case GL_RGBA16F_ARB:
1377 return &_mesa_texformat_rgba_float16;
1378 case GL_RGBA32F_ARB:
1379 return &_mesa_texformat_rgba_float32;
1380 default:
1381 ; /* fallthrough */
1382 }
1383 }
1384
Brian Paul1ad7b992005-09-28 02:29:50 +00001385 if (ctx->Extensions.EXT_packed_depth_stencil) {
1386 switch (internalFormat) {
1387 case GL_DEPTH_STENCIL_EXT:
1388 case GL_DEPTH24_STENCIL8_EXT:
1389 return &_mesa_texformat_z24_s8;
1390 default:
1391 ; /* fallthrough */
1392 }
1393 }
1394
Brian Paulf959f6e2004-04-22 00:27:31 +00001395 _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
1396 return NULL;
Gareth Hughes2c3d34c2001-03-18 08:53:49 +00001397}