[Mesa-dev] [PATCH 4/9] glsl: report errors via GL_ARB_debug_output

nobled nobled at dreamwidth.org
Fri Apr 13 08:51:56 PDT 2012


---
 src/glsl/glsl_parser_extras.cpp     |   14 ++++++++++++++
 src/glsl/standalone_scaffolding.cpp |    6 ++++++
 src/glsl/standalone_scaffolding.h   |    4 ++++
 3 files changed, 24 insertions(+), 0 deletions(-)

diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index aade2e1..d6a156d 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -139,13 +139,27 @@ static void
 _mesa_glsl_msg(const YYLTYPE *locp, _mesa_glsl_parse_state *state,
                bool error, const char *fmt, va_list ap)
 {
+   struct gl_context *ctx = state->ctx;
+   int msg_offset;
+   const char *msg;
+
    assert(state->info_log != NULL);
+
+   /* Get the offset that the new message will be written to. */
+   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);
+
+   msg = &state->info_log[msg_offset];
+   /* Report the error via GL_ARB_debug_output. */
+   if (error)
+      _mesa_shader_error(ctx, SHADER_ERROR_UNKNOWN, 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..99079b1 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_error(struct gl_context *, gl_shader_error,
+                   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..8dedbaa 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_error(struct gl_context *ctx, gl_shader_error err,
+                   const char *msg, int len);
+
 /**
  * Initialize the given gl_context structure to a reasonable set of
  * defaults representing the minimum capabilities required by the
-- 
1.7.4.1


More information about the mesa-dev mailing list