driconf: add allow_higher_compat_version option
authorSamuel Pitoiset <samuel.pitoiset@gmail.com>
Tue, 14 Feb 2017 15:18:24 +0000 (16:18 +0100)
committerSamuel Pitoiset <samuel.pitoiset@gmail.com>
Wed, 15 Feb 2017 15:15:32 +0000 (16:15 +0100)
Mesa currently doesn't allow to create 3.1+ compatibility profiles
mainly because various features are unimplemented and bugs can
happen.

However, some buggy apps request a compat profile without using
any old features unimplemented in mesa, and they fail to start.

This option should help some games to run but it's not enough
for all (eg. Dying Light).

v2: - s/force_compat_profile/allow_higher_compat_version

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/include/state_tracker/st_api.h
src/gallium/state_trackers/dri/dri_screen.c
src/mesa/drivers/dri/common/xmlpool/t_options.h
src/mesa/drivers/dri/i965/brw_context.c
src/mesa/main/mtypes.h
src/mesa/main/version.c
src/mesa/state_tracker/st_extensions.c

index a2e37d2e488e67be754c9d09cff197f64b730b0a..1b9ef290b1fd8af1d914e9bf13d24940edc2060a 100644 (file)
@@ -245,6 +245,7 @@ struct st_config_options
    unsigned force_glsl_version;
    boolean force_s3tc_enable;
    boolean allow_glsl_extension_directive_midshader;
+   boolean allow_higher_compat_version;
    boolean glsl_zero_init;
 };
 
index a950f5241d275f12b78242bddf3be0fc5e77acde..1e278c3d1c2ab49c1d8463652f9c00ccc261f613 100644 (file)
@@ -70,6 +70,7 @@ const __DRIconfigOptionsExtension gallium_config_options = {
          DRI_CONF_DISABLE_SHADER_BIT_ENCODING("false")
          DRI_CONF_FORCE_GLSL_VERSION(0)
          DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER("false")
+         DRI_CONF_ALLOW_HIGHER_COMPAT_VERSION("false")
       DRI_CONF_SECTION_END
 
       DRI_CONF_SECTION_MISCELLANEOUS
@@ -99,6 +100,8 @@ dri_fill_st_options(struct st_config_options *options,
       driQueryOptionb(optionCache, "force_s3tc_enable");
    options->allow_glsl_extension_directive_midshader =
       driQueryOptionb(optionCache, "allow_glsl_extension_directive_midshader");
+   options->allow_higher_compat_version =
+      driQueryOptionb(optionCache, "allow_higher_compat_version");
    options->glsl_zero_init = driQueryOptionb(optionCache, "glsl_zero_init");
 }
 
index a189bbedec6aeab70a0d96818a1fc14989158c11..f200093177deed2c667fde167c27bacf21197b7b 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_HIGHER_COMPAT_VERSION(def) \
+DRI_CONF_OPT_BEGIN_B(allow_higher_compat_version, def) \
+        DRI_CONF_DESC(en,gettext("Allow a higher compat profile (version 3.1+) for apps that request it")) \
+DRI_CONF_OPT_END
+
 
 
 /**
index 7240b1f4455d2c6b5fd5451a1c8aa305ae6a45c3..c56a14e3d66c445daa5fe8b98c2c7dd8ac019a66 100644 (file)
@@ -916,6 +916,9 @@ brw_process_driconf_options(struct brw_context *brw)
    ctx->Const.AllowGLSLExtensionDirectiveMidShader =
       driQueryOptionb(options, "allow_glsl_extension_directive_midshader");
 
+   ctx->Const.AllowHigherCompatVersion =
+      driQueryOptionb(options, "allow_higher_compat_version");
+
    ctx->Const.GLSLZeroInit = driQueryOptionb(options, "glsl_zero_init");
 
    brw->dual_color_blend_by_location =
index a845a394c8f7d4e788cea2b0478eb1f0d6b6aaf9..08bd929255c9459782cc5e6a21f87b7b89d14841 100644 (file)
@@ -3500,6 +3500,13 @@ struct gl_constants
     */
    GLboolean AllowGLSLExtensionDirectiveMidShader;
 
+   /**
+    * Allow creating a higher compat profile (version 3.1+) for apps that
+    * request it. Be careful when adding that driconf option because some
+    * features are unimplemented and might not work correctly.
+    */
+   GLboolean AllowHigherCompatVersion;
+
    /**
     * Force uninitialized variables to default to zero.
     */
index 85ec9de61225eb339076dbf1b9d1b54d3777010e..3d54d21a0428718d10176b24239fc6c9a66afd67 100644 (file)
@@ -566,8 +566,10 @@ _mesa_get_version(const struct gl_extensions *extensions,
    case API_OPENGL_COMPAT:
       /* Disable GLSL 1.40 and later for legacy contexts.
        * This disallows creation of the GL 3.1 compatibility context. */
-      if (consts->GLSLVersion > 130) {
-         consts->GLSLVersion = 130;
+      if (!consts->AllowHigherCompatVersion) {
+         if (consts->GLSLVersion > 130) {
+            consts->GLSLVersion = 130;
+         }
       }
       /* fall through */
    case API_OPENGL_CORE:
index 293814e3aec4fdbacd96b5962904bad7c419e409..37fe4469c37b7802e5dd2a2e8988257ed6f12019 100644 (file)
@@ -879,6 +879,8 @@ void st_init_extensions(struct pipe_screen *screen,
       consts->ForceGLSLVersion = options->force_glsl_version;
    }
 
+   consts->AllowHigherCompatVersion = options->allow_higher_compat_version;
+
    if (consts->GLSLVersion >= 400)
       extensions->ARB_gpu_shader5 = GL_TRUE;
    if (consts->GLSLVersion >= 410)