From 18decf78b2d16bfa6a417fae3b6add552a9559a3 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 5 May 2020 18:59:49 +0100 Subject: [PATCH] Treat entry point variables consistently with other functions --- .../driver/shaders/spirv/spirv_debug.cpp | 9 +++++ renderdoc/driver/shaders/spirv/spirv_debug.h | 3 +- .../shaders/spirv/spirv_debug_setup.cpp | 33 +++++++++++-------- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/renderdoc/driver/shaders/spirv/spirv_debug.cpp b/renderdoc/driver/shaders/spirv/spirv_debug.cpp index 4cf1fc213..4778b59d2 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_debug.cpp @@ -474,6 +474,15 @@ void ThreadState::SkipIgnoredInstructions() } } +void ThreadState::EnterEntryPoint(ShaderDebugState *state) +{ + m_State = state; + + EnterFunction({}); + + m_State = NULL; +} + void ThreadState::StepNext(ShaderDebugState *state, const rdcarray &workgroup) { m_State = state; diff --git a/renderdoc/driver/shaders/spirv/spirv_debug.h b/renderdoc/driver/shaders/spirv/spirv_debug.h index 66620ef0c..07a9185b6 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug.h +++ b/renderdoc/driver/shaders/spirv/spirv_debug.h @@ -176,7 +176,7 @@ struct ThreadState ThreadState(uint32_t workgroupIdx, Debugger &debug, const GlobalState &globalState); ~ThreadState(); - void EnterFunction(const rdcarray &arguments); + void EnterEntryPoint(ShaderDebugState *state); void StepNext(ShaderDebugState *state, const rdcarray &workgroup); enum DerivDir @@ -238,6 +238,7 @@ struct ThreadState void WritePointerValue(Id pointer, const ShaderVariable &val); private: + void EnterFunction(const rdcarray &arguments); void SetDst(Id id, const ShaderVariable &val); void ProcessScopeChange(const rdcarray &oldLive, const rdcarray &newLive); void JumpToLabel(Id target); diff --git a/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp index 8b90409c6..835ad850d 100644 --- a/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp +++ b/renderdoc/driver/shaders/spirv/spirv_debug_setup.cpp @@ -1020,24 +1020,31 @@ rdcarray Debugger::ContinueDebug() // initialise the first ShaderDebugState if we haven't stepped yet if(steps == 0) { - // we should be sitting at the entry point function prologue, step forward into the first block - // and past any function-local variable declarations - for(ThreadState &thread : workgroup) - thread.EnterFunction({}); - ShaderDebugState initial; - initial.nextInstruction = active.nextInstruction; + // we should be sitting at the entry point function prologue, step forward into the first block + // and past any function-local variable declarations + for(size_t lane = 0; lane < workgroup.size(); lane++) + { + ThreadState &thread = workgroup[lane]; - for(const Id &v : active.live) + if(lane == activeLaneIndex) + { + thread.EnterEntryPoint(&initial); + thread.FillCallstack(initial); + initial.nextInstruction = thread.nextInstruction; + initial.sourceVars = thread.sourceVars; + } + else + { + thread.EnterEntryPoint(NULL); + } + } + + // globals won't be filled out by entering the entry point, ensure their change is registered. + for(const Id &v : liveGlobals) initial.changes.push_back({ShaderVariable(), GetPointerValue(active.ids[v])}); - initial.sourceVars = active.sourceVars; - - initial.stepIndex = steps; - - active.FillCallstack(initial); - ret.push_back(initial); steps++;