glx/dri: Fix DRI drawable release at MakeCurrent time
authorAdam Jackson <ajax@redhat.com>
Tue, 21 Jun 2022 20:07:19 +0000 (16:07 -0400)
committerMarge Bot <emma+marge@anholt.net>
Mon, 27 Jun 2022 20:03:26 +0000 (20:03 +0000)
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
src/glx/dri3_glx.c
src/glx/dri_common.c
src/glx/drisw_glx.c
src/glx/driwindows_glx.c

index 216064c..5624e24 100644 (file)
@@ -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;
index 6370ca0..b2ac456 100644 (file)
@@ -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;
index 7e2809d..632506d 100644 (file)
@@ -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;
index bef171c..a4051e8 100644 (file)
@@ -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,
index 3eb961d..8c21c5e 100644 (file)
@@ -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;