struct pb_buffer *buffer;
- unsigned refcount;
struct pipe_fence_handle *fence;
struct list_head head;
/* Do the delayed destroy:
*/
- pb_destroy(fenced_buf->buffer);
+ pb_reference(&fenced_buf->buffer, NULL);
free(fenced_buf);
}
}
fenced_list->numDelayed++;
}
else {
- pb_destroy(fenced_buf->buffer);
+ pb_reference(&fenced_buf->buffer, NULL);
free(fenced_buf);
}
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;
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) {
fenced_buf = fenced_buffer_create(fenced_mgr->fenced_list, buf);
if(!fenced_buf) {
+ assert(buf->base.refcount == 1);
pb_destroy(buf);
}
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;
mmDestroy(mm->heap);
pb_unmap(mm->buffer);
- pb_destroy(mm->buffer);
+ pb_reference(&mm->buffer, NULL);
_glthread_UNLOCK_MUTEX(mm->mutex);
mgr = mm_bufmgr_create_from_buffer(buffer, size, align2);
if (!mgr) {
- pb_destroy(buffer);
+ pb_reference(&buffer, NULL);
return NULL;
}
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++;
--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);
}
FREE(pool->bufs);
pb_unmap(pool->buffer);
- pb_destroy(pool->buffer);
+ pb_reference(&pool->buffer, NULL);
_glthread_UNLOCK_MUTEX(pool->mutex);
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;
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;