[Mesa-dev] [RFC PATCH 1/4] driconf: add new force_compat_profile option

Samuel Pitoiset samuel.pitoiset at gmail.com
Fri Feb 10 13:41:30 UTC 2017


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 but they fail to start because Mesa clamps the
GLSL version to 130 for compat.

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

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
---
 src/gallium/include/state_tracker/st_api.h      | 1 +
 src/gallium/state_trackers/dri/dri_screen.c     | 3 +++
 src/mesa/drivers/dri/common/xmlpool/t_options.h | 5 +++++
 src/mesa/drivers/dri/i965/brw_context.c         | 3 +++
 src/mesa/main/mtypes.h                          | 5 +++++
 src/mesa/main/version.c                         | 6 ++++--
 src/mesa/state_tracker/st_extensions.c          | 4 ++++
 7 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
index a2e37d2e48..d526639825 100644
--- a/src/gallium/include/state_tracker/st_api.h
+++ b/src/gallium/include/state_tracker/st_api.h
@@ -245,6 +245,7 @@ struct st_config_options
    unsigned force_glsl_version;
    boolean force_s3tc_enable;
    boolean allow_glsl_extension_directive_midshader;
+   boolean force_compat_profile;
    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 a950f5241d..95f76ff2aa 100644
--- a/src/gallium/state_trackers/dri/dri_screen.c
+++ b/src/gallium/state_trackers/dri/dri_screen.c
@@ -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_FORCE_COMPAT_PROFILE("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->force_compat_profile =
+      driQueryOptionb(optionCache, "force_compat_profile");
    options->glsl_zero_init = driQueryOptionb(optionCache, "glsl_zero_init");
 }
 
diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h b/src/mesa/drivers/dri/common/xmlpool/t_options.h
index a189bbedec..c6d2a22f81 100644
--- a/src/mesa/drivers/dri/common/xmlpool/t_options.h
+++ b/src/mesa/drivers/dri/common/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_FORCE_COMPAT_PROFILE(def) \
+DRI_CONF_OPT_BEGIN_B(force_compat_profile, def) \
+        DRI_CONF_DESC(en,gettext("Force a compat profile for apps that request it without using any old features")) \
+DRI_CONF_OPT_END
+
 
 
 /**
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 7240b1f445..6c61b806b1 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -916,6 +916,9 @@ brw_process_driconf_options(struct brw_context *brw)
    ctx->Const.AllowGLSLExtensionDirectiveMidShader =
       driQueryOptionb(options, "allow_glsl_extension_directive_midshader");
 
+   ctx->Const.ForceCompatProfile =
+      driQueryOptionb(options, "force_compat_profile");
+
    ctx->Const.GLSLZeroInit = driQueryOptionb(options, "glsl_zero_init");
 
    brw->dual_color_blend_by_location =
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index a845a394c8..a72afbc143 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -3501,6 +3501,11 @@ struct gl_constants
    GLboolean AllowGLSLExtensionDirectiveMidShader;
 
    /**
+    * Force creating a compatibility profile for apps that request it.
+    */
+   GLboolean ForceCompatProfile;
+
+   /**
     * Force uninitialized variables to default to zero.
     */
    GLboolean GLSLZeroInit;
diff --git a/src/mesa/main/version.c b/src/mesa/main/version.c
index 85ec9de612..037279aff4 100644
--- a/src/mesa/main/version.c
+++ b/src/mesa/main/version.c
@@ -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->ForceCompatProfile) {
+         if (consts->GLSLVersion > 130) {
+            consts->GLSLVersion = 130;
+         }
       }
       /* fall through */
    case API_OPENGL_CORE:
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 293814e3ae..cb1b9c09ba 100644
--- a/src/mesa/state_tracker/st_extensions.c
+++ b/src/mesa/state_tracker/st_extensions.c
@@ -879,6 +879,10 @@ void st_init_extensions(struct pipe_screen *screen,
       consts->ForceGLSLVersion = options->force_glsl_version;
    }
 
+   /* Force creating a compat profile for apps that request it without using
+    * any old features. Be careful when adding that driconf option. */
+   consts->ForceCompatProfile = options->force_compat_profile;
+
    if (consts->GLSLVersion >= 400)
       extensions->ARB_gpu_shader5 = GL_TRUE;
    if (consts->GLSLVersion >= 410)
-- 
2.11.1



More information about the mesa-dev mailing list