• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1uniform half4 colorRed, colorGreen, testInputs;
2
3half fn(half4 v) {
4    // Add an un-inlinable construct to ensure that fn() remains a standalone function.
5    for (int x=1; x<=2; ++x) {
6        return v.x;
7    }
8}
9
10half4 main(float2 coords) {
11    half4 v = testInputs;
12
13    v = v.rgba;
14    v = v.rgb0.abgr;
15    v = v.rgba.00ra;
16    v = v.rgba.rrra.00ra.11ab;
17    v = v.abga.gb11;
18    v = v.abgr.abgr;
19    v = half4(v.rrrr.bb, 1, 1);
20    v = half4(v.ba.grgr);
21
22    // The swizzle will not be optimized away to avoid eliminating fn().
23    v = half3(fn(v), 123, 456).yyzz;
24    v = half3(fn(v), half2(123, 456)).yyzz;
25
26    // The swizzle will be optimized away because fn() can be reordered.
27    v = half3(fn(v), 123, 456).yzzx;
28    v = half3(fn(v), half2(123, 456)).yzzx;
29
30    // The swizzle will not be optimized away to avoid duplicating fn().
31    v = half3(fn(v), 123, 456).yxxz;
32    v = half3(fn(v), half2(123, 456)).yxxz;
33
34    // Swizzled constants.
35    v = half4(1, 2, 3, 4).xxyz;
36
37    // Swizzled uniforms mixed with constants.
38    v = half4(1, colorRed.rgb).yzwx;
39    v = half4(1, colorRed.rgb).yxzw;
40
41    // Left-side swizzles.
42    v.rgba = v;
43    v.abgr = v;
44    v.rgba.ra = v.gb;
45    v.abgr.gba = v.aa1;
46
47    return v == half4(1) ? colorGreen : colorRed;
48}
49