Remove a bunch texel fetch functions that can be handled by the new
[mesa.git] / src / mesa / main / texformat.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5
4 *
5 * Copyright (C) 1999-2005 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
25
26 /**
27 * \file texformat.c
28 * Texture formats.
29 *
30 * \author Gareth Hughes
31 */
32
33
34 #include "colormac.h"
35 #include "context.h"
36 #include "texformat.h"
37 #include "texstore.h"
38
39
40
41 /* Texel fetch routines for all supported formats
42 */
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
52 /**
53 * Null texel fetch function.
54 *
55 * Have to have this so the FetchTexel function pointer is never NULL.
56 */
57 static void fetch_null_texel( const struct gl_texture_image *texImage,
58 GLint i, GLint j, GLint k, GLchan *texel )
59 {
60 (void) texImage; (void) i; (void) j; (void) k;
61 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
68 static void fetch_null_texelf( const struct gl_texture_image *texImage,
69 GLint i, GLint j, GLint k, GLfloat *texel )
70 {
71 (void) texImage; (void) i; (void) j; (void) k;
72 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!");
77 }
78
79 static 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
86 /**
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
99
100 /***************************************************************/
101 /** \name Default GLchan-based formats */
102 /*@{*/
103
104 const struct gl_texture_format _mesa_texformat_rgba = {
105 MESA_FORMAT_RGBA, /* MesaFormat */
106 GL_RGBA, /* BaseFormat */
107 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
108 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 */
116 4 * sizeof(GLchan), /* TexelBytes */
117 _mesa_texstore_rgba, /* StoreTexImageFunc */
118 fetch_texel_1d_rgba, /* FetchTexel1D */
119 fetch_texel_2d_rgba, /* FetchTexel2D */
120 fetch_texel_3d_rgba, /* FetchTexel3D */
121 fetch_texel_1d_f_rgba, /* FetchTexel1Df */
122 fetch_texel_2d_f_rgba, /* FetchTexel2Df */
123 fetch_texel_3d_f_rgba, /* FetchTexel3Df */
124 store_texel_rgba /* StoreTexel */
125 };
126
127 const struct gl_texture_format _mesa_texformat_rgb = {
128 MESA_FORMAT_RGB, /* MesaFormat */
129 GL_RGB, /* BaseFormat */
130 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
131 CHAN_BITS, /* RedBits */
132 CHAN_BITS, /* GreenBits */
133 CHAN_BITS, /* BlueBits */
134 0, /* AlphaBits */
135 0, /* LuminanceBits */
136 0, /* IntensityBits */
137 0, /* IndexBits */
138 0, /* DepthBits */
139 3 * sizeof(GLchan), /* TexelBytes */
140 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
141 fetch_texel_1d_rgb, /* FetchTexel1D */
142 fetch_texel_2d_rgb, /* FetchTexel2D */
143 fetch_texel_3d_rgb, /* FetchTexel3D */
144 fetch_texel_1d_f_rgb, /* FetchTexel1Df */
145 fetch_texel_2d_f_rgb, /* FetchTexel2Df */
146 fetch_texel_3d_f_rgb, /* FetchTexel3Df */
147 store_texel_rgb /* StoreTexel */
148 };
149
150 const struct gl_texture_format _mesa_texformat_alpha = {
151 MESA_FORMAT_ALPHA, /* MesaFormat */
152 GL_ALPHA, /* BaseFormat */
153 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
154 0, /* RedBits */
155 0, /* GreenBits */
156 0, /* BlueBits */
157 CHAN_BITS, /* AlphaBits */
158 0, /* LuminanceBits */
159 0, /* IntensityBits */
160 0, /* IndexBits */
161 0, /* DepthBits */
162 sizeof(GLchan), /* TexelBytes */
163 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
164 fetch_texel_1d_alpha, /* FetchTexel1D */
165 fetch_texel_2d_alpha, /* FetchTexel2D */
166 fetch_texel_3d_alpha, /* FetchTexel3D */
167 NULL, /* FetchTexel1Df */
168 NULL, /* FetchTexel2Df */
169 NULL, /* FetchTexel3Df */
170 store_texel_alpha /* StoreTexel */
171 };
172
173 const struct gl_texture_format _mesa_texformat_luminance = {
174 MESA_FORMAT_LUMINANCE, /* MesaFormat */
175 GL_LUMINANCE, /* BaseFormat */
176 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
177 0, /* RedBits */
178 0, /* GreenBits */
179 0, /* BlueBits */
180 0, /* AlphaBits */
181 CHAN_BITS, /* LuminanceBits */
182 0, /* IntensityBits */
183 0, /* IndexBits */
184 0, /* DepthBits */
185 sizeof(GLchan), /* TexelBytes */
186 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
187 fetch_texel_1d_luminance, /* FetchTexel1D */
188 fetch_texel_2d_luminance, /* FetchTexel2D */
189 fetch_texel_3d_luminance, /* FetchTexel3D */
190 NULL, /* FetchTexel1Df */
191 NULL, /* FetchTexel2Df */
192 NULL, /* FetchTexel3Df */
193 store_texel_luminance /* StoreTexel */
194 };
195
196 const struct gl_texture_format _mesa_texformat_luminance_alpha = {
197 MESA_FORMAT_LUMINANCE_ALPHA, /* MesaFormat */
198 GL_LUMINANCE_ALPHA, /* BaseFormat */
199 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
200 0, /* RedBits */
201 0, /* GreenBits */
202 0, /* BlueBits */
203 CHAN_BITS, /* AlphaBits */
204 CHAN_BITS, /* LuminanceBits */
205 0, /* IntensityBits */
206 0, /* IndexBits */
207 0, /* DepthBits */
208 2 * sizeof(GLchan), /* TexelBytes */
209 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
210 fetch_texel_1d_luminance_alpha, /* FetchTexel1D */
211 fetch_texel_2d_luminance_alpha, /* FetchTexel2D */
212 fetch_texel_3d_luminance_alpha, /* FetchTexel3D */
213 NULL, /* FetchTexel1Df */
214 NULL, /* FetchTexel2Df */
215 NULL, /* FetchTexel3Df */
216 store_texel_luminance_alpha /* StoreTexel */
217 };
218
219 const struct gl_texture_format _mesa_texformat_intensity = {
220 MESA_FORMAT_INTENSITY, /* MesaFormat */
221 GL_INTENSITY, /* BaseFormat */
222 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
223 0, /* RedBits */
224 0, /* GreenBits */
225 0, /* BlueBits */
226 0, /* AlphaBits */
227 0, /* LuminanceBits */
228 CHAN_BITS, /* IntensityBits */
229 0, /* IndexBits */
230 0, /* DepthBits */
231 sizeof(GLchan), /* TexelBytes */
232 _mesa_texstore_rgba,/*yes*/ /* StoreTexImageFunc */
233 fetch_texel_1d_intensity, /* FetchTexel1D */
234 fetch_texel_2d_intensity, /* FetchTexel2D */
235 fetch_texel_3d_intensity, /* FetchTexel3D */
236 NULL, /* FetchTexel1Df */
237 NULL, /* FetchTexel2Df */
238 NULL, /* FetchTexel3Df */
239 store_texel_intensity /* StoreTexel */
240 };
241
242 const struct gl_texture_format _mesa_texformat_depth_component_float32 = {
243 MESA_FORMAT_DEPTH_COMPONENT_FLOAT32, /* MesaFormat */
244 GL_DEPTH_COMPONENT, /* BaseFormat */
245 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
246 0, /* RedBits */
247 0, /* GreenBits */
248 0, /* BlueBits */
249 0, /* AlphaBits */
250 0, /* LuminanceBits */
251 0, /* IntensityBits */
252 0, /* IndexBits */
253 sizeof(GLfloat) * 8, /* DepthBits */
254 sizeof(GLfloat), /* TexelBytes */
255 _mesa_texstore_depth_component_float32,/* StoreTexImageFunc */
256 NULL, /* FetchTexel1D */
257 NULL, /* FetchTexel1D */
258 NULL, /* FetchTexel1D */
259 fetch_texel_1d_f_depth_component_f32,/* FetchTexel1Df */
260 fetch_texel_2d_f_depth_component_f32,/* FetchTexel2Df */
261 fetch_texel_3d_f_depth_component_f32,/* FetchTexel3Df */
262 store_texel_depth_component_f32 /* StoreTexel */
263 };
264
265 const struct gl_texture_format _mesa_texformat_depth_component16 = {
266 MESA_FORMAT_DEPTH_COMPONENT16, /* MesaFormat */
267 GL_DEPTH_COMPONENT, /* BaseFormat */
268 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
269 0, /* RedBits */
270 0, /* GreenBits */
271 0, /* BlueBits */
272 0, /* AlphaBits */
273 0, /* LuminanceBits */
274 0, /* IntensityBits */
275 0, /* IndexBits */
276 sizeof(GLushort) * 8, /* DepthBits */
277 sizeof(GLushort), /* TexelBytes */
278 _mesa_texstore_depth_component16, /* StoreTexImageFunc */
279 NULL, /* FetchTexel1D */
280 NULL, /* FetchTexel1D */
281 NULL, /* FetchTexel1D */
282 fetch_texel_1d_f_depth_component16, /* FetchTexel1Df */
283 fetch_texel_2d_f_depth_component16, /* FetchTexel2Df */
284 fetch_texel_3d_f_depth_component16, /* FetchTexel3Df */
285 store_texel_depth_component16 /* StoreTexel */
286 };
287
288 const struct gl_texture_format _mesa_texformat_rgba_float32 = {
289 MESA_FORMAT_RGBA_FLOAT32, /* MesaFormat */
290 GL_RGBA, /* BaseFormat */
291 GL_FLOAT, /* DataType */
292 8 * sizeof(GLfloat), /* RedBits */
293 8 * sizeof(GLfloat), /* GreenBits */
294 8 * sizeof(GLfloat), /* BlueBits */
295 8 * sizeof(GLfloat), /* AlphaBits */
296 0, /* LuminanceBits */
297 0, /* IntensityBits */
298 0, /* IndexBits */
299 0, /* DepthBits */
300 4 * sizeof(GLfloat), /* TexelBytes */
301 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
302 NULL, /* FetchTexel1D */
303 NULL, /* FetchTexel1D */
304 NULL, /* FetchTexel1D */
305 fetch_texel_1d_f_rgba_f32, /* FetchTexel1Df */
306 fetch_texel_2d_f_rgba_f32, /* FetchTexel2Df */
307 fetch_texel_3d_f_rgba_f32, /* FetchTexel3Df */
308 store_texel_rgba_f32 /* StoreTexel */
309 };
310
311 const struct gl_texture_format _mesa_texformat_rgba_float16 = {
312 MESA_FORMAT_RGBA_FLOAT16, /* MesaFormat */
313 GL_RGBA, /* BaseFormat */
314 GL_FLOAT, /* DataType */
315 8 * sizeof(GLhalfARB), /* RedBits */
316 8 * sizeof(GLhalfARB), /* GreenBits */
317 8 * sizeof(GLhalfARB), /* BlueBits */
318 8 * sizeof(GLhalfARB), /* AlphaBits */
319 0, /* LuminanceBits */
320 0, /* IntensityBits */
321 0, /* IndexBits */
322 0, /* DepthBits */
323 4 * sizeof(GLhalfARB), /* TexelBytes */
324 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
325 NULL, /* FetchTexel1D */
326 NULL, /* FetchTexel1D */
327 NULL, /* FetchTexel1D */
328 fetch_texel_1d_f_rgba_f16, /* FetchTexel1Df */
329 fetch_texel_2d_f_rgba_f16, /* FetchTexel2Df */
330 fetch_texel_3d_f_rgba_f16, /* FetchTexel3Df */
331 store_texel_rgba_f16 /* StoreTexel */
332 };
333
334 const struct gl_texture_format _mesa_texformat_rgb_float32 = {
335 MESA_FORMAT_RGB_FLOAT32, /* MesaFormat */
336 GL_RGB, /* BaseFormat */
337 GL_FLOAT, /* DataType */
338 8 * sizeof(GLfloat), /* RedBits */
339 8 * sizeof(GLfloat), /* GreenBits */
340 8 * sizeof(GLfloat), /* BlueBits */
341 0, /* AlphaBits */
342 0, /* LuminanceBits */
343 0, /* IntensityBits */
344 0, /* IndexBits */
345 0, /* DepthBits */
346 3 * sizeof(GLfloat), /* TexelBytes */
347 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
348 NULL, /* FetchTexel1D */
349 NULL, /* FetchTexel1D */
350 NULL, /* FetchTexel1D */
351 fetch_texel_1d_f_rgb_f32, /* FetchTexel1Df */
352 fetch_texel_2d_f_rgb_f32, /* FetchTexel2Df */
353 fetch_texel_3d_f_rgb_f32, /* FetchTexel3Df */
354 store_texel_rgb_f32 /* StoreTexel */
355 };
356
357 const struct gl_texture_format _mesa_texformat_rgb_float16 = {
358 MESA_FORMAT_RGB_FLOAT16, /* MesaFormat */
359 GL_RGB, /* BaseFormat */
360 GL_FLOAT, /* DataType */
361 8 * sizeof(GLhalfARB), /* RedBits */
362 8 * sizeof(GLhalfARB), /* GreenBits */
363 8 * sizeof(GLhalfARB), /* BlueBits */
364 0, /* AlphaBits */
365 0, /* LuminanceBits */
366 0, /* IntensityBits */
367 0, /* IndexBits */
368 0, /* DepthBits */
369 3 * sizeof(GLhalfARB), /* TexelBytes */
370 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
371 NULL, /* FetchTexel1D */
372 NULL, /* FetchTexel1D */
373 NULL, /* FetchTexel1D */
374 fetch_texel_1d_f_rgb_f16, /* FetchTexel1Df */
375 fetch_texel_2d_f_rgb_f16, /* FetchTexel2Df */
376 fetch_texel_3d_f_rgb_f16, /* FetchTexel3Df */
377 store_texel_rgb_f16 /* StoreTexel */
378 };
379
380 const struct gl_texture_format _mesa_texformat_alpha_float32 = {
381 MESA_FORMAT_ALPHA_FLOAT32, /* MesaFormat */
382 GL_ALPHA, /* BaseFormat */
383 GL_FLOAT, /* DataType */
384 0, /* RedBits */
385 0, /* GreenBits */
386 0, /* BlueBits */
387 8 * sizeof(GLfloat), /* AlphaBits */
388 0, /* LuminanceBits */
389 0, /* IntensityBits */
390 0, /* IndexBits */
391 0, /* DepthBits */
392 1 * sizeof(GLfloat), /* TexelBytes */
393 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
394 NULL, /* FetchTexel1D */
395 NULL, /* FetchTexel1D */
396 NULL, /* FetchTexel1D */
397 fetch_texel_1d_f_alpha_f32, /* FetchTexel1Df */
398 fetch_texel_2d_f_alpha_f32, /* FetchTexel2Df */
399 fetch_texel_3d_f_alpha_f32, /* FetchTexel3Df */
400 store_texel_alpha_f32 /* StoreTexel */
401 };
402
403 const struct gl_texture_format _mesa_texformat_alpha_float16 = {
404 MESA_FORMAT_ALPHA_FLOAT16, /* MesaFormat */
405 GL_ALPHA, /* BaseFormat */
406 GL_FLOAT, /* DataType */
407 0, /* RedBits */
408 0, /* GreenBits */
409 0, /* BlueBits */
410 8 * sizeof(GLhalfARB), /* AlphaBits */
411 0, /* LuminanceBits */
412 0, /* IntensityBits */
413 0, /* IndexBits */
414 0, /* DepthBits */
415 1 * sizeof(GLhalfARB), /* TexelBytes */
416 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
417 NULL, /* FetchTexel1D */
418 NULL, /* FetchTexel1D */
419 NULL, /* FetchTexel1D */
420 fetch_texel_1d_f_alpha_f16, /* FetchTexel1Df */
421 fetch_texel_2d_f_alpha_f16, /* FetchTexel2Df */
422 fetch_texel_3d_f_alpha_f16, /* FetchTexel3Df */
423 store_texel_alpha_f16 /* StoreTexel */
424 };
425
426 const struct gl_texture_format _mesa_texformat_luminance_float32 = {
427 MESA_FORMAT_LUMINANCE_FLOAT32, /* MesaFormat */
428 GL_LUMINANCE, /* BaseFormat */
429 GL_FLOAT, /* DataType */
430 0, /* RedBits */
431 0, /* GreenBits */
432 0, /* BlueBits */
433 0, /* AlphaBits */
434 8 * sizeof(GLfloat), /* LuminanceBits */
435 0, /* IntensityBits */
436 0, /* IndexBits */
437 0, /* DepthBits */
438 1 * sizeof(GLfloat), /* TexelBytes */
439 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
440 NULL, /* FetchTexel1D */
441 NULL, /* FetchTexel2D */
442 NULL, /* FetchTexel3D */
443 fetch_texel_1d_f_luminance_f32, /* FetchTexel1Df */
444 fetch_texel_2d_f_luminance_f32, /* FetchTexel2Df */
445 fetch_texel_3d_f_luminance_f32, /* FetchTexel3Df */
446 store_texel_luminance_f32 /* StoreTexel */
447 };
448
449 const struct gl_texture_format _mesa_texformat_luminance_float16 = {
450 MESA_FORMAT_LUMINANCE_FLOAT16, /* MesaFormat */
451 GL_LUMINANCE, /* BaseFormat */
452 GL_FLOAT, /* DataType */
453 0, /* RedBits */
454 0, /* GreenBits */
455 0, /* BlueBits */
456 0, /* AlphaBits */
457 8 * sizeof(GLhalfARB), /* LuminanceBits */
458 0, /* IntensityBits */
459 0, /* IndexBits */
460 0, /* DepthBits */
461 1 * sizeof(GLhalfARB), /* TexelBytes */
462 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
463 NULL, /* FetchTexel1D */
464 NULL, /* FetchTexel2D */
465 NULL, /* FetchTexel3D */
466 fetch_texel_1d_f_luminance_f16, /* FetchTexel1Df */
467 fetch_texel_2d_f_luminance_f16, /* FetchTexel2Df */
468 fetch_texel_3d_f_luminance_f16, /* FetchTexel3Df */
469 store_texel_luminance_f16 /* StoreTexel */
470 };
471
472 const struct gl_texture_format _mesa_texformat_luminance_alpha_float32 = {
473 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32, /* MesaFormat */
474 GL_LUMINANCE_ALPHA, /* BaseFormat */
475 GL_FLOAT, /* DataType */
476 0, /* RedBits */
477 0, /* GreenBits */
478 0, /* BlueBits */
479 8 * sizeof(GLfloat), /* AlphaBits */
480 8 * sizeof(GLfloat), /* LuminanceBits */
481 0, /* IntensityBits */
482 0, /* IndexBits */
483 0, /* DepthBits */
484 2 * sizeof(GLfloat), /* TexelBytes */
485 _mesa_texstore_rgba_float32, /* StoreTexImageFunc */
486 NULL, /* FetchTexel1D */
487 NULL, /* FetchTexel2D */
488 NULL, /* FetchTexel3D */
489 fetch_texel_1d_f_luminance_alpha_f32,/* FetchTexel1Df */
490 fetch_texel_2d_f_luminance_alpha_f32,/* FetchTexel2Df */
491 fetch_texel_3d_f_luminance_alpha_f32,/* FetchTexel3Df */
492 store_texel_luminance_alpha_f32 /* StoreTexel */
493 };
494
495 const struct gl_texture_format _mesa_texformat_luminance_alpha_float16 = {
496 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16, /* MesaFormat */
497 GL_LUMINANCE_ALPHA, /* BaseFormat */
498 GL_FLOAT, /* DataType */
499 0, /* RedBits */
500 0, /* GreenBits */
501 0, /* BlueBits */
502 8 * sizeof(GLhalfARB), /* AlphaBits */
503 8 * sizeof(GLhalfARB), /* LuminanceBits */
504 0, /* IntensityBits */
505 0, /* IndexBits */
506 0, /* DepthBits */
507 2 * sizeof(GLhalfARB), /* TexelBytes */
508 _mesa_texstore_rgba_float16, /* StoreTexImageFunc */
509 NULL, /* FetchTexel1D */
510 NULL, /* FetchTexel2D */
511 NULL, /* FetchTexel3D */
512 fetch_texel_1d_f_luminance_alpha_f16,/* FetchTexel1Df */
513 fetch_texel_2d_f_luminance_alpha_f16,/* FetchTexel2Df */
514 fetch_texel_3d_f_luminance_alpha_f16,/* FetchTexel3Df */
515 store_texel_luminance_alpha_f16 /* StoreTexel */
516 };
517
518 const struct gl_texture_format _mesa_texformat_intensity_float32 = {
519 MESA_FORMAT_INTENSITY_FLOAT32, /* MesaFormat */
520 GL_INTENSITY, /* BaseFormat */
521 GL_FLOAT, /* DataType */
522 0, /* RedBits */
523 0, /* GreenBits */
524 0, /* BlueBits */
525 0, /* AlphaBits */
526 0, /* LuminanceBits */
527 8 * sizeof(GLfloat), /* IntensityBits */
528 0, /* IndexBits */
529 0, /* DepthBits */
530 1 * sizeof(GLfloat), /* TexelBytes */
531 _mesa_texstore_rgba_float32,/*yes*/ /* StoreTexImageFunc */
532 NULL, /* FetchTexel1D */
533 NULL, /* FetchTexel2D */
534 NULL, /* FetchTexel3D */
535 fetch_texel_1d_f_intensity_f32, /* FetchTexel1Df */
536 fetch_texel_2d_f_intensity_f32, /* FetchTexel2Df */
537 fetch_texel_3d_f_intensity_f32, /* FetchTexel3Df */
538 store_texel_intensity_f32 /* StoreTexel */
539 };
540
541 const struct gl_texture_format _mesa_texformat_intensity_float16 = {
542 MESA_FORMAT_INTENSITY_FLOAT16, /* MesaFormat */
543 GL_INTENSITY, /* BaseFormat */
544 GL_FLOAT, /* DataType */
545 0, /* RedBits */
546 0, /* GreenBits */
547 0, /* BlueBits */
548 0, /* AlphaBits */
549 0, /* LuminanceBits */
550 8 * sizeof(GLhalfARB), /* IntensityBits */
551 0, /* IndexBits */
552 0, /* DepthBits */
553 1 * sizeof(GLhalfARB), /* TexelBytes */
554 _mesa_texstore_rgba_float16,/*yes*/ /* StoreTexImageFunc */
555 NULL, /* FetchTexel1D */
556 NULL, /* FetchTexel2D */
557 NULL, /* FetchTexel3D */
558 fetch_texel_1d_f_intensity_f16, /* FetchTexel1Df */
559 fetch_texel_2d_f_intensity_f16, /* FetchTexel2Df */
560 fetch_texel_3d_f_intensity_f16, /* FetchTexel3Df */
561 store_texel_intensity_f16 /* StoreTexel */
562 };
563
564
565 /*@}*/
566
567
568 /***************************************************************/
569 /** \name Hardware formats */
570 /*@{*/
571
572 const struct gl_texture_format _mesa_texformat_rgba8888 = {
573 MESA_FORMAT_RGBA8888, /* MesaFormat */
574 GL_RGBA, /* BaseFormat */
575 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
576 8, /* RedBits */
577 8, /* GreenBits */
578 8, /* BlueBits */
579 8, /* AlphaBits */
580 0, /* LuminanceBits */
581 0, /* IntensityBits */
582 0, /* IndexBits */
583 0, /* DepthBits */
584 4, /* TexelBytes */
585 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
586 fetch_texel_1d_rgba8888, /* FetchTexel1D */
587 fetch_texel_2d_rgba8888, /* FetchTexel2D */
588 fetch_texel_3d_rgba8888, /* FetchTexel3D */
589 NULL, /* FetchTexel1Df */
590 NULL, /* FetchTexel2Df */
591 NULL, /* FetchTexel3Df */
592 store_texel_rgba8888 /* StoreTexel */
593 };
594
595 const struct gl_texture_format _mesa_texformat_rgba8888_rev = {
596 MESA_FORMAT_RGBA8888_REV, /* MesaFormat */
597 GL_RGBA, /* BaseFormat */
598 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
599 8, /* RedBits */
600 8, /* GreenBits */
601 8, /* BlueBits */
602 8, /* AlphaBits */
603 0, /* LuminanceBits */
604 0, /* IntensityBits */
605 0, /* IndexBits */
606 0, /* DepthBits */
607 4, /* TexelBytes */
608 _mesa_texstore_rgba8888, /* StoreTexImageFunc */
609 fetch_texel_1d_rgba8888_rev, /* FetchTexel1D */
610 fetch_texel_2d_rgba8888_rev, /* FetchTexel2D */
611 fetch_texel_3d_rgba8888_rev, /* FetchTexel3D */
612 NULL, /* FetchTexel1Df */
613 NULL, /* FetchTexel2Df */
614 NULL, /* FetchTexel3Df */
615 store_texel_rgba8888_rev /* StoreTexel */
616 };
617
618 const struct gl_texture_format _mesa_texformat_argb8888 = {
619 MESA_FORMAT_ARGB8888, /* MesaFormat */
620 GL_RGBA, /* BaseFormat */
621 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
622 8, /* RedBits */
623 8, /* GreenBits */
624 8, /* BlueBits */
625 8, /* AlphaBits */
626 0, /* LuminanceBits */
627 0, /* IntensityBits */
628 0, /* IndexBits */
629 0, /* DepthBits */
630 4, /* TexelBytes */
631 _mesa_texstore_argb8888, /* StoreTexImageFunc */
632 fetch_texel_1d_argb8888, /* FetchTexel1D */
633 fetch_texel_2d_argb8888, /* FetchTexel2D */
634 fetch_texel_3d_argb8888, /* FetchTexel3D */
635 NULL, /* FetchTexel1Df */
636 NULL, /* FetchTexel2Df */
637 NULL, /* FetchTexel3Df */
638 store_texel_argb8888 /* StoreTexel */
639 };
640
641 const struct gl_texture_format _mesa_texformat_argb8888_rev = {
642 MESA_FORMAT_ARGB8888_REV, /* MesaFormat */
643 GL_RGBA, /* BaseFormat */
644 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
645 8, /* RedBits */
646 8, /* GreenBits */
647 8, /* BlueBits */
648 8, /* AlphaBits */
649 0, /* LuminanceBits */
650 0, /* IntensityBits */
651 0, /* IndexBits */
652 0, /* DepthBits */
653 4, /* TexelBytes */
654 _mesa_texstore_argb8888, /* StoreTexImageFunc */
655 fetch_texel_1d_argb8888_rev, /* FetchTexel1D */
656 fetch_texel_2d_argb8888_rev, /* FetchTexel2D */
657 fetch_texel_3d_argb8888_rev, /* FetchTexel3D */
658 NULL, /* FetchTexel1Df */
659 NULL, /* FetchTexel2Df */
660 NULL, /* FetchTexel3Df */
661 store_texel_argb8888_rev /* StoreTexel */
662 };
663
664 const struct gl_texture_format _mesa_texformat_rgb888 = {
665 MESA_FORMAT_RGB888, /* MesaFormat */
666 GL_RGB, /* BaseFormat */
667 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
668 8, /* RedBits */
669 8, /* GreenBits */
670 8, /* BlueBits */
671 0, /* AlphaBits */
672 0, /* LuminanceBits */
673 0, /* IntensityBits */
674 0, /* IndexBits */
675 0, /* DepthBits */
676 3, /* TexelBytes */
677 _mesa_texstore_rgb888, /* StoreTexImageFunc */
678 fetch_texel_1d_rgb888, /* FetchTexel1D */
679 fetch_texel_2d_rgb888, /* FetchTexel2D */
680 fetch_texel_3d_rgb888, /* FetchTexel3D */
681 NULL, /* FetchTexel1Df */
682 NULL, /* FetchTexel2Df */
683 NULL, /* FetchTexel3Df */
684 store_texel_rgb888 /* StoreTexel */
685 };
686
687 const struct gl_texture_format _mesa_texformat_bgr888 = {
688 MESA_FORMAT_BGR888, /* MesaFormat */
689 GL_RGB, /* BaseFormat */
690 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
691 8, /* RedBits */
692 8, /* GreenBits */
693 8, /* BlueBits */
694 0, /* AlphaBits */
695 0, /* LuminanceBits */
696 0, /* IntensityBits */
697 0, /* IndexBits */
698 0, /* DepthBits */
699 3, /* TexelBytes */
700 _mesa_texstore_bgr888, /* StoreTexImageFunc */
701 fetch_texel_1d_bgr888, /* FetchTexel1D */
702 fetch_texel_2d_bgr888, /* FetchTexel2D */
703 fetch_texel_3d_bgr888, /* FetchTexel3D */
704 NULL, /* FetchTexel1Df */
705 NULL, /* FetchTexel2Df */
706 NULL, /* FetchTexel3Df */
707 store_texel_bgr888 /* StoreTexel */
708 };
709
710 const struct gl_texture_format _mesa_texformat_rgb565 = {
711 MESA_FORMAT_RGB565, /* MesaFormat */
712 GL_RGB, /* BaseFormat */
713 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
714 5, /* RedBits */
715 6, /* GreenBits */
716 5, /* BlueBits */
717 0, /* AlphaBits */
718 0, /* LuminanceBits */
719 0, /* IntensityBits */
720 0, /* IndexBits */
721 0, /* DepthBits */
722 2, /* TexelBytes */
723 _mesa_texstore_rgb565, /* StoreTexImageFunc */
724 fetch_texel_1d_rgb565, /* FetchTexel1D */
725 fetch_texel_2d_rgb565, /* FetchTexel2D */
726 fetch_texel_3d_rgb565, /* FetchTexel3D */
727 NULL, /* FetchTexel1Df */
728 NULL, /* FetchTexel2Df */
729 NULL, /* FetchTexel3Df */
730 store_texel_rgb565 /* StoreTexel */
731 };
732
733 const struct gl_texture_format _mesa_texformat_rgb565_rev = {
734 MESA_FORMAT_RGB565_REV, /* MesaFormat */
735 GL_RGB, /* BaseFormat */
736 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
737 5, /* RedBits */
738 6, /* GreenBits */
739 5, /* BlueBits */
740 0, /* AlphaBits */
741 0, /* LuminanceBits */
742 0, /* IntensityBits */
743 0, /* IndexBits */
744 0, /* DepthBits */
745 2, /* TexelBytes */
746 _mesa_texstore_rgb565, /* StoreTexImageFunc */
747 fetch_texel_1d_rgb565_rev, /* FetchTexel1D */
748 fetch_texel_2d_rgb565_rev, /* FetchTexel2D */
749 fetch_texel_3d_rgb565_rev, /* FetchTexel3D */
750 NULL, /* FetchTexel1Df */
751 NULL, /* FetchTexel2Df */
752 NULL, /* FetchTexel3Df */
753 store_texel_rgb565_rev /* StoreTexel */
754 };
755
756 const struct gl_texture_format _mesa_texformat_argb4444 = {
757 MESA_FORMAT_ARGB4444, /* MesaFormat */
758 GL_RGBA, /* BaseFormat */
759 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
760 4, /* RedBits */
761 4, /* GreenBits */
762 4, /* BlueBits */
763 4, /* AlphaBits */
764 0, /* LuminanceBits */
765 0, /* IntensityBits */
766 0, /* IndexBits */
767 0, /* DepthBits */
768 2, /* TexelBytes */
769 _mesa_texstore_argb4444, /* StoreTexImageFunc */
770 fetch_texel_1d_argb4444, /* FetchTexel1D */
771 fetch_texel_2d_argb4444, /* FetchTexel2D */
772 fetch_texel_3d_argb4444, /* FetchTexel3D */
773 NULL, /* FetchTexel1Df */
774 NULL, /* FetchTexel2Df */
775 NULL, /* FetchTexel3Df */
776 store_texel_argb4444 /* StoreTexel */
777 };
778
779 const struct gl_texture_format _mesa_texformat_argb4444_rev = {
780 MESA_FORMAT_ARGB4444_REV, /* MesaFormat */
781 GL_RGBA, /* BaseFormat */
782 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
783 4, /* RedBits */
784 4, /* GreenBits */
785 4, /* BlueBits */
786 4, /* AlphaBits */
787 0, /* LuminanceBits */
788 0, /* IntensityBits */
789 0, /* IndexBits */
790 0, /* DepthBits */
791 2, /* TexelBytes */
792 _mesa_texstore_argb4444, /* StoreTexImageFunc */
793 fetch_texel_1d_argb4444_rev, /* FetchTexel1D */
794 fetch_texel_2d_argb4444_rev, /* FetchTexel2D */
795 fetch_texel_3d_argb4444_rev, /* FetchTexel3D */
796 NULL, /* FetchTexel1Df */
797 NULL, /* FetchTexel2Df */
798 NULL, /* FetchTexel3Df */
799 store_texel_argb4444_rev /* StoreTexel */
800 };
801
802 const struct gl_texture_format _mesa_texformat_argb1555 = {
803 MESA_FORMAT_ARGB1555, /* MesaFormat */
804 GL_RGBA, /* BaseFormat */
805 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
806 5, /* RedBits */
807 5, /* GreenBits */
808 5, /* BlueBits */
809 1, /* AlphaBits */
810 0, /* LuminanceBits */
811 0, /* IntensityBits */
812 0, /* IndexBits */
813 0, /* DepthBits */
814 2, /* TexelBytes */
815 _mesa_texstore_argb1555, /* StoreTexImageFunc */
816 fetch_texel_1d_argb1555, /* FetchTexel1D */
817 fetch_texel_2d_argb1555, /* FetchTexel2D */
818 fetch_texel_3d_argb1555, /* FetchTexel3D */
819 NULL, /* FetchTexel1Df */
820 NULL, /* FetchTexel2Df */
821 NULL, /* FetchTexel3Df */
822 store_texel_argb1555 /* StoreTexel */
823 };
824
825 const struct gl_texture_format _mesa_texformat_argb1555_rev = {
826 MESA_FORMAT_ARGB1555_REV, /* MesaFormat */
827 GL_RGBA, /* BaseFormat */
828 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
829 5, /* RedBits */
830 5, /* GreenBits */
831 5, /* BlueBits */
832 1, /* AlphaBits */
833 0, /* LuminanceBits */
834 0, /* IntensityBits */
835 0, /* IndexBits */
836 0, /* DepthBits */
837 2, /* TexelBytes */
838 _mesa_texstore_argb1555, /* StoreTexImageFunc */
839 fetch_texel_1d_argb1555_rev, /* FetchTexel1D */
840 fetch_texel_2d_argb1555_rev, /* FetchTexel2D */
841 fetch_texel_3d_argb1555_rev, /* FetchTexel3D */
842 NULL, /* FetchTexel1Df */
843 NULL, /* FetchTexel2Df */
844 NULL, /* FetchTexel3Df */
845 store_texel_argb1555_rev /* StoreTexel */
846 };
847
848 const struct gl_texture_format _mesa_texformat_al88 = {
849 MESA_FORMAT_AL88, /* MesaFormat */
850 GL_LUMINANCE_ALPHA, /* BaseFormat */
851 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
852 0, /* RedBits */
853 0, /* GreenBits */
854 0, /* BlueBits */
855 8, /* AlphaBits */
856 8, /* LuminanceBits */
857 0, /* IntensityBits */
858 0, /* IndexBits */
859 0, /* DepthBits */
860 2, /* TexelBytes */
861 _mesa_texstore_al88, /* StoreTexImageFunc */
862 fetch_texel_1d_al88, /* FetchTexel1D */
863 fetch_texel_2d_al88, /* FetchTexel2D */
864 fetch_texel_3d_al88, /* FetchTexel3D */
865 NULL, /* FetchTexel1Df */
866 NULL, /* FetchTexel2Df */
867 NULL, /* FetchTexel3Df */
868 store_texel_al88 /* StoreTexel */
869 };
870
871 const struct gl_texture_format _mesa_texformat_al88_rev = {
872 MESA_FORMAT_AL88_REV, /* MesaFormat */
873 GL_LUMINANCE_ALPHA, /* BaseFormat */
874 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
875 0, /* RedBits */
876 0, /* GreenBits */
877 0, /* BlueBits */
878 8, /* AlphaBits */
879 8, /* LuminanceBits */
880 0, /* IntensityBits */
881 0, /* IndexBits */
882 0, /* DepthBits */
883 2, /* TexelBytes */
884 _mesa_texstore_al88, /* StoreTexImageFunc */
885 fetch_texel_1d_al88_rev, /* FetchTexel1D */
886 fetch_texel_2d_al88_rev, /* FetchTexel2D */
887 fetch_texel_3d_al88_rev, /* FetchTexel3D */
888 NULL, /* FetchTexel1Df */
889 NULL, /* FetchTexel2Df */
890 NULL, /* FetchTexel3Df */
891 store_texel_al88_rev /* StoreTexel */
892 };
893
894 const struct gl_texture_format _mesa_texformat_rgb332 = {
895 MESA_FORMAT_RGB332, /* MesaFormat */
896 GL_RGB, /* BaseFormat */
897 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
898 3, /* RedBits */
899 3, /* GreenBits */
900 2, /* BlueBits */
901 0, /* AlphaBits */
902 0, /* LuminanceBits */
903 0, /* IntensityBits */
904 0, /* IndexBits */
905 0, /* DepthBits */
906 1, /* TexelBytes */
907 _mesa_texstore_rgb332, /* StoreTexImageFunc */
908 fetch_texel_1d_rgb332, /* FetchTexel1D */
909 fetch_texel_2d_rgb332, /* FetchTexel2D */
910 fetch_texel_3d_rgb332, /* FetchTexel3D */
911 NULL, /* FetchTexel1Df */
912 NULL, /* FetchTexel2Df */
913 NULL, /* FetchTexel3Df */
914 store_texel_rgb332 /* StoreTexel */
915 };
916
917 const struct gl_texture_format _mesa_texformat_a8 = {
918 MESA_FORMAT_A8, /* MesaFormat */
919 GL_ALPHA, /* BaseFormat */
920 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
921 0, /* RedBits */
922 0, /* GreenBits */
923 0, /* BlueBits */
924 8, /* AlphaBits */
925 0, /* LuminanceBits */
926 0, /* IntensityBits */
927 0, /* IndexBits */
928 0, /* DepthBits */
929 1, /* TexelBytes */
930 _mesa_texstore_a8, /* StoreTexImageFunc */
931 fetch_texel_1d_a8, /* FetchTexel1D */
932 fetch_texel_2d_a8, /* FetchTexel2D */
933 fetch_texel_3d_a8, /* FetchTexel3D */
934 NULL, /* FetchTexel1Df */
935 NULL, /* FetchTexel2Df */
936 NULL, /* FetchTexel3Df */
937 store_texel_a8 /* StoreTexel */
938 };
939
940 const struct gl_texture_format _mesa_texformat_l8 = {
941 MESA_FORMAT_L8, /* MesaFormat */
942 GL_LUMINANCE, /* BaseFormat */
943 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
944 0, /* RedBits */
945 0, /* GreenBits */
946 0, /* BlueBits */
947 0, /* AlphaBits */
948 8, /* LuminanceBits */
949 0, /* IntensityBits */
950 0, /* IndexBits */
951 0, /* DepthBits */
952 1, /* TexelBytes */
953 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
954 fetch_texel_1d_l8, /* FetchTexel1D */
955 fetch_texel_2d_l8, /* FetchTexel2D */
956 fetch_texel_3d_l8, /* FetchTexel3D */
957 NULL, /* FetchTexel1Df */
958 NULL, /* FetchTexel2Df */
959 NULL, /* FetchTexel3Df */
960 store_texel_l8 /* StoreTexel */
961 };
962
963 const struct gl_texture_format _mesa_texformat_i8 = {
964 MESA_FORMAT_I8, /* MesaFormat */
965 GL_INTENSITY, /* BaseFormat */
966 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
967 0, /* RedBits */
968 0, /* GreenBits */
969 0, /* BlueBits */
970 0, /* AlphaBits */
971 0, /* LuminanceBits */
972 8, /* IntensityBits */
973 0, /* IndexBits */
974 0, /* DepthBits */
975 1, /* TexelBytes */
976 _mesa_texstore_a8,/*yes*/ /* StoreTexImageFunc */
977 fetch_texel_1d_i8, /* FetchTexel1D */
978 fetch_texel_2d_i8, /* FetchTexel2D */
979 fetch_texel_3d_i8, /* FetchTexel3D */
980 NULL, /* FetchTexel1Df */
981 NULL, /* FetchTexel2Df */
982 NULL, /* FetchTexel3Df */
983 store_texel_i8 /* StoreTexel */
984 };
985
986 const struct gl_texture_format _mesa_texformat_ci8 = {
987 MESA_FORMAT_CI8, /* MesaFormat */
988 GL_COLOR_INDEX, /* BaseFormat */
989 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
990 0, /* RedBits */
991 0, /* GreenBits */
992 0, /* BlueBits */
993 0, /* AlphaBits */
994 0, /* LuminanceBits */
995 0, /* IntensityBits */
996 8, /* IndexBits */
997 0, /* DepthBits */
998 1, /* TexelBytes */
999 _mesa_texstore_ci8, /* StoreTexImageFunc */
1000 fetch_texel_1d_ci8, /* FetchTexel1D */
1001 fetch_texel_2d_ci8, /* FetchTexel2D */
1002 fetch_texel_3d_ci8, /* FetchTexel3D */
1003 NULL, /* FetchTexel1Df */
1004 NULL, /* FetchTexel2Df */
1005 NULL, /* FetchTexel3Df */
1006 store_texel_ci8 /* StoreTexel */
1007 };
1008
1009 const struct gl_texture_format _mesa_texformat_ycbcr = {
1010 MESA_FORMAT_YCBCR, /* MesaFormat */
1011 GL_YCBCR_MESA, /* BaseFormat */
1012 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1013 0, /* RedBits */
1014 0, /* GreenBits */
1015 0, /* BlueBits */
1016 0, /* AlphaBits */
1017 0, /* LuminanceBits */
1018 0, /* IntensityBits */
1019 0, /* IndexBits */
1020 0, /* DepthBits */
1021 2, /* TexelBytes */
1022 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
1023 fetch_texel_1d_ycbcr, /* FetchTexel1D */
1024 fetch_texel_2d_ycbcr, /* FetchTexel2D */
1025 fetch_texel_3d_ycbcr, /* FetchTexel3D */
1026 NULL, /* FetchTexel1Df */
1027 NULL, /* FetchTexel2Df */
1028 NULL, /* FetchTexel3Df */
1029 store_texel_ycbcr /* StoreTexel */
1030 };
1031
1032 const struct gl_texture_format _mesa_texformat_ycbcr_rev = {
1033 MESA_FORMAT_YCBCR_REV, /* MesaFormat */
1034 GL_YCBCR_MESA, /* BaseFormat */
1035 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
1036 0, /* RedBits */
1037 0, /* GreenBits */
1038 0, /* BlueBits */
1039 0, /* AlphaBits */
1040 0, /* LuminanceBits */
1041 0, /* IntensityBits */
1042 0, /* IndexBits */
1043 0, /* DepthBits */
1044 2, /* TexelBytes */
1045 _mesa_texstore_ycbcr, /* StoreTexImageFunc */
1046 fetch_texel_1d_ycbcr_rev, /* FetchTexel1D */
1047 fetch_texel_2d_ycbcr_rev, /* FetchTexel2D */
1048 fetch_texel_3d_ycbcr_rev, /* FetchTexel3D */
1049 NULL, /* FetchTexel1Df */
1050 NULL, /* FetchTexel2Df */
1051 NULL, /* FetchTexel3Df */
1052 store_texel_ycbcr_rev /* StoreTexel */
1053 };
1054
1055 /*@}*/
1056
1057
1058 /***************************************************************/
1059 /** \name Null format (useful for proxy textures) */
1060 /*@{*/
1061
1062 const struct gl_texture_format _mesa_null_texformat = {
1063 -1, /* MesaFormat */
1064 0, /* BaseFormat */
1065 GL_NONE, /* DataType */
1066 0, /* RedBits */
1067 0, /* GreenBits */
1068 0, /* BlueBits */
1069 0, /* AlphaBits */
1070 0, /* LuminanceBits */
1071 0, /* IntensityBits */
1072 0, /* IndexBits */
1073 0, /* DepthBits */
1074 0, /* TexelBytes */
1075 NULL, /* StoreTexImageFunc */
1076 fetch_null_texel, /* FetchTexel1D */
1077 fetch_null_texel, /* FetchTexel2D */
1078 fetch_null_texel, /* FetchTexel3D */
1079 fetch_null_texelf, /* FetchTexel1Df */
1080 fetch_null_texelf, /* FetchTexel2Df */
1081 fetch_null_texelf, /* FetchTexel3Df */
1082 store_null_texel /* StoreTexel */
1083 };
1084
1085 /*@}*/
1086
1087
1088 /**
1089 * Choose an appropriate texture format given the format, type and
1090 * internalFormat parameters passed to glTexImage().
1091 *
1092 * \param ctx the GL context.
1093 * \param internalFormat user's prefered internal texture format.
1094 * \param format incoming image pixel format.
1095 * \param type incoming image data type.
1096 *
1097 * \return a pointer to a gl_texture_format object which describes the
1098 * choosen texture format, or NULL on failure.
1099 *
1100 * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers
1101 * will typically override this function with a specialized version.
1102 */
1103 const struct gl_texture_format *
1104 _mesa_choose_tex_format( GLcontext *ctx, GLint internalFormat,
1105 GLenum format, GLenum type )
1106 {
1107 (void) format;
1108 (void) type;
1109
1110 switch (internalFormat) {
1111 /* RGBA formats */
1112 case 4:
1113 case GL_RGBA:
1114 case GL_RGB10_A2:
1115 case GL_RGBA12:
1116 case GL_RGBA16:
1117 return &_mesa_texformat_rgba;
1118 case GL_RGBA8:
1119 return &_mesa_texformat_rgba8888;
1120 case GL_RGB5_A1:
1121 return &_mesa_texformat_argb1555;
1122 case GL_RGBA2:
1123 return &_mesa_texformat_argb4444_rev; /* just to test another format*/
1124 case GL_RGBA4:
1125 return &_mesa_texformat_argb4444;
1126
1127 /* RGB formats */
1128 case 3:
1129 case GL_RGB:
1130 case GL_RGB10:
1131 case GL_RGB12:
1132 case GL_RGB16:
1133 return &_mesa_texformat_rgb;
1134 case GL_RGB8:
1135 return &_mesa_texformat_rgb888;
1136 case GL_R3_G3_B2:
1137 return &_mesa_texformat_rgb332;
1138 case GL_RGB4:
1139 return &_mesa_texformat_rgb565_rev; /* just to test another format */
1140 case GL_RGB5:
1141 return &_mesa_texformat_rgb565;
1142
1143 /* Alpha formats */
1144 case GL_ALPHA:
1145 case GL_ALPHA4:
1146 case GL_ALPHA12:
1147 case GL_ALPHA16:
1148 return &_mesa_texformat_alpha;
1149 case GL_ALPHA8:
1150 return &_mesa_texformat_a8;
1151
1152 /* Luminance formats */
1153 case 1:
1154 case GL_LUMINANCE:
1155 case GL_LUMINANCE4:
1156 case GL_LUMINANCE12:
1157 case GL_LUMINANCE16:
1158 return &_mesa_texformat_luminance;
1159 case GL_LUMINANCE8:
1160 return &_mesa_texformat_l8;
1161
1162 /* Luminance/Alpha formats */
1163 case 2:
1164 case GL_LUMINANCE_ALPHA:
1165 case GL_LUMINANCE4_ALPHA4:
1166 case GL_LUMINANCE6_ALPHA2:
1167 case GL_LUMINANCE12_ALPHA4:
1168 case GL_LUMINANCE12_ALPHA12:
1169 case GL_LUMINANCE16_ALPHA16:
1170 return &_mesa_texformat_luminance_alpha;
1171 case GL_LUMINANCE8_ALPHA8:
1172 return &_mesa_texformat_al88;
1173
1174 case GL_INTENSITY:
1175 case GL_INTENSITY4:
1176 case GL_INTENSITY12:
1177 case GL_INTENSITY16:
1178 return &_mesa_texformat_intensity;
1179 case GL_INTENSITY8:
1180 return &_mesa_texformat_i8;
1181
1182 case GL_COLOR_INDEX:
1183 case GL_COLOR_INDEX1_EXT:
1184 case GL_COLOR_INDEX2_EXT:
1185 case GL_COLOR_INDEX4_EXT:
1186 case GL_COLOR_INDEX12_EXT:
1187 case GL_COLOR_INDEX16_EXT:
1188 case GL_COLOR_INDEX8_EXT:
1189 return &_mesa_texformat_ci8;
1190
1191 default:
1192 ; /* fallthrough */
1193 }
1194
1195 if (ctx->Extensions.SGIX_depth_texture ||
1196 ctx->Extensions.ARB_depth_texture) {
1197 switch (internalFormat) {
1198 case GL_DEPTH_COMPONENT:
1199 case GL_DEPTH_COMPONENT24_SGIX:
1200 case GL_DEPTH_COMPONENT32_SGIX:
1201 return &_mesa_texformat_depth_component_float32;
1202 case GL_DEPTH_COMPONENT16_SGIX:
1203 return &_mesa_texformat_depth_component16;
1204 default:
1205 ; /* fallthrough */
1206 }
1207 }
1208
1209 if (ctx->Extensions.ARB_texture_compression) {
1210 switch (internalFormat) {
1211 case GL_COMPRESSED_ALPHA_ARB:
1212 return &_mesa_texformat_alpha;
1213 case GL_COMPRESSED_LUMINANCE_ARB:
1214 return &_mesa_texformat_luminance;
1215 case GL_COMPRESSED_LUMINANCE_ALPHA_ARB:
1216 return &_mesa_texformat_luminance_alpha;
1217 case GL_COMPRESSED_INTENSITY_ARB:
1218 return &_mesa_texformat_intensity;
1219 case GL_COMPRESSED_RGB_ARB:
1220 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1221 return &_mesa_texformat_rgb_fxt1;
1222 else if (ctx->Extensions.EXT_texture_compression_s3tc ||
1223 ctx->Extensions.S3_s3tc)
1224 return &_mesa_texformat_rgb_dxt1;
1225 else
1226 return &_mesa_texformat_rgb;
1227 case GL_COMPRESSED_RGBA_ARB:
1228 if (ctx->Extensions.TDFX_texture_compression_FXT1)
1229 return &_mesa_texformat_rgba_fxt1;
1230 else if (ctx->Extensions.EXT_texture_compression_s3tc ||
1231 ctx->Extensions.S3_s3tc)
1232 return &_mesa_texformat_rgba_dxt3; /* Not rgba_dxt1, see spec */
1233 else
1234 return &_mesa_texformat_rgba;
1235 default:
1236 ; /* fallthrough */
1237 }
1238 }
1239
1240 if (ctx->Extensions.MESA_ycbcr_texture) {
1241 if (internalFormat == GL_YCBCR_MESA) {
1242 if (type == GL_UNSIGNED_SHORT_8_8_MESA)
1243 return &_mesa_texformat_ycbcr;
1244 else
1245 return &_mesa_texformat_ycbcr_rev;
1246 }
1247 }
1248
1249 if (ctx->Extensions.TDFX_texture_compression_FXT1) {
1250 switch (internalFormat) {
1251 case GL_COMPRESSED_RGB_FXT1_3DFX:
1252 return &_mesa_texformat_rgb_fxt1;
1253 case GL_COMPRESSED_RGBA_FXT1_3DFX:
1254 return &_mesa_texformat_rgba_fxt1;
1255 default:
1256 ; /* fallthrough */
1257 }
1258 }
1259
1260 if (ctx->Extensions.EXT_texture_compression_s3tc) {
1261 switch (internalFormat) {
1262 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
1263 return &_mesa_texformat_rgb_dxt1;
1264 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT:
1265 return &_mesa_texformat_rgba_dxt1;
1266 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT:
1267 return &_mesa_texformat_rgba_dxt3;
1268 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT:
1269 return &_mesa_texformat_rgba_dxt5;
1270 default:
1271 ; /* fallthrough */
1272 }
1273 }
1274
1275 if (ctx->Extensions.S3_s3tc) {
1276 switch (internalFormat) {
1277 case GL_RGB_S3TC:
1278 case GL_RGB4_S3TC:
1279 return &_mesa_texformat_rgb_dxt1;
1280 case GL_RGBA_S3TC:
1281 case GL_RGBA4_S3TC:
1282 return &_mesa_texformat_rgba_dxt3;
1283 default:
1284 ; /* fallthrough */
1285 }
1286 }
1287
1288 if (ctx->Extensions.ARB_texture_float) {
1289 switch (internalFormat) {
1290 case GL_ALPHA16F_ARB:
1291 return &_mesa_texformat_alpha_float16;
1292 case GL_ALPHA32F_ARB:
1293 return &_mesa_texformat_alpha_float32;
1294 case GL_LUMINANCE16F_ARB:
1295 return &_mesa_texformat_luminance_float16;
1296 case GL_LUMINANCE32F_ARB:
1297 return &_mesa_texformat_luminance_float32;
1298 case GL_LUMINANCE_ALPHA16F_ARB:
1299 return &_mesa_texformat_luminance_alpha_float16;
1300 case GL_LUMINANCE_ALPHA32F_ARB:
1301 return &_mesa_texformat_luminance_alpha_float32;
1302 case GL_INTENSITY16F_ARB:
1303 return &_mesa_texformat_intensity_float16;
1304 case GL_INTENSITY32F_ARB:
1305 return &_mesa_texformat_intensity_float32;
1306 case GL_RGB16F_ARB:
1307 return &_mesa_texformat_rgb_float16;
1308 case GL_RGB32F_ARB:
1309 return &_mesa_texformat_rgb_float32;
1310 case GL_RGBA16F_ARB:
1311 return &_mesa_texformat_rgba_float16;
1312 case GL_RGBA32F_ARB:
1313 return &_mesa_texformat_rgba_float32;
1314 default:
1315 ; /* fallthrough */
1316 }
1317 }
1318
1319 _mesa_problem(ctx, "unexpected format in _mesa_choose_tex_format()");
1320 return NULL;
1321 }