3c2997cacc
We will continue to fold expressions like `10 + 0` or `5 * 1` or `PI * 1` (assuming PI is a const float) because both sides are known, but non-constant-expressions like `x + 0` (assuming x is not a constant) or `foo *= 1` will be left as-is when the optimizer is off. This improves the accuracy of the Viewer shader tab, because a runtime effect expression like `color *= scale` will be preserved in the final output when optimization is off, instead of being replaced with a Nop when scale equals one. Change-Id: I218b327cb0cd12654dca446dee8a5baa96f589b8 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/539197 Commit-Queue: John Stiles <johnstiles@google.com> Auto-Submit: John Stiles <johnstiles@google.com> Reviewed-by: Brian Osman <brianosman@google.com>
46 lines
1.0 KiB
GLSL
46 lines
1.0 KiB
GLSL
|
|
out vec4 sk_FragColor;
|
|
uniform vec4 colorGreen;
|
|
uniform vec4 colorRed;
|
|
bool flatten_known_if_b() {
|
|
int value;
|
|
{
|
|
value = 1;
|
|
}
|
|
return value == 1;
|
|
}
|
|
bool eliminate_empty_if_else_b() {
|
|
bool check = false;
|
|
check = !check;
|
|
return check;
|
|
}
|
|
bool eliminate_empty_else_b() {
|
|
bool check = true;
|
|
if (check) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
bool flatten_matching_ternary_b() {
|
|
return true;
|
|
}
|
|
bool flatten_expr_without_side_effects_b() {
|
|
bool check = true;
|
|
return check;
|
|
}
|
|
bool eliminate_no_op_arithmetic_b() {
|
|
const int ONE = 1;
|
|
int x = ONE;
|
|
return x == 1;
|
|
}
|
|
bool flatten_switch_b() {
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
vec4 main() {
|
|
ivec4 _0_x = ivec4(1, 2, 3, 4);
|
|
ivec4 _1_y = ivec4(1, 2, 3, 4);
|
|
return ((((((_0_x == _1_y && flatten_known_if_b()) && eliminate_empty_if_else_b()) && eliminate_empty_else_b()) && flatten_matching_ternary_b()) && flatten_expr_without_side_effects_b()) && eliminate_no_op_arithmetic_b()) && flatten_switch_b() ? colorGreen : colorRed;
|
|
}
|