From 8e3c191cd139d83d496acae72eba95dbd3c502e1 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Sat, 16 Apr 2016 13:22:54 +0200 Subject: [PATCH] Print the array stride for debugging purposes as well --- vulkano-shaders/src/structs.rs | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/vulkano-shaders/src/structs.rs b/vulkano-shaders/src/structs.rs index 75fade28..64261f93 100644 --- a/vulkano-shaders/src/structs.rs +++ b/vulkano-shaders/src/structs.rs @@ -64,6 +64,20 @@ fn write_struct(doc: &parse::Spirv, struct_id: u32, members: &[u32]) -> String { None }).next(); + let spirv_stride = doc.instructions.iter().filter_map(|i| { + match *i { + parse::Instruction::Decorate { target_id, + decoration: enums::Decoration::DecorationArrayStride, + ref params } if target_id == member => + { + return Some(params[0]); + }, + _ => () + }; + + None + }).next(); + // Some structs don't have `Offset` decorations, in the case they are used as local // variables only. Ignoring these. let spirv_offset = match spirv_offset { @@ -96,8 +110,8 @@ fn write_struct(doc: &parse::Spirv, struct_id: u32, members: &[u32]) -> String { current_rust_offset = None; } - members_defs.push(format!("pub {name}: {ty} /* offset: {offset} */", - name = member_name, ty = ty, offset = spirv_offset)); + members_defs.push(format!("pub {name}: {ty} /* offset: {offset}, stride: {stride:?} */", + name = member_name, ty = ty, offset = spirv_offset, stride = spirv_stride)); } // We can only derive common traits if there's no unsized member in the struct.