r300g: add bufmgr cached for vertex/index buffers.
authorDave Airlie <airlied@redhat.com>
Sun, 21 Mar 2010 08:25:31 +0000 (18:25 +1000)
committerDave Airlie <airlied@redhat.com>
Sun, 21 Mar 2010 09:39:28 +0000 (19:39 +1000)
This adds the cached bufmgr for vertex/index buffers on top of the kernel
manager.

Signed-off-by: Dave Airlie <airlied@redhat.com>
src/gallium/winsys/drm/radeon/core/radeon_drm_buffer.c
src/gallium/winsys/drm/radeon/core/radeon_r300.c
src/gallium/winsys/drm/radeon/core/radeon_winsys.h

index 2472b6bf9522a79f2193ef7fbfd9da5a78094695..1d29b0b727adc35179b30dc89dc001f0990644ed 100644 (file)
@@ -72,17 +72,20 @@ radeon_drm_buffer_map(struct pb_buffer *_buf,
     struct radeon_drm_buffer *buf = radeon_drm_buffer(_buf);
     int write;
 
+    if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
+       if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs))
+           return NULL;
+    }
+
     if (buf->bo->ptr != NULL)
        return buf->bo->ptr;
-    
+
     if (flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
         uint32_t domain;
-
         if (radeon_bo_is_busy(buf->bo, &domain))
             return NULL;
     }
 
-
     if (radeon_bo_is_referenced_by_cs(buf->bo, buf->mgr->rws->cs)) {
         buf->mgr->rws->flush_cb(buf->mgr->rws->flush_data);
     }
index 5b82a776a8155aef15bcc6d6e6770534ecdc786a..62d66d31dc12a084133855bf08f00c1831a6d98c 100644 (file)
@@ -44,6 +44,9 @@ radeon_r300_winsys_buffer_create(struct r300_winsys_screen *rws,
 
     if (usage & PIPE_BUFFER_USAGE_CONSTANT)
         provider = ws->mman;
+    else if ((usage & PIPE_BUFFER_USAGE_VERTEX) ||
+            (usage & PIPE_BUFFER_USAGE_INDEX))
+       provider = ws->cman;
     else
         provider = ws->kman;
     buffer = provider->create_buffer(provider, size, &desc);
@@ -260,6 +263,7 @@ radeon_winsys_destroy(struct r300_winsys_screen *rws)
     struct radeon_libdrm_winsys *ws = (struct radeon_libdrm_winsys *)rws;
     radeon_cs_destroy(ws->cs);
 
+    ws->cman->destroy(ws->cman);
     ws->kman->destroy(ws->kman);
     ws->mman->destroy(ws->mman);
 
@@ -281,6 +285,10 @@ radeon_setup_winsys(int fd, struct radeon_libdrm_winsys* ws)
     if (!ws->kman)
        goto fail;
 
+    ws->cman = pb_cache_manager_create(ws->kman, 100000);
+    if (!ws->cman)
+       goto fail;
+
     ws->mman = pb_malloc_bufmgr_create();
     if (!ws->mman)
        goto fail;
@@ -325,7 +333,8 @@ fail:
     if (ws->bom)
        radeon_bo_manager_gem_dtor(ws->bom);
 
-
+    if (ws->cman)
+       ws->cman->destroy(ws->cman);
     if (ws->kman)
        ws->kman->destroy(ws->kman);
     if (ws->mman)
index 16cc701ad6f1f2d0262526894cc57ef3deece70a..ad7b976abd26b38fd7254af518895ef0a281ef5c 100644 (file)
@@ -38,6 +38,8 @@ struct radeon_libdrm_winsys {
 
     struct pb_manager *kman;
 
+    struct pb_manager *cman;
+
     struct pb_manager *mman;
 
     /* PCI ID */