diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h index 25b4920b480..86e30283bc2 100644 --- a/src/gallium/drivers/freedreno/freedreno_context.h +++ b/src/gallium/drivers/freedreno/freedreno_context.h @@ -324,6 +324,12 @@ struct fd_context { */ int in_fence_fd dt; + /** + * If we *ever* see an in-fence-fd, assume that userspace is + * not relying on implicit fences. + */ + bool no_implicit_sync; + /* track last known reset status globally and per-context to * determine if more resets occurred since then. If global reset * count increases, it means some other context crashed. If diff --git a/src/gallium/drivers/freedreno/freedreno_fence.c b/src/gallium/drivers/freedreno/freedreno_fence.c index 82b63b2452d..da592de2b3f 100644 --- a/src/gallium/drivers/freedreno/freedreno_fence.c +++ b/src/gallium/drivers/freedreno/freedreno_fence.c @@ -237,6 +237,8 @@ fd_pipe_fence_server_sync(struct pipe_context *pctx, struct pipe_fence_handle *f if (!fence->use_fence_fd) return; + ctx->no_implicit_sync = true; + assert(fence->fence); if (sync_accumulate("freedreno", &ctx->in_fence_fd, fence->fence->fence_fd)) { /* error */ diff --git a/src/gallium/drivers/freedreno/freedreno_resource.c b/src/gallium/drivers/freedreno/freedreno_resource.c index 6216c6edd96..31a9a895ccc 100644 --- a/src/gallium/drivers/freedreno/freedreno_resource.c +++ b/src/gallium/drivers/freedreno/freedreno_resource.c @@ -702,6 +702,14 @@ fd_flush_resource(struct pipe_context *pctx, struct pipe_resource *prsc) struct fd_context *ctx = fd_context(pctx); struct fd_resource *rsc = fd_resource(prsc); + /* Flushing the resource is only required if we are relying on + * implicit-sync, in which case the rendering must be flushed + * to the kernel for the fence to be added to the backing GEM + * object. + */ + if (ctx->no_implicit_sync) + return; + flush_resource(ctx, rsc, PIPE_MAP_READ); /* If we had to flush a batch, make sure it makes it's way all the