Fix #7195
authorAapo Tahkola <aet@rasterburn.org>
Sun, 9 Jul 2006 00:04:06 +0000 (00:04 +0000)
committerAapo Tahkola <aet@rasterburn.org>
Sun, 9 Jul 2006 00:04:06 +0000 (00:04 +0000)
src/mesa/drivers/dri/r300/r300_context.c
src/mesa/drivers/dri/r300/radeon_lock.c

index 8ba91c9d810175aacf36aff3b080565da23d0da0..541ffa3997e19f01addef4bc4812fe9ab07c1ce7 100644 (file)
@@ -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);
 
index 893b4b4e7efdfca6ed6012c52af3886b562de3cb..edf261831486a4c5da41182ac2e6ea6868962142 100644 (file)
@@ -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);