summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2022-06-21 16:07:19 -0400
committerMarge Bot <emma+marge@anholt.net>2022-06-27 20:03:26 +0000
commit31b04e420b0eb080084c6323066ea0b83929d59e (patch)
treeedba689e117ebf36674a48db9895cb46e87edbdd
parent59944831a794e3797839fd7066e34c802c69d43e (diff)
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>
-rw-r--r--src/glx/dri2_glx.c2
-rw-r--r--src/glx/dri3_glx.c2
-rw-r--r--src/glx/dri_common.c2
-rw-r--r--src/glx/drisw_glx.c2
-rw-r--r--src/glx/driwindows_glx.c2
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;