util/driconf: add workarounds for the Chronicles of Riddick
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/24567>
This commit is contained in:
@@ -144,7 +144,7 @@ deprecated_texture(const _mesa_glsl_parse_state *state)
|
||||
static bool
|
||||
deprecated_texture_derivatives_only(const _mesa_glsl_parse_state *state)
|
||||
{
|
||||
return deprecated_texture(state) && derivatives_only(state);
|
||||
return (deprecated_texture(state) && derivatives_only(state)) || state->allow_vertex_texture_bias;
|
||||
}
|
||||
|
||||
static bool
|
||||
|
@@ -317,6 +317,10 @@ _mesa_glsl_parse_state::_mesa_glsl_parse_state(struct gl_context *_ctx,
|
||||
sizeof(this->atomic_counter_offsets));
|
||||
this->allow_extension_directive_midshader =
|
||||
ctx->Const.AllowGLSLExtensionDirectiveMidShader;
|
||||
this->alias_shader_extension =
|
||||
ctx->Const.AliasShaderExtension;
|
||||
this->allow_vertex_texture_bias =
|
||||
ctx->Const.AllowVertexTextureBias;
|
||||
this->allow_glsl_120_subset_in_110 =
|
||||
ctx->Const.AllowGLSL120SubsetIn110;
|
||||
this->allow_builtin_variable_redeclaration =
|
||||
@@ -814,17 +818,51 @@ void _mesa_glsl_extension::set_flags(_mesa_glsl_parse_state *state,
|
||||
state->*(this->warn_flag) = (behavior == extension_warn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check alias_shader_extension for any aliased shader extensions
|
||||
*/
|
||||
static const char *find_extension_alias(_mesa_glsl_parse_state *state, const char *name)
|
||||
{
|
||||
char *exts, *field, *ext_alias = NULL;
|
||||
|
||||
/* Copy alias_shader_extension because strtok() is destructive. */
|
||||
exts = strdup(state->alias_shader_extension);
|
||||
if (exts) {
|
||||
for (field = strtok(exts, ","); field != NULL; field = strtok(NULL, ",")) {
|
||||
if(strncmp(name, field, strlen(name)) == 0) {
|
||||
field = strstr(field, ":");
|
||||
if(field) {
|
||||
ext_alias = strdup(field + 1);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
free(exts);
|
||||
}
|
||||
return ext_alias;
|
||||
}
|
||||
|
||||
/**
|
||||
* Find an extension by name in _mesa_glsl_supported_extensions. If
|
||||
* the name is not found, return NULL.
|
||||
*/
|
||||
static const _mesa_glsl_extension *find_extension(const char *name)
|
||||
static const _mesa_glsl_extension *find_extension(_mesa_glsl_parse_state *state, const char *name)
|
||||
{
|
||||
const char *ext_alias = NULL;
|
||||
if (state->alias_shader_extension) {
|
||||
ext_alias = find_extension_alias(state, name);
|
||||
name = ext_alias ? ext_alias : name;
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < ARRAY_SIZE(_mesa_glsl_supported_extensions); ++i) {
|
||||
if (strcmp(name, _mesa_glsl_supported_extensions[i].name) == 0) {
|
||||
free((void *)ext_alias);
|
||||
return &_mesa_glsl_supported_extensions[i];
|
||||
}
|
||||
}
|
||||
|
||||
free((void *)ext_alias);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -879,7 +917,7 @@ _mesa_glsl_process_extension(const char *name, YYLTYPE *name_locp,
|
||||
}
|
||||
}
|
||||
} else {
|
||||
const _mesa_glsl_extension *extension = find_extension(name);
|
||||
const _mesa_glsl_extension *extension = find_extension(state, name);
|
||||
if (extension &&
|
||||
(extension->compatible_with_state(state, api, gl_version) ||
|
||||
(state->consts->AllowGLSLCompatShaders &&
|
||||
|
@@ -961,6 +961,8 @@ struct _mesa_glsl_parse_state {
|
||||
bool layer_viewport_relative;
|
||||
|
||||
bool allow_extension_directive_midshader;
|
||||
char *alias_shader_extension;
|
||||
bool allow_vertex_texture_bias;
|
||||
bool allow_glsl_120_subset_in_110;
|
||||
bool allow_builtin_variable_redeclaration;
|
||||
bool ignore_write_to_readonly_var;
|
||||
|
@@ -21,6 +21,8 @@ DRI_CONF_SECTION_DEBUG
|
||||
DRI_CONF_DISABLE_BLEND_FUNC_EXTENDED(false)
|
||||
DRI_CONF_DISABLE_ARB_GPU_SHADER5(false)
|
||||
DRI_CONF_DISABLE_UNIFORM_ARRAY_RESIZE(false)
|
||||
DRI_CONF_ALIAS_SHADER_EXTENSION()
|
||||
DRI_CONF_ALLOW_VERTEX_TEXTURE_BIAS(false)
|
||||
DRI_CONF_FORCE_GLSL_VERSION(0)
|
||||
DRI_CONF_ALLOW_EXTRA_PP_TOKENS(false)
|
||||
DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER(false)
|
||||
|
@@ -42,6 +42,8 @@ u_driconf_fill_st_options(struct st_config_options *options,
|
||||
query_bool_option(disable_arb_gpu_shader5);
|
||||
query_bool_option(disable_glsl_line_continuations);
|
||||
query_bool_option(disable_uniform_array_resize);
|
||||
query_string_option(alias_shader_extension);
|
||||
query_bool_option(allow_vertex_texture_bias);
|
||||
query_bool_option(force_compat_shaders);
|
||||
query_bool_option(force_glsl_extensions_warn);
|
||||
query_int_option(force_glsl_version);
|
||||
|
@@ -171,6 +171,8 @@ struct st_config_options
|
||||
bool disable_glsl_line_continuations;
|
||||
bool disable_arb_gpu_shader5;
|
||||
bool disable_uniform_array_resize;
|
||||
char *alias_shader_extension;
|
||||
bool allow_vertex_texture_bias;
|
||||
bool force_compat_shaders;
|
||||
bool force_glsl_extensions_warn;
|
||||
unsigned force_glsl_version;
|
||||
|
@@ -798,6 +798,16 @@ struct gl_constants
|
||||
*/
|
||||
bool DisableUniformArrayResize;
|
||||
|
||||
/**
|
||||
* Alias extension e.g. GL_ATI_shader_texture_lod to GL_ARB_shader_texture_lod.
|
||||
*/
|
||||
char *AliasShaderExtension;
|
||||
|
||||
/**
|
||||
* Allow fs-only bias argument in vertex shaders.
|
||||
*/
|
||||
GLboolean AllowVertexTextureBias;
|
||||
|
||||
/**
|
||||
* Align varyings to POT in a slot
|
||||
*
|
||||
|
@@ -1468,6 +1468,11 @@ void st_init_extensions(struct pipe_screen *screen,
|
||||
if (options->disable_uniform_array_resize)
|
||||
consts->DisableUniformArrayResize = 1;
|
||||
|
||||
consts->AliasShaderExtension = options->alias_shader_extension;
|
||||
|
||||
if (options->allow_vertex_texture_bias)
|
||||
consts->AllowVertexTextureBias = GL_TRUE;
|
||||
|
||||
if (options->allow_glsl_extension_directive_midshader)
|
||||
consts->AllowGLSLExtensionDirectiveMidShader = GL_TRUE;
|
||||
|
||||
|
@@ -161,6 +161,12 @@ TODO: document the other workarounds.
|
||||
<option name="disable_uniform_array_resize" value="true" />
|
||||
</application>
|
||||
|
||||
<application name="The Chronicles of Riddick: Assault on Dark Athena" executable="DarkAthena.exe">
|
||||
<option name="disable_uniform_array_resize" value="true" />
|
||||
<option name="alias_shader_extension" value="GL_ATI_shader_texture_lod:GL_ARB_shader_texture_lod" />
|
||||
<option name="allow_vertex_texture_bias" value="true" />
|
||||
</application>
|
||||
|
||||
<application name="Dying Light" executable="DyingLightGame">
|
||||
<option name="allow_glsl_builtin_variable_redeclaration" value="true" />
|
||||
</application>
|
||||
|
@@ -168,6 +168,13 @@
|
||||
DRI_CONF_OPT_B(disable_uniform_array_resize, def, \
|
||||
"Disable the glsl optimisation that resizes uniform arrays")
|
||||
|
||||
#define DRI_CONF_ALIAS_SHADER_EXTENSION() \
|
||||
DRI_CONF_OPT_S_NODEF(alias_shader_extension, "Allow alias for shader extensions")
|
||||
|
||||
#define DRI_CONF_ALLOW_VERTEX_TEXTURE_BIAS(def) \
|
||||
DRI_CONF_OPT_B(allow_vertex_texture_bias, def, \
|
||||
"Allow GL2 vertex shaders to have access to texture2D/textureCube with bias variants")
|
||||
|
||||
#define DRI_CONF_FORCE_GLSL_VERSION(def) \
|
||||
DRI_CONF_OPT_I(force_glsl_version, def, 0, 999, \
|
||||
"Force a default GLSL version for shaders that lack an explicit #version line")
|
||||
|
Reference in New Issue
Block a user