Skip to content

Commit

Permalink
[wgsl] Validate continue inside switch control flow. (#3434)
Browse files Browse the repository at this point in the history
This Cl adds a test that the execution of a `continue` instruction
inside of a `switch` has the correct control flow.
  • Loading branch information
dj2 authored Feb 27, 2024
1 parent 62389bc commit a7a4900
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/webgpu/listing_meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -1669,6 +1669,7 @@
"webgpu:shader,execution,flow_control,switch:switch_default_only:*": { "subcaseMS": 12.550 },
"webgpu:shader,execution,flow_control,switch:switch_multiple_case:*": { "subcaseMS": 5.550 },
"webgpu:shader,execution,flow_control,switch:switch_multiple_case_default:*": { "subcaseMS": 12.000 },
"webgpu:shader,execution,flow_control,switch:switch_inside_loop_with_continue:*": { "subcaseMS": 0 },
"webgpu:shader,execution,flow_control,while:while_basic:*": { "subcaseMS": 5.951 },
"webgpu:shader,execution,flow_control,while:while_break:*": { "subcaseMS": 12.450 },
"webgpu:shader,execution,flow_control,while:while_continue:*": { "subcaseMS": 5.650 },
Expand Down
33 changes: 33 additions & 0 deletions src/webgpu/shader/execution/flow_control/switch.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,3 +154,36 @@ ${f.expect_order(2)}
`
);
});

g.test('switch_inside_loop_with_continue')
.desc('Test that flow control executes correct for a switch calling continue inside a loop')
.params(u => u.combine('preventValueOptimizations', [true, false]))
.fn(t => {
runFlowControlTest(
t,
f => `
${f.expect_order(0)}
var i = ${f.value(0)};
loop {
switch (i) {
case 1: {
${f.expect_order(4)}
continue;
}
default: {
${f.expect_order(1)}
break;
}
}
${f.expect_order(2)}
continuing {
${f.expect_order(3, 5)}
i++;
break if i >= 2;
}
}
${f.expect_order(6)}
`
);
});

0 comments on commit a7a4900

Please sign in to comment.