mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
spv-in: special-case a loop with true/false node == merge node
beautify beautify #2
This commit is contained in:
committed by
Dzmitry Malyshau
parent
67e3e0a697
commit
44a6c02cda
@@ -338,13 +338,24 @@ impl FlowGraph {
|
||||
condition,
|
||||
true_id,
|
||||
false_id,
|
||||
} => body.push(crate::Statement::If {
|
||||
condition,
|
||||
accept: self
|
||||
.naga_traverse(self.block_to_node[&true_id], Some(merge_node_index))?,
|
||||
reject: self
|
||||
.naga_traverse(self.block_to_node[&false_id], Some(merge_node_index))?,
|
||||
}),
|
||||
} => {
|
||||
let true_node_index = self.block_to_node[&true_id];
|
||||
let false_node_index = self.block_to_node[&false_id];
|
||||
|
||||
body.push(crate::Statement::If {
|
||||
condition,
|
||||
accept: if true_node_index == merge_node_index {
|
||||
vec![crate::Statement::Break]
|
||||
} else {
|
||||
self.naga_traverse(true_node_index, Some(merge_node_index))?
|
||||
},
|
||||
reject: if false_node_index == merge_node_index {
|
||||
vec![crate::Statement::Break]
|
||||
} else {
|
||||
self.naga_traverse(false_node_index, Some(merge_node_index))?
|
||||
},
|
||||
});
|
||||
}
|
||||
Terminator::Branch { target_id } => body.extend(
|
||||
self.naga_traverse(self.block_to_node[&target_id], Some(merge_node_index))?,
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user