summaryrefslogtreecommitdiff
path: root/src/shader_recompiler/frontend/ir
diff options
context:
space:
mode:
authorGravatar FernandoS272021-03-24 00:02:30 +0100
committerGravatar ameerj2021-07-22 21:51:24 -0400
commit8cb9443cb99c4510e6ef26a91d09a31a8fa6281f (patch)
tree2337f294c7179e1e2e98cafedde5c2eb254965cb /src/shader_recompiler/frontend/ir
parentshader: Implement NDC [-1, 1], attribute types and default varying initializa... (diff)
downloadyuzu-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.cpp18
-rw-r--r--src/shader_recompiler/frontend/ir/ir_emitter.h1
-rw-r--r--src/shader_recompiler/frontend/ir/opcodes.inc3
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
734F16F32F64 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
734F16F32F64 IREmitter::FPRoundEven(const F16F32F64& value, FpControl control) { 752F16F32F64 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,
192OPCODE(FPSaturate16, F16, F16, ) 192OPCODE(FPSaturate16, F16, F16, )
193OPCODE(FPSaturate32, F32, F32, ) 193OPCODE(FPSaturate32, F32, F32, )
194OPCODE(FPSaturate64, F64, F64, ) 194OPCODE(FPSaturate64, F64, F64, )
195OPCODE(FPClamp16, F16, F16, F16, F16, )
196OPCODE(FPClamp32, F32, F32, F32, F32, )
197OPCODE(FPClamp64, F64, F64, F64, F64, )
195OPCODE(FPRoundEven16, F16, F16, ) 198OPCODE(FPRoundEven16, F16, F16, )
196OPCODE(FPRoundEven32, F32, F32, ) 199OPCODE(FPRoundEven32, F32, F32, )
197OPCODE(FPRoundEven64, F64, F64, ) 200OPCODE(FPRoundEven64, F64, F64, )