From ed9c24aaea1a05ace809f4d8320c8f7b60bd060f Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Wed, 18 Dec 2024 16:43:45 +0000 Subject: [PATCH] Use debug location scope to find current debug scope --- renderdoc/driver/shaders/dxil/dxil_debug.cpp | 23 +++++--------------- renderdoc/driver/shaders/dxil/dxil_debug.h | 11 +--------- 2 files changed, 6 insertions(+), 28 deletions(-) diff --git a/renderdoc/driver/shaders/dxil/dxil_debug.cpp b/renderdoc/driver/shaders/dxil/dxil_debug.cpp index 13d2f8cc7..8ece7c231 100644 --- a/renderdoc/driver/shaders/dxil/dxil_debug.cpp +++ b/renderdoc/driver/shaders/dxil/dxil_debug.cpp @@ -6158,21 +6158,6 @@ void Debugger::CalcActiveMask(rdcarray &activeMask) return; } -ScopedDebugData *Debugger::FindScopedDebugData(const uint32_t instructionIndex) const -{ - ScopedDebugData *scope = NULL; - // Scopes are sorted with increasing minInstruction - for(ScopedDebugData *s : m_DebugInfo.scopedDebugDatas) - { - uint32_t scopeMinInstruction = s->minInstruction; - if((scopeMinInstruction <= instructionIndex) && (instructionIndex <= s->maxInstruction)) - scope = s; - else if(scopeMinInstruction > instructionIndex) - break; - } - return scope; -} - ScopedDebugData *Debugger::FindScopedDebugData(const DXIL::Metadata *md) const { for(ScopedDebugData *s : m_DebugInfo.scopedDebugDatas) @@ -6205,7 +6190,6 @@ ScopedDebugData *Debugger::AddScopedDebugData(const DXIL::Metadata *scopeMD) scope = new ScopedDebugData(); scope->md = scopeMD; - scope->minInstruction = UINT32_MAX; scope->maxInstruction = 0; // File scope should not have a parent if(scopeMD->dwarf->type == DIBase::File) @@ -6651,6 +6635,9 @@ void Debugger::ParseDebugData() for(uint32_t i = 0; i < countInstructions; ++i) { + if(f->instructions[i]->debugLoc == ~0U) + continue; + uint32_t instructionIndex = i + info.globalInstructionOffset; DXIL::Program::LocalSourceVariable localSrcVar; @@ -6658,7 +6645,8 @@ void Debugger::ParseDebugData() localSrcVar.endInst = instructionIndex; // For each instruction - find which scope it belongs - const ScopedDebugData *scope = FindScopedDebugData(instructionIndex); + const DebugLocation &debugLoc = m_Program->m_DebugLocations[f->instructions[i]->debugLoc]; + const ScopedDebugData *scope = FindScopedDebugData(GetMDScope(debugLoc.scope)); // track which mappings we've processed, so if the same variable has mappings in multiple // scopes we only pick the innermost. rdcarray processed; @@ -7624,7 +7612,6 @@ ShaderDebugTrace *Debugger::BeginDebug(uint32_t eventId, const DXBC::DXBCContain continue; currentScope = thisScope; - thisScope->minInstruction = RDCMIN(thisScope->minInstruction, instructionIndex); thisScope->maxInstruction = instructionIndex; // Walk upwards from this scope to find where to append to the scope hierarchy { diff --git a/renderdoc/driver/shaders/dxil/dxil_debug.h b/renderdoc/driver/shaders/dxil/dxil_debug.h index d6ae5f9d5..85084b7fc 100644 --- a/renderdoc/driver/shaders/dxil/dxil_debug.h +++ b/renderdoc/driver/shaders/dxil/dxil_debug.h @@ -477,17 +477,9 @@ struct ScopedDebugData rdcstr functionName; rdcstr fileName; uint32_t line; - uint32_t minInstruction; uint32_t maxInstruction; - bool operator<(const ScopedDebugData &o) const - { - if(minInstruction != o.minInstruction) - return minInstruction < o.minInstruction; - if(maxInstruction != o.maxInstruction) - return maxInstruction < o.maxInstruction; - return line < o.line; - } + bool operator<(const ScopedDebugData &o) const { return line < o.line; } }; struct TypeData @@ -537,7 +529,6 @@ private: const DXIL::Metadata *GetMDScope(const DXIL::Metadata *scopeMD) const; ScopedDebugData *AddScopedDebugData(const DXIL::Metadata *scopeMD); ScopedDebugData *FindScopedDebugData(const DXIL::Metadata *md) const; - ScopedDebugData *FindScopedDebugData(const uint32_t instructionIndex) const; const TypeData &AddDebugType(const DXIL::Metadata *typeMD); void AddLocalVariable(const DXIL::Metadata *localVariableMD, uint32_t instructionIndex, bool isDeclare, int32_t byteOffset, uint32_t countBytes, Id debugSSAId,