-
Notifications
You must be signed in to change notification settings - Fork 193
[hlsl-out] Implement switch statement #1265
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you!
we need to add switch
test to control_flow.wgsl
to see how/if it works
src/back/hlsl/writer.rs
Outdated
if case.fall_through { | ||
writeln!(self.out, "{}/* fallthrough */", &indent_str_2)?; | ||
writeln!(self.out, "{}{{", &indent_str_2)?; | ||
writeln!(self.out, "{}break;", INDENT.repeat(indent + 3))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand. This goes into break
and the other branch goes into break
too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, misunderstood tint
logic in fallthrough case. We should generate it in new block.
We'll need to release a patch after this is merged, for iced |
@@ -425,7 +425,9 @@ fn convert_wgsl() { | |||
), | |||
( | |||
"control-flow", | |||
Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, | |||
// TODO: SPIRV https://github.com/gfx-rs/naga/issues/1017 | |||
//Targets::SPIRV | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unfortunately, spv-out
panic with the updated test. So, I decided to remove it for a while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the panic exactly?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added test case here - #1017
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src/back/spv/block.rs:1552:83
stack backtrace:
0: rust_begin_unwind
at /rustc/a178d0322ce20e33eac124758e837cbd80a6f633/library/std/src/panicking.rs:515:5
|
||
// Write `break;` if the block isn't fallthrough | ||
if !case.fall_through { | ||
writeln!(self.out, "{}break;", INDENT.repeat(indent + 2))?; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's not required, since return
is present in IR for all cases.
@@ -425,7 +425,9 @@ fn convert_wgsl() { | |||
), | |||
( | |||
"control-flow", | |||
Targets::SPIRV | Targets::METAL | Targets::GLSL | Targets::HLSL | Targets::WGSL, | |||
// TODO: SPIRV https://github.com/gfx-rs/naga/issues/1017 | |||
//Targets::SPIRV | |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's the panic exactly?
* [hlsl-out] Implement switch statement * [hlsl-out] Implement switch statement * Add switch tests to control-flow snapshot
Included in v0.6.1 |
* [hlsl-out] Implement switch statement * [hlsl-out] Implement switch statement * Add switch tests to control-flow snapshot
Fix #1261