[Mesa-dev] [PATCH 07/11] intel: Allow src == NULL and *dst != NULL in intel_miptree_reference().
Eric Anholt
eric at anholt.net
Thu Sep 22 12:34:19 PDT 2011
This makes this API consistent with intel_region_reference, and the
consumers consumers wanted it this way.
---
src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 12 ++++++++++--
src/mesa/drivers/dri/intel/intel_tex_image.c | 7 +------
src/mesa/drivers/dri/intel/intel_tex_validate.c | 2 --
3 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
index 5434e48..4c940e5 100644
--- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
+++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c
@@ -180,9 +180,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);
}
diff --git a/src/mesa/drivers/dri/intel/intel_tex_image.c b/src/mesa/drivers/dri/intel/intel_tex_image.c
index 69da0e2..30c3cfb 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_image.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_image.c
@@ -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.
diff --git a/src/mesa/drivers/dri/intel/intel_tex_validate.c b/src/mesa/drivers/dri/intel/intel_tex_validate.c
index 59354d6..1379108 100644
--- a/src/mesa/drivers/dri/intel/intel_tex_validate.c
+++ b/src/mesa/drivers/dri/intel/intel_tex_validate.c
@@ -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);
--
1.7.5.4
More information about the mesa-dev
mailing list