diff --git a/src/compiler/glsl/gl_nir_link_uniforms.c b/src/compiler/glsl/gl_nir_link_uniforms.c
index cc223b9fafb..975ddca5984 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 218911959b0..1e9f90a96cb 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 8b9d8a72987..64692bf2459 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 decf7c00450..3d2d26ab2e0 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 cbc12ae3e34..e7be7f21be5 100644
--- a/src/mesa/main/consts_exts.h
+++ b/src/mesa/main/consts_exts.h
@@ -794,6 +794,11 @@ struct gl_constants
*/
GLboolean DisableTransformFeedbackPacking;
+ /**
+ * Disable the glsl optimisation that resizes uniform arrays.
+ */
+ bool DisableUniformArrayResize;
+
/**
* Align varyings to POT in a slot
*
diff --git a/src/mesa/state_tracker/st_extensions.c b/src/mesa/state_tracker/st_extensions.c
index 28ac4cb68bd..d232a4764c5 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 9c35fcbc135..22ccdbf32e7 100644
--- a/src/util/00-mesa-defaults.conf
+++ b/src/util/00-mesa-defaults.conf
@@ -149,6 +149,10 @@ TODO: document the other workarounds.
+
+
+
+
diff --git a/src/util/driconf.h b/src/util/driconf.h
index af474c17095..bcc6d8190e4 100644
--- a/src/util/driconf.h
+++ b/src/util/driconf.h
@@ -164,6 +164,10 @@
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")