[]Function wgpu::read_spirv

pub fn read_spirv<R>(x: R) -> Result<Vec<u32>, Error> where
    R: Read + Seek

Safely read SPIR-V

Converts to native endianness and returns correctly aligned storage without unnecessary copying. Returns an InvalidData error if the input is trivially not SPIR-V.

This function can also be used to convert an already in-memory &[u8] to a valid Vec<u32>, but prefer working with &[u32] from the start whenever possible.

Examples

let mut file = std::fs::File::open("/path/to/shader.spv").unwrap();
let words = gfx_hal::pso::read_spirv(&mut file).unwrap();
const SPIRV: &[u8] = &[
    0x03, 0x02, 0x23, 0x07, // ...
];
let words = gfx_hal::pso::read_spirv(std::io::Cursor::new(&SPIRV[..])).unwrap();