Mesa (main): glx/dri: Fix DRI drawable release at MakeCurrent time

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Jun 27 20:37:33 UTC 2022


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

Author: Adam Jackson <ajax at redhat.com>
Date:   Tue Jun 21 16:07:19 2022 -0400

glx/dri: Fix DRI drawable release at MakeCurrent time

We want to release the drawables of the context we're coming from, but
we were releasing them from the context we're switching to. This is
probably not a big deal normally because both contexts are likely to be
on the same display, which is all that driReleaseDrawables is really
sensitive to. But if the contexts are on different Displays this would
go quite wrong.

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17176>

---

 src/glx/dri2_glx.c       | 2 +-
 src/glx/dri3_glx.c       | 2 +-
 src/glx/dri_common.c     | 2 +-
 src/glx/drisw_glx.c      | 2 +-
 src/glx/driwindows_glx.c | 2 +-
 5 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 216064c27ad..5624e24be5e 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -135,7 +135,7 @@ dri2_bind_context(struct glx_context *context, struct glx_context *old,
    pdraw = (struct dri2_drawable *) driFetchDrawable(context, draw);
    pread = (struct dri2_drawable *) driFetchDrawable(context, read);
 
-   driReleaseDrawables(&pcp->base);
+   driReleaseDrawables(old);
 
    if (pdraw)
       dri_draw = pdraw->driDrawable;
diff --git a/src/glx/dri3_glx.c b/src/glx/dri3_glx.c
index 6370ca05beb..b2ac456b8e4 100644
--- a/src/glx/dri3_glx.c
+++ b/src/glx/dri3_glx.c
@@ -195,7 +195,7 @@ dri3_bind_context(struct glx_context *context, struct glx_context *old,
    pdraw = (struct dri3_drawable *) driFetchDrawable(context, draw);
    pread = (struct dri3_drawable *) driFetchDrawable(context, read);
 
-   driReleaseDrawables(&pcp->base);
+   driReleaseDrawables(old);
 
    if (pdraw)
       dri_draw = pdraw->loader_drawable.dri_drawable;
diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c
index 7e2809d0c79..632506dabbd 100644
--- a/src/glx/dri_common.c
+++ b/src/glx/dri_common.c
@@ -491,7 +491,7 @@ releaseDrawable(const struct glx_display *priv, GLXDrawable drawable)
 _X_HIDDEN void
 driReleaseDrawables(struct glx_context *gc)
 {
-   const struct glx_display *priv = gc->psc->display;
+   const struct glx_display *priv = (gc && gc->psc) ? gc->psc->display : NULL;
 
    if (priv == NULL)
       return;
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index bef171c1ebd..a4051e85b41 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -437,7 +437,7 @@ drisw_bind_context(struct glx_context *context, struct glx_context *old,
    pdraw = (struct drisw_drawable *) driFetchDrawable(context, draw);
    pread = (struct drisw_drawable *) driFetchDrawable(context, read);
 
-   driReleaseDrawables(&pcp->base);
+   driReleaseDrawables(old);
 
    if (!(*psc->core->bindContext) (pcp->driContext,
                                   pdraw ? pdraw->driDrawable : NULL,
diff --git a/src/glx/driwindows_glx.c b/src/glx/driwindows_glx.c
index 3eb961dae3d..8c21c5ee58a 100644
--- a/src/glx/driwindows_glx.c
+++ b/src/glx/driwindows_glx.c
@@ -88,7 +88,7 @@ driwindows_bind_context(struct glx_context *context, struct glx_context *old,
    pdraw = (struct driwindows_drawable *) driFetchDrawable(context, draw);
    pread = (struct driwindows_drawable *) driFetchDrawable(context, read);
 
-   driReleaseDrawables(&pcp->base);
+   driReleaseDrawables(old);
 
    if (pdraw == NULL || pread == NULL)
       return GLXBadDrawable;



More information about the mesa-commit mailing list