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/Makefile3
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer.h28
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c143
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h9
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c4
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr.h5
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c2
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c13
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c26
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c6
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c18
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c4
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c10
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c8
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_validate.c2
15 files changed, 186 insertions, 95 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/Makefile b/src/gallium/auxiliary/pipebuffer/Makefile
index 3b501c51df..1c00ba8d98 100644
--- a/src/gallium/auxiliary/pipebuffer/Makefile
+++ b/src/gallium/auxiliary/pipebuffer/Makefile
@@ -17,6 +17,3 @@ C_SOURCES = \
pb_validate.c
include ../../Makefile.template
-
-symlinks:
-
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer.h b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
index d8f1f02d68..2a1315922a 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer.h
@@ -45,10 +45,9 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_error.h"
#include "pipe/p_state.h"
-#include "pipe/p_inlines.h"
#ifdef __cplusplus
@@ -159,7 +158,7 @@ pb_map(struct pb_buffer *buf,
assert(buf);
if(!buf)
return NULL;
- assert(buf->base.refcount > 0);
+ assert(p_atomic_read(&buf->base.reference.count) > 0);
return buf->vtbl->map(buf, flags);
}
@@ -170,7 +169,7 @@ pb_unmap(struct pb_buffer *buf)
assert(buf);
if(!buf)
return;
- assert(buf->base.refcount > 0);
+ assert(p_atomic_read(&buf->base.reference.count) > 0);
buf->vtbl->unmap(buf);
}
@@ -186,7 +185,7 @@ pb_get_base_buffer( struct pb_buffer *buf,
offset = 0;
return;
}
- assert(buf->base.refcount > 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);
@@ -222,29 +221,18 @@ pb_destroy(struct pb_buffer *buf)
assert(buf);
if(!buf)
return;
- assert(buf->base.refcount == 0);
+ assert(p_atomic_read(&buf->base.reference.count) == 0);
buf->vtbl->destroy(buf);
}
-
-/* XXX: thread safety issues!
- */
static INLINE void
pb_reference(struct pb_buffer **dst,
struct pb_buffer *src)
{
- if (src) {
- assert(src->base.refcount);
- src->base.refcount++;
- }
-
- if (*dst) {
- assert((*dst)->base.refcount);
- if(--(*dst)->base.refcount == 0)
- pb_destroy( *dst );
- }
+ struct pb_buffer *old = *dst;
- *dst = src;
+ if (pipe_reference((struct pipe_reference**)dst, &src->base.reference))
+ pb_destroy( old );
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
index f9e6226436..1bdf7a0b2d 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
@@ -36,14 +36,14 @@
#include "pipe/p_config.h"
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
#include <unistd.h>
#include <sched.h>
#endif
#include "pipe/p_compiler.h"
#include "pipe/p_error.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
@@ -66,8 +66,12 @@ struct fenced_buffer_list
struct pb_fence_ops *ops;
size_t numDelayed;
-
struct list_head delayed;
+
+#ifdef DEBUG
+ size_t numUnfenced;
+ struct list_head unfenced;
+#endif
};
@@ -111,12 +115,15 @@ _fenced_buffer_add(struct fenced_buffer *fenced_buf)
{
struct fenced_buffer_list *fenced_list = fenced_buf->list;
- assert(fenced_buf->base.base.refcount);
+ assert(p_atomic_read(&fenced_buf->base.base.reference.count));
assert(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE);
assert(fenced_buf->fence);
- assert(!fenced_buf->head.prev);
- assert(!fenced_buf->head.next);
+#ifdef DEBUG
+ LIST_DEL(&fenced_buf->head);
+ assert(fenced_list->numUnfenced);
+ --fenced_list->numUnfenced;
+#endif
LIST_ADDTAIL(&fenced_buf->head, &fenced_list->delayed);
++fenced_list->numDelayed;
}
@@ -128,8 +135,19 @@ _fenced_buffer_add(struct fenced_buffer *fenced_buf)
static INLINE void
_fenced_buffer_destroy(struct fenced_buffer *fenced_buf)
{
- assert(!fenced_buf->base.base.refcount);
+ struct fenced_buffer_list *fenced_list = fenced_buf->list;
+
+ assert(p_atomic_read(&fenced_buf->base.base.reference.count) == 0);
assert(!fenced_buf->fence);
+#ifdef DEBUG
+ assert(fenced_buf->head.prev);
+ assert(fenced_buf->head.next);
+ LIST_DEL(&fenced_buf->head);
+ assert(fenced_list->numUnfenced);
+ --fenced_list->numUnfenced;
+#else
+ (void)fenced_list;
+#endif
pb_reference(&fenced_buf->buffer, NULL);
FREE(fenced_buf);
}
@@ -149,16 +167,21 @@ _fenced_buffer_remove(struct fenced_buffer_list *fenced_list,
assert(fenced_buf->head.prev);
assert(fenced_buf->head.next);
- LIST_DEL(&fenced_buf->head);
-#ifdef DEBUG
- fenced_buf->head.prev = NULL;
- fenced_buf->head.next = NULL;
-#endif
+ LIST_DEL(&fenced_buf->head);
assert(fenced_list->numDelayed);
--fenced_list->numDelayed;
- if(!fenced_buf->base.base.refcount)
+#ifdef DEBUG
+ LIST_ADDTAIL(&fenced_buf->head, &fenced_list->unfenced);
+ ++fenced_list->numUnfenced;
+#endif
+
+ /**
+ * FIXME!!!
+ */
+
+ if(!p_atomic_read(&fenced_buf->base.base.reference.count))
_fenced_buffer_destroy(fenced_buf);
}
@@ -234,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.refcount == 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) {
@@ -265,16 +288,26 @@ fenced_buffer_map(struct pb_buffer *buf,
unsigned flags)
{
struct fenced_buffer *fenced_buf = fenced_buffer(buf);
+ struct fenced_buffer_list *fenced_list = fenced_buf->list;
+ struct pb_fence_ops *ops = fenced_list->ops;
void *map;
- assert(flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE);
- assert(!(flags & ~PIPE_BUFFER_USAGE_CPU_READ_WRITE));
- flags &= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+ assert(!(flags & PIPE_BUFFER_USAGE_GPU_READ_WRITE));
- /* Check for GPU read/write access */
- if(fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) {
- /* Wait for the GPU to finish writing */
- _fenced_buffer_finish(fenced_buf);
+ /* Serialize writes */
+ if((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_WRITE) ||
+ ((fenced_buf->flags & PIPE_BUFFER_USAGE_GPU_READ) && (flags & PIPE_BUFFER_USAGE_CPU_WRITE))) {
+ if(flags & PIPE_BUFFER_USAGE_DONTBLOCK) {
+ /* Don't wait for the GPU to finish writing */
+ if(ops->fence_signalled(ops, fenced_buf->fence, 0) == 0)
+ _fenced_buffer_remove(fenced_list, fenced_buf);
+ else
+ return NULL;
+ }
+ else {
+ /* Wait for the GPU to finish writing */
+ _fenced_buffer_finish(fenced_buf);
+ }
}
#if 0
@@ -288,7 +321,7 @@ fenced_buffer_map(struct pb_buffer *buf,
map = pb_map(fenced_buf->buffer, flags);
if(map) {
++fenced_buf->mapcount;
- fenced_buf->flags |= flags;
+ fenced_buf->flags |= flags & PIPE_BUFFER_USAGE_CPU_READ_WRITE;
}
return map;
@@ -432,7 +465,7 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list,
return NULL;
}
- buf->base.base.refcount = 1;
+ pipe_reference_init(&buf->base.base.reference, 1);
buf->base.base.alignment = buffer->base.alignment;
buf->base.base.usage = buffer->base.usage;
buf->base.base.size = buffer->base.size;
@@ -441,6 +474,13 @@ fenced_buffer_create(struct fenced_buffer_list *fenced_list,
buf->buffer = buffer;
buf->list = fenced_list;
+#ifdef DEBUG
+ pipe_mutex_lock(fenced_list->mutex);
+ LIST_ADDTAIL(&buf->head, &fenced_list->unfenced);
+ ++fenced_list->numUnfenced;
+ pipe_mutex_unlock(fenced_list->mutex);
+#endif
+
return &buf->base;
}
@@ -457,9 +497,13 @@ fenced_buffer_list_create(struct pb_fence_ops *ops)
fenced_list->ops = ops;
LIST_INITHEAD(&fenced_list->delayed);
-
fenced_list->numDelayed = 0;
+#ifdef DEBUG
+ LIST_INITHEAD(&fenced_list->unfenced);
+ fenced_list->numUnfenced = 0;
+#endif
+
pipe_mutex_init(fenced_list->mutex);
return fenced_list;
@@ -476,6 +520,51 @@ fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
}
+#ifdef DEBUG
+void
+fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list)
+{
+ struct pb_fence_ops *ops = fenced_list->ops;
+ struct list_head *curr, *next;
+ struct fenced_buffer *fenced_buf;
+
+ pipe_mutex_lock(fenced_list->mutex);
+
+ debug_printf("%10s %7s %10s %s\n",
+ "buffer", "reference.count", "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",
+ fenced_buf,
+ fenced_buf->base.base.reference.count);
+ curr = next;
+ next = curr->next;
+ }
+
+ curr = fenced_list->delayed.next;
+ next = curr->next;
+ while(curr != &fenced_list->delayed) {
+ 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",
+ fenced_buf,
+ fenced_buf->base.base.reference.count,
+ fenced_buf->fence,
+ signaled == 0 ? "y" : "n");
+ curr = next;
+ next = curr->next;
+ }
+
+ pipe_mutex_unlock(fenced_list->mutex);
+}
+#endif
+
+
void
fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
{
@@ -484,13 +573,17 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list)
/* Wait on outstanding fences */
while (fenced_list->numDelayed) {
pipe_mutex_unlock(fenced_list->mutex);
-#if defined(PIPE_OS_LINUX)
+#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD)
sched_yield();
#endif
_fenced_buffer_list_check_free(fenced_list, 1);
pipe_mutex_lock(fenced_list->mutex);
}
+#ifdef DEBUG
+ //assert(!fenced_list->numUnfenced);
+#endif
+
pipe_mutex_unlock(fenced_list->mutex);
fenced_list->ops->destroy(fenced_list->ops);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
index d1c9d4c17d..034ca1e024 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h
@@ -51,7 +51,7 @@
#define PB_BUFFER_FENCED_H_
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#ifdef __cplusplus
@@ -114,6 +114,13 @@ void
fenced_buffer_list_check_free(struct fenced_buffer_list *fenced_list,
int wait);
+
+#ifdef DEBUG
+void
+fenced_buffer_list_dump(struct fenced_buffer_list *fenced_list);
+#endif
+
+
void
fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list);
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
index 53f497cfb0..689fd74771 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_malloc.c
@@ -34,7 +34,7 @@
*/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "pb_buffer.h"
#include "pb_bufmgr.h"
@@ -132,7 +132,7 @@ pb_malloc_buffer_create(size_t size,
if(!buf)
return NULL;
- buf->base.base.refcount = 1;
+ 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;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
index fec8db91c7..74077f8277 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr.h
@@ -200,10 +200,11 @@ pb_ondemand_manager_create(struct pb_manager *provider);
/**
* Debug buffer manager to detect buffer under- and overflows.
*
- * Band size should be a multiple of the largest alignment
+ * Under/overflow sizes should be a multiple of the largest alignment
*/
struct pb_manager *
-pb_debug_manager_create(struct pb_manager *provider, size_t band_size);
+pb_debug_manager_create(struct pb_manager *provider,
+ size_t underflow_size, size_t 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 c956924cc7..db67d46c56 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_alt.c
@@ -34,7 +34,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "pb_buffer.h"
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
index a168853713..010a2ecc1f 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_cache.c
@@ -35,7 +35,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
@@ -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.refcount);
+ 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.refcount == 0);
+ assert(p_atomic_read(&buf->base.base.reference.count) == 0);
_pb_cache_buffer_list_check_free(mgr);
@@ -293,7 +293,8 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr,
if(buf) {
LIST_DEL(&buf->head);
pipe_mutex_unlock(mgr->mutex);
- ++buf->base.base.refcount;
+ /* Increase refcount */
+ pb_reference((struct pb_buffer**)&buf, &buf->base);
return &buf->base;
}
@@ -309,12 +310,12 @@ pb_cache_manager_create_buffer(struct pb_manager *_mgr,
return NULL;
}
- assert(buf->buffer->base.refcount >= 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);
- buf->base.base.refcount = 1;
+ 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;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
index 26d9c24aec..478682dbee 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_debug.c
@@ -34,7 +34,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "util/u_math.h"
#include "util/u_memory.h"
@@ -78,7 +78,8 @@ struct pb_debug_manager
struct pb_manager *provider;
- size_t band_size;
+ size_t underflow_size;
+ size_t overflow_size;
};
@@ -205,9 +206,9 @@ pb_debug_buffer_check(struct pb_debug_buffer *buf)
static void
pb_debug_buffer_destroy(struct pb_buffer *_buf)
{
- struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
+ struct pb_debug_buffer *buf = pb_debug_buffer(_buf);
- assert(!buf->base.base.refcount);
+ assert(p_atomic_read(&buf->base.base.reference.count) == 0);
pb_debug_buffer_check(buf);
@@ -301,7 +302,7 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
if(!buf)
return NULL;
- real_size = size + 2*mgr->band_size;
+ real_size = mgr->underflow_size + size + mgr->overflow_size;
real_desc = *desc;
real_desc.usage |= PIPE_BUFFER_USAGE_CPU_WRITE;
real_desc.usage |= PIPE_BUFFER_USAGE_CPU_READ;
@@ -314,12 +315,12 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
return NULL;
}
- assert(buf->buffer->base.refcount >= 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);
- buf->base.base.refcount = 1;
+ 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;
@@ -327,7 +328,7 @@ pb_debug_manager_create_buffer(struct pb_manager *_mgr,
buf->base.vtbl = &pb_debug_buffer_vtbl;
buf->mgr = mgr;
- buf->underflow_size = mgr->band_size;
+ buf->underflow_size = mgr->underflow_size;
buf->overflow_size = buf->buffer->base.size - buf->underflow_size - size;
pb_debug_buffer_fill(buf);
@@ -356,7 +357,8 @@ pb_debug_manager_destroy(struct pb_manager *_mgr)
struct pb_manager *
-pb_debug_manager_create(struct pb_manager *provider, size_t band_size)
+pb_debug_manager_create(struct pb_manager *provider,
+ size_t underflow_size, size_t overflow_size)
{
struct pb_debug_manager *mgr;
@@ -371,7 +373,8 @@ pb_debug_manager_create(struct pb_manager *provider, size_t band_size)
mgr->base.create_buffer = pb_debug_manager_create_buffer;
mgr->base.flush = pb_debug_manager_flush;
mgr->provider = provider;
- mgr->band_size = band_size;
+ mgr->underflow_size = underflow_size;
+ mgr->overflow_size = overflow_size;
return &mgr->base;
}
@@ -381,7 +384,8 @@ pb_debug_manager_create(struct pb_manager *provider, size_t band_size)
struct pb_manager *
-pb_debug_manager_create(struct pb_manager *provider, size_t band_size)
+pb_debug_manager_create(struct pb_manager *provider,
+ size_t underflow_size, size_t 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 47e9fee533..144db5669b 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c
@@ -34,7 +34,7 @@
*/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "pb_buffer.h"
@@ -79,6 +79,10 @@ fenced_bufmgr_create_buffer(struct pb_manager *mgr,
buf = fenced_mgr->provider->create_buffer(fenced_mgr->provider, size, desc);
if(!buf) {
+#if 0
+ fenced_buffer_list_dump(fenced_mgr->fenced_list);
+#endif
+
/* give up */
return NULL;
}
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
index 2f5a5d8ea0..fb18dcc5dc 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c
@@ -34,7 +34,7 @@
#include "pipe/p_defines.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "util/u_memory.h"
#include "util/u_double_list.h"
@@ -97,11 +97,11 @@ mm_buffer_destroy(struct pb_buffer *buf)
struct mm_buffer *mm_buf = mm_buffer(buf);
struct mm_pb_manager *mm = mm_buf->mgr;
- assert(buf->base.refcount == 0);
+ assert(p_atomic_read(&mm_buf->base.base.reference.count) == 0);
pipe_mutex_lock(mm->mutex);
u_mmFreeMem(mm_buf->block);
- FREE(buf);
+ FREE(mm_buf);
pipe_mutex_unlock(mm->mutex);
}
@@ -189,7 +189,7 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
return NULL;
}
- mm_buf->base.base.refcount = 1;
+ 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;
@@ -204,13 +204,9 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr,
#if 0
mmDumpMemInfo(mm->heap);
#endif
-
- mm_buf->block = u_mmAllocMem(mm->heap, size, mm->align2, 0);
- if(!mm_buf->block) {
- FREE(mm_buf);
- pipe_mutex_unlock(mm->mutex);
- return NULL;
- }
+ FREE(mm_buf);
+ pipe_mutex_unlock(mm->mutex);
+ return NULL;
}
/* Some sanity checks */
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
index ba02a84e62..4f7e6b1c4d 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_ondemand.c
@@ -34,7 +34,7 @@
*/
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "util/u_memory.h"
#include "pb_buffer.h"
#include "pb_bufmgr.h"
@@ -242,7 +242,7 @@ pb_ondemand_manager_create_buffer(struct pb_manager *_mgr,
if(!buf)
return NULL;
- buf->base.base.refcount = 1;
+ 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;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
index a6ff37653e..75b95e132e 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_pool.c
@@ -36,7 +36,7 @@
#include "pipe/p_compiler.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
@@ -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.refcount == 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,8 +216,8 @@ 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.refcount == 0);
- pool_buf->base.base.refcount = 1;
+ 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;
@@ -295,7 +295,7 @@ pool_bufmgr_create(struct pb_manager *provider,
pool_buf = pool->bufs;
for (i = 0; i < numBufs; ++i) {
- pool_buf->base.base.refcount = 0;
+ 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;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
index 9b9fedccb4..a431fd5211 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_slab.c
@@ -38,7 +38,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_error.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pipe/p_thread.h"
#include "pipe/p_defines.h"
#include "util/u_memory.h"
@@ -202,7 +202,7 @@ pb_slab_buffer_destroy(struct pb_buffer *_buf)
pipe_mutex_lock(mgr->mutex);
- assert(buf->base.base.refcount == 0);
+ assert(p_atomic_read(&buf->base.base.reference.count) == 0);
buf->mapCount = 0;
@@ -340,7 +340,7 @@ pb_slab_create(struct pb_slab_manager *mgr)
buf = slab->buffers;
for (i=0; i < numBuffers; ++i) {
- buf->base.base.refcount = 0;
+ pipe_reference_init(&buf->base.base.reference, 0);
buf->base.base.size = mgr->bufSize;
buf->base.base.alignment = 0;
buf->base.base.usage = 0;
@@ -419,7 +419,7 @@ pb_slab_manager_create_buffer(struct pb_manager *_mgr,
pipe_mutex_unlock(mgr->mutex);
buf = LIST_ENTRY(struct pb_slab_buffer, list, head);
- ++buf->base.base.refcount;
+ pipe_reference_init(&buf->base.base.reference, 1);
buf->base.base.alignment = desc->alignment;
buf->base.base.usage = desc->usage;
diff --git a/src/gallium/auxiliary/pipebuffer/pb_validate.c b/src/gallium/auxiliary/pipebuffer/pb_validate.c
index 94532bb4ce..150fd50618 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_validate.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_validate.c
@@ -36,7 +36,7 @@
#include "pipe/p_compiler.h"
#include "pipe/p_error.h"
#include "util/u_memory.h"
-#include "pipe/p_debug.h"
+#include "util/u_debug.h"
#include "pb_buffer.h"
#include "pb_buffer_fenced.h"