[glsl-in] Use local for mutable non pointer args

This commit is contained in:
João Capucho
2021-06-06 18:53:25 +01:00
committed by Dzmitry Malyshau
parent 605bab12e3
commit b15b0b6862

View File

@@ -395,7 +395,41 @@ impl<'function> Context<'function> {
None
};
if let Some(current) = self.scopes.last_mut() {
if mutable && load.is_none() {
let handle = self.locals.append(LocalVariable {
name: Some(name.clone()),
ty,
init: None,
});
let local_expr = self.add_expression(Expression::LocalVariable(handle), body);
self.emit_flush(body);
self.emit_start();
body.push(Statement::Store {
pointer: local_expr,
value: expr,
});
let local_load = self.add_expression(
Expression::Load {
pointer: local_expr,
},
body,
);
if let Some(current) = self.scopes.last_mut() {
(*current).insert(
name,
VariableReference {
expr: local_expr,
load: Some(local_load),
mutable,
entry_arg: None,
},
);
}
} else if let Some(current) = self.scopes.last_mut() {
(*current).insert(
name,
VariableReference {