Skip to content

Commit

Permalink
Rationalise DXIL debugger instruction indexes
Browse files Browse the repository at this point in the history
Use m_ActiveGlobalInstructionIdx instead of m_GlobalInstructionIdx
Removed m_GlobalInstructionIdx
  • Loading branch information
Zorro666 committed Jan 8, 2025
1 parent a98d0a4 commit 4b35fbc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 13 deletions.
17 changes: 7 additions & 10 deletions renderdoc/driver/shaders/dxil/dxil_debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ ThreadState::ThreadState(uint32_t workgroupIndex, Debugger &debugger,
m_WorkgroupIndex = workgroupIndex;
m_FunctionInfo = NULL;
m_FunctionInstructionIdx = 0;
m_GlobalInstructionIdx = 0;
m_ActiveGlobalInstructionIdx = 0;
m_Killed = false;
m_Ended = false;
m_Callstack.clear();
Expand Down Expand Up @@ -1747,7 +1747,7 @@ void ThreadState::EnterFunction(const Function *function, const rdcarray<Value *
m_PreviousBlock = ~0U;
m_PhiVariables.clear();

m_GlobalInstructionIdx = m_FunctionInfo->globalInstructionOffset + m_FunctionInstructionIdx;
m_ActiveGlobalInstructionIdx = m_FunctionInfo->globalInstructionOffset + m_FunctionInstructionIdx;
m_Callstack.push_back(frame);

ShaderDebugState *state = m_State;
Expand Down Expand Up @@ -4144,14 +4144,13 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
{
m_Block = blockId;
m_FunctionInstructionIdx = m_FunctionInfo->function->blocks[m_Block]->startInstructionIdx;
m_GlobalInstructionIdx = m_FunctionInfo->globalInstructionOffset + m_FunctionInstructionIdx;
}
else
{
RDCERR("Unknown branch target %u '%s'", m_Block, GetArgumentName(targetArg).c_str());
}
if(m_State && !m_Ended)
m_State->nextInstruction = m_GlobalInstructionIdx;
m_State->nextInstruction = m_FunctionInfo->globalInstructionOffset + m_FunctionInstructionIdx;
break;
}
case Operation::Phi:
Expand Down Expand Up @@ -5228,7 +5227,6 @@ bool ThreadState::ExecuteInstruction(DebugAPIWrapper *apiWrapper,
{
m_Block = blockId;
m_FunctionInstructionIdx = m_FunctionInfo->function->blocks[m_Block]->startInstructionIdx;
m_GlobalInstructionIdx = m_FunctionInfo->globalInstructionOffset + m_FunctionInstructionIdx;
}
else
{
Expand Down Expand Up @@ -5458,12 +5456,12 @@ void ThreadState::StepOverNopInstructions()
return;
do
{
m_GlobalInstructionIdx = m_FunctionInfo->globalInstructionOffset + m_FunctionInstructionIdx;
RDCASSERT(m_FunctionInstructionIdx < m_FunctionInfo->function->instructions.size());
const Instruction *inst = m_FunctionInfo->function->instructions[m_FunctionInstructionIdx];
if(!IsNopInstruction(*inst))
{
m_ActiveGlobalInstructionIdx = m_GlobalInstructionIdx;
m_ActiveGlobalInstructionIdx =
m_FunctionInfo->globalInstructionOffset + m_FunctionInstructionIdx;
return;
}

Expand All @@ -5476,9 +5474,8 @@ void ThreadState::StepNext(ShaderDebugState *state, DebugAPIWrapper *apiWrapper,
{
m_State = state;

RDCASSERTEQUAL(m_GlobalInstructionIdx,
RDCASSERTEQUAL(m_ActiveGlobalInstructionIdx,
m_FunctionInfo->globalInstructionOffset + m_FunctionInstructionIdx);
RDCASSERTEQUAL(m_ActiveGlobalInstructionIdx, m_GlobalInstructionIdx);
if(m_State)
{
m_State->flags = ShaderEvents::NoEvent;
Expand Down Expand Up @@ -8378,7 +8375,7 @@ rdcarray<ShaderDebugState> Debugger::ContinueDebug(DebugAPIWrapper *apiWrapper)
{
thread.EnterEntryPoint(m_EntryPointFunction, &initial);
thread.FillCallstack(initial);
initial.nextInstruction = thread.m_GlobalInstructionIdx;
initial.nextInstruction = thread.m_ActiveGlobalInstructionIdx;
}
else
{
Expand Down
4 changes: 1 addition & 3 deletions renderdoc/driver/shaders/dxil/dxil_debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,7 @@ struct ThreadState
// The current and previous function basic block index
uint32_t m_Block = ~0U;
uint32_t m_PreviousBlock = ~0U;
// A global logical instruction index (bit like a PC) not the instruction index within a function
uint32_t m_GlobalInstructionIdx = ~0U;
// The PC of the active instruction that was or will be executed on the current simulation step
// The global PC of the active instruction that was or will be executed on the current simulation step
uint32_t m_ActiveGlobalInstructionIdx = ~0U;

// SSA Ids guaranteed to be greater than 0 and less than this value
Expand Down

0 comments on commit 4b35fbc

Please sign in to comment.