John Kessenich | a2858d9 | 2018-01-31 08:11:18 -0700 | [diff] [blame] | 1 | #version 450 |
| 2 | |
| 3 | #extension GL_EXT_control_flow_attributes : enable |
| 4 | |
| 5 | bool cond; |
| 6 | |
David Neto | 8c3d5b4 | 2019-10-21 14:50:31 -0400 | [diff] [blame] | 7 | void f0() { |
| 8 | [[loop]] for (;;) { } |
| 9 | } |
| 10 | |
| 11 | void f1() { |
| 12 | [[dont_unroll]] while(true) { } |
| 13 | } |
| 14 | |
John Kessenich | a2858d9 | 2018-01-31 08:11:18 -0700 | [diff] [blame] | 15 | void main() |
| 16 | { |
| 17 | [[unroll]] for (int i = 0; i < 8; ++i) { } |
David Neto | 8c3d5b4 | 2019-10-21 14:50:31 -0400 | [diff] [blame] | 18 | f0(); |
John Kessenich | a2858d9 | 2018-01-31 08:11:18 -0700 | [diff] [blame] | 19 | [[dependency_infinite]] do { } while(true); |
| 20 | [[dependency_length(1+3)]] for (int i = 0; i < 8; ++i) { } |
| 21 | [[flatten]] if (cond) { } else { } |
| 22 | [[branch]] if (cond) cond = false; |
| 23 | [[dont_flatten]] switch(3) { } // dropped |
| 24 | [[dont_flatten]] switch(3) { case 3: break; } |
| 25 | |
| 26 | // warnings on all these |
| 27 | [[unroll(2)]] for (int i = 0; i < 8; ++i) { } |
| 28 | [[dont_unroll(-2)]] while(true) { } |
| 29 | [[dependency_infinite(3)]] do { } while(true); |
| 30 | [[dependency_length]] for (int i = 0; i < 8; ++i) { } |
| 31 | [[flatten(3)]] if (cond) { } else { } |
| 32 | [[branch(5.2)]] if (cond) cond = false; |
| 33 | [[dont_flatten(3 + 7)]] switch(3) { case 3: break; } |
| 34 | |
| 35 | // other valid uses |
| 36 | [[ unroll, dont_unroll, dependency_length(2) ]] while(cond) { } |
| 37 | [ [ dont_flatten , branch ] ] switch(3) { case 3: break; } |
| 38 | [ |
| 39 | // attribute |
| 40 | [ |
| 41 | // here |
| 42 | flatten |
| 43 | ] |
| 44 | ] if (cond) { } else { } |
| 45 | [[ dependency_length(2), dependency_infinite ]] while(cond) { } |
| 46 | } |