intel: Allow src == NULL and *dst != NULL in intel_miptree_reference().

This makes this API consistent with intel_region_reference, and the
consumers wanted it this way.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Eric Anholt 2011-09-21 15:38:32 -07:00
parent db3ada6055
commit 32fe506ae1
3 changed files with 11 additions and 10 deletions

View file

@ -173,9 +173,17 @@ void
intel_miptree_reference(struct intel_mipmap_tree **dst,
struct intel_mipmap_tree *src)
{
src->refcount++;
if (*dst == src)
return;
intel_miptree_release(dst);
if (src) {
src->refcount++;
DBG("%s %p refcount now %d\n", __FUNCTION__, src, src->refcount);
}
*dst = src;
DBG("%s %p refcount now %d\n", __FUNCTION__, src, src->refcount);
}

View file

@ -370,8 +370,6 @@ intelTexImage(struct gl_context * ctx,
}
}
assert(!intelImage->mt);
if (intelObj->mt &&
intel_miptree_match_image(intelObj->mt, &intelImage->base.Base)) {
/* Use an existing miptree when possible */
@ -391,10 +389,7 @@ intelTexImage(struct gl_context * ctx,
* whole object since our level didn't fit what was there
* before, and any lower levels would fit into our miptree.
*/
if (intelImage->mt) {
intel_miptree_release(&intelObj->mt);
intel_miptree_reference(&intelObj->mt, intelImage->mt);
}
intel_miptree_reference(&intelObj->mt, intelImage->mt);
}
/* Attempt to use the blitter for PBO image uploads.

View file

@ -43,8 +43,6 @@ copy_image_data_to_tree(struct intel_context *intel,
intelObj->mt,
intelImage->base.Base.Face,
intelImage->base.Base.Level, intelImage->mt);
intel_miptree_release(&intelImage->mt);
}
else {
assert(intelImage->base.Base.Data != NULL);