diff options
| author | 2021-03-24 00:02:30 +0100 | |
|---|---|---|
| committer | 2021-07-22 21:51:24 -0400 | |
| commit | 8cb9443cb99c4510e6ef26a91d09a31a8fa6281f (patch) | |
| tree | 2337f294c7179e1e2e98cafedde5c2eb254965cb /src/shader_recompiler/frontend/ir | |
| parent | shader: Implement NDC [-1, 1], attribute types and default varying initializa... (diff) | |
| download | yuzu-8cb9443cb99c4510e6ef26a91d09a31a8fa6281f.tar.gz yuzu-8cb9443cb99c4510e6ef26a91d09a31a8fa6281f.tar.xz yuzu-8cb9443cb99c4510e6ef26a91d09a31a8fa6281f.zip | |
shader: Fix F2I
Diffstat (limited to 'src/shader_recompiler/frontend/ir')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/ir_emitter.cpp | 18 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/ir_emitter.h | 1 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/opcodes.inc | 3 |
3 files changed, 22 insertions, 0 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp index ce610799a..6280c08f6 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp +++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp | |||
| @@ -731,6 +731,24 @@ F16F32F64 IREmitter::FPSaturate(const F16F32F64& value) { | |||
| 731 | } | 731 | } |
| 732 | } | 732 | } |
| 733 | 733 | ||
| 734 | F16F32F64 IREmitter::FPClamp(const F16F32F64& value, const F16F32F64& min_value, | ||
| 735 | const F16F32F64& max_value) { | ||
| 736 | if (value.Type() != min_value.Type() || value.Type() != max_value.Type()) { | ||
| 737 | throw InvalidArgument("Mismatching types {}, {}, and {}", value.Type(), min_value.Type(), | ||
| 738 | max_value.Type()); | ||
| 739 | } | ||
| 740 | switch (value.Type()) { | ||
| 741 | case Type::F16: | ||
| 742 | return Inst<F16>(Opcode::FPClamp16, value, min_value, max_value); | ||
| 743 | case Type::F32: | ||
| 744 | return Inst<F32>(Opcode::FPClamp32, value, min_value, max_value); | ||
| 745 | case Type::F64: | ||
| 746 | return Inst<F64>(Opcode::FPClamp64, value, min_value, max_value); | ||
| 747 | default: | ||
| 748 | ThrowInvalidType(value.Type()); | ||
| 749 | } | ||
| 750 | } | ||
| 751 | |||
| 734 | F16F32F64 IREmitter::FPRoundEven(const F16F32F64& value, FpControl control) { | 752 | F16F32F64 IREmitter::FPRoundEven(const F16F32F64& value, FpControl control) { |
| 735 | switch (value.Type()) { | 753 | switch (value.Type()) { |
| 736 | case Type::F16: | 754 | case Type::F16: |
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h index 39109b0de..ebbda78a9 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.h +++ b/src/shader_recompiler/frontend/ir/ir_emitter.h | |||
| @@ -147,6 +147,7 @@ public: | |||
| 147 | [[nodiscard]] F32F64 FPRecipSqrt(const F32F64& value); | 147 | [[nodiscard]] F32F64 FPRecipSqrt(const F32F64& value); |
| 148 | [[nodiscard]] F32 FPSqrt(const F32& value); | 148 | [[nodiscard]] F32 FPSqrt(const F32& value); |
| 149 | [[nodiscard]] F16F32F64 FPSaturate(const F16F32F64& value); | 149 | [[nodiscard]] F16F32F64 FPSaturate(const F16F32F64& value); |
| 150 | [[nodiscard]] F16F32F64 FPClamp(const F16F32F64& value, const F16F32F64& min_value, const F16F32F64& max_value); | ||
| 150 | [[nodiscard]] F16F32F64 FPRoundEven(const F16F32F64& value, FpControl control = {}); | 151 | [[nodiscard]] F16F32F64 FPRoundEven(const F16F32F64& value, FpControl control = {}); |
| 151 | [[nodiscard]] F16F32F64 FPFloor(const F16F32F64& value, FpControl control = {}); | 152 | [[nodiscard]] F16F32F64 FPFloor(const F16F32F64& value, FpControl control = {}); |
| 152 | [[nodiscard]] F16F32F64 FPCeil(const F16F32F64& value, FpControl control = {}); | 153 | [[nodiscard]] F16F32F64 FPCeil(const F16F32F64& value, FpControl control = {}); |
diff --git a/src/shader_recompiler/frontend/ir/opcodes.inc b/src/shader_recompiler/frontend/ir/opcodes.inc index 8945c7b04..dd17212a1 100644 --- a/src/shader_recompiler/frontend/ir/opcodes.inc +++ b/src/shader_recompiler/frontend/ir/opcodes.inc | |||
| @@ -192,6 +192,9 @@ OPCODE(FPLog2, F32, F32, | |||
| 192 | OPCODE(FPSaturate16, F16, F16, ) | 192 | OPCODE(FPSaturate16, F16, F16, ) |
| 193 | OPCODE(FPSaturate32, F32, F32, ) | 193 | OPCODE(FPSaturate32, F32, F32, ) |
| 194 | OPCODE(FPSaturate64, F64, F64, ) | 194 | OPCODE(FPSaturate64, F64, F64, ) |
| 195 | OPCODE(FPClamp16, F16, F16, F16, F16, ) | ||
| 196 | OPCODE(FPClamp32, F32, F32, F32, F32, ) | ||
| 197 | OPCODE(FPClamp64, F64, F64, F64, F64, ) | ||
| 195 | OPCODE(FPRoundEven16, F16, F16, ) | 198 | OPCODE(FPRoundEven16, F16, F16, ) |
| 196 | OPCODE(FPRoundEven32, F32, F32, ) | 199 | OPCODE(FPRoundEven32, F32, F32, ) |
| 197 | OPCODE(FPRoundEven64, F64, F64, ) | 200 | OPCODE(FPRoundEven64, F64, F64, ) |