1uniform half4 colorGreen; 2uniform half unknownInput; 3 4struct S { 5 half4 ah4[1]; 6 half ah[1]; 7 half4 h4; 8 half h; 9}; 10 11// Each helper function needs to reference the variable multiple times, because if it's only read 12// from once, it is inlined directly whether or not it is trivial. 13half4 funcb(bool b) { 14 return half4(b, b, b, !b); 15} 16 17half4 func1(half h) { 18 return h.xxxx * h.xxxx; 19} 20 21half4 func2(half2 h2) { 22 return h2.xyxy * h2.yxyx; 23} 24 25half4 func3(half3 h3) { 26 return h3.xyzx * h3.xyzx; 27} 28 29half4 func4(half4 h4) { 30 return h4 * h4; 31} 32 33half4 main(float2 coords) { 34 S s; 35 s.ah4[0] = half4(unknownInput); 36 s.ah[0] = unknownInput; 37 s.h4 = half4(unknownInput); 38 s.h = unknownInput; 39 40 S as[1]; 41 as[0].ah4[0] = half4(unknownInput); 42 43 bool b = bool(unknownInput); 44 int i = int(unknownInput); 45 46 // These expressions are considered "trivial" and will be cloned directly into the inlined 47 // function without a temporary variable. 48 half4 var; 49 var = func1(+s.h); 50 var = funcb(b); 51 var = func2(s.ah4[0].yw); 52 var = func2(as[0].ah4[0].xy); 53 var = func3(s.h4.zzz); 54 var = func3(colorGreen.xyz); 55 var = func3(s.h.xxx); 56 var = func4(half4(s.h)); 57 var = func4(s.ah4[0].xxxy); 58 var = func4(colorGreen); 59 60 // These expressions are considered "non-trivial" and will be placed in a temporary variable 61 // when inlining occurs. 62 var = func1(-s.h); 63 var = funcb(!b); 64// var = func2(as[i].h4.yw); // indexing by non-constant expressions disallowed in ES2 65 var = func3(s.h4.yyy + s.h4.zzz); 66 var = func4(s.h4.y001); 67 68 return colorGreen; 69} 70