From: Mark Janes Date: Fri, 7 Dec 2018 00:35:44 +0000 (-0800) Subject: mesa: add logging function for formatted string X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=16d108b502370b31cad7438a3e53b25554840f47;p=mesa.git mesa: add logging function for formatted string Reviewed-by: Erik Faye-Lund --- 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)) { \