skia2/tests/sksl/shared/SwitchWithLoops.glsl
John Stiles c81edd0e8c Reland "Rewrite switch statements in GLSL strict-ES2 mode."
This reverts commit d26d0e6a47.

Reason for revert: uses dedicated caps bit

Original change's description:
> Revert "Rewrite switch statements in GLSL strict-ES2 mode."
>
> This reverts commit 45e3838006.
>
> Reason for revert: Also need to rewrite them in actual ES2 mode.
>
> Original change's description:
> > Rewrite switch statements in GLSL strict-ES2 mode.
> >
> > Once this lands, switch statements will work everywhere--Metal, SPIR-V,
> > GLSL, and SkVM.
> >
> > Change-Id: I2797d0a872de8be77bb9f7aa6acb93421d571d70
> > Bug: skia:12450
> > Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452356
> > Commit-Queue: John Stiles <johnstiles@google.com>
> > Auto-Submit: John Stiles <johnstiles@google.com>
> > Reviewed-by: Brian Osman <brianosman@google.com>
>
> Bug: skia:12450
> Change-Id: I92656ed40289872405c0873f2c56a52b04e35b1d
> No-Presubmit: true
> No-Tree-Checks: true
> No-Try: true
> Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452556
> Auto-Submit: Brian Osman <brianosman@google.com>
> Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
> Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>

Bug: skia:12450
Change-Id: I0d3b0969d2040dbb4ee808132146687767c97442
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/452560
Commit-Queue: John Stiles <johnstiles@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
Auto-Submit: John Stiles <johnstiles@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
2021-09-24 16:43:42 +00:00

54 lines
1.5 KiB
GLSL

#version 400
out vec4 sk_FragColor;
uniform vec4 colorGreen;
uniform vec4 colorRed;
bool switch_with_continue_in_loop_bi(int x) {
int val = 0;
int _tmpSwitchValue1 = x, _tmpSwitchFallthrough0 = 0;
for (int _tmpSwitchLoop2 = 0; _tmpSwitchLoop2 < 1; _tmpSwitchLoop2++) {
if ((_tmpSwitchValue1 == 1)) {
for (int i = 0;i < 10; ++i) {
++val;
continue;
++val;
}
_tmpSwitchFallthrough0 = 1;
}
++val;
}
return val == 11;
}
bool loop_with_break_in_switch_bi(int x) {
int val = 0;
for (int i = 0;i < 10; ++i) {
int _tmpSwitchValue4 = x, _tmpSwitchFallthrough3 = 0;
for (int _tmpSwitchLoop5 = 0; _tmpSwitchLoop5 < 1; _tmpSwitchLoop5++) {
if ((_tmpSwitchValue4 == 1)) {
++val;
break;
_tmpSwitchFallthrough3 = 1;
}
return false;
}
++val;
}
return val == 20;
}
vec4 main() {
int x = int(colorGreen.y);
int _0_val = 0;
int _tmpSwitchValue7 = x, _tmpSwitchFallthrough6 = 0;
for (int _tmpSwitchLoop8 = 0; _tmpSwitchLoop8 < 1; _tmpSwitchLoop8++) {
if ((_tmpSwitchValue7 == 1)) {
for (int _1_i = 0;_1_i < 10; ++_1_i) {
++_0_val;
break;
++_0_val;
}
_tmpSwitchFallthrough6 = 1;
}
++_0_val;
}
return (_0_val == 2 && switch_with_continue_in_loop_bi(x)) && loop_with_break_in_switch_bi(x) ? colorGreen : colorRed;
}