Function rspirv::dr::load_words

source ·
pub fn load_words(binary: impl AsRef<[u32]>) -> 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<u32> = vec![
    0x07230203,  // Magic number
    0x00010000,  // Version number: 1.0
    0x00000000,  // Generator number: 0
    0x00000000,  // Bound: 0
    0x00000000,  // Reserved word: 0
    0x0003000e,  // OpMemoryModel
    0x00000000,  // Logical
    0x00000001,  // GLSL450
];

let dis = match rspirv::dr::load_words(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");