From b1e67c5d840a2c07c4ccf73bf1d3200b8531efa3 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Thu, 3 Jan 2008 19:46:59 +0000 Subject: [PATCH] 965: fix various refcount issues --- src/mesa/pipe/xlib/xm_winsys_aub.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/mesa/pipe/xlib/xm_winsys_aub.c b/src/mesa/pipe/xlib/xm_winsys_aub.c index b2076383906..2be8f8793de 100644 --- a/src/mesa/pipe/xlib/xm_winsys_aub.c +++ b/src/mesa/pipe/xlib/xm_winsys_aub.c @@ -99,6 +99,8 @@ static void *aub_buffer_map(struct pipe_winsys *winsys, { struct aub_buffer *sbo = aub_bo(buf); + assert(sbo->data); + if (flags & PIPE_BUFFER_FLAG_WRITE) sbo->dump_on_unmap = 1; @@ -116,6 +118,9 @@ static void aub_buffer_unmap(struct pipe_winsys *winsys, if (sbo->map_count == 0 && sbo->dump_on_unmap) { + + sbo->dump_on_unmap = 0; + brw_aub_gtt_data( iws->aubfile, sbo->offset, sbo->data, @@ -132,6 +137,7 @@ aub_buffer_reference(struct pipe_winsys *winsys, struct pipe_buffer_handle *buf) { if (*ptr) { + assert(aub_bo(*ptr)->refcount != 0); if (--(aub_bo(*ptr)->refcount) == 0) free(*ptr); *ptr = NULL; @@ -273,7 +279,9 @@ aub_buffer_create(struct pipe_winsys *winsys, unsigned flags, unsigned hint) { - return pipe_bo(CALLOC_STRUCT(aub_buffer)); + struct aub_buffer *sbo = CALLOC_STRUCT(aub_buffer); + sbo->refcount = 1; + return pipe_bo(sbo); } @@ -282,6 +290,8 @@ aub_user_buffer_create(struct pipe_winsys *winsys, void *ptr, unsigned bytes) { struct aub_buffer *sbo = CALLOC_STRUCT(aub_buffer); + sbo->refcount = 1; + /* Lets hope this is meant for upload, not as a result! */ aub_buffer_data( winsys, -- 2.30.2