Naga(msl): Clear named expressions after writing each function (#4594)

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
This commit is contained in:
Daniel McNab 2023-11-02 18:46:36 +00:00 committed by GitHub
parent ea8b619ba4
commit 7709010a79
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -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

View File

@ -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 {
@ -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)