[Mesa-dev] [RFC PATCH 1/1] st/dri: add a new driconf option override_glsl_version for ARK games

Eero Tamminen eero.t.tamminen at intel.com
Mon Feb 6 15:04:26 UTC 2017


Hi,
On 03.02.2017 19:23, Samuel Pitoiset wrote:
> This is similar to the MESA_GLSL_VERSION_OVERRIDE envvar (mainly
> for developers). But this one has the advantage to be configured
> for specific apps which require a context with an explicit version.
>
> For example, when an app requires a 3.2 core context, RadeonSI
> will return a 4.5 context but this might fail (eg. ARK games).
>
> No need to add both "ARK: Survival Evolved" and "ARK: Survival
> Of The Fittest" because the executable name is the same.

Those games use Unreal Engine v4 and "ShooterGame" is the binary name 
for one of the demos included in UE v4 SDK:
	https://wiki.unrealengine.com/Linux_Demos

If ARK developers couldn't be bothered to change the name of their 
binary before release, maybe other game developers don't/haven't either. 
  I.e. I'm not sure it's unique enough.


-> Safer to have an option that just tells Mesa to use context version 
that the application requested (if Mesa supports that on given HW).


	- Eero

> 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/gallium/state_trackers/osmesa/osmesa.c      | 1 +
>  src/mesa/drivers/dri/common/drirc               | 4 ++++
>  src/mesa/drivers/dri/common/xmlpool/t_options.h | 5 +++++
>  src/mesa/drivers/dri/i965/brw_context.c         | 3 +++
>  src/mesa/state_tracker/st_extensions.c          | 3 +++
>  7 files changed, 20 insertions(+)
>
> diff --git a/src/gallium/include/state_tracker/st_api.h b/src/gallium/include/state_tracker/st_api.h
> index a2e37d2e48..e0a73d74ad 100644
> --- a/src/gallium/include/state_tracker/st_api.h
> +++ b/src/gallium/include/state_tracker/st_api.h
> @@ -246,6 +246,7 @@ struct st_config_options
>     boolean force_s3tc_enable;
>     boolean allow_glsl_extension_directive_midshader;
>     boolean glsl_zero_init;
> +   unsigned override_glsl_version;
>  };
>
>  /**
> diff --git a/src/gallium/state_trackers/dri/dri_screen.c b/src/gallium/state_trackers/dri/dri_screen.c
> index a950f5241d..a1fa0a3be3 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_OVERRIDE_GLSL_VERSION(0)
>        DRI_CONF_SECTION_END
>
>        DRI_CONF_SECTION_MISCELLANEOUS
> @@ -100,6 +101,8 @@ dri_fill_st_options(struct st_config_options *options,
>     options->allow_glsl_extension_directive_midshader =
>        driQueryOptionb(optionCache, "allow_glsl_extension_directive_midshader");
>     options->glsl_zero_init = driQueryOptionb(optionCache, "glsl_zero_init");
> +   options->override_glsl_version =
> +      driQueryOptioni(optionCache, "override_glsl_version");
>  }
>
>  static const __DRIconfig **
> diff --git a/src/gallium/state_trackers/osmesa/osmesa.c b/src/gallium/state_trackers/osmesa/osmesa.c
> index 18f1b88128..8102be14ed 100644
> --- a/src/gallium/state_trackers/osmesa/osmesa.c
> +++ b/src/gallium/state_trackers/osmesa/osmesa.c
> @@ -679,6 +679,7 @@ OSMesaCreateContextAttribs(const int *attribList, OSMesaContext sharelist)
>     attribs.options.disable_shader_bit_encoding = FALSE;
>     attribs.options.force_s3tc_enable = FALSE;
>     attribs.options.force_glsl_version = 0;
> +   attribs.options.override_glsl_version = 0;
>
>     osmesa_init_st_visual(&attribs.visual,
>                           PIPE_FORMAT_R8G8B8A8_UNORM,
> diff --git a/src/mesa/drivers/dri/common/drirc b/src/mesa/drivers/dri/common/drirc
> index 20fd8123e4..52c121a064 100644
> --- a/src/mesa/drivers/dri/common/drirc
> +++ b/src/mesa/drivers/dri/common/drirc
> @@ -104,5 +104,9 @@ TODO: document the other workarounds.
>          <application name="Divinity: Original Sin Enhanced Edition" executable="EoCApp">
>              <option name="allow_glsl_extension_directive_midshader" value="true" />
>          </application>
> +
> +        <application name="ARK: Survival Evolved" executable="ShooterGame">
> +            <option name="override_glsl_version" value="320" />
> +        </application>
>      </device>
>  </driconf>
> diff --git a/src/mesa/drivers/dri/common/xmlpool/t_options.h b/src/mesa/drivers/dri/common/xmlpool/t_options.h
> index a189bbedec..fb9ecbe3e7 100644
> --- a/src/mesa/drivers/dri/common/xmlpool/t_options.h
> +++ b/src/mesa/drivers/dri/common/xmlpool/t_options.h
> @@ -110,6 +110,11 @@ DRI_CONF_OPT_BEGIN_V(force_glsl_version, int, def, "0:999") \
>          DRI_CONF_DESC(en,gettext("Force a default GLSL version for shaders that lack an explicit #version line")) \
>  DRI_CONF_OPT_END
>
> +#define DRI_CONF_OVERRIDE_GLSL_VERSION(def) \
> +DRI_CONF_OPT_BEGIN_V(override_glsl_version, int, def, "0:999") \
> +        DRI_CONF_DESC(en,gettext("Override the GLSL version for apps that require an explicit version")) \
> +DRI_CONF_OPT_END
> +
>  #define DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER(def) \
>  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")) \
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index 7240b1f445..373985ceb8 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -910,6 +910,9 @@ brw_process_driconf_options(struct brw_context *brw)
>     ctx->Const.ForceGLSLVersion =
>        driQueryOptioni(options, "force_glsl_version");
>
> +   ctx->Const.GLSLVersion =
> +      driQueryOptioni(options, "override_glsl_version");
> +
>     ctx->Const.DisableGLSLLineContinuations =
>        driQueryOptionb(options, "disable_glsl_line_continuations");
>
> diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
> index 293814e3ae..d534e8e5dc 100644
> --- a/src/mesa/state_tracker/st_extensions.c
> +++ b/src/mesa/state_tracker/st_extensions.c
> @@ -874,6 +874,9 @@ void st_init_extensions(struct pipe_screen *screen,
>
>     _mesa_override_glsl_version(consts);
>
> +   if (options->override_glsl_version > 0)
> +      consts->GLSLVersion = options->override_glsl_version;
> +
>     if (options->force_glsl_version > 0 &&
>         options->force_glsl_version <= consts->GLSLVersion) {
>        consts->ForceGLSLVersion = options->force_glsl_version;
>



More information about the mesa-dev mailing list