mesa: remove gl_texture_image::IsCompressed field
authorBrian Paul <brianp@vmware.com>
Thu, 1 Oct 2009 22:29:44 +0000 (16:29 -0600)
committerBrian Paul <brianp@vmware.com>
Thu, 1 Oct 2009 22:29:44 +0000 (16:29 -0600)
Use _mesa_is_format_compressed() instead.

18 files changed:
src/mesa/drivers/dri/intel/intel_mipmap_tree.c
src/mesa/drivers/dri/intel/intel_tex_image.c
src/mesa/drivers/dri/intel/intel_tex_subimage.c
src/mesa/drivers/dri/intel/intel_tex_validate.c
src/mesa/drivers/dri/r200/r200_texstate.c
src/mesa/drivers/dri/radeon/radeon_mipmap_tree.c
src/mesa/drivers/dri/radeon/radeon_texstate.c
src/mesa/drivers/dri/radeon/radeon_texture.c
src/mesa/drivers/dri/tdfx/tdfx_tex.c
src/mesa/drivers/dri/unichrome/via_tex.c
src/mesa/drivers/glide/fxddtex.c
src/mesa/main/mipmap.c
src/mesa/main/mtypes.h
src/mesa/main/texgetimage.c
src/mesa/main/teximage.c
src/mesa/main/texparam.c
src/mesa/main/texstore.c
src/mesa/state_tracker/st_cb_texture.c

