diff --git a/README.md b/README.md index 6b0adf349b..cd8420c72b 100644 --- a/README.md +++ b/README.md @@ -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 ``` diff --git a/bin/naga.rs b/bin/naga.rs index efa7ddd760..3f640e1d51 100644 --- a/bin/naga.rs +++ b/bin/naga.rs @@ -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;