mirror of
https://github.com/yuzu-mirror/yuzu.git
synced 2024-11-08 09:19:59 +00:00
Merge pull request #3317 from ReinUsesLisp/gl-decomp-cc-decomp
gl_shader_decompiler: Fix decompilation of condition codes
This commit is contained in:
commit
51c8aea979
1 changed files with 5 additions and 27 deletions
|
@ -2325,7 +2325,7 @@ public:
|
||||||
explicit ExprDecompiler(GLSLDecompiler& decomp) : decomp{decomp} {}
|
explicit ExprDecompiler(GLSLDecompiler& decomp) : decomp{decomp} {}
|
||||||
|
|
||||||
void operator()(const ExprAnd& expr) {
|
void operator()(const ExprAnd& expr) {
|
||||||
inner += "( ";
|
inner += '(';
|
||||||
std::visit(*this, *expr.operand1);
|
std::visit(*this, *expr.operand1);
|
||||||
inner += " && ";
|
inner += " && ";
|
||||||
std::visit(*this, *expr.operand2);
|
std::visit(*this, *expr.operand2);
|
||||||
|
@ -2333,7 +2333,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const ExprOr& expr) {
|
void operator()(const ExprOr& expr) {
|
||||||
inner += "( ";
|
inner += '(';
|
||||||
std::visit(*this, *expr.operand1);
|
std::visit(*this, *expr.operand1);
|
||||||
inner += " || ";
|
inner += " || ";
|
||||||
std::visit(*this, *expr.operand2);
|
std::visit(*this, *expr.operand2);
|
||||||
|
@ -2351,28 +2351,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const ExprCondCode& expr) {
|
void operator()(const ExprCondCode& expr) {
|
||||||
const Node cc = decomp.ir.GetConditionCode(expr.cc);
|
inner += decomp.Visit(decomp.ir.GetConditionCode(expr.cc)).AsBool();
|
||||||
std::string target;
|
|
||||||
|
|
||||||
if (const auto pred = std::get_if<PredicateNode>(&*cc)) {
|
|
||||||
const auto index = pred->GetIndex();
|
|
||||||
switch (index) {
|
|
||||||
case Tegra::Shader::Pred::NeverExecute:
|
|
||||||
target = "false";
|
|
||||||
break;
|
|
||||||
case Tegra::Shader::Pred::UnusedIndex:
|
|
||||||
target = "true";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
target = decomp.GetPredicate(index);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else if (const auto flag = std::get_if<InternalFlagNode>(&*cc)) {
|
|
||||||
target = decomp.GetInternalFlag(flag->GetFlag());
|
|
||||||
} else {
|
|
||||||
UNREACHABLE();
|
|
||||||
}
|
|
||||||
inner += target;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const ExprVar& expr) {
|
void operator()(const ExprVar& expr) {
|
||||||
|
@ -2384,8 +2363,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(VideoCommon::Shader::ExprGprEqual& expr) {
|
void operator()(VideoCommon::Shader::ExprGprEqual& expr) {
|
||||||
inner +=
|
inner += fmt::format("(ftou({}) == {})", decomp.GetRegister(expr.gpr), expr.value);
|
||||||
"( ftou(" + decomp.GetRegister(expr.gpr) + ") == " + std::to_string(expr.value) + ')';
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::string& GetResult() const {
|
const std::string& GetResult() const {
|
||||||
|
@ -2393,8 +2371,8 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::string inner;
|
|
||||||
GLSLDecompiler& decomp;
|
GLSLDecompiler& decomp;
|
||||||
|
std::string inner;
|
||||||
};
|
};
|
||||||
|
|
||||||
class ASTDecompiler {
|
class ASTDecompiler {
|
||||||
|
|
Loading…
Reference in a new issue