egl_dri2: Always unbind old contexts
This fixes __DRIdrawable refcounting. Binding a context increases their refcount, so we need to decrease it.
This commit is contained in:
parent
87dde5b1cd
commit
4e8f95f64d
|
@ -597,19 +597,20 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
|
||||||
rdraw = (dri2_rsurf) ? dri2_rsurf->dri_drawable : NULL;
|
rdraw = (dri2_rsurf) ? dri2_rsurf->dri_drawable : NULL;
|
||||||
cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
|
cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
|
||||||
|
|
||||||
|
if (old_ctx) {
|
||||||
|
__DRIcontext *old_cctx = dri2_egl_context(old_ctx)->dri_context;
|
||||||
|
dri2_dpy->core->unbindContext(old_cctx);
|
||||||
|
}
|
||||||
|
|
||||||
if ((cctx == NULL && ddraw == NULL && rdraw == NULL) ||
|
if ((cctx == NULL && ddraw == NULL && rdraw == NULL) ||
|
||||||
dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) {
|
dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) {
|
||||||
drv->API.DestroySurface(drv, disp, old_dsurf);
|
if (old_dsurf)
|
||||||
drv->API.DestroySurface(drv, disp, old_rsurf);
|
drv->API.DestroySurface(drv, disp, old_dsurf);
|
||||||
if (old_ctx) {
|
if (old_rsurf)
|
||||||
/* unbind the old context only when there is no new context bound */
|
drv->API.DestroySurface(drv, disp, old_rsurf);
|
||||||
if (!ctx) {
|
/* no destroy? */
|
||||||
__DRIcontext *old_cctx = dri2_egl_context(old_ctx)->dri_context;
|
if (old_ctx)
|
||||||
dri2_dpy->core->unbindContext(old_cctx);
|
|
||||||
}
|
|
||||||
/* no destroy? */
|
|
||||||
_eglPutContext(old_ctx);
|
_eglPutContext(old_ctx);
|
||||||
}
|
|
||||||
|
|
||||||
return EGL_TRUE;
|
return EGL_TRUE;
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue