summaryrefslogtreecommitdiffstats
path: root/src/video_core/shader/ast.h
diff options
context:
space:
mode:
authorFernando Sahmkow <fsahmkow27@gmail.com>2019-08-16 22:25:02 +0200
committerFernandoS27 <fsahmkow27@gmail.com>2019-10-05 00:52:50 +0200
commit47e4f6a52c5eb34916e2c1f4c876e6e8624e3840 (patch)
tree60ca95508197ceb868b004791caf81a042b22842 /src/video_core/shader/ast.h
parentgl_shader_decompiler: Implement AST decompiling (diff)
downloadyuzu-47e4f6a52c5eb34916e2c1f4c876e6e8624e3840.tar
yuzu-47e4f6a52c5eb34916e2c1f4c876e6e8624e3840.tar.gz
yuzu-47e4f6a52c5eb34916e2c1f4c876e6e8624e3840.tar.bz2
yuzu-47e4f6a52c5eb34916e2c1f4c876e6e8624e3840.tar.lz
yuzu-47e4f6a52c5eb34916e2c1f4c876e6e8624e3840.tar.xz
yuzu-47e4f6a52c5eb34916e2c1f4c876e6e8624e3840.tar.zst
yuzu-47e4f6a52c5eb34916e2c1f4c876e6e8624e3840.zip
Diffstat (limited to '')
-rw-r--r--src/video_core/shader/ast.h20
1 files changed, 18 insertions, 2 deletions
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<u32, u32> labels_map{};
u32 labels_count{};
std::vector<ASTNode> labels{};