From faaa532aeda5bb171222134a7128254a34b87a2a Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 7 Mar 2024 23:44:19 -0800 Subject: [SPIRV] Fix pointer lowering bug. (#3713) * [SPIRV] Fix pointer lowering bug. * Update falcor CI setting. --- source/slang/slang-emit-spirv.cpp | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'source') diff --git a/source/slang/slang-emit-spirv.cpp b/source/slang/slang-emit-spirv.cpp index 098c2cc2b..1b5747621 100644 --- a/source/slang/slang-emit-spirv.cpp +++ b/source/slang/slang-emit-spirv.cpp @@ -5805,14 +5805,23 @@ SlangResult emitSPIRVFromIR( } // Move forward delcared pointers to the end. - for (auto ptrType : context.m_forwardDeclaredPointers) + do { - auto spvPtrType = context.m_mapIRInstToSpvInst[ptrType]; - context.ensureInst(ptrType->getValueType()); - auto parent = spvPtrType->parent; - spvPtrType->removeFromParent(); - parent->addInst(spvPtrType); - } + auto fwdPointers = context.m_forwardDeclaredPointers; + context.m_forwardDeclaredPointers.clear(); + + for (auto ptrType : fwdPointers) + { + auto spvPtrType = context.m_mapIRInstToSpvInst[ptrType]; + // When we emit a pointee type, we may introduce new + // forward-declared pointer types, so we need to + // keep iterating until we have emitted all of them. + context.ensureInst(ptrType->getValueType()); + auto parent = spvPtrType->parent; + spvPtrType->removeFromParent(); + parent->addInst(spvPtrType); + } + } while (context.m_forwardDeclaredPointers.getCount() != 0); context.emitFrontMatter(); -- cgit v1.2.3