mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[spv-in] fix treating OpPhi variables as pointers
This commit is contained in:
committed by
Dzmitry Malyshau
parent
e715bda507
commit
e3818bb236
@@ -202,13 +202,12 @@ impl FlowGraph {
|
||||
for node_index in self.flow.node_indices() {
|
||||
let phis = std::mem::replace(&mut self.flow[node_index].phis, Vec::new());
|
||||
for phi in phis.iter() {
|
||||
let phi_var = &lookup_expression[&phi.id];
|
||||
for &(variable_id, parent_id) in phi.variables.iter() {
|
||||
let variable = &lookup_expression[&variable_id];
|
||||
let parent_node = &mut self.flow[self.block_to_node[&parent_id]];
|
||||
|
||||
parent_node.block.push(crate::Statement::Store {
|
||||
pointer: phi_var.handle,
|
||||
pointer: phi.pointer,
|
||||
value: variable.handle,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -94,11 +94,13 @@ impl crate::TypeInner {
|
||||
}
|
||||
|
||||
/// OpPhi instruction.
|
||||
#[derive(Clone, Default, Debug)]
|
||||
#[derive(Debug)]
|
||||
struct PhiInstruction {
|
||||
/// SPIR-V's ID.
|
||||
id: u32,
|
||||
|
||||
pointer: Handle<crate::Expression>,
|
||||
|
||||
/// Tuples of (variable, parent).
|
||||
variables: Vec<(u32, u32)>,
|
||||
}
|
||||
@@ -684,25 +686,32 @@ impl<I: Iterator<Item = u32>> Parser<I> {
|
||||
ty: self.lookup_type.lookup(result_type_id)?.handle,
|
||||
init: None,
|
||||
});
|
||||
self.lookup_expression.insert(
|
||||
result_id,
|
||||
LookupExpression {
|
||||
handle: expressions
|
||||
.append(crate::Expression::LocalVariable(var_handle)),
|
||||
type_id: result_type_id,
|
||||
},
|
||||
);
|
||||
let pointer = expressions.append(crate::Expression::LocalVariable(var_handle));
|
||||
|
||||
let in_count = (inst.wc - 3) / 2;
|
||||
let mut phi = PhiInstruction {
|
||||
id: result_id,
|
||||
..Default::default()
|
||||
pointer,
|
||||
variables: Vec::with_capacity(in_count as usize),
|
||||
};
|
||||
for _ in 0..(inst.wc - 3) / 2 {
|
||||
phi.variables.push((self.next()?, self.next()?));
|
||||
for _ in 0..in_count {
|
||||
let source_id = self.next()?;
|
||||
let value = self.next()?;
|
||||
phi.variables.push((source_id, value));
|
||||
}
|
||||
|
||||
phis.push(phi);
|
||||
emitter.start(expressions);
|
||||
|
||||
// Associate the lookup with an actual value, which is emitted
|
||||
// into the current block.
|
||||
self.lookup_expression.insert(
|
||||
result_id,
|
||||
LookupExpression {
|
||||
handle: expressions.append(crate::Expression::Load { pointer }),
|
||||
type_id: result_type_id,
|
||||
},
|
||||
);
|
||||
}
|
||||
Op::AccessChain => {
|
||||
struct AccessExpression {
|
||||
|
||||
Reference in New Issue
Block a user