summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar ReinUsesLisp2020-01-17 19:06:27 -0300
committerGravatar ReinUsesLisp2020-01-17 21:23:01 -0300
commitf34e519da3025d8203e2206ba931de57115fbc1e (patch)
tree18cae62c59e21f698488492e1279be299486f4c5
parentMerge pull request #3311 from ReinUsesLisp/z32fx24s8 (diff)
downloadyuzu-f34e519da3025d8203e2206ba931de57115fbc1e.tar.gz
yuzu-f34e519da3025d8203e2206ba931de57115fbc1e.tar.xz
yuzu-f34e519da3025d8203e2206ba931de57115fbc1e.zip
gl_shader_decompiler: Fix decompilation of condition codes
Use Visit instead of reimplementing it. Fixes unimplemented negations for condition codes.
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp32
1 files changed, 5 insertions, 27 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index f9f7a97b5..e9ceca768 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -2313,7 +2313,7 @@ public:
2313 explicit ExprDecompiler(GLSLDecompiler& decomp) : decomp{decomp} {} 2313 explicit ExprDecompiler(GLSLDecompiler& decomp) : decomp{decomp} {}
2314 2314
2315 void operator()(const ExprAnd& expr) { 2315 void operator()(const ExprAnd& expr) {
2316 inner += "( "; 2316 inner += '(';
2317 std::visit(*this, *expr.operand1); 2317 std::visit(*this, *expr.operand1);
2318 inner += " && "; 2318 inner += " && ";
2319 std::visit(*this, *expr.operand2); 2319 std::visit(*this, *expr.operand2);
@@ -2321,7 +2321,7 @@ public:
2321 } 2321 }
2322 2322
2323 void operator()(const ExprOr& expr) { 2323 void operator()(const ExprOr& expr) {
2324 inner += "( "; 2324 inner += '(';
2325 std::visit(*this, *expr.operand1); 2325 std::visit(*this, *expr.operand1);
2326 inner += " || "; 2326 inner += " || ";
2327 std::visit(*this, *expr.operand2); 2327 std::visit(*this, *expr.operand2);
@@ -2339,28 +2339,7 @@ public:
2339 } 2339 }
2340 2340
2341 void operator()(const ExprCondCode& expr) { 2341 void operator()(const ExprCondCode& expr) {
2342 const Node cc = decomp.ir.GetConditionCode(expr.cc); 2342 inner += decomp.Visit(decomp.ir.GetConditionCode(expr.cc)).AsBool();
2343 std::string target;
2344
2345 if (const auto pred = std::get_if<PredicateNode>(&*cc)) {
2346 const auto index = pred->GetIndex();
2347 switch (index) {
2348 case Tegra::Shader::Pred::NeverExecute:
2349 target = "false";
2350 break;
2351 case Tegra::Shader::Pred::UnusedIndex:
2352 target = "true";
2353 break;
2354 default:
2355 target = decomp.GetPredicate(index);
2356 break;
2357 }
2358 } else if (const auto flag = std::get_if<InternalFlagNode>(&*cc)) {
2359 target = decomp.GetInternalFlag(flag->GetFlag());
2360 } else {
2361 UNREACHABLE();
2362 }
2363 inner += target;
2364 } 2343 }
2365 2344
2366 void operator()(const ExprVar& expr) { 2345 void operator()(const ExprVar& expr) {
@@ -2372,8 +2351,7 @@ public:
2372 } 2351 }
2373 2352
2374 void operator()(VideoCommon::Shader::ExprGprEqual& expr) { 2353 void operator()(VideoCommon::Shader::ExprGprEqual& expr) {
2375 inner += 2354 inner += fmt::format("(ftou({}) == {})", decomp.GetRegister(expr.gpr), expr.value);
2376 "( ftou(" + decomp.GetRegister(expr.gpr) + ") == " + std::to_string(expr.value) + ')';
2377 } 2355 }
2378 2356
2379 const std::string& GetResult() const { 2357 const std::string& GetResult() const {
@@ -2381,8 +2359,8 @@ public:
2381 } 2359 }
2382 2360
2383private: 2361private:
2384 std::string inner;
2385 GLSLDecompiler& decomp; 2362 GLSLDecompiler& decomp;
2363 std::string inner;
2386}; 2364};
2387 2365
2388class ASTDecompiler { 2366class ASTDecompiler {