Mesa (master): freedreno: fix eglDupNativeFenceFD error

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Nov 12 19:53:00 UTC 2019


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

Author: Rob Clark <robdclark at chromium.org>
Date:   Tue Nov 12 09:01:34 2019 -0800

freedreno: fix eglDupNativeFenceFD error

We can end up with scenarios where last_fence is associated with a batch
that is flushed through some other path before needs_out_fence_fd gets
set.  Resulting in returning a fence that has no backing fd.

The simplest thing is to just skip the optimization to try and avoid
no-op batches when a fence-fd is requested.  This should normally be
just once a frame anyways.

Signed-off-by: Rob Clark <robdclark at chromium.org>
Reviewed-by: Kristian H. Kristensen <hoegsberg at google.com>

---

 src/gallium/drivers/freedreno/freedreno_context.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/freedreno/freedreno_context.c b/src/gallium/drivers/freedreno/freedreno_context.c
index b2ac396d9d1..ca3b793000d 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.c
+++ b/src/gallium/drivers/freedreno/freedreno_context.c
@@ -49,6 +49,14 @@ fd_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fencep,
 
 	DBG("%p: flush: flags=%x\n", ctx->batch, flags);
 
+	/* In some sequence of events, we can end up with a last_fence that is
+	 * not an "fd" fence, which results in eglDupNativeFenceFDANDROID()
+	 * errors.
+	 *
+	 */
+	if (flags & PIPE_FLUSH_FENCE_FD)
+		fd_fence_ref(&ctx->last_fence, NULL);
+
 	/* if no rendering since last flush, ie. app just decided it needed
 	 * a fence, re-use the last one:
 	 */
@@ -63,10 +71,8 @@ fd_context_flush(struct pipe_context *pctx, struct pipe_fence_handle **fencep,
 	/* Take a ref to the batch's fence (batch can be unref'd when flushed: */
 	fd_fence_ref(&fence, batch->fence);
 
-	/* TODO is it worth trying to figure out if app is using fence-fd's, to
-	 * avoid requesting one every batch?
-	 */
-	batch->needs_out_fence_fd = true;
+	if (flags & PIPE_FLUSH_FENCE_FD)
+		batch->needs_out_fence_fd = true;
 
 	if (!ctx->screen->reorder) {
 		fd_batch_flush(batch, true);




More information about the mesa-commit mailing list