diff options
author | Michel Dänzer <[email protected]> | 2009-03-04 11:58:48 +0100 |
---|---|---|
committer | Michel Dänzer <[email protected]> | 2009-03-04 11:58:48 +0100 |
commit | 5e27cd46c04a9e7b5904cc014bffd0f4daae31fe (patch) | |
tree | a57289f14d69f1977dfaee592af908052d726b8c /src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c | |
parent | 60041203d5847de8ab71842a6ce5d33d96cc4930 (diff) |
gallium: Unify reference counting.
The core reference counting code is centralized in p_refcnt.h.
This has some consequences related to struct pipe_buffer:
* The screen member of struct pipe_buffer must be initialized, or
pipe_buffer_reference() will crash trying to destroy a buffer with reference
count 0. u_simple_screen takes care of this, but I may have missed some of
the drivers not using it.
* Except for rare exceptions deep in winsys code, buffers must always be
allocated via pipe_buffer_create() or via screen->*buffer_create() rather
than via winsys->*buffer_create().
Diffstat (limited to 'src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c')
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c index 12447acfd93..ca6c14a627e 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c @@ -108,7 +108,7 @@ 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); + assert(pool_buf->base.base.reference.count == 0); pipe_mutex_lock(pool->mutex); LIST_ADD(&pool_buf->head, &pool->free); @@ -216,8 +216,8 @@ pool_bufmgr_create_buffer(struct pb_manager *mgr, pipe_mutex_unlock(pool->mutex); pool_buf = LIST_ENTRY(struct pool_buffer, item, head); - assert(pool_buf->base.base.refcount == 0); - pool_buf->base.base.refcount = 1; + assert(pool_buf->base.base.reference.count == 0); + pipe_reference_init(&pool_buf->base.base.reference, 1); pool_buf->base.base.alignment = desc->alignment; pool_buf->base.base.usage = desc->usage; @@ -295,7 +295,7 @@ pool_bufmgr_create(struct pb_manager *provider, pool_buf = pool->bufs; for (i = 0; i < numBufs; ++i) { - pool_buf->base.base.refcount = 0; + pipe_reference_init(&pool_buf->base.base.reference, 0); pool_buf->base.base.alignment = 0; pool_buf->base.base.usage = 0; pool_buf->base.base.size = bufSize; |