summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer.h8
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c12
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c6
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c4
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c4
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c2
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c2
-rw-r--r--src/gallium/drivers/trace/tr_state.c2
-rw-r--r--src/gallium/include/pipe/p_refcnt.h13
10 files changed, 30 insertions, 25 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index f3a48d7ab0f..2a1315922a8 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 e4adf8aad7c..1bdf7a0b2da 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 06ed0002ca8..010a2ecc1fa 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 37ed64b84f6..478682dbee9 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 9b0f77bedb4..fb18dcc5dca 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 ca6c14a627e..75b95e132e8 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 2cdb5a5e29d..a431fd5211e 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;
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 4919ec826e9..ade18b23332 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -138,7 +138,7 @@ softpipe_texture_create(struct pipe_screen *screen,
goto fail;
}
- assert(spt->base.reference.count == 1);
+ assert(atomic_read(&spt->base.reference.count) == 1);
return &spt->base;
fail:
diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c
index c305b093354..b6a1ce0d625 100644
--- a/src/gallium/drivers/trace/tr_state.c
+++ b/src/gallium/drivers/trace/tr_state.c
@@ -53,7 +53,7 @@ void trace_dump_block(const struct pipe_format_block *block)
static void trace_dump_reference(const struct pipe_reference *reference)
{
trace_dump_struct_begin("pipe_reference");
- trace_dump_member(uint, reference, count);
+ trace_dump_member(int, &reference->count, count);
trace_dump_struct_end();
}
diff --git a/src/gallium/include/pipe/p_refcnt.h b/src/gallium/include/pipe/p_refcnt.h
index 27b4e8fbfed..60844e40a57 100644
--- a/src/gallium/include/pipe/p_refcnt.h
+++ b/src/gallium/include/pipe/p_refcnt.h
@@ -30,6 +30,7 @@
#include "p_defines.h"
+#include "p_atomic.h"
#ifdef __cplusplus
@@ -39,14 +40,14 @@ extern "C" {
struct pipe_reference
{
- unsigned count;
+ struct pipe_atomic count;
};
static INLINE void
pipe_reference_init(struct pipe_reference *reference, unsigned count)
{
- reference->count = count;
+ p_atomic_set(&reference->count, count);
}
@@ -64,13 +65,13 @@ pipe_reference(struct pipe_reference **ptr, struct pipe_reference *reference)
/* bump the reference.count first */
if (reference) {
- assert(reference->count);
- reference->count++;
+ assert(p_atomic_read(&reference->count) != 0);
+ p_atomic_inc(&reference->count);
}
if (*ptr) {
- assert((*ptr)->count);
- if (--(*ptr)->count == 0) {
+ assert(p_atomic_read(&(*ptr)->count) != 0);
+ if (p_atomic_dec_zero(&(*ptr)->count)) {
destroy = TRUE;
}
}