diff options
| -rw-r--r-- | src/video_core/shader/control_flow.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/video_core/shader/control_flow.cpp b/src/video_core/shader/control_flow.cpp index 336397cdb..4c8971615 100644 --- a/src/video_core/shader/control_flow.cpp +++ b/src/video_core/shader/control_flow.cpp | |||
| @@ -547,13 +547,13 @@ bool TryQuery(CFGRebuildState& state) { | |||
| 547 | gather_labels(q2.ssy_stack, state.ssy_labels, block); | 547 | gather_labels(q2.ssy_stack, state.ssy_labels, block); |
| 548 | gather_labels(q2.pbk_stack, state.pbk_labels, block); | 548 | gather_labels(q2.pbk_stack, state.pbk_labels, block); |
| 549 | if (std::holds_alternative<SingleBranch>(*block.branch)) { | 549 | if (std::holds_alternative<SingleBranch>(*block.branch)) { |
| 550 | const auto branch = std::get_if<SingleBranch>(block.branch.get()); | 550 | auto* branch = std::get_if<SingleBranch>(block.branch.get()); |
| 551 | if (!branch->condition.IsUnconditional()) { | 551 | if (!branch->condition.IsUnconditional()) { |
| 552 | q2.address = block.end + 1; | 552 | q2.address = block.end + 1; |
| 553 | state.queries.push_back(q2); | 553 | state.queries.push_back(q2); |
| 554 | } | 554 | } |
| 555 | 555 | ||
| 556 | Query conditional_query{q2}; | 556 | auto& conditional_query = state.queries.emplace_back(q2); |
| 557 | if (branch->is_sync) { | 557 | if (branch->is_sync) { |
| 558 | if (branch->address == unassigned_branch) { | 558 | if (branch->address == unassigned_branch) { |
| 559 | branch->address = conditional_query.ssy_stack.top(); | 559 | branch->address = conditional_query.ssy_stack.top(); |
| @@ -567,21 +567,21 @@ bool TryQuery(CFGRebuildState& state) { | |||
| 567 | conditional_query.pbk_stack.pop(); | 567 | conditional_query.pbk_stack.pop(); |
| 568 | } | 568 | } |
| 569 | conditional_query.address = branch->address; | 569 | conditional_query.address = branch->address; |
| 570 | state.queries.push_back(std::move(conditional_query)); | ||
| 571 | return true; | 570 | return true; |
| 572 | } | 571 | } |
| 573 | const auto multi_branch = std::get_if<MultiBranch>(block.branch.get()); | 572 | |
| 573 | const auto* multi_branch = std::get_if<MultiBranch>(block.branch.get()); | ||
| 574 | for (const auto& branch_case : multi_branch->branches) { | 574 | for (const auto& branch_case : multi_branch->branches) { |
| 575 | Query conditional_query{q2}; | 575 | auto& conditional_query = state.queries.emplace_back(q2); |
| 576 | conditional_query.address = branch_case.address; | 576 | conditional_query.address = branch_case.address; |
| 577 | state.queries.push_back(std::move(conditional_query)); | ||
| 578 | } | 577 | } |
| 578 | |||
| 579 | return true; | 579 | return true; |
| 580 | } | 580 | } |
| 581 | 581 | ||
| 582 | void InsertBranch(ASTManager& mm, const BlockBranchInfo& branch_info) { | 582 | void InsertBranch(ASTManager& mm, const BlockBranchInfo& branch_info) { |
| 583 | const auto get_expr = ([&](const Condition& cond) -> Expr { | 583 | const auto get_expr = [](const Condition& cond) -> Expr { |
| 584 | Expr result{}; | 584 | Expr result; |
| 585 | if (cond.cc != ConditionCode::T) { | 585 | if (cond.cc != ConditionCode::T) { |
| 586 | result = MakeExpr<ExprCondCode>(cond.cc); | 586 | result = MakeExpr<ExprCondCode>(cond.cc); |
| 587 | } | 587 | } |
| @@ -594,10 +594,10 @@ void InsertBranch(ASTManager& mm, const BlockBranchInfo& branch_info) { | |||
| 594 | } | 594 | } |
| 595 | Expr extra = MakeExpr<ExprPredicate>(pred); | 595 | Expr extra = MakeExpr<ExprPredicate>(pred); |
| 596 | if (negate) { | 596 | if (negate) { |
| 597 | extra = MakeExpr<ExprNot>(extra); | 597 | extra = MakeExpr<ExprNot>(std::move(extra)); |
| 598 | } | 598 | } |
| 599 | if (result) { | 599 | if (result) { |
| 600 | return MakeExpr<ExprAnd>(extra, result); | 600 | return MakeExpr<ExprAnd>(std::move(extra), std::move(result)); |
| 601 | } | 601 | } |
| 602 | return extra; | 602 | return extra; |
| 603 | } | 603 | } |
| @@ -605,9 +605,10 @@ void InsertBranch(ASTManager& mm, const BlockBranchInfo& branch_info) { | |||
| 605 | return result; | 605 | return result; |
| 606 | } | 606 | } |
| 607 | return MakeExpr<ExprBoolean>(true); | 607 | return MakeExpr<ExprBoolean>(true); |
| 608 | }); | 608 | }; |
| 609 | |||
| 609 | if (std::holds_alternative<SingleBranch>(*branch_info)) { | 610 | if (std::holds_alternative<SingleBranch>(*branch_info)) { |
| 610 | const auto branch = std::get_if<SingleBranch>(branch_info.get()); | 611 | const auto* branch = std::get_if<SingleBranch>(branch_info.get()); |
| 611 | if (branch->address < 0) { | 612 | if (branch->address < 0) { |
| 612 | if (branch->kill) { | 613 | if (branch->kill) { |
| 613 | mm.InsertReturn(get_expr(branch->condition), true); | 614 | mm.InsertReturn(get_expr(branch->condition), true); |
| @@ -619,7 +620,7 @@ void InsertBranch(ASTManager& mm, const BlockBranchInfo& branch_info) { | |||
| 619 | mm.InsertGoto(get_expr(branch->condition), branch->address); | 620 | mm.InsertGoto(get_expr(branch->condition), branch->address); |
| 620 | return; | 621 | return; |
| 621 | } | 622 | } |
| 622 | const auto multi_branch = std::get_if<MultiBranch>(branch_info.get()); | 623 | const auto* multi_branch = std::get_if<MultiBranch>(branch_info.get()); |
| 623 | for (const auto& branch_case : multi_branch->branches) { | 624 | for (const auto& branch_case : multi_branch->branches) { |
| 624 | mm.InsertGoto(MakeExpr<ExprGprEqual>(multi_branch->gpr, branch_case.cmp_value), | 625 | mm.InsertGoto(MakeExpr<ExprGprEqual>(multi_branch->gpr, branch_case.cmp_value), |
| 625 | branch_case.address); | 626 | branch_case.address); |