From 951083d583683a48919f380521266ead64d28dfb Mon Sep 17 00:00:00 2001 From: Lily Haverlag Date: Mon, 18 Sep 2023 11:41:56 +0200 Subject: [PATCH 1/2] Separate main() into its own function in lib.rs --- .gitignore | 3 + bindings_generator/src/main.rs | 6 +- src/lib.rs | 156 +++++++++++++++++++++++++++++++-- src/main.rs | 156 +++------------------------------ test/output.dxil | Bin 0 -> 93408 bytes 5 files changed, 166 insertions(+), 155 deletions(-) create mode 100644 test/output.dxil diff --git a/.gitignore b/.gitignore index 4fffb2f..5b60e06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,5 @@ /target /Cargo.lock +.DS_Store +.vscode/launch.json +*.metallib diff --git a/bindings_generator/src/main.rs b/bindings_generator/src/main.rs index c199758..d6d6313 100644 --- a/bindings_generator/src/main.rs +++ b/bindings_generator/src/main.rs @@ -5,10 +5,7 @@ fn main() { bindgen::Builder::default() .header(header) - .clang_args(&[ - "-I./vendor/", - "-Wno-microsoft-enum-forward-reference" - ]) + .clang_args(&["-I./vendor/", "-Wno-microsoft-enum-forward-reference"]) .dynamic_link_require_all(true) .dynamic_library_name("metal_irconverter") .layout_tests(false) @@ -28,7 +25,6 @@ fn main() { .blocklist_item("__security_cookie") .blocklist_item("__va_start") .blocklist_item("__report_gsfailure") - // Not in the DLLs provided by Apple .blocklist_item("IRMetalLibSynthesizeIntersectionWrapperFunction") .generate() diff --git a/src/lib.rs b/src/lib.rs index 9d2b1de..895cad7 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,5 +1,7 @@ #![doc = include_str!("../README.md")] +use std::path::Path; + struct IRCompilerOpaque; struct IRObjectOpaque; struct IRRootSignatureOpaque; @@ -499,8 +501,6 @@ impl<'lib> IRRootSignature<'lib> { let me = (funcs.create_from_descriptor)(desc, &mut error); - dbg!(error); - Ok(Self { funcs, me }) } } @@ -587,10 +587,6 @@ impl<'lib> IRCompiler<'lib> { ) }; - dbg!(v); - - dbg!(error); - if error.is_null() { Ok(IRObject { funcs: input.funcs.clone(), @@ -601,3 +597,151 @@ impl<'lib> IRCompiler<'lib> { } } } + +// Moved from main.rs to lib.rs +fn create_static_sampler( + min_mag_mip_mode: IRFilter, + address_mode: IRTextureAddressMode, + index: u32, + anisotropy: Option, +) -> IRStaticSamplerDescriptor { + let max_anisotropy = anisotropy.unwrap_or(1); + + IRStaticSamplerDescriptor { + filter: min_mag_mip_mode, + address_u: address_mode, + address_v: address_mode, + address_w: address_mode, + mip_lod_bias: 0.0, + max_anisotropy: max_anisotropy, + comparison_func: IRComparisonFunction::IRComparisonFunctionNever, + min_lod: 0.0, + max_lod: 100000.0, + shader_register: index, + register_space: 0, + shader_visibility: IRShaderVisibility::IRShaderVisibilityAll, + border_color: IRStaticBorderColor::IRStaticBorderColorTransparentBlack, + } +} + +/// Takes a DXIL binary, cross-compiles it to metal and returns a metallib binary +pub fn compile_dxil_to_metallib( + dxil_binary: &Vec, +) -> Result, Box> { + unsafe { + // Load the metal shader converter library + // todo(lily): reconsider the hardcoded path here. the .pkg file is hardcoded to this path, but maybe we can include this dylib in the repo? + #[cfg(target_os = "macos")] + let lib = libloading::Library::new("/usr/local/lib/libmetalirconverter.dylib")?; + #[cfg(target_os = "windows")] + let lib = libloading::Library::new("metalirconverter.dll")?; // hope it's in the path or cwd, otherwise too bad + + // Set up root signature. This should match up with the root signature as defined in breda + let parameters = { + let push_constants = IRRootParameter1 { + parameter_type: IRRootParameterType::IRRootParameterType32BitConstants, + shader_visibility: IRShaderVisibility::IRShaderVisibilityAll, + u: IRRootParameter1_u { + constants: IRRootConstants { + register_space: 0 as u32, + shader_register: 0, + num32_bit_values: 4, // debug has 6 + }, + }, + }; + + let indirect_identifier = IRRootParameter1 { + parameter_type: IRRootParameterType::IRRootParameterType32BitConstants, + shader_visibility: IRShaderVisibility::IRShaderVisibilityAll, + u: IRRootParameter1_u { + constants: IRRootConstants { + register_space: 1 as u32, + shader_register: 0, + num32_bit_values: 1, + }, + }, + }; + + vec![push_constants, indirect_identifier] + }; + + let static_samplers = [ + create_static_sampler( + IRFilter::IRFilterMinMagMipPoint, + IRTextureAddressMode::IRTextureAddressModeWrap, + 0, + None, + ), + create_static_sampler( + IRFilter::IRFilterMinMagMipPoint, + IRTextureAddressMode::IRTextureAddressModeClamp, + 1, + None, + ), + create_static_sampler( + IRFilter::IRFilterMinMagMipLinear, + IRTextureAddressMode::IRTextureAddressModeWrap, + 2, + None, + ), + create_static_sampler( + IRFilter::IRFilterMinMagMipLinear, + IRTextureAddressMode::IRTextureAddressModeClamp, + 3, + None, + ), + create_static_sampler( + IRFilter::IRFilterMinMagMipLinear, + IRTextureAddressMode::IRTextureAddressModeBorder, + 4, + None, + ), + create_static_sampler( + IRFilter::IRFilterAnisotropic, + IRTextureAddressMode::IRTextureAddressModeWrap, + 5, + Some(2), + ), + create_static_sampler( + IRFilter::IRFilterAnisotropic, + IRTextureAddressMode::IRTextureAddressModeWrap, + 6, + Some(4), + ), + ]; + + let desc_1_1 = IRRootSignatureDescriptor1 { + flags: IRRootSignatureFlags::IRRootSignatureFlagCBVSRVUAVHeapDirectlyIndexed, + num_parameters: parameters.len() as u32, + p_parameters: parameters.as_ptr(), + num_static_samplers: static_samplers.len() as u32, + p_static_samplers: static_samplers.as_ptr(), + }; + + let desc = IRVersionedRootSignatureDescriptor { + version: IRRootSignatureVersion::IRRootSignatureVersion_1_1, + u: IRVersionedRootSignatureDescriptor_u { desc_1_1 }, + }; + + let root_sig = IRRootSignature::create_from_descriptor(&lib, &desc)?; + + // Cross-compile to Metal + let mut mtl_binary = IRMetalLibBinary::new(&lib)?; + let obj = IRObject::create_from_dxil(&lib, &dxil_binary)?; + let mut c = IRCompiler::new(&lib)?; + c.set_global_root_signature(&root_sig); + let mtllib = c.alloc_compile_and_link(&[b"main\0"], &obj)?; + mtllib.get_metal_lib_binary(IRShaderStage::IRShaderStageCompute, &mut mtl_binary); + + Ok(mtl_binary.get_byte_code()) + } +} + +pub fn compile_dxil_to_metallib_from_path( + path_dxil: &Path, +) -> Result, Box> { + // Load DXIL binary from path + let dxil_binary = std::fs::read(path_dxil)?; + let metallib = compile_dxil_to_metallib(&dxil_binary); + return metallib; +} diff --git a/src/main.rs b/src/main.rs index 8d1bfb2..9e8544a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,146 +1,14 @@ -use saxaboom::{ - IRComparisonFunction, IRCompiler, IRFilter, IRMetalLibBinary, IRObject, IRRootConstants, - IRRootDescriptor1, IRRootParameter1, IRRootParameter1_u, IRRootParameterType, IRRootSignature, - IRRootSignatureDescriptor1, IRRootSignatureFlags, IRRootSignatureVersion, IRShaderStage, - IRShaderVisibility, IRStaticBorderColor, IRStaticSamplerDescriptor, IRTextureAddressMode, - IRVersionedRootSignatureDescriptor, IRVersionedRootSignatureDescriptor_u, -}; - -fn create_static_sampler( - min_mag_mip_mode: IRFilter, - address_mode: IRTextureAddressMode, - index: u32, - anisotropy: Option, -) -> IRStaticSamplerDescriptor { - let max_anisotropy = anisotropy.unwrap_or(1); - - IRStaticSamplerDescriptor { - filter: min_mag_mip_mode, - address_u: address_mode, - address_v: address_mode, - address_w: address_mode, - mip_lod_bias: 0.0, - max_anisotropy: max_anisotropy, - comparison_func: IRComparisonFunction::IRComparisonFunctionNever, - min_lod: 0.0, - max_lod: 100000.0, - shader_register: index, - register_space: 0, - shader_visibility: IRShaderVisibility::IRShaderVisibilityAll, - border_color: IRStaticBorderColor::IRStaticBorderColorTransparentBlack, - } -} - -fn main() -> Result<(), Box> { - unsafe { - let lib = libloading::Library::new( - "C:/Program Files/Metal Shader Converter/lib/metalirconverter.dll", - )?; - - let parameters = { - let push_constants = IRRootParameter1 { - parameter_type: IRRootParameterType::IRRootParameterType32BitConstants, - shader_visibility: IRShaderVisibility::IRShaderVisibilityAll, - u: IRRootParameter1_u { - constants: IRRootConstants { - register_space: 0 as u32, - shader_register: 0, - num32_bit_values: 4, // debug has 6 - }, - }, - }; - - let indirect_identifier = IRRootParameter1 { - parameter_type: IRRootParameterType::IRRootParameterType32BitConstants, - shader_visibility: IRShaderVisibility::IRShaderVisibilityAll, - u: IRRootParameter1_u { - constants: IRRootConstants { - register_space: 1 as u32, - shader_register: 0, - num32_bit_values: 1, - }, - }, - }; - - vec![push_constants, indirect_identifier] - }; - - let static_samplers = [ - create_static_sampler( - IRFilter::IRFilterMinMagMipPoint, - IRTextureAddressMode::IRTextureAddressModeWrap, - 0, - None, - ), - create_static_sampler( - IRFilter::IRFilterMinMagMipPoint, - IRTextureAddressMode::IRTextureAddressModeClamp, - 1, - None, - ), - create_static_sampler( - IRFilter::IRFilterMinMagMipLinear, - IRTextureAddressMode::IRTextureAddressModeWrap, - 2, - None, - ), - create_static_sampler( - IRFilter::IRFilterMinMagMipLinear, - IRTextureAddressMode::IRTextureAddressModeClamp, - 3, - None, - ), - create_static_sampler( - IRFilter::IRFilterMinMagMipLinear, - IRTextureAddressMode::IRTextureAddressModeBorder, - 4, - None, - ), - create_static_sampler( - IRFilter::IRFilterAnisotropic, - IRTextureAddressMode::IRTextureAddressModeWrap, - 5, - Some(2), - ), - create_static_sampler( - IRFilter::IRFilterAnisotropic, - IRTextureAddressMode::IRTextureAddressModeWrap, - 6, - Some(4), - ), - ]; - - let desc_1_1 = IRRootSignatureDescriptor1 { - flags: IRRootSignatureFlags::IRRootSignatureFlagCBVSRVUAVHeapDirectlyIndexed, - num_parameters: parameters.len() as u32, - p_parameters: parameters.as_ptr(), - num_static_samplers: static_samplers.len() as u32, - p_static_samplers: static_samplers.as_ptr(), - }; - - let desc = IRVersionedRootSignatureDescriptor { - version: IRRootSignatureVersion::IRRootSignatureVersion_1_1, - u: IRVersionedRootSignatureDescriptor_u { desc_1_1 }, - }; - - let root_sig = IRRootSignature::create_from_descriptor(&lib, &desc)?; - - let egui_update = include_bytes!( - "C:/Users/Jasper/traverse/breda/crates/breda-egui/assets/shaders/egui_update.cs.dxil" - ); - // let memcpy = include_bytes!("C:/Users/Jasper/traverse/breda/apps/cs-memcpy/assets/shaders/memcpy.cs.dxil"); - - let mut mtl_binary = IRMetalLibBinary::new(&lib)?; - - let obj = IRObject::create_from_dxil(&lib, egui_update)?; - let mut c = IRCompiler::new(&lib)?; - c.set_global_root_signature(&root_sig); - let mtllib = c.alloc_compile_and_link(&[b"main\0"], &obj)?; - dbg!(mtllib.get_type()); - dbg!(mtllib.get_metal_ir_shader_stage()); - mtllib.get_metal_lib_binary(IRShaderStage::IRShaderStageCompute, &mut mtl_binary); - dbg!(mtl_binary.get_byte_code().len()); - std::fs::write("out.bin", mtl_binary.get_byte_code()); +use std::path::Path; + +use saxaboom::compile_dxil_to_metallib_from_path; + +fn main() { + let shaders_to_test = ["test/output.dxil"]; + for shader_path in shaders_to_test { + print!("Testing shader \"{shader_path}\": "); + match compile_dxil_to_metallib_from_path(&Path::new(shader_path)) { + Ok(_) => println!("\tOk."), + Err(e) => println!("Error: {e:?}"), + } } - Ok(()) } diff --git a/test/output.dxil b/test/output.dxil new file mode 100644 index 0000000000000000000000000000000000000000..29e80bc00a93169db6530ce32ebb4ca63812cab6 GIT binary patch literal 93408 zcmeHw30zZWw)hRf5E8^7s0jfZz)~b?*(z>r*+e!i2qH^pfe@6khy<<5v=cUsik3wy z5NScwY2AuTwb*w4fYw2j4!9KreLA(&_V4uBzImOt)Bo%Le0NE1LVy54ah~}pB=>&b z`ObItbG~y!K#ZS1rt@OJ=Q|k;%p86P!2c-tp924L;eRjs{VD^il`*hu@c$wFj|>cU zW5acLnV=uRkxSgk&lvjsiq7Zo$Y{4jxb6o3^}T+F*96)PA9#;&qW<&YJ-!h9rd|`t zH>T7D_#GS;;8&W!z*4aZSjtM+OH6PW3xM$8-Uhht=ihYO!2-kL;U2d@gu}FkduI7g zWxlPZ!7QG~{BlN-#j_LGg6XE)lNJ2MCVu5yzw`$puK+%5cio2h#sD*}*3G!T~DLEAF(F?oOD=7;DlQ^dH=O8yzWWt3vU zFpdf1tP2wTL}6?eyv4SP2>N?CD$PYH#irIy`-|YmS4DNDHj~3jO1MSm!+6SOwvRc+ zVVU%?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^)mxP5_%$=&Q{4 zVrfPmfsx@ti+vU|JR6QpWP2v5rm<48S=L2M>+`4f1zw0g-7LE1<8dUtF#Kq10k#%aZ5HXI$yM->2-@efQ1dpB0z6*NM;ls~WXSNh9|3 z1$v+Hz035xU)Vfp|I2)zx+1Q6{@t!^tUzXO=N8apq3?fcn*#?JPo=KrYW0xa~`PvG(F-d>Av;gwU*pBU z&w?JN>c+n@`r}{w0peeCz40%zfBYM$C;pAsiGNu>ZrBw-3SPls0n29L?`B{g$uD>% zc_q#Bp64cg!CUI)F@K(0%3PUj{=DSWq?EbRIoT=6XlRgcWDtl6{t`#+e}99;%BGo$ z8{b#{pQ9Pb*WL#&hJ5c?utRj;+X2@p-+LVHJ@vg$eeW=QFDY^GYm9v_2bR#|d)tys zYqL3Z81uf^$HynY6kIJ~D;L0Tqxf0A#?PMf@O>yUu`bH*R=9BMUHq9D?7b6Bu|-X$ zzF5$y;scFKd4FD2;O1pr)ZFbBb*>>l+_~*$c)(;VVMSNhgPW2ot!=&c51RT;@mMtN z6OYEmQ{HE0GCGT(hBBw59m*&niPs#UT!TODlD^4FELBYw$+T-Guh>J)#skhu7U5@8 zP_Thy^=WOyxV4e->Kl?o7`6oDnyQDOc+~4MX7j-3m*0PX#^&!nv7B8GeA0Gh`E>7I zY_;pz@FY%Ygvnx`i)^2Xycf3A&X%*Md2VT%o!jm^>(Y-5GTTcDo{9pIwZ1 z@Ci! Date: Tue, 19 Sep 2023 16:23:51 +0200 Subject: [PATCH 2/2] Expect user to provide library file --- src/lib.rs | 10 ++++------ src/main.rs | 3 ++- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 895cad7..8add845 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -626,15 +626,12 @@ fn create_static_sampler( /// Takes a DXIL binary, cross-compiles it to metal and returns a metallib binary pub fn compile_dxil_to_metallib( + path_compiler_lib: &Path, dxil_binary: &Vec, ) -> Result, Box> { unsafe { // Load the metal shader converter library - // todo(lily): reconsider the hardcoded path here. the .pkg file is hardcoded to this path, but maybe we can include this dylib in the repo? - #[cfg(target_os = "macos")] - let lib = libloading::Library::new("/usr/local/lib/libmetalirconverter.dylib")?; - #[cfg(target_os = "windows")] - let lib = libloading::Library::new("metalirconverter.dll")?; // hope it's in the path or cwd, otherwise too bad + let lib = libloading::Library::new(path_compiler_lib)?; // Set up root signature. This should match up with the root signature as defined in breda let parameters = { @@ -738,10 +735,11 @@ pub fn compile_dxil_to_metallib( } pub fn compile_dxil_to_metallib_from_path( + path_compiler_lib: &Path, path_dxil: &Path, ) -> Result, Box> { // Load DXIL binary from path let dxil_binary = std::fs::read(path_dxil)?; - let metallib = compile_dxil_to_metallib(&dxil_binary); + let metallib = compile_dxil_to_metallib(path_compiler_lib, &dxil_binary); return metallib; } diff --git a/src/main.rs b/src/main.rs index 9e8544a..b7464b8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -4,9 +4,10 @@ use saxaboom::compile_dxil_to_metallib_from_path; fn main() { let shaders_to_test = ["test/output.dxil"]; + for shader_path in shaders_to_test { print!("Testing shader \"{shader_path}\": "); - match compile_dxil_to_metallib_from_path(&Path::new(shader_path)) { + match compile_dxil_to_metallib_from_path(&Path::new("/usr/local/lib/libmetalirconverter.dylib"), &Path::new(shader_path)) { Ok(_) => println!("\tOk."), Err(e) => println!("Error: {e:?}"), }