Skip to content

Commit

Permalink
Naga(msl): Clear named expressions after writing each function (#4594)
Browse files Browse the repository at this point in the history
This appears to match other backends, and fixes
fix the case where expressions which were named in earlier
functions are used in local variable declarations
  • Loading branch information
DJMcNab authored Nov 2, 2023
1 parent ea8b619 commit 7709010
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,14 @@ For naga changelogs at or before v0.14.0. See [naga's changelog](naga/CHANGELOG.

### Bug Fixes


#### WGL

- Create a hidden window per `wgpu::Instance` instead of sharing a global one.

#### Naga MSL-OUT

- Fix issue where local variables were sometimes using variable names from previous functions.

## v0.18.0 (2023-10-25)

### Desktop OpenGL 3.3+ Support on Windows
Expand Down
4 changes: 2 additions & 2 deletions naga/src/back/msl/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3643,10 +3643,10 @@ impl<W: Write> Writer<W> {
writeln!(self.out, ";")?;
}

self.named_expressions.clear();
self.update_expressions_to_bake(fun, fun_info, &context.expression);
self.put_block(back::Level(1), &fun.body, &context)?;
writeln!(self.out, "}}")?;
self.named_expressions.clear();
}

let mut info = TranslationInfo {
Expand Down Expand Up @@ -4313,13 +4313,13 @@ impl<W: Write> Writer<W> {
writeln!(self.out, ";")?;
}

self.named_expressions.clear();
self.update_expressions_to_bake(fun, fun_info, &context.expression);
self.put_block(back::Level(1), &fun.body, &context)?;
writeln!(self.out, "}}")?;
if ep_index + 1 != module.entry_points.len() {
writeln!(self.out)?;
}
self.named_expressions.clear();
}

Ok(info)
Expand Down

0 comments on commit 7709010

Please sign in to comment.