mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[spv-in] dump the flow graph before it's serialized
This commit is contained in:
committed by
Dzmitry Malyshau
parent
1dc955551b
commit
cb45cd9011
@@ -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);
|
||||
|
||||
@@ -142,14 +142,26 @@ impl<I: Iterator<Item = u32>> super::Parser<I> {
|
||||
|
||||
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<I: Iterator<Item = u32>> super::Parser<I> {
|
||||
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(())
|
||||
|
||||
Reference in New Issue
Block a user