diff --git a/src/glx/dri_common.c b/src/glx/dri_common.c index 2db29fd6abb..2f141acae83 100644 --- a/src/glx/dri_common.c +++ b/src/glx/dri_common.c @@ -393,24 +393,24 @@ driReleaseDrawables(struct glx_context *gc) return; if (__glxHashLookup(priv->drawHash, - gc->currentDrawable, (void *) &pdraw) == 0) { + gc->currentDrawable, (void *) &pdraw) == 0) { if (pdraw->drawable == pdraw->xDrawable) { - pdraw->refcount --; - if (pdraw->refcount == 0) { - (*pdraw->destroyDrawable)(pdraw); - __glxHashDelete(priv->drawHash, gc->currentDrawable); - } + pdraw->refcount --; + if (pdraw->refcount == 0) { + (*pdraw->destroyDrawable)(pdraw); + __glxHashDelete(priv->drawHash, gc->currentDrawable); + } } } if (__glxHashLookup(priv->drawHash, - gc->currentReadable, (void *) &pdraw) == 0) { + gc->currentReadable, (void *) &pdraw) == 0) { if (pdraw->drawable == pdraw->xDrawable) { - pdraw->refcount --; - if (pdraw->refcount == 0) { - (*pdraw->destroyDrawable)(pdraw); - __glxHashDelete(priv->drawHash, gc->currentReadable); - } + pdraw->refcount --; + if (pdraw->refcount == 0) { + (*pdraw->destroyDrawable)(pdraw); + __glxHashDelete(priv->drawHash, gc->currentReadable); + } } } diff --git a/src/mapi/u_current.c b/src/mapi/u_current.c index 1402cea45d5..e3ad1db5839 100644 --- a/src/mapi/u_current.c +++ b/src/mapi/u_current.c @@ -220,13 +220,14 @@ u_current_init(void) +#include "stdio.h" /** * Set the current context pointer for this thread. * The context pointer is an opaque type which should be cast to * void from the real context pointer type. */ void -u_current_set_context(const void *ptr) +_u_current_set_context(const void *ptr, const char *func) { u_current_init(); @@ -236,6 +237,7 @@ u_current_set_context(const void *ptr) tss_set(u_current_context_tsd, (void *) ptr); u_current_context = (ThreadSafe) ? NULL : (void *) ptr; #endif + fprintf (stderr, "%s u_current_context: %p from %s \n", __func__, u_current_context, func); } /** @@ -247,8 +249,10 @@ void * u_current_get_context_internal(void) { #if defined(GLX_USE_TLS) + fprintf (stderr, "%s tls u_current_context: %p \n", __func__, u_current_context); return u_current_context; #else + fprintf (stderr, "%s nottls ThreadSafe: %d u_current_context: %p \n", __func__, ThreadSafe, ThreadSafe ? tss_get(u_current_context_tsd) : u_current_context); return ThreadSafe ? tss_get(u_current_context_tsd) : u_current_context; #endif } diff --git a/src/mapi/u_current.h b/src/mapi/u_current.h index 3c9a414ee84..44c261c6604 100644 --- a/src/mapi/u_current.h +++ b/src/mapi/u_current.h @@ -57,7 +57,10 @@ struct _glapi_table * u_current_get_table_internal(void); void -u_current_set_context(const void *ptr); +_u_current_set_context(const void *ptr, const char *func); + +#define u_current_set_context(ptr) \ + _u_current_set_context(ptr, __func__) void * u_current_get_context_internal(void); diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index ac3a04bceff..9a8850c43c0 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -545,8 +545,33 @@ driCopyContext(__DRIcontext *dest, __DRIcontext *src, unsigned long mask) /*****************************************************************/ /*@{*/ -static void dri_get_drawable(__DRIdrawable *pdp); -static void dri_put_drawable(__DRIdrawable *pdp); +static void _dri_get_drawable(__DRIdrawable *pdp, const char *func) +{ + pdp->refcount++; + + fprintf(stderr, "%s pdp: %p, refcount: %d from: %s \n", + __func__, pdp, pdp ? pdp->refcount : 0, func); +} + +#define dri_get_drawable(pdp) \ + _dri_get_drawable(pdp, __func__) + +static void _dri_put_drawable(__DRIdrawable *pdp, const char *func) +{ + fprintf(stderr, "%s pdp: %p, refcount: %d from: %s \n", + __func__, pdp, pdp ? pdp->refcount - 1 : 0, func); + if (pdp) { + pdp->refcount--; + if (pdp->refcount) + return; + + pdp->driScreenPriv->driver->DestroyBuffer(pdp); + free(pdp); + } +} + +#define dri_put_drawable(pdp) \ + _dri_put_drawable(pdp, __func__) /** * This function takes both a read buffer and a draw buffer. This is needed @@ -647,22 +672,6 @@ static int driUnbindContext(__DRIcontext *pcp) /*@}*/ -static void dri_get_drawable(__DRIdrawable *pdp) -{ - pdp->refcount++; -} - -static void dri_put_drawable(__DRIdrawable *pdp) -{ - if (pdp) { - pdp->refcount--; - if (pdp->refcount) - return; - - pdp->driScreenPriv->driver->DestroyBuffer(pdp); - free(pdp); - } -} static __DRIdrawable * driCreateNewDrawable(__DRIscreen *screen, diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index c3d4784e94c..de5b5fe9126 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -1228,7 +1228,10 @@ intelDestroyContext(__DRIcontext * driContextPriv) GLboolean intelUnbindContext(__DRIcontext * driContextPriv) { - GET_CURRENT_CONTEXT(ctx); + //GET_CURRENT_CONTEXT(ctx); + struct gl_context *ctx = (struct gl_context *) (likely(_glapi_Context) + ? _glapi_Context : _glapi_get_context()); + fprintf (stderr, "%s _glapi_Context: %p \n", __func__, _glapi_Context); _mesa_glthread_finish(ctx); /* Unset current context and dispath table */ diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c index d84793f71f8..cc5c4436263 100644 --- a/src/mesa/drivers/dri/i965/intel_screen.c +++ b/src/mesa/drivers/dri/i965/intel_screen.c @@ -1688,6 +1688,7 @@ static void intelDestroyScreen(__DRIscreen * sPriv) { struct intel_screen *screen = sPriv->driverPrivate; + fprintf(stderr, "meml %s \n", __func__); brw_bufmgr_destroy(screen->bufmgr); driDestroyOptionInfo(&screen->optionCache); @@ -2485,6 +2486,7 @@ __DRIconfig **intelInitScreen2(__DRIscreen *dri_screen) { struct intel_screen *screen; + fprintf(stderr, "meml %s \n", __func__); if (dri_screen->image.loader) { } else if (dri_screen->dri2.loader->base.version <= 2 || dri_screen->dri2.loader->getBuffersWithFormat == NULL) { diff --git a/src/mesa/main/glthread.c b/src/mesa/main/glthread.c index 145c5199978..151b4304f49 100644 --- a/src/mesa/main/glthread.c +++ b/src/mesa/main/glthread.c @@ -181,7 +181,7 @@ _mesa_glthread_flush_batch(struct gl_context *ctx) void _mesa_glthread_finish(struct gl_context *ctx) { - struct glthread_state *glthread = ctx->GLThread; + struct glthread_state *glthread = ctx ? ctx->GLThread : NULL; if (!glthread) return;