st/mesa: fix computation of last_level in GenerateMipmap
authorMarek Olšák <maraeo@gmail.com>
Sun, 11 Nov 2012 14:32:59 +0000 (15:32 +0100)
committerMarek Olšák <maraeo@gmail.com>
Mon, 12 Nov 2012 20:37:31 +0000 (21:37 +0100)
Array textures were broken.

NOTE: This is a candidate for the stable branches.

Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/mesa/state_tracker/st_gen_mipmap.c

index 889200686e477afbe300f941ee1e6ae6cdc5314f..c09261312540ad87694f8c1e66314fd54f20cbaf 100644 (file)
@@ -121,30 +121,16 @@ compute_num_levels(struct gl_context *ctx,
                    struct gl_texture_object *texObj,
                    GLenum target)
 {
-   if (target == GL_TEXTURE_RECTANGLE_ARB) {
-      return 1;
-   }
-   else {
-      const struct gl_texture_image *baseImage = 
-         _mesa_get_tex_image(ctx, texObj, target, texObj->BaseLevel);
-      GLuint size, numLevels;
+   const struct gl_texture_image *baseImage;
+   GLuint numLevels;
 
-      size = MAX2(baseImage->Width2, baseImage->Height2);
-      size = MAX2(size, baseImage->Depth2);
+   baseImage = _mesa_get_tex_image(ctx, texObj, target, texObj->BaseLevel);
 
-      numLevels = texObj->BaseLevel;
-
-      while (size > 0) {
-         numLevels++;
-         size >>= 1;
-      }
+   numLevels = texObj->BaseLevel + baseImage->MaxNumLevels;
+   numLevels = MIN2(numLevels, texObj->MaxLevel + 1);
+   assert(numLevels >= 1);
 
-      numLevels = MIN2(numLevels, texObj->MaxLevel + 1);
-
-      assert(numLevels >= 1);
-
-      return numLevels;
-   }
+   return numLevels;
 }