assert(buf);
if(!buf)
return NULL;
- assert(p_atomic_read(&buf->base.reference.count) > 0);
+ assert(pipe_is_referenced(&buf->base.reference));
return buf->vtbl->map(buf, flags);
}
assert(buf);
if(!buf)
return;
- assert(p_atomic_read(&buf->base.reference.count) > 0);
+ assert(pipe_is_referenced(&buf->base.reference));
buf->vtbl->unmap(buf);
}
offset = 0;
return;
}
- assert(p_atomic_read(&buf->base.reference.count) > 0);
+ assert(pipe_is_referenced(&buf->base.reference));
assert(buf->vtbl->get_base_buffer);
buf->vtbl->get_base_buffer(buf, base_buf, offset);
assert(*base_buf);
assert(buf);
if(!buf)
return;
- assert(p_atomic_read(&buf->base.reference.count) == 0);
+ assert(!pipe_is_referenced(&buf->base.reference));
buf->vtbl->destroy(buf);
}
{
struct fenced_buffer_list *fenced_list = fenced_buf->list;
- assert(p_atomic_read(&fenced_buf->base.base.reference.count));
+ assert(pipe_is_referenced(&fenced_buf->base.base.reference));
assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
assert(fenced_buf->fence);
{
struct fenced_buffer_list *fenced_list = fenced_buf->list;
- assert(p_atomic_read(&fenced_buf->base.base.reference.count) == 0);
+ assert(!pipe_is_referenced(&fenced_buf->base.base.reference));
assert(!fenced_buf->fence);
#ifdef DEBUG
assert(fenced_buf->head.prev);
* FIXME!!!
*/
- if(!p_atomic_read(&fenced_buf->base.base.reference.count))
+ if(!pipe_is_referenced(&fenced_buf->base.base.reference))
_fenced_buffer_destroy(fenced_buf);
}
struct fenced_buffer_list *fenced_list = fenced_buf->list;
pipe_mutex_lock(fenced_list->mutex);
- assert(p_atomic_read(&fenced_buf->base.base.reference.count) == 0);
+ assert(!pipe_is_referenced(&fenced_buf->base.base.reference));
if (fenced_buf->fence) {
struct pb_fence_ops *ops = fenced_list->ops;
if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0) {
LIST_DEL(&buf->head);
assert(mgr->numDelayed);
--mgr->numDelayed;
- assert(p_atomic_read(&buf->base.base.reference.count) == 0);
+ assert(!pipe_is_referenced(&buf->base.base.reference));
pb_reference(&buf->buffer, NULL);
FREE(buf);
}
struct pb_cache_manager *mgr = buf->mgr;
pipe_mutex_lock(mgr->mutex);
- assert(p_atomic_read(&buf->base.base.reference.count) == 0);
+ assert(!pipe_is_referenced(&buf->base.base.reference));
_pb_cache_buffer_list_check_free(mgr);
return NULL;
}
- assert(p_atomic_read(&buf->buffer->base.reference.count) >= 1);
+ assert(pipe_is_referenced(&buf->buffer->base.reference));
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);
{
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
- assert(p_atomic_read(&buf->base.base.reference.count) == 0);
+ assert(!pipe_is_referenced(&buf->base.base.reference));
pb_debug_buffer_check(buf);
return NULL;
}
- assert(p_atomic_read(&buf->buffer->base.reference.count) >= 1);
+ assert(pipe_is_referenced(&buf->buffer->base.reference));
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);
struct mm_buffer *mm_buf = mm_buffer(buf);
struct mm_pb_manager *mm = mm_buf->mgr;
- assert(p_atomic_read(&mm_buf->base.base.reference.count) == 0);
+ assert(!pipe_is_referenced(&mm_buf->base.base.reference));
pipe_mutex_lock(mm->mutex);
u_mmFreeMem(mm_buf->block);
struct pool_buffer *pool_buf = pool_buffer(buf);
struct pool_pb_manager *pool = pool_buf->mgr;
- assert(p_atomic_read(&pool_buf->base.base.reference.count) == 0);
+ assert(!pipe_is_referenced(&pool_buf->base.base.reference));
pipe_mutex_lock(pool->mutex);
LIST_ADD(&pool_buf->head, &pool->free);
pipe_mutex_unlock(pool->mutex);
pool_buf = LIST_ENTRY(struct pool_buffer, item, head);
- assert(p_atomic_read(&pool_buf->base.base.reference.count) == 0);
+ assert(!pipe_is_referenced(&pool_buf->base.base.reference));
pipe_reference_init(&pool_buf->base.base.reference, 1);
pool_buf->base.base.alignment = desc->alignment;
pool_buf->base.base.usage = desc->usage;
pipe_mutex_lock(mgr->mutex);
- assert(p_atomic_read(&buf->base.base.reference.count) == 0);
+ assert(!pipe_is_referenced(&buf->base.base.reference));
buf->mapCount = 0;
goto fail;
}
- assert(p_atomic_read(&spt->base.reference.count) == 1);
return &spt->base;
fail:
}
+static INLINE bool
+pipe_is_referenced(struct pipe_reference *reference)
+{
+ return p_atomic_read(&reference->count) != 0;
+}
+
+
/**
* Set 'ptr' to point to 'reference' and update reference counting.
* The old thing pointed to, if any, will be unreferenced first.
/* bump the reference.count first */
if (reference) {
- assert(p_atomic_read(&reference->count) != 0);
+ assert(pipe_is_referenced(reference));
p_atomic_inc(&reference->count);
}
if (*ptr) {
- assert(p_atomic_read(&(*ptr)->count) != 0);
+ assert(pipe_is_referenced(*ptr));
if (p_atomic_dec_zero(&(*ptr)->count)) {
destroy = TRUE;
}
return destroy;
}
+
#ifdef __cplusplus
}
#endif
newtex = screen->texture_create(screen, &pt);
- assert(!newtex || p_atomic_read(&newtex->reference.count) == 1);
+ assert(!newtex || pipe_is_referenced(&newtex->reference));
return newtex;
}