glsl: Lower break instructions when necessary at the end of a loop.
authorPaul Berry <stereotype441@gmail.com>
Sat, 2 Jul 2011 00:29:35 +0000 (17:29 -0700)
committerPaul Berry <stereotype441@gmail.com>
Fri, 8 Jul 2011 16:59:30 +0000 (09:59 -0700)
commit067c9d7bd776260298ceabda026425ed7e4eb161
treea119596fb68b44926f8c6a299ab3e9d9b74de678
parente71b4ab8a64bf978b2036976a41e30996eebb0c8
glsl: Lower break instructions when necessary at the end of a loop.

Normally lower_jumps.cpp doesn't need to lower a break instruction
that occurs at the end of a loop, because all back-ends can produce
proper GPU instructions for a break instruction in this "canonical"
location.  However, if other break instructions within the loop are
already being lowered, then a break instruction at the end of the loop
needs to be lowered too, since after the optimization is complete a
new conditional break will be inserted at the end of the loop.

Without this patch, lower_jumps.cpp may require multiple passes in
order to lower all jumps.  This results in sub-optimal output because
lower_jumps.cpp produces a brand new set of temporary variables each
time it is run, and the redundant temporary variables are not
guaranteed to be eliminated by later optimization passes.

Fixes unit test test_lower_breaks_6.
src/glsl/lower_jumps.cpp