diff options
| author | 2021-03-21 04:33:19 +0100 | |
|---|---|---|
| committer | 2021-07-22 21:51:23 -0400 | |
| commit | 27fb97377eeb40849260ea866a90519521c6f59b (patch) | |
| tree | 103da3128456dba052d4c057a41d6e9ae0e2a2ba /src/shader_recompiler/frontend | |
| parent | shader: Implement HSETP2 (diff) | |
| download | yuzu-27fb97377eeb40849260ea866a90519521c6f59b.tar.gz yuzu-27fb97377eeb40849260ea866a90519521c6f59b.tar.xz yuzu-27fb97377eeb40849260ea866a90519521c6f59b.zip | |
shader: Fix floating point comparison for FP16
Diffstat (limited to 'src/shader_recompiler/frontend')
4 files changed, 32 insertions, 32 deletions
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/common_funcs.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/common_funcs.cpp index af9a8f82c..d30e82b10 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/common_funcs.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/common_funcs.cpp | |||
| @@ -72,7 +72,7 @@ bool IsCompareOpOrdered(FPCompareOp op) { | |||
| 72 | } | 72 | } |
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | IR::U1 FloatingPointCompare(IR::IREmitter& ir, const IR::F32& operand_1, const IR::F32& operand_2, | 75 | IR::U1 FloatingPointCompare(IR::IREmitter& ir, const IR::F16F32F64& operand_1, const IR::F16F32F64& operand_2, |
| 76 | FPCompareOp compare_op, IR::FpControl control) { | 76 | FPCompareOp compare_op, IR::FpControl control) { |
| 77 | const bool ordered{IsCompareOpOrdered(compare_op)}; | 77 | const bool ordered{IsCompareOpOrdered(compare_op)}; |
| 78 | switch (compare_op) { | 78 | switch (compare_op) { |
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/common_funcs.h b/src/shader_recompiler/frontend/maxwell/translate/impl/common_funcs.h index f8add3c34..f584060b3 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/common_funcs.h +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/common_funcs.h | |||
| @@ -18,7 +18,7 @@ namespace Shader::Maxwell { | |||
| 18 | 18 | ||
| 19 | [[nodiscard]] bool IsCompareOpOrdered(FPCompareOp op); | 19 | [[nodiscard]] bool IsCompareOpOrdered(FPCompareOp op); |
| 20 | 20 | ||
| 21 | [[nodiscard]] IR::U1 FloatingPointCompare(IR::IREmitter& ir, const IR::F32& operand_1, | 21 | [[nodiscard]] IR::U1 FloatingPointCompare(IR::IREmitter& ir, const IR::F16F32F64& operand_1, |
| 22 | const IR::F32& operand_2, FPCompareOp compare_op, | 22 | const IR::F16F32F64& operand_2, FPCompareOp compare_op, |
| 23 | IR::FpControl control = {}); | 23 | IR::FpControl control = {}); |
| 24 | } // namespace Shader::Maxwell | 24 | } // namespace Shader::Maxwell |
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/half_floating_point_set.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/half_floating_point_set.cpp index 4825ca06a..1d28c0531 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/half_floating_point_set.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/half_floating_point_set.cpp | |||
| @@ -22,8 +22,8 @@ void HSET2(TranslatorVisitor& v, u64 insn, const IR::U32& src_b, bool bf, bool f | |||
| 22 | 22 | ||
| 23 | auto [lhs_a, rhs_a]{Extract(v.ir, v.X(hset2.src_a_reg), hset2.swizzle_a)}; | 23 | auto [lhs_a, rhs_a]{Extract(v.ir, v.X(hset2.src_a_reg), hset2.swizzle_a)}; |
| 24 | auto [lhs_b, rhs_b]{Extract(v.ir, src_b, swizzle_b)}; | 24 | auto [lhs_b, rhs_b]{Extract(v.ir, src_b, swizzle_b)}; |
| 25 | // TODO: Implement FP16 FloatingPointCompare | 25 | |
| 26 | //if (lhs_a.Type() != lhs_b.Type()) { | 26 | if (lhs_a.Type() != lhs_b.Type()) { |
| 27 | if (lhs_a.Type() == IR::Type::F16) { | 27 | if (lhs_a.Type() == IR::Type::F16) { |
| 28 | lhs_a = v.ir.FPConvert(32, lhs_a); | 28 | lhs_a = v.ir.FPConvert(32, lhs_a); |
| 29 | rhs_a = v.ir.FPConvert(32, rhs_a); | 29 | rhs_a = v.ir.FPConvert(32, rhs_a); |
| @@ -32,7 +32,7 @@ void HSET2(TranslatorVisitor& v, u64 insn, const IR::U32& src_b, bool bf, bool f | |||
| 32 | lhs_b = v.ir.FPConvert(32, lhs_b); | 32 | lhs_b = v.ir.FPConvert(32, lhs_b); |
| 33 | rhs_b = v.ir.FPConvert(32, rhs_b); | 33 | rhs_b = v.ir.FPConvert(32, rhs_b); |
| 34 | } | 34 | } |
| 35 | //} | 35 | } |
| 36 | 36 | ||
| 37 | lhs_a = v.ir.FPAbsNeg(lhs_a, hset2.abs_a != 0, hset2.neg_a != 0); | 37 | lhs_a = v.ir.FPAbsNeg(lhs_a, hset2.abs_a != 0, hset2.neg_a != 0); |
| 38 | rhs_a = v.ir.FPAbsNeg(rhs_a, hset2.abs_a != 0, hset2.neg_a != 0); | 38 | rhs_a = v.ir.FPAbsNeg(rhs_a, hset2.abs_a != 0, hset2.neg_a != 0); |
| @@ -94,22 +94,22 @@ void TranslatorVisitor::HSET2_cbuf(u64 insn) { | |||
| 94 | } | 94 | } |
| 95 | 95 | ||
| 96 | void TranslatorVisitor::HSET2_imm(u64 insn) { | 96 | void TranslatorVisitor::HSET2_imm(u64 insn) { |
| 97 | union { | 97 | union { |
| 98 | u64 insn; | 98 | u64 insn; |
| 99 | BitField<53, 1, u64> bf; | 99 | BitField<53, 1, u64> bf; |
| 100 | BitField<54, 1, u64> ftz; | 100 | BitField<54, 1, u64> ftz; |
| 101 | BitField<49, 4, FPCompareOp> compare_op; | 101 | BitField<49, 4, FPCompareOp> compare_op; |
| 102 | BitField<56, 1, u64> neg_high; | 102 | BitField<56, 1, u64> neg_high; |
| 103 | BitField<30, 9, u64> high; | 103 | BitField<30, 9, u64> high; |
| 104 | BitField<29, 1, u64> neg_low; | 104 | BitField<29, 1, u64> neg_low; |
| 105 | BitField<20, 9, u64> low; | 105 | BitField<20, 9, u64> low; |
| 106 | } const hset2{insn}; | 106 | } const hset2{insn}; |
| 107 | 107 | ||
| 108 | const u32 imm{static_cast<u32>(hset2.low << 6) | ((hset2.neg_low != 0 ? 1 : 0) << 15) | | 108 | const u32 imm{static_cast<u32>(hset2.low << 6) | ((hset2.neg_low != 0 ? 1 : 0) << 15) | |
| 109 | static_cast<u32>(hset2.high << 22) | ((hset2.neg_high != 0 ? 1 : 0) << 31)}; | 109 | static_cast<u32>(hset2.high << 22) | ((hset2.neg_high != 0 ? 1 : 0) << 31)}; |
| 110 | 110 | ||
| 111 | HSET2(*this, insn, ir.Imm32(imm), hset2.bf != 0, hset2.ftz != 0, false, false, | 111 | HSET2(*this, insn, ir.Imm32(imm), hset2.bf != 0, hset2.ftz != 0, false, false, hset2.compare_op, |
| 112 | hset2.compare_op, Swizzle::H1_H0); | 112 | Swizzle::H1_H0); |
| 113 | } | 113 | } |
| 114 | 114 | ||
| 115 | } // namespace Shader::Maxwell | 115 | } // namespace Shader::Maxwell |
diff --git a/src/shader_recompiler/frontend/maxwell/translate/impl/half_floating_point_set_predicate.cpp b/src/shader_recompiler/frontend/maxwell/translate/impl/half_floating_point_set_predicate.cpp index 6b1ac21d5..3e2a23c92 100644 --- a/src/shader_recompiler/frontend/maxwell/translate/impl/half_floating_point_set_predicate.cpp +++ b/src/shader_recompiler/frontend/maxwell/translate/impl/half_floating_point_set_predicate.cpp | |||
| @@ -24,17 +24,17 @@ void HSETP2(TranslatorVisitor& v, u64 insn, const IR::U32& src_b, bool neg_b, bo | |||
| 24 | 24 | ||
| 25 | auto [lhs_a, rhs_a]{Extract(v.ir, v.X(hsetp2.src_a_reg), hsetp2.swizzle_a)}; | 25 | auto [lhs_a, rhs_a]{Extract(v.ir, v.X(hsetp2.src_a_reg), hsetp2.swizzle_a)}; |
| 26 | auto [lhs_b, rhs_b]{Extract(v.ir, src_b, swizzle_b)}; | 26 | auto [lhs_b, rhs_b]{Extract(v.ir, src_b, swizzle_b)}; |
| 27 | // TODO: Implement FP16 FloatingPointCompare | 27 | |
| 28 | // if (lhs_a.Type() != lhs_b.Type()) { | 28 | if (lhs_a.Type() != lhs_b.Type()) { |
| 29 | if (lhs_a.Type() == IR::Type::F16) { | 29 | if (lhs_a.Type() == IR::Type::F16) { |
| 30 | lhs_a = v.ir.FPConvert(32, lhs_a); | 30 | lhs_a = v.ir.FPConvert(32, lhs_a); |
| 31 | rhs_a = v.ir.FPConvert(32, rhs_a); | 31 | rhs_a = v.ir.FPConvert(32, rhs_a); |
| 32 | } | 32 | } |
| 33 | if (lhs_b.Type() == IR::Type::F16) { | 33 | if (lhs_b.Type() == IR::Type::F16) { |
| 34 | lhs_b = v.ir.FPConvert(32, lhs_b); | 34 | lhs_b = v.ir.FPConvert(32, lhs_b); |
| 35 | rhs_b = v.ir.FPConvert(32, rhs_b); | 35 | rhs_b = v.ir.FPConvert(32, rhs_b); |
| 36 | } | ||
| 36 | } | 37 | } |
| 37 | //} | ||
| 38 | 38 | ||
| 39 | lhs_a = v.ir.FPAbsNeg(lhs_a, hsetp2.abs_a != 0, hsetp2.neg_a != 0); | 39 | lhs_a = v.ir.FPAbsNeg(lhs_a, hsetp2.abs_a != 0, hsetp2.neg_a != 0); |
| 40 | rhs_a = v.ir.FPAbsNeg(rhs_a, hsetp2.abs_a != 0, hsetp2.neg_a != 0); | 40 | rhs_a = v.ir.FPAbsNeg(rhs_a, hsetp2.abs_a != 0, hsetp2.neg_a != 0); |