diff --git a/examples/convert.rs b/examples/convert.rs index 2174cdaf1f..e148049019 100644 --- a/examples/convert.rs +++ b/examples/convert.rs @@ -76,9 +76,10 @@ fn main() { } let param_path = std::path::PathBuf::from(&args[1]).with_extension("param.ron"); - let params = match fs::read_to_string(param_path) { + let params = match fs::read_to_string(¶m_path) { Ok(string) => ron::de::from_str(&string).unwrap_pretty(), Err(_) => { + log::warn!("Param file {:?} not found, using defaults", param_path); let mut param = Parameters::default(); // very useful to have this by default param.spv_capabilities.insert(spirv::Capability::Shader); diff --git a/src/front/spv/function.rs b/src/front/spv/function.rs index 8675e53930..307d398559 100644 --- a/src/front/spv/function.rs +++ b/src/front/spv/function.rs @@ -142,14 +142,26 @@ impl> super::Parser { flow_graph.classify(); flow_graph.remove_phi_instructions(&self.lookup_expression); + + if let Some(ref prefix) = self.options.flow_graph_dump_prefix { + let dump = flow_graph.to_graphviz().unwrap_or_default(); + let dump_suffix = match self.lookup_entry_point.get(&fun_id) { + Some(ep) => format!("flow.{:?}-{}.dot", ep.stage, ep.name), + None => format!("flow.Fun-{}.dot", module.functions.len()), + }; + let dest = prefix.join(dump_suffix); + if let Err(e) = std::fs::write(&dest, dump) { + log::error!("Unable to dump the flow graph into {:?}: {}", dest, e); + } + } + fun.body = flow_graph.to_naga()?; // done self.patch_function_calls(&mut fun)?; - let dump_suffix = match self.lookup_entry_point.remove(&fun_id) { + match self.lookup_entry_point.remove(&fun_id) { Some(ep) => { - let dump_name = format!("flow.{:?}-{}.dot", ep.stage, ep.name); module.entry_points.insert( (ep.stage, ep.name), crate::EntryPoint { @@ -158,20 +170,13 @@ impl> super::Parser { function: fun, }, ); - dump_name } None => { let handle = module.functions.append(fun); self.lookup_function.insert(fun_id, handle); - format!("flow.Fun-{}.dot", handle.index()) } }; - if let Some(ref prefix) = self.options.flow_graph_dump_prefix { - let dump = flow_graph.to_graphviz().unwrap_or_default(); - let _ = std::fs::write(prefix.join(dump_suffix), dump); - } - self.lookup_expression.clear(); self.lookup_sampled_image.clear(); Ok(())