summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader/ast.cpp
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-09-23 14:10:29 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-10-05 00:52:54 +0200
commit5ea740beb52ee8ccbabef81397ce9458077c6a42 (patch)
treecd892d83be0f3e39f6d83a689c0f7ce2d17953b6 /src/video_core/shader/ast.cpp
parentvk_shader_compiler: Don't enclose branches with if(true) to avoid crashing AMD (diff)
downloadyuzu-5ea740beb52ee8ccbabef81397ce9458077c6a42.tar
yuzu-5ea740beb52ee8ccbabef81397ce9458077c6a42.tar.gz
yuzu-5ea740beb52ee8ccbabef81397ce9458077c6a42.tar.bz2
yuzu-5ea740beb52ee8ccbabef81397ce9458077c6a42.tar.lz
yuzu-5ea740beb52ee8ccbabef81397ce9458077c6a42.tar.xz
yuzu-5ea740beb52ee8ccbabef81397ce9458077c6a42.tar.zst
yuzu-5ea740beb52ee8ccbabef81397ce9458077c6a42.zip
Diffstat (limited to 'src/video_core/shader/ast.cpp')
-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) {
const ASTNode break_node = ASTBase::Make<ASTBreak>(parent, var_condition);
zipper.InsertAfter(break_node, var_node);
} else if (is_if || is_else) {
+ const u32 var_index = NewVariable();
+ const Expr var_condition = MakeExpr<ExprVar>(var_index);
+ const ASTNode var_node = ASTBase::Make<ASTVarSet>(parent, var_index, condition);
+ const ASTNode var_node_init = ASTBase::Make<ASTVarSet>(parent, var_index, false_condition);
+ if (is_if) {
+ zipper2.InsertBefore(var_node_init, parent);
+ } else {
+ zipper2.InsertBefore(var_node_init, parent->GetPrevious());
+ }
+ zipper.InsertAfter(var_node, prev);
+ goto_node->SetGotoCondition(var_condition);
if (post) {
- const u32 var_index = NewVariable();
- const Expr var_condition = MakeExpr<ExprVar>(var_index);
- const ASTNode var_node = ASTBase::Make<ASTVarSet>(parent, var_index, condition);
- const ASTNode var_node_init =
- ASTBase::Make<ASTVarSet>(parent, var_index, false_condition);
- if (is_if) {
- zipper2.InsertBefore(var_node_init, parent);
- } else {
- zipper2.InsertBefore(var_node_init, parent->GetPrevious());
- }
- zipper.InsertAfter(var_node, prev);
- goto_node->SetGotoCondition(var_condition);
zipper.DetachTail(post);
const ASTNode if_node = ASTBase::Make<ASTIfThen>(parent, MakeExprNot(var_condition));
ASTZipper* sub_zipper = if_node->GetSubNodes();
sub_zipper->Init(post, if_node);
zipper.InsertAfter(if_node, var_node);
- } else {
- Expr if_condition;
- if (is_if) {
- if_condition = parent->GetIfCondition();
- } else {
- ASTNode if_node = parent->GetPrevious();
- if_condition = MakeExprNot(if_node->GetIfCondition());
- }
- Expr new_condition = MakeExprAnd(if_condition, condition);
- goto_node->SetGotoCondition(new_condition);
}
} else {
UNREACHABLE();