2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2007 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.
28 * \file texcompress_s3tc.c
29 * GL_EXT_texture_compression_s3tc support.
32 #ifndef USE_EXTERNAL_DXTN_LIB
33 #define USE_EXTERNAL_DXTN_LIB 1
43 #include "texcompress.h"
44 #include "texformat.h"
48 #define DXTN_LIBNAME "dxtn.dll"
51 #elif defined(__DJGPP__)
52 #define DXTN_LIBNAME "dxtn.dxe"
54 #define DXTN_LIBNAME "libtxc_dxtn.so"
57 #if FEATURE_EXT_texture_sRGB
59 * Convert an 8-bit sRGB value from non-linear space to a
60 * linear RGB value in [0, 1].
61 * Implemented with a 256-entry lookup table.
64 nonlinear_to_linear(GLubyte cs8
)
66 static GLfloat table
[256];
67 static GLboolean tableReady
= GL_FALSE
;
69 /* compute lookup table now */
71 for (i
= 0; i
< 256; i
++) {
72 const GLfloat cs
= UBYTE_TO_FLOAT(i
);
74 table
[i
] = cs
/ 12.92f
;
77 table
[i
] = (GLfloat
) _mesa_pow((cs
+ 0.055) / 1.055, 2.4);
84 #endif /* FEATURE_EXT_texture_sRGB */
86 typedef void (*dxtFetchTexelFuncExt
)( GLint srcRowstride
, GLubyte
*pixdata
, GLint col
, GLint row
, GLvoid
*texelOut
);
88 dxtFetchTexelFuncExt fetch_ext_rgb_dxt1
= NULL
;
89 dxtFetchTexelFuncExt fetch_ext_rgba_dxt1
= NULL
;
90 dxtFetchTexelFuncExt fetch_ext_rgba_dxt3
= NULL
;
91 dxtFetchTexelFuncExt fetch_ext_rgba_dxt5
= NULL
;
93 typedef void (*dxtCompressTexFuncExt
)(GLint srccomps
, GLint width
,
94 GLint height
, const GLchan
*srcPixData
,
95 GLenum destformat
, GLubyte
*dest
,
98 static dxtCompressTexFuncExt ext_tx_compress_dxtn
= NULL
;
100 static void *dxtlibhandle
= NULL
;
104 _mesa_init_texture_s3tc( GLcontext
*ctx
)
106 /* called during context initialization */
107 ctx
->Mesa_DXTn
= GL_FALSE
;
108 #if USE_EXTERNAL_DXTN_LIB
110 dxtlibhandle
= _mesa_dlopen(DXTN_LIBNAME
, 0);
112 _mesa_warning(ctx
, "couldn't open " DXTN_LIBNAME
", software DXTn "
113 "compression/decompression unavailable");
116 /* the fetch functions are not per context! Might be problematic... */
117 fetch_ext_rgb_dxt1
= (dxtFetchTexelFuncExt
)
118 _mesa_dlsym(dxtlibhandle
, "fetch_2d_texel_rgb_dxt1");
119 fetch_ext_rgba_dxt1
= (dxtFetchTexelFuncExt
)
120 _mesa_dlsym(dxtlibhandle
, "fetch_2d_texel_rgba_dxt1");
121 fetch_ext_rgba_dxt3
= (dxtFetchTexelFuncExt
)
122 _mesa_dlsym(dxtlibhandle
, "fetch_2d_texel_rgba_dxt3");
123 fetch_ext_rgba_dxt5
= (dxtFetchTexelFuncExt
)
124 _mesa_dlsym(dxtlibhandle
, "fetch_2d_texel_rgba_dxt5");
125 ext_tx_compress_dxtn
= (dxtCompressTexFuncExt
)
126 _mesa_dlsym(dxtlibhandle
, "tx_compress_dxtn");
128 if (!fetch_ext_rgb_dxt1
||
129 !fetch_ext_rgba_dxt1
||
130 !fetch_ext_rgba_dxt3
||
131 !fetch_ext_rgba_dxt5
||
132 !ext_tx_compress_dxtn
) {
133 _mesa_warning(ctx
, "couldn't reference all symbols in "
134 DXTN_LIBNAME
", software DXTn compression/decompression "
136 fetch_ext_rgb_dxt1
= NULL
;
137 fetch_ext_rgba_dxt1
= NULL
;
138 fetch_ext_rgba_dxt3
= NULL
;
139 fetch_ext_rgba_dxt5
= NULL
;
140 ext_tx_compress_dxtn
= NULL
;
141 _mesa_dlclose(dxtlibhandle
);
147 ctx
->Mesa_DXTn
= GL_TRUE
;
148 _mesa_warning(ctx
, "software DXTn compression/decompression available");
156 * Called via TexFormat->StoreImage to store an RGB_DXT1 texture.
159 texstore_rgb_dxt1(TEXSTORE_PARAMS
)
161 const GLchan
*pixels
;
164 const GLint texWidth
= dstRowStride
* 4 / 8; /* a bit of a hack */
165 const GLchan
*tempImage
= NULL
;
167 ASSERT(dstFormat
== &_mesa_texformat_rgb_dxt1
);
168 ASSERT(dstXoffset
% 4 == 0);
169 ASSERT(dstYoffset
% 4 == 0);
170 ASSERT(dstZoffset
% 4 == 0);
172 (void) dstImageOffsets
;
174 if (srcFormat
!= GL_RGB
||
175 srcType
!= CHAN_TYPE
||
176 ctx
->_ImageTransferState
||
177 srcPacking
->SwapBytes
) {
178 /* convert image to RGB/GLchan */
179 tempImage
= _mesa_make_temp_chan_image(ctx
, dims
,
181 dstFormat
->BaseFormat
,
182 srcWidth
, srcHeight
, srcDepth
,
183 srcFormat
, srcType
, srcAddr
,
186 return GL_FALSE
; /* out of memory */
187 _mesa_adjust_image_for_convolution(ctx
, dims
, &srcWidth
, &srcHeight
);
189 srcRowStride
= 3 * srcWidth
;
193 pixels
= (const GLchan
*) srcAddr
;
194 srcRowStride
= _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
,
195 srcType
) / sizeof(GLchan
);
198 dst
= _mesa_compressed_image_address(dstXoffset
, dstYoffset
, 0,
199 dstFormat
->MesaFormat
,
200 texWidth
, (GLubyte
*) dstAddr
);
202 if (ext_tx_compress_dxtn
) {
203 (*ext_tx_compress_dxtn
)(3, srcWidth
, srcHeight
, pixels
,
204 GL_COMPRESSED_RGB_S3TC_DXT1_EXT
,
208 _mesa_warning(ctx
, "external dxt library not available");
212 _mesa_free((void *) tempImage
);
219 * Called via TexFormat->StoreImage to store an RGBA_DXT1 texture.
222 texstore_rgba_dxt1(TEXSTORE_PARAMS
)
224 const GLchan
*pixels
;
227 const GLint texWidth
= dstRowStride
* 4 / 8; /* a bit of a hack */
228 const GLchan
*tempImage
= NULL
;
230 ASSERT(dstFormat
== &_mesa_texformat_rgba_dxt1
);
231 ASSERT(dstXoffset
% 4 == 0);
232 ASSERT(dstYoffset
% 4 == 0);
233 ASSERT(dstZoffset
% 4 == 0);
235 (void) dstImageOffsets
;
237 if (srcFormat
!= GL_RGBA
||
238 srcType
!= CHAN_TYPE
||
239 ctx
->_ImageTransferState
||
240 srcPacking
->SwapBytes
) {
241 /* convert image to RGBA/GLchan */
242 tempImage
= _mesa_make_temp_chan_image(ctx
, dims
,
244 dstFormat
->BaseFormat
,
245 srcWidth
, srcHeight
, srcDepth
,
246 srcFormat
, srcType
, srcAddr
,
249 return GL_FALSE
; /* out of memory */
250 _mesa_adjust_image_for_convolution(ctx
, dims
, &srcWidth
, &srcHeight
);
252 srcRowStride
= 4 * srcWidth
;
256 pixels
= (const GLchan
*) srcAddr
;
257 srcRowStride
= _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
,
258 srcType
) / sizeof(GLchan
);
261 dst
= _mesa_compressed_image_address(dstXoffset
, dstYoffset
, 0,
262 dstFormat
->MesaFormat
,
263 texWidth
, (GLubyte
*) dstAddr
);
264 if (ext_tx_compress_dxtn
) {
265 (*ext_tx_compress_dxtn
)(4, srcWidth
, srcHeight
, pixels
,
266 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT
,
270 _mesa_warning(ctx
, "external dxt library not available");
274 _mesa_free((void*) tempImage
);
281 * Called via TexFormat->StoreImage to store an RGBA_DXT3 texture.
284 texstore_rgba_dxt3(TEXSTORE_PARAMS
)
286 const GLchan
*pixels
;
289 const GLint texWidth
= dstRowStride
* 4 / 16; /* a bit of a hack */
290 const GLchan
*tempImage
= NULL
;
292 ASSERT(dstFormat
== &_mesa_texformat_rgba_dxt3
);
293 ASSERT(dstXoffset
% 4 == 0);
294 ASSERT(dstYoffset
% 4 == 0);
295 ASSERT(dstZoffset
% 4 == 0);
297 (void) dstImageOffsets
;
299 if (srcFormat
!= GL_RGBA
||
300 srcType
!= CHAN_TYPE
||
301 ctx
->_ImageTransferState
||
302 srcPacking
->SwapBytes
) {
303 /* convert image to RGBA/GLchan */
304 tempImage
= _mesa_make_temp_chan_image(ctx
, dims
,
306 dstFormat
->BaseFormat
,
307 srcWidth
, srcHeight
, srcDepth
,
308 srcFormat
, srcType
, srcAddr
,
311 return GL_FALSE
; /* out of memory */
312 _mesa_adjust_image_for_convolution(ctx
, dims
, &srcWidth
, &srcHeight
);
314 srcRowStride
= 4 * srcWidth
;
317 pixels
= (const GLchan
*) srcAddr
;
318 srcRowStride
= _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
,
319 srcType
) / sizeof(GLchan
);
322 dst
= _mesa_compressed_image_address(dstXoffset
, dstYoffset
, 0,
323 dstFormat
->MesaFormat
,
324 texWidth
, (GLubyte
*) dstAddr
);
325 if (ext_tx_compress_dxtn
) {
326 (*ext_tx_compress_dxtn
)(4, srcWidth
, srcHeight
, pixels
,
327 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT
,
331 _mesa_warning(ctx
, "external dxt library not available");
335 _mesa_free((void *) tempImage
);
342 * Called via TexFormat->StoreImage to store an RGBA_DXT5 texture.
345 texstore_rgba_dxt5(TEXSTORE_PARAMS
)
347 const GLchan
*pixels
;
350 const GLint texWidth
= dstRowStride
* 4 / 16; /* a bit of a hack */
351 const GLchan
*tempImage
= NULL
;
353 ASSERT(dstFormat
== &_mesa_texformat_rgba_dxt5
);
354 ASSERT(dstXoffset
% 4 == 0);
355 ASSERT(dstYoffset
% 4 == 0);
356 ASSERT(dstZoffset
% 4 == 0);
358 (void) dstImageOffsets
;
360 if (srcFormat
!= GL_RGBA
||
361 srcType
!= CHAN_TYPE
||
362 ctx
->_ImageTransferState
||
363 srcPacking
->SwapBytes
) {
364 /* convert image to RGBA/GLchan */
365 tempImage
= _mesa_make_temp_chan_image(ctx
, dims
,
367 dstFormat
->BaseFormat
,
368 srcWidth
, srcHeight
, srcDepth
,
369 srcFormat
, srcType
, srcAddr
,
372 return GL_FALSE
; /* out of memory */
373 _mesa_adjust_image_for_convolution(ctx
, dims
, &srcWidth
, &srcHeight
);
375 srcRowStride
= 4 * srcWidth
;
378 pixels
= (const GLchan
*) srcAddr
;
379 srcRowStride
= _mesa_image_row_stride(srcPacking
, srcWidth
, srcFormat
,
380 srcType
) / sizeof(GLchan
);
383 dst
= _mesa_compressed_image_address(dstXoffset
, dstYoffset
, 0,
384 dstFormat
->MesaFormat
,
385 texWidth
, (GLubyte
*) dstAddr
);
386 if (ext_tx_compress_dxtn
) {
387 (*ext_tx_compress_dxtn
)(4, srcWidth
, srcHeight
, pixels
,
388 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT
,
392 _mesa_warning(ctx
, "external dxt library not available");
396 _mesa_free((void *) tempImage
);
403 fetch_texel_2d_rgb_dxt1( const struct gl_texture_image
*texImage
,
404 GLint i
, GLint j
, GLint k
, GLchan
*texel
)
407 if (fetch_ext_rgb_dxt1
) {
408 ASSERT (sizeof(GLchan
) == sizeof(GLubyte
));
409 fetch_ext_rgb_dxt1(texImage
->RowStride
,
410 (GLubyte
*)(texImage
)->Data
, i
, j
, texel
);
413 _mesa_debug(NULL
, "attempted to decode s3tc texture without library available\n");
418 fetch_texel_2d_f_rgb_dxt1( const struct gl_texture_image
*texImage
,
419 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
421 /* just sample as GLchan and convert to float here */
423 fetch_texel_2d_rgb_dxt1(texImage
, i
, j
, k
, rgba
);
424 texel
[RCOMP
] = CHAN_TO_FLOAT(rgba
[RCOMP
]);
425 texel
[GCOMP
] = CHAN_TO_FLOAT(rgba
[GCOMP
]);
426 texel
[BCOMP
] = CHAN_TO_FLOAT(rgba
[BCOMP
]);
427 texel
[ACOMP
] = CHAN_TO_FLOAT(rgba
[ACOMP
]);
432 fetch_texel_2d_rgba_dxt1( const struct gl_texture_image
*texImage
,
433 GLint i
, GLint j
, GLint k
, GLchan
*texel
)
436 if (fetch_ext_rgba_dxt1
) {
437 fetch_ext_rgba_dxt1(texImage
->RowStride
,
438 (GLubyte
*)(texImage
)->Data
, i
, j
, texel
);
441 _mesa_debug(NULL
, "attempted to decode s3tc texture without library available\n");
446 fetch_texel_2d_f_rgba_dxt1( const struct gl_texture_image
*texImage
,
447 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
449 /* just sample as GLchan and convert to float here */
451 fetch_texel_2d_rgba_dxt1(texImage
, i
, j
, k
, rgba
);
452 texel
[RCOMP
] = CHAN_TO_FLOAT(rgba
[RCOMP
]);
453 texel
[GCOMP
] = CHAN_TO_FLOAT(rgba
[GCOMP
]);
454 texel
[BCOMP
] = CHAN_TO_FLOAT(rgba
[BCOMP
]);
455 texel
[ACOMP
] = CHAN_TO_FLOAT(rgba
[ACOMP
]);
460 fetch_texel_2d_rgba_dxt3( const struct gl_texture_image
*texImage
,
461 GLint i
, GLint j
, GLint k
, GLchan
*texel
)
464 if (fetch_ext_rgba_dxt3
) {
465 ASSERT (sizeof(GLchan
) == sizeof(GLubyte
));
466 fetch_ext_rgba_dxt3(texImage
->RowStride
, (GLubyte
*)(texImage
)->Data
,
470 _mesa_debug(NULL
, "attempted to decode s3tc texture without library available\n");
475 fetch_texel_2d_f_rgba_dxt3( const struct gl_texture_image
*texImage
,
476 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
478 /* just sample as GLchan and convert to float here */
480 fetch_texel_2d_rgba_dxt3(texImage
, i
, j
, k
, rgba
);
481 texel
[RCOMP
] = CHAN_TO_FLOAT(rgba
[RCOMP
]);
482 texel
[GCOMP
] = CHAN_TO_FLOAT(rgba
[GCOMP
]);
483 texel
[BCOMP
] = CHAN_TO_FLOAT(rgba
[BCOMP
]);
484 texel
[ACOMP
] = CHAN_TO_FLOAT(rgba
[ACOMP
]);
489 fetch_texel_2d_rgba_dxt5( const struct gl_texture_image
*texImage
,
490 GLint i
, GLint j
, GLint k
, GLchan
*texel
)
493 if (fetch_ext_rgba_dxt5
) {
494 fetch_ext_rgba_dxt5(texImage
->RowStride
, (GLubyte
*)(texImage
)->Data
,
498 _mesa_debug(NULL
, "attempted to decode s3tc texture without library available\n");
503 fetch_texel_2d_f_rgba_dxt5( const struct gl_texture_image
*texImage
,
504 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
506 /* just sample as GLchan and convert to float here */
508 fetch_texel_2d_rgba_dxt5(texImage
, i
, j
, k
, rgba
);
509 texel
[RCOMP
] = CHAN_TO_FLOAT(rgba
[RCOMP
]);
510 texel
[GCOMP
] = CHAN_TO_FLOAT(rgba
[GCOMP
]);
511 texel
[BCOMP
] = CHAN_TO_FLOAT(rgba
[BCOMP
]);
512 texel
[ACOMP
] = CHAN_TO_FLOAT(rgba
[ACOMP
]);
515 #if FEATURE_EXT_texture_sRGB
517 fetch_texel_2d_f_srgb_dxt1( const struct gl_texture_image
*texImage
,
518 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
520 /* just sample as GLchan and convert to float here */
522 fetch_texel_2d_rgb_dxt1(texImage
, i
, j
, k
, rgba
);
523 texel
[RCOMP
] = nonlinear_to_linear(rgba
[RCOMP
]);
524 texel
[GCOMP
] = nonlinear_to_linear(rgba
[GCOMP
]);
525 texel
[BCOMP
] = nonlinear_to_linear(rgba
[BCOMP
]);
526 texel
[ACOMP
] = CHAN_TO_FLOAT(rgba
[ACOMP
]);
530 fetch_texel_2d_f_srgba_dxt1( const struct gl_texture_image
*texImage
,
531 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
533 /* just sample as GLchan and convert to float here */
535 fetch_texel_2d_rgba_dxt1(texImage
, i
, j
, k
, rgba
);
536 texel
[RCOMP
] = nonlinear_to_linear(rgba
[RCOMP
]);
537 texel
[GCOMP
] = nonlinear_to_linear(rgba
[GCOMP
]);
538 texel
[BCOMP
] = nonlinear_to_linear(rgba
[BCOMP
]);
539 texel
[ACOMP
] = CHAN_TO_FLOAT(rgba
[ACOMP
]);
543 fetch_texel_2d_f_srgba_dxt3( const struct gl_texture_image
*texImage
,
544 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
546 /* just sample as GLchan and convert to float here */
548 fetch_texel_2d_rgba_dxt3(texImage
, i
, j
, k
, rgba
);
549 texel
[RCOMP
] = nonlinear_to_linear(rgba
[RCOMP
]);
550 texel
[GCOMP
] = nonlinear_to_linear(rgba
[GCOMP
]);
551 texel
[BCOMP
] = nonlinear_to_linear(rgba
[BCOMP
]);
552 texel
[ACOMP
] = CHAN_TO_FLOAT(rgba
[ACOMP
]);
556 fetch_texel_2d_f_srgba_dxt5( const struct gl_texture_image
*texImage
,
557 GLint i
, GLint j
, GLint k
, GLfloat
*texel
)
559 /* just sample as GLchan and convert to float here */
561 fetch_texel_2d_rgba_dxt5(texImage
, i
, j
, k
, rgba
);
562 texel
[RCOMP
] = nonlinear_to_linear(rgba
[RCOMP
]);
563 texel
[GCOMP
] = nonlinear_to_linear(rgba
[GCOMP
]);
564 texel
[BCOMP
] = nonlinear_to_linear(rgba
[BCOMP
]);
565 texel
[ACOMP
] = CHAN_TO_FLOAT(rgba
[ACOMP
]);
569 const struct gl_texture_format _mesa_texformat_rgb_dxt1
= {
570 MESA_FORMAT_RGB_DXT1
, /* MesaFormat */
571 GL_RGB
, /* BaseFormat */
572 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
573 4, /*approx*/ /* RedBits */
574 4, /*approx*/ /* GreenBits */
575 4, /*approx*/ /* BlueBits */
577 0, /* LuminanceBits */
578 0, /* IntensityBits */
583 texstore_rgb_dxt1
, /* StoreTexImageFunc */
584 NULL
, /*impossible*/ /* FetchTexel1D */
585 fetch_texel_2d_rgb_dxt1
, /* FetchTexel2D */
586 NULL
, /*impossible*/ /* FetchTexel3D */
587 NULL
, /*impossible*/ /* FetchTexel1Df */
588 fetch_texel_2d_f_rgb_dxt1
, /* FetchTexel2Df */
589 NULL
, /*impossible*/ /* FetchTexel3Df */
590 NULL
/* StoreTexel */
593 const struct gl_texture_format _mesa_texformat_rgba_dxt1
= {
594 MESA_FORMAT_RGBA_DXT1
, /* MesaFormat */
595 GL_RGBA
, /* BaseFormat */
596 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
597 4, /*approx*/ /* RedBits */
598 4, /*approx*/ /* GreenBits */
599 4, /*approx*/ /* BlueBits */
600 1, /*approx*/ /* AlphaBits */
601 0, /* LuminanceBits */
602 0, /* IntensityBits */
607 texstore_rgba_dxt1
, /* StoreTexImageFunc */
608 NULL
, /*impossible*/ /* FetchTexel1D */
609 fetch_texel_2d_rgba_dxt1
, /* FetchTexel2D */
610 NULL
, /*impossible*/ /* FetchTexel3D */
611 NULL
, /*impossible*/ /* FetchTexel1Df */
612 fetch_texel_2d_f_rgba_dxt1
, /* FetchTexel2Df */
613 NULL
, /*impossible*/ /* FetchTexel3Df */
614 NULL
/* StoreTexel */
617 const struct gl_texture_format _mesa_texformat_rgba_dxt3
= {
618 MESA_FORMAT_RGBA_DXT3
, /* MesaFormat */
619 GL_RGBA
, /* BaseFormat */
620 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
621 4, /*approx*/ /* RedBits */
622 4, /*approx*/ /* GreenBits */
623 4, /*approx*/ /* BlueBits */
624 4, /*approx*/ /* AlphaBits */
625 0, /* LuminanceBits */
626 0, /* IntensityBits */
631 texstore_rgba_dxt3
, /* StoreTexImageFunc */
632 NULL
, /*impossible*/ /* FetchTexel1D */
633 fetch_texel_2d_rgba_dxt3
, /* FetchTexel2D */
634 NULL
, /*impossible*/ /* FetchTexel3D */
635 NULL
, /*impossible*/ /* FetchTexel1Df */
636 fetch_texel_2d_f_rgba_dxt3
, /* FetchTexel2Df */
637 NULL
, /*impossible*/ /* FetchTexel3Df */
638 NULL
/* StoreTexel */
641 const struct gl_texture_format _mesa_texformat_rgba_dxt5
= {
642 MESA_FORMAT_RGBA_DXT5
, /* MesaFormat */
643 GL_RGBA
, /* BaseFormat */
644 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
645 4,/*approx*/ /* RedBits */
646 4,/*approx*/ /* GreenBits */
647 4,/*approx*/ /* BlueBits */
648 4,/*approx*/ /* AlphaBits */
649 0, /* LuminanceBits */
650 0, /* IntensityBits */
655 texstore_rgba_dxt5
, /* StoreTexImageFunc */
656 NULL
, /*impossible*/ /* FetchTexel1D */
657 fetch_texel_2d_rgba_dxt5
, /* FetchTexel2D */
658 NULL
, /*impossible*/ /* FetchTexel3D */
659 NULL
, /*impossible*/ /* FetchTexel1Df */
660 fetch_texel_2d_f_rgba_dxt5
, /* FetchTexel2Df */
661 NULL
, /*impossible*/ /* FetchTexel3Df */
662 NULL
/* StoreTexel */
665 #if FEATURE_EXT_texture_sRGB
666 const struct gl_texture_format _mesa_texformat_srgb_dxt1
= {
667 MESA_FORMAT_SRGB_DXT1
, /* MesaFormat */
668 GL_RGB
, /* BaseFormat */
669 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
670 4, /*approx*/ /* RedBits */
671 4, /*approx*/ /* GreenBits */
672 4, /*approx*/ /* BlueBits */
674 0, /* LuminanceBits */
675 0, /* IntensityBits */
680 texstore_rgb_dxt1
, /* StoreTexImageFunc */
681 NULL
, /*impossible*/ /* FetchTexel1D */
682 NULL
, /* FetchTexel2D */
683 NULL
, /*impossible*/ /* FetchTexel3D */
684 NULL
, /*impossible*/ /* FetchTexel1Df */
685 fetch_texel_2d_f_srgb_dxt1
, /* FetchTexel2Df */
686 NULL
, /*impossible*/ /* FetchTexel3Df */
687 NULL
/* StoreTexel */
690 const struct gl_texture_format _mesa_texformat_srgba_dxt1
= {
691 MESA_FORMAT_SRGBA_DXT1
, /* MesaFormat */
692 GL_RGBA
, /* BaseFormat */
693 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
694 4, /*approx*/ /* RedBits */
695 4, /*approx*/ /* GreenBits */
696 4, /*approx*/ /* BlueBits */
697 1, /*approx*/ /* AlphaBits */
698 0, /* LuminanceBits */
699 0, /* IntensityBits */
704 texstore_rgba_dxt1
, /* StoreTexImageFunc */
705 NULL
, /*impossible*/ /* FetchTexel1D */
706 NULL
, /* FetchTexel2D */
707 NULL
, /*impossible*/ /* FetchTexel3D */
708 NULL
, /*impossible*/ /* FetchTexel1Df */
709 fetch_texel_2d_f_srgba_dxt1
, /* FetchTexel2Df */
710 NULL
, /*impossible*/ /* FetchTexel3Df */
711 NULL
/* StoreTexel */
714 const struct gl_texture_format _mesa_texformat_srgba_dxt3
= {
715 MESA_FORMAT_SRGBA_DXT3
, /* MesaFormat */
716 GL_RGBA
, /* BaseFormat */
717 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
718 4, /*approx*/ /* RedBits */
719 4, /*approx*/ /* GreenBits */
720 4, /*approx*/ /* BlueBits */
721 4, /*approx*/ /* AlphaBits */
722 0, /* LuminanceBits */
723 0, /* IntensityBits */
728 texstore_rgba_dxt3
, /* StoreTexImageFunc */
729 NULL
, /*impossible*/ /* FetchTexel1D */
730 NULL
, /* FetchTexel2D */
731 NULL
, /*impossible*/ /* FetchTexel3D */
732 NULL
, /*impossible*/ /* FetchTexel1Df */
733 fetch_texel_2d_f_srgba_dxt3
, /* FetchTexel2Df */
734 NULL
, /*impossible*/ /* FetchTexel3Df */
735 NULL
/* StoreTexel */
738 const struct gl_texture_format _mesa_texformat_srgba_dxt5
= {
739 MESA_FORMAT_SRGBA_DXT5
, /* MesaFormat */
740 GL_RGBA
, /* BaseFormat */
741 GL_UNSIGNED_NORMALIZED_ARB
, /* DataType */
742 4,/*approx*/ /* RedBits */
743 4,/*approx*/ /* GreenBits */
744 4,/*approx*/ /* BlueBits */
745 4,/*approx*/ /* AlphaBits */
746 0, /* LuminanceBits */
747 0, /* IntensityBits */
752 texstore_rgba_dxt5
, /* StoreTexImageFunc */
753 NULL
, /*impossible*/ /* FetchTexel1D */
754 NULL
, /* FetchTexel2D */
755 NULL
, /*impossible*/ /* FetchTexel3D */
756 NULL
, /*impossible*/ /* FetchTexel1Df */
757 fetch_texel_2d_f_srgba_dxt5
, /* FetchTexel2Df */
758 NULL
, /*impossible*/ /* FetchTexel3Df */
759 NULL
/* StoreTexel */