[Mesa-dev] [PATCH 2/2] add MESA_GLSL option to require that #extension directives come before any variable or function declarations, etc
Kevin Rogovin
kevin.rogovin at intel.com
Tue Dec 3 00:00:38 PST 2013
Add an additional bit flag, GLSL_EXTENSION_STRICT for
gl_context#Shader#Flags to require that #extension
directives must come before variable of function
declarations. The flag is set to on if MESA_GLSL has
the option extension_strict_ordering in it.
---
src/glsl/glsl_parser_extras.cpp | 6 +++---
src/mesa/main/mtypes.h | 8 +++++++-
src/mesa/main/shaderapi.c | 2 ++
3 files changed, 12 insertions(+), 4 deletions(-)
diff --git a/src/glsl/glsl_parser_extras.cpp b/src/glsl/glsl_parser_extras.cpp
index 75640e1..25d16ab 100644
--- a/src/glsl/glsl_parser_extras.cpp
+++ b/src/glsl/glsl_parser_extras.cpp
@@ -1515,11 +1515,11 @@ _mesa_glsl_compile_shader(struct gl_context *ctx, struct gl_shader *shader,
new(shader) _mesa_glsl_parse_state(ctx, shader->Type, shader);
const char *source = shader->Source;
- if(1) {
+ if(ctx->Shader.Flags&GLSL_EXTENSION_STRICT) {
+ state->ext_directive_list=NULL;
+ } else {
state->ext_directive_list=&extension_directive_list;
init_glcpp_extension_directive_list(state->ext_directive_list);
- } else {
- state->ext_directive_list=NULL;
}
state->error = glcpp_preprocess(state, &source, &state->info_log,
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index b4b432f..28cb5f9 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -2652,7 +2652,13 @@ struct gl_shader_program
#define GLSL_USE_PROG 0x80 /**< Log glUseProgram calls */
#define GLSL_REPORT_ERRORS 0x100 /**< Print compilation errors */
#define GLSL_DUMP_ON_ERROR 0x200 /**< Dump shaders to stderr on compile error */
-
+/**
+ * In GLSL sources, follow specifications
+ * with respect to #extension ordering, i.e.
+ * such directives must come before function
+ * declarations, variable declarations, etc.
+ */
+#define GLSL_EXTENSION_STRICT 0x400
/**
* Context state for GLSL vertex/fragment shaders.
diff --git a/src/mesa/main/shaderapi.c b/src/mesa/main/shaderapi.c
index 1d9aac3..dd12f42 100644
--- a/src/mesa/main/shaderapi.c
+++ b/src/mesa/main/shaderapi.c
@@ -92,6 +92,8 @@ get_shader_flags(void)
flags |= GLSL_USE_PROG;
if (strstr(env, "errors"))
flags |= GLSL_REPORT_ERRORS;
+ if(strstr(env, "extension_strict_ordering"))
+ flags |= GLSL_EXTENSION_STRICT;
}
return flags;
--
1.8.1.2
More information about the mesa-dev
mailing list