pub fn code(bytes: &[u8]) -> Result<Vec<u32>>Expand description
The program’s token stream (its SHEX or SHDR part) as 32-bit little-endian words, for decode().
Examples found in repository?
examples/inspect_dxbc.rs (line 6)
3fn main() -> Result<(), Box<dyn std::error::Error>> {
4 let path = std::env::args().nth(1).ok_or("usage: inspect <shader.dxbc>")?;
5 let container = std::fs::read(path)?;
6 let code = dxbc_reader::code(&container)?; // the SHDR/SHEX part as 32-bit words
7 let program = dxbc_reader::decode(&code)?;
8 println!(
9 "{} with {} instructions",
10 program.target(),
11 program.instructions.len()
12 );
13
14 // Reflection and signatures straight from the container:
15 if let Some(rdef) = dxbc_reader::rdef(&container)? {
16 for binding in &rdef.bindings {
17 println!("{} at register {}", binding.name, binding.register);
18 }
19 }
20 let (stage, inputs, outputs) = dxbc_reader::signature_elements(&container)?;
21 println!("{stage:?}: {} inputs, {} outputs", inputs.len(), outputs.len());
22 Ok(())
23}