Mesa (master): mesa: add _mesa_shader_debug()

Dylan Noblesmith nobled at kemper.freedesktop.org
Wed May 2 16:12:38 UTC 2012


Module: Mesa
Branch: master
Commit: 58fee81c78c95b1b086aa39aa4e26762c8943680
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=58fee81c78c95b1b086aa39aa4e26762c8943680

Author: Dylan Noblesmith <nobled at dreamwidth.org>
Date:   Mon Apr  2 16:11:11 2012 +0000

mesa: add _mesa_shader_debug()

This should be the one entrypoint libglsl needs
for GL_ARB_debug_output.

v2: added comments.

Reviewed-by: Brian Paul <brianp at vmware.com>

---

 src/mesa/main/errors.c |   43 +++++++++++++++++++++++++++++++++++++++++++
 src/mesa/main/errors.h |    3 +++
 2 files changed, 46 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/errors.c b/src/mesa/main/errors.c
index fcf873f..4a187b7 100644
--- a/src/mesa/main/errors.c
+++ b/src/mesa/main/errors.c
@@ -1062,4 +1062,47 @@ _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... )
    (void) fmtString;
 }
 
+
+/**
+ * Report debug information from the shader compiler via GL_ARB_debug_output.
+ *
+ * \param ctx GL context.
+ * \param type The namespace to which this message belongs.
+ * \param id The message ID within the given namespace.
+ * \param msg The message to output. Need not be null-terminated.
+ * \param len The length of 'msg'. If negative, 'msg' must be null-terminated.
+ */
+void
+_mesa_shader_debug( struct gl_context *ctx, GLenum type, GLuint id,
+                    const char *msg, int len )
+{
+   GLenum source = GL_DEBUG_SOURCE_SHADER_COMPILER_ARB,
+          severity;
+
+   switch (type) {
+   case GL_DEBUG_TYPE_ERROR_ARB:
+      assert(id < SHADER_ERROR_COUNT);
+      severity = GL_DEBUG_SEVERITY_HIGH_ARB;
+      break;
+   case GL_DEBUG_TYPE_DEPRECATED_BEHAVIOR_ARB:
+   case GL_DEBUG_TYPE_UNDEFINED_BEHAVIOR_ARB:
+   case GL_DEBUG_TYPE_PORTABILITY_ARB:
+   case GL_DEBUG_TYPE_PERFORMANCE_ARB:
+   case GL_DEBUG_TYPE_OTHER_ARB:
+      assert(0 && "other categories not implemented yet");
+   default:
+      _mesa_problem(ctx, "bad enum in _mesa_shader_debug()");
+      return;
+   }
+
+   if (len < 0)
+      len = strlen(msg);
+
+   /* Truncate the message if necessary. */
+   if (len >= MAX_DEBUG_MESSAGE_LENGTH)
+      len = MAX_DEBUG_MESSAGE_LENGTH - 1;
+
+   _mesa_log_msg(ctx, source, type, id, severity, len, msg);
+}
+
 /*@}*/
diff --git a/src/mesa/main/errors.h b/src/mesa/main/errors.h
index ed1c6fc..b4490fa 100644
--- a/src/mesa/main/errors.h
+++ b/src/mesa/main/errors.h
@@ -68,6 +68,9 @@ _mesa_error( struct gl_context *ctx, GLenum error, const char *fmtString, ... )
 extern void
 _mesa_debug( const struct gl_context *ctx, const char *fmtString, ... ) PRINTFLIKE(2, 3);
 
+extern void
+_mesa_shader_debug( struct gl_context *ctx, GLenum type, GLuint id, const char *msg, int len );
+
 #ifdef __cplusplus
 }
 #endif




More information about the mesa-commit mailing list