Mesa (main): frontend/dri: Fix fence-fd logic

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 7 20:44:50 UTC 2021


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

Author: Rob Clark <robdclark at chromium.org>
Date:   Sun Jun  6 11:02:26 2021 -0700

frontend/dri: Fix fence-fd logic

We can't ask for a fence fd if we don't pass PIPE_FLUSH_FENCE_FD.  Also
don't leak fences.

Fixes: abec42c9a30 ("gallium/dri: implement EGL_KHR_mutable_render_buffer")
Signed-off-by: Rob Clark <robdclark at chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei at chromium.org>
Reviewed-by: Emma Anholt <emma at anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11202>

---

 src/gallium/frontends/dri/dri2.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/gallium/frontends/dri/dri2.c b/src/gallium/frontends/dri/dri2.c
index 128b8f15a75..ebc18a73c86 100644
--- a/src/gallium/frontends/dri/dri2.c
+++ b/src/gallium/frontends/dri/dri2.c
@@ -719,7 +719,13 @@ dri2_flush_frontbuffer(struct dri_context *ctx,
       pipe->flush_resource(pipe, drawable->textures[statt]);
    }
 
-   pipe->flush(pipe, ctx->is_shared_buffer_bound ? &fence : NULL, 0);
+   if (ctx->is_shared_buffer_bound) {
+      /* is_shared_buffer_bound should only be true with image extension: */
+      assert(image);
+      pipe->flush(pipe, &fence, PIPE_FLUSH_FENCE_FD);
+   } else {
+      pipe->flush(pipe, NULL, 0);
+   }
 
    if (image) {
       image->flushFrontBuffer(dri_drawable, dri_drawable->loaderPrivate);
@@ -729,6 +735,8 @@ dri2_flush_frontbuffer(struct dri_context *ctx,
 
          shared_buffer_loader->displaySharedBuffer(dri_drawable, fence_fd,
                                                    dri_drawable->loaderPrivate);
+
+         pipe->screen->fence_reference(pipe->screen, &fence, NULL);
       }
    }
    else if (loader->flushFrontBuffer) {



More information about the mesa-commit mailing list