X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Ftrace%2Ftr_dump.c;h=ecc5bbcc2cf82f4f77aeebcfd759948f056aa8ec;hb=e253ead78e65a64b606e8f46cdceec2689aaf9f4;hp=3a1409e95a7e1820b61a8916602749431dd4c1e9;hpb=1036ef2bf468611d37b5df06fc4424f2002e3837;p=mesa.git diff --git a/src/gallium/drivers/trace/tr_dump.c b/src/gallium/drivers/trace/tr_dump.c index 3a1409e95a7..ecc5bbcc2cf 100644 --- a/src/gallium/drivers/trace/tr_dump.c +++ b/src/gallium/drivers/trace/tr_dump.c @@ -40,36 +40,35 @@ #include "pipe/p_config.h" -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) +#include #include -#endif #include "pipe/p_compiler.h" -#include "pipe/p_thread.h" +#include "os/os_thread.h" #include "util/u_debug.h" #include "util/u_memory.h" #include "util/u_string.h" -#include "util/u_stream.h" +#include "util/u_math.h" +#include "util/u_format.h" #include "tr_dump.h" #include "tr_screen.h" #include "tr_texture.h" -#include "tr_buffer.h" -static struct util_stream *stream = NULL; +static FILE *stream = NULL; static unsigned refcount = 0; -static pipe_mutex call_mutex; +pipe_static_mutex(call_mutex); static long unsigned call_no = 0; static boolean dumping = FALSE; -static boolean initialized = FALSE; static INLINE void trace_dump_write(const char *buf, size_t size) { - if(stream) - util_stream_write(stream, buf, size); + if (stream) { + fwrite(buf, size, 1, stream); + } } @@ -220,37 +219,24 @@ trace_dump_trace_close(void) { if(stream) { trace_dump_writes("\n"); - util_stream_close(stream); + fclose(stream); stream = NULL; refcount = 0; call_no = 0; - pipe_mutex_destroy(call_mutex); } } -void trace_dump_init() -{ - if (initialized) - return; - - pipe_mutex_init(call_mutex); - dumping = FALSE; - initialized = TRUE; -} - boolean trace_dump_trace_begin() { const char *filename; - assert(initialized); - filename = debug_get_option("GALLIUM_TRACE", NULL); if(!filename) return FALSE; if(!stream) { - stream = util_stream_create(filename, 0); + stream = fopen(filename, "wt"); if(!stream) return FALSE; @@ -258,7 +244,7 @@ boolean trace_dump_trace_begin() trace_dump_writes("\n"); trace_dump_writes("\n"); -#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) +#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE) /* Linux applications rarely cleanup GL / Gallium resources so catch * application exit here */ atexit(trace_dump_trace_close); @@ -351,7 +337,7 @@ void trace_dump_call_begin_locked(const char *klass, const char *method) trace_dump_indent(1); trace_dump_writes(""); } +void trace_dump_box_bytes(const void *data, + enum pipe_format format, + const struct pipe_box *box, + unsigned stride, + unsigned slice_stride) +{ + size_t size; + + if (slice_stride) + size = box->depth * slice_stride; + else if (stride) + size = util_format_get_nblocksy(format, box->height) * stride; + else { + size = util_format_get_nblocksx(format, box->width) * util_format_get_blocksize(format); + } + + trace_dump_bytes(data, size); +} + void trace_dump_string(const char *str) { if (!dumping) @@ -574,27 +579,15 @@ void trace_dump_ptr(const void *value) trace_dump_null(); } -void trace_dump_buffer_ptr(struct pipe_buffer *_buffer) -{ - if (!dumping) - return; - - if (_buffer) { - struct trace_buffer *tr_buf = trace_buffer(_buffer); - trace_dump_ptr(tr_buf->buffer); - } else { - trace_dump_null(); - } -} -void trace_dump_texture_ptr(struct pipe_texture *_texture) +void trace_dump_resource_ptr(struct pipe_resource *_resource) { if (!dumping) return; - if (_texture) { - struct trace_texture *tr_tex = trace_texture(_texture); - trace_dump_ptr(tr_tex->texture); + if (_resource) { + struct trace_resource *tr_resource = trace_resource(_resource); + trace_dump_ptr(tr_resource->resource); } else { trace_dump_null(); }