summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Janes <[email protected]>2018-12-06 16:35:44 -0800
committerMark Janes <[email protected]>2019-03-14 12:56:59 -0700
commit16d108b502370b31cad7438a3e53b25554840f47 (patch)
tree51f7b7a964eb9ad1c93cdb486c7a1ea16a6cd91c
parentb8a1a3214afa3ac8f3b46ecce59bdd75a612c7e9 (diff)
mesa: add logging function for formatted string
Reviewed-by: Erik Faye-Lund <[email protected]>
-rw-r--r--src/mesa/main/errors.c27
-rw-r--r--src/mesa/main/errors.h8
2 files changed, 35 insertions, 0 deletions
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)) { \