aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2020-06-05 13:57:40 +1000
committerMarge Bot <[email protected]>2020-06-07 03:28:30 +0000
commite43ab7bb05857461609ed2bd43703eb272a3ebe1 (patch)
treea2ce07fc7d2366a79c8fdf11642bc9cb6eecd792
parentdd81f4853c879c38987909f5e6e670b325f9f6af (diff)
glsl: fix potential slow compile times for GLSLOptimizeConservatively
See code comment for full description of the change. Fixes: 0a5018c1a483 ("mesa: add gl_constants::GLSLOptimizeConservatively") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3034 Tested-by: Witold Baryluk <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5346>
-rw-r--r--src/compiler/glsl/glsl_parser_extras.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index c0f116b8fb4..e5c9f83e63a 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -2361,7 +2361,20 @@ do_common_optimization(exec_list *ir, bool linked,
OPT(lower_vector_insert, ir, false);
OPT(optimize_swizzles, ir);
- OPT(optimize_split_arrays, ir, linked);
+ /* Some drivers only call do_common_optimization() once rather than in a
+ * loop, and split arrays causes each element of a constant array to
+ * dereference is own copy of the entire array initilizer. This IR is not
+ * something that can be generated manually in a shader and is not
+ * accounted for by NIR optimisations, the result is an exponential slow
+ * down in compilation speed as a constant arrays element count grows. To
+ * avoid that here we make sure to always clean up the mess split arrays
+ * causes to constant arrays.
+ */
+ bool array_split = optimize_split_arrays(ir, linked);
+ if (array_split)
+ do_constant_propagation(ir);
+ progress |= array_split;
+
OPT(optimize_redundant_jumps, ir);
if (options->MaxUnrollIterations) {