diff options
| author | 2021-02-24 05:21:30 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:22 -0400 | |
| commit | e87a502da2d5a8356a639d53c0a16a77890de4c7 (patch) | |
| tree | 00fd1a9a32c0334c49189098829b782a37533c46 /src/shader_recompiler/frontend/ir/ir_emitter.cpp | |
| parent | shader: Implement more of XMAD and FFMA32I and fix XMAD.CBCC (diff) | |
| download | yuzu-e87a502da2d5a8356a639d53c0a16a77890de4c7.tar.gz yuzu-e87a502da2d5a8356a639d53c0a16a77890de4c7.tar.xz yuzu-e87a502da2d5a8356a639d53c0a16a77890de4c7.zip | |
shader: Fix control flow
Diffstat (limited to 'src/shader_recompiler/frontend/ir/ir_emitter.cpp')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/ir_emitter.cpp | 27 |
1 files changed, 18 insertions, 9 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp index 8ba86e614..0209d5540 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp +++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp | |||
| @@ -134,18 +134,27 @@ void IREmitter::SetOFlag(const U1& value) { | |||
| 134 | Inst(Opcode::SetOFlag, value); | 134 | Inst(Opcode::SetOFlag, value); |
| 135 | } | 135 | } |
| 136 | 136 | ||
| 137 | U1 IREmitter::Condition(IR::Condition cond) { | 137 | static U1 GetFlowTest(IREmitter& ir, FlowTest flow_test) { |
| 138 | if (cond == IR::Condition{true}) { | 138 | switch (flow_test) { |
| 139 | return Imm1(true); | 139 | case FlowTest::T: |
| 140 | } else if (cond == IR::Condition{false}) { | 140 | return ir.Imm1(true); |
| 141 | return Imm1(false); | 141 | case FlowTest::F: |
| 142 | return ir.Imm1(false); | ||
| 143 | case FlowTest::EQ: | ||
| 144 | // TODO: Test this | ||
| 145 | return ir.GetZFlag(); | ||
| 146 | case FlowTest::NE: | ||
| 147 | // TODO: Test this | ||
| 148 | return ir.LogicalNot(ir.GetZFlag()); | ||
| 149 | default: | ||
| 150 | throw NotImplementedException("Flow test {}", flow_test); | ||
| 142 | } | 151 | } |
| 152 | } | ||
| 153 | |||
| 154 | U1 IREmitter::Condition(IR::Condition cond) { | ||
| 143 | const FlowTest flow_test{cond.FlowTest()}; | 155 | const FlowTest flow_test{cond.FlowTest()}; |
| 144 | const auto [pred, is_negated]{cond.Pred()}; | 156 | const auto [pred, is_negated]{cond.Pred()}; |
| 145 | if (flow_test == FlowTest::T) { | 157 | return LogicalAnd(GetPred(pred, is_negated), GetFlowTest(*this, flow_test)); |
| 146 | return GetPred(pred, is_negated); | ||
| 147 | } | ||
| 148 | throw NotImplementedException("Condition {}", cond); | ||
| 149 | } | 158 | } |
| 150 | 159 | ||
| 151 | F32 IREmitter::GetAttribute(IR::Attribute attribute) { | 160 | F32 IREmitter::GetAttribute(IR::Attribute attribute) { |