diff --git a/shader-parser/src/parse.rs b/shader-parser/src/parse.rs index dcfc12db..4bfccd0e 100644 --- a/shader-parser/src/parse.rs +++ b/shader-parser/src/parse.rs @@ -1,4 +1,5 @@ +/// Parses a SPIR-V document. pub fn parse_spirv(data: &[u8]) -> Result { if data.len() < 20 { return Err(ParseError::MissingHeader); @@ -25,6 +26,9 @@ pub fn parse_spirv(data: &[u8]) -> Result { parse_u32s(&data) } +/// Parses a SPIR-V document from a list of u32s. +/// +/// Endianess has already been handled. fn parse_u32s(i: &[u32]) -> Result { if i.len() < 5 { return Err(ParseError::MissingHeader); @@ -54,6 +58,7 @@ fn parse_u32s(i: &[u32]) -> Result { }) } +/// Error that can happen when parsing. #[derive(Debug, Clone)] pub enum ParseError { MissingHeader, @@ -291,8 +296,6 @@ mod test { #[test] fn test() { let data = include_bytes!("../tests/frag.spv"); - let doc = parse::parse_spirv(data).unwrap(); - - println!("{:?}", doc); + parse::parse_spirv(data).unwrap(); } }