2021-04-27 16:50:49 +00:00
|
|
|
layout(key) in half one; // always equals 1.0
|
|
|
|
layout(key, when=one != 1.0f) in half unused; // never used
|
|
|
|
layout(key) float alsoUnused = one + one; // also never used
|
2021-04-22 19:08:33 +00:00
|
|
|
|
2021-04-22 19:05:20 +00:00
|
|
|
half4 main() {
|
|
|
|
half4 color = half4(0);
|
|
|
|
|
|
|
|
// Basic if statement. (00 == 00: true --> color=0001)
|
2021-04-22 19:08:33 +00:00
|
|
|
if (color.rg == color.ba) color.a = one;
|
2021-04-22 19:05:20 +00:00
|
|
|
|
|
|
|
// Basic if statement with Block. (00 == 01: false)
|
|
|
|
if (color.rg == color.ba) {
|
|
|
|
color.r = color.a;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO(skia:11872): Add test for If statement with comma-expression statement instead of Block.
|
|
|
|
|
|
|
|
// Basic if-else statement. (0 == 0: true --> color=1011)
|
|
|
|
if (color.r == color.g) color = color.araa; else color = color.rrra;
|
|
|
|
|
|
|
|
// Chained if-else statements.
|
2021-04-22 19:08:33 +00:00
|
|
|
if (color.r + color.g + color.b + color.a == one) { // (3 == 1: false)
|
2021-04-22 19:05:20 +00:00
|
|
|
color = half4(-1);
|
|
|
|
} else if (color.r + color.g + color.b + color.a == 2) { // (3 == 2: false)
|
|
|
|
color = half4(-2);
|
|
|
|
} else {
|
|
|
|
color = color.ggaa; // (color=0011)
|
|
|
|
}
|
|
|
|
|
|
|
|
// Nested if-else statements.
|
2021-04-22 19:08:33 +00:00
|
|
|
if (color.r == one) { // (0 == 1: false)
|
2021-04-22 19:05:20 +00:00
|
|
|
if (color.r == 2) {
|
|
|
|
color = color.rrrr;
|
|
|
|
} else {
|
|
|
|
color = color.gggg;
|
|
|
|
}
|
|
|
|
} else {
|
2021-04-22 19:08:33 +00:00
|
|
|
if (color.b * color.a == one) { // (1*1 == 1: true)
|
2021-04-22 19:05:20 +00:00
|
|
|
color = color.rbga; // (color = 0101)
|
|
|
|
} else {
|
|
|
|
color = color.aaaa;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-30 17:47:31 +00:00
|
|
|
@if (one != 1.0) {
|
|
|
|
color.r = 1;
|
|
|
|
}
|
|
|
|
|
2021-04-22 19:05:20 +00:00
|
|
|
return color;
|
|
|
|
}
|