Don't print the module in converter if no output is specified (#744)

This commit is contained in:
Dzmitry Malyshau
2021-04-21 09:40:29 -04:00
committed by GitHub
parent 4664cd301a
commit b86c2fbeeb
2 changed files with 16 additions and 7 deletions

View File

@@ -15,7 +15,7 @@ Front-end | Status | Feature | Notes |
--------------- | ------------------ | ------- | ----- |
SPIR-V (binary) | :white_check_mark: | spv-in | |
WGSL | :white_check_mark: | wgsl-in | |
GLSL | :ok: | glsl-in | Vulkan flavor is expected |
GLSL | :construction: | glsl-in | Vulkan flavor is expected |
Rust | | | |
Back-end | Status | Feature | Notes |
@@ -36,7 +36,8 @@ DOT (GraphViz) | :ok: | dot-out | Not a shading language |
Naga includes a default binary target "convert", which allows to test the conversion of different code paths.
```bash
cargo run --features spv-in -- my_shader.spv # dump the IR module to debug output
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,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

@@ -23,10 +23,10 @@ trait PrettyResult {
}
fn print_err(error: impl Error) {
println!("{}:", error);
eprintln!("{}:", error);
let mut e = error.source();
while let Some(source) = e {
println!("\t{}", source);
eprintln!("\t{}", source);
e = source.source();
}
}
@@ -174,7 +174,6 @@ fn main() {
};
// validate the IR
#[allow(unused_variables)]
let info =
match naga::valid::Validator::new(naga::valid::ValidationFlags::all()).validate(&module) {
Ok(info) => Some(info),
@@ -187,11 +186,20 @@ fn main() {
let output_path = match output_path {
Some(ref string) => string,
None => {
println!("{:#?}", module);
println!("{:#?}", info);
if info.is_some() {
println!("Validation successful");
}
return;
}
};
if output_path == "-" {
println!("{:#?}", module);
if let Some(info) = info {
println!();
println!("{:#?}", info);
}
return;
}
match Path::new(output_path)
.extension()