Add binary back

This commit is contained in:
Jasper Bekkers 2020-09-14 12:18:04 +01:00
parent e26d1a7616
commit 3bba335477
No known key found for this signature in database
GPG Key ID: C59CE25F4DA6625D
2 changed files with 22 additions and 20 deletions

View File

@ -24,9 +24,9 @@ pub enum LinkerError {
Unknown,
}
type Result<T> = std::result::Result<T, LinkerError>;
pub type Result<T> = std::result::Result<T, LinkerError>;
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<rs
// output the module
Ok(output)
}
fn main() -> 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(())
}

20
rspirv-linker/src/main.rs Normal file
View File

@ -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(())
}