index 6bb7481ae4491afe11c9e5a067d33b1076c14e8b..a11869e7e88009456c8b4dea1beaba4c568d89db 100644 (file)
@@ -293,6 +293,8 @@ intel_miptree_match_image(struct intel_mipmap_tree *mt,
                           struct gl_texture_image *image,
                           GLuint face, GLuint level)
 {
+   GLboolean isCompressed = _mesa_is_format_compressed(image->TexFormat);
+
    /* Images with borders are never pulled into mipmap trees. 
     */
    if (image->Border ||
@@ -302,10 +304,10 @@ intel_miptree_match_image(struct intel_mipmap_tree *mt,
       return GL_FALSE;
 
    if (image->InternalFormat != mt->internal_format ||
-       image->IsCompressed != mt->compressed)
+       isCompressed != mt->compressed)
       return GL_FALSE;
 
-   if (!image->IsCompressed &&
+   if (!isCompressed &&
        !mt->compressed &&
        _mesa_get_format_bytes(image->TexFormat) != mt->cpp)
       return GL_FALSE;
index bbbeac8f7f1eeffb3ec38cfc486a0591f4f1c37f..29cca451483da19d4bdea56ac94cb1a3c1789a73 100644 (file)
@@ -125,7 +125,7 @@ guess_and_alloc_mipmap_tree(struct intel_context *intel,
    }
 
    assert(!intelObj->mt);
-   if (intelImage->base.IsCompressed)
+   if (_mesa_is_format_compressed(intelImage->base.TexFormat))
       comp_byte = intel_compressed_num_bytes(intelImage->base.TexFormat);
 
    texelBytes = _mesa_get_format_bytes(intelImage->base.TexFormat);
@@ -339,7 +339,6 @@ intelTexImage(GLcontext * ctx,
 
    if (_mesa_is_format_compressed(texImage->TexFormat)) {
       texelBytes = 0;
-      texImage->IsCompressed = GL_TRUE;
       texImage->CompressedSize =
         ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
                                           texImage->Height, texImage->Depth,
@@ -405,7 +404,7 @@ intelTexImage(GLcontext * ctx,
       int comp_byte = 0;
       GLuint texelBytes = _mesa_get_format_bytes(intelImage->base.TexFormat);
       GLenum baseFormat = _mesa_get_format_base_format(intelImage->base.TexFormat);
-      if (intelImage->base.IsCompressed) {
+      if (_mesa_is_format_compressed(intelImage->base.TexFormat)) {
         comp_byte =
            intel_compressed_num_bytes(intelImage->base.TexFormat);
       }
@@ -494,7 +493,7 @@ intelTexImage(GLcontext * ctx,
    }
    else {
       /* Allocate regular memory and store the image there temporarily.   */
-      if (texImage->IsCompressed) {
+      if (_mesa_is_format_compressed(texImage->TexFormat)) {
          sizeInBytes = texImage->CompressedSize;
          dstRowStride =
             _mesa_compressed_row_stride(texImage->TexFormat, width);
index bba1b53009dcc3954deb537c20288a526a8b3a61..cc329dae58b8ede44b37e6ed08bb6b9bd3f5df3c 100644 (file)
@@ -85,7 +85,7 @@ intelTexSubimage(GLcontext * ctx,
                                                &dstRowStride,
                                                texImage->ImageOffsets);
    else {
-      if (texImage->IsCompressed) {
+      if (_mesa_is_format_compressed(texImage->TexFormat)) {
          dstRowStride =
             _mesa_compressed_row_stride(texImage->TexFormat, width);
          assert(dims != 3);
index 0296c92523d6d54349a4ce52e23548a7d8f0474d..d5b562f5e57dd789a8e964a764bfdd457031e145 100644 (file)
@@ -165,7 +165,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
       intel_miptree_reference(&intelObj->mt, firstImage->mt);
    }
 
-   if (firstImage->base.IsCompressed) {
+   if (_mesa_is_format_compressed(firstImage->base.TexFormat)) {
       comp_byte = intel_compressed_num_bytes(firstImage->base.TexFormat);
       cpp = comp_byte;
    }
@@ -190,7 +190,7 @@ intel_finalize_mipmap_tree(struct intel_context *intel, GLuint unit)
        intelObj->mt->height0 != firstImage->base.Height ||
        intelObj->mt->depth0 != firstImage->base.Depth ||
        intelObj->mt->cpp != cpp ||
-       intelObj->mt->compressed != firstImage->base.IsCompressed)) {
+       intelObj->mt->compressed != _mesa_is_format_compressed(firstImage->base.TexFormat))) {
       intel_miptree_release(intel, &intelObj->mt);
    }
 
index daca318684df671395254a21749a86d02d4e5a72..1a6fa9f548f6e2178efc7b3e5f64351c1f64bcc3 100644 (file)
@@ -1504,7 +1504,7 @@ static void setup_hardware_state(r200ContextPtr rmesa, radeonTexObj *t)
                   | ((firstImage->Height - 1) << R200_PP_TX_HEIGHTMASK_SHIFT));
 
    if ( !t->image_override ) {
-      if (firstImage->IsCompressed)
+      if (_mesa_is_format_compressed(firstImage->TexFormat))
          t->pp_txpitch = (firstImage->Width + 63) & ~(63);
       else
          t->pp_txpitch = ((firstImage->Width * texelBytes) + 63) & ~(63);
index b602bfb4b0fbb7fb87b0e5e567e32e211f3c33ae..5429525587dbcedb71c8aecfd52ee6e285d10133 100644 (file)
@@ -314,16 +314,17 @@ static void calculate_first_last_level(struct gl_texture_object *tObj,
 GLboolean radeon_miptree_matches_image(radeon_mipmap_tree *mt,
                struct gl_texture_image *texImage, GLuint face, GLuint level)
 {
+       GLboolean isCompressed = _mesa_is_format_compressed(texImage->TexFormat);
        radeon_mipmap_level *lvl;
 
        if (face >= mt->faces || level < mt->firstLevel || level > mt->lastLevel)
                return GL_FALSE;
 
        if (texImage->InternalFormat != mt->internal_format ||
-           texImage->IsCompressed != mt->compressed)
+           isCompressed != mt->compressed)
                return GL_FALSE;
 
-       if (!texImage->IsCompressed &&
+       if (!isCompressed &&
            !mt->compressed &&
            _mesa_get_format_bytes(texImage->TexFormat) != mt->bpp)
                return GL_FALSE;
@@ -354,7 +355,7 @@ GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct gl_textu
                numfaces = 6;
 
        firstImage = texObj->Image[0][firstLevel];
-       compressed = firstImage->IsCompressed ? firstImage->TexFormat : 0;
+       compressed = _mesa_is_format_compressed(firstImage->TexFormat) ? firstImage->TexFormat : 0;
        texelBytes = _mesa_get_format_bytes(firstImage->TexFormat);
 
        return (mt->firstLevel == firstLevel &&
@@ -374,7 +375,7 @@ GLboolean radeon_miptree_matches_texture(radeon_mipmap_tree *mt, struct gl_textu
 void radeon_try_alloc_miptree(radeonContextPtr rmesa, radeonTexObj *t,
                radeon_texture_image *image, GLuint face, GLuint level)
 {
-       GLuint compressed = image->base.IsCompressed ? image->base.TexFormat : 0;
+       GLuint compressed = _mesa_is_format_compressed(image->base.TexFormat) ? image->base.TexFormat : 0;
        GLuint numfaces = 1;
        GLuint firstLevel, lastLevel;
        GLuint texelBytes;
index 1064602504f4e670bf5b8801dbfb85c68a119b86..5d22a1185959ca968f614bdc91348452d3935504 100644 (file)
@@ -81,8 +81,10 @@ struct tx_table {
    GLuint format, filter;
 };
 
+/* XXX verify this table against MESA_FORMAT_x values */
 static const struct tx_table tx_table[] =
 {
+   0, /* MESA_FORMAT_NONE */
    _ALPHA(RGBA8888),
    _ALPHA_REV(RGBA8888),
    _ALPHA(ARGB8888),
@@ -1083,7 +1085,7 @@ static GLboolean setup_hardware_state(r100ContextPtr rmesa, radeonTexObj *t, int
                   | ((firstImage->Height - 1) << RADEON_TEX_VSIZE_SHIFT));
 
    if ( !t->image_override ) {
-      if (firstImage->IsCompressed)
+      if (_mesa_is_format_compressed(firstImage->TexFormat))
          t->pp_txpitch = (firstImage->Width + 63) & ~(63);
       else
          t->pp_txpitch = ((firstImage->Width * texelBytes) + 63) & ~(63);
index 0378b3c9fcd560020f5c3fb6c060c401cf7b7431..442116a2dd15a5935eeed520905f88642e0c5708 100644 (file)
@@ -546,13 +546,11 @@ static void radeon_teximage(
 
        if (_mesa_is_format_compressed(texImage->TexFormat)) {
                texelBytes = 0;
-               texImage->IsCompressed = GL_TRUE;
                texImage->CompressedSize =
                        ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
                                           texImage->Height, texImage->Depth,
                                           texImage->TexFormat);
        } else {
-               texImage->IsCompressed = GL_FALSE;
                texImage->CompressedSize = 0;
 
                texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
@@ -590,7 +588,7 @@ static void radeon_teximage(
                dstRowStride = lvl->rowstride;
        } else {
                int size;
-               if (texImage->IsCompressed) {
+               if (_mesa_is_format_compressed(texImage->TexFormat)) {
                        size = texImage->CompressedSize;
                } else {
                        size = texImage->Width * texImage->Height * texImage->Depth * _mesa_get_format_bytes(texImage->TexFormat);
index 427d315a01d36155924005a8b8e67a1cc326b6ee..8b68137eedfa349569feb8b6c4db589289581609 100644 (file)
@@ -191,7 +191,6 @@ tdfxGenerateMipmap(GLcontext *ctx, GLenum target,
 
    texImage = _mesa_get_tex_image(ctx, texObj, target, level);
    texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
-   assert(!texImage->IsCompressed);
 
    mml = TDFX_TEXIMAGE_DATA(texImage);
 
@@ -1233,7 +1232,7 @@ adjust2DRatio (GLcontext *ctx,
    GLvoid *tempImage;
    GLuint dstImageOffsets = 0;
 
-   if (!texImage->IsCompressed) {
+   if (!_mesa_is_format_compressed(texImage->TexFormat)) {
       GLubyte *destAddr;
 
       tempImage = MALLOC(width * height * texelBytes);
@@ -1366,7 +1365,7 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
      * be correct, since it would mess with "compressedSize".
      * Ditto for GL_RGBA[4]_S3TC, which is always mapped to DXT3.
      */
-    if (texImage->IsCompressed) {
+    if (_mesa_is_format_compressed(texImage->TexFormat)) {
       switch (internalFormat) {
       case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
       case GL_RGB_S3TC:
@@ -1393,7 +1392,7 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
        }
        if (texNapalm) {
           texImage->InternalFormat = internalFormat = texNapalm;
-          texImage->IsCompressed = GL_TRUE;
+          _mesa_is_format_compressed(texImage->TexFormat) = GL_TRUE;
        }
     }
 #endif
@@ -1409,7 +1408,7 @@ tdfxTexImage2D(GLcontext *ctx, GLenum target, GLint level,
     texImage->FetchTexelc = fxFetchFunction(mesaFormat);
     texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
 
-    if (texImage->IsCompressed) {
+    if (_mesa_is_format_compressed(texImage->TexFormat)) {
        texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
                                                                mml->width,
                                                                mml->height,
@@ -1492,7 +1491,7 @@ tdfxTexSubImage2D(GLcontext *ctx, GLenum target, GLint level,
     assert(texImage->_BaseFormat);
 
     texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
-    if (texImage->IsCompressed) {
+    if (_mesa_is_format_compressed(texImage->TexFormat)) {
        dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat, mml->width);
     } else {
        dstRowStride = mml->width * texelBytes;
@@ -1594,8 +1593,6 @@ tdfxCompressedTexImage2D (GLcontext *ctx, GLenum target,
        return;
     }
 
-    assert(texImage->IsCompressed);
-
     ti = TDFX_TEXTURE_DATA(texObj);
     if (!ti) {
         texObj->DriverData = fxAllocTexObjData(fxMesa);
index b6be06d1ee29f6a507b6c9ef5f71d7a3fdd06bd8..a4cf5466fdb8dd7c7254f95ff58ea752f357af4c 100644 (file)
@@ -696,7 +696,6 @@ static void viaTexImage(GLcontext *ctx,
 
    if (texelBytes == 0) {
       /* compressed format */
-      texImage->IsCompressed = GL_TRUE;
       texImage->CompressedSize =
          ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
                                            texImage->Height, texImage->Depth,
@@ -713,7 +712,7 @@ static void viaTexImage(GLcontext *ctx,
    viaImage->pitchLog2 = logbase2(postConvWidth * texelBytes);
 
    /* allocate memory */
-   if (texImage->IsCompressed)
+   if (_mesa_is_format_compressed(texImage->TexFormat))
       sizeInBytes = texImage->CompressedSize;
    else
       sizeInBytes = postConvWidth * postConvHeight * texelBytes;
@@ -793,7 +792,7 @@ static void viaTexImage(GLcontext *ctx,
       GLint dstRowStride;
       GLboolean success;
 
-      if (texImage->IsCompressed) {
+      if (_mesa_is_format_compressed(texImage->TexFormat)) {
          dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat, width);
       }
       else {
index a64b6a555377e7baefe13307c99e59877b4138c7..a820cb818ec40aeae49929cae897e521d547ced0 100644 (file)
@@ -1234,7 +1234,7 @@ adjust2DRatio (GLcontext *ctx,
    const GLint newHeight = height * mml->hScale;
    GLvoid *tempImage;
 
-   if (!texImage->IsCompressed) {
+   if (!_mesa_is_format_compressed(texImage->TexFormat)) {
       GLubyte *destAddr;
 
       tempImage = MALLOC(width * height * texelBytes);
@@ -1353,7 +1353,7 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
 
 #if FX_COMPRESS_S3TC_AS_FXT1_HACK
    /* [koolsmoky] substitute FXT1 for DXTn and Legacy S3TC */
-   if (!ctx->Mesa_DXTn && texImage->IsCompressed) {
+   if (!ctx->Mesa_DXTn && _mesa_is_format_compressed(texImage->TexFormat)) {
      switch (internalFormat) {
      case GL_COMPRESSED_RGB_S3TC_DXT1_EXT:
      case GL_RGB_S3TC:
@@ -1380,7 +1380,6 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
       }
       if (texNapalm) {
          texImage->InternalFormat = internalFormat = texNapalm;
-         texImage->IsCompressed = GL_TRUE;
       }
    }
 #endif
@@ -1397,7 +1396,7 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
 
    /* allocate mipmap buffer */
    assert(!texImage->Data);
-   if (texImage->IsCompressed) {
+   if (_mesa_is_format_compressed(texImage->TexFormat)) {
       texImage->CompressedSize = _mesa_compressed_texture_size(ctx,
                                                                mml->width,
                                                                mml->height,
@@ -1451,7 +1450,7 @@ fxDDTexImage2D(GLcontext * ctx, GLenum target, GLint level,
          const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
          const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
 
-         assert(!texImage->IsCompressed);
+         assert(!_mesa_is_format_compressed(texImage->TexFormat));
 
          while (level < texObj->MaxLevel && level < maxLevels - 1) {
             mipWidth = width / 2;
@@ -1523,7 +1522,7 @@ fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
    assert(texImage->_BaseFormat);
 
    texelBytes = _mesa_get_format_bytes(texImage->TexFormat->MesaFormat);
-   if (texImage->IsCompressed) {
+   if (_mesa_is_format_compressed(texImage->TexFormat)) {
       dstRowStride = _mesa_compressed_row_stride(texImage->InternalFormat, mml->width);
    } else {
       dstRowStride = mml->width * texelBytes;
@@ -1564,7 +1563,7 @@ fxDDTexSubImage2D(GLcontext * ctx, GLenum target, GLint level,
       const struct gl_texture_unit *texUnit = &ctx->Texture.Unit[ctx->Texture.CurrentUnit];
       const GLint maxLevels = _mesa_max_texture_levels(ctx, texObj->Target);
 
-      assert(!texImage->IsCompressed);
+      assert(!_mesa_is_format_compressed(texImage->TexFormat));
 
       width = texImage->Width;
       height = texImage->Height;
@@ -1620,7 +1619,7 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
                        width, height);
    }
 
-   assert(texImage->IsCompressed);
+   assert(_mesa_is_format_compressed(texImage->TexFormat));
 
    if (!fxIsTexSupported(target, internalFormat, texImage)) {
       _mesa_problem(NULL, "fx Driver: unsupported texture in fxDDCompressedTexImg()\n");
@@ -1712,7 +1711,7 @@ fxDDCompressedTexImage2D (GLcontext *ctx, GLenum target,
 
    /* GL_SGIS_generate_mipmap */
    if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-      assert(!texImage->IsCompressed);
+      assert(!_mesa_is_format_compressed(texImage->TexFormat));
    }
 
    fxTexInvalidate(ctx, texObj);
@@ -1777,7 +1776,7 @@ fxDDCompressedTexSubImage2D( GLcontext *ctx, GLenum target,
 
    /* GL_SGIS_generate_mipmap */
    if (level == texObj->BaseLevel && texObj->GenerateMipmap) {
-      assert(!texImage->IsCompressed);
+      assert(!_mesa_is_format_compressed(texImage->TexFormat));
    }
 
    if (ti->validated && ti->isInTM)
index ccd153303d4988da4817bac9ed129743f404f7f8..f6d6ce33c8645b2669a7b228ec6aff5cd5a5317e 100644 (file)
@@ -1511,7 +1511,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
    ASSERT(maxLevels > 0);  /* bad target */
 
    /* Find convertFormat - the format that do_row() will process */
-   if (srcImage->IsCompressed) {
+   if (_mesa_is_format_compressed(srcImage->TexFormat)) {
       /* setup for compressed textures */
       GLuint row;
       GLint  components, size;
@@ -1589,7 +1589,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
                                          &dstWidth, &dstHeight, &dstDepth);
       if (!nextLevel) {
          /* all done */
-         if (srcImage->IsCompressed) {
+         if (_mesa_is_format_compressed(srcImage->TexFormat)) {
             _mesa_free((void *) srcData);
             _mesa_free(dstData);
          }
@@ -1614,8 +1614,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
       dstImage->TexFormat = srcImage->TexFormat;
       dstImage->FetchTexelc = srcImage->FetchTexelc;
       dstImage->FetchTexelf = srcImage->FetchTexelf;
-      dstImage->IsCompressed = srcImage->IsCompressed;
-      if (dstImage->IsCompressed) {
+      if (_mesa_is_format_compressed(dstImage->TexFormat)) {
          dstImage->CompressedSize
             = ctx->Driver.CompressedTextureSize(ctx, dstImage->Width,
                                               dstImage->Height,
@@ -1631,7 +1630,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
       /* Alloc new teximage data buffer.
        * Setup src and dest data pointers.
        */
-      if (dstImage->IsCompressed) {
+      if (_mesa_is_format_compressed(dstImage->TexFormat)) {
          dstImage->Data = _mesa_alloc_texmemory(dstImage->CompressedSize);
          if (!dstImage->Data) {
             _mesa_error(ctx, GL_OUT_OF_MEMORY, "generating mipmaps");
@@ -1661,7 +1660,7 @@ _mesa_generate_mipmap(GLcontext *ctx, GLenum target,
                                   dstData, dstImage->RowStride);
 
 
-      if (dstImage->IsCompressed) {
+      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);
index 1599a6f13fca79f3ffb08b84c3c391a32a83ee8e..f084edb8403df1b480d6b15734e50e35ffad9d1f 100644 (file)
@@ -1173,7 +1173,6 @@ struct gl_texture_image
    FetchTexelFuncC FetchTexelc;        /**< GLchan texel fetch function pointer */
    FetchTexelFuncF FetchTexelf;        /**< Float texel fetch function pointer */
 
-   GLboolean IsCompressed;     /**< GL_ARB_texture_compression */
    GLuint CompressedSize;      /**< GL_ARB_texture_compression */
 
    GLuint RowStride;           /**< Padded width in units of texels */
index e9e408d8c55e54ef6e43f77e48c0087f81904701..3e3951b1c494bb1e0e70088fb0af28587d3576d8 100644 (file)
@@ -567,7 +567,7 @@ _mesa_GetCompressedTexImageARB(GLenum target, GLint level, GLvoid *img)
    {
       texImage = _mesa_select_tex_image(ctx, texObj, target, level);
       if (texImage) {
-         if (texImage->IsCompressed) {
+         if (_mesa_is_format_compressed(texImage->TexFormat)) {
             /* this typically calls _mesa_get_compressed_teximage() */
             ctx->Driver.GetCompressedTexImage(ctx, target, level, img,
                                               texObj, texImage);
index c4e5ce2682480a5d9fdf580908e26357d1103453..86f46b9551707f47e7f41a1646bf01ea07c3b524 100644 (file)
@@ -903,7 +903,6 @@ clear_teximage_fields(struct gl_texture_image *img)
    img->TexFormat = MESA_FORMAT_NONE;
    img->FetchTexelc = NULL;
    img->FetchTexelf = NULL;
-   img->IsCompressed = 0;
    img->CompressedSize = 0;
 }
 
@@ -967,7 +966,6 @@ _mesa_init_teximage_fields(GLcontext *ctx, GLenum target,
 
    img->MaxLog2 = MAX2(img->WidthLog2, img->HeightLog2);
 
-   img->IsCompressed = GL_FALSE;
    img->CompressedSize = 0;
 
    if ((width == 1 || _mesa_is_pow_two(img->Width2)) &&
@@ -1589,7 +1587,7 @@ subtexture_error_check2( GLcontext *ctx, GLuint dimensions,
    }
 #endif
 
-   if (destTex->IsCompressed) {
+   if (_mesa_is_format_compressed(destTex->TexFormat)) {
       if (!target_can_be_compressed(ctx, target)) {
          _mesa_error(ctx, GL_INVALID_ENUM,
                      "glTexSubImage%D(target)", dimensions);
@@ -1951,7 +1949,7 @@ copytexsubimage_error_check2( GLcontext *ctx, GLuint dimensions,
       }
    }
 
-   if (teximage->IsCompressed) {
+   if (_mesa_is_format_compressed(teximage->TexFormat)) {
       if (!target_can_be_compressed(ctx, target)) {
          _mesa_error(ctx, GL_INVALID_ENUM,
                      "glCopyTexSubImage%d(target)", dimensions);
index a9df1dac15a04a93f27d9993f50766bb644d287f..a6b611dffb2cf9b8d2c4afdbb2067f9a9367b696 100644 (file)
@@ -852,7 +852,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
 
       /* GL_ARB_texture_compression */
       case GL_TEXTURE_COMPRESSED_IMAGE_SIZE:
-        if (img->IsCompressed && !isProxy) {
+        if (_mesa_is_format_compressed(img->TexFormat) && !isProxy) {
            /* Don't use ctx->Driver.CompressedTextureSize() since that
             * may returned a padded hardware size.
             */
@@ -866,7 +866,7 @@ _mesa_GetTexLevelParameteriv( GLenum target, GLint level,
         }
          break;
       case GL_TEXTURE_COMPRESSED:
-         *params = (GLint) img->IsCompressed;
+         *params = (GLint) _mesa_is_format_compressed(img->TexFormat);
          break;
 
       /* GL_ARB_texture_float */
index 48bee88e0ff9d28378c4fa6e3c29b6a34b70dfee..3e87e47cb1637ead8e8baedea3aa1a30f98e6a76 100644 (file)
@@ -3244,10 +3244,7 @@ _mesa_set_fetch_functions(struct gl_texture_image *texImage, GLuint dims)
 static void
 compute_texture_size(GLcontext *ctx, struct gl_texture_image *texImage)
 {
-   texImage->IsCompressed =
-      _mesa_is_format_compressed(texImage->TexFormat);
-
-   if (texImage->IsCompressed) {
+   if (_mesa_is_format_compressed(texImage->TexFormat)) {
       texImage->CompressedSize =
          ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
                                            texImage->Height, texImage->Depth,
@@ -3260,6 +3257,41 @@ compute_texture_size(GLcontext *ctx, struct gl_texture_image *texImage)
 }
 
 
+/** Return texture size in bytes */
+static GLuint
+texture_size(const struct gl_texture_image *texImage)
+{
+   GLuint sz;
+
+   if (_mesa_is_format_compressed(texImage->TexFormat))
+      sz = texImage->CompressedSize;
+   else
+      sz = texImage->Width * texImage->Height * texImage->Depth *
+         _mesa_get_format_bytes(texImage->TexFormat);
+
+   return sz;
+}
+
+
+/** Return row stride in bytes */
+static GLuint
+texture_row_stride(const struct gl_texture_image *texImage)
+{
+   GLuint stride;
+
+   if (_mesa_is_format_compressed(texImage->TexFormat)) {
+      stride = _mesa_compressed_row_stride(texImage->TexFormat,
+                                           texImage->Width);
+   }
+   else {
+      GLuint texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
+      stride = texImage->RowStride * texelBytes;
+   }
+
+   return stride;
+}
+
+
 
 /**
  * This is the software fallback for Driver.TexImage1D()
@@ -3289,10 +3321,8 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
    compute_texture_size(ctx, texImage);
 
    /* allocate memory */
-   if (texImage->IsCompressed)
-      sizeInBytes = texImage->CompressedSize;
-   else
-      sizeInBytes = texImage->Width * _mesa_get_format_bytes(texImage->TexFormat);
+   sizeInBytes = texture_size(texImage);
+
    texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
    if (!texImage->Data) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
@@ -3309,16 +3339,14 @@ _mesa_store_teximage1d(GLcontext *ctx, GLenum target, GLint level,
    }
    else {
       const GLint dstRowStride = 0;
-      GLboolean success;
-
-      success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
-                               texImage->TexFormat,
-                               texImage->Data,
-                               0, 0, 0,  /* dstX/Y/Zoffset */
-                               dstRowStride,
-                               texImage->ImageOffsets,
-                               width, 1, 1,
-                               format, type, pixels, packing);
+      GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
+                                         texImage->TexFormat,
+                                         texImage->Data,
+                                         0, 0, 0,  /* dstX/Y/Zoffset */
+                                         dstRowStride,
+                                         texImage->ImageOffsets,
+                                         width, 1, 1,
+                                         format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage1D");
       }
@@ -3360,10 +3388,7 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
    texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
 
    /* allocate memory */
-   if (texImage->IsCompressed)
-      sizeInBytes = texImage->CompressedSize;
-   else
-      sizeInBytes = texImage->Width * texImage->Height * texelBytes;
+   sizeInBytes = texture_size(texImage);
    texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
    if (!texImage->Data) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
@@ -3379,26 +3404,15 @@ _mesa_store_teximage2d(GLcontext *ctx, GLenum target, GLint level,
       return;
    }
    else {
-      GLint dstRowStride;
-      GLboolean success;
-
-      if (texImage->IsCompressed) {
-         dstRowStride
-            = _mesa_compressed_row_stride(texImage->TexFormat, width);
-      }
-      else {
-         dstRowStride = texImage->RowStride * texelBytes;
-      }
-
-      success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
-                               texImage->TexFormat,
-                               texImage->Data,
-                               0, 0, 0,  /* dstX/Y/Zoffset */
-                               dstRowStride,
-                               texImage->ImageOffsets,
-                               width, height, 1,
-                               format, type, pixels, packing);
-
+      GLint dstRowStride = texture_row_stride(texImage);
+      GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                                         texImage->TexFormat,
+                                         texImage->Data,
+                                         0, 0, 0,  /* dstX/Y/Zoffset */
+                                         dstRowStride,
+                                         texImage->ImageOffsets,
+                                         width, height, 1,
+                                         format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage2D");
       }
@@ -3436,10 +3450,7 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
    texelBytes = _mesa_get_format_bytes(texImage->TexFormat);
 
    /* allocate memory */
-   if (texImage->IsCompressed)
-      sizeInBytes = texImage->CompressedSize;
-   else
-      sizeInBytes = width * height * depth * texelBytes;
+   sizeInBytes = texture_size(texImage);
    texImage->Data = _mesa_alloc_texmemory(sizeInBytes);
    if (!texImage->Data) {
       _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
@@ -3455,25 +3466,15 @@ _mesa_store_teximage3d(GLcontext *ctx, GLenum target, GLint level,
       return;
    }
    else {
-      GLint dstRowStride;
-      GLboolean success;
-
-      if (texImage->IsCompressed) {
-         dstRowStride
-            = _mesa_compressed_row_stride(texImage->TexFormat, width);
-      }
-      else {
-         dstRowStride = texImage->RowStride * texelBytes;
-      }
-
-      success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
-                               texImage->TexFormat,
-                               texImage->Data,
-                               0, 0, 0,  /* dstX/Y/Zoffset */
-                               dstRowStride,
-                               texImage->ImageOffsets,
-                               width, height, depth,
-                               format, type, pixels, packing);
+      GLint dstRowStride = texture_row_stride(texImage);
+      GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
+                                         texImage->TexFormat,
+                                         texImage->Data,
+                                         0, 0, 0,  /* dstX/Y/Zoffset */
+                                         dstRowStride,
+                                         texImage->ImageOffsets,
+                                         width, height, depth,
+                                         format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexImage3D");
       }
@@ -3505,16 +3506,14 @@ _mesa_store_texsubimage1d(GLcontext *ctx, GLenum target, GLint level,
 
    {
       const GLint dstRowStride = 0;
-      GLboolean success;
-
-      success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
-                               texImage->TexFormat,
-                               texImage->Data,
-                               xoffset, 0, 0,  /* offsets */
-                               dstRowStride,
-                               texImage->ImageOffsets,
-                               width, 1, 1,
-                               format, type, pixels, packing);
+      GLboolean success = _mesa_texstore(ctx, 1, texImage->_BaseFormat,
+                                         texImage->TexFormat,
+                                         texImage->Data,
+                                         xoffset, 0, 0,  /* offsets */
+                                         dstRowStride,
+                                         texImage->ImageOffsets,
+                                         width, 1, 1,
+                                         format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage1D");
       }
@@ -3545,26 +3544,15 @@ _mesa_store_texsubimage2d(GLcontext *ctx, GLenum target, GLint level,
       return;
 
    {
-      GLint dstRowStride = 0;
-      GLboolean success;
-
-      if (texImage->IsCompressed) {
-         dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat,
-                                                    texImage->Width);
-      }
-      else {
-         dstRowStride = texImage->RowStride *
-            _mesa_get_format_bytes(texImage->TexFormat);
-      }
-
-      success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
-                               texImage->TexFormat,
-                               texImage->Data,
-                               xoffset, yoffset, 0,
-                               dstRowStride,
-                               texImage->ImageOffsets,
-                               width, height, 1,
-                               format, type, pixels, packing);
+      GLint dstRowStride = texture_row_stride(texImage);
+      GLboolean success = _mesa_texstore(ctx, 2, texImage->_BaseFormat,
+                                         texImage->TexFormat,
+                                         texImage->Data,
+                                         xoffset, yoffset, 0,
+                                         dstRowStride,
+                                         texImage->ImageOffsets,
+                                         width, height, 1,
+                                         format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage2D");
       }
@@ -3595,26 +3583,15 @@ _mesa_store_texsubimage3d(GLcontext *ctx, GLenum target, GLint level,
       return;
 
    {
-      GLint dstRowStride;
-      GLboolean success;
-
-      if (texImage->IsCompressed) {
-         dstRowStride = _mesa_compressed_row_stride(texImage->TexFormat,
-                                                    texImage->Width);
-      }
-      else {
-         dstRowStride = texImage->RowStride *
-            _mesa_get_format_bytes(texImage->TexFormat);
-      }
-
-      success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
-                               texImage->TexFormat,
-                               texImage->Data,
-                               xoffset, yoffset, zoffset,
-                               dstRowStride,
-                               texImage->ImageOffsets,
-                               width, height, depth,
-                               format, type, pixels, packing);
+      GLint dstRowStride = texture_row_stride(texImage);
+      GLboolean success = _mesa_texstore(ctx, 3, texImage->_BaseFormat,
+                                         texImage->TexFormat,
+                                         texImage->Data,
+                                         xoffset, yoffset, zoffset,
+                                         dstRowStride,
+                                         texImage->ImageOffsets,
+                                         width, height, depth,
+                                         format, type, pixels, packing);
       if (!success) {
          _mesa_error(ctx, GL_OUT_OF_MEMORY, "glTexSubImage3D");
       }
index 716fbc8b2956ee94bda946fc03a78c770176b5bd..b457a8dc6eff04619eaf7d492aa5e7da4c3331b8 100644 (file)
@@ -562,7 +562,6 @@ st_TexImage(GLcontext * ctx,
    if (_mesa_is_format_compressed(texImage->TexFormat)) {
       /* must be a compressed format */
       texelBytes = 0;
-      texImage->IsCompressed = GL_TRUE;
       texImage->CompressedSize =
         ctx->Driver.CompressedTextureSize(ctx, texImage->Width,
                                           texImage->Height, texImage->Depth,
@@ -696,7 +695,7 @@ st_TexImage(GLcontext * ctx,
    }
    else {
       /* Allocate regular memory and store the image there temporarily.   */
-      if (texImage->IsCompressed) {
+      if (_mesa_is_format_compressed(texImage->TexFormat)) {
          sizeInBytes = texImage->CompressedSize;
          dstRowStride =
             _mesa_compressed_row_stride(texImage->TexFormat, width);
@@ -1823,7 +1822,7 @@ st_finalize_texture(GLcontext *ctx,
    }
 
    /* FIXME: determine format block instead of cpp */
-   if (firstImage->base.IsCompressed) {
+   if (_mesa_is_format_compressed(firstImage->base.TexFormat)) {
       cpp = compressed_num_bytes(firstImage->base.TexFormat);
    }
    else {