-
Notifications
You must be signed in to change notification settings - Fork 344
Closed
Labels
wgslWebGPU Shading Language IssuesWebGPU Shading Language Issueswgsl resolvedResolved - waiting for a change to the WGSL specificationResolved - waiting for a change to the WGSL specification
Description
Right now the case statement allows matching only one literal value:
const x_9 : u32 = w;
switch (x_9) {
default: {
w = 10;
}
case 0: {
w = 1;
}
case 1: {
w = 2;
}
case 5: {
fallthrough;
}
case 6: {
w = 6;
}
}
In this example, both the 5 and 6 cases should do the same thing. I propose that we be able to list multiple values per case statement, like this:
const x_9 : u32 = w;
switch (x_9) {
default: {
w = 10;
}
case 0: {
w = 1;
}
case 1: {
w = 2;
}
case 5, 6: { // This is the changed line.
w = 6;
}
}
This eliminates the need to write a bunch of boilerplate, namely { fallthrough; }
It's also easier to read, and to preserve in a round-trip with SPIR-V and LLVM. (In SPIR-V and LLVM, you can repeat the target block name for different case values.)
We would still retain the restriction that a case value may not appear in two different case statements for a particular switch construct.
mehmetoguzderin, kvark, othermaciej, kdashg, damyanp and 1 more
Metadata
Metadata
Assignees
Labels
wgslWebGPU Shading Language IssuesWebGPU Shading Language Issueswgsl resolvedResolved - waiting for a change to the WGSL specificationResolved - waiting for a change to the WGSL specification