summaryrefslogtreecommitdiffstats
path: root/src/compiler/glsl/opt_constant_propagation.cpp
diff options
context:
space:
mode:
authorKenneth Graunke <kenneth@whitecape.org>2016-04-29 17:57:46 -0700
committerKenneth Graunke <kenneth@whitecape.org>2016-06-23 11:58:50 -0700
commitfb857b5eea43640bfe19dcc12a88a09a6448e55a (patch)
treeecfb60898182824e6954e06a3c88f75f2acdc91e /src/compiler/glsl/opt_constant_propagation.cpp
parentef78df8d3b0cf540e5f08c8c2f6caa338b64a6c7 (diff)
downloadexternal_mesa3d-fb857b5eea43640bfe19dcc12a88a09a6448e55a.zip
external_mesa3d-fb857b5eea43640bfe19dcc12a88a09a6448e55a.tar.gz
external_mesa3d-fb857b5eea43640bfe19dcc12a88a09a6448e55a.tar.bz2
glsl: Don't constant propagate arrays.
Constant propagation on arrays doesn't make a lot of sense. If the array is only accessed with constant indexes, then opt_array_splitting would split it up. Otherwise, we have variable indexing. If there's multiple accesses, then constant propagation would end up replicating the data. The lower_const_arrays_to_uniforms pass creates uniforms for each ir_constant with array type that it encounters. This means that it creates redundant uniforms for each copy of the constant, which means uploading too much data. It can even mean exceeding the maximum number of uniform components, causing link failures. We could try and teach the pass to de-duplicate the data by hashing constants, but it makes more sense to avoid duplicating it in the first place. We should promote constant arrays to uniforms, then propagate the uniform access. Fixes the TressFX shaders from Tomb Raider, which exceeded the maximum number of uniform components by a huge margin and failed to link. On Broadwell: total instructions in shared programs: 9067702 -> 9068202 (0.01%) instructions in affected programs: 10335 -> 10835 (4.84%) helped: 10 (Hoard, Shadow of Mordor, Amnesia: The Dark Descent) HURT: 20 (Natural Selection 2) loops in affected programs: 4 -> 0 The hurt programs appear to no longer have a constarray uniform, as all constants were successfully propagated. Apparently before this patch, we successfully unrolled a loop containing array access, but only after promoting constant arrays to uniforms. With this patch, we unroll it first, so all array access is direct, and the array is split up, and individual constants are propagated. This seems better. Cc: mesa-stable@lists.freedesktop.org Reported-by: Karol Herbst <nouveau@karolherbst.de> Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
Diffstat (limited to 'src/compiler/glsl/opt_constant_propagation.cpp')
-rw-r--r--src/compiler/glsl/opt_constant_propagation.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/compiler/glsl/opt_constant_propagation.cpp b/src/compiler/glsl/opt_constant_propagation.cpp
index 6ec4ab4..69bca74 100644
--- a/src/compiler/glsl/opt_constant_propagation.cpp
+++ b/src/compiler/glsl/opt_constant_propagation.cpp
@@ -145,7 +145,7 @@ ir_constant_propagation_visitor::constant_folding(ir_rvalue **rvalue)
this->progress = true;
ir_dereference_variable *var_ref = (*rvalue)->as_dereference_variable();
- if (var_ref) {
+ if (var_ref && !var_ref->type->is_array()) {
ir_constant *constant = var_ref->constant_expression_value();
if (constant) {
*rvalue = constant;