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"
58 #if FEATURE_texture_s3tc
61 #if FEATURE_EXT_texture_sRGB
63 * Convert an 8-bit sRGB value from non-linear space to a
64 * linear RGB value in [0, 1].
65 * Implemented with a 256-entry lookup table.
68 nonlinear_to_linear(GLubyte cs8)
70 static GLfloat table[256];
71 static GLboolean tableReady = GL_FALSE;
73 /* compute lookup table now */
75 for (i = 0; i < 256; i++) {
76 const GLfloat cs = UBYTE_TO_FLOAT(i);
78 table[i] = cs / 12.92f;
81 table[i] = (GLfloat) _mesa_pow((cs + 0.055) / 1.055, 2.4);
88 #endif /* FEATURE_EXT_texture_sRGB */
90 typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut );
92 dxtFetchTexelFuncExt fetch_ext_rgb_dxt1 = NULL;
93 dxtFetchTexelFuncExt fetch_ext_rgba_dxt1 = NULL;
94 dxtFetchTexelFuncExt fetch_ext_rgba_dxt3 = NULL;
95 dxtFetchTexelFuncExt fetch_ext_rgba_dxt5 = NULL;
97 typedef void (*dxtCompressTexFuncExt)(GLint srccomps, GLint width,
98 GLint height, const GLchan *srcPixData,
99 GLenum destformat, GLubyte *dest,
102 static dxtCompressTexFuncExt ext_tx_compress_dxtn = NULL;
104 static void *dxtlibhandle = NULL;
108 _mesa_init_texture_s3tc( GLcontext *ctx )
110 /* called during context initialization */
111 ctx->Mesa_DXTn = GL_FALSE;
112 #if USE_EXTERNAL_DXTN_LIB
114 dxtlibhandle = _mesa_dlopen(DXTN_LIBNAME, 0);
116 _mesa_warning(ctx, "couldn't open " DXTN_LIBNAME ", software DXTn "
117 "compression/decompression unavailable");
120 /* the fetch functions are not per context! Might be problematic... */
121 fetch_ext_rgb_dxt1 = (dxtFetchTexelFuncExt)
122 _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgb_dxt1");
123 fetch_ext_rgba_dxt1 = (dxtFetchTexelFuncExt)
124 _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt1");
125 fetch_ext_rgba_dxt3 = (dxtFetchTexelFuncExt)
126 _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt3");
127 fetch_ext_rgba_dxt5 = (dxtFetchTexelFuncExt)
128 _mesa_dlsym(dxtlibhandle, "fetch_2d_texel_rgba_dxt5");
129 ext_tx_compress_dxtn = (dxtCompressTexFuncExt)
130 _mesa_dlsym(dxtlibhandle, "tx_compress_dxtn");
132 if (!fetch_ext_rgb_dxt1 ||
133 !fetch_ext_rgba_dxt1 ||
134 !fetch_ext_rgba_dxt3 ||
135 !fetch_ext_rgba_dxt5 ||
136 !ext_tx_compress_dxtn) {
137 _mesa_warning(ctx, "couldn't reference all symbols in "
138 DXTN_LIBNAME ", software DXTn compression/decompression "
140 fetch_ext_rgb_dxt1 = NULL;
141 fetch_ext_rgba_dxt1 = NULL;
142 fetch_ext_rgba_dxt3 = NULL;
143 fetch_ext_rgba_dxt5 = NULL;
144 ext_tx_compress_dxtn = NULL;
145 _mesa_dlclose(dxtlibhandle);
151 ctx->Mesa_DXTn = GL_TRUE;
152 _mesa_warning(ctx, "software DXTn compression/decompression available");
160 * Called via TexFormat->StoreImage to store an RGB_DXT1 texture.
163 texstore_rgb_dxt1(TEXSTORE_PARAMS)
165 const GLchan *pixels;
168 const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
169 const GLchan *tempImage = NULL;
171 ASSERT(dstFormat == &_mesa_texformat_rgb_dxt1);
172 ASSERT(dstXoffset % 4 == 0);
173 ASSERT(dstYoffset % 4 == 0);
174 ASSERT(dstZoffset % 4 == 0);
176 (void) dstImageOffsets;
178 if (srcFormat != GL_RGB ||
179 srcType != CHAN_TYPE ||
180 ctx->_ImageTransferState ||
181 srcPacking->SwapBytes) {
182 /* convert image to RGB/GLchan */
183 tempImage = _mesa_make_temp_chan_image(ctx, dims,
185 dstFormat->BaseFormat,
186 srcWidth, srcHeight, srcDepth,
187 srcFormat, srcType, srcAddr,
190 return GL_FALSE; /* out of memory */
191 _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
193 srcRowStride = 3 * srcWidth;
197 pixels = (const GLchan *) srcAddr;
198 srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
199 srcType) / sizeof(GLchan);
202 dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
203 dstFormat->MesaFormat,
204 texWidth, (GLubyte *) dstAddr);
206 if (ext_tx_compress_dxtn) {
207 (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels,
208 GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
212 _mesa_warning(ctx, "external dxt library not available: texstore_rgb_dxt1");
216 _mesa_free((void *) tempImage);
223 * Called via TexFormat->StoreImage to store an RGBA_DXT1 texture.
226 texstore_rgba_dxt1(TEXSTORE_PARAMS)
228 const GLchan *pixels;
231 const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
232 const GLchan *tempImage = NULL;
234 ASSERT(dstFormat == &_mesa_texformat_rgba_dxt1);
235 ASSERT(dstXoffset % 4 == 0);
236 ASSERT(dstYoffset % 4 == 0);
237 ASSERT(dstZoffset % 4 == 0);
239 (void) dstImageOffsets;
241 if (srcFormat != GL_RGBA ||
242 srcType != CHAN_TYPE ||
243 ctx->_ImageTransferState ||
244 srcPacking->SwapBytes) {
245 /* convert image to RGBA/GLchan */
246 tempImage = _mesa_make_temp_chan_image(ctx, dims,
248 dstFormat->BaseFormat,
249 srcWidth, srcHeight, srcDepth,
250 srcFormat, srcType, srcAddr,
253 return GL_FALSE; /* out of memory */
254 _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
256 srcRowStride = 4 * srcWidth;
260 pixels = (const GLchan *) srcAddr;
261 srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
262 srcType) / sizeof(GLchan);
265 dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
266 dstFormat->MesaFormat,
267 texWidth, (GLubyte *) dstAddr);
268 if (ext_tx_compress_dxtn) {
269 (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
270 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
274 _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt1");
278 _mesa_free((void*) tempImage);
285 * Called via TexFormat->StoreImage to store an RGBA_DXT3 texture.
288 texstore_rgba_dxt3(TEXSTORE_PARAMS)
290 const GLchan *pixels;
293 const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
294 const GLchan *tempImage = NULL;
296 ASSERT(dstFormat == &_mesa_texformat_rgba_dxt3);
297 ASSERT(dstXoffset % 4 == 0);
298 ASSERT(dstYoffset % 4 == 0);
299 ASSERT(dstZoffset % 4 == 0);
301 (void) dstImageOffsets;
303 if (srcFormat != GL_RGBA ||
304 srcType != CHAN_TYPE ||
305 ctx->_ImageTransferState ||
306 srcPacking->SwapBytes) {
307 /* convert image to RGBA/GLchan */
308 tempImage = _mesa_make_temp_chan_image(ctx, dims,
310 dstFormat->BaseFormat,
311 srcWidth, srcHeight, srcDepth,
312 srcFormat, srcType, srcAddr,
315 return GL_FALSE; /* out of memory */
316 _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
318 srcRowStride = 4 * srcWidth;
321 pixels = (const GLchan *) srcAddr;
322 srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
323 srcType) / sizeof(GLchan);
326 dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
327 dstFormat->MesaFormat,
328 texWidth, (GLubyte *) dstAddr);
329 if (ext_tx_compress_dxtn) {
330 (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
331 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
335 _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt3");
339 _mesa_free((void *) tempImage);
346 * Called via TexFormat->StoreImage to store an RGBA_DXT5 texture.
349 texstore_rgba_dxt5(TEXSTORE_PARAMS)
351 const GLchan *pixels;
354 const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
355 const GLchan *tempImage = NULL;
357 ASSERT(dstFormat == &_mesa_texformat_rgba_dxt5);
358 ASSERT(dstXoffset % 4 == 0);
359 ASSERT(dstYoffset % 4 == 0);
360 ASSERT(dstZoffset % 4 == 0);
362 (void) dstImageOffsets;
364 if (srcFormat != GL_RGBA ||
365 srcType != CHAN_TYPE ||
366 ctx->_ImageTransferState ||
367 srcPacking->SwapBytes) {
368 /* convert image to RGBA/GLchan */
369 tempImage = _mesa_make_temp_chan_image(ctx, dims,
371 dstFormat->BaseFormat,
372 srcWidth, srcHeight, srcDepth,
373 srcFormat, srcType, srcAddr,
376 return GL_FALSE; /* out of memory */
377 _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
379 srcRowStride = 4 * srcWidth;
382 pixels = (const GLchan *) srcAddr;
383 srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
384 srcType) / sizeof(GLchan);
387 dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
388 dstFormat->MesaFormat,
389 texWidth, (GLubyte *) dstAddr);
390 if (ext_tx_compress_dxtn) {
391 (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels,
392 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
396 _mesa_warning(ctx, "external dxt library not available: texstore_rgba_dxt5");
400 _mesa_free((void *) tempImage);
407 fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage,
408 GLint i, GLint j, GLint k, GLchan *texel )
411 if (fetch_ext_rgb_dxt1) {
412 ASSERT (sizeof(GLchan) == sizeof(GLubyte));
413 fetch_ext_rgb_dxt1(texImage->RowStride,
414 (GLubyte *)(texImage)->Data, i, j, texel);
417 _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgb_dxt1");
422 fetch_texel_2d_f_rgb_dxt1( const struct gl_texture_image *texImage,
423 GLint i, GLint j, GLint k, GLfloat *texel )
425 /* just sample as GLchan and convert to float here */
427 fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba);
428 texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
429 texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
430 texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
431 texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
436 fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage,
437 GLint i, GLint j, GLint k, GLchan *texel )
440 if (fetch_ext_rgba_dxt1) {
441 fetch_ext_rgba_dxt1(texImage->RowStride,
442 (GLubyte *)(texImage)->Data, i, j, texel);
445 _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt1\n");
450 fetch_texel_2d_f_rgba_dxt1( const struct gl_texture_image *texImage,
451 GLint i, GLint j, GLint k, GLfloat *texel )
453 /* just sample as GLchan and convert to float here */
455 fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba);
456 texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
457 texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
458 texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
459 texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
464 fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage,
465 GLint i, GLint j, GLint k, GLchan *texel )
468 if (fetch_ext_rgba_dxt3) {
469 ASSERT (sizeof(GLchan) == sizeof(GLubyte));
470 fetch_ext_rgba_dxt3(texImage->RowStride, (GLubyte *)(texImage)->Data,
474 _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt3\n");
479 fetch_texel_2d_f_rgba_dxt3( const struct gl_texture_image *texImage,
480 GLint i, GLint j, GLint k, GLfloat *texel )
482 /* just sample as GLchan and convert to float here */
484 fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba);
485 texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
486 texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
487 texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
488 texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
493 fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage,
494 GLint i, GLint j, GLint k, GLchan *texel )
497 if (fetch_ext_rgba_dxt5) {
498 fetch_ext_rgba_dxt5(texImage->RowStride, (GLubyte *)(texImage)->Data,
502 _mesa_debug(NULL, "attempted to decode s3tc texture without library available: fetch_texel_2d_rgba_dxt5\n");
507 fetch_texel_2d_f_rgba_dxt5( const struct gl_texture_image *texImage,
508 GLint i, GLint j, GLint k, GLfloat *texel )
510 /* just sample as GLchan and convert to float here */
512 fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba);
513 texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
514 texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
515 texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
516 texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
519 #if FEATURE_EXT_texture_sRGB
521 fetch_texel_2d_f_srgb_dxt1( const struct gl_texture_image *texImage,
522 GLint i, GLint j, GLint k, GLfloat *texel )
524 /* just sample as GLchan and convert to float here */
526 fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba);
527 texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
528 texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
529 texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
530 texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
534 fetch_texel_2d_f_srgba_dxt1( const struct gl_texture_image *texImage,
535 GLint i, GLint j, GLint k, GLfloat *texel )
537 /* just sample as GLchan and convert to float here */
539 fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba);
540 texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
541 texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
542 texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
543 texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
547 fetch_texel_2d_f_srgba_dxt3( const struct gl_texture_image *texImage,
548 GLint i, GLint j, GLint k, GLfloat *texel )
550 /* just sample as GLchan and convert to float here */
552 fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba);
553 texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
554 texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
555 texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
556 texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
560 fetch_texel_2d_f_srgba_dxt5( const struct gl_texture_image *texImage,
561 GLint i, GLint j, GLint k, GLfloat *texel )
563 /* just sample as GLchan and convert to float here */
565 fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba);
566 texel[RCOMP] = nonlinear_to_linear(rgba[RCOMP]);
567 texel[GCOMP] = nonlinear_to_linear(rgba[GCOMP]);
568 texel[BCOMP] = nonlinear_to_linear(rgba[BCOMP]);
569 texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
571 #endif /* FEATURE_EXT_texture_sRGB */
574 #else /* FEATURE_texture_s3tc */
578 _mesa_init_texture_s3tc( GLcontext *ctx )
584 #endif /* FEATURE_texture_s3tc */
587 const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
588 MESA_FORMAT_RGB_DXT1, /* MesaFormat */
589 GL_RGB, /* BaseFormat */
590 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
591 4, /*approx*/ /* RedBits */
592 4, /*approx*/ /* GreenBits */
593 4, /*approx*/ /* BlueBits */
595 0, /* LuminanceBits */
596 0, /* IntensityBits */
601 #if FEATURE_texture_s3tc
602 texstore_rgb_dxt1, /* StoreTexImageFunc */
603 NULL, /*impossible*/ /* FetchTexel1D */
604 fetch_texel_2d_rgb_dxt1, /* FetchTexel2D */
605 NULL, /*impossible*/ /* FetchTexel3D */
606 NULL, /*impossible*/ /* FetchTexel1Df */
607 fetch_texel_2d_f_rgb_dxt1, /* FetchTexel2Df */
608 NULL, /*impossible*/ /* FetchTexel3Df */
609 NULL /* StoreTexel */
612 _MESA_TEXFORMAT_NULL_OPS
616 const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
617 MESA_FORMAT_RGBA_DXT1, /* MesaFormat */
618 GL_RGBA, /* BaseFormat */
619 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
620 4, /*approx*/ /* RedBits */
621 4, /*approx*/ /* GreenBits */
622 4, /*approx*/ /* BlueBits */
623 1, /*approx*/ /* AlphaBits */
624 0, /* LuminanceBits */
625 0, /* IntensityBits */
630 #if FEATURE_texture_s3tc
631 texstore_rgba_dxt1, /* StoreTexImageFunc */
632 NULL, /*impossible*/ /* FetchTexel1D */
633 fetch_texel_2d_rgba_dxt1, /* FetchTexel2D */
634 NULL, /*impossible*/ /* FetchTexel3D */
635 NULL, /*impossible*/ /* FetchTexel1Df */
636 fetch_texel_2d_f_rgba_dxt1, /* FetchTexel2Df */
637 NULL, /*impossible*/ /* FetchTexel3Df */
638 NULL /* StoreTexel */
641 _MESA_TEXFORMAT_NULL_OPS
645 const struct gl_texture_format _mesa_texformat_rgba_dxt3 = {
646 MESA_FORMAT_RGBA_DXT3, /* MesaFormat */
647 GL_RGBA, /* BaseFormat */
648 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
649 4, /*approx*/ /* RedBits */
650 4, /*approx*/ /* GreenBits */
651 4, /*approx*/ /* BlueBits */
652 4, /*approx*/ /* AlphaBits */
653 0, /* LuminanceBits */
654 0, /* IntensityBits */
659 #if FEATURE_texture_s3tc
660 texstore_rgba_dxt3, /* StoreTexImageFunc */
661 NULL, /*impossible*/ /* FetchTexel1D */
662 fetch_texel_2d_rgba_dxt3, /* FetchTexel2D */
663 NULL, /*impossible*/ /* FetchTexel3D */
664 NULL, /*impossible*/ /* FetchTexel1Df */
665 fetch_texel_2d_f_rgba_dxt3, /* FetchTexel2Df */
666 NULL, /*impossible*/ /* FetchTexel3Df */
667 NULL /* StoreTexel */
670 _MESA_TEXFORMAT_NULL_OPS
674 const struct gl_texture_format _mesa_texformat_rgba_dxt5 = {
675 MESA_FORMAT_RGBA_DXT5, /* MesaFormat */
676 GL_RGBA, /* BaseFormat */
677 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
678 4,/*approx*/ /* RedBits */
679 4,/*approx*/ /* GreenBits */
680 4,/*approx*/ /* BlueBits */
681 4,/*approx*/ /* AlphaBits */
682 0, /* LuminanceBits */
683 0, /* IntensityBits */
688 #if FEATURE_texture_s3tc
689 texstore_rgba_dxt5, /* StoreTexImageFunc */
690 NULL, /*impossible*/ /* FetchTexel1D */
691 fetch_texel_2d_rgba_dxt5, /* FetchTexel2D */
692 NULL, /*impossible*/ /* FetchTexel3D */
693 NULL, /*impossible*/ /* FetchTexel1Df */
694 fetch_texel_2d_f_rgba_dxt5, /* FetchTexel2Df */
695 NULL, /*impossible*/ /* FetchTexel3Df */
696 NULL /* StoreTexel */
699 _MESA_TEXFORMAT_NULL_OPS
703 #if FEATURE_EXT_texture_sRGB
704 const struct gl_texture_format _mesa_texformat_srgb_dxt1 = {
705 MESA_FORMAT_SRGB_DXT1, /* MesaFormat */
706 GL_RGB, /* BaseFormat */
707 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
708 4, /*approx*/ /* RedBits */
709 4, /*approx*/ /* GreenBits */
710 4, /*approx*/ /* BlueBits */
712 0, /* LuminanceBits */
713 0, /* IntensityBits */
718 texstore_rgb_dxt1, /* StoreTexImageFunc */
719 NULL, /*impossible*/ /* FetchTexel1D */
720 NULL, /* FetchTexel2D */
721 NULL, /*impossible*/ /* FetchTexel3D */
722 NULL, /*impossible*/ /* FetchTexel1Df */
723 fetch_texel_2d_f_srgb_dxt1, /* FetchTexel2Df */
724 NULL, /*impossible*/ /* FetchTexel3Df */
725 NULL /* StoreTexel */
728 const struct gl_texture_format _mesa_texformat_srgba_dxt1 = {
729 MESA_FORMAT_SRGBA_DXT1, /* MesaFormat */
730 GL_RGBA, /* BaseFormat */
731 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
732 4, /*approx*/ /* RedBits */
733 4, /*approx*/ /* GreenBits */
734 4, /*approx*/ /* BlueBits */
735 1, /*approx*/ /* AlphaBits */
736 0, /* LuminanceBits */
737 0, /* IntensityBits */
742 texstore_rgba_dxt1, /* StoreTexImageFunc */
743 NULL, /*impossible*/ /* FetchTexel1D */
744 NULL, /* FetchTexel2D */
745 NULL, /*impossible*/ /* FetchTexel3D */
746 NULL, /*impossible*/ /* FetchTexel1Df */
747 fetch_texel_2d_f_srgba_dxt1, /* FetchTexel2Df */
748 NULL, /*impossible*/ /* FetchTexel3Df */
749 NULL /* StoreTexel */
752 const struct gl_texture_format _mesa_texformat_srgba_dxt3 = {
753 MESA_FORMAT_SRGBA_DXT3, /* MesaFormat */
754 GL_RGBA, /* BaseFormat */
755 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
756 4, /*approx*/ /* RedBits */
757 4, /*approx*/ /* GreenBits */
758 4, /*approx*/ /* BlueBits */
759 4, /*approx*/ /* AlphaBits */
760 0, /* LuminanceBits */
761 0, /* IntensityBits */
766 texstore_rgba_dxt3, /* StoreTexImageFunc */
767 NULL, /*impossible*/ /* FetchTexel1D */
768 NULL, /* FetchTexel2D */
769 NULL, /*impossible*/ /* FetchTexel3D */
770 NULL, /*impossible*/ /* FetchTexel1Df */
771 fetch_texel_2d_f_srgba_dxt3, /* FetchTexel2Df */
772 NULL, /*impossible*/ /* FetchTexel3Df */
773 NULL /* StoreTexel */
776 const struct gl_texture_format _mesa_texformat_srgba_dxt5 = {
777 MESA_FORMAT_SRGBA_DXT5, /* MesaFormat */
778 GL_RGBA, /* BaseFormat */
779 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
780 4,/*approx*/ /* RedBits */
781 4,/*approx*/ /* GreenBits */
782 4,/*approx*/ /* BlueBits */
783 4,/*approx*/ /* AlphaBits */
784 0, /* LuminanceBits */
785 0, /* IntensityBits */
790 texstore_rgba_dxt5, /* StoreTexImageFunc */
791 NULL, /*impossible*/ /* FetchTexel1D */
792 NULL, /* FetchTexel2D */
793 NULL, /*impossible*/ /* FetchTexel3D */
794 NULL, /*impossible*/ /* FetchTexel1Df */
795 fetch_texel_2d_f_srgba_dxt5, /* FetchTexel2Df */
796 NULL, /*impossible*/ /* FetchTexel3Df */
797 NULL /* StoreTexel */