From b0acc3a5628c6c6dd669cbb7cff2d974b175605e Mon Sep 17 00:00:00 2001 From: Stefan Schake Date: Wed, 25 Apr 2018 00:01:00 +0200 Subject: broadcom/vc4: Native fence fd support With the syncobj support in place, lets use it to implement the EGL_ANDROID_native_fence_sync extension. This mostly follows previous implementations in freedreno and etnaviv. v2: Drop the flags (Eric) Handle in_fence_fd already in job_submit (Eric) Drop extra vc4_fence_context_init (Eric) Dup fds with CLOEXEC (Eric) Mention exact extension name (Eric) Signed-off-by: Stefan Schake Reviewed-by: Eric Anholt --- src/gallium/drivers/vc4/vc4_context.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/gallium/drivers/vc4/vc4_context.c') diff --git a/src/gallium/drivers/vc4/vc4_context.c b/src/gallium/drivers/vc4/vc4_context.c index 0deb3ef85ee..9ff39c2655f 100644 --- a/src/gallium/drivers/vc4/vc4_context.c +++ b/src/gallium/drivers/vc4/vc4_context.c @@ -59,8 +59,17 @@ vc4_pipe_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence, if (fence) { struct pipe_screen *screen = pctx->screen; + int fd = -1; + + if (flags & PIPE_FLUSH_FENCE_FD) { + /* The vc4_fence takes ownership of the returned fd. */ + drmSyncobjExportSyncFile(vc4->fd, vc4->job_syncobj, + &fd); + } + struct vc4_fence *f = vc4_fence_create(vc4->screen, - vc4->last_emit_seqno); + vc4->last_emit_seqno, + fd); screen->fence_reference(screen, fence, NULL); *fence = (struct pipe_fence_handle *)f; } @@ -124,8 +133,12 @@ vc4_context_destroy(struct pipe_context *pctx) vc4_program_fini(pctx); - if (vc4->screen->has_syncobj) + if (vc4->screen->has_syncobj) { drmSyncobjDestroy(vc4->fd, vc4->job_syncobj); + drmSyncobjDestroy(vc4->fd, vc4->in_syncobj); + } + if (vc4->in_fence_fd >= 0) + close(vc4->in_fence_fd); ralloc_free(vc4); } @@ -167,6 +180,10 @@ vc4_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) if (err) goto fail; + err = vc4_fence_context_init(vc4); + if (err) + goto fail; + slab_create_child(&vc4->transfer_pool, &screen->transfer_pool); vc4->uploader = u_upload_create_default(&vc4->base); -- cgit v1.2.3