st/mesa: fix mipmap generation for non-POW textures
authorBrian Paul <brianp@vmware.com>
Mon, 21 Feb 2011 22:11:44 +0000 (15:11 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 21 Feb 2011 22:15:53 +0000 (15:15 -0700)
This is part of the fix for https://bugs.freedesktop.org/show_bug.cgi?id=34463

src/mesa/state_tracker/st_gen_mipmap.c

index 18eb3be6809142b6f33a5507f8cbc6f74a894eb3..4bf682808390f631b47c75f71da007ce64c75c9d 100644 (file)
@@ -336,6 +336,11 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
    if (lastLevel == 0)
       return;
 
+   /* The texture isn't in a "complete" state yet so set the expected
+    * lastLevel here, since it won't get done in st_finalize_texture().
+    */
+   stObj->lastLevel = lastLevel;
+
    if (pt->last_level < lastLevel) {
       /* The current gallium texture doesn't have space for all the
        * mipmap levels we need to generate.  So allocate a new texture.
@@ -353,11 +358,6 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
                                     oldTex->array_size,
                                     oldTex->bind);
 
-      /* The texture isn't in a "complete" state yet so set the expected
-       * lastLevel here, since it won't get done in st_finalize_texture().
-       */
-      stObj->lastLevel = lastLevel;
-
       /* This will copy the old texture's base image into the new texture
        * which we just allocated.
        */
@@ -366,8 +366,6 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
       /* release the old tex (will likely be freed too) */
       pipe_resource_reference(&oldTex, NULL);
       pipe_sampler_view_reference(&stObj->sampler_view, NULL);
-
-      pt = stObj->pt;
    }
    else {
       /* Make sure that the base texture image data is present in the
@@ -376,6 +374,8 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
       st_finalize_texture(ctx, st->pipe, texObj);
    }
 
+   pt = stObj->pt;
+
    assert(pt->last_level >= lastLevel);
 
    /* Try to generate the mipmap by rendering/texturing.  If that fails,