File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,6 @@ edition = "2021"
77
88[dependencies ]
99shader-compiler-bridge = { path = " ../bridge" }
10- # naga = { version = "0.11.0", features = ["spv-in", "glsl-out"] }
1110spirv_cross = { version = " 0.23.1" , features = [" glsl" ] }
11+ clap = { version = " 4.1.8" , features = [" derive" ] }
1212byte-slice-cast = " 1.2.2"
Original file line number Diff line number Diff line change 3535*/
3636
3737use byte_slice_cast:: AsByteSlice ;
38+ use clap:: Parser ;
39+ use std:: path:: PathBuf ;
40+
41+ #[ derive( clap:: Parser ) ]
42+ struct Args {
43+ /// Path to the input binary maxwell shader
44+ ///
45+ /// Expects a 0x30-byte header before the SPH
46+ input : PathBuf ,
47+ /// Path to the output GLSL shader
48+ output : PathBuf ,
49+ }
3850
3951fn main ( ) {
40- let shader_path = std :: env :: args ( ) . nth ( 1 ) . unwrap ( ) ;
52+ let args = Args :: parse ( ) ;
4153
42- let shader = std:: fs:: read ( shader_path ) . unwrap ( ) ;
54+ let shader = std:: fs:: read ( args . input ) . unwrap ( ) ;
4355 // skip the 0x30-bytes header before the SPH
4456 let shader = & shader[ 0x30 ..] ;
4557
4658 let spirv = shader_compiler_bridge:: translate_shader ( shader. to_vec ( ) ) ;
4759 let spirv_bytes = spirv. as_byte_slice ( ) ;
4860
49- std:: fs:: write ( "shader.spv" , spirv_bytes) . unwrap ( ) ;
61+ // std::fs::write("shader.spv", spirv_bytes).unwrap();
5062
5163 let module = spirv_cross:: spirv:: Module :: from_words ( & spirv) ;
5264 let mut ast = spirv_cross:: spirv:: Ast :: < spirv_cross:: glsl:: Target > :: parse ( & module)
@@ -61,5 +73,5 @@ fn main() {
6173
6274 let glsl = ast. compile ( ) . expect ( "Failed to compile GLSL" ) ;
6375
64- println ! ( "{}" , glsl) ;
76+ std :: fs :: write ( args . output , glsl) . unwrap ( ) ;
6577}
You can’t perform that action at this time.
0 commit comments