summaryrefslogtreecommitdiff
path: root/src/gallium/auxiliary/pipebuffer
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/auxiliary/pipebuffer')
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer.h14
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c16
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c8
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr.h20
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c8
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c132
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c26
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c8
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c20
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c36
12 files changed, 202 insertions, 90 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index 92b6fd0056..2590546cb4 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
@@ -72,6 +72,12 @@ struct pb_desc
/**
+ * Size. Regular (32bit) unsigned for now.
+ */
+typedef unsigned pb_size;
+
+
+/**
* Base class for all pb_* buffers.
*/
struct pb_buffer
@@ -126,7 +132,7 @@ struct pb_vtbl
*/
void (*get_base_buffer)( struct pb_buffer *buf,
struct pb_buffer **base_buf,
- unsigned *offset );
+ pb_size *offset );
};
@@ -177,7 +183,7 @@ pb_unmap(struct pb_buffer *buf)
static INLINE void
pb_get_base_buffer( struct pb_buffer *buf,
struct pb_buffer **base_buf,
- unsigned *offset )
+ pb_size *offset )
{
assert(buf);
if(!buf) {
@@ -241,7 +247,7 @@ pb_reference(struct pb_buffer **dst,
* the requested or not.
*/
static INLINE boolean
-pb_check_alignment(size_t requested, size_t provided)
+pb_check_alignment(pb_size requested, pb_size provided)
{
if(!requested)
return TRUE;
@@ -269,7 +275,7 @@ pb_check_usage(unsigned requested, unsigned provided)
* hardware.
*/
struct pb_buffer *
-pb_malloc_buffer_create(size_t size,
+pb_malloc_buffer_create(pb_size size,
const struct pb_desc *desc);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
index 044e8e1dd3..109ac7c9d6 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
@@ -65,11 +65,11 @@ struct fenced_buffer_list
struct pb_fence_ops *ops;
- size_t numDelayed;
+ pb_size numDelayed;
struct list_head delayed;
#ifdef DEBUG
- size_t numUnfenced;
+ pb_size numUnfenced;
struct list_head unfenced;
#endif
};
@@ -433,7 +433,7 @@ fenced_buffer_fence(struct pb_buffer *buf,
static void
fenced_buffer_get_base_buffer(struct pb_buffer *buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
pb_get_base_buffer(fenced_buf->buffer, base_buf, offset);
@@ -531,16 +531,17 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list)
pipe_mutex_lock(fenced_list->mutex);
- debug_printf("%10s %7s %10s %s\n",
- "buffer", "reference.count", "fence", "signalled");
+ debug_printf("%10s %7s %7s %10s %s\n",
+ "buffer", "size", "refcount", "fence", "signalled");
curr = fenced_list->unfenced.next;
next = curr->next;
while(curr != &fenced_list->unfenced) {
fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
assert(!fenced_buf->fence);
- debug_printf("%10p %7u\n",
+ debug_printf("%10p %7u %7u\n",
fenced_buf,
+ fenced_buf->base.base.size,
fenced_buf->base.base.reference.count);
curr = next;
next = curr->next;
@@ -552,8 +553,9 @@ fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list)
int signaled;
fenced_buf = LIST_ENTRY(struct fenced_buffer, curr, head);
signaled = ops->fence_signalled(ops, fenced_buf->fence, 0);
- debug_printf("%10p %7u %10p %s\n",
+ debug_printf("%10p %7u %7u %10p %s\n",
fenced_buf,
+ fenced_buf->base.base.size,
fenced_buf->base.base.reference.count,
fenced_buf->fence,
signaled == 0 ? "y" : "n");
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
index 689fd74771..6bdce5fcb0 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
@@ -53,6 +53,8 @@ static INLINE struct malloc_buffer *
malloc_buffer(struct pb_buffer *buf)
{
assert(buf);
+ if (!buf)
+ return NULL;
assert(buf->vtbl == &malloc_buffer_vtbl);
return (struct malloc_buffer *)buf;
}
@@ -102,7 +104,7 @@ malloc_buffer_fence(struct pb_buffer *buf,
static void
malloc_buffer_get_base_buffer(struct pb_buffer *buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
*base_buf = buf;
*offset = 0;
@@ -121,7 +123,7 @@ malloc_buffer_vtbl = {
struct pb_buffer *
-pb_malloc_buffer_create(size_t size,
+pb_malloc_buffer_create(pb_size size,
const struct pb_desc *desc)
{
struct malloc_buffer *buf;
@@ -150,7 +152,7 @@ pb_malloc_buffer_create(size_t size,
static struct pb_buffer *
pb_malloc_bufmgr_create_buffer(struct pb_manager *mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
return pb_malloc_buffer_create(size, desc);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
index 74077f8277..39ab8e722c 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
@@ -73,7 +73,7 @@ struct pb_manager
struct pb_buffer *
(*create_buffer)( struct pb_manager *mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc);
/**
@@ -106,7 +106,7 @@ pb_malloc_bufmgr_create(void);
*/
struct pb_manager *
pool_bufmgr_create(struct pb_manager *provider,
- size_t n, size_t size,
+ pb_size n, pb_size size,
const struct pb_desc *desc);
@@ -119,7 +119,7 @@ pool_bufmgr_create(struct pb_manager *provider,
*/
struct pb_manager *
mm_bufmgr_create(struct pb_manager *provider,
- size_t size, size_t align2);
+ pb_size size, pb_size align2);
/**
* Same as mm_bufmgr_create.
@@ -128,7 +128,7 @@ mm_bufmgr_create(struct pb_manager *provider,
*/
struct pb_manager *
mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
- size_t size, size_t align2);
+ pb_size size, pb_size align2);
/**
@@ -136,8 +136,8 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
*/
struct pb_manager *
pb_slab_manager_create(struct pb_manager *provider,
- size_t bufSize,
- size_t slabSize,
+ pb_size bufSize,
+ pb_size slabSize,
const struct pb_desc *desc);
/**
@@ -146,9 +146,9 @@ pb_slab_manager_create(struct pb_manager *provider,
*/
struct pb_manager *
pb_slab_range_manager_create(struct pb_manager *provider,
- size_t minBufSize,
- size_t maxBufSize,
- size_t slabSize,
+ pb_size minBufSize,
+ pb_size maxBufSize,
+ pb_size slabSize,
const struct pb_desc *desc);
@@ -204,7 +204,7 @@ pb_ondemand_manager_create(struct pb_manager *provider);
*/
struct pb_manager *
pb_debug_manager_create(struct pb_manager *provider,
- size_t underflow_size, size_t overflow_size);
+ pb_size underflow_size, pb_size overflow_size);
#ifdef __cplusplus
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
index db67d46c56..f60c836f18 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
@@ -60,7 +60,7 @@ pb_alt_manager(struct pb_manager *mgr)
static struct pb_buffer *
pb_alt_manager_create_buffer(struct pb_manager *_mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pb_alt_manager *mgr = pb_alt_manager(_mgr);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
index 35358430b4..57d1ede45a 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
@@ -81,7 +81,7 @@ struct pb_cache_manager
pipe_mutex mutex;
struct list_head delayed;
- size_t numDelayed;
+ pb_size numDelayed;
};
@@ -204,7 +204,7 @@ pb_cache_buffer_fence(struct pb_buffer *_buf,
static void
pb_cache_buffer_get_base_buffer(struct pb_buffer *_buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct pb_cache_buffer *buf = pb_cache_buffer(_buf);
pb_get_base_buffer(buf->buffer, base_buf, offset);
@@ -224,7 +224,7 @@ pb_cache_buffer_vtbl = {
static INLINE boolean
pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
if(buf->base.base.size < size)
@@ -246,7 +246,7 @@ pb_cache_is_buffer_compat(struct pb_cache_buffer *buf,
static struct pb_buffer *
pb_cache_manager_create_buffer(struct pb_manager *_mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pb_cache_manager *mgr = pb_cache_manager(_mgr);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
index f1a05be46e..1b4df28c70 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
@@ -40,6 +40,7 @@
#include "util/u_memory.h"
#include "util/u_double_list.h"
#include "util/u_time.h"
+#include "util/u_debug_stack.h"
#include "pb_buffer.h"
#include "pb_bufmgr.h"
@@ -48,6 +49,10 @@
#ifdef DEBUG
+#define PB_DEBUG_CREATE_BACKTRACE 8
+#define PB_DEBUG_MAP_BACKTRACE 8
+
+
/**
* Convenience macro (type safe).
*/
@@ -67,8 +72,16 @@ struct pb_debug_buffer
struct pb_buffer *buffer;
struct pb_debug_manager *mgr;
- size_t underflow_size;
- size_t overflow_size;
+ pb_size underflow_size;
+ pb_size overflow_size;
+
+ struct debug_stack_frame create_backtrace[PB_DEBUG_CREATE_BACKTRACE];
+
+ pipe_mutex mutex;
+ unsigned map_count;
+ struct debug_stack_frame map_backtrace[PB_DEBUG_MAP_BACKTRACE];
+
+ struct list_head head;
};
@@ -78,8 +91,11 @@ struct pb_debug_manager
struct pb_manager *provider;
- size_t underflow_size;
- size_t overflow_size;
+ pb_size underflow_size;
+ pb_size overflow_size;
+
+ pipe_mutex mutex;
+ struct list_head list;
};
@@ -108,9 +124,9 @@ static const uint8_t random_pattern[32] = {
static INLINE void
-fill_random_pattern(uint8_t *dst, size_t size)
+fill_random_pattern(uint8_t *dst, pb_size size)
{
- size_t i = 0;
+ pb_size i = 0;
while(size--) {
*dst++ = random_pattern[i++];
i &= sizeof(random_pattern) - 1;
@@ -119,11 +135,11 @@ fill_random_pattern(uint8_t *dst, size_t size)
static INLINE boolean
-check_random_pattern(const uint8_t *dst, size_t size,
- size_t *min_ofs, size_t *max_ofs)
+check_random_pattern(const uint8_t *dst, pb_size size,
+ pb_size *min_ofs, pb_size *max_ofs)
{
boolean result = TRUE;
- size_t i;
+ pb_size i;
*min_ofs = size;
*max_ofs = 0;
for(i = 0; i < size; ++i) {
@@ -167,7 +183,7 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf)
assert(map);
if(map) {
boolean underflow, overflow;
- size_t min_ofs, max_ofs;
+ pb_size min_ofs, max_ofs;
underflow = !check_random_pattern(map, buf->underflow_size,
&min_ofs, &max_ofs);
@@ -189,6 +205,9 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf)
max_ofs == buf->overflow_size - 1 ? "+" : "");
}
+ if(underflow || overflow)
+ debug_backtrace_dump(buf->create_backtrace, PB_DEBUG_CREATE_BACKTRACE);
+
debug_assert(!underflow && !overflow);
/* re-fill if not aborted */
@@ -207,11 +226,18 @@ static void
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));
pb_debug_buffer_check(buf);
+ pipe_mutex_lock(mgr->mutex);
+ LIST_DEL(&buf->head);
+ pipe_mutex_unlock(mgr->mutex);
+
+ pipe_mutex_destroy(buf->mutex);
+
pb_reference(&buf->buffer, NULL);
FREE(buf);
}
@@ -230,6 +256,13 @@ pb_debug_buffer_map(struct pb_buffer *_buf,
if(!map)
return NULL;
+ if(map) {
+ pipe_mutex_lock(buf->mutex);
+ ++buf->map_count;
+ debug_backtrace_capture(buf->map_backtrace, 1, PB_DEBUG_MAP_BACKTRACE);
+ pipe_mutex_unlock(buf->mutex);
+ }
+
return (uint8_t *)map + buf->underflow_size;
}
@@ -238,6 +271,13 @@ static void
pb_debug_buffer_unmap(struct pb_buffer *_buf)
{
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
+
+ pipe_mutex_lock(buf->mutex);
+ assert(buf->map_count);
+ if(buf->map_count)
+ --buf->map_count;
+ pipe_mutex_unlock(buf->mutex);
+
pb_unmap(buf->buffer);
pb_debug_buffer_check(buf);
@@ -247,7 +287,7 @@ pb_debug_buffer_unmap(struct pb_buffer *_buf)
static void
pb_debug_buffer_get_base_buffer(struct pb_buffer *_buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
pb_get_base_buffer(buf->buffer, base_buf, offset);
@@ -262,6 +302,14 @@ pb_debug_buffer_validate(struct pb_buffer *_buf,
{
struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
+ pipe_mutex_lock(buf->mutex);
+ if(buf->map_count) {
+ debug_printf("%s: attempting to validate a mapped buffer\n", __FUNCTION__);
+ debug_printf("last map backtrace is\n");
+ debug_backtrace_dump(buf->map_backtrace, PB_DEBUG_MAP_BACKTRACE);
+ }
+ pipe_mutex_unlock(buf->mutex);
+
pb_debug_buffer_check(buf);
return pb_validate(buf->buffer, vl, flags);
@@ -288,15 +336,40 @@ pb_debug_buffer_vtbl = {
};
+static void
+pb_debug_manager_dump(struct pb_debug_manager *mgr)
+{
+ struct list_head *curr, *next;
+ struct pb_debug_buffer *buf;
+
+ pipe_mutex_lock(mgr->mutex);
+
+ curr = mgr->list.next;
+ next = curr->next;
+ while(curr != &mgr->list) {
+ buf = LIST_ENTRY(struct pb_debug_buffer, curr, head);
+
+ debug_printf("buffer = %p\n", buf);
+ debug_printf(" .size = %p\n", buf->base.base.size);
+ debug_backtrace_dump(buf->create_backtrace, PB_DEBUG_CREATE_BACKTRACE);
+
+ curr = next;
+ next = curr->next;
+ }
+
+ pipe_mutex_unlock(mgr->mutex);
+}
+
+
static struct pb_buffer *
pb_debug_manager_create_buffer(struct pb_manager *_mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pb_debug_manager *mgr = pb_debug_manager(_mgr);
struct pb_debug_buffer *buf;
struct pb_desc real_desc;
- size_t real_size;
+ pb_size real_size;
buf = CALLOC_STRUCT(pb_debug_buffer);
if(!buf)
@@ -312,6 +385,13 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
&real_desc);
if(!buf->buffer) {
FREE(buf);
+#if 0
+ pipe_mutex_lock(mgr->mutex);
+ debug_printf("%s: failed to create buffer\n", __FUNCTION__);
+ if(!LIST_IS_EMPTY(&mgr->list))
+ pb_debug_manager_dump(mgr);
+ pipe_mutex_unlock(mgr->mutex);
+#endif
return NULL;
}
@@ -331,8 +411,16 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
buf->underflow_size = mgr->underflow_size;
buf->overflow_size = buf->buffer->base.size - buf->underflow_size - size;
+ debug_backtrace_capture(buf->create_backtrace, 1, PB_DEBUG_CREATE_BACKTRACE);
+
pb_debug_buffer_fill(buf);
+ pipe_mutex_init(buf->mutex);
+
+ pipe_mutex_lock(mgr->mutex);
+ LIST_ADDTAIL(&buf->head, &mgr->list);
+ pipe_mutex_unlock(mgr->mutex);
+
return &buf->base;
}
@@ -351,6 +439,15 @@ static void
pb_debug_manager_destroy(struct pb_manager *_mgr)
{
struct pb_debug_manager *mgr = pb_debug_manager(_mgr);
+
+ pipe_mutex_lock(mgr->mutex);
+ if(!LIST_IS_EMPTY(&mgr->list)) {
+ debug_printf("%s: unfreed buffers\n", __FUNCTION__);
+ pb_debug_manager_dump(mgr);
+ }
+ pipe_mutex_unlock(mgr->mutex);
+
+ pipe_mutex_destroy(mgr->mutex);
mgr->provider->destroy(mgr->provider);
FREE(mgr);
}
@@ -358,7 +455,7 @@ pb_debug_manager_destroy(struct pb_manager *_mgr)
struct pb_manager *
pb_debug_manager_create(struct pb_manager *provider,
- size_t underflow_size, size_t overflow_size)
+ pb_size underflow_size, pb_size overflow_size)
{
struct pb_debug_manager *mgr;
@@ -375,7 +472,10 @@ pb_debug_manager_create(struct pb_manager *provider,
mgr->provider = provider;
mgr->underflow_size = underflow_size;
mgr->overflow_size = overflow_size;
-
+
+ pipe_mutex_init(mgr->mutex);
+ LIST_INITHEAD(&mgr->list);
+
return &mgr->base;
}
@@ -385,7 +485,7 @@ pb_debug_manager_create(struct pb_manager *provider,
struct pb_manager *
pb_debug_manager_create(struct pb_manager *provider,
- size_t underflow_size, size_t overflow_size)
+ pb_size underflow_size, pb_size overflow_size)
{
return provider;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
index 144db5669b..97dd1427fd 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
@@ -62,7 +62,7 @@ fenced_pb_manager(struct pb_manager *mgr)
static struct pb_buffer *
fenced_bufmgr_create_buffer(struct pb_manager *mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct fenced_pb_manager *fenced_mgr = fenced_pb_manager(mgr);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
index 5a342fbf3b..6400fc5b0a 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
@@ -55,10 +55,10 @@ struct mm_pb_manager
pipe_mutex mutex;
- size_t size;
+ pb_size size;
struct mem_block *heap;
- size_t align2;
+ pb_size align2;
struct pb_buffer *buffer;
void *map;
@@ -148,7 +148,7 @@ mm_buffer_fence(struct pb_buffer *buf,
static void
mm_buffer_get_base_buffer(struct pb_buffer *buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct mm_buffer *mm_buf = mm_buffer(buf);
struct mm_pb_manager *mm = mm_buf->mgr;
@@ -170,15 +170,15 @@ mm_buffer_vtbl = {
static struct pb_buffer *
mm_bufmgr_create_buffer(struct pb_manager *mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct mm_pb_manager *mm = mm_pb_manager(mgr);
struct mm_buffer *mm_buf;
/* We don't handle alignments larger then the one initially setup */
- assert(pb_check_alignment(desc->alignment, 1 << mm->align2));
- if(!pb_check_alignment(desc->alignment, 1 << mm->align2))
+ assert(pb_check_alignment(desc->alignment, (pb_size)1 << mm->align2));
+ if(!pb_check_alignment(desc->alignment, (pb_size)1 << mm->align2))
return NULL;
pipe_mutex_lock(mm->mutex);
@@ -198,10 +198,10 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
mm_buf->mgr = mm;
- mm_buf->block = u_mmAllocMem(mm->heap, size, mm->align2, 0);
+ mm_buf->block = u_mmAllocMem(mm->heap, (int)size, (int)mm->align2, 0);
if(!mm_buf->block) {
- debug_printf("warning: heap full\n");
#if 0
+ debug_printf("warning: heap full\n");
mmDumpMemInfo(mm->heap);
#endif
FREE(mm_buf);
@@ -210,8 +210,8 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
}
/* Some sanity checks */
- assert(0 <= (unsigned)mm_buf->block->ofs && (unsigned)mm_buf->block->ofs < mm->size);
- assert(size <= (unsigned)mm_buf->block->size && (unsigned)mm_buf->block->ofs + (unsigned)mm_buf->block->size <= mm->size);
+ assert(0 <= (pb_size)mm_buf->block->ofs && (pb_size)mm_buf->block->ofs < mm->size);
+ assert(size <= (pb_size)mm_buf->block->size && (pb_size)mm_buf->block->ofs + (pb_size)mm_buf->block->size <= mm->size);
pipe_mutex_unlock(mm->mutex);
return SUPER(mm_buf);
@@ -245,7 +245,7 @@ mm_bufmgr_destroy(struct pb_manager *mgr)
struct pb_manager *
mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
- size_t size, size_t align2)
+ pb_size size, pb_size align2)
{
struct mm_pb_manager *mm;
@@ -273,7 +273,7 @@ mm_bufmgr_create_from_buffer(struct pb_buffer *buffer,
if(!mm->map)
goto failure;
- mm->heap = u_mmInit(0, size);
+ mm->heap = u_mmInit(0, (int)size);
if (!mm->heap)
goto failure;
@@ -292,7 +292,7 @@ if(mm->heap)
struct pb_manager *
mm_bufmgr_create(struct pb_manager *provider,
- size_t size, size_t align2)
+ pb_size size, pb_size align2)
{
struct pb_buffer *buffer;
struct pb_manager *mgr;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
index 4f7e6b1c4d..cb32d25136 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
@@ -55,7 +55,7 @@ struct pb_ondemand_buffer
/** Real buffer */
struct pb_buffer *buffer;
- size_t size;
+ pb_size size;
struct pb_desc desc;
};
@@ -74,6 +74,8 @@ static INLINE struct pb_ondemand_buffer *
pb_ondemand_buffer(struct pb_buffer *buf)
{
assert(buf);
+ if (!buf)
+ return NULL;
assert(buf->vtbl == &pb_ondemand_buffer_vtbl);
return (struct pb_ondemand_buffer *)buf;
}
@@ -204,7 +206,7 @@ pb_ondemand_buffer_fence(struct pb_buffer *_buf,
static void
pb_ondemand_buffer_get_base_buffer(struct pb_buffer *_buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct pb_ondemand_buffer *buf = pb_ondemand_buffer(_buf);
@@ -232,7 +234,7 @@ pb_ondemand_buffer_vtbl = {
static struct pb_buffer *
pb_ondemand_manager_create_buffer(struct pb_manager *_mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pb_ondemand_manager *mgr = pb_ondemand_manager(_mgr);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
index 07fd1a22d9..7fd65ed226 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
@@ -58,11 +58,11 @@ struct pool_pb_manager
pipe_mutex mutex;
- size_t bufSize;
- size_t bufAlign;
+ pb_size bufSize;
+ pb_size bufAlign;
- size_t numFree;
- size_t numTot;
+ pb_size numFree;
+ pb_size numTot;
struct list_head free;
@@ -89,7 +89,7 @@ struct pool_buffer
struct list_head head;
- size_t start;
+ pb_size start;
};
@@ -162,7 +162,7 @@ pool_buffer_fence(struct pb_buffer *buf,
static void
pool_buffer_get_base_buffer(struct pb_buffer *buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct pool_buffer *pool_buf = pool_buffer(buf);
struct pool_pb_manager *pool = pool_buf->mgr;
@@ -184,7 +184,7 @@ pool_buffer_vtbl = {
static struct pb_buffer *
pool_bufmgr_create_buffer(struct pb_manager *mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pool_pb_manager *pool = pool_pb_manager(mgr);
@@ -251,13 +251,13 @@ pool_bufmgr_destroy(struct pb_manager *mgr)
struct pb_manager *
pool_bufmgr_create(struct pb_manager *provider,
- size_t numBufs,
- size_t bufSize,
+ pb_size numBufs,
+ pb_size bufSize,
const struct pb_desc *desc)
{
struct pool_pb_manager *pool;
struct pool_buffer *pool_buf;
- size_t i;
+ pb_size i;
if(!provider)
return NULL;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
index 724aaadb43..e7352e90db 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
@@ -68,7 +68,7 @@ struct pb_slab_buffer
unsigned mapCount;
/** Offset relative to the start of the slab buffer. */
- size_t start;
+ pb_size start;
/** Use when validating, to signal that all mappings are finished */
/* TODO: Actually validation does not reach this stage yet */
@@ -83,8 +83,8 @@ struct pb_slab
{
struct list_head head;
struct list_head freeBuffers;
- size_t numBuffers;
- size_t numFree;
+ pb_size numBuffers;
+ pb_size numFree;
struct pb_slab_buffer *buffers;
struct pb_slab_manager *mgr;
@@ -108,10 +108,10 @@ struct pb_slab_manager
struct pb_manager *provider;
/** Size of the buffers we hand on downstream */
- size_t bufSize;
+ pb_size bufSize;
/** Size of the buffers we request upstream */
- size_t slabSize;
+ pb_size slabSize;
/**
* Alignment, usage to be used to allocate the slab buffers.
@@ -150,14 +150,14 @@ struct pb_slab_range_manager
struct pb_manager *provider;
- size_t minBufSize;
- size_t maxBufSize;
+ pb_size minBufSize;
+ pb_size maxBufSize;
/** @sa pb_slab_manager::desc */
struct pb_desc desc;
unsigned numBuckets;
- size_t *bucketSizes;
+ pb_size *bucketSizes;
/** Array of pb_slab_manager, one for each bucket size */
struct pb_manager **buckets;
@@ -270,7 +270,7 @@ pb_slab_buffer_fence(struct pb_buffer *_buf,
static void
pb_slab_buffer_get_base_buffer(struct pb_buffer *_buf,
struct pb_buffer **base_buf,
- unsigned *offset)
+ pb_size *offset)
{
struct pb_slab_buffer *buf = pb_slab_buffer(_buf);
pb_get_base_buffer(buf->slab->bo, base_buf, offset);
@@ -369,7 +369,7 @@ out_err0:
static struct pb_buffer *
pb_slab_manager_create_buffer(struct pb_manager *_mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pb_slab_manager *mgr = pb_slab_manager(_mgr);
@@ -450,8 +450,8 @@ pb_slab_manager_destroy(struct pb_manager *_mgr)
struct pb_manager *
pb_slab_manager_create(struct pb_manager *provider,
- size_t bufSize,
- size_t slabSize,
+ pb_size bufSize,
+ pb_size slabSize,
const struct pb_desc *desc)
{
struct pb_slab_manager *mgr;
@@ -479,11 +479,11 @@ pb_slab_manager_create(struct pb_manager *provider,
static struct pb_buffer *
pb_slab_range_manager_create_buffer(struct pb_manager *_mgr,
- size_t size,
+ pb_size size,
const struct pb_desc *desc)
{
struct pb_slab_range_manager *mgr = pb_slab_range_manager(_mgr);
- size_t bufSize;
+ pb_size bufSize;
unsigned i;
bufSize = mgr->minBufSize;
@@ -527,13 +527,13 @@ pb_slab_range_manager_destroy(struct pb_manager *_mgr)
struct pb_manager *
pb_slab_range_manager_create(struct pb_manager *provider,
- size_t minBufSize,
- size_t maxBufSize,
- size_t slabSize,
+ pb_size minBufSize,
+ pb_size maxBufSize,
+ pb_size slabSize,
const struct pb_desc *desc)
{
struct pb_slab_range_manager *mgr;
- size_t bufSize;
+ pb_size bufSize;
unsigned i;
if(!provider)