Add buffer manager destroy function.
authorEric Anholt <eric@anholt.net>
Thu, 31 May 2007 16:45:45 +0000 (09:45 -0700)
committerEric Anholt <eric@anholt.net>
Thu, 31 May 2007 16:45:45 +0000 (09:45 -0700)
src/mesa/drivers/dri/common/dri_bufmgr.c
src/mesa/drivers/dri/common/dri_bufmgr.h
src/mesa/drivers/dri/common/dri_bufmgr_fake.c
src/mesa/drivers/dri/common/dri_bufmgr_ttm.c
src/mesa/drivers/dri/i915tex/intel_screen.c

index 840fc7601ac7eb05f6a5670f06c26c0550a35c83..407409bf06df0cc7229ebe3523ff27278d54a04b 100644 (file)
@@ -144,3 +144,9 @@ dri_bo_get_subdata(dri_bo *bo, unsigned long offset,
    memcpy(data, (unsigned char *)bo->virtual + offset, size);
    dri_bo_unmap(bo);
 }
+
+void
+dri_bufmgr_destroy(dri_bufmgr *bufmgr)
+{
+   bufmgr->destroy(bufmgr);
+}
index 6aac54b7f42922e13df917781a2006e0f666e36c..0f8e27923be8d634fe23caff5423a5033d4ad6d5 100644 (file)
@@ -155,8 +155,9 @@ struct _dri_bufmgr {
    void (*fence_wait)(dri_fence *fence);
 
    /**
-    * Checks and returns whether the given fence is signaled.
+    * Tears down the buffer manager instance.
     */
+   void (*destroy)(dri_bufmgr *bufmgr);
 };
 
 dri_bo *dri_bo_alloc(dri_bufmgr *bufmgr, const char *name, unsigned long size,
@@ -190,6 +191,6 @@ dri_bufmgr *dri_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
                                 int (*fence_wait)(void *private,
                                                   unsigned int cookie),
                                 void *driver_priv);
-void dri_bufmgr_fake_contended_lock_take(dri_bufmgr *bufmgr);
+void dri_bufmgr_destroy(dri_bufmgr *bufmgr);
 
 #endif
index 90a2ff85f9802bc89462dafb349645df16d6364a..c6202d969cc0e7c5f789ab7fd0a844dae8d9f2a2 100644 (file)
@@ -829,6 +829,16 @@ dri_fake_fence_wait(dri_fence *fence)
    _glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
 }
 
+static void
+dri_fake_destroy(dri_bufmgr *bufmgr)
+{
+   dri_bufmgr_fake *bufmgr_fake = (dri_bufmgr_fake *)bufmgr;
+
+   _glthread_DESTROY_MUTEX(bufmgr_fake->mutex);
+   mmDestroy(bufmgr_fake->heap);
+   free(bufmgr);
+}
+
 dri_bufmgr *
 dri_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
                     unsigned long size,
@@ -865,6 +875,7 @@ dri_bufmgr_fake_init(unsigned long low_offset, void *low_virtual,
    bufmgr_fake->bufmgr.fence_wait = dri_fake_fence_wait;
    bufmgr_fake->bufmgr.fence_reference = dri_fake_fence_reference;
    bufmgr_fake->bufmgr.fence_unreference = dri_fake_fence_unreference;
+   bufmgr_fake->bufmgr.destroy = dri_fake_destroy;
 
    bufmgr_fake->fence_emit = fence_emit;
    bufmgr_fake->fence_wait = fence_wait;
index a721a7ce5c36bb1cc887f811b1182675e2b0a96c..64248a1d87179422baf0918c5b9c01de1f9739e3 100644 (file)
@@ -339,6 +339,15 @@ dri_ttm_fence_wait(dri_fence *fence)
    }
 }
 
+static void
+dri_fake_destroy(dri_bufmgr *bufmgr)
+{
+   dri_bufmgr_ttm *bufmgr_ttm = (dri_bufmgr_ttm *)bufmgr;
+
+   _glthread_DESTROY_MUTEX(bufmgr_ttm->mutex);
+   free(bufmgr);
+}
+
 /**
  * Initializes the TTM buffer manager, which uses the kernel to allocate, map,
  * and manage map buffer objections.
index 4d61407909d474d8c3c556c3ca5748240d6addb3..e3a631b69611320cf1c0946407f93c6e60c3aa08 100644 (file)
@@ -557,7 +557,7 @@ intelDestroyScreen(__DRIscreenPrivate * sPriv)
 
    intelUnmapScreenRegions(intelScreen);
 
-   /* XXX: bufmgr teardown */
+   dri_bufmgr_destroy(intelScreen->bufmgr);
    FREE(intelScreen);
    sPriv->private = NULL;
 }