Mesa (master): mesa: Remove compressed code from generate_mipmaps_uncompressed().

Eric Anholt anholt at kemper.freedesktop.org
Tue Jun 14 18:25:07 UTC 2011


Module: Mesa
Branch: master
Commit: 2bfd81df0a05351d79613b84908f167d6c5ad0af
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=2bfd81df0a05351d79613b84908f167d6c5ad0af

Author: Eric Anholt <eric at anholt.net>
Date:   Fri Jun 10 12:04:19 2011 -0700

mesa: Remove compressed code from generate_mipmaps_uncompressed().

---

 src/mesa/main/mipmap.c |  118 ++----------------------------------------------
 1 files changed, 4 insertions(+), 114 deletions(-)

diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
index 2bdb111..45fcc27 100644
--- a/src/mesa/main/mipmap.c
+++ b/src/mesa/main/mipmap.c
@@ -1892,79 +1892,10 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
 			     GLuint maxLevel)
 {
    GLint level;
-   gl_format convertFormat;
-   const GLubyte *srcData = NULL;
-   GLubyte *dstData = NULL;
    GLenum datatype;
    GLuint comps;
 
-   /* Find convertFormat - the format that do_row() will process */
-   if (_mesa_is_format_compressed(srcImage->TexFormat)) {
-      /* setup for compressed textures - need to allocate temporary
-       * image buffers to hold uncompressed images.
-       */
-      GLuint row;
-      GLint  components, size;
-      GLchan *dst;
-
-      assert(texObj->Target == GL_TEXTURE_2D ||
-             texObj->Target == GL_TEXTURE_CUBE_MAP_ARB);
-
-      if (srcImage->_BaseFormat == GL_RGB) {
-         convertFormat = MESA_FORMAT_RGB888;
-         components = 3;
-      } else if (srcImage->_BaseFormat == GL_RED) {
-         convertFormat = MESA_FORMAT_R8;
-         components = 1;
-      } else if (srcImage->_BaseFormat == GL_RG) {
-         convertFormat = MESA_FORMAT_RG88;
-         components = 2;
-      } else if (srcImage->_BaseFormat == GL_RGBA) {
-         convertFormat = MESA_FORMAT_RGBA8888;
-         components = 4;
-      } else if (srcImage->_BaseFormat == GL_LUMINANCE) {
-         convertFormat = MESA_FORMAT_L8;
-         components = 1;
-      } else if (srcImage->_BaseFormat == GL_LUMINANCE_ALPHA) {
-         convertFormat = MESA_FORMAT_AL88;
-         components = 2;
-      } else {
-         _mesa_problem(ctx, "bad srcImage->_BaseFormat in _mesa_generate_mipmaps");
-         return;
-      }
-
-      /* allocate storage for uncompressed GL_RGB or GL_RGBA images */
-      size = _mesa_bytes_per_pixel(srcImage->_BaseFormat, CHAN_TYPE)
-         * srcImage->Width * srcImage->Height * srcImage->Depth + 20;
-      /* 20 extra bytes, just be safe when calling last FetchTexel */
-      srcData = (GLubyte *) malloc(size);
-      if (!srcData) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps");
-         return;
-      }
-      dstData = (GLubyte *) malloc(size / 2);  /* 1/4 would probably be OK */
-      if (!dstData) {
-         _mesa_error(ctx, GL_OUT_OF_MEMORY, "generate mipmaps");
-         free((void *) srcData);
-         return;
-      }
-
-      /* decompress base image here */
-      dst = (GLchan *) srcData;
-      for (row = 0; row < srcImage->Height; row++) {
-         GLuint col;
-         for (col = 0; col < srcImage->Width; col++) {
-            srcImage->FetchTexelc(srcImage, col, row, 0, dst);
-            dst += components;
-         }
-      }
-   }
-   else {
-      /* uncompressed */
-      convertFormat = srcImage->TexFormat;
-   }
-
-   _mesa_format_to_type_and_comps(convertFormat, &datatype, &comps);
+   _mesa_format_to_type_and_comps(srcImage->TexFormat, &datatype, &comps);
 
    for (level = texObj->BaseLevel; level < maxLevel; level++) {
       /* generate image[level+1] from image[level] */
@@ -1986,14 +1917,8 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
       nextLevel = next_mipmap_level_size(target, border,
                                          srcWidth, srcHeight, srcDepth,
                                          &dstWidth, &dstHeight, &dstDepth);
-      if (!nextLevel) {
-         /* all done */
-         if (_mesa_is_format_compressed(srcImage->TexFormat)) {
-            free((void *) srcData);
-            free(dstData);
-         }
+      if (!nextLevel)
          return;
-      }
 
       /* get dest gl_texture_image */
       dstImage = _mesa_get_tex_image(ctx, texObj, target, level + 1);
@@ -2025,50 +1950,15 @@ generate_mipmap_uncompressed(struct gl_context *ctx, GLenum target,
          }
       }
 
-      /* Setup src and dest data pointers */
-      if (_mesa_is_format_compressed(dstImage->TexFormat)) {
-         /* srcData and dstData are already set */
-         ASSERT(srcData);
-         ASSERT(dstData);
-      }
-      else {
-         srcData = (const GLubyte *) srcImage->Data;
-         dstData = (GLubyte *) dstImage->Data;
-      }
-
       ASSERT(dstImage->TexFormat);
       ASSERT(dstImage->FetchTexelc);
       ASSERT(dstImage->FetchTexelf);
 
       _mesa_generate_mipmap_level(target, datatype, comps, border,
                                   srcWidth, srcHeight, srcDepth,
-                                  srcData, srcImage->RowStride,
+                                  srcImage->Data, srcImage->RowStride,
                                   dstWidth, dstHeight, dstDepth,
-                                  dstData, dstImage->RowStride);
-
-
-      if (_mesa_is_format_compressed(dstImage->TexFormat)) {
-         GLubyte *temp;
-         /* compress image from dstData into dstImage->Data */
-         const GLenum srcFormat = _mesa_get_format_base_format(convertFormat);
-         GLint dstRowStride
-            = _mesa_format_row_stride(dstImage->TexFormat, dstWidth);
-
-         _mesa_texstore(ctx, 2, dstImage->_BaseFormat,
-                        dstImage->TexFormat,
-                        dstImage->Data,
-                        0, 0, 0, /* dstX/Y/Zoffset */
-                        dstRowStride, 0, /* strides */
-                        dstWidth, dstHeight, 1, /* size */
-                        srcFormat, CHAN_TYPE,
-                        dstData, /* src data, actually */
-                        &ctx->DefaultPacking);
-
-         /* swap src and dest pointers */
-         temp = (GLubyte *) srcData;
-         srcData = dstData;
-         dstData = temp;
-      }
+                                  dstImage->Data, dstImage->RowStride);
 
    } /* loop over mipmap levels */
 }




More information about the mesa-commit mailing list