summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@tungstengraphics.com>2007-12-18 22:01:35 +0000
committerJosé Fonseca <jrfonseca@tungstengraphics.com>2008-01-17 12:09:37 +0900
commit3eaf882a662f719845ead1017e28a121cbce86fb (patch)
tree520f12a693806d6be25df357e0c8883f78f7b75a
parent39b8303d4af97235b4daeba5a9ee0e12640e0be5 (diff)
gallium: Alternative mm_bufmgr_create_from_buffer constructor for mm pool managers.
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr.h11
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c34
2 files changed, 37 insertions, 8 deletions
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr.h b/src/mesa/pipe/pipebuffer/pb_bufmgr.h
index 0e6c3a8d37..12e36323a8 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr.h
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr.h
@@ -65,7 +65,7 @@ struct buffer_manager
/* XXX: we will likely need more allocation flags */
struct pipe_buffer *
(*create_buffer)( struct buffer_manager *mgr,
- size_t size);
+ size_t size );
void
(*destroy)( struct buffer_manager *mgr );
@@ -96,6 +96,15 @@ struct buffer_manager *
mm_bufmgr_create(struct buffer_manager *provider,
size_t size, size_t align2);
+/**
+ * Same as mm_bufmgr_create.
+ *
+ * Buffer will be release when the manager is destroyed.
+ */
+struct buffer_manager *
+mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer,
+ size_t size, size_t align2);
+
/**
* Fenced buffer manager.
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
index 8e6dcf1116..e184655f1a 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
@@ -218,11 +218,14 @@ mm_bufmgr_destroy(struct buffer_manager *mgr)
struct buffer_manager *
-mm_bufmgr_create(struct buffer_manager *provider,
- size_t size, size_t align2)
+mm_bufmgr_create_from_buffer(struct pipe_buffer *buffer,
+ size_t size, size_t align2)
{
struct mm_buffer_manager *mm;
+ if(!buffer)
+ return NULL;
+
mm = (struct mm_buffer_manager *)calloc(1, sizeof(*mm));
if (!mm)
return NULL;
@@ -237,9 +240,7 @@ mm_bufmgr_create(struct buffer_manager *provider,
_glthread_INIT_MUTEX(mm->mutex);
- mm->buffer = provider->create_buffer(provider, size);
- if (!mm->buffer)
- goto failure;
+ mm->buffer = buffer;
mm->map = buffer_map(mm->buffer,
PIPE_BUFFER_FLAG_READ | PIPE_BUFFER_FLAG_WRITE );
@@ -257,9 +258,28 @@ if(mm->heap)
mmDestroy(mm->heap);
if(mm->map)
buffer_unmap(mm->buffer);
- if(mm->buffer)
- buffer_release(mm->buffer);
if(mm)
free(mm);
return NULL;
}
+
+
+struct buffer_manager *
+mm_bufmgr_create(struct buffer_manager *provider,
+ size_t size, size_t align2)
+{
+ struct pipe_buffer *buffer;
+ struct buffer_manager *mgr;
+
+ buffer = provider->create_buffer(provider, size);
+ if (!buffer)
+ return NULL;
+
+ mgr = mm_bufmgr_create_from_buffer(buffer, size, align2);
+ if (!mgr) {
+ buffer_release(buffer);
+ return NULL;
+ }
+
+ return mgr;
+}