Mesa (master): glsl: report errors via GL_ARB_debug_output
Dylan Noblesmith
nobled at kemper.freedesktop.org
Wed May 2 16:12:43 UTC 2012
Module: Mesa
Branch: master
Commit: d5a10dba6464d6cc40b3abcd6b704fb087e1056c
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d5a10dba6464d6cc40b3abcd6b704fb087e1056c
Author: Dylan Noblesmith <nobled at dreamwidth.org>
Date: Mon Apr 2 16:26:05 2012 +0000
glsl: report errors via GL_ARB_debug_output
Reviewed-by: Brian Paul <brianp at vmware.com>
---
src/glsl/glsl_parser_extras.cpp | 11 +++++++++++
src/glsl/standalone_scaffolding.cpp | 6 ++++++
src/glsl/standalone_scaffolding.h | 4 ++++
3 files changed, 21 insertions(+), 0 deletions(-)
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 4f26205..6f1c86b 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -146,12 +146,23 @@ _mesa_glsl_msg(const YYLTYPE *locp, _mesa_glsl_parse_state *state,
bool error = (type == GL_DEBUG_TYPE_ERROR_ARB);
assert(state->info_log != NULL);
+
+ /* Get the offset that the new message will be written to. */
+ int msg_offset = strlen(state->info_log);
+
ralloc_asprintf_append(&state->info_log, "%u:%u(%u): %s: ",
locp->source,
locp->first_line,
locp->first_column,
error ? "error" : "warning");
ralloc_vasprintf_append(&state->info_log, fmt, ap);
+
+ const char *const msg = &state->info_log[msg_offset];
+ struct gl_context *ctx = state->ctx;
+ /* Report the error via GL_ARB_debug_output. */
+ if (error)
+ _mesa_shader_debug(ctx, type, id, msg, strlen(msg));
+
ralloc_strcat(&state->info_log, "\n");
}
diff --git a/src/glsl/standalone_scaffolding.cpp b/src/glsl/standalone_scaffolding.cpp
index 24cc64a..f15f2d8 100644
--- a/src/glsl/standalone_scaffolding.cpp
+++ b/src/glsl/standalone_scaffolding.cpp
@@ -41,6 +41,12 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
*ptr = sh;
}
+void
+_mesa_shader_debug(struct gl_context *, GLenum, GLuint,
+ const char *, int)
+{
+}
+
struct gl_shader *
_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type)
{
diff --git a/src/glsl/standalone_scaffolding.h b/src/glsl/standalone_scaffolding.h
index 8773320..41ce35b 100644
--- a/src/glsl/standalone_scaffolding.h
+++ b/src/glsl/standalone_scaffolding.h
@@ -40,6 +40,10 @@ _mesa_reference_shader(struct gl_context *ctx, struct gl_shader **ptr,
extern "C" struct gl_shader *
_mesa_new_shader(struct gl_context *ctx, GLuint name, GLenum type);
+extern "C" void
+_mesa_shader_debug(struct gl_context *ctx, GLenum type, GLuint id,
+ const char *msg, int len);
+
/**
* Initialize the given gl_context structure to a reasonable set of
* defaults representing the minimum capabilities required by the
More information about the mesa-commit
mailing list