summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/maxwell
diff options
context:
space:
mode:
authorGravatar ameerj2021-03-28 22:23:45 -0400
committerGravatar ameerj2021-07-22 21:51:25 -0400
commit6c51f496320f698e123207c09ca61e55180a31b5 (patch)
treec5ecbbce29797fd7ba3138e11f9c364899375e2b /src/shader_recompiler/frontend/maxwell
parentshader: Implement BRX (diff)
downloadyuzu-6c51f496320f698e123207c09ca61e55180a31b5.tar.gz
yuzu-6c51f496320f698e123207c09ca61e55180a31b5.tar.xz
yuzu-6c51f496320f698e123207c09ca61e55180a31b5.zip
shader: Implement FSWZADD
Diffstat (limited to 'src/shader_recompiler/frontend/maxwell')
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/floating_point_swizzled_add.cpp44
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/impl.cpp4
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/impl.h1
-rw-r--r--src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp4
4 files changed, 49 insertions, 4 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/floating_point_swizzled_add.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/floating_point_swizzled_add.cpp
new file mode 100644
index 000000000..e42921a21
--- /dev/null
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/floating_point_swizzled_add.cpp
@@ -0,0 +1,44 @@
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/common_types.h"
6#include "shader_recompiler/exception.h"
7#include "shader_recompiler/frontend/maxwell/translate/impl/common_encoding.h"
8#include "shader_recompiler/frontend/maxwell/translate/impl/impl.h"
9
10namespace Shader::Maxwell {
11void TranslatorVisitor::FSWZADD(u64 insn) {
12 union {
13 u64 raw;
14 BitField<0, 8, IR::Reg> dest_reg;
15 BitField<28, 8, u64> swizzle;
16 BitField<38, 1, u64> ndv;
17 BitField<39, 2, FpRounding> round;
18 BitField<44, 1, u64> ftz;
19 BitField<47, 1, u64> cc;
20 } const fswzadd{insn};
21
22 if (fswzadd.ndv != 0) {
23 throw NotImplementedException("FSWZADD NDV");
24 }
25
26 const IR::F32 src_a{GetFloatReg8(insn)};
27 const IR::F32 src_b{GetFloatReg20(insn)};
28 const IR::U32 swizzle{ir.Imm32(static_cast<u32>(fswzadd.swizzle))};
29
30 const IR::FpControl fp_control{
31 .no_contraction{false},
32 .rounding{CastFpRounding(fswzadd.round)},
33 .fmz_mode{fswzadd.ftz != 0 ? IR::FmzMode::FTZ : IR::FmzMode::None},
34 };
35
36 const IR::F32 result{ir.FSwizzleAdd(src_a, src_b, swizzle, fp_control)};
37 F(fswzadd.dest_reg, result);
38
39 if (fswzadd.cc != 0) {
40 throw NotImplementedException("FSWZADD CC");
41 }
42}
43
44} // namespace Shader::Maxwell
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/impl.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/impl.cpp
index 9bae89c10..30b570ce4 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/impl.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/impl.cpp
@@ -91,6 +91,10 @@ IR::U32 TranslatorVisitor::GetReg39(u64 insn) {
91 return X(reg.index); 91 return X(reg.index);
92} 92}
93 93
94IR::F32 TranslatorVisitor::GetFloatReg8(u64 insn) {
95 return ir.BitCast<IR::F32>(GetReg8(insn));
96}
97
94IR::F32 TranslatorVisitor::GetFloatReg20(u64 insn) { 98IR::F32 TranslatorVisitor::GetFloatReg20(u64 insn) {
95 return ir.BitCast<IR::F32>(GetReg20(insn)); 99 return ir.BitCast<IR::F32>(GetReg20(insn));
96} 100}
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/impl.h b/src/shader_recompiler/frontend/maxwell/translate/impl/impl.h
index 54c31deb4..bf7d1bae8 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/impl.h
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/impl.h
@@ -353,6 +353,7 @@ public:
353 [[nodiscard]] IR::U32 GetReg8(u64 insn); 353 [[nodiscard]] IR::U32 GetReg8(u64 insn);
354 [[nodiscard]] IR::U32 GetReg20(u64 insn); 354 [[nodiscard]] IR::U32 GetReg20(u64 insn);
355 [[nodiscard]] IR::U32 GetReg39(u64 insn); 355 [[nodiscard]] IR::U32 GetReg39(u64 insn);
356 [[nodiscard]] IR::F32 GetFloatReg8(u64 insn);
356 [[nodiscard]] IR::F32 GetFloatReg20(u64 insn); 357 [[nodiscard]] IR::F32 GetFloatReg20(u64 insn);
357 [[nodiscard]] IR::F32 GetFloatReg39(u64 insn); 358 [[nodiscard]] IR::F32 GetFloatReg39(u64 insn);
358 [[nodiscard]] IR::F64 GetDoubleReg20(u64 insn); 359 [[nodiscard]] IR::F64 GetDoubleReg20(u64 insn);
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 a0057a473..6a580f831 100644
--- a/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp
+++ b/src/shader_recompiler/frontend/maxwell/translate/impl/not_implemented.cpp
@@ -89,10 +89,6 @@ void TranslatorVisitor::FCHK_imm(u64) {
89 ThrowNotImplemented(Opcode::FCHK_imm); 89 ThrowNotImplemented(Opcode::FCHK_imm);
90} 90}
91 91
92void TranslatorVisitor::FSWZADD(u64) {
93 ThrowNotImplemented(Opcode::FSWZADD);
94}
95
96void TranslatorVisitor::GETCRSPTR(u64) { 92void TranslatorVisitor::GETCRSPTR(u64) {
97 ThrowNotImplemented(Opcode::GETCRSPTR); 93 ThrowNotImplemented(Opcode::GETCRSPTR);
98} 94}