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

nobled nobled at dreamwidth.org
Fri Apr 13 08:52:26 PDT 2012


---
 src/glsl/glcpp/glcpp.c |    7 +++++++
 src/glsl/glcpp/pp.c    |   14 ++++++++++++++
 2 files changed, 21 insertions(+), 0 deletions(-)

diff --git a/src/glsl/glcpp/glcpp.c b/src/glsl/glcpp/glcpp.c
index bd6344b..3f20b2b 100644
--- a/src/glsl/glcpp/glcpp.c
+++ b/src/glsl/glcpp/glcpp.c
@@ -25,6 +25,7 @@
 #include <string.h>
 #include <errno.h>
 #include "glcpp.h"
+#include "main/errors.h"
 #include "main/mtypes.h"
 #include "main/shaderobj.h"

@@ -38,6 +39,12 @@ _mesa_reference_shader(struct gl_context *ctx,
struct gl_shader **ptr,
    *ptr = sh;
 }

+void
+_mesa_shader_error(struct gl_context *ctx, gl_shader_error err,
+                   const char *msg, int len)
+{
+}
+
 /* Read from fp until EOF and return a string of everything read.
  */
 static char *
diff --git a/src/glsl/glcpp/pp.c b/src/glsl/glcpp/pp.c
index 32054bb..c19b638 100644
--- a/src/glsl/glcpp/pp.c
+++ b/src/glsl/glcpp/pp.c
@@ -31,6 +31,15 @@ static void
 glcpp_msg (YYLTYPE *locp, glcpp_parser_t *parser, bool error,
            const char *fmt, va_list ap)
 {
+	struct gl_context *ctx = parser->ctx;
+	int msg_offset;
+	const char *msg;
+
+	assert(parser->info_log);
+
+	/* Get the offset that the new message will be written to. */
+	msg_offset = strlen(parser->info_log);
+
 	ralloc_asprintf_append(&parser->info_log, "%u:%u(%u): "
 						  "preprocessor %s: ",
 						  locp->source,
@@ -40,6 +49,11 @@ glcpp_msg (YYLTYPE *locp, glcpp_parser_t *parser, bool error,

 	ralloc_vasprintf_append(&parser->info_log, fmt, ap);

+	msg = &parser->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(&parser->info_log, "\n");
 }

-- 
1.7.4.1


More information about the mesa-dev mailing list