skia2/tests/sksl/shared/SwitchWithFallthrough.glsl
John Stiles 44409c070a Distinguish between unscoped blocks and compound statements.
Previously, we used unscoped blocks for two similar functions:
- Rewrite one statement as two simpler statements:
  `int a, b;` -> `int a; int b;`
- Group together multiple statements without braces. e.g. the inliner
  uses unscoped Blocks to rearrange statements.

Conceptually, these are different from the debugger's perspective. The
compound statements should be treated as one unit; the grouped
statements should be treated individually (and the enclosing Block
should be ignored). A Block now contains a BlockKind enum to
distinguish between these cases.

Change-Id: Ie14a570bb46992689fb96b8fd3b67f2ca6e5239f
Bug: skia:13189
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/528655
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: John Stiles <johnstiles@google.com>
2022-04-11 14:34:07 +00:00

52 lines
1.5 KiB
GLSL

#version 400
out vec4 sk_FragColor;
uniform vec4 colorGreen;
uniform vec4 colorRed;
bool switch_fallthrough_twice_bi(int value) {
bool ok = false;
int _tmpSwitchValue1 = value, _tmpSwitchFallthrough0 = 0;
for (int _tmpSwitchLoop2 = 0; _tmpSwitchLoop2 < 1; _tmpSwitchLoop2++) {
if ((_tmpSwitchValue1 == 0)) {
break;
_tmpSwitchFallthrough0 = 1;
}
if ((_tmpSwitchFallthrough0 > 0) || (_tmpSwitchValue1 == 1)) {
;
_tmpSwitchFallthrough0 = 1;
}
if ((_tmpSwitchFallthrough0 > 0) || (_tmpSwitchValue1 == 2)) {
;
_tmpSwitchFallthrough0 = 1;
}
if ((_tmpSwitchFallthrough0 > 0) || (_tmpSwitchValue1 == 3)) {
ok = true;
break;
_tmpSwitchFallthrough0 = 1;
}
break;
}
return ok;
}
vec4 main() {
int x = int(colorGreen.y);
bool _0_ok = false;
int _tmpSwitchValue4 = x, _tmpSwitchFallthrough3 = 0;
for (int _tmpSwitchLoop5 = 0; _tmpSwitchLoop5 < 1; _tmpSwitchLoop5++) {
if ((_tmpSwitchValue4 == 2)) {
break;
_tmpSwitchFallthrough3 = 1;
}
if ((_tmpSwitchFallthrough3 > 0) || (_tmpSwitchValue4 == 1)) {
;
_tmpSwitchFallthrough3 = 1;
}
if ((_tmpSwitchFallthrough3 > 0) || (_tmpSwitchValue4 == 0)) {
_0_ok = true;
break;
_tmpSwitchFallthrough3 = 1;
}
break;
}
return _0_ok && switch_fallthrough_twice_bi(x) ? colorGreen : colorRed;
}