Created attachment 119059 [details]
Patch that avoid the problem
OpenGL version string: 3.0 Mesa 11.1.0-devel (git-13a5805)
OpenGL renderer string: Mesa DRI Intel(R) Haswell Desktop
00:02.0 VGA compatible controller : Intel Corporation Xeon E3-1200 v3/4th Gen Core Processor Integrated Graphics Controller [8086:0412] (rev 06)
Intel(R) Core(TM) i7-4770 CPU @ 3.40GHz
Mesa built with: --enable-debug
When running the InteractionFunctionCalls2 OpenGL ES 3.1 CTS test, I hit below assert:
glcts: nir/nir_lower_vars_to_ssa.c:462: lower_copies_to_load_store: Assertion `arg_entry' failed.
Aborted (core dumped)
With attached patch the issue is avoided and all the Arrays of arrays tests pass. The problem is that we get duplicated set and keys, which are then deleted from the table, so on the second time in the loop we hit the assert. The patch just removes the duplication, but the real fix would avoid the duplication in the first place.
It looks like the problem is with the get_deref_node() function, arrays of arrays support looks to be missing here and so its returning the same deref_node for two different AoA vars.
Ignore my last comment the AoA support in that function looks fine. There is an issue well before getting to this code.
In assignment visitor in the glsl to nir pass nir_visitor::visit(ir_assignment *ir) the rhs and lhs side reference the same variable.
Ok so this isn't a problem just with arrays of arrays its a problem with 1D arrays too.
I've send a minimal piglit test  that triggers the assert, the problem I believe is a missed opportunity to optimise out a redundant assignment and so nir ends up with a scenario it wasn't expecting.
It shouldn't be to hard to fix once I figure out where in the code we would normally optimise this out.
Mesa patch : https://patchwork.freedesktop.org/patch/63372/
I confirm that the patch fixes the problem.
Just pushed a fix. Turns out it was a bug in nir_lower_vars_to_ssa where it couldn't handle a copy_var from a deref to the same deref. It's a silly thing to have in a shader but certainly not illegal.
Thanks, Timothy, for pointing me at it!
on Feb 24, 2017 at 03:35:12.
(provided by the Example extension).