Manage fences in user-mode bufmgr_fake to clean buffers
authorKeith Packard <keithp@keithp.com>
Thu, 9 Oct 2008 21:30:56 +0000 (14:30 -0700)
committerKeith Packard <keithp@keithp.com>
Fri, 10 Oct 2008 01:25:58 +0000 (18:25 -0700)
When using bufmgr_fake without DRM, the X server idles the ring whenever it
wants to wait for something to complete (brutal, but effective). In this
case, bufmgr_fake must treat the pending fence as having passed. However, it
wasn't recording the fences as it emitted them, nor cleaning buffers as they
passed.

Signed-off-by: Keith Packard <keithp@keithp.com>
libdrm/intel/intel_bufmgr_fake.c

index c8f643d..1be4698 100644 (file)
@@ -256,8 +256,10 @@ _fence_emit_internal(dri_bufmgr_fake *bufmgr_fake)
    struct drm_i915_irq_emit ie;
    int ret, seq = 1;
 
-   if (bufmgr_fake->fence_emit != NULL)
-      return bufmgr_fake->fence_emit(bufmgr_fake->fence_priv);
+   if (bufmgr_fake->fence_emit != NULL) {
+      seq = bufmgr_fake->fence_emit(bufmgr_fake->fence_priv);
+      return seq;
+   }
 
    ie.irq_seq = &seq;
    ret = drmCommandWriteRead(bufmgr_fake->fd, DRM_I915_IRQ_EMIT,
@@ -268,8 +270,7 @@ _fence_emit_internal(dri_bufmgr_fake *bufmgr_fake)
    }
 
    DBG("emit 0x%08x\n", seq);
-   bufmgr_fake->last_fence = seq;
-   return bufmgr_fake->last_fence;
+   return seq;
 }
 
 static void
@@ -282,6 +283,7 @@ _fence_wait_internal(dri_bufmgr_fake *bufmgr_fake, int seq)
 
    if (bufmgr_fake->fence_wait != NULL) {
       bufmgr_fake->fence_wait(seq, bufmgr_fake->fence_priv);
+      clear_fenced(bufmgr_fake, seq);
       return;
    }
 
@@ -571,6 +573,7 @@ static int clear_fenced(dri_bufmgr_fake *bufmgr_fake,
    struct block *block, *tmp;
    int ret = 0;
 
+   bufmgr_fake->last_fence = fence_cookie;
    DRMLISTFOREACHSAFE(block, tmp, &bufmgr_fake->fenced) {
       assert(block->fenced);