summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2019-09-23 08:10:29 -0400
committerGravatar FernandoS272019-10-04 18:52:54 -0400
commit5ea740beb52ee8ccbabef81397ce9458077c6a42 (patch)
treecd892d83be0f3e39f6d83a689c0f7ce2d17953b6 /src
parentvk_shader_compiler: Don't enclose branches with if(true) to avoid crashing AMD (diff)
downloadyuzu-5ea740beb52ee8ccbabef81397ce9458077c6a42.tar.gz
yuzu-5ea740beb52ee8ccbabef81397ce9458077c6a42.tar.xz
yuzu-5ea740beb52ee8ccbabef81397ce9458077c6a42.zip
Shader_IR: Correct OutwardMoves for Ifs
Diffstat (limited to 'src')
-rw-r--r--src/video_core/shader/ast.cpp33
1 files changed, 11 insertions, 22 deletions
diff --git a/src/video_core/shader/ast.cpp b/src/video_core/shader/ast.cpp
index 7c8507280..54f0240e1 100644
--- a/src/video_core/shader/ast.cpp
+++ b/src/video_core/shader/ast.cpp
@@ -685,34 +685,23 @@ void ASTManager::MoveOutward(ASTNode goto_node) {
685 const ASTNode break_node = ASTBase::Make<ASTBreak>(parent, var_condition); 685 const ASTNode break_node = ASTBase::Make<ASTBreak>(parent, var_condition);
686 zipper.InsertAfter(break_node, var_node); 686 zipper.InsertAfter(break_node, var_node);
687 } else if (is_if || is_else) { 687 } else if (is_if || is_else) {
688 const u32 var_index = NewVariable();
689 const Expr var_condition = MakeExpr<ExprVar>(var_index);
690 const ASTNode var_node = ASTBase::Make<ASTVarSet>(parent, var_index, condition);
691 const ASTNode var_node_init = ASTBase::Make<ASTVarSet>(parent, var_index, false_condition);
692 if (is_if) {
693 zipper2.InsertBefore(var_node_init, parent);
694 } else {
695 zipper2.InsertBefore(var_node_init, parent->GetPrevious());
696 }
697 zipper.InsertAfter(var_node, prev);
698 goto_node->SetGotoCondition(var_condition);
688 if (post) { 699 if (post) {
689 const u32 var_index = NewVariable();
690 const Expr var_condition = MakeExpr<ExprVar>(var_index);
691 const ASTNode var_node = ASTBase::Make<ASTVarSet>(parent, var_index, condition);
692 const ASTNode var_node_init =
693 ASTBase::Make<ASTVarSet>(parent, var_index, false_condition);
694 if (is_if) {
695 zipper2.InsertBefore(var_node_init, parent);
696 } else {
697 zipper2.InsertBefore(var_node_init, parent->GetPrevious());
698 }
699 zipper.InsertAfter(var_node, prev);
700 goto_node->SetGotoCondition(var_condition);
701 zipper.DetachTail(post); 700 zipper.DetachTail(post);
702 const ASTNode if_node = ASTBase::Make<ASTIfThen>(parent, MakeExprNot(var_condition)); 701 const ASTNode if_node = ASTBase::Make<ASTIfThen>(parent, MakeExprNot(var_condition));
703 ASTZipper* sub_zipper = if_node->GetSubNodes(); 702 ASTZipper* sub_zipper = if_node->GetSubNodes();
704 sub_zipper->Init(post, if_node); 703 sub_zipper->Init(post, if_node);
705 zipper.InsertAfter(if_node, var_node); 704 zipper.InsertAfter(if_node, var_node);
706 } else {
707 Expr if_condition;
708 if (is_if) {
709 if_condition = parent->GetIfCondition();
710 } else {
711 ASTNode if_node = parent->GetPrevious();
712 if_condition = MakeExprNot(if_node->GetIfCondition());
713 }
714 Expr new_condition = MakeExprAnd(if_condition, condition);
715 goto_node->SetGotoCondition(new_condition);
716 } 705 }
717 } else { 706 } else {
718 UNREACHABLE(); 707 UNREACHABLE();