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
This commit is contained in:
Jake Turner
2025-04-10 14:58:25 +01:00
parent e53b6d3bf4
commit a1cf098fe3
+18 -17
View File
@@ -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);