summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2016-04-29 12:53:03 -0700
committerKenneth Graunke <[email protected]>2016-05-15 23:59:05 -0700
commit8e59670bcf925714896fb275a364e97a5137f0f7 (patch)
treef4537d852a847037d7210da5a1e7c6d5929fb36f /src
parentc907ca6c8d256f4b8c271bcf0901661ef943ae08 (diff)
glsl: Make opt_constant_variable() bail in useless cases.
The pass ultimately skips over any entries with assignment_count != 1, so there's no need to do further work once we've determined that there are multiple assignments. The constant value could be a large array (i.e. uvec4[327]), at which point skipping the constant_expression_value() call (and the clone() call within) can save us piles of memory. No change in shader-db. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Ian Romanick <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/compiler/glsl/opt_constant_variable.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/compiler/glsl/opt_constant_variable.cpp b/src/compiler/glsl/opt_constant_variable.cpp
index 3ddb12904c7..1c06ffe6750 100644
--- a/src/compiler/glsl/opt_constant_variable.cpp
+++ b/src/compiler/glsl/opt_constant_variable.cpp
@@ -102,6 +102,13 @@ ir_constant_variable_visitor::visit_enter(ir_assignment *ir)
assert(entry);
entry->assignment_count++;
+ /* If there's more than one assignment, don't bother - we won't do anything
+ * with this variable anyway, and continuing just wastes memory cloning
+ * constant expressions.
+ */
+ if (entry->assignment_count > 1)
+ return visit_continue;
+
/* If it's already constant, don't do the work. */
if (entry->var->constant_value)
return visit_continue;