[Mesa-dev] [PATCH 2/6] i965/sync: Stop cacheing fence's signal status

Chad Versace chadversary at chromium.org
Wed Sep 28 06:51:20 UTC 2016


Cacheing the signal status complicates the code for questionable
performance benefit. I added the cacheing long ago, and I now think it
was the wrong decision.

When we later add support for fences based on sync fds (that is, a fd
backed by struct sync_file in Linux 4.8), the cacheing becomes even more
hairy. So it's best to eliminate it now.
---
 src/mesa/drivers/dri/i965/intel_syncobj.c | 27 ++-------------------------
 1 file changed, 2 insertions(+), 25 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/intel_syncobj.c b/src/mesa/drivers/dri/i965/intel_syncobj.c
index 4276f3f..ba8d3d0 100644
--- a/src/mesa/drivers/dri/i965/intel_syncobj.c
+++ b/src/mesa/drivers/dri/i965/intel_syncobj.c
@@ -47,9 +47,7 @@ struct brw_fence {
    struct brw_context *brw;
    /** The fence waits for completion of this batch. */
    drm_intel_bo *batch_bo;
-
    mtx_t mutex;
-   bool signalled;
 };
 
 struct intel_gl_sync_object {
@@ -78,7 +76,6 @@ static void
 brw_fence_insert(struct brw_context *brw, struct brw_fence *fence)
 {
    assert(!fence->batch_bo);
-   assert(!fence->signalled);
 
    brw_emit_mi_flush(brw);
    fence->batch_bo = brw->batch.bo;
@@ -89,17 +86,7 @@ brw_fence_insert(struct brw_context *brw, struct brw_fence *fence)
 static bool
 brw_fence_has_completed_locked(struct brw_fence *fence)
 {
-   if (fence->signalled)
-      return true;
-
-   if (fence->batch_bo && !drm_intel_bo_busy(fence->batch_bo)) {
-      drm_intel_bo_unreference(fence->batch_bo);
-      fence->batch_bo = NULL;
-      fence->signalled = true;
-      return true;
-   }
-
-   return false;
+   return !drm_intel_bo_busy(fence->batch_bo);
 }
 
 static bool
@@ -118,9 +105,6 @@ static bool
 brw_fence_client_wait_locked(struct brw_context *brw, struct brw_fence *fence,
                              uint64_t timeout)
 {
-   if (fence->signalled)
-      return true;
-
    assert(fence->batch_bo);
 
    /* DRM_IOCTL_I915_GEM_WAIT uses a signed 64 bit timeout and returns
@@ -131,14 +115,7 @@ brw_fence_client_wait_locked(struct brw_context *brw, struct brw_fence *fence,
    if (timeout > INT64_MAX)
       timeout = INT64_MAX;
 
-   if (drm_intel_gem_bo_wait(fence->batch_bo, timeout) != 0)
-      return false;
-
-   fence->signalled = true;
-   drm_intel_bo_unreference(fence->batch_bo);
-   fence->batch_bo = NULL;
-
-   return true;
+   return drm_intel_gem_bo_wait(fence->batch_bo, timeout) == 0;
 }
 
 /**
-- 
2.10.0



More information about the mesa-dev mailing list