glsl: look for frag data bindings with [0] tacked onto the end for arrays
authorIlia Mirkin <imirkin@alum.mit.edu>
Wed, 6 Jul 2016 23:35:16 +0000 (19:35 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Sat, 13 Aug 2016 00:21:08 +0000 (20:21 -0400)
commit1baae00089c7bf5f31424c1287aa24f8ce5981a3
treeafb8142df612bce0cd69e7bf4c159c38edda36ca
parent0294dd00ccdab2c20d5df786ba780d7e091c2ab4
glsl: look for frag data bindings with [0] tacked onto the end for arrays

The GL spec is very unclear on this point. Apparently this is discussed
without resolution in the closed Khronos bugtracker at
https://cvs.khronos.org/bugzilla/show_bug.cgi?id=7829 . The
recommendation is to allow dropping the [0] for looking up the bindings.

The approach taken in this patch is to instead tack on [0]'s for each
arrayness level of the output's type, and doing the lookup again. That
way, for

out vec4 foo[2][2][2]

we will end up looking for bindings for foo, foo[0], foo[0][0], and
foo[0][0][0], in that order of preference.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=96765
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Eric Anholt <eric@anholt.net>
src/compiler/glsl/linker.cpp