diff options
author | Thomas Hellstrom <thellstrom-at-vmware-dot-com> | 2009-03-13 15:47:18 +0100 |
---|---|---|
committer | Thomas Hellstrom <thellstrom-at-vmware-dot-com> | 2009-03-16 11:40:47 +0100 |
commit | cf25ef9072f5290d228a381727c4ff921b0c60d6 (patch) | |
tree | 6e8be9bcf952d395920d742ac3468896c52ffed8 /src/gallium/auxiliary/pipebuffer | |
parent | fc1ef97c3349588cd33a22dc88ab30b6f701000e (diff) |
gallium: Use struct pipe_atomic for pipe refcounts.
Signed-off-by: Thomas Hellstrom <thellstrom-at-vmware-dot-com>
Diffstat (limited to 'src/gallium/auxiliary/pipebuffer')
7 files changed, 21 insertions, 17 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h index f3a48d7ab0..2a1315922a 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h @@ -158,7 +158,7 @@ pb_map(struct pb_buffer *buf, assert(buf); if(!buf) return NULL; - assert(buf->base.reference.count > 0); + assert(p_atomic_read(&buf->base.reference.count) > 0); return buf->vtbl->map(buf, flags); } @@ -169,7 +169,7 @@ pb_unmap(struct pb_buffer *buf) assert(buf); if(!buf) return; - assert(buf->base.reference.count > 0); + assert(p_atomic_read(&buf->base.reference.count) > 0); buf->vtbl->unmap(buf); } @@ -185,7 +185,7 @@ pb_get_base_buffer( struct pb_buffer *buf, offset = 0; return; } - assert(buf->base.reference.count > 0); + assert(p_atomic_read(&buf->base.reference.count) > 0); assert(buf->vtbl->get_base_buffer); buf->vtbl->get_base_buffer(buf, base_buf, offset); assert(*base_buf); @@ -221,7 +221,7 @@ pb_destroy(struct pb_buffer *buf) assert(buf); if(!buf) return; - assert(buf->base.reference.count == 0); + assert(p_atomic_read(&buf->base.reference.count) == 0); buf->vtbl->destroy(buf); } diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index e4adf8aad7..1bdf7a0b2d 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -115,7 +115,7 @@ _fenced_buffer_add(struct fenced_buffer *fenced_buf) { struct fenced_buffer_list *fenced_list = fenced_buf->list; - assert(fenced_buf->base.base.reference.count); + assert(p_atomic_read(&fenced_buf->base.base.reference.count)); assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE); assert(fenced_buf->fence); @@ -137,7 +137,7 @@ _fenced_buffer_destroy(struct fenced_buffer *fenced_buf) { struct fenced_buffer_list *fenced_list = fenced_buf->list; - assert(!fenced_buf->base.base.reference.count); + assert(p_atomic_read(&fenced_buf->base.base.reference.count) == 0); assert(!fenced_buf->fence); #ifdef DEBUG assert(fenced_buf->head.prev); @@ -177,7 +177,11 @@ _fenced_buffer_remove(struct fenced_buffer_list *fenced_list, ++fenced_list->numUnfenced; #endif - if(!fenced_buf->base.base.reference.count) + /** + * FIXME!!! + */ + + if(!p_atomic_read(&fenced_buf->base.base.reference.count)) _fenced_buffer_destroy(fenced_buf); } @@ -253,7 +257,7 @@ fenced_buffer_destroy(struct pb_buffer *buf) struct fenced_buffer_list *fenced_list = fenced_buf->list; pipe_mutex_lock(fenced_list->mutex); - assert(fenced_buf->base.base.reference.count == 0); + assert(p_atomic_read(&fenced_buf->base.base.reference.count) == 0); if (fenced_buf->fence) { struct pb_fence_ops *ops = fenced_list->ops; if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) { diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c index 06ed0002ca..010a2ecc1f 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c @@ -112,7 +112,7 @@ _pb_cache_buffer_destroy(struct pb_cache_buffer *buf) LIST_DEL(&buf->head); assert(mgr->numDelayed); --mgr->numDelayed; - assert(!buf->base.base.reference.count); + assert(p_atomic_read(&buf->base.base.reference.count) == 0); pb_reference(&buf->buffer, NULL); FREE(buf); } @@ -153,7 +153,7 @@ pb_cache_buffer_destroy(struct pb_buffer *_buf) struct pb_cache_manager *mgr = buf->mgr; pipe_mutex_lock(mgr->mutex); - assert(buf->base.base.reference.count == 0); + assert(p_atomic_read(&buf->base.base.reference.count) == 0); _pb_cache_buffer_list_check_free(mgr); @@ -310,7 +310,7 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr, return NULL; } - assert(buf->buffer->base.reference.count >= 1); + assert(p_atomic_read(&buf->buffer->base.reference.count) >= 1); assert(pb_check_alignment(desc->alignment, buf->buffer->base.alignment)); assert(pb_check_usage(desc->usage, buf->buffer->base.usage)); assert(buf->buffer->base.size >= size); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c index 37ed64b84f..478682dbee 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c @@ -208,7 +208,7 @@ pb_debug_buffer_destroy(struct pb_buffer *_buf) { struct pb_debug_buffer *buf = pb_debug_buffer(_buf); - assert(!buf->base.base.reference.count); + assert(p_atomic_read(&buf->base.base.reference.count) == 0); pb_debug_buffer_check(buf); @@ -315,7 +315,7 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr, return NULL; } - assert(buf->buffer->base.reference.count >= 1); + assert(p_atomic_read(&buf->buffer->base.reference.count) >= 1); assert(pb_check_alignment(real_desc.alignment, buf->buffer->base.alignment)); assert(pb_check_usage(real_desc.usage, buf->buffer->base.usage)); assert(buf->buffer->base.size >= real_size); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c index 9b0f77bedb..fb18dcc5dc 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c @@ -97,7 +97,7 @@ mm_buffer_destroy(struct pb_buffer *buf) struct mm_buffer *mm_buf = mm_buffer(buf); struct mm_pb_manager *mm = mm_buf->mgr; - assert(mm_buf->base.base.reference.count == 0); + assert(p_atomic_read(&mm_buf->base.base.reference.count) == 0); pipe_mutex_lock(mm->mutex); u_mmFreeMem(mm_buf->block); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c index ca6c14a627..75b95e132e 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.reference.count == 0); + assert(p_atomic_read(&pool_buf->base.base.reference.count) == 0); pipe_mutex_lock(pool->mutex); LIST_ADD(&pool_buf->head, &pool->free); @@ -216,7 +216,7 @@ 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.reference.count == 0); + assert(p_atomic_read(&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; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c index 2cdb5a5e29..a431fd5211 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c @@ -202,7 +202,7 @@ pb_slab_buffer_destroy(struct pb_buffer *_buf) pipe_mutex_lock(mgr->mutex); - assert(buf->base.base.reference.count == 0); + assert(p_atomic_read(&buf->base.base.reference.count) == 0); buf->mapCount = 0; |