[Bug 78468] Compiling of shader gets stuck in infinite loop

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Thu Sep 11 00:17:43 PDT 2014


https://bugs.freedesktop.org/show_bug.cgi?id=78468

--- Comment #15 from Iago Toral <itoral at igalia.com> ---
That small fragment shader example I mention above does not get fixed by
altering the needs_rvalue stuff, so it seems that the problem is more generic
or could have multiple causes leading to it.

In the case of that small fragment shader, I traced the problem down to the
fact that during the optimization passes we generate large assignment
instructions like these:

(assign  (x) (var_ref flattening_tmp_y at 116)  (expression float * (swiz x
(expression float + (swiz x (expression float + (swiz x (expression float +
(swiz x (expression float + (swiz x (expression float + (swiz x (expression
float + (swiz x (expression float + (swiz x (expression float + (swiz x
(expression float + (swiz x (expression float + (swiz x (expression float +
(swiz x (expression float + (swiz x (expression float + (swiz x (expression
float + (swiz x (expression float + (swiz x (expression float + (swiz x
(expression float + (swiz x (expression float + (swiz x (expression float +
(swiz x (expression float + (swiz x (expression float + (swiz x (expression
float + (swiz x (expression float + (swiz x (expression float + (swiz x
(expression float + (swiz x (expression float + (swiz x (expression float +
(swiz x (expression float + (swiz x (expression float + (var_ref col_y)
(constant float (0.100000)) ) )(constant float (0.100000)) ) )(constant float
(0.100000)) ) )(constant float (0.100000)) ) )(constant float (0.100000)) )
)(constant float (0.100000)) ) )(constant float (0.100000)) ) )(constant float
(0.100000)) ) )(constant float (0.100000)) ) )(constant float (0.100000)) )
)(constant float (0.100000)) ) )(constant float (0.100000)) ) )(constant float
(0.100000)) ) )(constant float (0.100000)) ) )(constant float (0.100000)) )
)(constant float (0.100000)) ) )(constant float (0.100000)) ) )(constant float
(0.100000)) ) )(constant float (0.100000)) ) )(constant float (0.100000)) )
)(constant float (0.100000)) ) )(constant float (0.100000)) ) )(constant float
(0.100000)) ) )(constant float (0.100000)) ) )(constant float (0.100000)) )
)(constant float (0.100000)) ) )(constant float (0.100000)) ) )(constant float
(0.100000)) ) )(constant float (0.100000)) ) )(constant float (0.500000)) ) ) 

These are the result of trying to pack the multiple additions we have in the
loop into one single instruction. What is weird about this, is that this only
happens when we have a certain number of iterations in the loop, if we have too
few or too many, this never happens, at least for the example I mentioned
above. For example, for a loop with only 10 iterations this is the code we
produce (notice how it adds 0.1 nine times to make 0.9 rather than chaining 9
add expressions:

(assign  (x) (var_ref flattening_tmp_y)  (expression float * (expression float
+ (constant float (0.900000)) (var_ref col_y) ) (constant float (0.500000)) ) ) 

If we have too many iterations in the loop, it does not get unrolled, and
again, we avoid the problem.

The optimization pass that introduces the large chain of expressions leading to
the problem in do_constant_folding is do_tree_grafting(). Indeed, removing this
pass fixes the problem for the small fragment shader I mention above.

-- 
You are receiving this mail because:
You are the QA Contact for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/intel-3d-bugs/attachments/20140911/7ef87cf7/attachment-0001.html>


More information about the intel-3d-bugs mailing list