From b5923dcce5eb7b525b36dd18fdccb4ed84e2f069 Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Fri, 27 Oct 2023 19:48:38 +0100 Subject: [PATCH 1/2] Naga: Clear named expressions after writing 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 --- naga/src/back/msl/writer.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/naga/src/back/msl/writer.rs b/naga/src/back/msl/writer.rs index 09f7b1c73f..d93ad65062 100644 --- a/naga/src/back/msl/writer.rs +++ b/naga/src/back/msl/writer.rs @@ -3643,10 +3643,10 @@ impl Writer { 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 Writer { 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) From aac875981ebdb03fdabae56e6f9c8f5762968f5f Mon Sep 17 00:00:00 2001 From: Daniel McNab <36049421+DJMcNab@users.noreply.github.com> Date: Fri, 27 Oct 2023 19:56:53 +0100 Subject: [PATCH 2/2] Add a changelog entry --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 725f72b991..41095fb742 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,10 @@ Bottom level categories: For naga changelogs at or before v0.14.0. See [naga's changelog](naga/CHANGELOG.md). +### Bug fixes + +- Fix issue in the metal backend of naga, where local variables were sometimes using variable names from previous functions + ## v0.18.0 (2023-10-25) ### Desktop OpenGL 3.3+ Support on Windows