*/
struct pb_buffer
{
- /* This used to be a pipe_buffer struct:
- */
- struct {
- struct pipe_reference reference;
- unsigned size;
- unsigned alignment;
- unsigned usage;
- } base;
+ struct pipe_reference reference;
+ unsigned size;
+ unsigned alignment;
+ unsigned usage;
/**
* Pointer to the virtual function table.
assert(buf);
if(!buf)
return NULL;
- assert(pipe_is_referenced(&buf->base.reference));
+ assert(pipe_is_referenced(&buf->reference));
return buf->vtbl->map(buf, flags, flush_ctx);
}
assert(buf);
if(!buf)
return;
- assert(pipe_is_referenced(&buf->base.reference));
+ assert(pipe_is_referenced(&buf->reference));
buf->vtbl->unmap(buf);
}
offset = 0;
return;
}
- assert(pipe_is_referenced(&buf->base.reference));
+ assert(pipe_is_referenced(&buf->reference));
assert(buf->vtbl->get_base_buffer);
buf->vtbl->get_base_buffer(buf, base_buf, offset);
assert(*base_buf);
- assert(*offset < (*base_buf)->base.size);
+ assert(*offset < (*base_buf)->size);
}
assert(buf);
if(!buf)
return;
- assert(!pipe_is_referenced(&buf->base.reference));
+ assert(!pipe_is_referenced(&buf->reference));
buf->vtbl->destroy(buf);
}
{
struct pb_buffer *old = *dst;
- if (pipe_reference(&(*dst)->base.reference, &src->base.reference))
+ if (pipe_reference(&(*dst)->reference, &src->reference))
pb_destroy( old );
*dst = src;
}
assert(!fenced_buf->fence);
debug_printf("%10p %7u %8u %7s\n",
(void *) fenced_buf,
- fenced_buf->base.base.size,
- p_atomic_read(&fenced_buf->base.base.reference.count),
+ fenced_buf->base.size,
+ p_atomic_read(&fenced_buf->base.reference.count),
fenced_buf->buffer ? "gpu" : (fenced_buf->data ? "cpu" : "none"));
curr = next;
next = curr->next;
signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
debug_printf("%10p %7u %8u %7s %10p %s\n",
(void *) fenced_buf,
- fenced_buf->base.base.size,
- p_atomic_read(&fenced_buf->base.base.reference.count),
+ fenced_buf->base.size,
+ p_atomic_read(&fenced_buf->base.reference.count),
"gpu",
(void *) fenced_buf->fence,
signaled == 0 ? "y" : "n");
fenced_buffer_destroy_locked(struct fenced_manager *fenced_mgr,
struct fenced_buffer *fenced_buf)
{
- assert(!pipe_is_referenced(&fenced_buf->base.base.reference));
+ assert(!pipe_is_referenced(&fenced_buf->base.reference));
assert(!fenced_buf->fence);
assert(fenced_buf->head.prev);
fenced_buffer_add_locked(struct fenced_manager *fenced_mgr,
struct fenced_buffer *fenced_buf)
{
- assert(pipe_is_referenced(&fenced_buf->base.base.reference));
+ assert(pipe_is_referenced(&fenced_buf->base.reference));
assert(fenced_buf->flags & PB_USAGE_GPU_READ_WRITE);
assert(fenced_buf->fence);
- p_atomic_inc(&fenced_buf->base.base.reference.count);
+ p_atomic_inc(&fenced_buf->base.reference.count);
LIST_DEL(&fenced_buf->head);
assert(fenced_mgr->num_unfenced);
LIST_ADDTAIL(&fenced_buf->head, &fenced_mgr->unfenced);
++fenced_mgr->num_unfenced;
- if (p_atomic_dec_zero(&fenced_buf->base.base.reference.count)) {
+ if (p_atomic_dec_zero(&fenced_buf->base.reference.count)) {
fenced_buffer_destroy_locked(fenced_mgr, fenced_buf);
return TRUE;
}
debug_warning("waiting for GPU");
#endif
- assert(pipe_is_referenced(&fenced_buf->base.base.reference));
+ assert(pipe_is_referenced(&fenced_buf->base.reference));
assert(fenced_buf->fence);
if(fenced_buf->fence) {
pipe_mutex_lock(fenced_mgr->mutex);
- assert(pipe_is_referenced(&fenced_buf->base.base.reference));
+ assert(pipe_is_referenced(&fenced_buf->base.reference));
/*
* Only proceed if the fence object didn't change in the meanwhile.
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
struct fenced_manager *fenced_mgr = fenced_buf->mgr;
- assert(!pipe_is_referenced(&fenced_buf->base.base.reference));
+ assert(!pipe_is_referenced(&fenced_buf->base.reference));
pipe_mutex_lock(fenced_mgr->mutex);
pipe_mutex_lock(fenced_mgr->mutex);
- assert(pipe_is_referenced(&fenced_buf->base.base.reference));
+ assert(pipe_is_referenced(&fenced_buf->base.reference));
assert(fenced_buf->buffer);
if(fence != fenced_buf->fence) {
if(!fenced_buf)
goto no_buffer;
- pipe_reference_init(&fenced_buf->base.base.reference, 1);
- fenced_buf->base.base.alignment = desc->alignment;
- fenced_buf->base.base.usage = desc->usage;
- fenced_buf->base.base.size = size;
+ pipe_reference_init(&fenced_buf->base.reference, 1);
+ fenced_buf->base.alignment = desc->alignment;
+ fenced_buf->base.usage = desc->usage;
+ fenced_buf->base.size = size;
fenced_buf->size = size;
fenced_buf->desc = *desc;
if(!buf)
return NULL;
- pipe_reference_init(&buf->base.base.reference, 1);
- buf->base.base.usage = desc->usage;
- buf->base.base.size = size;
- buf->base.base.alignment = desc->alignment;
+ pipe_reference_init(&buf->base.reference, 1);
+ buf->base.usage = desc->usage;
+ buf->base.size = size;
+ buf->base.alignment = desc->alignment;
buf->base.vtbl = &malloc_buffer_vtbl;
buf->data = align_malloc(size, desc->alignment < sizeof(void*) ? sizeof(void*) : desc->alignment);
LIST_DEL(&buf->head);
assert(mgr->numDelayed);
--mgr->numDelayed;
- assert(!pipe_is_referenced(&buf->base.base.reference));
+ assert(!pipe_is_referenced(&buf->base.reference));
pb_reference(&buf->buffer, NULL);
FREE(buf);
}
struct pb_cache_manager *mgr = buf->mgr;
pipe_mutex_lock(mgr->mutex);
- assert(!pipe_is_referenced(&buf->base.base.reference));
+ assert(!pipe_is_referenced(&buf->base.reference));
_pb_cache_buffer_list_check_free(mgr);
pb_size size,
const struct pb_desc *desc)
{
- if(buf->base.base.size < size)
+ if(buf->base.size < size)
return 0;
/* be lenient with size */
- if(buf->base.base.size >= 2*size)
+ if(buf->base.size >= 2*size)
return 0;
- if(!pb_check_alignment(desc->alignment, buf->base.base.alignment))
+ if(!pb_check_alignment(desc->alignment, buf->base.alignment))
return 0;
- if(!pb_check_usage(desc->usage, buf->base.base.usage))
+ if(!pb_check_usage(desc->usage, buf->base.usage))
return 0;
if (buf->mgr->provider->is_buffer_busy) {
--mgr->numDelayed;
pipe_mutex_unlock(mgr->mutex);
/* Increase refcount */
- pipe_reference_init(&buf->base.base.reference, 1);
+ pipe_reference_init(&buf->base.reference, 1);
return &buf->base;
}
return NULL;
}
- 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);
+ assert(pipe_is_referenced(&buf->buffer->reference));
+ assert(pb_check_alignment(desc->alignment, buf->buffer->alignment));
+ assert(pb_check_usage(desc->usage, buf->buffer->usage));
+ assert(buf->buffer->size >= size);
- pipe_reference_init(&buf->base.base.reference, 1);
- buf->base.base.alignment = buf->buffer->base.alignment;
- buf->base.base.usage = buf->buffer->base.usage;
- buf->base.base.size = buf->buffer->base.size;
+ pipe_reference_init(&buf->base.reference, 1);
+ buf->base.alignment = buf->buffer->alignment;
+ buf->base.usage = buf->buffer->usage;
+ buf->base.size = buf->buffer->size;
buf->base.vtbl = &pb_cache_buffer_vtbl;
buf->mgr = mgr;
assert(map);
if(map) {
fill_random_pattern(map, buf->underflow_size);
- fill_random_pattern(map + buf->underflow_size + buf->base.base.size,
+ fill_random_pattern(map + buf->underflow_size + buf->base.size,
buf->overflow_size);
pb_unmap(buf->buffer);
}
buf->underflow_size - max_ofs);
}
- overflow = !check_random_pattern(map + buf->underflow_size + buf->base.base.size,
+ overflow = !check_random_pattern(map + buf->underflow_size + buf->base.size,
buf->overflow_size,
&min_ofs, &max_ofs);
if(overflow) {
debug_printf("buffer overflow (size %u plus offset %u to %u%s bytes) detected\n",
- buf->base.base.size,
+ buf->base.size,
min_ofs,
max_ofs,
max_ofs == buf->overflow_size - 1 ? "+" : "");
if(underflow)
fill_random_pattern(map, buf->underflow_size);
if(overflow)
- fill_random_pattern(map + buf->underflow_size + buf->base.base.size,
+ fill_random_pattern(map + buf->underflow_size + buf->base.size,
buf->overflow_size);
pb_unmap(buf->buffer);
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
struct pb_debug_manager *mgr = buf->mgr;
- assert(!pipe_is_referenced(&buf->base.base.reference));
+ assert(!pipe_is_referenced(&buf->base.reference));
pb_debug_buffer_check(buf);
buf = LIST_ENTRY(struct pb_debug_buffer, curr, head);
debug_printf("buffer = %p\n", (void *) buf);
- debug_printf(" .size = 0x%x\n", buf->base.base.size);
+ debug_printf(" .size = 0x%x\n", buf->base.size);
debug_backtrace_dump(buf->create_backtrace, PB_DEBUG_CREATE_BACKTRACE);
curr = next;
return NULL;
}
- 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);
+ assert(pipe_is_referenced(&buf->buffer->reference));
+ assert(pb_check_alignment(real_desc.alignment, buf->buffer->alignment));
+ assert(pb_check_usage(real_desc.usage, buf->buffer->usage));
+ assert(buf->buffer->size >= real_size);
- pipe_reference_init(&buf->base.base.reference, 1);
- buf->base.base.alignment = desc->alignment;
- buf->base.base.usage = desc->usage;
- buf->base.base.size = size;
+ pipe_reference_init(&buf->base.reference, 1);
+ buf->base.alignment = desc->alignment;
+ buf->base.usage = desc->usage;
+ buf->base.size = size;
buf->base.vtbl = &pb_debug_buffer_vtbl;
buf->mgr = mgr;
buf->underflow_size = mgr->underflow_size;
- buf->overflow_size = buf->buffer->base.size - buf->underflow_size - size;
+ buf->overflow_size = buf->buffer->size - buf->underflow_size - size;
debug_backtrace_capture(buf->create_backtrace, 1, PB_DEBUG_CREATE_BACKTRACE);
struct mm_buffer *mm_buf = mm_buffer(buf);
struct mm_pb_manager *mm = mm_buf->mgr;
- assert(!pipe_is_referenced(&mm_buf->base.base.reference));
+ assert(!pipe_is_referenced(&mm_buf->base.reference));
pipe_mutex_lock(mm->mutex);
u_mmFreeMem(mm_buf->block);
return NULL;
}
- pipe_reference_init(&mm_buf->base.base.reference, 1);
- mm_buf->base.base.alignment = desc->alignment;
- mm_buf->base.base.usage = desc->usage;
- mm_buf->base.base.size = size;
+ pipe_reference_init(&mm_buf->base.reference, 1);
+ mm_buf->base.alignment = desc->alignment;
+ mm_buf->base.usage = desc->usage;
+ mm_buf->base.size = size;
mm_buf->base.vtbl = &mm_buffer_vtbl;
if(!buf)
return NULL;
- pipe_reference_init(&buf->base.base.reference, 1);
- buf->base.base.alignment = desc->alignment;
- buf->base.base.usage = desc->usage;
- buf->base.base.size = size;
+ pipe_reference_init(&buf->base.reference, 1);
+ buf->base.alignment = desc->alignment;
+ buf->base.usage = desc->usage;
+ buf->base.size = size;
buf->base.vtbl = &pb_ondemand_buffer_vtbl;
buf->mgr = mgr;
struct pool_buffer *pool_buf = pool_buffer(buf);
struct pool_pb_manager *pool = pool_buf->mgr;
- assert(!pipe_is_referenced(&pool_buf->base.base.reference));
+ assert(!pipe_is_referenced(&pool_buf->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(!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;
+ assert(!pipe_is_referenced(&pool_buf->base.reference));
+ pipe_reference_init(&pool_buf->base.reference, 1);
+ pool_buf->base.alignment = desc->alignment;
+ pool_buf->base.usage = desc->usage;
return SUPER(pool_buf);
}
pool_buf = pool->bufs;
for (i = 0; i < numBufs; ++i) {
- 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;
+ pipe_reference_init(&pool_buf->base.reference, 0);
+ pool_buf->base.alignment = 0;
+ pool_buf->base.usage = 0;
+ pool_buf->base.size = bufSize;
pool_buf->base.vtbl = &pool_buffer_vtbl;
pool_buf->mgr = pool;
pool_buf->start = i * bufSize;
pipe_mutex_lock(mgr->mutex);
- assert(!pipe_is_referenced(&buf->base.base.reference));
+ assert(!pipe_is_referenced(&buf->base.reference));
buf->mapCount = 0;
}
pb_unmap(slab->bo);
- numBuffers = slab->bo->base.size / mgr->bufSize;
+ numBuffers = slab->bo->size / mgr->bufSize;
slab->buffers = CALLOC(numBuffers, sizeof(*slab->buffers));
if (!slab->buffers) {
buf = slab->buffers;
for (i=0; i < numBuffers; ++i) {
- pipe_reference_init(&buf->base.base.reference, 0);
- buf->base.base.size = mgr->bufSize;
- buf->base.base.alignment = 0;
- buf->base.base.usage = 0;
+ pipe_reference_init(&buf->base.reference, 0);
+ buf->base.size = mgr->bufSize;
+ buf->base.alignment = 0;
+ buf->base.usage = 0;
buf->base.vtbl = &pb_slab_buffer_vtbl;
buf->slab = slab;
buf->start = i* mgr->bufSize;
pipe_mutex_unlock(mgr->mutex);
buf = LIST_ENTRY(struct pb_slab_buffer, list, head);
- pipe_reference_init(&buf->base.base.reference, 1);
- buf->base.base.alignment = desc->alignment;
- buf->base.base.usage = desc->usage;
+ pipe_reference_init(&buf->base.reference, 1);
+ buf->base.alignment = desc->alignment;
+ buf->base.usage = desc->usage;
return &buf->base;
}
} else {
ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_SURFACE_SYNC, 3, ctx->predicate_drawing);
ctx->pm4[ctx->pm4_cdwords++] = flush_flags;
- ctx->pm4[ctx->pm4_cdwords++] = (bo->buf->base.size + 255) >> 8;
+ ctx->pm4[ctx->pm4_cdwords++] = (bo->buf->size + 255) >> 8;
ctx->pm4[ctx->pm4_cdwords++] = 0x00000000;
ctx->pm4[ctx->pm4_cdwords++] = 0x0000000A;
ctx->pm4[ctx->pm4_cdwords++] = PKT3(PKT3_NOP, 0, ctx->predicate_drawing);
if (!bo)
return NULL;
- pipe_reference_init(&bo->base.base.reference, 1);
- bo->base.base.alignment = desc->alignment;
- bo->base.base.usage = desc->usage;
- bo->base.base.size = size;
+ pipe_reference_init(&bo->base.reference, 1);
+ bo->base.alignment = desc->alignment;
+ bo->base.usage = desc->usage;
+ bo->base.size = size;
bo->base.vtbl = &radeon_bo_vtbl;
bo->mgr = mgr;
bo->rws = mgr->rws;
bo->name = whandle->handle;
/* Initialize it. */
- pipe_reference_init(&bo->base.base.reference, 1);
- bo->base.base.alignment = 0;
- bo->base.base.usage = PB_USAGE_GPU_WRITE | PB_USAGE_GPU_READ;
- bo->base.base.size = bo->size;
+ pipe_reference_init(&bo->base.reference, 1);
+ bo->base.alignment = 0;
+ bo->base.usage = PB_USAGE_GPU_WRITE | PB_USAGE_GPU_READ;
+ bo->base.size = bo->size;
bo->base.vtbl = &radeon_bo_vtbl;
bo->mgr = mgr;
bo->rws = mgr->rws;
if (stride)
*stride = whandle->stride;
if (size)
- *size = bo->base.base.size;
+ *size = bo->base.size;
return (struct pb_buffer*)bo;
if(!buf)
goto error1;
- pipe_reference_init(&buf->base.base.reference, 1);
- buf->base.base.alignment = desc->alignment;
- buf->base.base.usage = desc->usage;
- buf->base.base.size = size;
+ pipe_reference_init(&buf->base.reference, 1);
+ buf->base.alignment = desc->alignment;
+ buf->base.usage = desc->usage;
+ buf->base.size = size;
buf->base.vtbl = &vmw_gmr_buffer_vtbl;
buf->mgr = mgr;
* SVGA virtual device it's not a performance issue since flushing commands
* to the FIFO won't cause flushing in the host.
*/
- vswc->seen_regions += reloc->buffer->base.size;
+ vswc->seen_regions += reloc->buffer->size;
if(vswc->seen_regions >= VMW_GMR_POOL_SIZE/3)
vswc->preemptive_flush = TRUE;
}