nv30: Silence pipe_cap warnings
[mesa.git] / src / gallium / drivers / trace / tr_dump.c
index 19cf0de1d38c5d7ea156f1acd1a4861bbf6a986d..ecc5bbcc2cf82f4f77aeebcfd759948f056aa8ec 100644 (file)
 
 #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);
+   }
 }
 
 
@@ -219,37 +219,24 @@ trace_dump_trace_close(void)
 {
    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;
 
@@ -366,7 +353,7 @@ void trace_dump_call_end_locked(void)
    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)
@@ -471,13 +458,22 @@ void trace_dump_bytes(const void *data,
 }
 
 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)