Expect *.txt instead of - for the debug output of the converter

This commit is contained in:
Dzmitry Malyshau
2021-05-06 23:09:13 -04:00
parent 09032695b0
commit f18a97785f
2 changed files with 10 additions and 9 deletions

View File

@@ -37,7 +37,7 @@ DOT (GraphViz) | :ok: | dot-out | Not a shading language |
Naga includes a default binary target, which allows to test the conversion of different code paths.
```bash
cargo run --features wgsl-in -- my_shader.wgsl # validate only
cargo run --features spv-in -- my_shader.spv - # dump the IR module to debug output
cargo run --features spv-in -- my_shader.spv my_shader.txt # dump the IR module into a file
cargo run --features spv-in,msl-out -- my_shader.spv my_shader.metal --flow-dir flow-dir # convert the SPV to Metal, also dump the SPIR-V flow graph to `flow-dir`
cargo run --features wgsl-in,glsl-out -- my_shader.wgsl my_shader.vert --profile es310 # convert the WGSL to GLSL vertex stage under ES 3.20 profile
```

View File

@@ -199,14 +199,6 @@ fn main() {
}
}
};
if output_path == "-" {
println!("{:#?}", module);
if let Some(info) = info {
println!();
println!("{:#?}", info);
}
return;
}
match Path::new(output_path)
.extension()
@@ -214,6 +206,15 @@ fn main() {
.to_str()
.unwrap()
{
"txt" => {
use std::io::Write;
let mut file = fs::File::create(output_path).unwrap();
writeln!(file, "{:#?}", module).unwrap();
if let Some(info) = info {
writeln!(file).unwrap();
writeln!(file, "{:#?}", info).unwrap();
}
}
#[cfg(feature = "msl-out")]
"metal" => {
use naga::back::msl;