[intel] Move batch bo_unmap from TTM code to shared, and add more asserts.
authorEric Anholt <eric@anholt.net>
Sat, 1 Dec 2007 02:17:12 +0000 (18:17 -0800)
committerEric Anholt <eric@anholt.net>
Sat, 1 Dec 2007 02:17:12 +0000 (18:17 -0800)
src/mesa/drivers/dri/common/dri_bufmgr_fake.c
src/mesa/drivers/dri/intel/intel_batchbuffer.c
src/mesa/drivers/dri/intel/intel_bufmgr_ttm.c

index 029f29ad693cb06340d23fc476b91996cf764eca..dda6e5a25eda5790fd108fc995d8ee714cd8d88d 100644 (file)
@@ -754,6 +754,7 @@ dri_fake_bo_unmap(dri_bo *bo)
       return 0;
 
    _glthread_LOCK_MUTEX(bufmgr_fake->mutex);
+   assert(bo_fake->map_count != 0);
    if (--bo_fake->map_count != 0) {
       _glthread_UNLOCK_MUTEX(bufmgr_fake->mutex);
       return 0;
@@ -785,6 +786,12 @@ dri_fake_bo_validate(dri_bo *bo, uint64_t flags)
 
    _glthread_LOCK_MUTEX(bufmgr_fake->mutex);
    {
+      /* Sanity check: Buffers should be unmapped before being validated.
+       * This is not so much of a problem for bufmgr_fake, but TTM refuses,
+       * and the problem is harder to debug there.
+       */
+      assert(bo_fake->map_count == 0);
+
       if (bo_fake->is_static) {
         /* Add it to the needs-fence list */
         bufmgr_fake->need_fence = 1;
index 3764027bff61d318148122f1d570e0fad02fb5c1..b51086a638c3381813e3338c6392fde9820fefbc 100644 (file)
@@ -131,6 +131,7 @@ do_flush_locked(struct intel_batchbuffer *batch,
    void *start;
    GLuint count;
 
+   dri_bo_unmap(batch->buf);
    start = dri_process_relocs(batch->buf, &count);
 
    batch->map = NULL;
index 5791f01ce16ad58f37cc928570976af5f75cea3d..3e0d818a0cc9ae6e4572da4fdd41fae4635c65b2 100644 (file)
@@ -825,8 +825,6 @@ dri_ttm_process_reloc(dri_bo *batch_buf, GLuint *count)
     void *ptr;
     int itemLoc;
 
-    dri_bo_unmap(batch_buf);
-
     /* Add the batch buffer to the validation list.  There are no relocations
      * pointing to it.
      */