From 4edfe96739244b4b49a80a6df9fb7c0be28160ff Mon Sep 17 00:00:00 2001 From: Alexis Payen de la Garanderie Date: Mon, 27 Apr 2020 15:54:16 +0900 Subject: [PATCH] Fixed recursion in combined_decoration_for_member Members in nested structs were not properly iterated on, and as a result, flags like row major for matrices could be not propagated properly. --- spirv_cross.cpp | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/spirv_cross.cpp b/spirv_cross.cpp index 6fd31c88..9b03ecfa 100644 --- a/spirv_cross.cpp +++ b/spirv_cross.cpp @@ -4204,19 +4204,22 @@ Bitset Compiler::combined_decoration_for_member(const SPIRType &type, uint32_t i if (type_meta) { - auto &memb = type_meta->members; - if (index >= memb.size()) + auto &members = type_meta->members; + if (index >= members.size()) return flags; - auto &dec = memb[index]; + auto &dec = members[index]; - // If our type is a struct, traverse all the members as well recursively. flags.merge_or(dec.decoration_flags); - for (uint32_t i = 0; i < type.member_types.size(); i++) + auto &member_type = get(type.member_types[index]); + + // If our member type is a struct, traverse all the child members as well recursively. + auto &member_childs = member_type.member_types; + for (uint32_t i = 0; i < member_childs.size(); i++) { - auto &memb_type = get(type.member_types[i]); - if (!memb_type.pointer) - flags.merge_or(combined_decoration_for_member(memb_type, i)); + auto &child_member_type = get(member_childs[i]); + if (!child_member_type.pointer) + flags.merge_or(combined_decoration_for_member(member_type, i)); } }