st/mesa: fix mipmap generation bug
authorBrian Paul <brianp@vmware.com>
Mon, 6 Dec 2010 18:01:19 +0000 (11:01 -0700)
committerBrian Paul <brianp@vmware.com>
Mon, 6 Dec 2010 18:01:21 +0000 (11:01 -0700)
In st_finalize_texture() we were looking at the st_texture_object::
lastLevel field instead of the pipe_resource::last_level field to
determine which resource to store the mipmap in.

Then, in st_generate_mipmap() we need to call st_finalize_texture() to
make sure the destination resource is properly allocated.

These changes fix the broken piglit fbo-generatemipmap-formats test.

src/mesa/state_tracker/st_cb_texture.c
src/mesa/state_tracker/st_gen_mipmap.c

index d0fb6301b08ff26730a4d34ac6523b827aa2135d..866426a75494e76e678edb53c37c218d2c78524f 100644 (file)
@@ -1855,8 +1855,9 @@ st_finalize_texture(struct gl_context *ctx,
     * will match.
     */
    if (firstImage->pt &&
+       stObj->pt &&
        firstImage->pt != stObj->pt &&
-       firstImage->pt->last_level >= stObj->lastLevel) {
+       firstImage->pt->last_level >= stObj->pt->last_level) {
       pipe_resource_reference(&stObj->pt, firstImage->pt);
       pipe_sampler_view_reference(&stObj->sampler_view, NULL);
    }
index 2472c0bcf11bc195beac545321194f561c122a53..c5f6008a22224870e814db924ff9d9da262d1881 100644 (file)
@@ -370,6 +370,12 @@ st_generate_mipmap(struct gl_context *ctx, GLenum target,
 
       pt = stObj->pt;
    }
+   else {
+      /* Make sure that the base texture image data is present in the
+       * texture buffer.
+       */
+      st_finalize_texture(ctx, st->pipe, texObj);
+   }
 
    assert(pt->last_level >= lastLevel);