From 3bba33547759817436b60129fbf53140f4ff2d61 Mon Sep 17 00:00:00 2001 From: Jasper Bekkers Date: Mon, 14 Sep 2020 12:18:04 +0100 Subject: [PATCH] Add binary back --- rspirv-linker/src/lib.rs | 22 ++-------------------- rspirv-linker/src/main.rs | 20 ++++++++++++++++++++ 2 files changed, 22 insertions(+), 20 deletions(-) create mode 100644 rspirv-linker/src/main.rs diff --git a/rspirv-linker/src/lib.rs b/rspirv-linker/src/lib.rs index 047ffda419..0f19a4e231 100644 --- a/rspirv-linker/src/lib.rs +++ b/rspirv-linker/src/lib.rs @@ -24,9 +24,9 @@ pub enum LinkerError { Unknown, } -type Result = std::result::Result; +pub type Result = std::result::Result; -fn load(bytes: &[u8]) -> rspirv::dr::Module { +pub fn load(bytes: &[u8]) -> rspirv::dr::Module { let mut loader = rspirv::dr::Loader::new(); rspirv::binary::parse_bytes(&bytes, &mut loader).unwrap(); let module = loader.module(); @@ -838,21 +838,3 @@ pub fn link(inputs: &mut [&mut rspirv::dr::Module], opts: &Options) -> Result Result<()> { - let body1 = include_bytes!("../test/1/body_1.spv"); - let body2 = include_bytes!("../test/1/body_2.spv"); - - let mut body1 = load(&body1[..]); - let mut body2 = load(&body2[..]); - - let opts = Options { - lib: false, - partial: false, - }; - - let output = link(&mut [&mut body1, &mut body2], &opts)?; - println!("{}\n\n", output.disassemble()); - - Ok(()) -} diff --git a/rspirv-linker/src/main.rs b/rspirv-linker/src/main.rs new file mode 100644 index 0000000000..c3afe8dcc5 --- /dev/null +++ b/rspirv-linker/src/main.rs @@ -0,0 +1,20 @@ +use rspirv_linker::*; +use rspirv::binary::Disassemble; + +fn main() -> Result<()> { + let body1 = include_bytes!("../test/1/body_1.spv"); + let body2 = include_bytes!("../test/1/body_2.spv"); + + let mut body1 = crate::load(&body1[..]); + let mut body2 = crate::load(&body2[..]); + + let opts = Options { + lib: false, + partial: false, + }; + + let output = link(&mut [&mut body1, &mut body2], &opts)?; + println!("{}\n\n", output.disassemble()); + + Ok(()) +}