diff options
author | Rob Clark <[email protected]> | 2015-02-15 00:04:57 -0500 |
---|---|---|
committer | Rob Clark <[email protected]> | 2015-02-21 17:11:02 -0500 |
commit | e17437386c1bf715b6b241bd9de3a583103f851b (patch) | |
tree | aa7a3c48f16afd40923278109d480d564479bf0c /src/gallium/drivers/freedreno/freedreno_fence.c | |
parent | 68552266535747bad1eff34d856c43158398b9bf (diff) |
freedreno: implement fence
I never actually implemented the stubbed out fence stuff back in the
early days. Fix that.
We'll need a few libdrm_freedreno changes to handle timeout properly,
so ignore that for now to avoid a libdrm_freedreno dependency bump.
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 | 60 |
1 files changed, 50 insertions, 10 deletions
diff --git a/src/gallium/drivers/freedreno/freedreno_fence.c b/src/gallium/drivers/freedreno/freedreno_fence.c index e6374655f5b..46b057d9062 100644 --- a/src/gallium/drivers/freedreno/freedreno_fence.c +++ b/src/gallium/drivers/freedreno/freedreno_fence.c @@ -26,27 +26,67 @@ * Rob Clark <[email protected]> */ +#include "util/u_inlines.h" + #include "freedreno_fence.h" +#include "freedreno_context.h" #include "freedreno_util.h" -boolean -fd_fence_wait(struct fd_fence *fence) +struct pipe_fence_handle { + struct pipe_reference reference; + struct fd_context *ctx; + uint32_t timestamp; +}; + +void +fd_screen_fence_ref(struct pipe_screen *pscreen, + struct pipe_fence_handle **ptr, + struct pipe_fence_handle *pfence) { - DBG("TODO: "); - return false; + if (pipe_reference(&(*ptr)->reference, &pfence->reference)) + FREE(*ptr); + + *ptr = pfence; } -boolean -fd_fence_signalled(struct fd_fence *fence) +/* TODO we need to spiff out libdrm_freedreno a bit to allow passing + * the timeout.. and maybe a better way to check if fence has been + * signaled. The current implementation is a bit lame for now to + * avoid bumping libdrm version requirement. + */ + +boolean fd_screen_fence_signalled(struct pipe_screen *screen, + struct pipe_fence_handle *fence) { - DBG("TODO: "); - return false; + uint32_t timestamp = fd_ringbuffer_timestamp(fence->ctx->ring); + + /* TODO util helper for compare w/ rollover? */ + return timestamp >= fence->timestamp; } -void -fd_fence_del(struct fd_fence *fence) +boolean fd_screen_fence_finish(struct pipe_screen *screen, + struct pipe_fence_handle *fence, + uint64_t timeout) { + if (fd_pipe_wait(fence->ctx->screen->pipe, fence->timestamp)) + return false; + return true; } +struct pipe_fence_handle * fd_fence_create(struct pipe_context *pctx) +{ + struct pipe_fence_handle *fence; + struct fd_context *ctx = fd_context(pctx); + + fence = CALLOC_STRUCT(pipe_fence_handle); + if (!fence) + return NULL; + pipe_reference_init(&fence->reference, 1); + + fence->ctx = ctx; + fence->timestamp = fd_ringbuffer_timestamp(ctx->ring); + + return fence; +} |