summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNicolai Hähnle <[email protected]>2017-10-22 17:38:57 +0200
committerNicolai Hähnle <[email protected]>2017-11-09 14:01:02 +0100
commit8491fcafab2e5e534c5b38606eef4873adac4987 (patch)
tree7c58b677b5c3e1724cad5139c26f5abb64798060 /src
parent9b8033a4a7e52a4db4d60ce6e70fb30c9a9224fe (diff)
gallium/u_dump: add and use util_dump_transfer_usage
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/util/u_debug.c19
-rw-r--r--src/gallium/auxiliary/util/u_dump.h3
-rw-r--r--src/gallium/auxiliary/util/u_dump_defines.c53
-rw-r--r--src/gallium/auxiliary/util/u_dump_state.c2
4 files changed, 61 insertions, 16 deletions
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c
index dd3e16791d6..866cfbdd35e 100644
--- a/src/gallium/auxiliary/util/u_debug.c
+++ b/src/gallium/auxiliary/util/u_debug.c
@@ -31,6 +31,7 @@
#include "pipe/p_compiler.h"
#include "util/u_debug.h"
+#include "util/u_dump.h"
#include "pipe/p_format.h"
#include "pipe/p_state.h"
#include "util/u_inlines.h"
@@ -484,21 +485,9 @@ debug_funclog_enter_exit(const char* f, const int line, const char* file)
void
debug_print_transfer_flags(const char *msg, unsigned usage)
{
- static const struct debug_named_value names[] = {
- DEBUG_NAMED_VALUE(PIPE_TRANSFER_READ),
- DEBUG_NAMED_VALUE(PIPE_TRANSFER_WRITE),
- DEBUG_NAMED_VALUE(PIPE_TRANSFER_MAP_DIRECTLY),
- DEBUG_NAMED_VALUE(PIPE_TRANSFER_DISCARD_RANGE),
- DEBUG_NAMED_VALUE(PIPE_TRANSFER_DONTBLOCK),
- DEBUG_NAMED_VALUE(PIPE_TRANSFER_UNSYNCHRONIZED),
- DEBUG_NAMED_VALUE(PIPE_TRANSFER_FLUSH_EXPLICIT),
- DEBUG_NAMED_VALUE(PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE),
- DEBUG_NAMED_VALUE(PIPE_TRANSFER_PERSISTENT),
- DEBUG_NAMED_VALUE(PIPE_TRANSFER_COHERENT),
- DEBUG_NAMED_VALUE_END
- };
-
- debug_printf("%s: %s\n", msg, debug_dump_flags(names, usage));
+ debug_printf("%s: ", msg);
+ util_dump_transfer_usage(stdout, usage);
+ printf("\n");
}
diff --git a/src/gallium/auxiliary/util/u_dump.h b/src/gallium/auxiliary/util/u_dump.h
index be9a0fa26d0..8c1a8f3f4ee 100644
--- a/src/gallium/auxiliary/util/u_dump.h
+++ b/src/gallium/auxiliary/util/u_dump.h
@@ -102,6 +102,9 @@ util_dump_query_type(FILE *stream, unsigned value);
void
util_dump_query_value_type(FILE *stream, unsigned value);
+void
+util_dump_transfer_usage(FILE *stream, unsigned value);
+
/*
* p_state.h, through a FILE
*/
diff --git a/src/gallium/auxiliary/util/u_dump_defines.c b/src/gallium/auxiliary/util/u_dump_defines.c
index e87e5301600..e431cd969bd 100644
--- a/src/gallium/auxiliary/util/u_dump_defines.c
+++ b/src/gallium/auxiliary/util/u_dump_defines.c
@@ -29,6 +29,7 @@
#include "util/u_memory.h"
#include "util/u_debug.h"
#include "util/u_dump.h"
+#include "util/u_math.h"
#if 0
@@ -89,6 +90,41 @@ util_dump_enum_continuous(unsigned value,
return util_dump_enum_continuous(value, ARRAY_SIZE(util_##_name##_names), util_##_name##_names); \
}
+static void
+util_dump_flags_continuous(FILE *stream, unsigned value, unsigned num_names,
+ const char * const *names)
+{
+ unsigned unknown = 0;
+ bool first = true;
+
+ while (value) {
+ int i = u_bit_scan(&value);
+ if (i >= num_names || !names[i])
+ unknown |= 1u << i;
+ if (!first)
+ fputs("|", stream);
+ fputs(names[i], stream);
+ first = false;
+ }
+
+ if (unknown) {
+ if (!first)
+ fputs("|", stream);
+ fprintf(stream, "%x", unknown);
+ first = false;
+ }
+
+ if (first)
+ fputs("0", stream);
+}
+
+#define DEFINE_UTIL_DUMP_FLAGS_CONTINUOUS(_name) \
+void \
+util_dump_##_name(FILE *stream, unsigned value) \
+{ \
+ util_dump_flags_continuous(stream, value, ARRAY_SIZE(util_##_name##_names), \
+ util_##_name##_names); \
+}
static const char *
util_blend_factor_names[] = {
@@ -470,3 +506,20 @@ util_dump_query_value_type(FILE *stream, unsigned value)
{
fprintf(stream, "%s", util_str_query_value_type(value, false));
}
+
+
+static const char * const
+util_transfer_usage_names[] = {
+ "PIPE_TRANSFER_READ",
+ "PIPE_TRANSFER_WRITE",
+ "PIPE_TRANSFER_MAP_DIRECTLY",
+ "PIPE_TRANSFER_DISCARD_RANGE",
+ "PIPE_TRANSFER_DONTBLOCK",
+ "PIPE_TRANSFER_UNSYNCHRONIZED",
+ "PIPE_TRANSFER_FLUSH_EXPLICIT",
+ "PIPE_TRANSFER_DISCARD_WHOLE_RESOURCE",
+ "PIPE_TRANSFER_PERSISTENT",
+ "PIPE_TRANSFER_COHERENT",
+};
+
+DEFINE_UTIL_DUMP_FLAGS_CONTINUOUS(transfer_usage)
diff --git a/src/gallium/auxiliary/util/u_dump_state.c b/src/gallium/auxiliary/util/u_dump_state.c
index a2543beaf38..2725d50cd9a 100644
--- a/src/gallium/auxiliary/util/u_dump_state.c
+++ b/src/gallium/auxiliary/util/u_dump_state.c
@@ -812,7 +812,7 @@ util_dump_transfer(FILE *stream, const struct pipe_transfer *state)
util_dump_member(stream, ptr, state, resource);
util_dump_member(stream, uint, state, level);
- util_dump_member(stream, uint, state, usage);
+ util_dump_member(stream, transfer_usage, state, usage);
util_dump_member_begin(stream, "box");
util_dump_box(stream, &state->box);
util_dump_member_end(stream);