<p dir="ltr">Reviewed-by: Marek Olšák <<a href="mailto:marek.olsak@amd.com">marek.olsak@amd.com</a>></p>
<div class="gmail_quote">On Nov 4, 2015 6:49 AM, "Ilia Mirkin" <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This will allow gallium drivers to send messages to KHR_debug endpoints<br>
<br>
Signed-off-by: Ilia Mirkin <<a href="mailto:imirkin@alum.mit.edu">imirkin@alum.mit.edu</a>><br>
---<br>
src/gallium/auxiliary/util/u_debug.c | 14 ++++++++++++++<br>
src/gallium/auxiliary/util/u_debug.h | 20 ++++++++++++++++++++<br>
src/gallium/docs/source/context.rst | 3 +++<br>
src/gallium/include/pipe/p_context.h | 8 ++++++++<br>
src/gallium/include/pipe/p_defines.h | 12 ++++++++++++<br>
src/gallium/include/pipe/p_state.h | 25 +++++++++++++++++++++++++<br>
6 files changed, 82 insertions(+)<br>
<br>
diff --git a/src/gallium/auxiliary/util/u_debug.c b/src/gallium/auxiliary/util/u_debug.c<br>
index 7388a49..7029536 100644<br>
--- a/src/gallium/auxiliary/util/u_debug.c<br>
+++ b/src/gallium/auxiliary/util/u_debug.c<br>
@@ -70,6 +70,20 @@ void _debug_vprintf(const char *format, va_list ap)<br>
#endif<br>
}<br>
<br>
+void<br>
+_pipe_debug_message(<br>
+ struct pipe_debug_callback *cb,<br>
+ unsigned *id,<br>
+ enum pipe_debug_type type,<br>
+ const char *fmt, ...)<br>
+{<br>
+ va_list args;<br>
+ va_start(args, fmt);<br>
+ if (cb && cb->debug_message)<br>
+ cb->debug_message(cb->data, id, type, fmt, args);<br>
+ va_end(args);<br>
+}<br>
+<br>
<br>
void<br>
debug_disable_error_message_boxes(void)<br>
diff --git a/src/gallium/auxiliary/util/u_debug.h b/src/gallium/auxiliary/util/u_debug.h<br>
index 926063a..aaf223c 100644<br>
--- a/src/gallium/auxiliary/util/u_debug.h<br>
+++ b/src/gallium/auxiliary/util/u_debug.h<br>
@@ -42,6 +42,7 @@<br>
#include "os/os_misc.h"<br>
<br>
#include "pipe/p_format.h"<br>
+#include "pipe/p_defines.h"<br>
<br>
<br>
#ifdef __cplusplus<br>
@@ -262,6 +263,25 @@ void _debug_assert_fail(const char *expr,<br>
_debug_printf("error: %s\n", __msg)<br>
#endif<br>
<br>
+/**<br>
+ * Output a debug log message to the debug info callback.<br>
+ */<br>
+#define pipe_debug_message(cb, type, fmt, ...) do { \<br>
+ static unsigned id = 0; \<br>
+ _pipe_debug_message(cb, &id, \<br>
+ PIPE_DEBUG_TYPE_ ## type, \<br>
+ fmt, __VA_ARGS__); \<br>
+} while (0)<br>
+<br>
+struct pipe_debug_callback;<br>
+<br>
+void<br>
+_pipe_debug_message(<br>
+ struct pipe_debug_callback *cb,<br>
+ unsigned *id,<br>
+ enum pipe_debug_type type,<br>
+ const char *fmt, ...) _util_printf_format(4, 5);<br>
+<br>
<br>
/**<br>
* Used by debug_dump_enum and debug_dump_flags to describe symbols.<br>
diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst<br>
index a7d08d2..dbc0877 100644<br>
--- a/src/gallium/docs/source/context.rst<br>
+++ b/src/gallium/docs/source/context.rst<br>
@@ -84,6 +84,9 @@ objects. They all follow simple, one-method binding calls, e.g.<br>
levels. This corresponds to GL's ``PATCH_DEFAULT_OUTER_LEVEL``.<br>
* ``default_inner_level`` is the default value for the inner tessellation<br>
levels. This corresponds to GL's ``PATCH_DEFAULT_INNER_LEVEL``.<br>
+* ``set_debug_callback`` sets the callback to be used for reporting<br>
+ various debug messages, eventually reported via KHR_debug and<br>
+ similar mechanisms.<br>
<br>
<br>
Sampler Views<br>
diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h<br>
index 6f9fe76..5adbd18 100644<br>
--- a/src/gallium/include/pipe/p_context.h<br>
+++ b/src/gallium/include/pipe/p_context.h<br>
@@ -45,6 +45,7 @@ struct pipe_blit_info;<br>
struct pipe_box;<br>
struct pipe_clip_state;<br>
struct pipe_constant_buffer;<br>
+struct pipe_debug_callback;<br>
struct pipe_depth_stencil_alpha_state;<br>
struct pipe_draw_info;<br>
struct pipe_fence_handle;<br>
@@ -239,6 +240,13 @@ struct pipe_context {<br>
const float default_inner_level[2]);<br>
<br>
/**<br>
+ * Sets the debug callback. If the pointer is null, then no callback is<br>
+ * set, otherwise a copy of the data should be made.<br>
+ */<br>
+ void (*set_debug_callback)(struct pipe_context *,<br>
+ const struct pipe_debug_callback *);<br>
+<br>
+ /**<br>
* Bind an array of shader buffers that will be used by a shader.<br>
* Any buffers that were previously bound to the specified range<br>
* will be unbound.<br>
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h<br>
index b15c880..d6f87cc 100644<br>
--- a/src/gallium/include/pipe/p_defines.h<br>
+++ b/src/gallium/include/pipe/p_defines.h<br>
@@ -868,6 +868,18 @@ struct pipe_driver_query_group_info<br>
unsigned num_queries;<br>
};<br>
<br>
+enum pipe_debug_type<br>
+{<br>
+ PIPE_DEBUG_TYPE_OUT_OF_MEMORY = 1,<br>
+ PIPE_DEBUG_TYPE_ERROR,<br>
+ PIPE_DEBUG_TYPE_SHADER_INFO,<br>
+ PIPE_DEBUG_TYPE_PERF_INFO,<br>
+ PIPE_DEBUG_TYPE_INFO,<br>
+ PIPE_DEBUG_TYPE_FALLBACK,<br>
+ PIPE_DEBUG_TYPE_CONFORMANCE,<br>
+};<br>
+<br>
+<br>
#ifdef __cplusplus<br>
}<br>
#endif<br>
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h<br>
index 4bf8d46..6bdf03a 100644<br>
--- a/src/gallium/include/pipe/p_state.h<br>
+++ b/src/gallium/include/pipe/p_state.h<br>
@@ -684,6 +684,31 @@ struct pipe_compute_state<br>
unsigned req_input_mem; /**< Required size of the INPUT resource. */<br>
};<br>
<br>
+/**<br>
+ * Structure that contains a callback for debug messages from the driver back<br>
+ * to the state tracker.<br>
+ */<br>
+struct pipe_debug_callback<br>
+{<br>
+ /**<br>
+ * Callback for the driver to report debug/performance/etc information back<br>
+ * to the state tracker.<br>
+ *<br>
+ * \param data user-supplied data pointer<br>
+ * \param id message type identifier, if pointed value is 0, then a<br>
+ * new id is assigned<br>
+ * \param type PIPE_DEBUG_TYPE_*<br>
+ * \param format printf-style format string<br>
+ * \param args args for format string<br>
+ */<br>
+ void (*debug_message)(void *data,<br>
+ unsigned *id,<br>
+ enum pipe_debug_type type,<br>
+ const char *fmt,<br>
+ va_list args);<br>
+ void *data;<br>
+};<br>
+<br>
#ifdef __cplusplus<br>
}<br>
#endif<br>
--<br>
2.4.10<br>
<br>
_______________________________________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="http://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">http://lists.freedesktop.org/mailman/listinfo/mesa-dev</a><br>
</blockquote></div>