R300: set the number of GB pipes on all r3xx-r5xx chips
[mesa.git] / src / mesa / drivers / dri / radeon / radeon_tex.c
index c6a911abef64671633caa35438a5be1c18637bf9..2dfb5042ecc23d5db5b69029b2f9c31290e3f725 100644 (file)
@@ -44,6 +44,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "main/texobj.h"
 
 #include "radeon_context.h"
+#include "radeon_mipmap_tree.h"
 #include "radeon_state.h"
 #include "radeon_ioctl.h"
 #include "radeon_swtcl.h"
@@ -170,6 +171,9 @@ static void radeonSetTexFilter( radeonTexObjPtr t, GLenum minf, GLenum magf )
 {
    GLuint anisotropy = (t->pp_txfilter & RADEON_MAX_ANISO_MASK);
 
+   /* Force revalidation to account for switches from/to mipmapping. */
+   t->validated = GL_FALSE;
+
    t->pp_txfilter &= ~(RADEON_MIN_FILTER_MASK | RADEON_MAG_FILTER_MASK);
 
    /* r100 chips can't handle mipmaps/aniso for cubemap/volume textures */
@@ -314,7 +318,7 @@ static void radeonTexParameter( GLcontext *ctx, GLenum target,
                                struct gl_texture_object *texObj,
                                GLenum pname, const GLfloat *params )
 {
-   radeonTexObjPtr t = (radeonTexObjPtr) texObj->DriverData;
+   radeonTexObj* t = radeon_tex_obj(texObj);
 
    if ( RADEON_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
       fprintf( stderr, "%s( %s )\n", __FUNCTION__,
@@ -342,21 +346,22 @@ static void radeonTexParameter( 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.
        */
-      driSwapOutTextureObject( (driTextureObject *) t );
+      if (t->mt) {
+         radeon_miptree_unreference(t->mt);
+        t->mt = 0;
+        t->validated = GL_FALSE;
+      }
       break;
 
    default:
       return;
    }
-
-   /* Mark this texobj as dirty (one bit per tex unit)
-    */
-   t->dirty_state = R100_TEX_ALL;
 }
 
 static void radeonDeleteTexture( GLcontext *ctx,
@@ -364,6 +369,7 @@ static void radeonDeleteTexture( GLcontext *ctx,
 {
    r100ContextPtr rmesa = R100_CONTEXT(ctx);
    radeonTexObj* t = radeon_tex_obj(texObj);
+   int i;
 
    if ( RADEON_DEBUG & (DEBUG_STATE|DEBUG_TEXTURE) ) {
       fprintf( stderr, "%s( %p (target = %s) )\n", __FUNCTION__, (void *)texObj,
@@ -371,8 +377,14 @@ static void radeonDeleteTexture( GLcontext *ctx,
    }
 
    if ( rmesa ) {
-     RADEON_FIREVERTICES( rmesa );
-     
+     radeon_firevertices(&rmesa->radeon);
+     for ( i = 0 ; i < rmesa->radeon.glCtx->Const.MaxTextureUnits ; i++ ) {
+       if ( t == rmesa->state.texture.unit[i].texobj ) {
+        rmesa->state.texture.unit[i].texobj = NULL;
+        rmesa->hw.tex[i].dirty = GL_FALSE;
+        rmesa->hw.cube[i].dirty = GL_FALSE;
+       }
+     }
    }
 
    if (t->mt) {
@@ -440,11 +452,12 @@ void radeonInitTextureFuncs( struct dd_function_table *functions )
    functions->TexImage2D               = radeonTexImage2D;
    functions->TexSubImage1D            = radeonTexSubImage1D;
    functions->TexSubImage2D            = radeonTexSubImage2D;
+   functions->GetTexImage               = radeonGetTexImage;
+   functions->GetCompressedTexImage     = radeonGetCompressedTexImage;
 
    functions->NewTextureObject         = radeonNewTextureObject;
    //   functions->BindTexture         = radeonBindTexture;
    functions->DeleteTexture            = radeonDeleteTexture;
-   functions->IsTextureResident                = driIsTextureResident;
 
    functions->TexEnv                   = radeonTexEnv;
    functions->TexParameter             = radeonTexParameter;
@@ -453,7 +466,7 @@ void radeonInitTextureFuncs( struct dd_function_table *functions )
    functions->CompressedTexImage2D     = radeonCompressedTexImage2D;
    functions->CompressedTexSubImage2D  = radeonCompressedTexSubImage2D;
 
-   functions->GenerateMipmap = radeon_generate_mipmap;
+   functions->GenerateMipmap = radeonGenerateMipmap;
 
    functions->NewTextureImage = radeonNewTextureImage;
    functions->FreeTexImageData = radeonFreeTexImageData;