From 274042a1a74b8a7f04bc3d4129d3f02f00f68f5f Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 15 Jul 2026 11:00:37 +0100 Subject: [PATCH] Fix disassembly of SPIR-V loop continues * An actual continue will need to print a goto to the increment block as we don't try to disassemble for loops --- .../driver/shaders/spirv/spirv_disassemble.cpp | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp b/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp index fd23a68d1..53d1021f6 100644 --- a/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_disassemble.cpp @@ -289,6 +289,8 @@ rdcstr Reflector::Disassemble(const rdcstr &entryPoint, // set of labels that must be printed because we have gotos for them std::set printLabels; + uint32_t loop_continue = 0; + Id currentBlock; ret = StringFormat::Fmt( @@ -1137,15 +1139,24 @@ rdcstr Reflector::Disassemble(const rdcstr &entryPoint, continue; } - // if we're in a loop, branches to the continue target are printed as 'continue' + // if we're in a loop, branches to the header target are printed as 'continue' - notably + // branches to the continue block are _not_ because they may contain the increment code if(lastLoopSwitch && lastLoopSwitch->type == StructuredCFG::Loop && - lastLoopSwitch->continueTarget == decoded.targetLabel) + lastLoopSwitch->headerBlock == decoded.targetLabel) { ret += indent + "continue;\n"; lineNum++; continue; } + if(lastLoopSwitch && lastLoopSwitch->type == StructuredCFG::Loop && + lastLoopSwitch->continueTarget == decoded.targetLabel) + { + if(dynamicNames.find(decoded.targetLabel) == dynamicNames.end()) + dynamicNames[decoded.targetLabel] = + StringFormat::Fmt("loop_continue%u", ++loop_continue); + } + // if we're in a switch and we're about to print a goto, see if it's a case label and // print a 'nicer' goto. Fallthrough to the next case would be handled above as a // redundant goto