From: Timothy Arceri Date: Mon, 9 Jan 2023 03:12:52 +0000 (+1100) Subject: util/driconf: add Dune: Spice Wars workaround X-Git-Tag: upstream/23.3.3~14853 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ac5af6c06d867507284121f31ddbabf07f7e29f4;p=platform%2Fupstream%2Fmesa.git util/driconf: add Dune: Spice Wars workaround As per the bug report the game does not correctly handle a uniform index of -1 being returned for the unused array element, which results in rendering issues. So here we skip the uniform array resizing optimisation. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/6397 Cc: mesa-stable Reviewed-by: Pierre-Eric Pelloux-Prayer Part-of: --- diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c index cc223b9..975ddca 100644 --- a/src/compiler/glsl/gl_nir_link_uniforms.c +++ b/src/compiler/glsl/gl_nir_link_uniforms.c @@ -1541,7 +1541,7 @@ gl_nir_link_uniforms(const struct gl_constants *consts, /* Iterate through all linked shaders */ struct nir_link_uniforms_state state = {0,}; - if (!prog->data->spirv) { + if (!prog->data->spirv && !consts->DisableUniformArrayResize) { /* Gather information on uniform use */ for (unsigned stage = 0; stage < MESA_SHADER_STAGES; stage++) { struct gl_linked_shader *sh = prog->_LinkedShaders[stage]; diff --git a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h index 2189119..1e9f90a 100644 --- a/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h +++ b/src/gallium/auxiliary/pipe-loader/driinfo_gallium.h @@ -18,6 +18,7 @@ DRI_CONF_SECTION_DEBUG DRI_CONF_DISABLE_GLSL_LINE_CONTINUATIONS(false) DRI_CONF_DISABLE_BLEND_FUNC_EXTENDED(false) DRI_CONF_DISABLE_ARB_GPU_SHADER5(false) + DRI_CONF_DISABLE_UNIFORM_ARRAY_RESIZE(false) DRI_CONF_FORCE_GLSL_VERSION(0) DRI_CONF_ALLOW_EXTRA_PP_TOKENS(false) DRI_CONF_ALLOW_GLSL_EXTENSION_DIRECTIVE_MIDSHADER(false) diff --git a/src/gallium/auxiliary/util/u_driconf.c b/src/gallium/auxiliary/util/u_driconf.c index 8b9d8a7..64692bf 100644 --- a/src/gallium/auxiliary/util/u_driconf.c +++ b/src/gallium/auxiliary/util/u_driconf.c @@ -41,6 +41,7 @@ u_driconf_fill_st_options(struct st_config_options *options, query_bool_option(disable_blend_func_extended); query_bool_option(disable_arb_gpu_shader5); query_bool_option(disable_glsl_line_continuations); + query_bool_option(disable_uniform_array_resize); query_bool_option(force_compat_shaders); query_bool_option(force_glsl_extensions_warn); query_int_option(force_glsl_version); diff --git a/src/gallium/include/frontend/api.h b/src/gallium/include/frontend/api.h index decf7c0..3d2d26a 100644 --- a/src/gallium/include/frontend/api.h +++ b/src/gallium/include/frontend/api.h @@ -170,6 +170,7 @@ struct st_config_options bool disable_blend_func_extended; bool disable_glsl_line_continuations; bool disable_arb_gpu_shader5; + bool disable_uniform_array_resize; bool force_compat_shaders; bool force_glsl_extensions_warn; unsigned force_glsl_version; diff --git a/src/mesa/main/consts_exts.h b/src/mesa/main/consts_exts.h index cbc12ae..e7be7f2 100644 --- a/src/mesa/main/consts_exts.h +++ b/src/mesa/main/consts_exts.h @@ -795,6 +795,11 @@ struct gl_constants GLboolean DisableTransformFeedbackPacking; /** + * Disable the glsl optimisation that resizes uniform arrays. + */ + bool DisableUniformArrayResize; + + /** * Align varyings to POT in a slot * * Drivers that prefer varyings to be aligned to POT must set this value to GL_TRUE diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c index 28ac4cb..d232a47 100644 --- a/src/mesa/state_tracker/st_extensions.c +++ b/src/mesa/state_tracker/st_extensions.c @@ -1471,6 +1471,9 @@ void st_init_extensions(struct pipe_screen *screen, if (options->disable_glsl_line_continuations) consts->DisableGLSLLineContinuations = 1; + if (options->disable_uniform_array_resize) + consts->DisableUniformArrayResize = 1; + if (options->allow_glsl_extension_directive_midshader) consts->AllowGLSLExtensionDirectiveMidShader = GL_TRUE; diff --git a/src/util/00-mesa-defaults.conf b/src/util/00-mesa-defaults.conf index 9c35fcb..22ccdbf 100644 --- a/src/util/00-mesa-defaults.conf +++ b/src/util/00-mesa-defaults.conf @@ -149,6 +149,10 @@ TODO: document the other workarounds.