radeonsi: Export signalled sync file instead of -1.
authorBas Nieuwenhuizen <basni@chromium.org>
Thu, 25 Jan 2018 15:48:17 +0000 (16:48 +0100)
committerBas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Fri, 26 Jan 2018 00:26:53 +0000 (01:26 +0100)
-1 is considered an error for EGL_ANDROID_native_fence_sync, so
we need to actually create a sync file.

Fixes: f536f45250 "radeonsi: implement sync_file import/export"
Reviewed-by: Dave Airlie <airlied@redhat.com>
src/gallium/drivers/radeon/radeon_winsys.h
src/gallium/drivers/radeonsi/si_fence.c
src/gallium/winsys/amdgpu/drm/amdgpu_cs.c

index d1c761f4eeab8a136813435c64348cc09b5dd9ea..307f8efaec084775d5bd423c4708d78cd0d3f899 100644 (file)
@@ -610,6 +610,11 @@ struct radeon_winsys {
     int (*fence_export_sync_file)(struct radeon_winsys *ws,
                                  struct pipe_fence_handle *fence);
 
+    /**
+     * Return a sync file FD that is already signalled.
+     */
+    int (*export_signalled_sync_file)(struct radeon_winsys *ws);
+
     /**
      * Initialize surface
      *
index 5f320803aaecd5f0f1916ae1c0af83249facccb3..47d68dbc3370c023803db3b215b8040c0cc99b3f 100644 (file)
@@ -356,6 +356,8 @@ static int si_fence_get_fd(struct pipe_screen *screen,
 
        /* If we don't have FDs at this point, it means we don't have fences
         * either. */
+       if (sdma_fd == -1 && gfx_fd == -1)
+               return ws->export_signalled_sync_file(ws);
        if (sdma_fd == -1)
                return gfx_fd;
        if (gfx_fd == -1)
index 63cd63287fd7737343487dbfa301ad4099377e94..0c778534606d7485ebd06c375e7bab1f73b8e0f0 100644 (file)
@@ -114,6 +114,27 @@ static int amdgpu_fence_export_sync_file(struct radeon_winsys *rws,
    return fd;
 }
 
+static int amdgpu_export_signalled_sync_file(struct radeon_winsys *rws)
+{
+   struct amdgpu_winsys *ws = amdgpu_winsys(rws);
+   uint32_t syncobj;
+   int fd = -1;
+
+   int r = amdgpu_cs_create_syncobj2(ws->dev, DRM_SYNCOBJ_CREATE_SIGNALED,
+                                     &syncobj);
+   if (r) {
+      return -1;
+   }
+
+   r = amdgpu_cs_syncobj_export_sync_file(ws->dev, syncobj, &fd);
+   if (r) {
+      fd = -1;
+   }
+
+   amdgpu_cs_destroy_syncobj(ws->dev, syncobj);
+   return fd;
+}
+
 static void amdgpu_fence_submitted(struct pipe_fence_handle *fence,
                                    uint64_t seq_no,
                                    uint64_t *user_fence_cpu_address)
@@ -1560,4 +1581,5 @@ void amdgpu_cs_init_functions(struct amdgpu_winsys *ws)
    ws->base.fence_reference = amdgpu_fence_reference;
    ws->base.fence_import_sync_file = amdgpu_fence_import_sync_file;
    ws->base.fence_export_sync_file = amdgpu_fence_export_sync_file;
+   ws->base.export_signalled_sync_file = amdgpu_export_signalled_sync_file;
 }