From: Jakob Bornecrantz Date: Sat, 14 Mar 2009 09:22:48 +0000 (+0100) Subject: trace: Dump buffer data via buffer writes X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f73066fbd59ce2f5ce1268502850027bf4f0699b;p=mesa.git trace: Dump buffer data via buffer writes --- diff --git a/src/gallium/drivers/trace/tr_buffer.h b/src/gallium/drivers/trace/tr_buffer.h index e9daeb77028..e9e4d354dad 100644 --- a/src/gallium/drivers/trace/tr_buffer.h +++ b/src/gallium/drivers/trace/tr_buffer.h @@ -42,6 +42,7 @@ struct trace_buffer struct pipe_buffer *buffer; void *map; + boolean range_flushed; }; diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c index b2f9b369aef..098c609f005 100644 --- a/src/gallium/drivers/trace/tr_screen.c +++ b/src/gallium/drivers/trace/tr_screen.c @@ -554,8 +554,6 @@ trace_screen_user_buffer_create(struct pipe_screen *_screen, trace_dump_call_end(); - /* XXX: Mark the user buffers. (we should wrap pipe_buffers, but is is - * impossible to do so while texture-less surfaces are still around */ if(result) { assert(!(result->usage & TRACE_BUFFER_USAGE_USER)); result->usage |= TRACE_BUFFER_USAGE_USER; @@ -615,24 +613,13 @@ trace_screen_buffer_map(struct pipe_screen *_screen, struct pipe_buffer *buffer = tr_buf->buffer; void *map; - trace_dump_call_begin("pipe_screen", "buffer_map"); - - trace_dump_arg(ptr, screen); - trace_dump_arg(ptr, buffer); - trace_dump_arg(uint, usage); - assert(screen->buffer_map); map = screen->buffer_map(screen, buffer, usage); - - trace_dump_ret(ptr, map); -#if 0 if(map) { if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) { - assert(!hash_table_get(tr_ws->buffer_maps, buffer)); - hash_table_set(tr_ws->buffer_maps, buffer, map); + tr_buf->map = map; } } -#endif return map; } @@ -651,22 +638,42 @@ trace_screen_buffer_map_range(struct pipe_screen *_screen, struct pipe_buffer *buffer = tr_buf->buffer; void *map; - trace_dump_call_begin("pipe_screen", "buffer_map_range"); + assert(screen->buffer_map_range); + map = screen->buffer_map_range(screen, buffer, offset, length, usage); + if(map) { + if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) { + tr_buf->map = map; + } + } + + return map; +} + + +static void +buffer_write(struct pipe_screen *screen, + struct pipe_buffer *buffer, + const char *map, + unsigned offset, + unsigned length) +{ + assert(map); + + trace_dump_call_begin("pipe_screen", "buffer_write"); trace_dump_arg(ptr, screen); + trace_dump_arg(ptr, buffer); - trace_dump_arg(uint, offset); - trace_dump_arg(uint, length); - trace_dump_arg(uint, usage); - assert(screen->buffer_map_range); - map = screen->buffer_map_range(screen, buffer, offset, length, usage); + trace_dump_arg_begin("data"); + trace_dump_bytes(map + offset, length); + trace_dump_arg_end(); - trace_dump_ret(ptr, map); + trace_dump_arg(uint, offset); + trace_dump_arg(uint, length); trace_dump_call_end(); - return map; } @@ -681,17 +688,10 @@ trace_screen_buffer_flush_mapped_range(struct pipe_screen *_screen, struct pipe_screen *screen = tr_scr->screen; struct pipe_buffer *buffer = tr_buf->buffer; - trace_dump_call_begin("pipe_screen", "buffer_flush_mapped_range"); - - trace_dump_arg(ptr, screen); - trace_dump_arg(ptr, buffer); - trace_dump_arg(uint, offset); - trace_dump_arg(uint, length); - - assert(screen->buffer_flush_mapped_range); + assert(tr_buf->map); + buffer_write(screen, buffer, tr_buf->map, offset, length); + tr_buf->range_flushed = TRUE; screen->buffer_flush_mapped_range(screen, buffer, offset, length); - - trace_dump_call_end(); } @@ -703,40 +703,12 @@ trace_screen_buffer_unmap(struct pipe_screen *_screen, struct trace_buffer *tr_buf = trace_buffer(tr_scr, _buffer); struct pipe_screen *screen = tr_scr->screen; struct pipe_buffer *buffer = tr_buf->buffer; -#if 0 - const void *map; - - map = hash_table_get(tr_ws->buffer_maps, buffer); - if(map) { - trace_dump_call_begin("pipe_winsys", "buffer_write"); - - trace_dump_arg(ptr, winsys); - - trace_dump_arg(ptr, buffer); - - trace_dump_arg_begin("data"); - trace_dump_bytes(map, buffer->size); - trace_dump_arg_end(); - - trace_dump_arg_begin("size"); - trace_dump_uint(buffer->size); - trace_dump_arg_end(); - - trace_dump_call_end(); - - hash_table_remove(tr_ws->buffer_maps, buffer); - } -#endif - - trace_dump_call_begin("pipe_screen", "buffer_unmap"); - - trace_dump_arg(ptr, screen); - trace_dump_arg(ptr, buffer); - assert(screen->buffer_unmap); + if (tr_buf->map && !tr_buf->range_flushed) + buffer_write(screen, buffer, tr_buf->map, 0, buffer->size); + tr_buf->map = NULL; + tr_buf->range_flushed = FALSE; screen->buffer_unmap(screen, buffer); - - trace_dump_call_end(); }