Mesa (staging/20.0): glsl: fix potential slow compile times for GLSLOptimizeConservatively
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Tue Jun 9 18:01:49 UTC 2020
Module: Mesa
Branch: staging/20.0
Commit: 0f8fad7f3c407766b6862d348f060b6d64280d5d
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=0f8fad7f3c407766b6862d348f060b6d64280d5d
Author: Timothy Arceri <tarceri at itsqueeze.com>
Date: Fri Jun 5 13:57:40 2020 +1000
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 <witold.baryluk at gmail.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5346>
(cherry picked from commit e43ab7bb05857461609ed2bd43703eb272a3ebe1)
---
.pick_status.json | 2 +-
src/compiler/glsl/glsl_parser_extras.cpp | 15 ++++++++++++++-
2 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index 3f93e35be1a..652ff6cd683 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -454,7 +454,7 @@
"description": "glsl: fix potential slow compile times for GLSLOptimizeConservatively",
"nominated": true,
"nomination_type": 1,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": "0a5018c1a483abe6c4dddc6c65a7f4e939efc726"
},
diff --git a/src/compiler/glsl/glsl_parser_extras.cpp b/src/compiler/glsl/glsl_parser_extras.cpp
index 293437acfcd..82f1fc96dca 100644
--- a/src/compiler/glsl/glsl_parser_extras.cpp
+++ b/src/compiler/glsl/glsl_parser_extras.cpp
@@ -2345,7 +2345,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) {
More information about the mesa-commit
mailing list