[Intel-gfx] [PATCH 20/21] i965: Implement EGL_ANDROID_native_fence_sync support for DRI2_FENCE

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


Wire up the callbacks from DRI2_FENCE for native fence support.

Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
 src/mesa/drivers/dri/i965/intel_syncobj.c | 48 +++++++++++++++++++++++++++++++
 1 file changed, 48 insertions(+)

diff --git a/src/mesa/drivers/dri/i965/intel_syncobj.c b/src/mesa/drivers/dri/i965/intel_syncobj.c
index b5df498..8ac5324 100644
--- a/src/mesa/drivers/dri/i965/intel_syncobj.c
+++ b/src/mesa/drivers/dri/i965/intel_syncobj.c
@@ -383,6 +383,51 @@ intel_dri_server_wait_sync(__DRIcontext *ctx, void *driver_fence, unsigned flags
    fence->ops->server_wait(fence, brw);
 }
 
+static unsigned
+intel_dri_get_capabilities(__DRIscreen *screen)
+{
+   struct intel_screen *intelScreen = screen->driverPrivate;
+   unsigned caps = 0;
+
+   if (intelScreen->has_fence_fd)
+      caps |= __DRI_FENCE_CAP_NATIVE_FD;
+
+   return caps;
+}
+
+static void *
+intel_dri_create_fence_fd(__DRIcontext *ctx, int fd)
+{
+   struct brw_context *brw = ctx->driverPrivate;
+   struct brw_fence *fence;
+
+   if (fd == -1) {
+      fence = intel_dri_create_fence(ctx);
+
+      /* XXX defer the flush? Requires ctx later + locking */
+      intel_batchbuffer_flush_fence(brw, &fence->handle);
+
+      return fence;
+   }
+
+   fence = calloc(1, sizeof(*fence));
+   if (!fence)
+      return NULL;
+
+   fence->handle = fd;
+   fence->ops = &fd_ops;
+
+   return fence;
+}
+
+static int
+intel_dri_get_fence_fd(__DRIscreen *screen, void *_fence)
+{
+   struct brw_fence *fence = _fence;
+
+   return dup(fence->handle);
+}
+
 const __DRI2fenceExtension intelFenceExtension = {
    .base = { __DRI2_FENCE, 1 },
 
@@ -391,4 +436,7 @@ const __DRI2fenceExtension intelFenceExtension = {
    .client_wait_sync = intel_dri_client_wait_sync,
    .server_wait_sync = intel_dri_server_wait_sync,
    .get_fence_from_cl_event = NULL,
+   .get_capabilities = intel_dri_get_capabilities,
+   .create_fence_fd = intel_dri_create_fence_fd,
+   .get_fence_fd = intel_dri_get_fence_fd,
 };
-- 
2.9.3



More information about the Intel-gfx mailing list