f4d77f373fd7933ea1f1c25dd5bd4a5c713b8c66
[mesa.git] / src / mesa / main / texcompress_s3tc.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.1
4 *
5 * Copyright (C) 1999-2004 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 texcompress_s3tc.c
28 * GL_EXT_texture_compression_s3tc support.
29 */
30
31 #ifndef USE_EXTERNAL_DXTN_LIB
32 #define USE_EXTERNAL_DXTN_LIB 0
33 #endif
34
35 #include "glheader.h"
36 #include "imports.h"
37 #include "colormac.h"
38 #include "context.h"
39 #include "convolve.h"
40 #include "image.h"
41 #include "texcompress.h"
42 #include "texformat.h"
43 #include "texstore.h"
44
45 #if USE_EXTERNAL_DXTN_LIB
46 #ifdef __MINGW32__
47 /* no dlopen */
48 #define DXTN_EXT "dxtn.dll"
49 #define DXTN_PREFIX ""
50 #define dlopen(name, mode) LoadLibrary(name)
51 #define dlsym(hndl, proc) GetProcAddress(hndl, proc)
52 #define dlclose(hndl) FreeLibrary(hndl)
53 #elif defined(__DJGPP__)
54 /* has dlopen, but doesn't like the names */
55 #include <dlfcn.h>
56 #define DXTN_EXT "dxtn.dxe"
57 #define DXTN_PREFIX "_"
58 #else
59 /* happiness */
60 #include <dlfcn.h>
61 #define DXTN_EXT "libtxc_dxtn.so"
62 #define DXTN_PREFIX ""
63 #endif
64 #endif /* USE_EXTERNAL_DXTN_LIB */
65
66 typedef void (*dxtFetchTexelFuncExt)( GLint srcRowstride, GLubyte *pixdata, GLint col, GLint row, GLvoid *texelOut );
67 dxtFetchTexelFuncExt fetch_ext_rgb_dxt1 = NULL;
68 dxtFetchTexelFuncExt fetch_ext_rgba_dxt1 = NULL;
69 dxtFetchTexelFuncExt fetch_ext_rgba_dxt3 = NULL;
70 dxtFetchTexelFuncExt fetch_ext_rgba_dxt5 = NULL;
71
72 typedef void (*dxtCompressTexFuncExt)(GLint srccomps, GLint width,
73 GLint height, const GLchan *srcPixData,
74 GLenum destformat, GLubyte *dest,
75 GLint dstRowStride);
76 static dxtCompressTexFuncExt ext_tx_compress_dxtn = NULL;
77
78 static void *dxtlibhandle = NULL;
79
80
81 void
82 _mesa_init_texture_s3tc( GLcontext *ctx )
83 {
84 /* called during context initialization */
85 ctx->Mesa_DXTn = GL_FALSE;
86 #if USE_EXTERNAL_DXTN_LIB
87 if (!dxtlibhandle) {
88 dxtlibhandle = dlopen (DXTN_EXT, RTLD_LAZY | RTLD_GLOBAL);
89 if (!dxtlibhandle) {
90 _mesa_warning(ctx, "couldn't open " DXTN_EXT ", software DXTn "
91 "compression/decompression unavailable\n");
92 }
93 else {
94 /* the fetch functions are not per context! Might be problematic... */
95 fetch_ext_rgb_dxt1 = (dxtFetchTexelFuncExt)dlsym(dxtlibhandle, DXTN_PREFIX "fetch_2d_texel_rgb_dxt1");
96 if (fetch_ext_rgb_dxt1 != NULL) {
97 fetch_ext_rgba_dxt1 = (dxtFetchTexelFuncExt)dlsym(dxtlibhandle, DXTN_PREFIX "fetch_2d_texel_rgba_dxt1");
98 }
99 if (fetch_ext_rgba_dxt1 != NULL) {
100 fetch_ext_rgba_dxt3 = (dxtFetchTexelFuncExt)dlsym(dxtlibhandle, DXTN_PREFIX "fetch_2d_texel_rgba_dxt3");
101 }
102 if (fetch_ext_rgba_dxt3 != NULL) {
103 fetch_ext_rgba_dxt5 = (dxtFetchTexelFuncExt)dlsym(dxtlibhandle, DXTN_PREFIX "fetch_2d_texel_rgba_dxt5");
104 }
105 if (fetch_ext_rgba_dxt5 != NULL) {
106 ext_tx_compress_dxtn = (dxtCompressTexFuncExt)dlsym(dxtlibhandle, DXTN_PREFIX "tx_compress_dxtn");
107 }
108
109 if (ext_tx_compress_dxtn == NULL) {
110 _mesa_warning(ctx, "couldn't reference all symbols in "
111 DXTN_EXT ", software DXTn compression/decompression "
112 "unavailable\n");
113 fetch_ext_rgb_dxt1 = NULL;
114 fetch_ext_rgba_dxt1 = NULL;
115 fetch_ext_rgba_dxt3 = NULL;
116 fetch_ext_rgba_dxt5 = NULL;
117 ext_tx_compress_dxtn = NULL;
118 dlclose(dxtlibhandle);
119 dxtlibhandle = NULL;
120 }
121 }
122 }
123 if (dxtlibhandle) {
124 ctx->Mesa_DXTn = GL_TRUE;
125 _mesa_warning(ctx, "software DXTn compression/decompression available\n");
126 }
127 #else
128 (void) ctx;
129 #endif
130 }
131
132 /**
133 * Called via TexFormat->StoreImage to store an RGB_DXT1 texture.
134 */
135 static GLboolean
136 texstore_rgb_dxt1(STORE_PARAMS)
137 {
138 const GLchan *pixels;
139 GLint srcRowStride;
140 GLubyte *dst;
141 const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
142 const GLchan *tempImage = NULL;
143
144 ASSERT(dstFormat == &_mesa_texformat_rgb_dxt1);
145 ASSERT(dstXoffset % 4 == 0);
146 ASSERT(dstYoffset % 4 == 0);
147 ASSERT(dstZoffset % 4 == 0);
148 (void) dstZoffset; (void) dstImageStride;
149
150 if (srcFormat != GL_RGB ||
151 srcType != CHAN_TYPE ||
152 ctx->_ImageTransferState ||
153 srcPacking->SwapBytes) {
154 /* convert image to RGB/GLchan */
155 tempImage = _mesa_make_temp_chan_image(ctx, dims,
156 baseInternalFormat,
157 dstFormat->BaseFormat,
158 srcWidth, srcHeight, srcDepth,
159 srcFormat, srcType, srcAddr,
160 srcPacking);
161 if (!tempImage)
162 return GL_FALSE; /* out of memory */
163 _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
164 pixels = tempImage;
165 srcRowStride = 3 * srcWidth;
166 srcFormat = GL_RGB;
167 }
168 else {
169 pixels = (const GLchan *) srcAddr;
170 srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
171 srcType) / sizeof(GLchan);
172 }
173
174 dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
175 GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
176 texWidth, (GLubyte *) dstAddr);
177
178 if (ext_tx_compress_dxtn) {
179 (*ext_tx_compress_dxtn)(3, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGB_S3TC_DXT1_EXT, dst, dstRowStride);
180 }
181 else {
182 _mesa_problem(ctx, "external dxt library not available");
183 }
184
185 if (tempImage)
186 _mesa_free((void *) tempImage);
187
188 return GL_TRUE;
189 }
190
191
192 /**
193 * Called via TexFormat->StoreImage to store an RGBA_DXT1 texture.
194 */
195 static GLboolean
196 texstore_rgba_dxt1(STORE_PARAMS)
197 {
198 const GLchan *pixels;
199 GLint srcRowStride;
200 GLubyte *dst;
201 const GLint texWidth = dstRowStride * 4 / 8; /* a bit of a hack */
202 const GLchan *tempImage = NULL;
203
204 ASSERT(dstFormat == &_mesa_texformat_rgba_dxt1);
205 ASSERT(dstXoffset % 4 == 0);
206 ASSERT(dstYoffset % 4 == 0);
207 ASSERT(dstZoffset % 4 == 0);
208 (void) dstZoffset; (void) dstImageStride;
209
210 if (srcFormat != GL_RGBA ||
211 srcType != CHAN_TYPE ||
212 ctx->_ImageTransferState ||
213 srcPacking->SwapBytes) {
214 /* convert image to RGBA/GLchan */
215 tempImage = _mesa_make_temp_chan_image(ctx, dims,
216 baseInternalFormat,
217 dstFormat->BaseFormat,
218 srcWidth, srcHeight, srcDepth,
219 srcFormat, srcType, srcAddr,
220 srcPacking);
221 if (!tempImage)
222 return GL_FALSE; /* out of memory */
223 _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
224 pixels = tempImage;
225 srcRowStride = 4 * srcWidth;
226 srcFormat = GL_RGBA;
227 }
228 else {
229 pixels = (const GLchan *) srcAddr;
230 srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
231 srcType) / sizeof(GLchan);
232 }
233
234 dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
235 GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
236 texWidth, (GLubyte *) dstAddr);
237 if (ext_tx_compress_dxtn) {
238 (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, dst, dstRowStride);
239 }
240 else {
241 _mesa_problem(ctx, "external dxt library not available");
242 }
243
244 if (tempImage)
245 _mesa_free((void*) tempImage);
246
247 return GL_TRUE;
248 }
249
250
251 /**
252 * Called via TexFormat->StoreImage to store an RGBA_DXT3 texture.
253 */
254 static GLboolean
255 texstore_rgba_dxt3(STORE_PARAMS)
256 {
257 const GLchan *pixels;
258 GLint srcRowStride;
259 GLubyte *dst;
260 const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
261 const GLchan *tempImage = NULL;
262
263 ASSERT(dstFormat == &_mesa_texformat_rgba_dxt3);
264 ASSERT(dstXoffset % 4 == 0);
265 ASSERT(dstYoffset % 4 == 0);
266 ASSERT(dstZoffset % 4 == 0);
267 (void) dstZoffset; (void) dstImageStride;
268
269 if (srcFormat != GL_RGBA ||
270 srcType != CHAN_TYPE ||
271 ctx->_ImageTransferState ||
272 srcPacking->SwapBytes) {
273 /* convert image to RGBA/GLchan */
274 tempImage = _mesa_make_temp_chan_image(ctx, dims,
275 baseInternalFormat,
276 dstFormat->BaseFormat,
277 srcWidth, srcHeight, srcDepth,
278 srcFormat, srcType, srcAddr,
279 srcPacking);
280 if (!tempImage)
281 return GL_FALSE; /* out of memory */
282 _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
283 pixels = tempImage;
284 srcRowStride = 4 * srcWidth;
285 }
286 else {
287 pixels = (const GLchan *) srcAddr;
288 srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
289 srcType) / sizeof(GLchan);
290 }
291
292 dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
293 GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
294 texWidth, (GLubyte *) dstAddr);
295 if (ext_tx_compress_dxtn) {
296 (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, dst, dstRowStride);
297 }
298 else {
299 _mesa_problem(ctx, "external dxt library not available");
300 }
301
302 if (tempImage)
303 _mesa_free((void *) tempImage);
304
305 return GL_TRUE;
306 }
307
308
309 /**
310 * Called via TexFormat->StoreImage to store an RGBA_DXT5 texture.
311 */
312 static GLboolean
313 texstore_rgba_dxt5(STORE_PARAMS)
314 {
315 const GLchan *pixels;
316 GLint srcRowStride;
317 GLubyte *dst;
318 const GLint texWidth = dstRowStride * 4 / 16; /* a bit of a hack */
319 const GLchan *tempImage = NULL;
320
321 ASSERT(dstFormat == &_mesa_texformat_rgba_dxt5);
322 ASSERT(dstXoffset % 4 == 0);
323 ASSERT(dstYoffset % 4 == 0);
324 ASSERT(dstZoffset % 4 == 0);
325 (void) dstZoffset; (void) dstImageStride;
326
327 if (srcFormat != GL_RGBA ||
328 srcType != CHAN_TYPE ||
329 ctx->_ImageTransferState ||
330 srcPacking->SwapBytes) {
331 /* convert image to RGBA/GLchan */
332 tempImage = _mesa_make_temp_chan_image(ctx, dims,
333 baseInternalFormat,
334 dstFormat->BaseFormat,
335 srcWidth, srcHeight, srcDepth,
336 srcFormat, srcType, srcAddr,
337 srcPacking);
338 if (!tempImage)
339 return GL_FALSE; /* out of memory */
340 _mesa_adjust_image_for_convolution(ctx, dims, &srcWidth, &srcHeight);
341 pixels = tempImage;
342 srcRowStride = 4 * srcWidth;
343 }
344 else {
345 pixels = (const GLchan *) srcAddr;
346 srcRowStride = _mesa_image_row_stride(srcPacking, srcWidth, srcFormat,
347 srcType) / sizeof(GLchan);
348 }
349
350 dst = _mesa_compressed_image_address(dstXoffset, dstYoffset, 0,
351 GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
352 texWidth, (GLubyte *) dstAddr);
353 if (ext_tx_compress_dxtn) {
354 (*ext_tx_compress_dxtn)(4, srcWidth, srcHeight, pixels, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, dst, dstRowStride);
355 }
356 else {
357 _mesa_problem(ctx, "external dxt library not available");
358 }
359
360 if (tempImage)
361 _mesa_free((void *) tempImage);
362
363 return GL_TRUE;
364 }
365
366
367 static void
368 fetch_texel_2d_rgb_dxt1( const struct gl_texture_image *texImage,
369 GLint i, GLint j, GLint k, GLchan *texel )
370 {
371 (void) k;
372 if (fetch_ext_rgb_dxt1) {
373 ASSERT (sizeof(GLchan) == sizeof(GLubyte));
374 (*fetch_ext_rgb_dxt1)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel);
375 }
376 else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
377 }
378
379
380 static void
381 fetch_texel_2d_f_rgb_dxt1( const struct gl_texture_image *texImage,
382 GLint i, GLint j, GLint k, GLfloat *texel )
383 {
384 /* just sample as GLchan and convert to float here */
385 GLchan rgba[4];
386 fetch_texel_2d_rgb_dxt1(texImage, i, j, k, rgba);
387 texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
388 texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
389 texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
390 texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
391 }
392
393
394 static void
395 fetch_texel_2d_rgba_dxt1( const struct gl_texture_image *texImage,
396 GLint i, GLint j, GLint k, GLchan *texel )
397 {
398 (void) k;
399 if (fetch_ext_rgba_dxt1) {
400 (*fetch_ext_rgba_dxt1)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel);
401 }
402 else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
403 }
404
405
406 static void
407 fetch_texel_2d_f_rgba_dxt1( const struct gl_texture_image *texImage,
408 GLint i, GLint j, GLint k, GLfloat *texel )
409 {
410 /* just sample as GLchan and convert to float here */
411 GLchan rgba[4];
412 fetch_texel_2d_rgba_dxt1(texImage, i, j, k, rgba);
413 texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
414 texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
415 texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
416 texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
417 }
418
419
420 static void
421 fetch_texel_2d_rgba_dxt3( const struct gl_texture_image *texImage,
422 GLint i, GLint j, GLint k, GLchan *texel )
423 {
424 (void) k;
425 if (fetch_ext_rgba_dxt3) {
426 ASSERT (sizeof(GLchan) == sizeof(GLubyte));
427 (*fetch_ext_rgba_dxt3)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel);
428 }
429 else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
430 }
431
432
433 static void
434 fetch_texel_2d_f_rgba_dxt3( const struct gl_texture_image *texImage,
435 GLint i, GLint j, GLint k, GLfloat *texel )
436 {
437 /* just sample as GLchan and convert to float here */
438 GLchan rgba[4];
439 fetch_texel_2d_rgba_dxt3(texImage, i, j, k, rgba);
440 texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
441 texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
442 texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
443 texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
444 }
445
446
447 static void
448 fetch_texel_2d_rgba_dxt5( const struct gl_texture_image *texImage,
449 GLint i, GLint j, GLint k, GLchan *texel )
450 {
451 (void) k;
452 if (fetch_ext_rgba_dxt5) {
453 (*fetch_ext_rgba_dxt5)((texImage)->RowStride, (GLubyte *)(texImage)->Data, i, j, texel);
454 }
455 else _mesa_debug(NULL, "attempted to decode s3tc texture without library available\n");
456 }
457
458
459 static void
460 fetch_texel_2d_f_rgba_dxt5( const struct gl_texture_image *texImage,
461 GLint i, GLint j, GLint k, GLfloat *texel )
462 {
463 /* just sample as GLchan and convert to float here */
464 GLchan rgba[4];
465 fetch_texel_2d_rgba_dxt5(texImage, i, j, k, rgba);
466 texel[RCOMP] = CHAN_TO_FLOAT(rgba[RCOMP]);
467 texel[GCOMP] = CHAN_TO_FLOAT(rgba[GCOMP]);
468 texel[BCOMP] = CHAN_TO_FLOAT(rgba[BCOMP]);
469 texel[ACOMP] = CHAN_TO_FLOAT(rgba[ACOMP]);
470 }
471
472
473 const struct gl_texture_format _mesa_texformat_rgb_dxt1 = {
474 MESA_FORMAT_RGB_DXT1, /* MesaFormat */
475 GL_RGB, /* BaseFormat */
476 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
477 4, /*approx*/ /* RedBits */
478 4, /*approx*/ /* GreenBits */
479 4, /*approx*/ /* BlueBits */
480 0, /* AlphaBits */
481 0, /* LuminanceBits */
482 0, /* IntensityBits */
483 0, /* IndexBits */
484 0, /* DepthBits */
485 0, /* TexelBytes */
486 texstore_rgb_dxt1, /* StoreTexImageFunc */
487 NULL, /*impossible*/ /* FetchTexel1D */
488 fetch_texel_2d_rgb_dxt1, /* FetchTexel2D */
489 NULL, /*impossible*/ /* FetchTexel3D */
490 NULL, /*impossible*/ /* FetchTexel1Df */
491 fetch_texel_2d_f_rgb_dxt1, /* FetchTexel2Df */
492 NULL, /*impossible*/ /* FetchTexel3Df */
493 };
494
495 const struct gl_texture_format _mesa_texformat_rgba_dxt1 = {
496 MESA_FORMAT_RGBA_DXT1, /* MesaFormat */
497 GL_RGBA, /* BaseFormat */
498 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
499 4, /*approx*/ /* RedBits */
500 4, /*approx*/ /* GreenBits */
501 4, /*approx*/ /* BlueBits */
502 1, /*approx*/ /* AlphaBits */
503 0, /* LuminanceBits */
504 0, /* IntensityBits */
505 0, /* IndexBits */
506 0, /* DepthBits */
507 0, /* TexelBytes */
508 texstore_rgba_dxt1, /* StoreTexImageFunc */
509 NULL, /*impossible*/ /* FetchTexel1D */
510 fetch_texel_2d_rgba_dxt1, /* FetchTexel2D */
511 NULL, /*impossible*/ /* FetchTexel3D */
512 NULL, /*impossible*/ /* FetchTexel1Df */
513 fetch_texel_2d_f_rgba_dxt1, /* FetchTexel2Df */
514 NULL, /*impossible*/ /* FetchTexel3Df */
515 };
516
517 const struct gl_texture_format _mesa_texformat_rgba_dxt3 = {
518 MESA_FORMAT_RGBA_DXT3, /* MesaFormat */
519 GL_RGBA, /* BaseFormat */
520 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
521 4, /*approx*/ /* RedBits */
522 4, /*approx*/ /* GreenBits */
523 4, /*approx*/ /* BlueBits */
524 4, /*approx*/ /* AlphaBits */
525 0, /* LuminanceBits */
526 0, /* IntensityBits */
527 0, /* IndexBits */
528 0, /* DepthBits */
529 0, /* TexelBytes */
530 texstore_rgba_dxt3, /* StoreTexImageFunc */
531 NULL, /*impossible*/ /* FetchTexel1D */
532 fetch_texel_2d_rgba_dxt3, /* FetchTexel2D */
533 NULL, /*impossible*/ /* FetchTexel3D */
534 NULL, /*impossible*/ /* FetchTexel1Df */
535 fetch_texel_2d_f_rgba_dxt3, /* FetchTexel2Df */
536 NULL, /*impossible*/ /* FetchTexel3Df */
537 };
538
539 const struct gl_texture_format _mesa_texformat_rgba_dxt5 = {
540 MESA_FORMAT_RGBA_DXT5, /* MesaFormat */
541 GL_RGBA, /* BaseFormat */
542 GL_UNSIGNED_NORMALIZED_ARB, /* DataType */
543 4,/*approx*/ /* RedBits */
544 4,/*approx*/ /* GreenBits */
545 4,/*approx*/ /* BlueBits */
546 4,/*approx*/ /* AlphaBits */
547 0, /* LuminanceBits */
548 0, /* IntensityBits */
549 0, /* IndexBits */
550 0, /* DepthBits */
551 0, /* TexelBytes */
552 texstore_rgba_dxt5, /* StoreTexImageFunc */
553 NULL, /*impossible*/ /* FetchTexel1D */
554 fetch_texel_2d_rgba_dxt5, /* FetchTexel2D */
555 NULL, /*impossible*/ /* FetchTexel3D */
556 NULL, /*impossible*/ /* FetchTexel1Df */
557 fetch_texel_2d_f_rgba_dxt5, /* FetchTexel2Df */
558 NULL, /*impossible*/ /* FetchTexel3Df */
559 };