From bf69ce37f0dcbb479078ee676d5100ac63e20750 Mon Sep 17 00:00:00 2001 From: Stéphane Marchesin Date: Wed, 15 Jun 2011 15:09:12 -0700 Subject: glx: implement drawable refcounting. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The current dri context unbind logic will leak drawables until the process dies (they will then get released by the GEM code). There are two ways to fix this: either always call driReleaseDrawables every time we unbind a context (but that costs us round trips to the X server at getbuffers() time) or implement proper drawable refcounting. This patch implements the latter. Signed-off-by: Antoine Labour Signed-off-by: Stéphane Marchesin Reviewed-by: Adam Jackson --- src/glx/glxcurrent.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/glx/glxcurrent.c') diff --git a/src/glx/glxcurrent.c b/src/glx/glxcurrent.c index 064fd71ae6..9eb7d5ac54 100644 --- a/src/glx/glxcurrent.c +++ b/src/glx/glxcurrent.c @@ -255,8 +255,6 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, if (--oldGC->thread_refcount == 0) { oldGC->vtable->unbind(oldGC, gc); oldGC->currentDpy = 0; - oldGC->currentDrawable = None; - oldGC->currentReadable = None; if (oldGC->xid == None && oldGC != gc) { /* We are switching away from a context that was @@ -268,13 +266,15 @@ MakeContextCurrent(Display * dpy, GLXDrawable draw, } if (gc) { - if (gc->thread_refcount++ == 0) { - gc->currentDpy = dpy; - gc->currentDrawable = draw; - gc->currentReadable = read; - } + if (gc->thread_refcount == 0) + gc->currentDpy = dpy; __glXSetCurrentContext(gc); ret = gc->vtable->bind(gc, oldGC, draw, read); + if (gc->thread_refcount == 0) { + gc->currentDrawable = draw; + gc->currentReadable = read; + } + gc->thread_refcount++; } else { __glXSetCurrentContextNull(); } -- cgit v1.2.3