diff options
| author | 2021-03-17 00:53:53 -0400 | |
|---|---|---|
| committer | 2021-07-22 21:51:23 -0400 | |
| commit | 3b7fd3ad0fcb0419c455c16127f43d01b6dc7fc9 (patch) | |
| tree | 194884a206ae5c4719fa4ddeeca1c3aa45acec36 /src/shader_recompiler/frontend/maxwell/translate/impl | |
| parent | shader: Reorder phi nodes when redefined as undefined opcodes (diff) | |
| download | yuzu-3b7fd3ad0fcb0419c455c16127f43d01b6dc7fc9.tar.gz yuzu-3b7fd3ad0fcb0419c455c16127f43d01b6dc7fc9.tar.xz yuzu-3b7fd3ad0fcb0419c455c16127f43d01b6dc7fc9.zip | |
shader: Implement CSET and CSETP
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell/translate/impl')
| -rw-r--r-- | src/shader_recompiler/frontend/maxwell/translate/impl/condition_code_set.cpp | 54 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp | 8 |
2 files changed, 54 insertions, 8 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/condition_code_set.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/condition_code_set.cpp new file mode 100644 index 000000000..ea0c40a54 --- /dev/null +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/condition_code_set.cpp | |||
| @@ -0,0 +1,54 @@ | |||
| 1 | // Copyright 2021 yuzu Emulator Project | ||
| 2 | // Licensed under GPLv2 or any later version | ||
| 3 | // Refer to the license.txt file included. | ||
| 4 | |||
| 5 | #include "common/bit_field.h" | ||
| 6 | #include "common/common_types.h" | ||
| 7 | #include "shader_recompiler/frontend/maxwell/translate/impl/common_funcs.h" | ||
| 8 | #include "shader_recompiler/frontend/maxwell/translate/impl/impl.h" | ||
| 9 | |||
| 10 | namespace Shader::Maxwell { | ||
| 11 | |||
| 12 | void TranslatorVisitor::CSET(u64 insn) { | ||
| 13 | union { | ||
| 14 | u64 raw; | ||
| 15 | BitField<0, 8, IR::Reg> dest_reg; | ||
| 16 | BitField<8, 5, IR::FlowTest> cc_test; | ||
| 17 | BitField<39, 3, IR::Pred> bop_pred; | ||
| 18 | BitField<42, 1, u64> neg_bop_pred; | ||
| 19 | BitField<44, 1, u64> bf; | ||
| 20 | BitField<45, 2, BooleanOp> bop; | ||
| 21 | } const cset{insn}; | ||
| 22 | |||
| 23 | const IR::U32 one_mask{ir.Imm32(-1)}; | ||
| 24 | const IR::U32 fp_one{ir.Imm32(0x3f800000)}; | ||
| 25 | const IR::U32 fail_result{ir.Imm32(0)}; | ||
| 26 | const IR::U32 pass_result{cset.bf == 0 ? one_mask : fp_one}; | ||
| 27 | const IR::U1 cc_test_result{ir.GetFlowTestResult(cset.cc_test)}; | ||
| 28 | const IR::U1 bop_pred{ir.GetPred(cset.bop_pred, cset.neg_bop_pred != 0)}; | ||
| 29 | const IR::U1 pred_result{PredicateCombine(ir, cc_test_result, bop_pred, cset.bop)}; | ||
| 30 | const IR::U32 result{ir.Select(pred_result, pass_result, fail_result)}; | ||
| 31 | X(cset.dest_reg, result); | ||
| 32 | } | ||
| 33 | |||
| 34 | void TranslatorVisitor::CSETP(u64 insn) { | ||
| 35 | union { | ||
| 36 | u64 raw; | ||
| 37 | BitField<0, 3, IR::Pred> dest_pred_b; | ||
| 38 | BitField<3, 3, IR::Pred> dest_pred_a; | ||
| 39 | BitField<8, 5, IR::FlowTest> cc_test; | ||
| 40 | BitField<39, 3, IR::Pred> bop_pred; | ||
| 41 | BitField<42, 1, u64> neg_bop_pred; | ||
| 42 | BitField<45, 2, BooleanOp> bop; | ||
| 43 | } const csetp{insn}; | ||
| 44 | |||
| 45 | const BooleanOp bop{csetp.bop}; | ||
| 46 | const IR::U1 bop_pred{ir.GetPred(csetp.bop_pred, csetp.neg_bop_pred != 0)}; | ||
| 47 | const IR::U1 cc_test_result{ir.GetFlowTestResult(csetp.cc_test)}; | ||
| 48 | const IR::U1 result_a{PredicateCombine(ir, cc_test_result, bop_pred, bop)}; | ||
| 49 | const IR::U1 result_b{PredicateCombine(ir, ir.LogicalNot(cc_test_result), bop_pred, bop)}; | ||
| 50 | ir.SetPred(csetp.dest_pred_a, result_a); | ||
| 51 | ir.SetPred(csetp.dest_pred_b, result_b); | ||
| 52 | } | ||
| 53 | |||
| 54 | } // namespace Shader::Maxwell | ||
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp index b31928370..0325f14ea 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp | |||
| @@ -85,14 +85,6 @@ void TranslatorVisitor::CS2R(u64) { | |||
| 85 | ThrowNotImplemented(Opcode::CS2R); | 85 | ThrowNotImplemented(Opcode::CS2R); |
| 86 | } | 86 | } |
| 87 | 87 | ||
| 88 | void TranslatorVisitor::CSET(u64) { | ||
| 89 | ThrowNotImplemented(Opcode::CSET); | ||
| 90 | } | ||
| 91 | |||
| 92 | void TranslatorVisitor::CSETP(u64) { | ||
| 93 | ThrowNotImplemented(Opcode::CSETP); | ||
| 94 | } | ||
| 95 | |||
| 96 | void TranslatorVisitor::DADD_reg(u64) { | 88 | void TranslatorVisitor::DADD_reg(u64) { |
| 97 | ThrowNotImplemented(Opcode::DADD_reg); | 89 | ThrowNotImplemented(Opcode::DADD_reg); |
| 98 | } | 90 | } |