Merge remote branch 'origin/mesa_7_7_branch'
[mesa.git] / src / mesa / drivers / dri / r300 / r300_tex.c
index 0af5bb4f469b3114017f48d9a71278a973e38148..726b3ff98e176cc217c68d9b91dd640740a4b357 100644 (file)
@@ -40,7 +40,6 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/image.h"
 #include "main/mipmap.h"
 #include "main/simple_list.h"
-#include "main/texformat.h"
 #include "main/texstore.h"
 #include "main/teximage.h"
 #include "main/texobj.h"
@@ -137,7 +136,7 @@ static void r300SetTexFilter(radeonTexObjPtr t, GLenum minf, GLenum magf, GLfloa
                        | R300_TX_MIN_FILTER_ANISO
                        | R300_TX_MIN_FILTER_MIP_LINEAR
                        | aniso_filter(anisotropy);
-               if (RADEON_DEBUG & DEBUG_TEXTURE)
+               if (RADEON_DEBUG & RADEON_TEXTURE)
                        fprintf(stderr, "Using maximum anisotropy of %f\n", anisotropy);
                return;
        }
@@ -196,8 +195,9 @@ static void r300TexParameter(GLcontext * ctx, GLenum target,
                             GLenum pname, const GLfloat * params)
 {
        radeonTexObj* t = radeon_tex_obj(texObj);
+       GLenum texBaseFormat;
 
-       if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
+       if (RADEON_DEBUG & (RADEON_STATE | RADEON_TEXTURE)) {
                fprintf(stderr, "%s( %s )\n", __FUNCTION__,
                        _mesa_lookup_enum_by_nr(pname));
        }
@@ -223,23 +223,16 @@ 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:
                if (!texObj->Image[0][texObj->BaseLevel])
                        return;
-               if (texObj->Image[0][texObj->BaseLevel]->TexFormat->BaseFormat
-                   == GL_DEPTH_COMPONENT) {
+               texBaseFormat = texObj->Image[0][texObj->BaseLevel]->_BaseFormat;
+
+               if (texBaseFormat == GL_DEPTH_COMPONENT ||
+                       texBaseFormat == GL_DEPTH_STENCIL) {
                        r300SetDepthTexMode(texObj);
                        break;
                } else {
@@ -260,7 +253,7 @@ static void r300DeleteTexture(GLcontext * ctx, struct gl_texture_object *texObj)
        r300ContextPtr rmesa = R300_CONTEXT(ctx);
        radeonTexObj* t = radeon_tex_obj(texObj);
 
-       if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
+       if (RADEON_DEBUG & (RADEON_STATE | RADEON_TEXTURE)) {
                fprintf(stderr, "%s( %p (target = %s) )\n", __FUNCTION__,
                        (void *)texObj,
                        _mesa_lookup_enum_by_nr(texObj->Target));
@@ -268,7 +261,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)
@@ -280,10 +277,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);
 }
 
@@ -302,7 +297,7 @@ static struct gl_texture_object *r300NewTextureObject(GLcontext * ctx,
        radeonTexObj* t = CALLOC_STRUCT(radeon_tex_obj);
 
 
-       if (RADEON_DEBUG & (DEBUG_STATE | DEBUG_TEXTURE)) {
+       if (RADEON_DEBUG & (RADEON_STATE | RADEON_TEXTURE)) {
                fprintf(stderr, "%s( %p (target = %s) )\n", __FUNCTION__,
                        t, _mesa_lookup_enum_by_nr(target));
        }