1uniform half4 colorGreen, colorRed; 2 3bool test_return() { 4 do { 5 return true; 6 continue; // should be eliminated 7 break; // should be eliminated 8 } while (false); 9 10 return false; // should be eliminated 11} 12 13bool test_break() { 14 do { 15 break; 16 continue; // should be eliminated 17 return false; // should be eliminated 18 } while (false); 19 20 return true; 21} 22 23bool test_continue() { 24 do { 25 continue; 26 break; // should be eliminated 27 return false; // should be eliminated 28 } while (false); 29 30 return true; 31} 32 33bool test_if_return() { 34 do { 35 if (colorGreen.g > 0) { 36 return true; 37 } else { 38 break; 39 } 40 continue; 41 } while (false); 42 43 return false; 44} 45 46bool test_if_break() { 47 do { 48 if (colorGreen.g > 0) { 49 break; 50 } else { 51 continue; 52 } 53 return false; // should be eliminated 54 } while (false); 55 56 return true; 57} 58 59bool test_else() { 60 do { 61 if (colorGreen.g == 0) { 62 return false; 63 } else { 64 return true; 65 } 66 break; // should be eliminated 67 continue; // should be eliminated 68 return false; // should be eliminated 69 } while (false); 70 71 return false; // should be eliminated 72} 73 74bool test_loop_return() { 75 // This test is technically ES2-compliant. 76 // In practice, some older GPUs don't like zero-iteration loops. 77 for (int x=0; x<0; ++x) { 78 return false; 79 return true; // should be eliminated 80 continue; // should be eliminated 81 } 82 return true; 83} 84 85bool test_loop_break() { 86 // This test is technically ES2-compliant. 87 // In practice, the Tegra3 driver doesn't support a `break` inside of a for loop. 88 for (int x=0; x<=1; ++x) { 89 break; 90 return false; // should be eliminated 91 continue; // should be eliminated 92 } 93 return true; 94} 95 96 97half4 main(float2 xy) { 98 return (test_return() && test_break() && test_continue() && 99 test_if_return() && test_if_break() && test_else()) && 100 test_loop_return() && test_loop_break() ? colorGreen 101 : colorRed; 102} 103