Mesa (master): util: added debug_print_transfer_flags() function

Brian Paul brianp at kemper.freedesktop.org
Mon Oct 15 14:02:59 UTC 2012


Module: Mesa
Branch: master
Commit: 1ec12c53ba71622dc5dcf62c23972aa539792ccb
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=1ec12c53ba71622dc5dcf62c23972aa539792ccb

Author: Brian Paul <brianp at vmware.com>
Date:   Fri Oct 12 12:10:59 2012 -0600

util: added debug_print_transfer_flags() function

---

 src/gallium/auxiliary/util/u_debug.c |   41 ++++++++++++++++++++++++++++++++++
 src/gallium/auxiliary/util/u_debug.h |    4 +++
 2 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index c41585f..b26192a 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -691,4 +691,45 @@ error1:
    ;
 }
 
+
+/**
+ * Print PIPE_TRANSFER_x flags with a message.
+ */
+void
+debug_print_transfer_flags(const char *msg, unsigned usage)
+{
+#define FLAG(x)  { x, #x }
+   static const struct {
+      unsigned bit;
+      const char *name;
+   } flags[] = {
+      FLAG(PIPE_TRANSFER_READ),
+      FLAG(PIPE_TRANSFER_WRITE),
+      FLAG(PIPE_TRANSFER_MAP_DIRECTLY),
+      FLAG(PIPE_TRANSFER_DISCARD_RANGE),
+      FLAG(PIPE_TRANSFER_DONTBLOCK),
+      FLAG(PIPE_TRANSFER_UNSYNCHRONIZED),
+      FLAG(PIPE_TRANSFER_FLUSH_EXPLICIT),
+      FLAG(PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE)
+   };
+   unsigned i;
+
+   debug_printf("%s ", msg);
+
+   for (i = 0; i < Elements(flags); i++) {
+      if (usage & flags[i].bit) {
+         debug_printf("%s", flags[i].name);
+         usage &= ~flags[i].bit;
+         if (usage) {
+            debug_printf(" | ");
+         }
+      }
+   }
+
+   debug_printf("\n");
+#undef FLAG
+}
+
+
+
 #endif
diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h
index ec7d4a0..14d319c 100644
--- a/src/gallium/auxiliary/util/u_debug.h
+++ b/src/gallium/auxiliary/util/u_debug.h
@@ -446,6 +446,10 @@ void debug_dump_float_rgba_bmp(const char *filename,
 #endif
 
 
+void
+debug_print_transfer_flags(const char *msg, unsigned usage);
+
+
 #ifdef	__cplusplus
 }
 #endif




More information about the mesa-commit mailing list