From 5307eeca020b88410ee2f7f39c21bba51d0739f9 Mon Sep 17 00:00:00 2001 From: Lander Gallastegi Date: Sun, 6 Apr 2025 20:56:48 +0200 Subject: [PATCH] Add break conditions to subprogram --- src/shader_recompiler/ir/subprogram.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/shader_recompiler/ir/subprogram.cpp b/src/shader_recompiler/ir/subprogram.cpp index bb944e3ef..7be3622d4 100644 --- a/src/shader_recompiler/ir/subprogram.cpp +++ b/src/shader_recompiler/ir/subprogram.cpp @@ -124,7 +124,15 @@ void SubProgram::AddPhi(Inst* orig_phi, Inst* phi) { if (cond->asl_node->type == AbstractSyntaxNode::Type::If) { AddInst(cond->asl_node->data.if_node.cond.InstRecursive()); } else if (cond->asl_node->type == AbstractSyntaxNode::Type::Loop) { - AddInst(&cond->asl_node->data.loop.continue_block->back()); + // In case of loop, we need to add the loop itself and also + // the break conditions. + Block* loop_merge = cond->asl_node->data.loop.merge; + for (Block* pred : loop_merge->ImmPredecessors()) { + if (pred->CondData().asl_node == cond->asl_node) { + ASSERT(pred->back().Type() == Inst::Type::ConditionRef); + AddInst(pred->back().InstRecursive()); + } + } } if (orig_phi->GetParent()->CondData().asl_node == cond->asl_node) { break;