glsl: Update deref types when resizing implicitly sized arrays.
authorKenneth Graunke <kenneth@whitecape.org>
Wed, 2 Nov 2016 20:35:30 +0000 (13:35 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Thu, 3 Nov 2016 08:42:37 +0000 (01:42 -0700)
commit8df4aebc94337983194cc72c817c08ee938117a1
treef0606834e9e1cf4f8d14560ffa061a4a80b672d7
parentd2861d682a235993844989f7742c9539c3e10245
glsl: Update deref types when resizing implicitly sized arrays.

At link time, we resolve the size of implicitly sized arrays.
When doing so, we update the type of the ir_variables.  However,
we neglected to update the type of ir_dereference nodes which
reference those variables.

It turns out array_resize_visitor (for GS/TCS/TES interface array
handling) already did 2/3 of the cases for this, so we can simply
refactor the code and reuse it.

This fixes:
GL45-CTS.shader_storage_buffer_object.basic-syntax
GL45-CTS.shader_storage_buffer_object.basic-syntaxSSO

which have an SSBO containing an implicitly sized array, followed
by some other members.  setup_buffer_access uses the dereference
types to compute offsets to fields, and it had a stale type where
the implicitly sized array's length was still 0 instead of the
actual length.

While we're here, we can also fix update_array_sizes to properly
update deref types as well, fixing a FINISHME from 2010.

Cc: mesa-stable@lists.freedesktop.org
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Timothy Arceri <timothy.arceri@collabora.com>
src/compiler/glsl/linker.cpp