OSDN Git Service

glsl/nir: do not change an element index to have correct block name
authorAndrii Simiklit <andrii.simiklit@globallogic.com>
Wed, 17 Jul 2019 12:05:49 +0000 (15:05 +0300)
committerDylan Baker <dylan@pnwbakers.com>
Tue, 7 Jan 2020 17:20:50 +0000 (09:20 -0800)
commitd9cbe10ee855fcb57cef7236a1db6eb9ec10a971
tree9aa01c1e7c740d95d756de386a8ef1c0c0930333
parente87b10088022e525f4209ef3be12b9dcb2c197ef
glsl/nir: do not change an element index to have correct block name

When SSBO array is used with packed layout, both IR tree
and as a result, NIR tree will be incorrect.
In fact, the SSBO dereference indices won't
match the array size in some cases like the following:

"layout(packed, binding=1) buffer SSBO { vec4 a; } ssbo[3];
 out vec4 color;
 void main() {
   color = ssbo[2].a;
 }"

After linking the IR and then NIR will have an SSBO array
definition with size 1 but dereference still will have index 2
and linked_shader->Program->sh.ShaderStorageBlocks
will contain just SSBO with name "SSBO[2]"

So this line should be removed at least as a workaround for now
to avoid error like:
Failed to find the block by name "SSBO[0]"

Fixes: 810dde2a "glsl/nir: Add a pass to lower UBO and SSBO access"
Signed-off-by: Andrii Simiklit <andrii.simiklit@globallogic.com>
Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
(cherry picked from commit be6d51e1e3a2b2165cd21fbdda2527d10f4ce9ff)
src/compiler/glsl/gl_nir_lower_buffers.c