Mesa (master): egl_dri2: Always unbind old contexts
Kristian Høgsberg
krh at kemper.freedesktop.org
Fri Feb 11 04:52:17 UTC 2011
Module: Mesa
Branch: master
Commit: 4e8f95f64d004aa1278609c5bbac9a53c0c6e4c9
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=4e8f95f64d004aa1278609c5bbac9a53c0c6e4c9
Author: Benjamin Franzke <benjaminfranzke at googlemail.com>
Date: Wed Feb 9 21:19:45 2011 +0100
egl_dri2: Always unbind old contexts
This fixes __DRIdrawable refcounting.
Binding a context increases their refcount,
so we need to decrease it.
---
src/egl/drivers/dri2/egl_dri2.c | 21 +++++++++++----------
1 files changed, 11 insertions(+), 10 deletions(-)
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 2c4deaf..e0d2db9 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -597,19 +597,20 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
rdraw = (dri2_rsurf) ? dri2_rsurf->dri_drawable : 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) ||
dri2_dpy->core->bindContext(cctx, ddraw, rdraw)) {
- drv->API.DestroySurface(drv, disp, old_dsurf);
- drv->API.DestroySurface(drv, disp, old_rsurf);
- if (old_ctx) {
- /* unbind the old context only when there is no new context bound */
- if (!ctx) {
- __DRIcontext *old_cctx = dri2_egl_context(old_ctx)->dri_context;
- dri2_dpy->core->unbindContext(old_cctx);
- }
- /* no destroy? */
+ if (old_dsurf)
+ drv->API.DestroySurface(drv, disp, old_dsurf);
+ if (old_rsurf)
+ drv->API.DestroySurface(drv, disp, old_rsurf);
+ /* no destroy? */
+ if (old_ctx)
_eglPutContext(old_ctx);
- }
return EGL_TRUE;
} else {
More information about the mesa-commit
mailing list