diff options
author | Marek Olšák <[email protected]> | 2011-09-11 17:24:24 +0200 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2011-09-11 18:29:27 +0200 |
commit | 4682e706012fe26627a2f827db01b5068cc62814 (patch) | |
tree | 640717b8898a4bf2e7dde1fa474a88159efee07e /src/gallium/auxiliary/pipebuffer | |
parent | 2154c672b3f2a0f3de7aaacd9260954b9310262a (diff) |
pb_buffer: inline 'base' sub-struct
Diffstat (limited to 'src/gallium/auxiliary/pipebuffer')
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_buffer.h | 24 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 32 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c | 8 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c | 30 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c | 30 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c | 10 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c | 8 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c | 18 | ||||
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c | 18 |
9 files changed, 87 insertions, 91 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h index 5a13f39849f..a5ec93c255e 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h @@ -97,14 +97,10 @@ typedef unsigned pb_size; */ 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. @@ -169,7 +165,7 @@ pb_map(struct pb_buffer *buf, 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); } @@ -180,7 +176,7 @@ pb_unmap(struct pb_buffer *buf) assert(buf); if(!buf) return; - assert(pipe_is_referenced(&buf->base.reference)); + assert(pipe_is_referenced(&buf->reference)); buf->vtbl->unmap(buf); } @@ -196,11 +192,11 @@ pb_get_base_buffer( struct pb_buffer *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); } @@ -232,7 +228,7 @@ pb_destroy(struct pb_buffer *buf) assert(buf); if(!buf) return; - assert(!pipe_is_referenced(&buf->base.reference)); + assert(!pipe_is_referenced(&buf->reference)); buf->vtbl->destroy(buf); } @@ -242,7 +238,7 @@ pb_reference(struct pb_buffer **dst, { 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; } diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index c310f28f51f..9e0cacecac1 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -210,8 +210,8 @@ fenced_manager_dump_locked(struct fenced_manager *fenced_mgr) 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; @@ -226,8 +226,8 @@ fenced_manager_dump_locked(struct fenced_manager *fenced_mgr) 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"); @@ -244,7 +244,7 @@ static INLINE void 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); @@ -269,11 +269,11 @@ static INLINE void 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); @@ -311,7 +311,7 @@ fenced_buffer_remove_locked(struct fenced_manager *fenced_mgr, 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; } @@ -337,7 +337,7 @@ fenced_buffer_finish_locked(struct fenced_manager *fenced_mgr, 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) { @@ -353,7 +353,7 @@ fenced_buffer_finish_locked(struct fenced_manager *fenced_mgr, 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. @@ -662,7 +662,7 @@ fenced_buffer_destroy(struct pb_buffer *buf) 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); @@ -837,7 +837,7 @@ fenced_buffer_fence(struct pb_buffer *buf, 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) { @@ -929,10 +929,10 @@ fenced_bufmgr_create_buffer(struct pb_manager *mgr, 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; diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c index 5754f476188..b106a1a0279 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c @@ -135,10 +135,10 @@ pb_malloc_buffer_create(pb_size size, 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); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c index 25accefa8d6..58721c068e2 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(!pipe_is_referenced(&buf->base.base.reference)); + assert(!pipe_is_referenced(&buf->base.reference)); 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(!pipe_is_referenced(&buf->base.base.reference)); + assert(!pipe_is_referenced(&buf->base.reference)); _pb_cache_buffer_list_check_free(mgr); @@ -227,17 +227,17 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf, 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) { @@ -313,7 +313,7 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr, --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; } @@ -329,15 +329,15 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr, 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; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c index 7604e75af8d..b9237359e6e 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c @@ -162,7 +162,7 @@ pb_debug_buffer_fill(struct pb_debug_buffer *buf) 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); } @@ -196,12 +196,12 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf) 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 ? "+" : ""); @@ -216,7 +216,7 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf) 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); @@ -230,7 +230,7 @@ pb_debug_buffer_destroy(struct pb_buffer *_buf) 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); @@ -352,7 +352,7 @@ pb_debug_manager_dump(struct pb_debug_manager *mgr) 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; @@ -400,21 +400,21 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr, 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); diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c index 88da786216a..fe96e5c9d49 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(!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); @@ -192,10 +192,10 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr, 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; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c index 694a092f3c2..e44bc9b17e4 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c @@ -244,10 +244,10 @@ pb_ondemand_manager_create_buffer(struct pb_manager *_mgr, 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; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c index 2f7c7389ff4..a8e9a34d519 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(!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); @@ -218,10 +218,10 @@ pool_bufmgr_create_buffer(struct pb_manager *mgr, 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); } @@ -297,10 +297,10 @@ pool_bufmgr_create(struct pb_manager *provider, 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; diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c index 176f9aa38aa..bd84b622b62 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c @@ -201,7 +201,7 @@ pb_slab_buffer_destroy(struct pb_buffer *_buf) pipe_mutex_lock(mgr->mutex); - assert(!pipe_is_referenced(&buf->base.base.reference)); + assert(!pipe_is_referenced(&buf->base.reference)); buf->mapCount = 0; @@ -326,7 +326,7 @@ pb_slab_create(struct pb_slab_manager *mgr) } 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) { @@ -342,10 +342,10 @@ pb_slab_create(struct pb_slab_manager *mgr) 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; @@ -421,9 +421,9 @@ pb_slab_manager_create_buffer(struct pb_manager *_mgr, 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; } |