mesa/util: add allow_glsl_builtin_const_expression driconf override
authorTimothy Arceri <tarceri@itsqueeze.com>
Thu, 14 Jun 2018 01:00:22 +0000 (11:00 +1000)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 19 Jun 2018 02:09:56 +0000 (12:09 +1000)
Google Earth VR shaders uses builtins in constant expressions with
GLSL 1.10. That feature wasn't allowed until GLSL 1.20.

Reviewed-by: Dave Airlie <airlied@redhat.com>
src/compiler/glsl/ast_function.cpp
src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
src/gallium/include/state_tracker/st_api.h
src/gallium/state_trackers/dri/dri_screen.c
src/mesa/main/mtypes.h
src/mesa/state_tracker/st_extensions.c
src/util/xmlpool/t_options.h

index 22d58e48c64cb5c0046b8015b1974bace3da4758..127aa1f91c456903173379002e42af5345b1c8b3 100644 (file)
@@ -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);
index 21dc599dc2680c1ffef2aef931db63efafde85c4..f25f208008057acad0fe0ab46115a34d25726fbd 100644 (file)
@@ -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_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")
index ec6e7844b8703530be2542379f4c943d779a4616..1efc7f081d1ab85b2ffc64401bc1598fd312e77c 100644 (file)
@@ -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_builtin_const_expression;
    boolean allow_glsl_builtin_variable_redeclaration;
    boolean allow_higher_compat_version;
    boolean glsl_zero_init;
index aaee98707766b062fa2c3f830b64bfde179f1709..a86b7519364e92326a1502e68c0806de8b6075d3 100644 (file)
@@ -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_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 =
index ef9fce24d91eca99ab178bc977d964a1a191565e..e7d9c03cfde9efa8a24cf4a23b6670f843f103ec 100644 (file)
@@ -3721,6 +3721,12 @@ struct gl_constants
     */
    GLboolean AllowGLSLExtensionDirectiveMidShader;
 
+   /**
+    * 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
     */
index c540cee3974a95e79c98f78b3950ccc0022415a3..6586240cb03b8e4dd1c9b65c1ed466840dc21a47 100644 (file)
@@ -1134,6 +1134,9 @@ void st_init_extensions(struct pipe_screen *screen,
    if (options->allow_glsl_extension_directive_midshader)
       consts->AllowGLSLExtensionDirectiveMidShader = 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);
 
index 3ada813d639d7a842a3f21ce15fbeae30d37239b..1a4945d6888c13dc79eec1b102851d2d85867dbf 100644 (file)
@@ -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_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")) \