freedreno/a3xx/compiler: start adding integer support
[mesa.git] / src / gallium / drivers / trace / tr_dump.c
index 826ce5bc1ba46815be7082368271ba5a26b88480..753b92d8b54012a31bf10fa690bc7c3166c718dc 100644 (file)
@@ -1,6 +1,6 @@
 /**************************************************************************
  *
- * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * Copyright 2008 VMware, Inc.
  * All Rights Reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,7 +18,7 @@
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -35,7 +35,7 @@
  * is abstracted out of this file, so that we can switch to a binary
  * representation if/when it becomes justified.
  *
- * @author Jose Fonseca <jrfonseca@tungstengraphics.com>
+ * @author Jose Fonseca <jfonseca@vmware.com>
  */
 
 #include "pipe/p_config.h"
@@ -59,7 +59,6 @@
 
 static boolean close_stream = FALSE;
 static FILE *stream = NULL;
-static unsigned refcount = 0;
 pipe_static_mutex(call_mutex);
 static long unsigned call_no = 0;
 static boolean dumping = FALSE;
@@ -234,7 +233,6 @@ trace_dump_trace_close(void)
          close_stream = FALSE;
          stream = NULL;
       }
-      refcount = 0;
       call_no = 0;
    }
 }
@@ -283,15 +281,13 @@ trace_dump_trace_begin(void)
       trace_dump_writes("<?xml-stylesheet type='text/xsl' href='trace.xsl'?>\n");
       trace_dump_writes("<trace version='0.1'>\n");
 
-#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 */
+      /* Many applications don't exit cleanly, others may create and destroy a
+       * screen multiple times, so we only write </trace> tag and close at exit
+       * time.
+       */
       atexit(trace_dump_trace_close);
-#endif
    }
 
-   ++refcount;
-
    return TRUE;
 }
 
@@ -300,13 +296,6 @@ boolean trace_dump_trace_enabled(void)
    return stream ? TRUE : FALSE;
 }
 
-void trace_dump_trace_end(void)
-{
-   if(stream)
-      if(!--refcount)
-         trace_dump_trace_close();
-}
-
 /*
  * Call lock
  */
@@ -506,19 +495,28 @@ void trace_dump_bytes(const void *data,
 }
 
 void trace_dump_box_bytes(const void *data,
-                         enum pipe_format format,
+                          struct pipe_resource *resource,
                          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);
+   /*
+    * Only dump buffer transfers to avoid huge files.
+    * TODO: Make this run-time configurable
+    */
+   if (resource->target != PIPE_BUFFER) {
+      size = 0;
+   } else {
+      enum pipe_format format = resource->format;
+      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);