diff options
author | Rob Clark <[email protected]> | 2016-08-15 14:27:10 -0400 |
---|---|---|
committer | Rob Clark <[email protected]> | 2016-12-01 20:24:46 -0500 |
commit | 0b98e84e9ba082b9aa00b24fded3fb56224c6fc6 (patch) | |
tree | 8f3800c82abf2e071d2539e5a08d73f6d2bf5ad3 /src/gallium/drivers/freedreno/freedreno_fence.c | |
parent | 16f6ceaca9e25f86bcdc509fc0abb48e2d51c3fa (diff) |
freedreno: native fence fd support
Signed-off-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/gallium/drivers/freedreno/freedreno_fence.c')
-rw-r--r-- | src/gallium/drivers/freedreno/freedreno_fence.c | 46 |
1 files changed, 42 insertions, 4 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_fence.c b/src/gallium/drivers/freedreno/freedreno_fence.c index a5f717169f9..f20c6ac120e 100644 --- a/src/gallium/drivers/freedreno/freedreno_fence.c +++ b/src/gallium/drivers/freedreno/freedreno_fence.c @@ -26,6 +26,8 @@ * Rob Clark <[email protected]> */ +#include <libsync.h> + #include "util/u_inlines.h" #include "freedreno_fence.h" @@ -36,16 +38,23 @@ struct pipe_fence_handle { struct pipe_reference reference; struct fd_context *ctx; struct fd_screen *screen; + int fence_fd; uint32_t timestamp; }; -void -fd_fence_ref(struct pipe_screen *pscreen, +static void fd_fence_destroy(struct pipe_fence_handle *fence) +{ + if (fence->fence_fd != -1) + close(fence->fence_fd); + FREE(fence); +} + +void fd_fence_ref(struct pipe_screen *pscreen, struct pipe_fence_handle **ptr, struct pipe_fence_handle *pfence) { if (pipe_reference(&(*ptr)->reference, &pfence->reference)) - FREE(*ptr); + fd_fence_destroy(*ptr); *ptr = pfence; } @@ -55,14 +64,42 @@ boolean fd_fence_finish(struct pipe_screen *pscreen, struct pipe_fence_handle *fence, uint64_t timeout) { + if (fence->fence_fd != -1) { + int ret = sync_wait(fence->fence_fd, timeout / 1000000); + return ret == 0; + } + if (fd_pipe_wait_timeout(fence->screen->pipe, fence->timestamp, timeout)) return false; return true; } +void fd_create_fence_fd(struct pipe_context *pctx, + struct pipe_fence_handle **pfence, int fd) +{ + *pfence = fd_fence_create(fd_context(pctx), 0, dup(fd)); +} + +void fd_fence_server_sync(struct pipe_context *pctx, + struct pipe_fence_handle *fence) +{ + struct fd_context *ctx = fd_context(pctx); + struct fd_batch *batch = ctx->batch; + + if (sync_accumulate("freedreno", &batch->in_fence_fd, fence->fence_fd)) { + /* error */ + } +} + +int fd_fence_get_fd(struct pipe_screen *pscreen, + struct pipe_fence_handle *fence) +{ + return dup(fence->fence_fd); +} + struct pipe_fence_handle * fd_fence_create(struct fd_context *ctx, - uint32_t timestamp) + uint32_t timestamp, int fence_fd) { struct pipe_fence_handle *fence; @@ -75,6 +112,7 @@ struct pipe_fence_handle * fd_fence_create(struct fd_context *ctx, fence->ctx = ctx; fence->screen = ctx->screen; fence->timestamp = timestamp; + fence->fence_fd = fence_fd; return fence; } |