aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/glsl
diff options
context:
space:
mode:
Diffstat (limited to 'mesalib/src/glsl')
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.cpp51
-rw-r--r--mesalib/src/glsl/glsl_parser_extras.h3
-rw-r--r--mesalib/src/glsl/standalone_scaffolding.cpp6
-rw-r--r--mesalib/src/glsl/standalone_scaffolding.h4
4 files changed, 48 insertions, 16 deletions
diff --git a/mesalib/src/glsl/glsl_parser_extras.cpp b/mesalib/src/glsl/glsl_parser_extras.cpp
index ae7a365f4..6f1c86b43 100644
--- a/mesalib/src/glsl/glsl_parser_extras.cpp
+++ b/mesalib/src/glsl/glsl_parser_extras.cpp
@@ -36,8 +36,9 @@ extern "C" {
#include "ir_optimization.h"
#include "loop_analysis.h"
-_mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *ctx,
+_mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
GLenum target, void *mem_ctx)
+ : ctx(_ctx)
{
switch (target) {
case GL_VERTEX_SHADER: this->target = vertex_shader; break;
@@ -134,24 +135,49 @@ _mesa_glsl_shader_target_name(enum _mesa_glsl_parser_targets target)
return "unknown";
}
+/* This helper function will append the given message to the shader's
+ info log and report it via GL_ARB_debug_output. Per that extension,
+ 'type' is one of the enum values classifying the message, and
+ 'id' is the implementation-defined ID of the given message. */
+static void
+_mesa_glsl_msg(const YYLTYPE *locp, _mesa_glsl_parse_state *state,
+ GLenum type, GLuint id, const char *fmt, va_list ap)
+{
+ 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");
+}
void
_mesa_glsl_error(YYLTYPE *locp, _mesa_glsl_parse_state *state,
const char *fmt, ...)
{
va_list ap;
+ GLenum type = GL_DEBUG_TYPE_ERROR_ARB;
state->error = true;
- assert(state->info_log != NULL);
- ralloc_asprintf_append(&state->info_log, "%u:%u(%u): error: ",
- locp->source,
- locp->first_line,
- locp->first_column);
va_start(ap, fmt);
- ralloc_vasprintf_append(&state->info_log, fmt, ap);
+ _mesa_glsl_msg(locp, state, type, SHADER_ERROR_UNKNOWN, fmt, ap);
va_end(ap);
- ralloc_strcat(&state->info_log, "\n");
}
@@ -160,16 +186,11 @@ _mesa_glsl_warning(const YYLTYPE *locp, _mesa_glsl_parse_state *state,
const char *fmt, ...)
{
va_list ap;
+ GLenum type = GL_DEBUG_TYPE_OTHER_ARB;
- assert(state->info_log != NULL);
- ralloc_asprintf_append(&state->info_log, "%u:%u(%u): warning: ",
- locp->source,
- locp->first_line,
- locp->first_column);
va_start(ap, fmt);
- ralloc_vasprintf_append(&state->info_log, fmt, ap);
+ _mesa_glsl_msg(locp, state, type, 0, fmt, ap);
va_end(ap);
- ralloc_strcat(&state->info_log, "\n");
}
diff --git a/mesalib/src/glsl/glsl_parser_extras.h b/mesalib/src/glsl/glsl_parser_extras.h
index 55676f5a9..1a909c68b 100644
--- a/mesalib/src/glsl/glsl_parser_extras.h
+++ b/mesalib/src/glsl/glsl_parser_extras.h
@@ -57,7 +57,7 @@ struct glsl_switch_state {
};
struct _mesa_glsl_parse_state {
- _mesa_glsl_parse_state(struct gl_context *ctx, GLenum target,
+ _mesa_glsl_parse_state(struct gl_context *_ctx, GLenum target,
void *mem_ctx);
/* Callers of this ralloc-based new need not call delete. It's
@@ -77,6 +77,7 @@ struct _mesa_glsl_parse_state {
ralloc_free(mem);
}
+ struct gl_context *const ctx;
void *scanner;
exec_list translation_unit;
glsl_symbol_table *symbols;
diff --git a/mesalib/src/glsl/standalone_scaffolding.cpp b/mesalib/src/glsl/standalone_scaffolding.cpp
index 24cc64ad9..f15f2d882 100644
--- a/mesalib/src/glsl/standalone_scaffolding.cpp
+++ b/mesalib/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/mesalib/src/glsl/standalone_scaffolding.h b/mesalib/src/glsl/standalone_scaffolding.h
index 877332006..41ce35bef 100644
--- a/mesalib/src/glsl/standalone_scaffolding.h
+++ b/mesalib/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