Skip to main content

rdef

Function rdef 

Source
pub fn rdef(bytes: &[u8]) -> Result<Option<Rdef>>
Expand description

A container’s RDEF part (None where it has none): the Shader Model 4 layout where its target is a 4.x one (a 28-byte header, then the tables), the Shader Model 5 layout (the RD11 record-size directory) where it is a 5.x one.

Examples found in repository?
examples/inspect_dxbc.rs (line 15)
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}