radv/winsys: add syncobj hooks
authorDave Airlie <airlied@redhat.com>
Tue, 18 Jul 2017 05:00:44 +0000 (06:00 +0100)
committerDave Airlie <airlied@redhat.com>
Fri, 21 Jul 2017 20:31:54 +0000 (21:31 +0100)
This just adds syncobj create/destroy/export/import paths into
the winsys interface.

Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Signed-off-by: Dave Airlie <airlied@redhat.com>
src/amd/vulkan/radv_radeon_winsys.h
src/amd/vulkan/winsys/amdgpu/radv_amdgpu_cs.c

index cdcaeca46eca6ac922e4af3918641d77cae2e971..2f3990c891c53f03fbdcb053ccd581439fe44b5c 100644 (file)
@@ -221,9 +221,17 @@ struct radeon_winsys {
                           bool absolute,
                           uint64_t timeout);
 
+       /* old semaphores - non shareable */
        struct radeon_winsys_sem *(*create_sem)(struct radeon_winsys *ws);
        void (*destroy_sem)(struct radeon_winsys_sem *sem);
 
+       /* new shareable sync objects */
+       int (*create_syncobj)(struct radeon_winsys *ws, uint32_t *handle);
+       void (*destroy_syncobj)(struct radeon_winsys *ws, uint32_t handle);
+
+       int (*export_syncobj)(struct radeon_winsys *ws, uint32_t syncobj, int *fd);
+       int (*import_syncobj)(struct radeon_winsys *ws, int fd, uint32_t *syncobj);
+
 };
 
 static inline void radeon_emit(struct radeon_winsys_cs *cs, uint32_t value)
index 93243dfd135a65a2e7839694bd10c5e47d0ce197..6ed8f32604f28e3c80c5735b7e769aeda982745d 100644 (file)
@@ -1172,6 +1172,38 @@ error_out:
        return r;
 }
 
+static int radv_amdgpu_create_syncobj(struct radeon_winsys *_ws,
+                                     uint32_t *handle)
+{
+       struct radv_amdgpu_winsys *ws = radv_amdgpu_winsys(_ws);
+       return amdgpu_cs_create_syncobj(ws->dev, handle);
+}
+
+static void radv_amdgpu_destroy_syncobj(struct radeon_winsys *_ws,
+                                   uint32_t handle)
+{
+       struct radv_amdgpu_winsys *ws = radv_amdgpu_winsys(_ws);
+       amdgpu_cs_destroy_syncobj(ws->dev, handle);
+}
+
+static int radv_amdgpu_export_syncobj(struct radeon_winsys *_ws,
+                                     uint32_t syncobj,
+                                     int *fd)
+{
+       struct radv_amdgpu_winsys *ws = radv_amdgpu_winsys(_ws);
+
+       return amdgpu_cs_export_syncobj(ws->dev, syncobj, fd);
+}
+
+static int radv_amdgpu_import_syncobj(struct radeon_winsys *_ws,
+                                     int fd,
+                                     uint32_t *syncobj)
+{
+       struct radv_amdgpu_winsys *ws = radv_amdgpu_winsys(_ws);
+
+       return amdgpu_cs_import_syncobj(ws->dev, fd, syncobj);
+}
+
 void radv_amdgpu_cs_init_functions(struct radv_amdgpu_winsys *ws)
 {
        ws->base.ctx_create = radv_amdgpu_ctx_create;
@@ -1190,5 +1222,9 @@ void radv_amdgpu_cs_init_functions(struct radv_amdgpu_winsys *ws)
        ws->base.destroy_fence = radv_amdgpu_destroy_fence;
        ws->base.create_sem = radv_amdgpu_create_sem;
        ws->base.destroy_sem = radv_amdgpu_destroy_sem;
+       ws->base.create_syncobj = radv_amdgpu_create_syncobj;
+       ws->base.destroy_syncobj = radv_amdgpu_destroy_syncobj;
+       ws->base.export_syncobj = radv_amdgpu_export_syncobj;
+       ws->base.import_syncobj = radv_amdgpu_import_syncobj;
        ws->base.fence_wait = radv_amdgpu_fence_wait;
 }