| uniform half4 colorGreen, colorRed; |
| |
| half4 main(float2 coords) { |
| // Verify that side effects in the not-taken side of a ternary do not occur. |
| half x = 1, y = 1; |
| (x == y) ? (x += 1) : (y += 1); // TRUE, x=2 y=1 |
| (x == y) ? (x += 3) : (y += 3); // FALSE, x=2 y=4 |
| (x < y) ? (x += 5) : (y += 5); // TRUE, x=7 y=4 |
| (y >= x) ? (x += 9) : (y += 9); // FALSE, x=7 y=13 |
| (x != y) ? (x += 1) : (y ); // TRUE, x=8 y=13 |
| (x == y) ? (x += 2) : (y ); // FALSE, x=8 y=13 |
| (x != y) ? (x ) : (y += 3); // TRUE, x=8 y=13 |
| (x == y) ? (x ) : (y += 4); // FALSE, x=8 y=17 |
| |
| // Verify that side effects in the test-condition of a ternary always occur before the if-true |
| // and if-false expressions are evaluated. |
| bool b = true; |
| bool c = (b = false) ? false : b; |
| |
| return c ? colorRed : (x == 8 && y == 17) ? colorGreen : colorRed; |
| } |