r600g: use malloc bufmgr for constant buffers
authorDave Airlie <airlied@redhat.com>
Fri, 17 Sep 2010 02:51:04 +0000 (12:51 +1000)
committerDave Airlie <airlied@redhat.com>
Fri, 17 Sep 2010 05:29:31 +0000 (15:29 +1000)
src/gallium/winsys/r600/drm/radeon.c
src/gallium/winsys/r600/drm/radeon_priv.h
src/gallium/winsys/r600/drm/radeon_ws_bo.c

index 2135b07ab639f781b3c44709726b22f90c6b992f..7b88075c5687f0d2c66119a87c8266417773aca1 100644 (file)
@@ -20,6 +20,7 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
+#include <pipebuffer/pb_bufmgr.h>
 #include "xf86drm.h"
 #include "radeon_priv.h"
 #include "radeon_drm.h"
@@ -125,6 +126,10 @@ struct radeon *radeon_new(int fd, unsigned device)
                        __func__, radeon->device);
                break;
        }
+
+       radeon->mman = pb_malloc_bufmgr_create();
+       if (!radeon->mman)
+               return NULL;
        return radeon;
 }
 
@@ -143,6 +148,8 @@ struct radeon *radeon_decref(struct radeon *radeon)
        if (--radeon->refcount > 0) {
                return NULL;
        }
+
+       radeon->mman->destroy(radeon->mman);
        drmClose(radeon->fd);
        free(radeon);
        return NULL;
index 49fe1a6ead1fcb04acfd409440a5dfd4a735bf9b..cb18d159a08a7d5db723ba81a0bc91cefa4294e5 100644 (file)
@@ -87,6 +87,7 @@ struct radeon {
        struct radeon_stype_info        *stype;
        unsigned max_states;
        boolean use_mem_constant; /* true for evergreen */
+       struct pb_manager *mman; /* malloc manager */
 };
 
 struct radeon_ws_bo {
index 422e298a8dba5ebd7b53873d28268df889f48c84..09e379f837ddb37e0ee22390879a6cdefb892b9a 100644 (file)
@@ -12,7 +12,7 @@ struct radeon_ws_bo *radeon_ws_bo(struct radeon *radeon,
        if (radeon->use_mem_constant && (usage & PIPE_BIND_CONSTANT_BUFFER)) {
                desc.alignment = alignment;
                desc.usage = usage;
-               ws_bo->pb = pb_malloc_buffer_create(size, &desc);
+               ws_bo->pb = radeon->mman->create_buffer(radeon->mman, size, &desc);
                if (ws_bo->pb == NULL) {
                        free(ws_bo);
                        return NULL;