Recursive array indexing where more than one array is used with non-constant indexing can lead to opt_array_splitting hitting an assertion after failing to realize that one of the arrays is not always accessed via constant indexing. This is present in master 1a469a34d517d4c2:
$ bin/shader_runner opt_array_splitting_crash.test
shader_runner: opt_array_splitting.cpp:296: void ir_array_splitting_visitor::split_deref(ir_dereference**): Assertion `constant' failed.
Aborted (core dumped)
I'll attach the offending shader runner test.
Created attachment 114380 [details]
shader runner test file triggering the assertion
Notice that even if the crash is fixed the test won't pass with current master. For the test to pass we need to support recursive reladdr scratch access, which I implement here:
If the crash is fixed and that patch is applied then the test should pass. I can get the test to pass with that patch by disabling the optimization pass to work around the assertion.
Patch sent for review:
glsl/opt_array_splitting: Fix crash when doing array indexing into other arrays
When we find indirect indexing into an array, the current implementation
of the array spliiting optimization pass does not look further into the
expression tree. However, if the variable expression involves variable
indexing into other arrays, we can miss that these other arrays also have
variable indexing. If that happens, the pass will crash later on after
hitting an assertion put there to ensure that split arrays are in fact
always indexed via constants:
void ir_array_splitting_visitor::split_deref(ir_dereference**): Assertion `constant' failed.
This patch fixes the problem by letting the pass step into the variable
index expression to identify these cases properly.
Reviewed-by: Timothy Arceri <email@example.com>
on Feb 24, 2017 at 01:42:08.
(provided by the Example extension).