diff options
author | Stefan Schake <[email protected]> | 2018-04-25 00:01:00 +0200 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2018-05-17 16:04:30 +0100 |
commit | b0acc3a5628c6c6dd669cbb7cff2d974b175605e (patch) | |
tree | ef0d04117ae2f56fc3c891e4baf1cb93974af265 /src/gallium/drivers/vc4/vc4_context.c | |
parent | 44036c354d800dda08d3688b042130039f3d592a (diff) |
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 <[email protected]>
Reviewed-by: Eric Anholt <[email protected]>
Diffstat (limited to 'src/gallium/drivers/vc4/vc4_context.c')
-rw-r--r-- | src/gallium/drivers/vc4/vc4_context.c | 21 |
1 files changed, 19 insertions, 2 deletions
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); |