From 4940451e4b093de5836c0ad6091f72afb102649c Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Thu, 8 May 2025 15:20:24 +0100 Subject: [PATCH] Make sure all SSA lifetimes extend to a uniform block (not a loop block) * Update any SSA max points which are inside a loop to the next uniform block * This covers the case of SSA IDs that are assigned to but never accessed --- renderdoc/driver/shaders/dxil/dxil_debug.cpp | 22 +++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/renderdoc/driver/shaders/dxil/dxil_debug.cpp b/renderdoc/driver/shaders/dxil/dxil_debug.cpp index da9ff60df..e60302a95 100644 --- a/renderdoc/driver/shaders/dxil/dxil_debug.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_debug.cpp @@ -8741,14 +8741,7 @@ ShaderDebugTrace *Debugger::BeginDebug(uint32_t eventId, const DXBC::DXBCContain if(inst.op == Operation::Phi) continue; - // If the current block is in a loop, set the execution point to the next uniform block ExecPointReference maxPoint(curBlock, maxInst); - if(loopBlocks.contains(curBlock)) - { - uint32_t nextUniformBlock = controlFlow.GetNextUniformBlock(curBlock); - maxPoint.block = nextUniformBlock; - maxPoint.instruction = f->blocks[nextUniformBlock]->startInstructionIdx + 1; - } for(uint32_t a = 0; a < inst.args.size(); ++a) { DXIL::Value *arg = inst.args[a]; @@ -8780,6 +8773,21 @@ ShaderDebugTrace *Debugger::BeginDebug(uint32_t eventId, const DXBC::DXBCContain // If these do not match in size that means there is a result SSA that is never read RDCASSERTEQUAL(ssaRefs.size(), ssaMaxExecPoints.size()); + // Update any SSA max points which are inside a loop to the next uniform block + // This covers the case of SSA IDs that are assigned to but never accessed + for(auto &it : ssaMaxExecPoints) + { + ExecPointReference &maxPoint = it.second; + uint32_t block = maxPoint.block; + // If the current block is in a loop, set the execution point to the next uniform block + if(loopBlocks.contains(block)) + { + uint32_t nextUniformBlock = controlFlow.GetNextUniformBlock(block); + maxPoint.block = nextUniformBlock; + maxPoint.instruction = f->blocks[nextUniformBlock]->startInstructionIdx + 1; + } + } + // store the block captured SSA IDs used as arguments to phi nodes FunctionInfo::PhiReferencedIdsPerBlock &phiReferencedIdsPerBlock = info.phiReferencedIdsPerBlock;