OSDN Git Service

glsl: Split arrays even in the presence of whole-array copies.
authorKenneth Graunke <kenneth@whitecape.org>
Mon, 20 Jun 2016 18:20:51 +0000 (11:20 -0700)
committerEmil Velikov <emil.l.velikov@gmail.com>
Fri, 24 Jun 2016 20:23:20 +0000 (21:23 +0100)
commit60b5ba557ecb8678ef240d01ff3f5f1c76428cc1
tree9db4850c78dab974e9bac48ab2acab2dddd9c984
parent9013f56bb7d3ad57cb4f7b182217edd6665125e1
glsl: Split arrays even in the presence of whole-array copies.

Previously, we failed to split constant arrays.  Code such as

   int[2] numbers = int[](1, 2);

would generates a whole-array assignment:

  (assign () (var_ref numbers)
             (constant (array int 4) (constant int 1) (constant int 2)))

opt_array_splitting generally tried to visit ir_dereference_array nodes,
and avoid recursing into the inner ir_dereference_variable.  So if it
ever saw a ir_dereference_variable, it assumed this was a whole-array
read and bailed.  However, in the above case, there's no array deref,
and we can totally handle it - we just have to "unroll" the assignment,
creating assignments for each element.

This was mitigated by the fact that we constant propagate whole arrays,
so a dereference of a single component would usually get the desired
single value anyway.  However, I plan to stop doing that shortly;
early experiments with disabling constant propagation of arrays
revealed this shortcoming.

This patch causes some arrays in Gl32GSCloth's geometry shaders to be
split, which allows other optimizations to eliminate unused GS inputs.
The VS then doesn't have to write them, which eliminates the entire VS
(5 -> 2 instructions).  It still renders correctly.

No other change in shader-db.

v2: Drop !AOA check and improve a comment (feedback from Tim Arceri).

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
(cherry picked from commit c264fdbc073a0dfc393f53a8be880f535fd4b988)
src/compiler/glsl/opt_array_splitting.cpp