From: Aapo Tahkola Date: Sun, 9 Jul 2006 00:04:06 +0000 (+0000) Subject: Fix #7195 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=b9920ba7b7fd8ed9a3c45e0cebafd28b419f73e3;p=mesa.git Fix #7195 --- diff --git a/src/mesa/drivers/dri/r300/r300_context.c b/src/mesa/drivers/dri/r300/r300_context.c index 8ba91c9d810..541ffa3997e 100644 --- a/src/mesa/drivers/dri/r300/r300_context.c +++ b/src/mesa/drivers/dri/r300/r300_context.c @@ -374,12 +374,26 @@ GLboolean r300CreateContext(const __GLcontextModes * glVisual, static void r300FreeGartAllocations(r300ContextPtr r300) { - int i, ret, tries=0, done_age; + int i, ret, tries=0, done_age, in_use=0; drm_radeon_mem_free_t memfree; memfree.region = RADEON_MEM_REGION_GART; #ifdef USER_BUFFERS + for (i = r300->rmm->u_last; i > 0; i--) { + if (r300->rmm->u_list[i].ptr == NULL) { + continue; + } + + /* check whether this buffer is still in use */ + if (r300->rmm->u_list[i].pending) { + in_use++; + } + } + /* Cannot flush/lock if no context exists. */ + if (in_use) + r300FlushCmdBuf(r300, __FUNCTION__); + done_age = radeonGetAge((radeonContextPtr)r300); for (i = r300->rmm->u_last; i > 0; i--) { @@ -465,8 +479,10 @@ void r300DestroyContext(__DRIcontextPrivate * driContextPriv) if (r300->dma.current.buf) { r300ReleaseDmaRegion(r300, &r300->dma.current, __FUNCTION__ ); +#ifndef USER_BUFFERS + r300FlushCmdBuf(r300, __FUNCTION__); +#endif } - r300FlushCmdBuf(r300, __FUNCTION__); r300FreeGartAllocations(r300); r300DestroyCmdBuf(r300); diff --git a/src/mesa/drivers/dri/r300/radeon_lock.c b/src/mesa/drivers/dri/r300/radeon_lock.c index 893b4b4e7ef..edf26183148 100644 --- a/src/mesa/drivers/dri/r300/radeon_lock.c +++ b/src/mesa/drivers/dri/r300/radeon_lock.c @@ -153,6 +153,8 @@ void radeonGetLock(radeonContextPtr radeon, GLuint flags) __DRIdrawablePrivate *dPriv = radeon->dri.drawable; __DRIscreenPrivate *sPriv = radeon->dri.screen; drm_radeon_sarea_t *sarea = radeon->sarea; + + assert (dPriv != NULL); drmGetLock(radeon->dri.fd, radeon->dri.hwContext, flags);