From c7431552c0ff203cd4b3ae37751b10e6111e4167 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 18 Feb 2009 10:25:04 +0000 Subject: pipebuffer: Don't retry to alloc memory block on mm. It will give the same result 2nd time too, as fencing is done at a higher level. --- src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) (limited to 'src/gallium/auxiliary/pipebuffer') diff --git a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c index fe80ca30ee..37984e7b7b 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_mm.c @@ -181,13 +181,9 @@ mm_bufmgr_create_buffer(struct pb_manager *mgr, #if 0 mmDumpMemInfo(mm->heap); #endif - - mm_buf->block = 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 */ -- cgit v1.2.3 From 7c12e1aa53ba457d29edf4c07d834c70d51f0bbd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Fonseca?= Date: Wed, 18 Feb 2009 15:12:16 +0000 Subject: pipebuffer: Dump debugging info for fenced buffer list. --- .../auxiliary/pipebuffer/pb_buffer_fenced.c | 98 ++++++++++++++++++++-- .../auxiliary/pipebuffer/pb_buffer_fenced.h | 7 ++ .../auxiliary/pipebuffer/pb_bufmgr_fenced.c | 4 + 3 files changed, 100 insertions(+), 9 deletions(-) (limited to 'src/gallium/auxiliary/pipebuffer') diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c index 17b2781052..c3d747898a 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c @@ -74,8 +74,12 @@ struct fenced_buffer_list struct pipe_winsys *winsys; size_t numDelayed; - struct list_head delayed; + +#ifdef DEBUG + size_t numUnfenced; + struct list_head unfenced; +#endif }; @@ -122,8 +126,11 @@ _fenced_buffer_add(struct fenced_buffer *fenced_buf) 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; } @@ -135,8 +142,19 @@ _fenced_buffer_add(struct fenced_buffer *fenced_buf) static INLINE void _fenced_buffer_destroy(struct fenced_buffer *fenced_buf) { + struct fenced_buffer_list *fenced_list = fenced_buf->list; + assert(!fenced_buf->base.base.refcount); 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); } @@ -156,15 +174,16 @@ _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; +#ifdef DEBUG + LIST_ADDTAIL(&fenced_buf->head, &fenced_list->unfenced); + ++fenced_list->numUnfenced; +#endif + if(!fenced_buf->base.base.refcount) _fenced_buffer_destroy(fenced_buf); } @@ -358,6 +377,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; } @@ -420,9 +446,13 @@ fenced_buffer_list_create(struct pipe_winsys *winsys) fenced_list->winsys = winsys; 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; @@ -439,6 +469,52 @@ 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 pipe_winsys *winsys = fenced_list->winsys; + struct list_head *curr, *next; + struct fenced_buffer *fenced_buf; + struct pipe_fence_handle *prev_fence = NULL; + + pipe_mutex_lock(fenced_list->mutex); + + debug_printf("%10s %7s %10s %s\n", + "buffer", "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", + fenced_buf, + fenced_buf->base.base.refcount); + 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 = winsys->fence_signalled(winsys, fenced_buf->fence, 0); + debug_printf("%10p %7u %10p %s\n", + fenced_buf, + fenced_buf->base.base.refcount, + 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) { @@ -454,6 +530,10 @@ fenced_buffer_list_destroy(struct fenced_buffer_list *fenced_list) pipe_mutex_lock(fenced_list->mutex); } +#ifdef DEBUG + //assert(!fenced_list->numUnfenced); +#endif + pipe_mutex_unlock(fenced_list->mutex); FREE(fenced_list); diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h index 50d5891bdb..510f456508 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h +++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.h @@ -94,6 +94,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_bufmgr_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c index 633ee70a75..8d67efab6c 100644 --- a/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c +++ b/src/gallium/auxiliary/pipebuffer/pb_bufmgr_fenced.c @@ -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; } -- cgit v1.2.3