Module: Mesa
Branch: master
Commit: 141b295311aed28d64a850531490d2044f5b6a78
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=141b295311aed28d64a850531490d2044f5b6a78

Author: Rob Clark <[email protected]>
Date:   Tue Aug  4 14:24:44 2020 -0700

freedreno: allow fence_fd fences to be recycled

This allows us to avoid a no-op flush if there has been no rendering,
but we hit pctx->flush(PIPE_FLUSH_FENCE_FD).

Signed-off-by: Rob Clark <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6177>

---

 src/gallium/drivers/freedreno/freedreno_context.c | 3 ++-
 src/gallium/drivers/freedreno/freedreno_fence.c   | 5 +++++
 src/gallium/drivers/freedreno/freedreno_fence.h   | 1 +
 3 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_context.c 
b/src/gallium/drivers/freedreno/freedreno_context.c
index a69a194379b..4ebb279bc3b 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.c
+++ b/src/gallium/drivers/freedreno/freedreno_context.c
@@ -60,7 +60,8 @@ fd_context_flush(struct pipe_context *pctx, struct 
pipe_fence_handle **fencep,
         * not an "fd" fence, which results in eglDupNativeFenceFDANDROID()
         * errors.
         */
-       if (flags & PIPE_FLUSH_FENCE_FD)
+       if ((flags & PIPE_FLUSH_FENCE_FD) && ctx->last_fence &&
+                       !fd_fence_is_fd(ctx->last_fence))
                fd_fence_ref(&ctx->last_fence, NULL);
 
        /* if no rendering since last flush, ie. app just decided it needed
diff --git a/src/gallium/drivers/freedreno/freedreno_fence.c 
b/src/gallium/drivers/freedreno/freedreno_fence.c
index 59ea1896f45..3477d9835c5 100644
--- a/src/gallium/drivers/freedreno/freedreno_fence.c
+++ b/src/gallium/drivers/freedreno/freedreno_fence.c
@@ -150,6 +150,11 @@ int fd_fence_get_fd(struct pipe_screen *pscreen,
        return os_dupfd_cloexec(fence->fence_fd);
 }
 
+bool fd_fence_is_fd(struct pipe_fence_handle *fence)
+{
+       return fence->fence_fd != -1;
+}
+
 struct pipe_fence_handle * fd_fence_create(struct fd_batch *batch)
 {
        return fence_create(batch->ctx, batch, 0, -1);
diff --git a/src/gallium/drivers/freedreno/freedreno_fence.h 
b/src/gallium/drivers/freedreno/freedreno_fence.h
index f0bc21bc890..efb9aaee166 100644
--- a/src/gallium/drivers/freedreno/freedreno_fence.h
+++ b/src/gallium/drivers/freedreno/freedreno_fence.h
@@ -44,6 +44,7 @@ void fd_fence_server_sync(struct pipe_context *pctx,
                struct pipe_fence_handle *fence);
 int fd_fence_get_fd(struct pipe_screen *pscreen,
                struct pipe_fence_handle *pfence);
+bool fd_fence_is_fd(struct pipe_fence_handle *fence);
 
 struct fd_batch;
 struct pipe_fence_handle * fd_fence_create(struct fd_batch *batch);

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to