dri/radeon: export a function to cleanup a texture object.
authorDave Airlie <airlied@redhat.com>
Tue, 17 Feb 2009 00:25:34 +0000 (10:25 +1000)
committerDave Airlie <airlied@redhat.com>
Tue, 17 Feb 2009 00:25:34 +0000 (10:25 +1000)
The radeon legacy code want to cleanup not free the texture obj,
so export a function to do that and wrap it.

src/mesa/drivers/dri/common/texmem.c
src/mesa/drivers/dri/common/texmem.h
src/mesa/drivers/dri/radeon/radeon_bo_legacy.c

index ff174a251d28301a39a5664dd045f31e612a9a0c..65c3c4e63e25d3d4196bf65803746ea09676f8c4 100644 (file)
@@ -314,11 +314,10 @@ void driSwapOutTextureObject( driTextureObject * t )
  * \param t Texture object to be destroyed
  */
 
-void driDestroyTextureObject( driTextureObject * t )
+void driCleanupTextureObject( driTextureObject * t )
 {
    driTexHeap * heap;
 
-
    if ( 0 ) {
       fprintf( stderr, "[%s:%d] freeing %p (tObj = %p, DriverData = %p)\n",
               __FILE__, __LINE__,
@@ -350,7 +349,6 @@ void driDestroyTextureObject( driTextureObject * t )
       }
 
       remove_from_list( t );
-      FREE( t );
    }
 
    if ( 0 ) {
@@ -359,6 +357,18 @@ void driDestroyTextureObject( driTextureObject * t )
 }
 
 
+void driDestroyTextureObject( driTextureObject * t )
+{
+   driTexHeap * heap;
+
+   if (t == NULL)
+     return;
+
+   driCleanupTextureObject(t);
+   FREE(t);
+}
+
+
 
 
 /**
index 9c065da8b4f65f1e2468e3a58937826730b146bd..b9beeeadfcac3ce9ace7dabcea61bbf56fdd084b 100644 (file)
@@ -272,6 +272,7 @@ void driAgeTextures( driTexHeap * heap );
 
 void driUpdateTextureLRU( driTextureObject * t );
 void driSwapOutTextureObject( driTextureObject * t );
+void driCleanupTextureObject( driTextureObject * t );
 void driDestroyTextureObject( driTextureObject * t );
 int driAllocateTexture( driTexHeap * const * heap_array, unsigned nr_heaps,
     driTextureObject * t );
index 1d25887e6913dfa6d8d2276c139664257bc7f6f5..65b0a9a0ce0c018e60a685620e3f36ea9adeefa2 100644 (file)
@@ -373,11 +373,13 @@ static void bo_free(struct bo_legacy *bo_legacy)
             /* dma buffers */
             bo_dma_free(&bo_legacy->base);
         } else {
+           if (bo_legacy->got_dri_texture_obj)
+               driCleanupTextureObject(&bo_legacy->dri_texture_obj);
+
             /* free backing store */
             free(bo_legacy->ptr);
         }
     }
-    memset(bo_legacy, 0 , sizeof(struct bo_legacy));
     free(bo_legacy);
 }