Merge branch 'master' into pipe-format-simplify
[mesa.git] / src / mesa / drivers / dri / r300 / r300_tex.c
index 27b78a912fadfa3c89c7207aead912ced3738117..ac3d5b1bec34840ec691910b48ba6c4915c1c457 100644 (file)
@@ -48,7 +48,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 
 #include "r300_context.h"
 #include "r300_state.h"
-#include "r300_ioctl.h"
 #include "radeon_mipmap_tree.h"
 #include "r300_tex.h"
 
@@ -223,16 +222,7 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
        case GL_TEXTURE_MAX_LEVEL:
        case GL_TEXTURE_MIN_LOD:
        case GL_TEXTURE_MAX_LOD:
-               /* This isn't the most efficient solution but there doesn't appear to
-                * be a nice alternative.  Since there's no LOD clamping,
-                * we just have to rely on loading the right subset of mipmap levels
-                * to simulate a clamped LOD.
-                */
-               if (t->mt) {
-                       radeon_miptree_unreference(t->mt);
-                       t->mt = 0;
-                       t->validated = GL_FALSE;
-               }
+               t->validated = GL_FALSE;
                break;
 
        case GL_DEPTH_TEXTURE_MODE:
@@ -270,7 +260,11 @@ static void r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
 
        if (rmesa) {
                int i;
-               radeon_firevertices(&rmesa->radeon);
+               struct radeon_bo *bo;
+               bo = !t->mt ? t->bo : t->mt->bo;
+               if (bo && radeon_bo_is_referenced_by_cs(bo, rmesa->radeon.cmdbuf.cs)) {
+                       radeon_firevertices(&rmesa->radeon);
+               }
 
                for(i = 0; i < R300_MAX_TEXTURE_UNITS; ++i)
                        if (rmesa->hw.textures[i] == t)
@@ -282,10 +276,8 @@ static void r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
                t->bo = NULL;
        }
 
-       if (t->mt) {
-               radeon_miptree_unreference(t->mt);
-               t->mt = 0;
-       }
+       radeon_miptree_unreference(&t->mt);
+
        _mesa_delete_texture_object(ctx, texObj);
 }