[Mesa-dev] [PATCH 03/11] mesa: add logging function for formatted string
Mark Janes
mark.a.janes at intel.com
Fri Dec 7 00:35:44 UTC 2018
---
src/mesa/main/errors.c | 27 +++++++++++++++++++++++++++
src/mesa/main/errors.h | 8 ++++++++
2 files changed, 35 insertions(+)
diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index fad8cb59cae..995b0510575 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -253,6 +253,33 @@ _mesa_gl_debugf(struct gl_context *ctx,
va_end(args);
}
+size_t
+_mesa_gl_debug(struct gl_context *ctx,
+ GLuint *id,
+ enum mesa_debug_source source,
+ enum mesa_debug_type type,
+ enum mesa_debug_severity severity,
+ const char *msg)
+{
+ _mesa_debug_get_id(id);
+
+ size_t len = strnlen(msg, MAX_DEBUG_MESSAGE_LENGTH);
+ if (len < MAX_DEBUG_MESSAGE_LENGTH) {
+ _mesa_log_msg(ctx, source, type, *id, severity, len, msg);
+ return len;
+ }
+
+ /* limit the message to fit within KHR_debug buffers */
+ char s[MAX_DEBUG_MESSAGE_LENGTH];
+ strncpy(s, msg, MAX_DEBUG_MESSAGE_LENGTH);
+ s[MAX_DEBUG_MESSAGE_LENGTH - 1] = '\0';
+ len = MAX_DEBUG_MESSAGE_LENGTH - 1;
+ _mesa_log_msg(ctx, source, type, *id, severity, len, s);
+
+ /* report the number of characters that were logged */
+ return len;
+}
+
/**
* Record an OpenGL state error. These usually occur when the user
diff --git a/src/mesa/main/errors.h b/src/mesa/main/errors.h
index 3e2d56e7741..17fe380f26a 100644
--- a/src/mesa/main/errors.h
+++ b/src/mesa/main/errors.h
@@ -90,6 +90,14 @@ _mesa_gl_debugf(struct gl_context *ctx,
enum mesa_debug_severity severity,
const char *fmtString, ...) PRINTFLIKE(6, 7);
+extern size_t
+_mesa_gl_debug(struct gl_context *ctx,
+ GLuint *id,
+ enum mesa_debug_source source,
+ enum mesa_debug_type type,
+ enum mesa_debug_severity severity,
+ const char *msg);
+
#define _mesa_perf_debug(ctx, sev, ...) do { \
static GLuint msg_id = 0; \
if (unlikely(ctx->Const.ContextFlags & GL_CONTEXT_FLAG_DEBUG_BIT)) { \
--
2.19.2
More information about the mesa-dev
mailing list