[Mesa-dev] [PATCH 4/7] mesa/util: add allow_glsl_builtin_const_expression driconf override
Timothy Arceri
tarceri at itsqueeze.com
Fri Jun 8 12:19:37 UTC 2018
Google Earth VR shaders uses builtins in constant expressions with
GLSL 1.10. That feature wasn't allowed until GLSL 1.20.
---
src/compiler/glsl/ast_function.cpp | 3 ++-
src/gallium/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 | 6 ++++++
src/mesa/state_tracker/st_extensions.c | 3 +++
src/util/xmlpool/t_options.h | 5 +++++
7 files changed, 20 insertions(+), 1 deletion(-)
diff --git a/src/compiler/glsl/ast_function.cpp b/src/compiler/glsl/ast_function.cpp
index 22d58e48c64..127aa1f91c4 100644
--- a/src/compiler/glsl/ast_function.cpp
+++ b/src/compiler/glsl/ast_function.cpp
@@ -529,7 +529,8 @@ generate_call(exec_list *instructions, ir_function_signature *sig,
* If the function call is a constant expression, don't generate any
* instructions; just generate an ir_constant.
*/
- if (state->is_version(120, 100)) {
+ if (state->is_version(120, 100) ||
+ state->ctx->Const.AllowGLSLBuiltinConstantExpression) {
ir_constant *value = sig->constant_expression_value(ctx,
actual_parameters,
NULL);
diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
index 5ca005de105..b5c9dc0eb61 100644
--- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
+++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
@@ -24,6 +24,7 @@ DRI_CONF_SECTION_DEBUG
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_CONST_EXPRESSION("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 08b825f84cc..033f2be8b26 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -223,6 +223,7 @@ struct st_config_options
unsigned force_glsl_version;
boolean allow_glsl_extension_directive_midshader;
boolean allow_glsl_semicolon_after_function;
+ boolean allow_glsl_builtin_const_expression;
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 49df6f4dddf..ddbd75aa85e 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -76,6 +76,8 @@ dri_fill_st_options(struct dri_screen *screen)
driQueryOptionb(optionCache, "allow_glsl_extension_directive_midshader");
options->allow_glsl_semicolon_after_function =
driQueryOptionb(optionCache, "allow_glsl_semicolon_after_function");
+ options->allow_glsl_builtin_const_expression =
+ driQueryOptionb(optionCache, "allow_glsl_builtin_const_expression");
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 15c52bee976..8847f461048 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3717,6 +3717,12 @@ struct gl_constants
*/
GLboolean AllowGLSLSemicolonAfterFunction;
+ /**
+ * Allow builtins as part of constant expressions. This was not allowed
+ * until GLSL 1.20 this allows it everywhere.
+ */
+ GLboolean AllowGLSLBuiltinConstantExpression;
+
/**
* 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 3ef963d9d5e..26190394577 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -1136,6 +1136,9 @@ void st_init_extensions(struct pipe_screen *screen,
if (options->allow_glsl_semicolon_after_function)
consts->AllowGLSLSemicolonAfterFunction = GL_TRUE;
+ if (options->allow_glsl_builtin_const_expression)
+ consts->AllowGLSLBuiltinConstantExpression = 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 a0b11c94fe0..e7054495e33 100644
--- a/src/util/xmlpool/t_options.h
+++ b/src/util/xmlpool/t_options.h
@@ -120,6 +120,11 @@ 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_CONST_EXPRESSION(def) \
+DRI_CONF_OPT_BEGIN_B(allow_glsl_builtin_const_expression, def) \
+ DRI_CONF_DESC(en,gettext("Allow builtins as part of constant expressions")) \
+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