2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 * Copyright (c) 2008 VMware, Inc.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice shall be included
16 * in all copies or substantial portions of the Software.
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 * \author Gareth Hughes
37 #include "texformat.h"
41 #if FEATURE_EXT_texture_sRGB
44 * Convert an 8-bit sRGB value from non-linear space to a
45 * linear RGB value in [0, 1].
46 * Implemented with a 256-entry lookup table.
49 nonlinear_to_linear(GLubyte cs8
)
51 static GLfloat table
[256];
52 static GLboolean tableReady
= GL_FALSE
;
54 /* compute lookup table now */
56 for (i
= 0; i
< 256; i
++) {
57 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
59 table
[i
] = cs
/ 12.92f
;
62 table
[i
] = (GLfloat
) _mesa_pow((cs
+ 0.055) / 1.055, 2.4);
71 #endif /* FEATURE_EXT_texture_sRGB */
74 /* Texel fetch routines for all supported formats
77 #include "texformat_tmp.h"
80 #include "texformat_tmp.h"
83 #include "texformat_tmp.h"
86 * Null texel fetch function.
88 * Have to have this so the FetchTexel function pointer is never NULL.
90 static void fetch_null_texel( const struct gl_texture_image
*texImage
,
91 GLint i
, GLint j
, GLint k
, GLchan
*texel
)
93 (void) texImage
; (void) i
; (void) j
; (void) k
;
98 _mesa_warning(NULL
, "fetch_null_texel() called!");
101 static void fetch_null_texelf( const struct gl_texture_image
*texImage
,
102 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
104 (void) texImage
; (void) i
; (void) j
; (void) k
;
109 _mesa_warning(NULL
, "fetch_null_texelf() called!");
112 static void store_null_texel(struct gl_texture_image
*texImage
,
113 GLint i
, GLint j
, GLint k
, const void *texel
)
125 * Notes about the predefined gl_texture_formats:
127 * 1. There are 1D, 2D and 3D functions for fetching texels from texture
128 * images, returning both GLchan values and GLfloat values. (six
129 * functions in total)
130 * You don't have to provide both the GLchan and GLfloat functions;
131 * just one or the other is OK. Mesa will use an "adaptor" to convert
132 * between GLchan/GLfloat when needed.
133 * Since the adaptors have small performance penalty, we provide both
134 * GLchan and GLfloat functions for some common formats like RGB, RGBA.
138 /***************************************************************/
139 /** \name Default GLchan-based formats */
142 const struct gl_texture_format _mesa_texformat_rgba
= {
143 MESA_FORMAT_RGBA
, /* MesaFormat */
144 GL_RGBA
, /* BaseFormat */
145 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
146 CHAN_BITS
, /* RedBits */
147 CHAN_BITS
, /* GreenBits */
148 CHAN_BITS
, /* BlueBits */
149 CHAN_BITS
, /* AlphaBits */
150 0, /* LuminanceBits */
151 0, /* IntensityBits */
155 4 * sizeof(GLchan
), /* TexelBytes */
156 _mesa_texstore_rgba
, /* StoreTexImageFunc */
157 NULL
, /* FetchTexel1D */
158 NULL
, /* FetchTexel2D */
159 NULL
, /* FetchTexel3D */
160 fetch_texel_1d_f_rgba
, /* FetchTexel1Df */
161 fetch_texel_2d_f_rgba
, /* FetchTexel2Df */
162 fetch_texel_3d_f_rgba
, /* FetchTexel3Df */
163 store_texel_rgba
/* StoreTexel */
166 const struct gl_texture_format _mesa_texformat_rgb
= {
167 MESA_FORMAT_RGB
, /* MesaFormat */
168 GL_RGB
, /* BaseFormat */
169 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
170 CHAN_BITS
, /* RedBits */
171 CHAN_BITS
, /* GreenBits */
172 CHAN_BITS
, /* BlueBits */
174 0, /* LuminanceBits */
175 0, /* IntensityBits */
179 3 * sizeof(GLchan
), /* TexelBytes */
180 _mesa_texstore_rgba
,/*yes*/ /* StoreTexImageFunc */
181 NULL
, /* FetchTexel1D */
182 NULL
, /* FetchTexel2D */
183 NULL
, /* FetchTexel3D */
184 fetch_texel_1d_f_rgb
, /* FetchTexel1Df */
185 fetch_texel_2d_f_rgb
, /* FetchTexel2Df */
186 fetch_texel_3d_f_rgb
, /* FetchTexel3Df */
187 store_texel_rgb
/* StoreTexel */
190 const struct gl_texture_format _mesa_texformat_alpha
= {
191 MESA_FORMAT_ALPHA
, /* MesaFormat */
192 GL_ALPHA
, /* BaseFormat */
193 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
197 CHAN_BITS
, /* AlphaBits */
198 0, /* LuminanceBits */
199 0, /* IntensityBits */
203 sizeof(GLchan
), /* TexelBytes */
204 _mesa_texstore_rgba
,/*yes*/ /* StoreTexImageFunc */
205 NULL
, /* FetchTexel1D */
206 NULL
, /* FetchTexel2D */
207 NULL
, /* FetchTexel3D */
208 fetch_texel_1d_f_alpha
, /* FetchTexel1Df */
209 fetch_texel_2d_f_alpha
, /* FetchTexel2Df */
210 fetch_texel_3d_f_alpha
, /* FetchTexel3Df */
211 store_texel_alpha
/* StoreTexel */
214 const struct gl_texture_format _mesa_texformat_luminance
= {
215 MESA_FORMAT_LUMINANCE
, /* MesaFormat */
216 GL_LUMINANCE
, /* BaseFormat */
217 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
222 CHAN_BITS
, /* LuminanceBits */
223 0, /* IntensityBits */
227 sizeof(GLchan
), /* TexelBytes */
228 _mesa_texstore_rgba
,/*yes*/ /* StoreTexImageFunc */
229 NULL
, /* FetchTexel1D */
230 NULL
, /* FetchTexel2D */
231 NULL
, /* FetchTexel3D */
232 fetch_texel_1d_f_luminance
, /* FetchTexel1Df */
233 fetch_texel_2d_f_luminance
, /* FetchTexel2Df */
234 fetch_texel_3d_f_luminance
, /* FetchTexel3Df */
235 store_texel_luminance
/* StoreTexel */
238 const struct gl_texture_format _mesa_texformat_luminance_alpha
= {
239 MESA_FORMAT_LUMINANCE_ALPHA
, /* MesaFormat */
240 GL_LUMINANCE_ALPHA
, /* BaseFormat */
241 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
245 CHAN_BITS
, /* AlphaBits */
246 CHAN_BITS
, /* LuminanceBits */
247 0, /* IntensityBits */
251 2 * sizeof(GLchan
), /* TexelBytes */
252 _mesa_texstore_rgba
,/*yes*/ /* StoreTexImageFunc */
253 NULL
, /* FetchTexel1D */
254 NULL
, /* FetchTexel2D */
255 NULL
, /* FetchTexel3D */
256 fetch_texel_1d_f_luminance_alpha
, /* FetchTexel1Df */
257 fetch_texel_2d_f_luminance_alpha
, /* FetchTexel2Df */
258 fetch_texel_3d_f_luminance_alpha
, /* FetchTexel3Df */
259 store_texel_luminance_alpha
/* StoreTexel */
262 const struct gl_texture_format _mesa_texformat_intensity
= {
263 MESA_FORMAT_INTENSITY
, /* MesaFormat */
264 GL_INTENSITY
, /* BaseFormat */
265 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
270 0, /* LuminanceBits */
271 CHAN_BITS
, /* IntensityBits */
275 sizeof(GLchan
), /* TexelBytes */
276 _mesa_texstore_rgba
,/*yes*/ /* StoreTexImageFunc */
277 NULL
, /* FetchTexel1D */
278 NULL
, /* FetchTexel2D */
279 NULL
, /* FetchTexel3D */
280 fetch_texel_1d_f_intensity
, /* FetchTexel1Df */
281 fetch_texel_2d_f_intensity
, /* FetchTexel2Df */
282 fetch_texel_3d_f_intensity
, /* FetchTexel3Df */
283 store_texel_intensity
/* StoreTexel */
287 #if FEATURE_EXT_texture_sRGB
289 const struct gl_texture_format _mesa_texformat_srgb8
= {
290 MESA_FORMAT_SRGB8
, /* MesaFormat */
291 GL_RGB
, /* BaseFormat */
292 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
297 0, /* LuminanceBits */
298 0, /* IntensityBits */
303 _mesa_texstore_srgb8
, /* StoreTexImageFunc */
304 NULL
, /* FetchTexel1D */
305 NULL
, /* FetchTexel2D */
306 NULL
, /* FetchTexel3D */
307 fetch_texel_1d_srgb8
, /* FetchTexel1Df */
308 fetch_texel_2d_srgb8
, /* FetchTexel2Df */
309 fetch_texel_3d_srgb8
, /* FetchTexel3Df */
310 store_texel_srgb8
/* StoreTexel */
313 const struct gl_texture_format _mesa_texformat_srgba8
= {
314 MESA_FORMAT_SRGBA8
, /* MesaFormat */
315 GL_RGBA
, /* BaseFormat */
316 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
321 0, /* LuminanceBits */
322 0, /* IntensityBits */
327 _mesa_texstore_srgba8
, /* StoreTexImageFunc */
328 NULL
, /* FetchTexel1D */
329 NULL
, /* FetchTexel2D */
330 NULL
, /* FetchTexel3D */
331 fetch_texel_1d_srgba8
, /* FetchTexel1Df */
332 fetch_texel_2d_srgba8
, /* FetchTexel2Df */
333 fetch_texel_3d_srgba8
, /* FetchTexel3Df */
334 store_texel_srgba8
/* StoreTexel */
337 const struct gl_texture_format _mesa_texformat_sargb8
= {
338 MESA_FORMAT_SARGB8
, /* MesaFormat */
339 GL_RGBA
, /* BaseFormat */
340 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
345 0, /* LuminanceBits */
346 0, /* IntensityBits */
351 _mesa_texstore_sargb8
, /* StoreTexImageFunc */
352 NULL
, /* FetchTexel1D */
353 NULL
, /* FetchTexel2D */
354 NULL
, /* FetchTexel3D */
355 fetch_texel_1d_sargb8
, /* FetchTexel1Df */
356 fetch_texel_2d_sargb8
, /* FetchTexel2Df */
357 fetch_texel_3d_sargb8
, /* FetchTexel3Df */
358 store_texel_sargb8
/* StoreTexel */
361 const struct gl_texture_format _mesa_texformat_sl8
= {
362 MESA_FORMAT_SL8
, /* MesaFormat */
363 GL_LUMINANCE
, /* BaseFormat */
364 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
369 8, /* LuminanceBits */
370 0, /* IntensityBits */
375 _mesa_texstore_sl8
, /* StoreTexImageFunc */
376 NULL
, /* FetchTexel1D */
377 NULL
, /* FetchTexel2D */
378 NULL
, /* FetchTexel3D */
379 fetch_texel_1d_sl8
, /* FetchTexel1Df */
380 fetch_texel_2d_sl8
, /* FetchTexel2Df */
381 fetch_texel_3d_sl8
, /* FetchTexel3Df */
382 store_texel_sl8
/* StoreTexel */
385 /* Note: this format name looks like a misnomer, make it sal8? */
386 const struct gl_texture_format _mesa_texformat_sla8
= {
387 MESA_FORMAT_SLA8
, /* MesaFormat */
388 GL_LUMINANCE_ALPHA
, /* BaseFormat */
389 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
394 8, /* LuminanceBits */
395 0, /* IntensityBits */
400 _mesa_texstore_sla8
, /* StoreTexImageFunc */
401 NULL
, /* FetchTexel1D */
402 NULL
, /* FetchTexel2D */
403 NULL
, /* FetchTexel3D */
404 fetch_texel_1d_sla8
, /* FetchTexel1Df */
405 fetch_texel_2d_sla8
, /* FetchTexel2Df */
406 fetch_texel_3d_sla8
, /* FetchTexel3Df */
407 store_texel_sla8
/* StoreTexel */
410 #endif /* FEATURE_EXT_texture_sRGB */
412 const struct gl_texture_format _mesa_texformat_rgba_float32
= {
413 MESA_FORMAT_RGBA_FLOAT32
, /* MesaFormat */
414 GL_RGBA
, /* BaseFormat */
415 GL_FLOAT
, /* DataType */
416 8 * sizeof(GLfloat
), /* RedBits */
417 8 * sizeof(GLfloat
), /* GreenBits */
418 8 * sizeof(GLfloat
), /* BlueBits */
419 8 * sizeof(GLfloat
), /* AlphaBits */
420 0, /* LuminanceBits */
421 0, /* IntensityBits */
425 4 * sizeof(GLfloat
), /* TexelBytes */
426 _mesa_texstore_rgba_float32
, /* StoreTexImageFunc */
427 NULL
, /* FetchTexel1D */
428 NULL
, /* FetchTexel1D */
429 NULL
, /* FetchTexel1D */
430 fetch_texel_1d_f_rgba_f32
, /* FetchTexel1Df */
431 fetch_texel_2d_f_rgba_f32
, /* FetchTexel2Df */
432 fetch_texel_3d_f_rgba_f32
, /* FetchTexel3Df */
433 store_texel_rgba_f32
/* StoreTexel */
436 const struct gl_texture_format _mesa_texformat_rgba_float16
= {
437 MESA_FORMAT_RGBA_FLOAT16
, /* MesaFormat */
438 GL_RGBA
, /* BaseFormat */
439 GL_FLOAT
, /* DataType */
440 8 * sizeof(GLhalfARB
), /* RedBits */
441 8 * sizeof(GLhalfARB
), /* GreenBits */
442 8 * sizeof(GLhalfARB
), /* BlueBits */
443 8 * sizeof(GLhalfARB
), /* AlphaBits */
444 0, /* LuminanceBits */
445 0, /* IntensityBits */
449 4 * sizeof(GLhalfARB
), /* TexelBytes */
450 _mesa_texstore_rgba_float16
, /* StoreTexImageFunc */
451 NULL
, /* FetchTexel1D */
452 NULL
, /* FetchTexel1D */
453 NULL
, /* FetchTexel1D */
454 fetch_texel_1d_f_rgba_f16
, /* FetchTexel1Df */
455 fetch_texel_2d_f_rgba_f16
, /* FetchTexel2Df */
456 fetch_texel_3d_f_rgba_f16
, /* FetchTexel3Df */
457 store_texel_rgba_f16
/* StoreTexel */
460 const struct gl_texture_format _mesa_texformat_rgb_float32
= {
461 MESA_FORMAT_RGB_FLOAT32
, /* MesaFormat */
462 GL_RGB
, /* BaseFormat */
463 GL_FLOAT
, /* DataType */
464 8 * sizeof(GLfloat
), /* RedBits */
465 8 * sizeof(GLfloat
), /* GreenBits */
466 8 * sizeof(GLfloat
), /* BlueBits */
468 0, /* LuminanceBits */
469 0, /* IntensityBits */
473 3 * sizeof(GLfloat
), /* TexelBytes */
474 _mesa_texstore_rgba_float32
,/*yes*/ /* StoreTexImageFunc */
475 NULL
, /* FetchTexel1D */
476 NULL
, /* FetchTexel1D */
477 NULL
, /* FetchTexel1D */
478 fetch_texel_1d_f_rgb_f32
, /* FetchTexel1Df */
479 fetch_texel_2d_f_rgb_f32
, /* FetchTexel2Df */
480 fetch_texel_3d_f_rgb_f32
, /* FetchTexel3Df */
481 store_texel_rgb_f32
/* StoreTexel */
484 const struct gl_texture_format _mesa_texformat_rgb_float16
= {
485 MESA_FORMAT_RGB_FLOAT16
, /* MesaFormat */
486 GL_RGB
, /* BaseFormat */
487 GL_FLOAT
, /* DataType */
488 8 * sizeof(GLhalfARB
), /* RedBits */
489 8 * sizeof(GLhalfARB
), /* GreenBits */
490 8 * sizeof(GLhalfARB
), /* BlueBits */
492 0, /* LuminanceBits */
493 0, /* IntensityBits */
497 3 * sizeof(GLhalfARB
), /* TexelBytes */
498 _mesa_texstore_rgba_float16
,/*yes*/ /* StoreTexImageFunc */
499 NULL
, /* FetchTexel1D */
500 NULL
, /* FetchTexel1D */
501 NULL
, /* FetchTexel1D */
502 fetch_texel_1d_f_rgb_f16
, /* FetchTexel1Df */
503 fetch_texel_2d_f_rgb_f16
, /* FetchTexel2Df */
504 fetch_texel_3d_f_rgb_f16
, /* FetchTexel3Df */
505 store_texel_rgb_f16
/* StoreTexel */
508 const struct gl_texture_format _mesa_texformat_alpha_float32
= {
509 MESA_FORMAT_ALPHA_FLOAT32
, /* MesaFormat */
510 GL_ALPHA
, /* BaseFormat */
511 GL_FLOAT
, /* DataType */
515 8 * sizeof(GLfloat
), /* AlphaBits */
516 0, /* LuminanceBits */
517 0, /* IntensityBits */
521 1 * sizeof(GLfloat
), /* TexelBytes */
522 _mesa_texstore_rgba_float32
,/*yes*/ /* StoreTexImageFunc */
523 NULL
, /* FetchTexel1D */
524 NULL
, /* FetchTexel1D */
525 NULL
, /* FetchTexel1D */
526 fetch_texel_1d_f_alpha_f32
, /* FetchTexel1Df */
527 fetch_texel_2d_f_alpha_f32
, /* FetchTexel2Df */
528 fetch_texel_3d_f_alpha_f32
, /* FetchTexel3Df */
529 store_texel_alpha_f32
/* StoreTexel */
532 const struct gl_texture_format _mesa_texformat_alpha_float16
= {
533 MESA_FORMAT_ALPHA_FLOAT16
, /* MesaFormat */
534 GL_ALPHA
, /* BaseFormat */
535 GL_FLOAT
, /* DataType */
539 8 * sizeof(GLhalfARB
), /* AlphaBits */
540 0, /* LuminanceBits */
541 0, /* IntensityBits */
545 1 * sizeof(GLhalfARB
), /* TexelBytes */
546 _mesa_texstore_rgba_float16
,/*yes*/ /* StoreTexImageFunc */
547 NULL
, /* FetchTexel1D */
548 NULL
, /* FetchTexel1D */
549 NULL
, /* FetchTexel1D */
550 fetch_texel_1d_f_alpha_f16
, /* FetchTexel1Df */
551 fetch_texel_2d_f_alpha_f16
, /* FetchTexel2Df */
552 fetch_texel_3d_f_alpha_f16
, /* FetchTexel3Df */
553 store_texel_alpha_f16
/* StoreTexel */
556 const struct gl_texture_format _mesa_texformat_luminance_float32
= {
557 MESA_FORMAT_LUMINANCE_FLOAT32
, /* MesaFormat */
558 GL_LUMINANCE
, /* BaseFormat */
559 GL_FLOAT
, /* DataType */
564 8 * sizeof(GLfloat
), /* LuminanceBits */
565 0, /* IntensityBits */
569 1 * sizeof(GLfloat
), /* TexelBytes */
570 _mesa_texstore_rgba_float32
,/*yes*/ /* StoreTexImageFunc */
571 NULL
, /* FetchTexel1D */
572 NULL
, /* FetchTexel2D */
573 NULL
, /* FetchTexel3D */
574 fetch_texel_1d_f_luminance_f32
, /* FetchTexel1Df */
575 fetch_texel_2d_f_luminance_f32
, /* FetchTexel2Df */
576 fetch_texel_3d_f_luminance_f32
, /* FetchTexel3Df */
577 store_texel_luminance_f32
/* StoreTexel */
580 const struct gl_texture_format _mesa_texformat_luminance_float16
= {
581 MESA_FORMAT_LUMINANCE_FLOAT16
, /* MesaFormat */
582 GL_LUMINANCE
, /* BaseFormat */
583 GL_FLOAT
, /* DataType */
588 8 * sizeof(GLhalfARB
), /* LuminanceBits */
589 0, /* IntensityBits */
593 1 * sizeof(GLhalfARB
), /* TexelBytes */
594 _mesa_texstore_rgba_float16
,/*yes*/ /* StoreTexImageFunc */
595 NULL
, /* FetchTexel1D */
596 NULL
, /* FetchTexel2D */
597 NULL
, /* FetchTexel3D */
598 fetch_texel_1d_f_luminance_f16
, /* FetchTexel1Df */
599 fetch_texel_2d_f_luminance_f16
, /* FetchTexel2Df */
600 fetch_texel_3d_f_luminance_f16
, /* FetchTexel3Df */
601 store_texel_luminance_f16
/* StoreTexel */
604 const struct gl_texture_format _mesa_texformat_luminance_alpha_float32
= {
605 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
, /* MesaFormat */
606 GL_LUMINANCE_ALPHA
, /* BaseFormat */
607 GL_FLOAT
, /* DataType */
611 8 * sizeof(GLfloat
), /* AlphaBits */
612 8 * sizeof(GLfloat
), /* LuminanceBits */
613 0, /* IntensityBits */
617 2 * sizeof(GLfloat
), /* TexelBytes */
618 _mesa_texstore_rgba_float32
, /* StoreTexImageFunc */
619 NULL
, /* FetchTexel1D */
620 NULL
, /* FetchTexel2D */
621 NULL
, /* FetchTexel3D */
622 fetch_texel_1d_f_luminance_alpha_f32
,/* FetchTexel1Df */
623 fetch_texel_2d_f_luminance_alpha_f32
,/* FetchTexel2Df */
624 fetch_texel_3d_f_luminance_alpha_f32
,/* FetchTexel3Df */
625 store_texel_luminance_alpha_f32
/* StoreTexel */
628 const struct gl_texture_format _mesa_texformat_luminance_alpha_float16
= {
629 MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
, /* MesaFormat */
630 GL_LUMINANCE_ALPHA
, /* BaseFormat */
631 GL_FLOAT
, /* DataType */
635 8 * sizeof(GLhalfARB
), /* AlphaBits */
636 8 * sizeof(GLhalfARB
), /* LuminanceBits */
637 0, /* IntensityBits */
641 2 * sizeof(GLhalfARB
), /* TexelBytes */
642 _mesa_texstore_rgba_float16
, /* StoreTexImageFunc */
643 NULL
, /* FetchTexel1D */
644 NULL
, /* FetchTexel2D */
645 NULL
, /* FetchTexel3D */
646 fetch_texel_1d_f_luminance_alpha_f16
,/* FetchTexel1Df */
647 fetch_texel_2d_f_luminance_alpha_f16
,/* FetchTexel2Df */
648 fetch_texel_3d_f_luminance_alpha_f16
,/* FetchTexel3Df */
649 store_texel_luminance_alpha_f16
/* StoreTexel */
652 const struct gl_texture_format _mesa_texformat_intensity_float32
= {
653 MESA_FORMAT_INTENSITY_FLOAT32
, /* MesaFormat */
654 GL_INTENSITY
, /* BaseFormat */
655 GL_FLOAT
, /* DataType */
660 0, /* LuminanceBits */
661 8 * sizeof(GLfloat
), /* IntensityBits */
665 1 * sizeof(GLfloat
), /* TexelBytes */
666 _mesa_texstore_rgba_float32
,/*yes*/ /* StoreTexImageFunc */
667 NULL
, /* FetchTexel1D */
668 NULL
, /* FetchTexel2D */
669 NULL
, /* FetchTexel3D */
670 fetch_texel_1d_f_intensity_f32
, /* FetchTexel1Df */
671 fetch_texel_2d_f_intensity_f32
, /* FetchTexel2Df */
672 fetch_texel_3d_f_intensity_f32
, /* FetchTexel3Df */
673 store_texel_intensity_f32
/* StoreTexel */
676 const struct gl_texture_format _mesa_texformat_intensity_float16
= {
677 MESA_FORMAT_INTENSITY_FLOAT16
, /* MesaFormat */
678 GL_INTENSITY
, /* BaseFormat */
679 GL_FLOAT
, /* DataType */
684 0, /* LuminanceBits */
685 8 * sizeof(GLhalfARB
), /* IntensityBits */
689 1 * sizeof(GLhalfARB
), /* TexelBytes */
690 _mesa_texstore_rgba_float16
,/*yes*/ /* StoreTexImageFunc */
691 NULL
, /* FetchTexel1D */
692 NULL
, /* FetchTexel2D */
693 NULL
, /* FetchTexel3D */
694 fetch_texel_1d_f_intensity_f16
, /* FetchTexel1Df */
695 fetch_texel_2d_f_intensity_f16
, /* FetchTexel2Df */
696 fetch_texel_3d_f_intensity_f16
, /* FetchTexel3Df */
697 store_texel_intensity_f16
/* StoreTexel */
700 const struct gl_texture_format _mesa_texformat_dudv8
= {
701 MESA_FORMAT_DUDV8
, /* MesaFormat */
702 GL_DUDV_ATI
, /* BaseFormat */
703 GL_SIGNED_NORMALIZED
, /* DataType */
704 /* maybe should add dudvBits field, but spec seems to be
705 lacking the ability to query with GetTexLevelParameter anyway */
710 0, /* LuminanceBits */
711 0, /* IntensityBits */
716 _mesa_texstore_dudv8
, /* StoreTexImageFunc */
717 NULL
, /* FetchTexel1D */
718 NULL
, /* FetchTexel2D */
719 NULL
, /* FetchTexel3D */
720 fetch_texel_1d_dudv8
, /* FetchTexel1Df */
721 fetch_texel_2d_dudv8
, /* FetchTexel2Df */
722 fetch_texel_3d_dudv8
, /* FetchTexel3Df */
723 NULL
/* StoreTexel */
726 const struct gl_texture_format _mesa_texformat_signed_rgba8888
= {
727 MESA_FORMAT_SIGNED_RGBA8888
, /* MesaFormat */
728 GL_RGBA
, /* BaseFormat */
729 GL_SIGNED_NORMALIZED
, /* DataType */
734 0, /* LuminanceBits */
735 0, /* IntensityBits */
740 _mesa_texstore_signed_rgba8888
, /* StoreTexImageFunc */
741 NULL
, /* FetchTexel1D */
742 NULL
, /* FetchTexel2D */
743 NULL
, /* FetchTexel3D */
744 fetch_texel_1d_signed_rgba8888
, /* FetchTexel1Df */
745 fetch_texel_2d_signed_rgba8888
, /* FetchTexel2Df */
746 fetch_texel_3d_signed_rgba8888
, /* FetchTexel3Df */
747 store_texel_signed_rgba8888
/* StoreTexel */
750 const struct gl_texture_format _mesa_texformat_signed_rgba8888_rev
= {
751 MESA_FORMAT_SIGNED_RGBA8888_REV
, /* MesaFormat */
752 GL_RGBA
, /* BaseFormat */
753 GL_SIGNED_NORMALIZED
, /* DataType */
758 0, /* LuminanceBits */
759 0, /* IntensityBits */
764 _mesa_texstore_signed_rgba8888
, /* StoreTexImageFunc */
765 NULL
, /* FetchTexel1D */
766 NULL
, /* FetchTexel2D */
767 NULL
, /* FetchTexel3D */
768 fetch_texel_1d_signed_rgba8888_rev
, /* FetchTexel1Df */
769 fetch_texel_2d_signed_rgba8888_rev
, /* FetchTexel2Df */
770 fetch_texel_3d_signed_rgba8888_rev
, /* FetchTexel3Df */
771 store_texel_signed_rgba8888_rev
/* StoreTexel */
777 /***************************************************************/
778 /** \name Hardware formats */
781 const struct gl_texture_format _mesa_texformat_rgba8888
= {
782 MESA_FORMAT_RGBA8888
, /* MesaFormat */
783 GL_RGBA
, /* BaseFormat */
784 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
789 0, /* LuminanceBits */
790 0, /* IntensityBits */
795 _mesa_texstore_rgba8888
, /* StoreTexImageFunc */
796 NULL
, /* FetchTexel1D */
797 NULL
, /* FetchTexel2D */
798 NULL
, /* FetchTexel3D */
799 fetch_texel_1d_f_rgba8888
, /* FetchTexel1Df */
800 fetch_texel_2d_f_rgba8888
, /* FetchTexel2Df */
801 fetch_texel_3d_f_rgba8888
, /* FetchTexel3Df */
802 store_texel_rgba8888
/* StoreTexel */
805 const struct gl_texture_format _mesa_texformat_rgba8888_rev
= {
806 MESA_FORMAT_RGBA8888_REV
, /* MesaFormat */
807 GL_RGBA
, /* BaseFormat */
808 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
813 0, /* LuminanceBits */
814 0, /* IntensityBits */
819 _mesa_texstore_rgba8888
, /* StoreTexImageFunc */
820 NULL
, /* FetchTexel1D */
821 NULL
, /* FetchTexel2D */
822 NULL
, /* FetchTexel3D */
823 fetch_texel_1d_f_rgba8888_rev
, /* FetchTexel1Df */
824 fetch_texel_2d_f_rgba8888_rev
, /* FetchTexel2Df */
825 fetch_texel_3d_f_rgba8888_rev
, /* FetchTexel3Df */
826 store_texel_rgba8888_rev
/* StoreTexel */
829 const struct gl_texture_format _mesa_texformat_argb8888
= {
830 MESA_FORMAT_ARGB8888
, /* MesaFormat */
831 GL_RGBA
, /* BaseFormat */
832 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
837 0, /* LuminanceBits */
838 0, /* IntensityBits */
843 _mesa_texstore_argb8888
, /* StoreTexImageFunc */
844 NULL
, /* FetchTexel1D */
845 NULL
, /* FetchTexel2D */
846 NULL
, /* FetchTexel3D */
847 fetch_texel_1d_f_argb8888
, /* FetchTexel1Df */
848 fetch_texel_2d_f_argb8888
, /* FetchTexel2Df */
849 fetch_texel_3d_f_argb8888
, /* FetchTexel3Df */
850 store_texel_argb8888
/* StoreTexel */
853 const struct gl_texture_format _mesa_texformat_argb8888_rev
= {
854 MESA_FORMAT_ARGB8888_REV
, /* MesaFormat */
855 GL_RGBA
, /* BaseFormat */
856 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
861 0, /* LuminanceBits */
862 0, /* IntensityBits */
867 _mesa_texstore_argb8888
, /* StoreTexImageFunc */
868 NULL
, /* FetchTexel1D */
869 NULL
, /* FetchTexel2D */
870 NULL
, /* FetchTexel3D */
871 fetch_texel_1d_f_argb8888_rev
, /* FetchTexel1Df */
872 fetch_texel_2d_f_argb8888_rev
, /* FetchTexel2Df */
873 fetch_texel_3d_f_argb8888_rev
, /* FetchTexel3Df */
874 store_texel_argb8888_rev
/* StoreTexel */
877 const struct gl_texture_format _mesa_texformat_rgb888
= {
878 MESA_FORMAT_RGB888
, /* MesaFormat */
879 GL_RGB
, /* BaseFormat */
880 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
885 0, /* LuminanceBits */
886 0, /* IntensityBits */
891 _mesa_texstore_rgb888
, /* StoreTexImageFunc */
892 NULL
, /* FetchTexel1D */
893 NULL
, /* FetchTexel2D */
894 NULL
, /* FetchTexel3D */
895 fetch_texel_1d_f_rgb888
, /* FetchTexel1Df */
896 fetch_texel_2d_f_rgb888
, /* FetchTexel2Df */
897 fetch_texel_3d_f_rgb888
, /* FetchTexel3Df */
898 store_texel_rgb888
/* StoreTexel */
901 const struct gl_texture_format _mesa_texformat_bgr888
= {
902 MESA_FORMAT_BGR888
, /* MesaFormat */
903 GL_RGB
, /* BaseFormat */
904 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
909 0, /* LuminanceBits */
910 0, /* IntensityBits */
915 _mesa_texstore_bgr888
, /* StoreTexImageFunc */
916 NULL
, /* FetchTexel1D */
917 NULL
, /* FetchTexel2D */
918 NULL
, /* FetchTexel3D */
919 fetch_texel_1d_f_bgr888
, /* FetchTexel1Df */
920 fetch_texel_2d_f_bgr888
, /* FetchTexel2Df */
921 fetch_texel_3d_f_bgr888
, /* FetchTexel3Df */
922 store_texel_bgr888
/* StoreTexel */
925 const struct gl_texture_format _mesa_texformat_rgb565
= {
926 MESA_FORMAT_RGB565
, /* MesaFormat */
927 GL_RGB
, /* BaseFormat */
928 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
933 0, /* LuminanceBits */
934 0, /* IntensityBits */
939 _mesa_texstore_rgb565
, /* StoreTexImageFunc */
940 NULL
, /* FetchTexel1D */
941 NULL
, /* FetchTexel2D */
942 NULL
, /* FetchTexel3D */
943 fetch_texel_1d_f_rgb565
, /* FetchTexel1Df */
944 fetch_texel_2d_f_rgb565
, /* FetchTexel2Df */
945 fetch_texel_3d_f_rgb565
, /* FetchTexel3Df */
946 store_texel_rgb565
/* StoreTexel */
949 const struct gl_texture_format _mesa_texformat_rgb565_rev
= {
950 MESA_FORMAT_RGB565_REV
, /* MesaFormat */
951 GL_RGB
, /* BaseFormat */
952 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
957 0, /* LuminanceBits */
958 0, /* IntensityBits */
963 _mesa_texstore_rgb565
, /* StoreTexImageFunc */
964 NULL
, /* FetchTexel1D */
965 NULL
, /* FetchTexel2D */
966 NULL
, /* FetchTexel3D */
967 fetch_texel_1d_f_rgb565_rev
, /* FetchTexel1Df */
968 fetch_texel_2d_f_rgb565_rev
, /* FetchTexel2Df */
969 fetch_texel_3d_f_rgb565_rev
, /* FetchTexel3Df */
970 store_texel_rgb565_rev
/* StoreTexel */
973 const struct gl_texture_format _mesa_texformat_rgba4444
= {
974 MESA_FORMAT_RGBA4444
, /* MesaFormat */
975 GL_RGBA
, /* BaseFormat */
976 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
981 0, /* LuminanceBits */
982 0, /* IntensityBits */
987 _mesa_texstore_rgba4444
, /* StoreTexImageFunc */
988 NULL
, /* FetchTexel1D */
989 NULL
, /* FetchTexel2D */
990 NULL
, /* FetchTexel3D */
991 fetch_texel_1d_f_rgba4444
, /* FetchTexel1Df */
992 fetch_texel_2d_f_rgba4444
, /* FetchTexel2Df */
993 fetch_texel_3d_f_rgba4444
, /* FetchTexel3Df */
994 store_texel_rgba4444
/* StoreTexel */
997 const struct gl_texture_format _mesa_texformat_argb4444
= {
998 MESA_FORMAT_ARGB4444
, /* MesaFormat */
999 GL_RGBA
, /* BaseFormat */
1000 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1005 0, /* LuminanceBits */
1006 0, /* IntensityBits */
1009 0, /* StencilBits */
1011 _mesa_texstore_argb4444
, /* StoreTexImageFunc */
1012 NULL
, /* FetchTexel1D */
1013 NULL
, /* FetchTexel2D */
1014 NULL
, /* FetchTexel3D */
1015 fetch_texel_1d_f_argb4444
, /* FetchTexel1Df */
1016 fetch_texel_2d_f_argb4444
, /* FetchTexel2Df */
1017 fetch_texel_3d_f_argb4444
, /* FetchTexel3Df */
1018 store_texel_argb4444
/* StoreTexel */
1021 const struct gl_texture_format _mesa_texformat_argb4444_rev
= {
1022 MESA_FORMAT_ARGB4444_REV
, /* MesaFormat */
1023 GL_RGBA
, /* BaseFormat */
1024 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1029 0, /* LuminanceBits */
1030 0, /* IntensityBits */
1033 0, /* StencilBits */
1035 _mesa_texstore_argb4444
, /* StoreTexImageFunc */
1036 NULL
, /* FetchTexel1D */
1037 NULL
, /* FetchTexel2D */
1038 NULL
, /* FetchTexel3D */
1039 fetch_texel_1d_f_argb4444_rev
, /* FetchTexel1Df */
1040 fetch_texel_2d_f_argb4444_rev
, /* FetchTexel2Df */
1041 fetch_texel_3d_f_argb4444_rev
, /* FetchTexel3Df */
1042 store_texel_argb4444_rev
/* StoreTexel */
1045 const struct gl_texture_format _mesa_texformat_rgba5551
= {
1046 MESA_FORMAT_RGBA5551
, /* MesaFormat */
1047 GL_RGBA
, /* BaseFormat */
1048 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1053 0, /* LuminanceBits */
1054 0, /* IntensityBits */
1057 0, /* StencilBits */
1059 _mesa_texstore_rgba5551
, /* StoreTexImageFunc */
1060 NULL
, /* FetchTexel1D */
1061 NULL
, /* FetchTexel2D */
1062 NULL
, /* FetchTexel3D */
1063 fetch_texel_1d_f_rgba5551
, /* FetchTexel1Df */
1064 fetch_texel_2d_f_rgba5551
, /* FetchTexel2Df */
1065 fetch_texel_3d_f_rgba5551
, /* FetchTexel3Df */
1066 store_texel_rgba5551
/* StoreTexel */
1069 const struct gl_texture_format _mesa_texformat_argb1555
= {
1070 MESA_FORMAT_ARGB1555
, /* MesaFormat */
1071 GL_RGBA
, /* BaseFormat */
1072 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1077 0, /* LuminanceBits */
1078 0, /* IntensityBits */
1081 0, /* StencilBits */
1083 _mesa_texstore_argb1555
, /* StoreTexImageFunc */
1084 NULL
, /* FetchTexel1D */
1085 NULL
, /* FetchTexel2D */
1086 NULL
, /* FetchTexel3D */
1087 fetch_texel_1d_f_argb1555
, /* FetchTexel1Df */
1088 fetch_texel_2d_f_argb1555
, /* FetchTexel2Df */
1089 fetch_texel_3d_f_argb1555
, /* FetchTexel3Df */
1090 store_texel_argb1555
/* StoreTexel */
1093 const struct gl_texture_format _mesa_texformat_argb1555_rev
= {
1094 MESA_FORMAT_ARGB1555_REV
, /* MesaFormat */
1095 GL_RGBA
, /* BaseFormat */
1096 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1101 0, /* LuminanceBits */
1102 0, /* IntensityBits */
1105 0, /* StencilBits */
1107 _mesa_texstore_argb1555
, /* StoreTexImageFunc */
1108 NULL
, /* FetchTexel1D */
1109 NULL
, /* FetchTexel2D */
1110 NULL
, /* FetchTexel3D */
1111 fetch_texel_1d_f_argb1555_rev
, /* FetchTexel1Df */
1112 fetch_texel_2d_f_argb1555_rev
, /* FetchTexel2Df */
1113 fetch_texel_3d_f_argb1555_rev
, /* FetchTexel3Df */
1114 store_texel_argb1555_rev
/* StoreTexel */
1117 const struct gl_texture_format _mesa_texformat_al88
= {
1118 MESA_FORMAT_AL88
, /* MesaFormat */
1119 GL_LUMINANCE_ALPHA
, /* BaseFormat */
1120 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1125 8, /* LuminanceBits */
1126 0, /* IntensityBits */
1129 0, /* StencilBits */
1131 _mesa_texstore_al88
, /* StoreTexImageFunc */
1132 NULL
, /* FetchTexel1D */
1133 NULL
, /* FetchTexel2D */
1134 NULL
, /* FetchTexel3D */
1135 fetch_texel_1d_f_al88
, /* FetchTexel1Df */
1136 fetch_texel_2d_f_al88
, /* FetchTexel2Df */
1137 fetch_texel_3d_f_al88
, /* FetchTexel3Df */
1138 store_texel_al88
/* StoreTexel */
1141 const struct gl_texture_format _mesa_texformat_al88_rev
= {
1142 MESA_FORMAT_AL88_REV
, /* MesaFormat */
1143 GL_LUMINANCE_ALPHA
, /* BaseFormat */
1144 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1149 8, /* LuminanceBits */
1150 0, /* IntensityBits */
1153 0, /* StencilBits */
1155 _mesa_texstore_al88
, /* StoreTexImageFunc */
1156 NULL
, /* FetchTexel1D */
1157 NULL
, /* FetchTexel2D */
1158 NULL
, /* FetchTexel3D */
1159 fetch_texel_1d_f_al88_rev
, /* FetchTexel1Df */
1160 fetch_texel_2d_f_al88_rev
, /* FetchTexel2Df */
1161 fetch_texel_3d_f_al88_rev
, /* FetchTexel3Df */
1162 store_texel_al88_rev
/* StoreTexel */
1165 const struct gl_texture_format _mesa_texformat_rgb332
= {
1166 MESA_FORMAT_RGB332
, /* MesaFormat */
1167 GL_RGB
, /* BaseFormat */
1168 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1173 0, /* LuminanceBits */
1174 0, /* IntensityBits */
1177 0, /* StencilBits */
1179 _mesa_texstore_rgb332
, /* StoreTexImageFunc */
1180 NULL
, /* FetchTexel1D */
1181 NULL
, /* FetchTexel2D */
1182 NULL
, /* FetchTexel3D */
1183 fetch_texel_1d_f_rgb332
, /* FetchTexel1Df */
1184 fetch_texel_2d_f_rgb332
, /* FetchTexel2Df */
1185 fetch_texel_3d_f_rgb332
, /* FetchTexel3Df */
1186 store_texel_rgb332
/* StoreTexel */
1189 const struct gl_texture_format _mesa_texformat_a8
= {
1190 MESA_FORMAT_A8
, /* MesaFormat */
1191 GL_ALPHA
, /* BaseFormat */
1192 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1197 0, /* LuminanceBits */
1198 0, /* IntensityBits */
1201 0, /* StencilBits */
1203 _mesa_texstore_a8
, /* StoreTexImageFunc */
1204 NULL
, /* FetchTexel1D */
1205 NULL
, /* FetchTexel2D */
1206 NULL
, /* FetchTexel3D */
1207 fetch_texel_1d_f_a8
, /* FetchTexel1Df */
1208 fetch_texel_2d_f_a8
, /* FetchTexel2Df */
1209 fetch_texel_3d_f_a8
, /* FetchTexel3Df */
1210 store_texel_a8
/* StoreTexel */
1213 const struct gl_texture_format _mesa_texformat_l8
= {
1214 MESA_FORMAT_L8
, /* MesaFormat */
1215 GL_LUMINANCE
, /* BaseFormat */
1216 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1221 8, /* LuminanceBits */
1222 0, /* IntensityBits */
1225 0, /* StencilBits */
1227 _mesa_texstore_a8
,/*yes*/ /* StoreTexImageFunc */
1228 NULL
, /* FetchTexel1D */
1229 NULL
, /* FetchTexel2D */
1230 NULL
, /* FetchTexel3D */
1231 fetch_texel_1d_f_l8
, /* FetchTexel1Df */
1232 fetch_texel_2d_f_l8
, /* FetchTexel2Df */
1233 fetch_texel_3d_f_l8
, /* FetchTexel3Df */
1234 store_texel_l8
/* StoreTexel */
1237 const struct gl_texture_format _mesa_texformat_i8
= {
1238 MESA_FORMAT_I8
, /* MesaFormat */
1239 GL_INTENSITY
, /* BaseFormat */
1240 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1245 0, /* LuminanceBits */
1246 8, /* IntensityBits */
1249 0, /* StencilBits */
1251 _mesa_texstore_a8
,/*yes*/ /* StoreTexImageFunc */
1252 NULL
, /* FetchTexel1D */
1253 NULL
, /* FetchTexel2D */
1254 NULL
, /* FetchTexel3D */
1255 fetch_texel_1d_f_i8
, /* FetchTexel1Df */
1256 fetch_texel_2d_f_i8
, /* FetchTexel2Df */
1257 fetch_texel_3d_f_i8
, /* FetchTexel3Df */
1258 store_texel_i8
/* StoreTexel */
1261 const struct gl_texture_format _mesa_texformat_ci8
= {
1262 MESA_FORMAT_CI8
, /* MesaFormat */
1263 GL_COLOR_INDEX
, /* BaseFormat */
1264 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1269 0, /* LuminanceBits */
1270 0, /* IntensityBits */
1273 0, /* StencilBits */
1275 _mesa_texstore_ci8
, /* StoreTexImageFunc */
1276 NULL
, /* FetchTexel1D */
1277 NULL
, /* FetchTexel2D */
1278 NULL
, /* FetchTexel3D */
1279 fetch_texel_1d_f_ci8
, /* FetchTexel1Df */
1280 fetch_texel_2d_f_ci8
, /* FetchTexel2Df */
1281 fetch_texel_3d_f_ci8
, /* FetchTexel3Df */
1282 store_texel_ci8
/* StoreTexel */
1285 const struct gl_texture_format _mesa_texformat_ycbcr
= {
1286 MESA_FORMAT_YCBCR
, /* MesaFormat */
1287 GL_YCBCR_MESA
, /* BaseFormat */
1288 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1293 0, /* LuminanceBits */
1294 0, /* IntensityBits */
1297 0, /* StencilBits */
1299 _mesa_texstore_ycbcr
, /* StoreTexImageFunc */
1300 NULL
, /* FetchTexel1D */
1301 NULL
, /* FetchTexel2D */
1302 NULL
, /* FetchTexel3D */
1303 fetch_texel_1d_f_ycbcr
, /* FetchTexel1Df */
1304 fetch_texel_2d_f_ycbcr
, /* FetchTexel2Df */
1305 fetch_texel_3d_f_ycbcr
, /* FetchTexel3Df */
1306 store_texel_ycbcr
/* StoreTexel */
1309 const struct gl_texture_format _mesa_texformat_ycbcr_rev
= {
1310 MESA_FORMAT_YCBCR_REV
, /* MesaFormat */
1311 GL_YCBCR_MESA
, /* BaseFormat */
1312 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1317 0, /* LuminanceBits */
1318 0, /* IntensityBits */
1321 0, /* StencilBits */
1323 _mesa_texstore_ycbcr
, /* StoreTexImageFunc */
1324 NULL
, /* FetchTexel1D */
1325 NULL
, /* FetchTexel2D */
1326 NULL
, /* FetchTexel3D */
1327 fetch_texel_1d_f_ycbcr_rev
, /* FetchTexel1Df */
1328 fetch_texel_2d_f_ycbcr_rev
, /* FetchTexel2Df */
1329 fetch_texel_3d_f_ycbcr_rev
, /* FetchTexel3Df */
1330 store_texel_ycbcr_rev
/* StoreTexel */
1333 const struct gl_texture_format _mesa_texformat_z24_s8
= {
1334 MESA_FORMAT_Z24_S8
, /* MesaFormat */
1335 GL_DEPTH_STENCIL_EXT
, /* BaseFormat */
1336 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1341 0, /* LuminanceBits */
1342 0, /* IntensityBits */
1345 8, /* StencilBits */
1347 _mesa_texstore_z24_s8
, /* StoreTexImageFunc */
1348 NULL
, /* FetchTexel1D */
1349 NULL
, /* FetchTexel2D */
1350 NULL
, /* FetchTexel3D */
1351 fetch_texel_1d_f_z24_s8
, /* FetchTexel1Df */
1352 fetch_texel_2d_f_z24_s8
, /* FetchTexel2Df */
1353 fetch_texel_3d_f_z24_s8
, /* FetchTexel3Df */
1354 store_texel_z24_s8
/* StoreTexel */
1357 const struct gl_texture_format _mesa_texformat_s8_z24
= {
1358 MESA_FORMAT_S8_Z24
, /* MesaFormat */
1359 GL_DEPTH_STENCIL_EXT
, /* BaseFormat */
1360 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1365 0, /* LuminanceBits */
1366 0, /* IntensityBits */
1369 8, /* StencilBits */
1371 _mesa_texstore_s8_z24
, /* StoreTexImageFunc */
1372 NULL
, /* FetchTexel1D */
1373 NULL
, /* FetchTexel2D */
1374 NULL
, /* FetchTexel3D */
1375 fetch_texel_1d_f_s8_z24
, /* FetchTexel1Df */
1376 fetch_texel_2d_f_s8_z24
, /* FetchTexel2Df */
1377 fetch_texel_3d_f_s8_z24
, /* FetchTexel3Df */
1378 store_texel_s8_z24
/* StoreTexel */
1381 const struct gl_texture_format _mesa_texformat_z16
= {
1382 MESA_FORMAT_Z16
, /* MesaFormat */
1383 GL_DEPTH_COMPONENT
, /* BaseFormat */
1384 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1389 0, /* LuminanceBits */
1390 0, /* IntensityBits */
1392 sizeof(GLushort
) * 8, /* DepthBits */
1393 0, /* StencilBits */
1394 sizeof(GLushort
), /* TexelBytes */
1395 _mesa_texstore_z16
, /* StoreTexImageFunc */
1396 NULL
, /* FetchTexel1D */
1397 NULL
, /* FetchTexel1D */
1398 NULL
, /* FetchTexel1D */
1399 fetch_texel_1d_f_z16
, /* FetchTexel1Df */
1400 fetch_texel_2d_f_z16
, /* FetchTexel2Df */
1401 fetch_texel_3d_f_z16
, /* FetchTexel3Df */
1402 store_texel_z16
/* StoreTexel */
1405 const struct gl_texture_format _mesa_texformat_z32
= {
1406 MESA_FORMAT_Z32
, /* MesaFormat */
1407 GL_DEPTH_COMPONENT
, /* BaseFormat */
1408 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
1413 0, /* LuminanceBits */
1414 0, /* IntensityBits */
1416 sizeof(GLuint
) * 8, /* DepthBits */
1417 0, /* StencilBits */
1418 sizeof(GLuint
), /* TexelBytes */
1419 _mesa_texstore_z32
, /* StoreTexImageFunc */
1420 NULL
, /* FetchTexel1D */
1421 NULL
, /* FetchTexel1D */
1422 NULL
, /* FetchTexel1D */
1423 fetch_texel_1d_f_z32
, /* FetchTexel1Df */
1424 fetch_texel_2d_f_z32
, /* FetchTexel2Df */
1425 fetch_texel_3d_f_z32
, /* FetchTexel3Df */
1426 store_texel_z32
/* StoreTexel */
1432 /***************************************************************/
1433 /** \name Null format (useful for proxy textures) */
1436 const struct gl_texture_format _mesa_null_texformat
= {
1437 -1, /* MesaFormat */
1439 GL_NONE
, /* DataType */
1444 0, /* LuminanceBits */
1445 0, /* IntensityBits */
1448 0, /* StencilBits */
1450 NULL
, /* StoreTexImageFunc */
1451 fetch_null_texel
, /* FetchTexel1D */
1452 fetch_null_texel
, /* FetchTexel2D */
1453 fetch_null_texel
, /* FetchTexel3D */
1454 fetch_null_texelf
, /* FetchTexel1Df */
1455 fetch_null_texelf
, /* FetchTexel2Df */
1456 fetch_null_texelf
, /* FetchTexel3Df */
1457 store_null_texel
/* StoreTexel */
1464 * Choose an appropriate texture format given the format, type and
1465 * internalFormat parameters passed to glTexImage().
1467 * \param ctx the GL context.
1468 * \param internalFormat user's prefered internal texture format.
1469 * \param format incoming image pixel format.
1470 * \param type incoming image data type.
1472 * \return a pointer to a gl_texture_format object which describes the
1473 * choosen texture format, or NULL on failure.
1475 * This is called via dd_function_table::ChooseTextureFormat. Hardware drivers
1476 * will typically override this function with a specialized version.
1478 const struct gl_texture_format
*
1479 _mesa_choose_tex_format( GLcontext
*ctx
, GLint internalFormat
,
1480 GLenum format
, GLenum type
)
1485 switch (internalFormat
) {
1492 return &_mesa_texformat_rgba
;
1494 return &_mesa_texformat_rgba8888
;
1496 return &_mesa_texformat_argb1555
;
1498 return &_mesa_texformat_argb4444_rev
; /* just to test another format*/
1500 return &_mesa_texformat_argb4444
;
1508 return &_mesa_texformat_rgb
;
1510 return &_mesa_texformat_rgb888
;
1512 return &_mesa_texformat_rgb332
;
1514 return &_mesa_texformat_rgb565_rev
; /* just to test another format */
1516 return &_mesa_texformat_rgb565
;
1523 return &_mesa_texformat_alpha
;
1525 return &_mesa_texformat_a8
;
1527 /* Luminance formats */
1531 case GL_LUMINANCE12
:
1532 case GL_LUMINANCE16
:
1533 return &_mesa_texformat_luminance
;
1535 return &_mesa_texformat_l8
;
1537 /* Luminance/Alpha formats */
1539 case GL_LUMINANCE_ALPHA
:
1540 case GL_LUMINANCE4_ALPHA4
:
1541 case GL_LUMINANCE6_ALPHA2
:
1542 case GL_LUMINANCE12_ALPHA4
:
1543 case GL_LUMINANCE12_ALPHA12
:
1544 case GL_LUMINANCE16_ALPHA16
:
1545 return &_mesa_texformat_luminance_alpha
;
1546 case GL_LUMINANCE8_ALPHA8
:
1547 return &_mesa_texformat_al88
;
1551 case GL_INTENSITY12
:
1552 case GL_INTENSITY16
:
1553 return &_mesa_texformat_intensity
;
1555 return &_mesa_texformat_i8
;
1557 case GL_COLOR_INDEX
:
1558 case GL_COLOR_INDEX1_EXT
:
1559 case GL_COLOR_INDEX2_EXT
:
1560 case GL_COLOR_INDEX4_EXT
:
1561 case GL_COLOR_INDEX12_EXT
:
1562 case GL_COLOR_INDEX16_EXT
:
1563 case GL_COLOR_INDEX8_EXT
:
1564 return &_mesa_texformat_ci8
;
1570 if (ctx
->Extensions
.ARB_depth_texture
) {
1571 switch (internalFormat
) {
1572 case GL_DEPTH_COMPONENT
:
1573 case GL_DEPTH_COMPONENT24
:
1574 case GL_DEPTH_COMPONENT32
:
1575 return &_mesa_texformat_z32
;
1576 case GL_DEPTH_COMPONENT16
:
1577 return &_mesa_texformat_z16
;
1583 switch (internalFormat
) {
1584 case GL_COMPRESSED_ALPHA_ARB
:
1585 return &_mesa_texformat_alpha
;
1586 case GL_COMPRESSED_LUMINANCE_ARB
:
1587 return &_mesa_texformat_luminance
;
1588 case GL_COMPRESSED_LUMINANCE_ALPHA_ARB
:
1589 return &_mesa_texformat_luminance_alpha
;
1590 case GL_COMPRESSED_INTENSITY_ARB
:
1591 return &_mesa_texformat_intensity
;
1592 case GL_COMPRESSED_RGB_ARB
:
1593 #if FEATURE_texture_fxt1
1594 if (ctx
->Extensions
.TDFX_texture_compression_FXT1
)
1595 return &_mesa_texformat_rgb_fxt1
;
1597 #if FEATURE_texture_s3tc
1598 if (ctx
->Extensions
.EXT_texture_compression_s3tc
||
1599 ctx
->Extensions
.S3_s3tc
)
1600 return &_mesa_texformat_rgb_dxt1
;
1602 return &_mesa_texformat_rgb
;
1603 case GL_COMPRESSED_RGBA_ARB
:
1604 #if FEATURE_texture_fxt1
1605 if (ctx
->Extensions
.TDFX_texture_compression_FXT1
)
1606 return &_mesa_texformat_rgba_fxt1
;
1608 #if FEATURE_texture_s3tc
1609 if (ctx
->Extensions
.EXT_texture_compression_s3tc
||
1610 ctx
->Extensions
.S3_s3tc
)
1611 return &_mesa_texformat_rgba_dxt3
; /* Not rgba_dxt1, see spec */
1613 return &_mesa_texformat_rgba
;
1618 if (ctx
->Extensions
.MESA_ycbcr_texture
) {
1619 if (internalFormat
== GL_YCBCR_MESA
) {
1620 if (type
== GL_UNSIGNED_SHORT_8_8_MESA
)
1621 return &_mesa_texformat_ycbcr
;
1623 return &_mesa_texformat_ycbcr_rev
;
1627 #if FEATURE_texture_fxt1
1628 if (ctx
->Extensions
.TDFX_texture_compression_FXT1
) {
1629 switch (internalFormat
) {
1630 case GL_COMPRESSED_RGB_FXT1_3DFX
:
1631 return &_mesa_texformat_rgb_fxt1
;
1632 case GL_COMPRESSED_RGBA_FXT1_3DFX
:
1633 return &_mesa_texformat_rgba_fxt1
;
1640 #if FEATURE_texture_s3tc
1641 if (ctx
->Extensions
.EXT_texture_compression_s3tc
) {
1642 switch (internalFormat
) {
1643 case GL_COMPRESSED_RGB_S3TC_DXT1_EXT
:
1644 return &_mesa_texformat_rgb_dxt1
;
1645 case GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
:
1646 return &_mesa_texformat_rgba_dxt1
;
1647 case GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
:
1648 return &_mesa_texformat_rgba_dxt3
;
1649 case GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
:
1650 return &_mesa_texformat_rgba_dxt5
;
1656 if (ctx
->Extensions
.S3_s3tc
) {
1657 switch (internalFormat
) {
1660 return &_mesa_texformat_rgb_dxt1
;
1663 return &_mesa_texformat_rgba_dxt3
;
1670 if (ctx
->Extensions
.ARB_texture_float
) {
1671 switch (internalFormat
) {
1672 case GL_ALPHA16F_ARB
:
1673 return &_mesa_texformat_alpha_float16
;
1674 case GL_ALPHA32F_ARB
:
1675 return &_mesa_texformat_alpha_float32
;
1676 case GL_LUMINANCE16F_ARB
:
1677 return &_mesa_texformat_luminance_float16
;
1678 case GL_LUMINANCE32F_ARB
:
1679 return &_mesa_texformat_luminance_float32
;
1680 case GL_LUMINANCE_ALPHA16F_ARB
:
1681 return &_mesa_texformat_luminance_alpha_float16
;
1682 case GL_LUMINANCE_ALPHA32F_ARB
:
1683 return &_mesa_texformat_luminance_alpha_float32
;
1684 case GL_INTENSITY16F_ARB
:
1685 return &_mesa_texformat_intensity_float16
;
1686 case GL_INTENSITY32F_ARB
:
1687 return &_mesa_texformat_intensity_float32
;
1689 return &_mesa_texformat_rgb_float16
;
1691 return &_mesa_texformat_rgb_float32
;
1692 case GL_RGBA16F_ARB
:
1693 return &_mesa_texformat_rgba_float16
;
1694 case GL_RGBA32F_ARB
:
1695 return &_mesa_texformat_rgba_float32
;
1701 if (ctx
->Extensions
.EXT_packed_depth_stencil
) {
1702 switch (internalFormat
) {
1703 case GL_DEPTH_STENCIL_EXT
:
1704 case GL_DEPTH24_STENCIL8_EXT
:
1705 return &_mesa_texformat_z24_s8
;
1711 if (ctx
->Extensions
.ATI_envmap_bumpmap
) {
1712 switch (internalFormat
) {
1715 return &_mesa_texformat_dudv8
;
1721 if (ctx
->Extensions
.MESA_texture_signed_rgba
) {
1722 switch (internalFormat
) {
1724 case GL_RGBA8_SNORM
:
1725 return &_mesa_texformat_signed_rgba8888
;
1732 #if FEATURE_EXT_texture_sRGB
1733 if (ctx
->Extensions
.EXT_texture_sRGB
) {
1734 switch (internalFormat
) {
1737 return &_mesa_texformat_srgb8
;
1738 case GL_SRGB_ALPHA_EXT
:
1739 case GL_SRGB8_ALPHA8_EXT
:
1740 return &_mesa_texformat_srgba8
;
1741 case GL_SLUMINANCE_EXT
:
1742 case GL_SLUMINANCE8_EXT
:
1743 return &_mesa_texformat_sl8
;
1744 case GL_SLUMINANCE_ALPHA_EXT
:
1745 case GL_SLUMINANCE8_ALPHA8_EXT
:
1746 return &_mesa_texformat_sla8
;
1747 case GL_COMPRESSED_SLUMINANCE_EXT
:
1748 return &_mesa_texformat_sl8
;
1749 case GL_COMPRESSED_SLUMINANCE_ALPHA_EXT
:
1750 return &_mesa_texformat_sla8
;
1751 case GL_COMPRESSED_SRGB_EXT
:
1752 #if FEATURE_texture_s3tc
1753 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
1754 return &_mesa_texformat_srgb_dxt1
;
1756 return &_mesa_texformat_srgb8
;
1757 case GL_COMPRESSED_SRGB_ALPHA_EXT
:
1758 #if FEATURE_texture_s3tc
1759 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
1760 return &_mesa_texformat_srgba_dxt3
; /* Not srgba_dxt1, see spec */
1762 return &_mesa_texformat_srgba8
;
1763 #if FEATURE_texture_s3tc
1764 case GL_COMPRESSED_SRGB_S3TC_DXT1_EXT
:
1765 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
1766 return &_mesa_texformat_srgb_dxt1
;
1768 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT
:
1769 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
1770 return &_mesa_texformat_srgba_dxt1
;
1772 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT
:
1773 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
1774 return &_mesa_texformat_srgba_dxt3
;
1776 case GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT
:
1777 if (ctx
->Extensions
.EXT_texture_compression_s3tc
)
1778 return &_mesa_texformat_srgba_dxt5
;
1785 #endif /* FEATURE_EXT_texture_sRGB */
1787 _mesa_problem(ctx
, "unexpected format in _mesa_choose_tex_format()");
1794 * Return datatype and number of components per texel for the
1795 * given gl_texture_format.
1798 _mesa_format_to_type_and_comps(const struct gl_texture_format
*format
,
1799 GLenum
*datatype
, GLuint
*comps
)
1801 switch (format
->MesaFormat
) {
1802 case MESA_FORMAT_RGBA8888
:
1803 case MESA_FORMAT_RGBA8888_REV
:
1804 case MESA_FORMAT_ARGB8888
:
1805 case MESA_FORMAT_ARGB8888_REV
:
1806 *datatype
= CHAN_TYPE
;
1809 case MESA_FORMAT_RGB888
:
1810 case MESA_FORMAT_BGR888
:
1811 *datatype
= GL_UNSIGNED_BYTE
;
1814 case MESA_FORMAT_RGB565
:
1815 case MESA_FORMAT_RGB565_REV
:
1816 *datatype
= GL_UNSIGNED_SHORT_5_6_5
;
1820 case MESA_FORMAT_ARGB4444
:
1821 case MESA_FORMAT_ARGB4444_REV
:
1822 *datatype
= GL_UNSIGNED_SHORT_4_4_4_4
;
1826 case MESA_FORMAT_ARGB1555
:
1827 case MESA_FORMAT_ARGB1555_REV
:
1828 *datatype
= GL_UNSIGNED_SHORT_1_5_5_5_REV
;
1832 case MESA_FORMAT_AL88
:
1833 case MESA_FORMAT_AL88_REV
:
1834 *datatype
= GL_UNSIGNED_BYTE
;
1837 case MESA_FORMAT_RGB332
:
1838 *datatype
= GL_UNSIGNED_BYTE_3_3_2
;
1842 case MESA_FORMAT_A8
:
1843 case MESA_FORMAT_L8
:
1844 case MESA_FORMAT_I8
:
1845 case MESA_FORMAT_CI8
:
1846 *datatype
= GL_UNSIGNED_BYTE
;
1850 case MESA_FORMAT_YCBCR
:
1851 case MESA_FORMAT_YCBCR_REV
:
1852 *datatype
= GL_UNSIGNED_SHORT
;
1856 case MESA_FORMAT_Z24_S8
:
1857 *datatype
= GL_UNSIGNED_INT
;
1858 *comps
= 1; /* XXX OK? */
1861 case MESA_FORMAT_S8_Z24
:
1862 *datatype
= GL_UNSIGNED_INT
;
1863 *comps
= 1; /* XXX OK? */
1866 case MESA_FORMAT_Z16
:
1867 *datatype
= GL_UNSIGNED_SHORT
;
1871 case MESA_FORMAT_Z32
:
1872 *datatype
= GL_UNSIGNED_INT
;
1876 case MESA_FORMAT_DUDV8
:
1877 *datatype
= GL_BYTE
;
1881 case MESA_FORMAT_SIGNED_RGBA8888
:
1882 case MESA_FORMAT_SIGNED_RGBA8888_REV
:
1883 *datatype
= GL_BYTE
;
1887 #if FEATURE_EXT_texture_sRGB
1888 case MESA_FORMAT_SRGB8
:
1889 *datatype
= GL_UNSIGNED_BYTE
;
1892 case MESA_FORMAT_SRGBA8
:
1893 case MESA_FORMAT_SARGB8
:
1894 *datatype
= GL_UNSIGNED_BYTE
;
1897 case MESA_FORMAT_SL8
:
1898 *datatype
= GL_UNSIGNED_BYTE
;
1901 case MESA_FORMAT_SLA8
:
1902 *datatype
= GL_UNSIGNED_BYTE
;
1907 #if FEATURE_texture_fxt1
1908 case MESA_FORMAT_RGB_FXT1
:
1909 case MESA_FORMAT_RGBA_FXT1
:
1911 #if FEATURE_texture_s3tc
1912 case MESA_FORMAT_RGB_DXT1
:
1913 case MESA_FORMAT_RGBA_DXT1
:
1914 case MESA_FORMAT_RGBA_DXT3
:
1915 case MESA_FORMAT_RGBA_DXT5
:
1916 #if FEATURE_EXT_texture_sRGB
1917 case MESA_FORMAT_SRGB_DXT1
:
1918 case MESA_FORMAT_SRGBA_DXT1
:
1919 case MESA_FORMAT_SRGBA_DXT3
:
1920 case MESA_FORMAT_SRGBA_DXT5
:
1922 /* XXX generate error instead? */
1923 *datatype
= GL_UNSIGNED_BYTE
;
1928 case MESA_FORMAT_RGBA
:
1929 *datatype
= CHAN_TYPE
;
1932 case MESA_FORMAT_RGB
:
1933 *datatype
= CHAN_TYPE
;
1936 case MESA_FORMAT_LUMINANCE_ALPHA
:
1937 *datatype
= CHAN_TYPE
;
1940 case MESA_FORMAT_ALPHA
:
1941 case MESA_FORMAT_LUMINANCE
:
1942 case MESA_FORMAT_INTENSITY
:
1943 *datatype
= CHAN_TYPE
;
1947 case MESA_FORMAT_RGBA_FLOAT32
:
1948 *datatype
= GL_FLOAT
;
1951 case MESA_FORMAT_RGBA_FLOAT16
:
1952 *datatype
= GL_HALF_FLOAT_ARB
;
1955 case MESA_FORMAT_RGB_FLOAT32
:
1956 *datatype
= GL_FLOAT
;
1959 case MESA_FORMAT_RGB_FLOAT16
:
1960 *datatype
= GL_HALF_FLOAT_ARB
;
1963 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT32
:
1964 *datatype
= GL_FLOAT
;
1967 case MESA_FORMAT_LUMINANCE_ALPHA_FLOAT16
:
1968 *datatype
= GL_HALF_FLOAT_ARB
;
1971 case MESA_FORMAT_ALPHA_FLOAT32
:
1972 case MESA_FORMAT_LUMINANCE_FLOAT32
:
1973 case MESA_FORMAT_INTENSITY_FLOAT32
:
1974 *datatype
= GL_FLOAT
;
1977 case MESA_FORMAT_ALPHA_FLOAT16
:
1978 case MESA_FORMAT_LUMINANCE_FLOAT16
:
1979 case MESA_FORMAT_INTENSITY_FLOAT16
:
1980 *datatype
= GL_HALF_FLOAT_ARB
;
1985 _mesa_problem(NULL
, "bad format in _mesa_format_to_type_and_comps");