pub struct Program {
pub instructions: Vec<Instruction>,
pub byte_len: usize,
}Expand description
A decoded fragment program.
Fields§
§instructions: Vec<Instruction>The instructions, in order.
byte_len: usizeThe program’s size in bytes.
Implementations§
Source§impl Program
impl Program
Sourcepub fn disassemble(&self) -> String
pub fn disassemble(&self) -> String
Stable inspection text. Full predicates and modifiers remain in the typed instruction even where an external assembler dialect omits them.
Examples found in repository?
examples/inspect_rsx.rs (line 23)
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}Trait Implementations§
impl Eq for Program
impl StructuralPartialEq for Program
Auto Trait Implementations§
impl Forget for Program
impl Freeze for Program
impl RefUnwindSafe for Program
impl Send for Program
impl Sync for Program
impl Unpin for Program
impl UnsafeUnpin for Program
impl UnwindSafe for Program
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more