diff options
| author | 2021-02-20 03:30:13 -0300 | |
|---|---|---|
| committer | 2021-07-22 21:51:22 -0400 | |
| commit | e2bc05b17d91854cbb9c0ce3647141bf7d33143e (patch) | |
| tree | 96769db006b6015cd536483db98ee0697aee4992 /src/shader_recompiler/frontend/ir | |
| parent | spirv: Add lower fp16 to fp32 pass (diff) | |
| download | yuzu-e2bc05b17d91854cbb9c0ce3647141bf7d33143e.tar.gz yuzu-e2bc05b17d91854cbb9c0ce3647141bf7d33143e.tar.xz yuzu-e2bc05b17d91854cbb9c0ce3647141bf7d33143e.zip | |
shader: Add denorm flush support
Diffstat (limited to 'src/shader_recompiler/frontend/ir')
| -rw-r--r-- | src/shader_recompiler/frontend/ir/ir_emitter.cpp | 32 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/ir_emitter.h | 8 | ||||
| -rw-r--r-- | src/shader_recompiler/frontend/ir/modifiers.h | 23 |
3 files changed, 34 insertions, 29 deletions
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.cpp b/src/shader_recompiler/frontend/ir/ir_emitter.cpp index 559ab9cca..8f120a2f6 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.cpp +++ b/src/shader_recompiler/frontend/ir/ir_emitter.cpp | |||
| @@ -558,53 +558,53 @@ F16F32F64 IREmitter::FPSaturate(const F16F32F64& value) { | |||
| 558 | } | 558 | } |
| 559 | } | 559 | } |
| 560 | 560 | ||
| 561 | F16F32F64 IREmitter::FPRoundEven(const F16F32F64& value) { | 561 | F16F32F64 IREmitter::FPRoundEven(const F16F32F64& value, FpControl control) { |
| 562 | switch (value.Type()) { | 562 | switch (value.Type()) { |
| 563 | case Type::F16: | 563 | case Type::F16: |
| 564 | return Inst<F16>(Opcode::FPRoundEven16, value); | 564 | return Inst<F16>(Opcode::FPRoundEven16, Flags{control}, value); |
| 565 | case Type::F32: | 565 | case Type::F32: |
| 566 | return Inst<F32>(Opcode::FPRoundEven32, value); | 566 | return Inst<F32>(Opcode::FPRoundEven32, Flags{control}, value); |
| 567 | case Type::F64: | 567 | case Type::F64: |
| 568 | return Inst<F64>(Opcode::FPRoundEven64, value); | 568 | return Inst<F64>(Opcode::FPRoundEven64, Flags{control}, value); |
| 569 | default: | 569 | default: |
| 570 | ThrowInvalidType(value.Type()); | 570 | ThrowInvalidType(value.Type()); |
| 571 | } | 571 | } |
| 572 | } | 572 | } |
| 573 | 573 | ||
| 574 | F16F32F64 IREmitter::FPFloor(const F16F32F64& value) { | 574 | F16F32F64 IREmitter::FPFloor(const F16F32F64& value, FpControl control) { |
| 575 | switch (value.Type()) { | 575 | switch (value.Type()) { |
| 576 | case Type::F16: | 576 | case Type::F16: |
| 577 | return Inst<F16>(Opcode::FPFloor16, value); | 577 | return Inst<F16>(Opcode::FPFloor16, Flags{control}, value); |
| 578 | case Type::F32: | 578 | case Type::F32: |
| 579 | return Inst<F32>(Opcode::FPFloor32, value); | 579 | return Inst<F32>(Opcode::FPFloor32, Flags{control}, value); |
| 580 | case Type::F64: | 580 | case Type::F64: |
| 581 | return Inst<F64>(Opcode::FPFloor64, value); | 581 | return Inst<F64>(Opcode::FPFloor64, Flags{control}, value); |
| 582 | default: | 582 | default: |
| 583 | ThrowInvalidType(value.Type()); | 583 | ThrowInvalidType(value.Type()); |
| 584 | } | 584 | } |
| 585 | } | 585 | } |
| 586 | 586 | ||
| 587 | F16F32F64 IREmitter::FPCeil(const F16F32F64& value) { | 587 | F16F32F64 IREmitter::FPCeil(const F16F32F64& value, FpControl control) { |
| 588 | switch (value.Type()) { | 588 | switch (value.Type()) { |
| 589 | case Type::F16: | 589 | case Type::F16: |
| 590 | return Inst<F16>(Opcode::FPCeil16, value); | 590 | return Inst<F16>(Opcode::FPCeil16, Flags{control}, value); |
| 591 | case Type::F32: | 591 | case Type::F32: |
| 592 | return Inst<F32>(Opcode::FPCeil32, value); | 592 | return Inst<F32>(Opcode::FPCeil32, Flags{control}, value); |
| 593 | case Type::F64: | 593 | case Type::F64: |
| 594 | return Inst<F64>(Opcode::FPCeil64, value); | 594 | return Inst<F64>(Opcode::FPCeil64, Flags{control}, value); |
| 595 | default: | 595 | default: |
| 596 | ThrowInvalidType(value.Type()); | 596 | ThrowInvalidType(value.Type()); |
| 597 | } | 597 | } |
| 598 | } | 598 | } |
| 599 | 599 | ||
| 600 | F16F32F64 IREmitter::FPTrunc(const F16F32F64& value) { | 600 | F16F32F64 IREmitter::FPTrunc(const F16F32F64& value, FpControl control) { |
| 601 | switch (value.Type()) { | 601 | switch (value.Type()) { |
| 602 | case Type::F16: | 602 | case Type::F16: |
| 603 | return Inst<F16>(Opcode::FPTrunc16, value); | 603 | return Inst<F16>(Opcode::FPTrunc16, Flags{control}, value); |
| 604 | case Type::F32: | 604 | case Type::F32: |
| 605 | return Inst<F32>(Opcode::FPTrunc32, value); | 605 | return Inst<F32>(Opcode::FPTrunc32, Flags{control}, value); |
| 606 | case Type::F64: | 606 | case Type::F64: |
| 607 | return Inst<F64>(Opcode::FPTrunc64, value); | 607 | return Inst<F64>(Opcode::FPTrunc64, Flags{control}, value); |
| 608 | default: | 608 | default: |
| 609 | ThrowInvalidType(value.Type()); | 609 | ThrowInvalidType(value.Type()); |
| 610 | } | 610 | } |
diff --git a/src/shader_recompiler/frontend/ir/ir_emitter.h b/src/shader_recompiler/frontend/ir/ir_emitter.h index 24b012a39..959f4f9da 100644 --- a/src/shader_recompiler/frontend/ir/ir_emitter.h +++ b/src/shader_recompiler/frontend/ir/ir_emitter.h | |||
| @@ -129,10 +129,10 @@ public: | |||
| 129 | [[nodiscard]] F32 FPSinNotReduced(const F32& value); | 129 | [[nodiscard]] F32 FPSinNotReduced(const F32& value); |
| 130 | [[nodiscard]] F32 FPSqrt(const F32& value); | 130 | [[nodiscard]] F32 FPSqrt(const F32& value); |
| 131 | [[nodiscard]] F16F32F64 FPSaturate(const F16F32F64& value); | 131 | [[nodiscard]] F16F32F64 FPSaturate(const F16F32F64& value); |
| 132 | [[nodiscard]] F16F32F64 FPRoundEven(const F16F32F64& value); | 132 | [[nodiscard]] F16F32F64 FPRoundEven(const F16F32F64& value, FpControl control = {}); |
| 133 | [[nodiscard]] F16F32F64 FPFloor(const F16F32F64& value); | 133 | [[nodiscard]] F16F32F64 FPFloor(const F16F32F64& value, FpControl control = {}); |
| 134 | [[nodiscard]] F16F32F64 FPCeil(const F16F32F64& value); | 134 | [[nodiscard]] F16F32F64 FPCeil(const F16F32F64& value, FpControl control = {}); |
| 135 | [[nodiscard]] F16F32F64 FPTrunc(const F16F32F64& value); | 135 | [[nodiscard]] F16F32F64 FPTrunc(const F16F32F64& value, FpControl control = {}); |
| 136 | 136 | ||
| 137 | [[nodiscard]] U32U64 IAdd(const U32U64& a, const U32U64& b); | 137 | [[nodiscard]] U32U64 IAdd(const U32U64& a, const U32U64& b); |
| 138 | [[nodiscard]] U32U64 ISub(const U32U64& a, const U32U64& b); | 138 | [[nodiscard]] U32U64 ISub(const U32U64& a, const U32U64& b); |
diff --git a/src/shader_recompiler/frontend/ir/modifiers.h b/src/shader_recompiler/frontend/ir/modifiers.h index c288eede0..44652eae7 100644 --- a/src/shader_recompiler/frontend/ir/modifiers.h +++ b/src/shader_recompiler/frontend/ir/modifiers.h | |||
| @@ -4,25 +4,30 @@ | |||
| 4 | 4 | ||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include "common/common_types.h" | ||
| 8 | |||
| 7 | namespace Shader::IR { | 9 | namespace Shader::IR { |
| 8 | 10 | ||
| 9 | enum class FmzMode : u8 { | 11 | enum class FmzMode : u8 { |
| 10 | None, // Denorms are not flushed, NAN is propagated (nouveau) | 12 | DontCare, // Not specified for this instruction |
| 11 | FTZ, // Flush denorms to zero, NAN is propagated (D3D11, NVN, GL, VK) | 13 | FTZ, // Flush denorms to zero, NAN is propagated (D3D11, NVN, GL, VK) |
| 12 | FMZ, // Flush denorms to zero, x * 0 == 0 (D3D9) | 14 | FMZ, // Flush denorms to zero, x * 0 == 0 (D3D9) |
| 15 | None, // Denorms are not flushed, NAN is propagated (nouveau) | ||
| 13 | }; | 16 | }; |
| 14 | 17 | ||
| 15 | enum class FpRounding : u8 { | 18 | enum class FpRounding : u8 { |
| 16 | RN, // Round to nearest even, | 19 | DontCare, // Not specified for this instruction |
| 17 | RM, // Round towards negative infinity | 20 | RN, // Round to nearest even, |
| 18 | RP, // Round towards positive infinity | 21 | RM, // Round towards negative infinity |
| 19 | RZ, // Round towards zero | 22 | RP, // Round towards positive infinity |
| 23 | RZ, // Round towards zero | ||
| 20 | }; | 24 | }; |
| 21 | 25 | ||
| 22 | struct FpControl { | 26 | struct FpControl { |
| 23 | bool no_contraction{false}; | 27 | bool no_contraction{false}; |
| 24 | FpRounding rounding{FpRounding::RN}; | 28 | FpRounding rounding{FpRounding::DontCare}; |
| 25 | FmzMode fmz_mode{FmzMode::FTZ}; | 29 | FmzMode fmz_mode{FmzMode::DontCare}; |
| 26 | }; | 30 | }; |
| 27 | static_assert(sizeof(FpControl) <= sizeof(u32)); | 31 | static_assert(sizeof(FpControl) <= sizeof(u32)); |
| 32 | |||
| 28 | } // namespace Shader::IR | 33 | } // namespace Shader::IR |