• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1uniform half4 colorRed, colorGreen;
2
3bool test() {
4    const half4 colorWhite = half4(1);
5    const half2 point = half2(40, 60);
6
7    bool ok = true;
8    // Comparisons on swizzled constants should fold
9    ok = ok && (point.x >= 0 && point.x <= 100 && point.y >= 0 && point.y <= 100);
10
11    // Arithmetic on swizzled constants should fold
12    ok = ok && (colorWhite.x == 1);
13    ok = ok && (colorWhite.x + colorWhite.y == 2);
14    ok = ok && (colorWhite.x + colorWhite.y + colorWhite.z == 3);
15    ok = ok && (colorWhite.x + colorWhite.y + colorWhite.z + colorWhite.w == 4);
16
17    // No-op arithmetic using swizzled constants should fold away
18    ok = ok && ((colorGreen * colorWhite.x) != (colorRed * colorWhite.y));
19
20    // Folding on swizzles with more than one component should be optimized.
21    const half2 pointOffset = point.yx + colorWhite.xz;
22    ok = ok && (pointOffset == half2(61, 41));
23
24    return ok;
25}
26
27half4 main(float2 coords) {
28    return test() ? colorGreen : colorRed;
29}
30