Function rspirv::dr::load_bytes
source · pub fn load_bytes(binary: impl AsRef<[u8]>) -> ParseResult<Module>
Expand description
Loads the SPIR-V binary
into memory and returns a Module
.
Examples
use rspirv;
use rspirv::binary::Disassemble;
let buffer: Vec<u8> = vec![
// Magic number. Version number: 1.0.
0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00,
// Generator number: 0. Bound: 0.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
// Reserved word: 0.
0x00, 0x00, 0x00, 0x00,
// OpMemoryModel. Logical.
0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00,
// GLSL450.
0x01, 0x00, 0x00, 0x00];
let dis = match rspirv::dr::load_bytes(buffer) {
Ok(module) => module.disassemble(),
Err(err) => format!("{}", err),
};
assert_eq!(dis,
"; SPIR-V\n\
; Version: 1.0\n\
; Generator: rspirv\n\
; Bound: 0\n\
OpMemoryModel Logical GLSL450");