From 47e4f6a52c5eb34916e2c1f4c876e6e8624e3840 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Fri, 16 Aug 2019 16:25:02 -0400 Subject: Shader_Ir: Refactor Decompilation process and allow multiple decompilation modes. --- src/video_core/shader/ast.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'src/video_core/shader/ast.h') diff --git a/src/video_core/shader/ast.h b/src/video_core/shader/ast.h index 06ab20cc5..849d0612c 100644 --- a/src/video_core/shader/ast.h +++ b/src/video_core/shader/ast.h @@ -274,7 +274,7 @@ private: class ASTManager final { public: - ASTManager(); + ASTManager(bool full_decompile); ~ASTManager(); ASTManager(const ASTManager& o) = delete; @@ -304,7 +304,18 @@ public: void SanityCheck(); bool IsFullyDecompiled() const { - return gotos.size() == 0; + if (full_decompile) { + return gotos.size() == 0; + } else { + for (ASTNode goto_node : gotos) { + u32 label_index = goto_node->GetGotoLabel(); + ASTNode glabel = labels[label_index]; + if (IsBackwardsJump(goto_node, glabel)) { + return false; + } + } + return true; + } } ASTNode GetProgram() const { @@ -318,6 +329,10 @@ public: } private: + bool IsBackwardsJump(ASTNode goto_node, ASTNode label_node) const; + + ASTNode CommonParent(ASTNode first, ASTNode second); + bool IndirectlyRelated(ASTNode first, ASTNode second); bool DirectlyRelated(ASTNode first, ASTNode second); @@ -334,6 +349,7 @@ private: return new_var; } + bool full_decompile{}; std::unordered_map labels_map{}; u32 labels_count{}; std::vector labels{}; -- cgit v1.2.3