From 56a6e890f32a51c91fa4feb78dc5a1a22e8008d9 Mon Sep 17 00:00:00 2001 From: Sinclair Yeh Date: Mon, 15 May 2017 16:22:53 -0700 Subject: [PATCH] drivers/svga: Connect driver-side fence_* functions Connect fence_get_fd, fence_create_fd, and fence_server_sync. Return PIPE_CAP_NATIVE_FENCE_FD capability based on what the winsys reports Reviewed-by: Brian Paul Reviewed-by: Charmaine Lee --- src/gallium/drivers/svga/svga_pipe_flush.c | 41 ++++++++++++++++++++++++++++++ src/gallium/drivers/svga/svga_screen.c | 16 +++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/svga/svga_pipe_flush.c b/src/gallium/drivers/svga/svga_pipe_flush.c index 8e0af12..85ec34f 100644 --- a/src/gallium/drivers/svga/svga_pipe_flush.c +++ b/src/gallium/drivers/svga/svga_pipe_flush.c @@ -42,6 +42,9 @@ static void svga_flush( struct pipe_context *pipe, */ svga_surfaces_flush( svga ); + if (flags & PIPE_FLUSH_FENCE_FD) + svga->swc->hints |= SVGA_HINT_FLAG_EXPORT_FENCE_FD; + /* Flush command queue. */ svga_context_flush(svga, fence); @@ -71,7 +74,45 @@ static void svga_flush( struct pipe_context *pipe, } +/** + * svga_create_fence_fd + * + * Wraps a SVGA fence around an imported file descriptor. This + * fd represents a fence from another process/device. The fence created + * here can then be fed into fence_server_sync() so SVGA can synchronize + * with an external process + */ +static void +svga_create_fence_fd(struct pipe_context *pipe, + struct pipe_fence_handle **fence, + int fd) +{ + struct svga_winsys_screen *sws = svga_winsys_screen(pipe->screen); + + sws->fence_create_fd(sws, fence, fd); +} + + +/** + * svga_fence_server_sync + * + * This function imports a fence from another process/device into the current + * software context so that SVGA can synchronize with it. + */ +static void +svga_fence_server_sync(struct pipe_context *pipe, + struct pipe_fence_handle *fence) +{ + struct svga_winsys_screen *sws = svga_winsys_screen(pipe->screen); + struct svga_context *svga = svga_context(pipe); + + sws->fence_server_sync(sws, &svga->swc->imported_fence_fd, fence); +} + + void svga_init_flush_functions( struct svga_context *svga ) { svga->pipe.flush = svga_flush; + svga->pipe.create_fence_fd = svga_create_fence_fd; + svga->pipe.fence_server_sync = svga_fence_server_sync; } diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c index 1368267..1ec91e5 100644 --- a/src/gallium/drivers/svga/svga_screen.c +++ b/src/gallium/drivers/svga/svga_screen.c @@ -337,6 +337,9 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_GENERATE_MIPMAP: return sws->have_generate_mipmap_cmd; + case PIPE_CAP_NATIVE_FENCE_FD: + return sws->have_fence_fd; + /* Unsupported features */ case PIPE_CAP_QUADS_FOLLOW_PROVOKING_VERTEX_CONVENTION: case PIPE_CAP_TEXTURE_MIRROR_CLAMP: @@ -380,7 +383,6 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param) case PIPE_CAP_PCI_DEVICE: case PIPE_CAP_PCI_FUNCTION: case PIPE_CAP_ROBUST_BUFFER_ACCESS_BEHAVIOR: - case PIPE_CAP_NATIVE_FENCE_FD: return 0; case PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT: return 64; @@ -864,6 +866,16 @@ svga_fence_finish(struct pipe_screen *screen, static int +svga_fence_get_fd(struct pipe_screen *screen, + struct pipe_fence_handle *fence) +{ + struct svga_winsys_screen *sws = svga_screen(screen)->sws; + + return sws->fence_get_fd(sws, fence, TRUE); +} + + +static int svga_get_driver_query_info(struct pipe_screen *screen, unsigned index, struct pipe_driver_query_info *info) @@ -1024,6 +1036,8 @@ svga_screen_create(struct svga_winsys_screen *sws) screen->context_create = svga_context_create; screen->fence_reference = svga_fence_reference; screen->fence_finish = svga_fence_finish; + screen->fence_get_fd = svga_fence_get_fd; + screen->get_driver_query_info = svga_get_driver_query_info; svgascreen->sws = sws; -- 2.7.4