pub fn parse(bytes: &[u8]) -> Result<Program<'_>, Error>Expand description
Read one container with no trailing bytes. Padding and concatenation belong
to the calling file format; use parse_prefix for those.
Examples found in repository?
examples/inspect_rsx.rs (line 20)
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let mut args = std::env::args().skip(1);
7 let (Some(texture_path), Some(shader_path)) = (args.next(), args.next()) else {
8 return Err("usage: inspect <texture.bin> <shader.fpo>".into());
9 };
10 let texture = gcm::CellGcmTexture::parse(&std::fs::read(texture_path)?)?; // exactly 24 bytes
11 println!(
12 "{}x{}, {} mips, linear: {}",
13 texture.width,
14 texture.height,
15 texture.mipmap,
16 texture.linear()
17 );
18
19 let shader = std::fs::read(shader_path)?;
20 let program = cgbinary::parse(&shader)?;
21 if let cgbinary::Stage::Fragment(_) = program.stage {
22 let code = fragment::decode(program.microcode)?;
23 print!("{}", code.disassemble());
24 }
25 Ok(())
26}