Skip to content

Commit

Permalink
glsl-out: Bake pre emit expressions
Browse files Browse the repository at this point in the history
These expressions don't appear in Emit statements so they need to be
baked manually.
  • Loading branch information
JCapucho committed May 27, 2022
1 parent f035854 commit 815ac82
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,16 @@ impl<'a, W: Write> Writer<'a, W> {
writeln!(self.out, ";")?
}

// Loop trough all expressions that need pre emission and if they need to be
// baked do so at the beginning of the function.
for (handle, expr) in ctx.expressions.iter() {
if expr.needs_pre_emit() && self.need_bake_expressions.contains(&handle) {
let name = format!("{}{}", back::BAKE_PREFIX, handle.index());
write!(self.out, "{}", back::Level(1))?;
self.write_named_expr(handle, name, &ctx)?;
}
}

// Write the function body (statement list)
for sta in func.body.iter() {
// Write a statement, the indentation should always be 1 when writing the function body
Expand Down

0 comments on commit 815ac82

Please sign in to comment.