[msl][glsl] Fix incorrect code gen for continuing inside switch.
In the GLSL and MSL backends when generating a continue inside a switch
block, the continuing statement would sink up into the switch label.
This means that a `break` for the continuing would break the switch
instead of the loop.
This CL moves the RemoveContinuingInSwitch transform from the HLSL
backend up to being a generic AST transform and calls it from the MSL
and GLSL backends to write the AST to no longer continue from switches.
Bug: tint:2039
Change-Id: Ica4a8d2de6bf97a179dac9e9216d8ddce99b5976
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/175820
Kokoro: Kokoro <noreply+kokoro@google.com>
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
diff --git a/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.msl b/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.msl
index 2662928..9ac0463 100644
--- a/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.msl
+++ b/test/tint/loops/nested_loop_switch_loop_switch.wgsl.expected.msl
@@ -7,27 +7,37 @@
if (VOLATILE_NAME)
kernel void tint_symbol() {
+ bool tint_continue_1 = false;
TINT_ISOLATE_UB(tint_volatile_true) for(int i = 0; (i < 2); i = as_type<int>((as_type<uint>(i) + as_type<uint>(2)))) {
+ tint_continue_1 = false;
switch(i) {
case 0: {
+ bool tint_continue = false;
TINT_ISOLATE_UB(tint_volatile_true_1) for(int j = 0; (j < 2); j = as_type<int>((as_type<uint>(j) + as_type<uint>(2)))) {
+ tint_continue = false;
switch(j) {
case 0: {
- continue;
+ tint_continue = true;
break;
}
default: {
break;
}
}
+ if (tint_continue) {
+ continue;
+ }
}
- continue;
+ tint_continue_1 = true;
break;
}
default: {
break;
}
}
+ if (tint_continue_1) {
+ continue;
+ }
}
return;
}