summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_fenced.c11
-rw-r--r--src/mesa/pipe/pipebuffer/pb_buffer_malloc.c3
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c1
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c9
-rw-r--r--src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c16
5 files changed, 31 insertions, 9 deletions
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c
index b2edc321ef..349647fe6e 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_fenced.c
@@ -80,7 +80,6 @@ struct fenced_buffer
struct pb_buffer *buffer;
- unsigned refcount;
struct pipe_fence_handle *fence;
struct list_head head;
@@ -145,7 +144,7 @@ _fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
/* Do the delayed destroy:
*/
- pb_destroy(fenced_buf->buffer);
+ pb_reference(&fenced_buf->buffer, NULL);
free(fenced_buf);
}
}
@@ -162,7 +161,7 @@ fenced_buffer_destroy(struct pb_buffer *buf)
fenced_list->numDelayed++;
}
else {
- pb_destroy(fenced_buf->buffer);
+ pb_reference(&fenced_buf->buffer, NULL);
free(fenced_buf);
}
@@ -220,9 +219,13 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list,
if(!buf)
return NULL;
+ buf->base.base.refcount = 1;
+ buf->base.base.alignment = buffer->base.alignment;
+ buf->base.base.usage = buffer->base.usage;
+ buf->base.base.size = buffer->base.size;
+
buf->base.vtbl = &fenced_buffer_vtbl;
buf->buffer = buffer;
- buf->refcount = 1;
buf->list = fenced_list;
return &buf->base;
diff --git a/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c b/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c
index f0ff1d347e..fc83a00f36 100644
--- a/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c
+++ b/src/mesa/pipe/pipebuffer/pb_buffer_malloc.c
@@ -114,10 +114,11 @@ pb_malloc_buffer_create(size_t size,
if(!buf)
return NULL;
- buf->base.vtbl = &malloc_buffer_vtbl;
+ buf->base.base.refcount = 1;
buf->base.base.alignment = desc->alignment;
buf->base.base.usage = desc->usage;
buf->base.base.size = size;
+ buf->base.vtbl = &malloc_buffer_vtbl;
buf->data = align_malloc(size, desc->alignment < sizeof(void*) ? sizeof(void*) : desc->alignment);
if(!buf->data) {
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c
index 6a81cbdae0..3b341c64c2 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_fenced.c
@@ -88,6 +88,7 @@ fenced_bufmgr_create_buffer(struct pb_manager *mgr,
fenced_buf = fenced_buffer_create(fenced_mgr->fenced_list, buf);
if(!fenced_buf) {
+ assert(buf->base.refcount == 1);
pb_destroy(buf);
}
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
index 2a62702c36..2694f57bca 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_mm.c
@@ -466,6 +466,11 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
return NULL;
}
+ mm_buf->base.base.refcount = 1;
+ mm_buf->base.base.alignment = desc->alignment;
+ mm_buf->base.base.usage = desc->usage;
+ mm_buf->base.base.size = size;
+
mm_buf->base.vtbl = &mm_buffer_vtbl;
mm_buf->mgr = mm;
@@ -505,7 +510,7 @@ mm_bufmgr_destroy(struct pb_manager *mgr)
mmDestroy(mm->heap);
pb_unmap(mm->buffer);
- pb_destroy(mm->buffer);
+ pb_reference(&mm->buffer, NULL);
_glthread_UNLOCK_MUTEX(mm->mutex);
@@ -579,7 +584,7 @@ mm_bufmgr_create(struct pb_manager *provider,
mgr = mm_bufmgr_create_from_buffer(buffer, size, align2);
if (!mgr) {
- pb_destroy(buffer);
+ pb_reference(&buffer, NULL);
return NULL;
}
diff --git a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
index 61c06ec824..7c29954112 100644
--- a/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
+++ b/src/mesa/pipe/pipebuffer/pb_bufmgr_pool.c
@@ -111,6 +111,8 @@ pool_buffer_destroy(struct pb_buffer *buf)
struct pool_buffer *pool_buf = pool_buffer(buf);
struct pool_pb_manager *pool = pool_buf->mgr;
+ assert(pool_buf->base.base.refcount == 0);
+
_glthread_LOCK_MUTEX(pool->mutex);
LIST_ADD(&pool_buf->head, &pool->free);
pool->numFree++;
@@ -192,7 +194,13 @@ pool_bufmgr_create_buffer(struct pb_manager *mgr,
--pool->numFree;
_glthread_UNLOCK_MUTEX(pool->mutex);
+
pool_buf = LIST_ENTRY(struct pool_buffer, item, head);
+ assert(pool_buf->base.base.refcount == 0);
+ pool_buf->base.base.refcount = 1;
+ pool_buf->base.base.alignment = desc->alignment;
+ pool_buf->base.base.usage = desc->usage;
+
return SUPER(pool_buf);
}
@@ -206,7 +214,7 @@ pool_bufmgr_destroy(struct pb_manager *mgr)
FREE(pool->bufs);
pb_unmap(pool->buffer);
- pb_destroy(pool->buffer);
+ pb_reference(&pool->buffer, NULL);
_glthread_UNLOCK_MUTEX(pool->mutex);
@@ -256,6 +264,10 @@ pool_bufmgr_create(struct pb_manager *provider,
pool_buf = pool->bufs;
for (i = 0; i < numBufs; ++i) {
+ pool_buf->base.base.refcount = 0;
+ pool_buf->base.base.alignment = 0;
+ pool_buf->base.base.usage = 0;
+ pool_buf->base.base.size = bufSize;
pool_buf->base.vtbl = &pool_buffer_vtbl;
pool_buf->mgr = pool;
pool_buf->start = i * bufSize;
@@ -271,7 +283,7 @@ failure:
if(pool->map)
pb_unmap(pool->buffer);
if(pool->buffer)
- pb_destroy(pool->buffer);
+ pb_reference(&pool->buffer, NULL);
if(pool)
FREE(pool);
return NULL;