diff options
3 files changed, 57 insertions, 16 deletions
diff --git a/src/shader_recompiler/CMakeLists.txt b/src/shader_recompiler/CMakeLists.txt index 8be2d353f..2e5de7f95 100644 --- a/src/shader_recompiler/CMakeLists.txt +++ b/src/shader_recompiler/CMakeLists.txt | |||
| @@ -60,6 +60,7 @@ add_library(shader_recompiler STATIC | |||
| 60 | frontend/maxwell/program.cpp | 60 | frontend/maxwell/program.cpp |
| 61 | frontend/maxwell/program.h | 61 | frontend/maxwell/program.h |
| 62 | frontend/maxwell/translate/impl/bitfield_extract.cpp | 62 | frontend/maxwell/translate/impl/bitfield_extract.cpp |
| 63 | frontend/maxwell/translate/impl/bitfield_insert.cpp | ||
| 63 | frontend/maxwell/translate/impl/common_encoding.h | 64 | frontend/maxwell/translate/impl/common_encoding.h |
| 64 | frontend/maxwell/translate/impl/floating_point_add.cpp | 65 | frontend/maxwell/translate/impl/floating_point_add.cpp |
| 65 | frontend/maxwell/translate/impl/floating_point_conversion_integer.cpp | 66 | frontend/maxwell/translate/impl/floating_point_conversion_integer.cpp |
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/bitfield_insert.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/bitfield_insert.cpp new file mode 100644 index 000000000..ee312c30d --- /dev/null +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/bitfield_insert.cpp | |||
| @@ -0,0 +1,56 @@ | |||
| 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/impl.h" | ||
| 8 | |||
| 9 | namespace Shader::Maxwell { | ||
| 10 | namespace { | ||
| 11 | void BFI(TranslatorVisitor& v, u64 insn, const IR::U32& src_a, const IR::U32& base) { | ||
| 12 | union { | ||
| 13 | u64 insn; | ||
| 14 | BitField<0, 8, IR::Reg> dest_reg; | ||
| 15 | BitField<8, 8, IR::Reg> insert_reg; | ||
| 16 | } const bfi{insn}; | ||
| 17 | |||
| 18 | const IR::U32 offset{v.ir.BitFieldExtract(src_a, v.ir.Imm32(0), v.ir.Imm32(8), false)}; | ||
| 19 | const IR::U32 unsafe_count{v.ir.BitFieldExtract(src_a, v.ir.Imm32(8), v.ir.Imm32(8), false)}; | ||
| 20 | const IR::U32 max_size{v.ir.Imm32(32)}; | ||
| 21 | |||
| 22 | // Edge case conditions | ||
| 23 | const IR::U1 zero_offset{v.ir.IEqual(offset, v.ir.Imm32(0))}; | ||
| 24 | const IR::U1 exceed_offset{v.ir.IGreaterThanEqual(offset, max_size, false)}; | ||
| 25 | const IR::U1 exceed_count{v.ir.IGreaterThanEqual(unsafe_count, max_size, false)}; | ||
| 26 | |||
| 27 | const IR::U32 remaining_size{v.ir.ISub(max_size, offset)}; | ||
| 28 | const IR::U32 safe_count{v.ir.Select(exceed_count, remaining_size, unsafe_count)}; | ||
| 29 | |||
| 30 | const IR::U32 insert{v.X(bfi.insert_reg)}; | ||
| 31 | IR::U32 result{v.ir.BitFieldInsert(base, insert, offset, safe_count)}; | ||
| 32 | |||
| 33 | result = IR::U32{v.ir.Select(exceed_offset, base, result)}; | ||
| 34 | result = IR::U32{v.ir.Select(zero_offset, base, result)}; | ||
| 35 | |||
| 36 | v.X(bfi.dest_reg, result); | ||
| 37 | } | ||
| 38 | } // Anonymous namespace | ||
| 39 | |||
| 40 | void TranslatorVisitor::BFI_reg(u64 insn) { | ||
| 41 | BFI(*this, insn, GetReg20(insn), GetReg39(insn)); | ||
| 42 | } | ||
| 43 | |||
| 44 | void TranslatorVisitor::BFI_rc(u64 insn) { | ||
| 45 | BFI(*this, insn, GetReg39(insn), GetCbuf(insn)); | ||
| 46 | } | ||
| 47 | |||
| 48 | void TranslatorVisitor::BFI_cr(u64 insn) { | ||
| 49 | BFI(*this, insn, GetCbuf(insn), GetReg39(insn)); | ||
| 50 | } | ||
| 51 | |||
| 52 | void TranslatorVisitor::BFI_imm(u64 insn) { | ||
| 53 | BFI(*this, insn, GetImm20(insn), GetReg39(insn)); | ||
| 54 | } | ||
| 55 | |||
| 56 | } // 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 3714f5f4f..ed2cfac60 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp | |||
| @@ -49,22 +49,6 @@ void TranslatorVisitor::BAR(u64) { | |||
| 49 | ThrowNotImplemented(Opcode::BAR); | 49 | ThrowNotImplemented(Opcode::BAR); |
| 50 | } | 50 | } |
| 51 | 51 | ||
| 52 | void TranslatorVisitor::BFI_reg(u64) { | ||
| 53 | ThrowNotImplemented(Opcode::BFI_reg); | ||
| 54 | } | ||
| 55 | |||
| 56 | void TranslatorVisitor::BFI_rc(u64) { | ||
| 57 | ThrowNotImplemented(Opcode::BFI_rc); | ||
| 58 | } | ||
| 59 | |||
| 60 | void TranslatorVisitor::BFI_cr(u64) { | ||
| 61 | ThrowNotImplemented(Opcode::BFI_cr); | ||
| 62 | } | ||
| 63 | |||
| 64 | void TranslatorVisitor::BFI_imm(u64) { | ||
| 65 | ThrowNotImplemented(Opcode::BFI_imm); | ||
| 66 | } | ||
| 67 | |||
| 68 | void TranslatorVisitor::BPT(u64) { | 52 | void TranslatorVisitor::BPT(u64) { |
| 69 | ThrowNotImplemented(Opcode::BPT); | 53 | ThrowNotImplemented(Opcode::BPT); |
| 70 | } | 54 | } |