From 7c26320cce3a55ff1c676bc7f12648de15ec8b51 Mon Sep 17 00:00:00 2001 From: Dzmitry Malyshau Date: Mon, 8 Mar 2021 21:22:23 -0500 Subject: [PATCH] [spv-in] defer function call patching to the end of the module --- src/front/spv/function.rs | 3 --- src/front/spv/mod.rs | 10 ++++++++++ 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/front/spv/function.rs b/src/front/spv/function.rs index 1fb0a74871..cc66d2b1d0 100644 --- a/src/front/spv/function.rs +++ b/src/front/spv/function.rs @@ -157,9 +157,6 @@ impl> super::Parser { fun.body = flow_graph.to_naga()?; - // done - self.patch_function_calls(&mut fun)?; - match self.lookup_entry_point.remove(&fun_id) { Some(ep) => { module.entry_points.push(crate::EntryPoint { diff --git a/src/front/spv/mod.rs b/src/front/spv/mod.rs index bd085a84b4..d43c5f882c 100644 --- a/src/front/spv/mod.rs +++ b/src/front/spv/mod.rs @@ -1754,6 +1754,16 @@ impl> Parser { }?; } + log::info!("Patching..."); + // patch all the function calls + for (_, fun) in module.functions.iter_mut() { + self.patch_function_calls(fun)?; + } + for ep in module.entry_points.iter_mut() { + self.patch_function_calls(&mut ep.function)?; + } + self.lookup_function.clear(); + // Check all the images and samplers to have consistent comparison property. for (handle, flags) in self.handle_sampling.drain() { if !image::patch_comparison_type(