diff options
| author | 2021-03-09 17:14:57 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:23 -0400 | |
| commit | 3a63fa0477ea8297c80133d35494e1dfdc012f95 (patch) | |
| tree | 3cd8b9be6f91cb1628b0d47513b7adb88df5f7b2 /src/shader_recompiler/frontend/maxwell/translate/impl/impl.cpp | |
| parent | shader: Initial support for textures and TEX (diff) | |
| download | yuzu-3a63fa0477ea8297c80133d35494e1dfdc012f95.tar.gz yuzu-3a63fa0477ea8297c80133d35494e1dfdc012f95.tar.xz yuzu-3a63fa0477ea8297c80133d35494e1dfdc012f95.zip | |
shader: Partial implementation of LDC
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell/translate/impl/impl.cpp')
| -rw-r--r-- | src/shader_recompiler/frontend/maxwell/translate/impl/impl.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/impl.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/impl.cpp index a5a0e1a9b..7564aeeb2 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/impl.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/impl.cpp | |||
| @@ -56,25 +56,32 @@ IR::F32 TranslatorVisitor::GetFloatReg39(u64 insn) { | |||
| 56 | return ir.BitCast<IR::F32>(GetReg39(insn)); | 56 | return ir.BitCast<IR::F32>(GetReg39(insn)); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | IR::U32 TranslatorVisitor::GetCbuf(u64 insn) { | 59 | static std::pair<IR::U32, IR::U32> CbufAddr(u64 insn) { |
| 60 | union { | 60 | union { |
| 61 | u64 raw; | 61 | u64 raw; |
| 62 | BitField<20, 14, s64> offset; | 62 | BitField<20, 14, s64> offset; |
| 63 | BitField<34, 5, u64> binding; | 63 | BitField<34, 5, u64> binding; |
| 64 | } const cbuf{insn}; | 64 | } const cbuf{insn}; |
| 65 | |||
| 65 | if (cbuf.binding >= 18) { | 66 | if (cbuf.binding >= 18) { |
| 66 | throw NotImplementedException("Out of bounds constant buffer binding {}", cbuf.binding); | 67 | throw NotImplementedException("Out of bounds constant buffer binding {}", cbuf.binding); |
| 67 | } | 68 | } |
| 68 | if (cbuf.offset >= 0x10'000 || cbuf.offset < 0) { | 69 | if (cbuf.offset >= 0x10'000 || cbuf.offset < 0) { |
| 69 | throw NotImplementedException("Out of bounds constant buffer offset {}", cbuf.offset); | 70 | throw NotImplementedException("Out of bounds constant buffer offset {}", cbuf.offset); |
| 70 | } | 71 | } |
| 71 | const IR::U32 binding{ir.Imm32(static_cast<u32>(cbuf.binding))}; | 72 | const IR::Value binding{static_cast<u32>(cbuf.binding)}; |
| 72 | const IR::U32 byte_offset{ir.Imm32(static_cast<u32>(cbuf.offset) * 4)}; | 73 | const IR::Value byte_offset{static_cast<u32>(cbuf.offset) * 4}; |
| 74 | return {IR::U32{binding}, IR::U32{byte_offset}}; | ||
| 75 | } | ||
| 76 | |||
| 77 | IR::U32 TranslatorVisitor::GetCbuf(u64 insn) { | ||
| 78 | const auto[binding, byte_offset]{CbufAddr(insn)}; | ||
| 73 | return ir.GetCbuf(binding, byte_offset); | 79 | return ir.GetCbuf(binding, byte_offset); |
| 74 | } | 80 | } |
| 75 | 81 | ||
| 76 | IR::F32 TranslatorVisitor::GetFloatCbuf(u64 insn) { | 82 | IR::F32 TranslatorVisitor::GetFloatCbuf(u64 insn) { |
| 77 | return ir.BitCast<IR::F32>(GetCbuf(insn)); | 83 | const auto[binding, byte_offset]{CbufAddr(insn)}; |
| 84 | return ir.GetFloatCbuf(binding, byte_offset); | ||
| 78 | } | 85 | } |
| 79 | 86 | ||
| 80 | IR::U32 TranslatorVisitor::GetImm20(u64 insn) { | 87 | IR::U32 TranslatorVisitor::GetImm20(u64 insn) { |
| @@ -83,6 +90,7 @@ IR::U32 TranslatorVisitor::GetImm20(u64 insn) { | |||
| 83 | BitField<20, 19, u64> value; | 90 | BitField<20, 19, u64> value; |
| 84 | BitField<56, 1, u64> is_negative; | 91 | BitField<56, 1, u64> is_negative; |
| 85 | } const imm{insn}; | 92 | } const imm{insn}; |
| 93 | |||
| 86 | if (imm.is_negative != 0) { | 94 | if (imm.is_negative != 0) { |
| 87 | const s64 raw{static_cast<s64>(imm.value)}; | 95 | const s64 raw{static_cast<s64>(imm.value)}; |
| 88 | return ir.Imm32(static_cast<s32>(-(1LL << 19) + raw)); | 96 | return ir.Imm32(static_cast<s32>(-(1LL << 19) + raw)); |