util/driconf: add Dune: Spice Wars workaround
authorTimothy Arceri <tarceri@itsqueeze.com>
Mon, 9 Jan 2023 03:12:52 +0000 (14:12 +1100)
committerMarge Bot <emma+marge@anholt.net>
Tue, 10 Jan 2023 03:53:19 +0000 (03:53 +0000)
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 <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20579>

src/compiler/glsl/gl_nir_link_uniforms.c
src/gallium/auxiliary/pipe-loader/driinfo_gallium.h
src/gallium/auxiliary/util/u_driconf.c
src/gallium/include/frontend/api.h
src/mesa/main/consts_exts.h
src/mesa/state_tracker/st_extensions.c
src/util/00-mesa-defaults.conf
src/util/driconf.h

index cc223b9..975ddca 100644 (file)
@@ -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];
index 2189119..1e9f90a 100644 (file)
@@ -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)
index 8b9d8a7..64692bf 100644 (file)
@@ -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);
index decf7c0..3d2d26a 100644 (file)
@@ -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;
index cbc12ae..e7be7f2 100644 (file)
@@ -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
index 28ac4cb..d232a47 100644 (file)
@@ -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;
 
index 9c35fcb..22ccdbf 100644 (file)
@@ -149,6 +149,10 @@ TODO: document the other workarounds.
             <option name="force_glsl_extensions_warn" value="true" />
         </application>
 
+        <application name="Dune: Spice Wars" executable="D4X.exe">
+            <option name="disable_uniform_array_resize" value="true" />
+        </application>
+
         <application name="Dying Light" executable="DyingLightGame">
             <option name="allow_glsl_builtin_variable_redeclaration" value="true" />
         </application>
index af474c1..bcc6d81 100644 (file)
    DRI_CONF_OPT_B(disable_glsl_line_continuations, def, \
                   "Disable backslash-based line continuations in GLSL source")
 
+#define DRI_CONF_DISABLE_UNIFORM_ARRAY_RESIZE(def) \
+   DRI_CONF_OPT_B(disable_uniform_array_resize, def, \
+                  "Disable the glsl optimisation that resizes uniform arrays")
+
 #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")