17117f1b4Smrg/*
27117f1b4Smrg * Mesa 3-D graphics library
37117f1b4Smrg *
47117f1b4Smrg * Copyright (C) 1999-2007  Brian Paul   All Rights Reserved.
54a49301eSmrg * Copyright (c) 2008 VMware, Inc.
67117f1b4Smrg *
77117f1b4Smrg * Permission is hereby granted, free of charge, to any person obtaining a
87117f1b4Smrg * copy of this software and associated documentation files (the "Software"),
97117f1b4Smrg * to deal in the Software without restriction, including without limitation
107117f1b4Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense,
117117f1b4Smrg * and/or sell copies of the Software, and to permit persons to whom the
127117f1b4Smrg * Software is furnished to do so, subject to the following conditions:
137117f1b4Smrg *
147117f1b4Smrg * The above copyright notice and this permission notice shall be included
157117f1b4Smrg * in all copies or substantial portions of the Software.
167117f1b4Smrg *
177117f1b4Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
187117f1b4Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
197117f1b4Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
20af69d88dSmrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
21af69d88dSmrg * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
22af69d88dSmrg * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
23af69d88dSmrg * OTHER DEALINGS IN THE SOFTWARE.
247117f1b4Smrg */
257117f1b4Smrg
267117f1b4Smrg
277117f1b4Smrg/**
287117f1b4Smrg * \file texcompress_s3tc.c
297117f1b4Smrg * GL_EXT_texture_compression_s3tc support.
307117f1b4Smrg */
317117f1b4Smrg
327117f1b4Smrg#include "glheader.h"
337ec681f3Smrg
347117f1b4Smrg#include "image.h"
353464ebd5Sriastradh#include "macros.h"
363464ebd5Sriastradh#include "mtypes.h"
377117f1b4Smrg#include "texcompress.h"
384a49301eSmrg#include "texcompress_s3tc.h"
3901e04c3fSmrg#include "texcompress_s3tc_tmp.h"
407117f1b4Smrg#include "texstore.h"
41af69d88dSmrg#include "format_unpack.h"
42af69d88dSmrg#include "util/format_srgb.h"
434a49301eSmrg
444a49301eSmrg
457117f1b4Smrg/**
464a49301eSmrg * Store user's image in rgb_dxt1 format.
477117f1b4Smrg */
484a49301eSmrgGLboolean
494a49301eSmrg_mesa_texstore_rgb_dxt1(TEXSTORE_PARAMS)
507117f1b4Smrg{
51af69d88dSmrg   const GLubyte *pixels;
527117f1b4Smrg   GLubyte *dst;
53af69d88dSmrg   const GLubyte *tempImage = NULL;
547117f1b4Smrg
5501e04c3fSmrg   assert(dstFormat == MESA_FORMAT_RGB_DXT1 ||
563464ebd5Sriastradh          dstFormat == MESA_FORMAT_SRGB_DXT1);
577117f1b4Smrg
587117f1b4Smrg   if (srcFormat != GL_RGB ||
59af69d88dSmrg       srcType != GL_UNSIGNED_BYTE ||
607117f1b4Smrg       ctx->_ImageTransferState ||
6101e04c3fSmrg       ALIGN(srcPacking->RowLength, srcPacking->Alignment) != srcWidth ||
627117f1b4Smrg       srcPacking->SwapBytes) {
63af69d88dSmrg      /* convert image to RGB/GLubyte */
6401e04c3fSmrg      GLubyte *tempImageSlices[1];
6501e04c3fSmrg      int rgbRowStride = 3 * srcWidth * sizeof(GLubyte);
6601e04c3fSmrg      tempImage = malloc(srcWidth * srcHeight * 3 * sizeof(GLubyte));
677117f1b4Smrg      if (!tempImage)
687117f1b4Smrg         return GL_FALSE; /* out of memory */
6901e04c3fSmrg      tempImageSlices[0] = (GLubyte *) tempImage;
7001e04c3fSmrg      _mesa_texstore(ctx, dims,
7101e04c3fSmrg                     baseInternalFormat,
7201e04c3fSmrg                     MESA_FORMAT_RGB_UNORM8,
7301e04c3fSmrg                     rgbRowStride, tempImageSlices,
7401e04c3fSmrg                     srcWidth, srcHeight, srcDepth,
7501e04c3fSmrg                     srcFormat, srcType, srcAddr,
7601e04c3fSmrg                     srcPacking);
777117f1b4Smrg      pixels = tempImage;
787117f1b4Smrg      srcFormat = GL_RGB;
797117f1b4Smrg   }
807117f1b4Smrg   else {
81af69d88dSmrg      pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
82af69d88dSmrg                                     srcFormat, srcType, 0, 0);
837117f1b4Smrg   }
847117f1b4Smrg
85af69d88dSmrg   dst = dstSlices[0];
867117f1b4Smrg
8701e04c3fSmrg   tx_compress_dxtn(3, srcWidth, srcHeight, pixels,
8801e04c3fSmrg                    GL_COMPRESSED_RGB_S3TC_DXT1_EXT,
8901e04c3fSmrg                    dst, dstRowStride);
907117f1b4Smrg
91af69d88dSmrg   free((void *) tempImage);
927117f1b4Smrg
937117f1b4Smrg   return GL_TRUE;
947117f1b4Smrg}
957117f1b4Smrg
967117f1b4Smrg
977117f1b4Smrg/**
984a49301eSmrg * Store user's image in rgba_dxt1 format.
997117f1b4Smrg */
1004a49301eSmrgGLboolean
1014a49301eSmrg_mesa_texstore_rgba_dxt1(TEXSTORE_PARAMS)
1027117f1b4Smrg{
103af69d88dSmrg   const GLubyte *pixels;
1047117f1b4Smrg   GLubyte *dst;
105af69d88dSmrg   const GLubyte *tempImage = NULL;
1067117f1b4Smrg
10701e04c3fSmrg   assert(dstFormat == MESA_FORMAT_RGBA_DXT1 ||
1083464ebd5Sriastradh          dstFormat == MESA_FORMAT_SRGBA_DXT1);
1097117f1b4Smrg
1107117f1b4Smrg   if (srcFormat != GL_RGBA ||
111af69d88dSmrg       srcType != GL_UNSIGNED_BYTE ||
1127117f1b4Smrg       ctx->_ImageTransferState ||
11301e04c3fSmrg       ALIGN(srcPacking->RowLength, srcPacking->Alignment) != srcWidth ||
1147117f1b4Smrg       srcPacking->SwapBytes) {
115af69d88dSmrg      /* convert image to RGBA/GLubyte */
11601e04c3fSmrg      GLubyte *tempImageSlices[1];
11701e04c3fSmrg      int rgbaRowStride = 4 * srcWidth * sizeof(GLubyte);
11801e04c3fSmrg      tempImage = malloc(srcWidth * srcHeight * 4 * sizeof(GLubyte));
1197117f1b4Smrg      if (!tempImage)
1207117f1b4Smrg         return GL_FALSE; /* out of memory */
12101e04c3fSmrg      tempImageSlices[0] = (GLubyte *) tempImage;
12201e04c3fSmrg      _mesa_texstore(ctx, dims,
12301e04c3fSmrg                     baseInternalFormat,
1247ec681f3Smrg#if UTIL_ARCH_LITTLE_ENDIAN
1257ec681f3Smrg                     MESA_FORMAT_R8G8B8A8_UNORM,
1267ec681f3Smrg#else
1277ec681f3Smrg                     MESA_FORMAT_A8B8G8R8_UNORM,
1287ec681f3Smrg#endif
12901e04c3fSmrg                     rgbaRowStride, tempImageSlices,
13001e04c3fSmrg                     srcWidth, srcHeight, srcDepth,
13101e04c3fSmrg                     srcFormat, srcType, srcAddr,
13201e04c3fSmrg                     srcPacking);
1337117f1b4Smrg      pixels = tempImage;
1347117f1b4Smrg      srcFormat = GL_RGBA;
1357117f1b4Smrg   }
1367117f1b4Smrg   else {
137af69d88dSmrg      pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
138af69d88dSmrg                                     srcFormat, srcType, 0, 0);
1397117f1b4Smrg   }
1407117f1b4Smrg
141af69d88dSmrg   dst = dstSlices[0];
142af69d88dSmrg
14301e04c3fSmrg   tx_compress_dxtn(4, srcWidth, srcHeight, pixels,
14401e04c3fSmrg                    GL_COMPRESSED_RGBA_S3TC_DXT1_EXT,
14501e04c3fSmrg                    dst, dstRowStride);
1467117f1b4Smrg
147af69d88dSmrg   free((void*) tempImage);
1487117f1b4Smrg
1497117f1b4Smrg   return GL_TRUE;
1507117f1b4Smrg}
1517117f1b4Smrg
1527117f1b4Smrg
1537117f1b4Smrg/**
1544a49301eSmrg * Store user's image in rgba_dxt3 format.
1557117f1b4Smrg */
1564a49301eSmrgGLboolean
1574a49301eSmrg_mesa_texstore_rgba_dxt3(TEXSTORE_PARAMS)
1587117f1b4Smrg{
159af69d88dSmrg   const GLubyte *pixels;
1607117f1b4Smrg   GLubyte *dst;
161af69d88dSmrg   const GLubyte *tempImage = NULL;
1627117f1b4Smrg
16301e04c3fSmrg   assert(dstFormat == MESA_FORMAT_RGBA_DXT3 ||
1643464ebd5Sriastradh          dstFormat == MESA_FORMAT_SRGBA_DXT3);
1657117f1b4Smrg
1667117f1b4Smrg   if (srcFormat != GL_RGBA ||
167af69d88dSmrg       srcType != GL_UNSIGNED_BYTE ||
1687117f1b4Smrg       ctx->_ImageTransferState ||
16901e04c3fSmrg       ALIGN(srcPacking->RowLength, srcPacking->Alignment) != srcWidth ||
1707117f1b4Smrg       srcPacking->SwapBytes) {
171af69d88dSmrg      /* convert image to RGBA/GLubyte */
17201e04c3fSmrg      GLubyte *tempImageSlices[1];
17301e04c3fSmrg      int rgbaRowStride = 4 * srcWidth * sizeof(GLubyte);
17401e04c3fSmrg      tempImage = malloc(srcWidth * srcHeight * 4 * sizeof(GLubyte));
1757117f1b4Smrg      if (!tempImage)
1767117f1b4Smrg         return GL_FALSE; /* out of memory */
17701e04c3fSmrg      tempImageSlices[0] = (GLubyte *) tempImage;
17801e04c3fSmrg      _mesa_texstore(ctx, dims,
17901e04c3fSmrg                     baseInternalFormat,
1807ec681f3Smrg#if UTIL_ARCH_LITTLE_ENDIAN
1817ec681f3Smrg                     MESA_FORMAT_R8G8B8A8_UNORM,
1827ec681f3Smrg#else
1837ec681f3Smrg                     MESA_FORMAT_A8B8G8R8_UNORM,
1847ec681f3Smrg#endif
18501e04c3fSmrg                     rgbaRowStride, tempImageSlices,
18601e04c3fSmrg                     srcWidth, srcHeight, srcDepth,
18701e04c3fSmrg                     srcFormat, srcType, srcAddr,
18801e04c3fSmrg                     srcPacking);
1897117f1b4Smrg      pixels = tempImage;
1907117f1b4Smrg   }
1917117f1b4Smrg   else {
192af69d88dSmrg      pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
193af69d88dSmrg                                     srcFormat, srcType, 0, 0);
1947117f1b4Smrg   }
1957117f1b4Smrg
196af69d88dSmrg   dst = dstSlices[0];
197af69d88dSmrg
19801e04c3fSmrg   tx_compress_dxtn(4, srcWidth, srcHeight, pixels,
19901e04c3fSmrg                    GL_COMPRESSED_RGBA_S3TC_DXT3_EXT,
20001e04c3fSmrg                    dst, dstRowStride);
2017117f1b4Smrg
202af69d88dSmrg   free((void *) tempImage);
2037117f1b4Smrg
2047117f1b4Smrg   return GL_TRUE;
2057117f1b4Smrg}
2067117f1b4Smrg
2077117f1b4Smrg
2087117f1b4Smrg/**
2094a49301eSmrg * Store user's image in rgba_dxt5 format.
2107117f1b4Smrg */
2114a49301eSmrgGLboolean
2124a49301eSmrg_mesa_texstore_rgba_dxt5(TEXSTORE_PARAMS)
2137117f1b4Smrg{
214af69d88dSmrg   const GLubyte *pixels;
2157117f1b4Smrg   GLubyte *dst;
216af69d88dSmrg   const GLubyte *tempImage = NULL;
2177117f1b4Smrg
21801e04c3fSmrg   assert(dstFormat == MESA_FORMAT_RGBA_DXT5 ||
2193464ebd5Sriastradh          dstFormat == MESA_FORMAT_SRGBA_DXT5);
2207117f1b4Smrg
2217117f1b4Smrg   if (srcFormat != GL_RGBA ||
222af69d88dSmrg       srcType != GL_UNSIGNED_BYTE ||
2237117f1b4Smrg       ctx->_ImageTransferState ||
22401e04c3fSmrg       ALIGN(srcPacking->RowLength, srcPacking->Alignment) != srcWidth ||
2257117f1b4Smrg       srcPacking->SwapBytes) {
226af69d88dSmrg      /* convert image to RGBA/GLubyte */
22701e04c3fSmrg      GLubyte *tempImageSlices[1];
22801e04c3fSmrg      int rgbaRowStride = 4 * srcWidth * sizeof(GLubyte);
22901e04c3fSmrg      tempImage = malloc(srcWidth * srcHeight * 4 * sizeof(GLubyte));
2307117f1b4Smrg      if (!tempImage)
2317117f1b4Smrg         return GL_FALSE; /* out of memory */
23201e04c3fSmrg      tempImageSlices[0] = (GLubyte *) tempImage;
23301e04c3fSmrg      _mesa_texstore(ctx, dims,
23401e04c3fSmrg                     baseInternalFormat,
2357ec681f3Smrg#if UTIL_ARCH_LITTLE_ENDIAN
2367ec681f3Smrg                     MESA_FORMAT_R8G8B8A8_UNORM,
2377ec681f3Smrg#else
2387ec681f3Smrg                     MESA_FORMAT_A8B8G8R8_UNORM,
2397ec681f3Smrg#endif
24001e04c3fSmrg                     rgbaRowStride, tempImageSlices,
24101e04c3fSmrg                     srcWidth, srcHeight, srcDepth,
24201e04c3fSmrg                     srcFormat, srcType, srcAddr,
24301e04c3fSmrg                     srcPacking);
2447117f1b4Smrg      pixels = tempImage;
2457117f1b4Smrg   }
2467117f1b4Smrg   else {
247af69d88dSmrg      pixels = _mesa_image_address2d(srcPacking, srcAddr, srcWidth, srcHeight,
248af69d88dSmrg                                     srcFormat, srcType, 0, 0);
2497117f1b4Smrg   }
2507117f1b4Smrg
251af69d88dSmrg   dst = dstSlices[0];
252af69d88dSmrg
25301e04c3fSmrg   tx_compress_dxtn(4, srcWidth, srcHeight, pixels,
25401e04c3fSmrg                    GL_COMPRESSED_RGBA_S3TC_DXT5_EXT,
25501e04c3fSmrg                    dst, dstRowStride);
2567117f1b4Smrg
257af69d88dSmrg   free((void *) tempImage);
2587117f1b4Smrg
2597117f1b4Smrg   return GL_TRUE;
2607117f1b4Smrg}
2617117f1b4Smrg
2627117f1b4Smrg
263af69d88dSmrgstatic void
264af69d88dSmrgfetch_rgb_dxt1(const GLubyte *map,
265af69d88dSmrg               GLint rowStride, GLint i, GLint j, GLfloat *texel)
2667117f1b4Smrg{
26701e04c3fSmrg   GLubyte tex[4];
26801e04c3fSmrg   fetch_2d_texel_rgb_dxt1(rowStride, map, i, j, tex);
26901e04c3fSmrg   texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]);
27001e04c3fSmrg   texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]);
27101e04c3fSmrg   texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]);
27201e04c3fSmrg   texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
2737117f1b4Smrg}
2747117f1b4Smrg
2757117f1b4Smrgstatic void
276af69d88dSmrgfetch_rgba_dxt1(const GLubyte *map,
277af69d88dSmrg                GLint rowStride, GLint i, GLint j, GLfloat *texel)
2787117f1b4Smrg{
27901e04c3fSmrg   GLubyte tex[4];
28001e04c3fSmrg   fetch_2d_texel_rgba_dxt1(rowStride, map, i, j, tex);
28101e04c3fSmrg   texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]);
28201e04c3fSmrg   texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]);
28301e04c3fSmrg   texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]);
28401e04c3fSmrg   texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
2857117f1b4Smrg}
2867117f1b4Smrg
2877117f1b4Smrgstatic void
288af69d88dSmrgfetch_rgba_dxt3(const GLubyte *map,
289af69d88dSmrg                GLint rowStride, GLint i, GLint j, GLfloat *texel)
2907117f1b4Smrg{
29101e04c3fSmrg   GLubyte tex[4];
29201e04c3fSmrg   fetch_2d_texel_rgba_dxt3(rowStride, map, i, j, tex);
29301e04c3fSmrg   texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]);
29401e04c3fSmrg   texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]);
29501e04c3fSmrg   texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]);
29601e04c3fSmrg   texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
2977117f1b4Smrg}
2987117f1b4Smrg
2997117f1b4Smrgstatic void
300af69d88dSmrgfetch_rgba_dxt5(const GLubyte *map,
301af69d88dSmrg                GLint rowStride, GLint i, GLint j, GLfloat *texel)
3027117f1b4Smrg{
30301e04c3fSmrg   GLubyte tex[4];
30401e04c3fSmrg   fetch_2d_texel_rgba_dxt5(rowStride, map, i, j, tex);
30501e04c3fSmrg   texel[RCOMP] = UBYTE_TO_FLOAT(tex[RCOMP]);
30601e04c3fSmrg   texel[GCOMP] = UBYTE_TO_FLOAT(tex[GCOMP]);
30701e04c3fSmrg   texel[BCOMP] = UBYTE_TO_FLOAT(tex[BCOMP]);
30801e04c3fSmrg   texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
3097117f1b4Smrg}
3107117f1b4Smrg
3117117f1b4Smrg
312af69d88dSmrgstatic void
313af69d88dSmrgfetch_srgb_dxt1(const GLubyte *map,
314af69d88dSmrg                GLint rowStride, GLint i, GLint j, GLfloat *texel)
3157117f1b4Smrg{
31601e04c3fSmrg   GLubyte tex[4];
31701e04c3fSmrg   fetch_2d_texel_rgb_dxt1(rowStride, map, i, j, tex);
31801e04c3fSmrg   texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]);
31901e04c3fSmrg   texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]);
32001e04c3fSmrg   texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]);
32101e04c3fSmrg   texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
3227117f1b4Smrg}
3237117f1b4Smrg
324af69d88dSmrgstatic void
325af69d88dSmrgfetch_srgba_dxt1(const GLubyte *map,
326af69d88dSmrg                 GLint rowStride, GLint i, GLint j, GLfloat *texel)
3274a49301eSmrg{
32801e04c3fSmrg   GLubyte tex[4];
32901e04c3fSmrg   fetch_2d_texel_rgba_dxt1(rowStride, map, i, j, tex);
33001e04c3fSmrg   texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]);
33101e04c3fSmrg   texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]);
33201e04c3fSmrg   texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]);
33301e04c3fSmrg   texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
3344a49301eSmrg}
3357117f1b4Smrg
336af69d88dSmrgstatic void
337af69d88dSmrgfetch_srgba_dxt3(const GLubyte *map,
338af69d88dSmrg                 GLint rowStride, GLint i, GLint j, GLfloat *texel)
3394a49301eSmrg{
34001e04c3fSmrg   GLubyte tex[4];
34101e04c3fSmrg   fetch_2d_texel_rgba_dxt3(rowStride, map, i, j, tex);
34201e04c3fSmrg   texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]);
34301e04c3fSmrg   texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]);
34401e04c3fSmrg   texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]);
34501e04c3fSmrg   texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
3464a49301eSmrg}
3474a49301eSmrg
348af69d88dSmrgstatic void
349af69d88dSmrgfetch_srgba_dxt5(const GLubyte *map,
350af69d88dSmrg                 GLint rowStride, GLint i, GLint j, GLfloat *texel)
3514a49301eSmrg{
35201e04c3fSmrg   GLubyte tex[4];
35301e04c3fSmrg   fetch_2d_texel_rgba_dxt5(rowStride, map, i, j, tex);
35401e04c3fSmrg   texel[RCOMP] = util_format_srgb_8unorm_to_linear_float(tex[RCOMP]);
35501e04c3fSmrg   texel[GCOMP] = util_format_srgb_8unorm_to_linear_float(tex[GCOMP]);
35601e04c3fSmrg   texel[BCOMP] = util_format_srgb_8unorm_to_linear_float(tex[BCOMP]);
35701e04c3fSmrg   texel[ACOMP] = UBYTE_TO_FLOAT(tex[ACOMP]);
3584a49301eSmrg}
3594a49301eSmrg
3607117f1b4Smrg
361c1f859d4Smrg
362af69d88dSmrgcompressed_fetch_func
363af69d88dSmrg_mesa_get_dxt_fetch_func(mesa_format format)
364af69d88dSmrg{
365af69d88dSmrg   switch (format) {
366af69d88dSmrg   case MESA_FORMAT_RGB_DXT1:
367af69d88dSmrg      return fetch_rgb_dxt1;
368af69d88dSmrg   case MESA_FORMAT_RGBA_DXT1:
369af69d88dSmrg      return fetch_rgba_dxt1;
370af69d88dSmrg   case MESA_FORMAT_RGBA_DXT3:
371af69d88dSmrg      return fetch_rgba_dxt3;
372af69d88dSmrg   case MESA_FORMAT_RGBA_DXT5:
373af69d88dSmrg      return fetch_rgba_dxt5;
374af69d88dSmrg   case MESA_FORMAT_SRGB_DXT1:
375af69d88dSmrg      return fetch_srgb_dxt1;
376af69d88dSmrg   case MESA_FORMAT_SRGBA_DXT1:
377af69d88dSmrg      return fetch_srgba_dxt1;
378af69d88dSmrg   case MESA_FORMAT_SRGBA_DXT3:
379af69d88dSmrg      return fetch_srgba_dxt3;
380af69d88dSmrg   case MESA_FORMAT_SRGBA_DXT5:
381af69d88dSmrg      return fetch_srgba_dxt5;
382af69d88dSmrg   default:
383af69d88dSmrg      return NULL;
384af69d88dSmrg   }
385af69d88dSmrg}
386