Revert "Fix image_matches_texture_obj() MaxLevel check"
authorWill Dyson <will.dyson@gmail.com>
Sat, 19 Jun 2010 20:04:45 +0000 (22:04 +0200)
committerMaciej Cencora <m.cencora@gmail.com>
Sat, 19 Jun 2010 20:09:24 +0000 (22:09 +0200)
This reverts commit a9ee95651131e27d5acf3d10909b5b7e5c8d3e92.
It was based on a failure to understand how ther driver allocates
memory, and causes a regression with Celestia.

Set MaxLevel to dstLevel before allocating new mipmap level.

The radeon driver will fail to allocate space for a new level that
is outside of BaseLevel..MaxLevel. Set MaxLevel before allocating.

Signed-off-by: Maciej Cencora <m.cencora@gmail.com>
src/mesa/drivers/common/meta.c
src/mesa/drivers/dri/radeon/radeon_texture.c

index fc286851663c6cb6419b08b916bccd78986571be..35255833821bb1255a7c241ce00e9cfd43a98015 100644 (file)
@@ -2400,6 +2400,9 @@ _mesa_meta_GenerateMipmap(GLcontext *ctx, GLenum target,
          break;
       }
 
+      /* Set MaxLevel large enough to hold the new level when we allocate it  */
+      _mesa_TexParameteri(target, GL_TEXTURE_MAX_LEVEL, dstLevel);
+
       /* Create empty dest image */
       if (target == GL_TEXTURE_1D) {
          _mesa_TexImage1D(target, dstLevel, srcImage->InternalFormat,
index bcac125baf474d9bf4b272d6a6e312d25bc8d55f..d2b190e42e0ec2e46e50aefd1cbedc2a4525266d 100644 (file)
@@ -593,12 +593,7 @@ static int image_matches_texture_obj(struct gl_texture_object *texObj,
        if (!baseImage)
                return 0;
 
-       /* Check image level against object BaseLevel, but not MaxLevel. MaxLevel is not
-        * the highest level that can be assigned to the miptree.
-        */
-       const unsigned maxLevel = texObj->BaseLevel + baseImage->MaxLog2;
-       if (level < texObj->BaseLevel || level > maxLevel
-                       || level > RADEON_MIPTREE_MAX_TEXTURE_LEVELS)
+       if (level < texObj->BaseLevel || level > texObj->MaxLevel)
                return 0;
 
        const unsigned levelDiff = level - texObj->BaseLevel;
@@ -620,7 +615,9 @@ static void teximage_assign_miptree(radeonContextPtr rmesa,
        radeonTexObj *t = radeon_tex_obj(texObj);
        radeon_texture_image* image = get_radeon_texture_image(texImage);
 
-       /* check image for dimension and level compatibility with texture */
+       /* Since miptree holds only images for levels <BaseLevel..MaxLevel>
+        * don't allocate the miptree if the teximage won't fit.
+        */
        if (!image_matches_texture_obj(texObj, texImage, level))
                return;