diff --git a/renderdoc/driver/shaders/dxil/dxil_bytecode.cpp b/renderdoc/driver/shaders/dxil/dxil_bytecode.cpp index 1fcbe3225..827cb51e9 100644 --- a/renderdoc/driver/shaders/dxil/dxil_bytecode.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_bytecode.cpp @@ -2558,7 +2558,7 @@ void LLVMOrderAccumulator::processGlobals(Program *prog, bool doLiveChecking) } } -void LLVMOrderAccumulator::processFunction(const Function *f) +void LLVMOrderAccumulator::processFunction(const Function *f, uint32_t *nextSSAId) { const Function &func = *f; @@ -2611,8 +2611,18 @@ void LLVMOrderAccumulator::processFunction(const Function *f) uint32_t curBlock = 0; for(Instruction *arg : func.args) + { +#if DISABLED(DXC_COMPATIBLE_DISASM) + if(arg->slot == ~0U) + { + arg->slot = *nextSSAId; + (*nextSSAId)++; + } +#else if(arg->getName().isEmpty()) arg->slot = slot++; +#endif + } if(!func.blocks.empty() && func.blocks[0]->name.empty()) func.blocks[0]->slot = slot++; @@ -2636,8 +2646,16 @@ void LLVMOrderAccumulator::processFunction(const Function *f) { accumulate(inst); +#if DISABLED(DXC_COMPATIBLE_DISASM) + if(inst->slot == ~0U) + { + inst->slot = *nextSSAId; + (*nextSSAId)++; + } +#else if(inst->getName().isEmpty()) inst->slot = slot++; +#endif } if(inst->op == Operation::Branch || inst->op == Operation::Unreachable || diff --git a/renderdoc/driver/shaders/dxil/dxil_bytecode.h b/renderdoc/driver/shaders/dxil/dxil_bytecode.h index 9cf1ea80e..6c3e72a8c 100644 --- a/renderdoc/driver/shaders/dxil/dxil_bytecode.h +++ b/renderdoc/driver/shaders/dxil/dxil_bytecode.h @@ -1263,7 +1263,10 @@ struct Instruction : public ForwardReferencableValue uint32_t debugLoc = ~0U; Operation op = Operation::NoOp; uint8_t align = 0; - // number assigned to instructions that don't have names and return a value, for disassembly + // For DXC Compatibility mode: slot contains a number assigned to instructions that don't have + // names and return a value, used for disassembly + + // Otherwise a unique global ID used by the debugger and disassemvbly uint32_t slot = ~0U; InstructionFlags &opFlags() { return (InstructionFlags &)flags; } InstructionFlags opFlags() const { return (InstructionFlags)flags; } @@ -1384,7 +1387,7 @@ public: size_t firstFuncConst; size_t numFuncConsts; - void processFunction(const Function *f); + void processFunction(const Function *f, uint32_t *nextSSAId = NULL); void exitFunction(); private: @@ -1645,6 +1648,7 @@ protected: rdcarray m_MetaSlots; rdcarray m_FuncAttrGroups; uint32_t m_NextMetaSlot = 0; + uint32_t m_NextSSAId = 0; bool m_Uselists = false; bool m_DXCStyle = false; diff --git a/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp b/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp index 6e666f77b..54da1a695 100644 --- a/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_disassemble.cpp @@ -1043,6 +1043,7 @@ void Program::Parse(const DXBC::Reflection *reflection) void Program::SettleIDs() { + RDCASSERTEQUAL(m_NextSSAId, 0); RDCASSERTEQUAL(m_NextMetaSlot, 0); RDCASSERT(m_MetaSlots.isEmpty()); @@ -1063,7 +1064,7 @@ void Program::SettleIDs() uint32_t &nextMetaSlot = m_NextMetaSlot; for(size_t i = 0; i < m_Functions.size(); i++) { - m_Accum.processFunction(m_Functions[i]); + m_Accum.processFunction(m_Functions[i], &m_NextSSAId); Function &func = *m_Functions[i];