st/mesa: fix mipmap generation bug

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.
(cherry picked from commit cae2bb76c1)
This commit is contained in:
Brian Paul 2010-12-06 11:01:19 -07:00 committed by Marek Olšák
parent a3740ba31e
commit f5435ec3a9
2 changed files with 8 additions and 1 deletions

View file

@ -1852,8 +1852,9 @@ st_finalize_texture(GLcontext *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);
}

View file

@ -366,6 +366,12 @@ st_generate_mipmap(GLcontext *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);