diff options
author | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-03-01 05:33:53 +0100 |
---|---|---|
committer | ameerj <52414509+ameerj@users.noreply.github.com> | 2021-07-23 03:51:22 +0200 |
commit | 20390c0548d6eef2af67a363ee120a630267b741 (patch) | |
tree | 0df880552f80d79c769403f04df5c364397396d1 /src/shader_recompiler/frontend/maxwell/translate/impl/integer_minimum_maximum.cpp | |
parent | shader: Implement BFI (diff) | |
download | yuzu-20390c0548d6eef2af67a363ee120a630267b741.tar yuzu-20390c0548d6eef2af67a363ee120a630267b741.tar.gz yuzu-20390c0548d6eef2af67a363ee120a630267b741.tar.bz2 yuzu-20390c0548d6eef2af67a363ee120a630267b741.tar.lz yuzu-20390c0548d6eef2af67a363ee120a630267b741.tar.xz yuzu-20390c0548d6eef2af67a363ee120a630267b741.tar.zst yuzu-20390c0548d6eef2af67a363ee120a630267b741.zip |
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell/translate/impl/integer_minimum_maximum.cpp')
-rw-r--r-- | src/shader_recompiler/frontend/maxwell/translate/impl/integer_minimum_maximum.cpp | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/integer_minimum_maximum.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/integer_minimum_maximum.cpp new file mode 100644 index 000000000..12c6aae3d --- /dev/null +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/integer_minimum_maximum.cpp @@ -0,0 +1,59 @@ +// Copyright 2021 yuzu Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#include "common/bit_field.h" +#include "common/common_types.h" +#include "shader_recompiler/frontend/maxwell/translate/impl/impl.h" + +namespace Shader::Maxwell { +namespace { +void IMNMX(TranslatorVisitor& v, u64 insn, const IR::U32& op_b) { + union { + u64 insn; + BitField<0, 8, IR::Reg> dest_reg; + BitField<8, 8, IR::Reg> src_reg; + BitField<39, 3, IR::Pred> pred; + BitField<42, 1, u64> neg_pred; + BitField<43, 2, u64> mode; + BitField<48, 1, u64> is_signed; + } const imnmx{insn}; + + if (imnmx.mode != 0) { + throw NotImplementedException("IMNMX.MODE"); + } + + IR::U1 pred = v.ir.GetPred(imnmx.pred); + const IR::U32 op_a{v.X(imnmx.src_reg)}; + IR::U32 min; + IR::U32 max; + + if (imnmx.is_signed != 0) { + min = IR::U32{v.ir.SMin(op_a, op_b)}; + max = IR::U32{v.ir.SMax(op_a, op_b)}; + } else { + min = IR::U32{v.ir.UMin(op_a, op_b)}; + max = IR::U32{v.ir.UMax(op_a, op_b)}; + } + if (imnmx.neg_pred != 0) { + std::swap(min, max); + } + + const IR::U32 result{v.ir.Select(pred, min, max)}; + v.X(imnmx.dest_reg, result); +} +} // Anonymous namespace + +void TranslatorVisitor::IMNMX_reg(u64 insn) { + IMNMX(*this, insn, GetReg20(insn)); +} + +void TranslatorVisitor::IMNMX_cbuf(u64 insn) { + IMNMX(*this, insn, GetCbuf(insn)); +} + +void TranslatorVisitor::IMNMX_imm(u64 insn) { + IMNMX(*this, insn, GetImm20(insn)); +} + +} // namespace Shader::Maxwell |