mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[spv-out] fix switch cases after default not being output
This commit is contained in:
@@ -1682,26 +1682,20 @@ impl<'w> BlockContext<'w> {
|
||||
|
||||
let default_id = self.gen_id();
|
||||
|
||||
let mut reached_default = false;
|
||||
let mut raw_cases = Vec::with_capacity(cases.len());
|
||||
let mut case_ids = Vec::with_capacity(cases.len());
|
||||
for case in cases.iter() {
|
||||
match case.value {
|
||||
crate::SwitchValue::Integer(value) => {
|
||||
let label_id = self.gen_id();
|
||||
// No cases should be added after the default case is encountered
|
||||
// since the default case catches all
|
||||
if !reached_default {
|
||||
raw_cases.push(super::instructions::Case {
|
||||
value: value as Word,
|
||||
label_id,
|
||||
});
|
||||
}
|
||||
raw_cases.push(super::instructions::Case {
|
||||
value: value as Word,
|
||||
label_id,
|
||||
});
|
||||
case_ids.push(label_id);
|
||||
}
|
||||
crate::SwitchValue::Default => {
|
||||
case_ids.push(default_id);
|
||||
reached_default = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1732,17 +1726,6 @@ impl<'w> BlockContext<'w> {
|
||||
)?;
|
||||
}
|
||||
|
||||
// If no default was encountered write a empty block to satisfy the presence of
|
||||
// a block the default label
|
||||
if !reached_default {
|
||||
self.write_block(
|
||||
default_id,
|
||||
&[],
|
||||
BlockExit::Branch { target: merge_id },
|
||||
inner_context,
|
||||
)?;
|
||||
}
|
||||
|
||||
block = Block::new(merge_id);
|
||||
}
|
||||
crate::Statement::Loop {
|
||||
|
||||
@@ -92,7 +92,7 @@ OpBranch %50
|
||||
%50 = OpLabel
|
||||
%52 = OpLoad %4 %37
|
||||
OpSelectionMerge %53 None
|
||||
OpSwitch %52 %54 1 %55 2 %56 3 %57 4 %58 5 %59
|
||||
OpSwitch %52 %54 1 %55 2 %56 3 %57 4 %58 5 %59 6 %60
|
||||
%55 = OpLabel
|
||||
OpStore %37 %5
|
||||
OpBranch %53
|
||||
|
||||
Reference in New Issue
Block a user