From a1cf098fe347d718b047c1555e3e4f689279d012 Mon Sep 17 00:00:00 2001 From: Jake Turner Date: Thu, 10 Apr 2025 14:58:25 +0100 Subject: [PATCH] Extend Shader ControlFlow handling of external simulation updates Previously automatic activation of merge points was only considered for the merge point head. Now consider any point in the merge point list and prune above it, similar to how function return points are handled --- renderdoc/shaders/controlflow.cpp | 35 ++++++++++++++++--------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/renderdoc/shaders/controlflow.cpp b/renderdoc/shaders/controlflow.cpp index 6bcffb2aa..18d041aa3 100644 --- a/renderdoc/shaders/controlflow.cpp +++ b/renderdoc/shaders/controlflow.cpp @@ -427,6 +427,16 @@ void ControlFlow::MergeConvergedTangles() // merge tangles if they have the same merge stack if(convTangle.GetMergePoints() == tangle.GetMergePoints()) { + RDCASSERTEQUAL(tangle.GetExecutionPoint(), convTangle.GetExecutionPoint()); + if(Shader_Debug_ControlFlow_Logging()) + { + RDCLOG( + "Tangle:%u ThreadCount:%u converged with Tangle:%u ThreadCount:%u ExecPoint:%u,%u at " + "MergePoint:%u,%u", + tangle.GetId(), tangle.GetThreadCount(), convTangle.GetId(), + convTangle.GetThreadCount(), tangle.GetExecutionPoint(), + convTangle.GetExecutionPoint(), tangle.GetMergePoint(), convTangle.GetMergePoint()); + } tangle.AppendThreadReferences(convTangle.GetThreadRefs()); convTangle.ClearMergePoints(); convTangle.ClearFunctionReturnPoints(); @@ -435,14 +445,6 @@ void ControlFlow::MergeConvergedTangles() convTangle.SetConverged(false); convTangle.SetDiverged(false); convTangle.SetAlive(false); - if(Shader_Debug_ControlFlow_Logging()) - { - RDCLOG( - "Tangle:%u ThreadCount:%u converged with Tangle:%u ThreadCount:%u ExecPoint:%u at " - "MergePoint:%u", - tangle.GetId(), tangle.GetThreadCount(), convTangle.GetId(), tangle.GetThreadCount(), - tangle.GetExecutionPoint(), tangle.GetMergePoint()); - } } } } @@ -508,13 +510,13 @@ void ControlFlow::UpdateState(const ThreadExecutionStates &threadExecutionStates if(!tangle.IsAlive()) continue; - const ExecutionPoint mergePoint = tangle.GetMergePoint(); - bool atMergePoint = - (tangle.GetExecutionPoint() == mergePoint) && (mergePoint != INVALID_EXECUTION_POINT); const ExecutionPoint functionReturnPoint = tangle.GetFunctionReturnPoint(); + bool atMergePoint = tangle.m_MergePoints.contains(tangle.GetExecutionPoint()); bool atFunctionReturnPoint = (tangle.GetExecutionPoint() == functionReturnPoint) && (functionReturnPoint != INVALID_EXECUTION_POINT); bool threadExecuted = false; + const ExecutionPoint mergePoint = + atMergePoint ? tangle.GetExecutionPoint() : tangle.GetMergePoint(); for(const ThreadReference &threadRef : tangle.GetThreadRefs()) { @@ -541,21 +543,20 @@ void ControlFlow::UpdateState(const ThreadExecutionStates &threadExecutionStates RDCASSERTEQUAL(tangle.GetExecutionPoint(), tangle.GetFunctionReturnPoint()); RDCASSERTNOTEQUAL(tangle.GetFunctionReturnPoint(), INVALID_EXECUTION_POINT); tangle.PruneMergePoints(tangle.GetFunctionReturnPoint()); - tangle.PopFunctionReturnPoint(); - tangle.SetStateChanged(true); if(Shader_Debug_ControlFlow_Logging()) { RDCLOG( - "Tangle:%u ThreadCount:% at ExecPoint:%u auto-activated FunctionReturnPoint:%u " + "Tangle:%u ThreadCount:%u at ExecPoint:%u auto-activated FunctionReturnPoint:%u " "Next MergePoint:%u", tangle.GetId(), tangle.GetThreadCount(), tangle.GetExecutionPoint(), - tangle.GetFunctionReturnPoint()); + tangle.GetFunctionReturnPoint(), tangle.GetMergePoint()); } + tangle.PopFunctionReturnPoint(); + tangle.SetStateChanged(true); } else if(atMergePoint) { - RDCASSERTEQUAL(tangle.GetExecutionPoint(), tangle.GetMergePoint()); - RDCASSERTNOTEQUAL(tangle.GetMergePoint(), INVALID_EXECUTION_POINT); + tangle.PruneMergePoints(tangle.GetExecutionPoint()); tangle.SetActive(false); tangle.SetConverged(true); tangle.SetDiverged(false);