#include "pipe/p_config.h"
-#if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) || defined(PIPE_OS_APPLE)
+#include <stdio.h>
#include <stdlib.h>
-#endif
#include "pipe/p_compiler.h"
#include "os/os_thread.h"
-#include "os/os_stream.h"
#include "util/u_debug.h"
#include "util/u_memory.h"
#include "util/u_string.h"
+#include "util/u_math.h"
+#include "util/u_format.h"
#include "tr_dump.h"
#include "tr_screen.h"
#include "tr_texture.h"
-static struct os_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)
- os_stream_write(stream, buf, size);
+ if (stream) {
+ fwrite(buf, size, 1, stream);
+ }
}
{
if(stream) {
trace_dump_writes("</trace>\n");
- os_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 = os_file_stream_create(filename);
+ stream = fopen(filename, "wt");
if(!stream)
return FALSE;
trace_dump_indent(1);
trace_dump_tag_end("call");
trace_dump_newline();
- os_stream_flush(stream);
+ fflush(stream);
}
void trace_dump_call_begin(const char *klass, const char *method)
}
void trace_dump_box_bytes(const void *data,
- unsigned format,
+ enum pipe_format format,
const struct pipe_box *box,
unsigned stride,
unsigned slice_stride)
{
- //size_t size = util_format_get_nblocksy(transfer->resource->format, transfer->box.height) * transfer->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)