radeon: steal miptree optimisation from intel codebase
authorDave Airlie <airlied@redhat.com>
Tue, 17 Feb 2009 00:26:58 +0000 (10:26 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 17 Feb 2009 00:26:58 +0000 (10:26 +1000)
This replaces a miptree if it won't distrub anything else.

src/mesa/drivers/dri/radeon/radeon_texture.c

index 4aa081ca347c45f13ddbed71a2f7a0d152e6abc2..6949ee4502c9f7147902e451bb5c34ca1c6bd221 100644 (file)
@@ -517,6 +517,16 @@ static void radeon_teximage(
        /* Allocate memory for image */
        radeonFreeTexImageData(ctx, texImage); /* Mesa core only clears texImage->Data but not image->mt */
 
+       if (t->mt &&
+           t->mt->firstLevel == level &&
+           t->mt->lastLevel == level &&
+           t->mt->target != GL_TEXTURE_CUBE_MAP_ARB &&
+           !radeon_miptree_matches_image(t->mt, texImage, face, level)) {
+         fprintf(stderr,"freeing old miptree\n");
+         radeon_miptree_unreference(t->mt);
+         t->mt = NULL;
+       }
+
        if (!t->mt)
                radeon_try_alloc_miptree(rmesa, t, texImage, face, level);
        if (t->mt && radeon_miptree_matches_image(t->mt, texImage, face, level)) {