summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2018-05-25 00:28:54 +0200
committerSubv <subv2112@gmail.com>2018-05-25 00:39:59 +0200
commite2cdf541772366fea6e94ec6309a4798ce06354b (patch)
tree4795f8b2462c8adf908afe5babffbb5481c60135 /src/video_core/renderer_opengl/gl_shader_decompiler.cpp
parentShader: Implemented compound predicates in fsetp. (diff)
downloadyuzu-e2cdf541772366fea6e94ec6309a4798ce06354b.tar
yuzu-e2cdf541772366fea6e94ec6309a4798ce06354b.tar.gz
yuzu-e2cdf541772366fea6e94ec6309a4798ce06354b.tar.bz2
yuzu-e2cdf541772366fea6e94ec6309a4798ce06354b.tar.lz
yuzu-e2cdf541772366fea6e94ec6309a4798ce06354b.tar.xz
yuzu-e2cdf541772366fea6e94ec6309a4798ce06354b.tar.zst
yuzu-e2cdf541772366fea6e94ec6309a4798ce06354b.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_decompiler.cpp')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_decompiler.cpp40
1 files changed, 12 insertions, 28 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
index 434bbade6..d24b1ab44 100644
--- a/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
+++ b/src/video_core/renderer_opengl/gl_shader_decompiler.cpp
@@ -609,6 +609,7 @@ private:
{PredCondition::LessThan, "<"},
{PredCondition::Equal, "=="},
{PredCondition::LessEqual, "<="},
+ {PredCondition::GreaterThan, ">"},
};
auto comparison = PredicateComparisonStrings.find(condition);
@@ -628,7 +629,7 @@ private:
static const std::unordered_map<PredOperation, const char*> PredicateOperationStrings = {
{PredOperation::And, "&&"},
{PredOperation::Or, "||"},
- {PredOperation::Xor, "^"},
+ {PredOperation::Xor, "^^"},
};
auto op = PredicateOperationStrings.find(operation);
@@ -977,35 +978,18 @@ private:
op_b = "abs(" + op_b + ')';
}
- using Tegra::Shader::Pred;
- ASSERT_MSG(instr.fset.pred39 == static_cast<u64>(Pred::UnusedIndex),
- "Compound predicates are not implemented");
-
// The fset instruction sets a register to 1.0 if the condition is true, and to 0
// otherwise.
- using Tegra::Shader::PredCondition;
- switch (instr.fset.cond) {
- case PredCondition::LessThan:
- regs.SetRegisterToFloat(instr.gpr0, 0,
- "((" + op_a + ") < (" + op_b + ")) ? 1.0 : 0", 1, 1);
- break;
- case PredCondition::Equal:
- regs.SetRegisterToFloat(instr.gpr0, 0,
- "((" + op_a + ") == (" + op_b + ")) ? 1.0 : 0", 1, 1);
- break;
- case PredCondition::LessEqual:
- regs.SetRegisterToFloat(instr.gpr0, 0,
- "((" + op_a + ") <= (" + op_b + ")) ? 1.0 : 0", 1, 1);
- break;
- case PredCondition::GreaterThan:
- regs.SetRegisterToFloat(instr.gpr0, 0,
- "((" + op_a + ") > (" + op_b + ")) ? 1.0 : 0", 1, 1);
- break;
- default:
- NGLOG_CRITICAL(HW_GPU, "Unhandled predicate condition: {} (a: {}, b: {})",
- static_cast<unsigned>(instr.fset.cond.Value()), op_a, op_b);
- UNREACHABLE();
- }
+ std::string second_pred =
+ GetPredicateCondition(instr.fset.pred39, instr.fset.neg_pred != 0);
+
+ std::string comparator = GetPredicateComparison(instr.fset.cond);
+ std::string combiner = GetPredicateCombiner(instr.fset.op);
+
+ std::string predicate = "(((" + op_a + ") " + comparator + " (" + op_b + ")) " +
+ combiner + " (" + second_pred + "))";
+
+ regs.SetRegisterToFloat(instr.gpr0, 0, predicate + " ? 1.0 : 0.0", 1, 1);
break;
}
default: {