[Mesa-dev] [PATCH 2/7] mesa/util: add allow_glsl_semicolon_after_function driconfig override
Timothy Arceri
tarceri at itsqueeze.com
Fri Jun 8 12:19:35 UTC 2018
These are seen in Google Earth VR shaders.
---
src/compiler/glsl/glsl_parser.yy | 18 +++++++++++++++++-
.../auxiliary/pipe-loader/driinfo_gallium.h | 1 +
src/gallium/include/state_tracker/st_api.h | 1 +
src/gallium/state_trackers/dri/dri_screen.c | 2 ++
src/mesa/main/mtypes.h | 5 +++++
src/mesa/state_tracker/st_extensions.c | 3 +++
src/util/xmlpool/t_options.h | 5 +++++
7 files changed, 34 insertions(+), 1 deletion(-)
diff --git a/src/compiler/glsl/glsl_parser.yy b/src/compiler/glsl/glsl_parser.yy
index b4951a258aa..5eaae51a0df 100644
--- a/src/compiler/glsl/glsl_parser.yy
+++ b/src/compiler/glsl/glsl_parser.yy
@@ -2679,7 +2679,23 @@ external_declaration:
;
function_definition:
- function_prototype compound_statement_no_new_scope
+ function_prototype compound_statement_no_new_scope ';'
+ {
+ if (state->ctx->Const.AllowGLSLSemicolonAfterFunction) {
+ void *ctx = state->linalloc;
+ $$ = new(ctx) ast_function_definition();
+ $$->set_location_range(@1, @2);
+ $$->prototype = $1;
+ $$->body = $2;
+
+ state->symbols->pop_scope();
+ } else {
+ _mesa_glsl_error(& @1, state,
+ "semicolon not allowed following function "
+ "definition");
+ }
+ }
+ | function_prototype compound_statement_no_new_scope
{
void *ctx = state->linalloc;
$$ = new(ctx) ast_function_definition();
diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
index 21dc599dc26..5ca005de105 100644
--- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
+++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
@@ -23,6 +23,7 @@ DRI_CONF_SECTION_DEBUG
DRI_CONF_DISABLE_SHADER_BIT_ENCODING("false")
DRI_CONF_FORCE_GLSL_VERSION(0)
DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER("false")
+ DRI_CONF_ALLOW_GLSL_SEMICOLON_AFTER_FUNCTION("false")
DRI_CONF_ALLOW_GLSL_BUILTIN_VARIABLE_REDECLARATION("false")
DRI_CONF_ALLOW_GLSL_CROSS_STAGE_INTERPOLATION_MISMATCH("false")
DRI_CONF_ALLOW_HIGHER_COMPAT_VERSION("false")
diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
index ec6e7844b87..08b825f84cc 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -222,6 +222,7 @@ struct st_config_options
boolean force_glsl_extensions_warn;
unsigned force_glsl_version;
boolean allow_glsl_extension_directive_midshader;
+ boolean allow_glsl_semicolon_after_function;
boolean allow_glsl_builtin_variable_redeclaration;
boolean allow_higher_compat_version;
boolean glsl_zero_init;
diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
index aaee9870776..49df6f4dddf 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -74,6 +74,8 @@ dri_fill_st_options(struct dri_screen *screen)
driQueryOptioni(optionCache, "force_glsl_version");
options->allow_glsl_extension_directive_midshader =
driQueryOptionb(optionCache, "allow_glsl_extension_directive_midshader");
+ options->allow_glsl_semicolon_after_function =
+ driQueryOptionb(optionCache, "allow_glsl_semicolon_after_function");
options->allow_glsl_builtin_variable_redeclaration =
driQueryOptionb(optionCache, "allow_glsl_builtin_variable_redeclaration");
options->allow_higher_compat_version =
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 93136f5f8ad..15c52bee976 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3712,6 +3712,11 @@ struct gl_constants
*/
GLboolean AllowGLSLExtensionDirectiveMidShader;
+ /**
+ * Allow semicolon after function definition.
+ */
+ GLboolean AllowGLSLSemicolonAfterFunction;
+
/**
* Allow GLSL built-in variables to be redeclared verbatim
*/
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index bf73d506c17..3ef963d9d5e 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -1133,6 +1133,9 @@ void st_init_extensions(struct pipe_screen *screen,
if (options->allow_glsl_extension_directive_midshader)
consts->AllowGLSLExtensionDirectiveMidShader = GL_TRUE;
+ if (options->allow_glsl_semicolon_after_function)
+ consts->AllowGLSLSemicolonAfterFunction = GL_TRUE;
+
consts->MinMapBufferAlignment =
screen->get_param(screen, PIPE_CAP_MIN_MAP_BUFFER_ALIGNMENT);
diff --git a/src/util/xmlpool/t_options.h b/src/util/xmlpool/t_options.h
index 3ada813d639..a0b11c94fe0 100644
--- a/src/util/xmlpool/t_options.h
+++ b/src/util/xmlpool/t_options.h
@@ -115,6 +115,11 @@ DRI_CONF_OPT_BEGIN_B(allow_glsl_extension_directive_midshader, def) \
DRI_CONF_DESC(en,gettext("Allow GLSL #extension directives in the middle of shaders")) \
DRI_CONF_OPT_END
+#define DRI_CONF_ALLOW_GLSL_SEMICOLON_AFTER_FUNCTION(def) \
+DRI_CONF_OPT_BEGIN_B(allow_glsl_semicolon_after_function, def) \
+ DRI_CONF_DESC(en,gettext("Allow semicolon after function definition")) \
+DRI_CONF_OPT_END
+
#define DRI_CONF_ALLOW_GLSL_BUILTIN_VARIABLE_REDECLARATION(def) \
DRI_CONF_OPT_BEGIN_B(allow_glsl_builtin_variable_redeclaration, def) \
DRI_CONF_DESC(en,gettext("Allow GLSL built-in variables to be redeclared verbatim")) \
--
2.17.1
More information about the mesa-dev
mailing list