gl_shader_decompiler: Implement AST decompiling

This commit is contained in:
Fernando Sahmkow 2019-06-29 01:44:07 -04:00 committed by FernandoS27
parent 6fdd501113
commit 38fc995f6c
11 changed files with 358 additions and 63 deletions

View file

@ -141,8 +141,6 @@ public:
Expr condition;
};
using TransformCallback = std::function<NodeBlock(u32 start, u32 end)>;
class ASTBase {
public:
explicit ASTBase(ASTNode parent, ASTData data) : parent{parent}, data{data} {}
@ -233,11 +231,7 @@ public:
return std::holds_alternative<ASTBlockEncoded>(data);
}
void TransformBlockEncoded(TransformCallback& callback) {
auto block = std::get_if<ASTBlockEncoded>(&data);
const u32 start = block->start;
const u32 end = block->end;
NodeBlock nodes = callback(start, end);
void TransformBlockEncoded(NodeBlock& nodes) {
data = ASTBlockDecoded(nodes);
}
@ -309,16 +303,20 @@ public:
void SanityCheck();
bool IsFullyDecompiled() {
bool IsFullyDecompiled() const {
return gotos.size() == 0;
}
ASTNode GetProgram() {
ASTNode GetProgram() const {
return main_node;
}
void Clear();
u32 GetVariables() const {
return variables;
}
private:
bool IndirectlyRelated(ASTNode first, ASTNode second);
@ -343,7 +341,7 @@ private:
u32 variables{};
ASTProgram* program{};
ASTNode main_node{};
Expr true_condition{};
Expr false_condition{};
};
} // namespace VideoCommon::Shader