Skip to content

Commit

Permalink
glsl-out: Bake Constant 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 c771c9c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/back/glsl/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,17 @@ impl<'a, W: Write> Writer<'a, W> {
writeln!(self.out, ";")?
}

// Loop trough all Constant expressions and bake them if needed.
for (handle, expr) in ctx.expressions.iter() {
if let crate::Expression::Constant(_) = *expr {
if 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 c771c9c

Please sign in to comment.