Add requested size to r300RefillCurrentDmaRegion.
authorJerome Glisse <glisse@freedesktop.org>
Thu, 2 Nov 2006 20:02:26 +0000 (20:02 +0000)
committerJerome Glisse <glisse@freedesktop.org>
Thu, 2 Nov 2006 20:02:26 +0000 (20:02 +0000)
This way we no longuer have the fixed RADEON_BUFFER_SIZE.
Anyway function calling AllocDmaRegion should check if this
succeed and fail gracefuly if not (see bug 8348).

src/mesa/drivers/dri/r300/r300_ioctl.c
src/mesa/drivers/dri/r300/r300_ioctl.h
src/mesa/drivers/dri/r300/radeon_context.c
src/mesa/drivers/dri/r300/radeon_mm.c

index 87276a11aed6335c0c18de26a4746480d23240cb..0774a2af6b4c067a76510095e5b36fdef7343797 100644 (file)
@@ -570,9 +570,10 @@ void r300Flush(GLcontext * ctx)
 #ifdef USER_BUFFERS
 #include "radeon_mm.h"
 
-void r300RefillCurrentDmaRegion(r300ContextPtr rmesa)
+void r300RefillCurrentDmaRegion(r300ContextPtr rmesa, int size)
 {
        struct r300_dma_buffer *dmabuf;
+       size = MAX2(size, RADEON_BUFFER_SIZE*16);
        
        if (RADEON_DEBUG & (DEBUG_IOCTL | DEBUG_DMA))
                fprintf(stderr, "%s\n", __FUNCTION__);
@@ -591,20 +592,20 @@ void r300RefillCurrentDmaRegion(r300ContextPtr rmesa)
        dmabuf->buf = (void *)1; /* hack */
        dmabuf->refcount = 1;
 
-       dmabuf->id = radeon_mm_alloc(rmesa, 4, RADEON_BUFFER_SIZE*16);
+       dmabuf->id = radeon_mm_alloc(rmesa, 4, size);
        if (dmabuf->id == 0) {
                LOCK_HARDWARE(&rmesa->radeon);  /* no need to validate */
                
                r300FlushCmdBufLocked(rmesa, __FUNCTION__);
                radeonWaitForIdleLocked(&rmesa->radeon);
                
-               dmabuf->id = radeon_mm_alloc(rmesa, 4, RADEON_BUFFER_SIZE*16);
+               dmabuf->id = radeon_mm_alloc(rmesa, 4, size);
 
 #ifdef HW_VBOS
                if (dmabuf->id == 0) {
                        /* Just kick all */
                        r300_evict_vbos(rmesa->radeon.glCtx, /*RADEON_BUFFER_SIZE*16*/1<<30);
-                       dmabuf->id = radeon_mm_alloc(rmesa, 4, RADEON_BUFFER_SIZE*16);
+                       dmabuf->id = radeon_mm_alloc(rmesa, 4, size);
                }
 #endif
                UNLOCK_HARDWARE(&rmesa->radeon);
@@ -617,7 +618,7 @@ void r300RefillCurrentDmaRegion(r300ContextPtr rmesa)
                        
        rmesa->dma.current.buf = dmabuf;
        rmesa->dma.current.address = radeon_mm_ptr(rmesa, dmabuf->id);
-       rmesa->dma.current.end = RADEON_BUFFER_SIZE*16;
+       rmesa->dma.current.end = size;
        rmesa->dma.current.start = 0;
        rmesa->dma.current.ptr = 0;
 }
@@ -665,7 +666,8 @@ void r300AllocDmaRegion(r300ContextPtr rmesa,
            (rmesa->dma.current.ptr + alignment) & ~alignment;
 
        if (rmesa->dma.current.ptr + bytes > rmesa->dma.current.end)
-               r300RefillCurrentDmaRegion(rmesa);
+               r300RefillCurrentDmaRegion(rmesa,
+                                          (bytes + 0x7) & ~0x7);
 
        region->start = rmesa->dma.current.start;
        region->ptr = rmesa->dma.current.start;
index 5514214cc6bdbe0877d6117d73cd0e8fdd741790..52325646e9fb384c90e67790fd44de77d832ac5a 100644 (file)
@@ -50,7 +50,6 @@ extern GLuint r300GartOffsetFromVirtual(r300ContextPtr rmesa,
 
 extern void r300Flush(GLcontext * ctx);
 
-extern void r300RefillCurrentDmaRegion(r300ContextPtr rmesa);
 extern void r300ReleaseDmaRegion(r300ContextPtr rmesa,
                          struct r300_dma_region *region, const char *caller);
 extern void r300AllocDmaRegion(r300ContextPtr rmesa,
index 62a6e1e5f79877527d5bce9b6139ffbc68e3eb5f..9ddd2f4e28282a2fa94b01155cd529d7d3cf8ac4 100644 (file)
@@ -267,12 +267,14 @@ GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
                        fprintf(stderr, "%s ctx %p\n", __FUNCTION__,
                                radeon->glCtx);
 
-               if ( (radeon->dri.drawable != driDrawPriv)
-                    || (radeon->dri.readable != driReadPriv) ) {
-
+               if (radeon->dri.drawable != driDrawPriv) {
                        driDrawableInitVBlank(driDrawPriv,
                                              radeon->vblank_flags,
                                              &radeon->vbl_seq);
+               }
+
+               if (radeon->dri.drawable != driDrawPriv ||
+                   radeon->dri.readable != driReadPriv) {
                        radeon->dri.drawable = driDrawPriv;
                        radeon->dri.readable = driReadPriv;
 
index 7595d2144f764d16619f404424ee0d255b455cdd..f86a1b4e72e70bc4643cb2267f7e88b64631db70 100644 (file)
@@ -213,7 +213,7 @@ int radeon_mm_alloc(r300ContextPtr rmesa, int alignment, int size)
                }
                goto again;
 #else
-               WARN_ONCE("Ran out of GART memory!\nPlease consider adjusting GARTSize option.\n");
+               WARN_ONCE("Ran out of GART memory (for %d)!\nPlease consider adjusting GARTSize option.\n", size);
                return 0;
 #endif
        }