From f3f02c327cccdce5b05e93914d691d643681912b Mon Sep 17 00:00:00 2001 From: Malcolm Bechard Date: Wed, 5 Jan 2022 15:25:16 -0500 Subject: [PATCH] fix for #1501 Maintain the incrementing location throughout the structure traversal. --- .../MoltenVKShaderConverter/SPIRVReflection.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/MoltenVKShaderConverter/MoltenVKShaderConverter/SPIRVReflection.h b/MoltenVKShaderConverter/MoltenVKShaderConverter/SPIRVReflection.h index f96f693e..ad4ca405 100644 --- a/MoltenVKShaderConverter/MoltenVKShaderConverter/SPIRVReflection.h +++ b/MoltenVKShaderConverter/MoltenVKShaderConverter/SPIRVReflection.h @@ -216,10 +216,10 @@ namespace mvk { type = &reflect.get_type(type->parent_type); if (type->basetype == SPIRV_CROSS_NAMESPACE::SPIRType::Struct) { + uint32_t memberLoc = loc; for (uint32_t idx = 0; idx < type->member_types.size(); idx++) { // Each member may have a location decoration. If not, each member - // gets an incrementing location. - uint32_t memberLoc = addSat(loc, idx); + // gets an incrementing location based the base location for the struct. uint32_t memberCmp = 0; if (reflect.has_member_decoration(type->self, idx, spv::DecorationLocation)) { memberLoc = reflect.get_member_decoration(type->self, idx, spv::DecorationLocation); @@ -233,14 +233,17 @@ namespace mvk { const SPIRV_CROSS_NAMESPACE::SPIRType& memberType = reflect.get_type(type->member_types[idx]); if (memberType.columns > 1) { for (uint32_t i = 0; i < memberType.columns; i++) { - outputs.push_back({memberType.basetype, memberType.vecsize, addSat(memberLoc, i), memberCmp, biType, patch, isUsed}); + outputs.push_back({memberType.basetype, memberType.vecsize, memberLoc, memberCmp, biType, patch, isUsed}); + memberLoc = addSat(memberLoc, 1); } } else if (!memberType.array.empty()) { for (uint32_t i = 0; i < memberType.array[0]; i++) { - outputs.push_back({memberType.basetype, memberType.vecsize, addSat(memberLoc, i), memberCmp, biType, patch, isUsed}); + outputs.push_back({memberType.basetype, memberType.vecsize, memberLoc, memberCmp, biType, patch, isUsed}); + memberLoc = addSat(memberLoc, 1); } } else { outputs.push_back({memberType.basetype, memberType.vecsize, memberLoc, memberCmp, biType, patch, isUsed}); + memberLoc = addSat(memberLoc, 1); } } } else if (type->columns > 1) {