[Intel-gfx] [PATCH 21/21] i965: Disable implicit sync when using EGL_ANDROID_native_fence_sync

Chris Wilson chris at chris-wilson.co.uk
Thu Aug 25 09:08:39 UTC 2016


If the client is controlling serialisation on shared buffers using
EGL_ANDROID_native_fence_sync, we assume that they are capable of fully
describing the serialisation required on those buffers and disable the
implicit syncs to prevent any "undue" serialisation between rendering.

This shotgun is likely too large - but it appears to be the default
standard on Android, and there is not yet a protocol for passing a
buffer and its fence between co-operating process. Other than the
existing implicit fences carried on dma-buf!

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Daniel Vetter <daniel.vetter at intel.com>
---
 src/mesa/drivers/dri/i965/intel_screen.c  | 7 +++++++
 src/mesa/drivers/dri/i965/intel_screen.h  | 1 +
 src/mesa/drivers/dri/i965/intel_syncobj.c | 8 ++++++++
 3 files changed, 16 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
index 1a32295..98f1c76 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.c
+++ b/src/mesa/drivers/dri/i965/intel_screen.c
@@ -751,6 +751,13 @@ intel_create_image_from_fds(__DRIscreen *screen,
       return NULL;
    }
 
+   /* If the GL clients are passing around EGL_ANDROID_native_fence_sync
+    * we presume that they do not want (or require!) any implicit
+    * serialisation. This affects all contexts using this surface.
+    */
+   if (intelScreen->explicit_fencing)
+      drm_intel_gem_bo_disable_implicit_sync(image->bo);
+
    if (f->nplanes == 1) {
       image->offset = image->offsets[0];
       intel_image_warn_if_unaligned(image, __func__);
diff --git a/src/mesa/drivers/dri/i965/intel_screen.h b/src/mesa/drivers/dri/i965/intel_screen.h
index d167758..35cd5df 100644
--- a/src/mesa/drivers/dri/i965/intel_screen.h
+++ b/src/mesa/drivers/dri/i965/intel_screen.h
@@ -47,6 +47,7 @@ struct intel_screen
    bool no_hw;
    bool hw_has_swizzling;
    bool has_fence_fd;
+   bool explicit_fencing;
 
    int hw_has_timestamp;
 
diff --git a/src/mesa/drivers/dri/i965/intel_syncobj.c b/src/mesa/drivers/dri/i965/intel_syncobj.c
index 8ac5324..3fc3820 100644
--- a/src/mesa/drivers/dri/i965/intel_syncobj.c
+++ b/src/mesa/drivers/dri/i965/intel_syncobj.c
@@ -417,6 +417,14 @@ intel_dri_create_fence_fd(__DRIcontext *ctx, int fd)
    fence->handle = fd;
    fence->ops = &fd_ops;
 
+   /* Explicit fencing requires disabling implicit fences for all shared
+    * buffers (so that the client is wholly responsible for all stalls,
+    * and rendering corruption).
+    *
+    * This is not stated in any spec, but is the defacto standard on Android.
+    */
+   brw->intelScreen->explicit_fencing = true;
+
    return fence;
 }
 
-- 
2.9.3



More information about the Intel-gfx mailing list