glsl: Fix continue statements in do-while loops.
authorPaul Berry <stereotype441@gmail.com>
Fri, 31 Jan 2014 17:55:35 +0000 (09:55 -0800)
committerPaul Berry <stereotype441@gmail.com>
Tue, 4 Feb 2014 17:06:09 +0000 (09:06 -0800)
commit7f5740899fe8ee2d7fecebf1b9622e06dbc78f43
treefd75c45ca7298fe65db4c5da35d98ee29dd264b8
parent56790856b303ad5ba86d7eb261ade91edaa3ee0b
glsl: Fix continue statements in do-while loops.

From the GLSL 4.40 spec, section 6.4 (Jumps):

    The continue jump is used only in loops. It skips the remainder of
    the body of the inner most loop of which it is inside. For while
    and do-while loops, this jump is to the next evaluation of the
    loop condition-expression from which the loop continues as
    previously defined.

Previously, we incorrectly treated a "continue" statement as jumping
to the top of a do-while loop.

This patch fixes the problem by replicating the loop condition when
converting the "continue" statement to IR.  (We already do a similar
thing in "for" loops, to ensure that "continue" causes the loop
expression to be executed).

Fixes piglit tests:
- glsl-fs-continue-inside-do-while.shader_test
- glsl-vs-continue-inside-do-while.shader_test
- glsl-fs-continue-in-switch-in-do-while.shader_test
- glsl-vs-continue-in-switch-in-do-while.shader_test

Cc: mesa-stable@lists.freedesktop.org
Acked-by: Carl Worth <cworth@cworth.org>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
Reviewed-by: Matt Turner <mattst88@gmail.com>
src/glsl/ast_to_hir.cpp