util: added debug_print_transfer_flags() function
authorBrian Paul <brianp@vmware.com>
Fri, 12 Oct 2012 18:10:59 +0000 (12:10 -0600)
committerBrian Paul <brianp@vmware.com>
Mon, 15 Oct 2012 13:49:14 +0000 (07:49 -0600)
src/gallium/auxiliary/util/u_debug.c
src/gallium/auxiliary/util/u_debug.h

index c41585fdd23c3aec7e14a298c0a4da52838d23ed..b26192a8b58a254789e8d37805a9fd41fe9c0269 100644 (file)
@@ -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
index ec7d4a07a8c803af6efce1b63772d1545c4f804c..14d319c2cf1db04b20f8ee99a98debaedd8acbd4 100644 (file)
@@ -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