From ef4dca9a5497938701434fb0d9f38f48db820fa8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Fri, 9 Oct 2026 00:22:25 +0200 Subject: [PATCH] fix(shader): quiet signaling NaNs only in IEEE mode Co-Authored-By: Claude --- .../tests/execution/DivFixupF16.cpp | 1 + .../tests/execution/Division.cpp | 1 + .../tests/execution/NanQuieting.cpp | 242 ++++++++++++++++++ .../tests/execution/SdwaLdexpF16.cpp | 1 + .../tests/execution/Vop1FloatUnary.cpp | 1 + .../Translation/TranslationContext.hpp | 2 + .../Translation/src/FloatInstructions.cpp | 23 +- .../src/TranslationContext/OperandAccess.cpp | 8 + docs/dev/TechnicalDebt.md | 5 +- 9 files changed, 271 insertions(+), 13 deletions(-) create mode 100644 core/libs/prx/libSceAgcDriver/tests/execution/NanQuieting.cpp diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/DivFixupF16.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/DivFixupF16.cpp index b44192a6f..13dcbe318 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/DivFixupF16.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/DivFixupF16.cpp @@ -139,6 +139,7 @@ void Run(AgcDriver::VulkanDevice& device) { {0, 0, 0, 128} }; request.useCache = false; + request.context.floatMode = ShaderRecompiler::ShaderFloatMode{0xf0u, true, true, false}; const auto result = ShaderRecompiler::Recompile(request); device.Dispatch(result, 1, 1, 1, {}, reinterpret_cast(code.data())); device.WaitIdle(); diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/Division.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/Division.cpp index fbc1aabd3..39bf75b41 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/Division.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/Division.cpp @@ -589,6 +589,7 @@ public: {0, 0, 0, 128} }; request.useCache = false; + request.context.floatMode = ShaderRecompiler::ShaderFloatMode{0xf0u, true, true, false}; result = ShaderRecompiler::Recompile(request); } diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/NanQuieting.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/NanQuieting.cpp new file mode 100644 index 000000000..07de164aa --- /dev/null +++ b/core/libs/prx/libSceAgcDriver/tests/execution/NanQuieting.cpp @@ -0,0 +1,242 @@ +#include "prx/libSceAgcDriver/Execution/include/VulkanDevice.hpp" +#include "prx/libSceAgcDriver/Graphics/include/Draw.hpp" +#include "Recompiler.hpp" +#include "VulkanTestDevice.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace { + +using AgcDriver::Graphics::Require; +using ShaderRecompiler::ShaderStage; + +constexpr std::uint32_t Threads = 32; +constexpr std::uint32_t Inputs = 4; +constexpr std::uint32_t Results = 16; +alignas(256) std::array Input{}; +alignas(256) std::array Output{}; + +alignas(256) constexpr std::array Code{ + 0x34020084u, 0x34060086u, 0xe0381000u, 0x80000401u, 0xbf8c3f70u, 0x7e140280u, 0x7e160280u, 0x7e180280u, + 0x7e1a0280u, 0x7e1c0280u, 0x7e1e0280u, 0x7e200280u, 0x7e220280u, 0x7e240280u, 0x7e260280u, 0x7e280280u, + 0x7e2a0280u, 0x7e2c0280u, 0x7e2e0280u, 0x7e300280u, 0x7e320280u, 0x2c3c0e90u, 0x7e146704u, 0x7e165504u, + 0x7e184104u, 0x7e1a4904u, 0x7e1c8104u, 0xd762000fu, 0x02010304u, 0xd55f0010u, 0x041a0b04u, 0xd5500011u, + 0x041a0b04u, 0x7e24ab07u, 0x7e26a907u, 0x7e28bf07u, 0xd53b0015u, 0x02010307u, 0x7e2cb307u, 0xd75f0017u, + 0x041e3d07u, 0x7e304305u, 0x7e32bd1eu, 0xe0781000u, 0x80010a03u, 0xe0781010u, 0x80010e03u, 0xe0781020u, + 0x80011203u, 0xe0781030u, 0x80011603u, 0xbf810000u, +}; + +constexpr std::uint32_t Rows[32][4] = { + {0x7f812345u, 0x40000000u, 0x40400000u, 0x40007d23u}, + {0xff800001u, 0x40000000u, 0x40400000u, 0x4000fc01u}, + {0x7fa00000u, 0x40000000u, 0x40400000u, 0x40007d00u}, + {0x7fc00000u, 0x40000000u, 0x40400000u, 0x40007e00u}, + {0xffc00001u, 0x40000000u, 0x40400000u, 0x4000fe01u}, + {0x7fc12345u, 0x40000000u, 0x40400000u, 0x40007e55u}, + {0x3f800000u, 0x40000000u, 0x40400000u, 0x40003c00u}, + {0x40800000u, 0x40000000u, 0x40400000u, 0x40004400u}, + {0x3f800000u, 0x7f812345u, 0x40400000u, 0x7e553c00u}, + {0x3f800000u, 0xff800001u, 0x40400000u, 0x3c003c00u}, + {0x3f800000u, 0x7fa00000u, 0x40400000u, 0x44003c00u}, + {0x3f800000u, 0x7fc00000u, 0x40400000u, 0x7d233c00u}, + {0x3f800000u, 0xffc00001u, 0x40400000u, 0xfc013c00u}, + {0x3f800000u, 0x7fc12345u, 0x40400000u, 0x7d003c00u}, + {0x3f800000u, 0x3f800000u, 0x40400000u, 0x7e003c00u}, + {0x3f800000u, 0x40800000u, 0x40400000u, 0xfe013c00u}, + {0x3f800000u, 0x40000000u, 0x7fc00000u, 0x7e553c00u}, + {0x3f800000u, 0x40000000u, 0xffc00001u, 0x3c003c00u}, + {0x3f800000u, 0x40000000u, 0x7fc12345u, 0x44003c00u}, + {0x3f800000u, 0x40000000u, 0x3f800000u, 0x7d233c00u}, + {0x3f800000u, 0x40000000u, 0x40800000u, 0xfc013c00u}, + {0x3f800000u, 0x40000000u, 0x7f812345u, 0x7d003c00u}, + {0x3f800000u, 0x40000000u, 0xff800001u, 0x7e003c00u}, + {0x3f800000u, 0x40000000u, 0x7fa00000u, 0xfe013c00u}, + {0x7f812345u, 0x7f812345u, 0x7fc00000u, 0x7e557d23u}, + {0xff800001u, 0xff800001u, 0xffc00001u, 0x3c00fc01u}, + {0x7fa00000u, 0x7fa00000u, 0x7fc12345u, 0x44007d00u}, + {0x7fc00000u, 0x7fc00000u, 0x3f800000u, 0x7d237e00u}, + {0xffc00001u, 0xffc00001u, 0x40800000u, 0xfc01fe01u}, + {0x7fc12345u, 0x7fc12345u, 0x7f812345u, 0x7d007e55u}, + {0x3f800000u, 0x3f800000u, 0xff800001u, 0x7e003c00u}, + {0x40800000u, 0x40800000u, 0x7fa00000u, 0xfe014400u} +}; +constexpr std::uint32_t ExpectedIeee[32][16] = { + {0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7f800000u, 0x7fc12345u, 0x00007f23u, 0x00007f23u, 0x00007f23u, 0x00007f23u, 0x00007f23u, 0x00007f23u, 0x40000000u, 0x00004000u}, + {0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0x7f800000u, 0xffc00001u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x40000000u, 0x00004000u}, + {0x7fe00000u, 0x7fe00000u, 0x7fe00000u, 0x7fe00000u, 0x7fe00000u, 0x7fe00000u, 0x7f800000u, 0x7fe00000u, 0x00007f00u, 0x00007f00u, 0x00007f00u, 0x00007f00u, 0x00007f00u, 0x00007f00u, 0x40000000u, 0x00004000u}, + {0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7f800000u, 0x7fc00000u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x40000000u, 0x00004000u}, + {0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0x7f800000u, 0xffc00001u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x40000000u, 0x00004000u}, + {0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7f800000u, 0x7fc12345u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x40000000u, 0x00004000u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x3f800000u, 0x40000000u, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00003c00u, 0x40000000u, 0x00004000u}, + {0x40000000u, 0x3e800000u, 0x00000000u, 0x40800000u, 0x3f000000u, 0x41000000u, 0x40800000u, 0x41000000u, 0x00004000u, 0x00003400u, 0x00000000u, 0x00004800u, 0x00003800u, 0x00004400u, 0x40000000u, 0x00004000u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fc12345u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007e55u, 0x7fc12345u, 0x00007e55u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0xffc00001u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00003c00u, 0xffc00001u, 0x00003c00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fe00000u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00003c00u, 0x7fe00000u, 0x00004400u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fc00000u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007f23u, 0x7fc00000u, 0x00007f23u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0xffc00001u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x0000fe01u, 0xffc00001u, 0x0000fe01u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fc12345u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007f00u, 0x7fc12345u, 0x00007f00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x3f800000u, 0x3f800000u, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007e00u, 0x3f800000u, 0x00007e00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x3f800000u, 0x40800000u, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x0000fe01u, 0x40800000u, 0x0000fe01u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fc00000u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007e55u, 0x40000000u, 0x00007e55u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0xffc00001u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00003c00u, 0x40000000u, 0x00003c00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fc12345u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00003c00u, 0x40000000u, 0x00004400u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x3f800000u, 0x40000000u, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007f23u, 0x40000000u, 0x00007f23u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x3f800000u, 0x40000000u, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x0000fe01u, 0x40000000u, 0x0000fe01u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fc12345u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007f00u, 0x40000000u, 0x00007f00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0xffc00001u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007e00u, 0x40000000u, 0x00007e00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fe00000u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x0000fe01u, 0x40000000u, 0x0000fe01u}, + {0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc00000u, 0xff7fffffu, 0x00007f23u, 0x00007f23u, 0x00007f23u, 0x00007f23u, 0x00007f23u, 0x00007f23u, 0x7fc12345u, 0x00007e55u}, + {0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xff7fffffu, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0xffc00001u, 0x00003c00u}, + {0x7fe00000u, 0x7fe00000u, 0x7fe00000u, 0x7fe00000u, 0x7fe00000u, 0x7fe00000u, 0x7fc12345u, 0xff7fffffu, 0x00007f00u, 0x00007f00u, 0x00007f00u, 0x00007f00u, 0x00007f00u, 0x00007f00u, 0x7fe00000u, 0x00004400u}, + {0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0xff7fffffu, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x7fc00000u, 0x00007f23u}, + {0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xff7fffffu, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0xffc00001u, 0x0000fe01u}, + {0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0xff7fffffu, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x7fc12345u, 0x00007f00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0xffc00001u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007e00u, 0x3f800000u, 0x00007e00u}, + {0x40000000u, 0x3e800000u, 0x00000000u, 0x40800000u, 0x3f000000u, 0x41000000u, 0x7fe00000u, 0xff7fffffu, 0x00004000u, 0x00003400u, 0x00000000u, 0x00004800u, 0x00003800u, 0x0000fe01u, 0x40800000u, 0x0000fe01u} +}; +constexpr std::uint32_t ExpectedNoIeee[32][16] = { + {0x7f812345u, 0x7f812345u, 0x7f812345u, 0x7f812345u, 0x7f812345u, 0x7f812345u, 0x7f800000u, 0x7f812345u, 0x00007d23u, 0x00007d23u, 0x00007d23u, 0x00007d23u, 0x00007d23u, 0x00007d23u, 0x40000000u, 0x00004000u}, + {0xff800001u, 0xff800001u, 0xff800001u, 0xff800001u, 0xff800001u, 0xff800001u, 0x7f800000u, 0xff800001u, 0x0000fc01u, 0x0000fc01u, 0x0000fc01u, 0x0000fc01u, 0x0000fc01u, 0x0000fc01u, 0x40000000u, 0x00004000u}, + {0x7fa00000u, 0x7fa00000u, 0x7fa00000u, 0x7fa00000u, 0x7fa00000u, 0x7fa00000u, 0x7f800000u, 0x7fa00000u, 0x00007d00u, 0x00007d00u, 0x00007d00u, 0x00007d00u, 0x00007d00u, 0x00007d00u, 0x40000000u, 0x00004000u}, + {0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7f800000u, 0x7fc00000u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x40000000u, 0x00004000u}, + {0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0x7f800000u, 0xffc00001u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x40000000u, 0x00004000u}, + {0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7f800000u, 0x7fc12345u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x40000000u, 0x00004000u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x3f800000u, 0x40000000u, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00003c00u, 0x40000000u, 0x00004000u}, + {0x40000000u, 0x3e800000u, 0x00000000u, 0x40800000u, 0x3f000000u, 0x41000000u, 0x40800000u, 0x41000000u, 0x00004000u, 0x00003400u, 0x00000000u, 0x00004800u, 0x00003800u, 0x00004400u, 0x40000000u, 0x00004000u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7f812345u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007e55u, 0x7f812345u, 0x00007e55u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0xff800001u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00003c00u, 0xff800001u, 0x00003c00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fa00000u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00003c00u, 0x7fa00000u, 0x00004400u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fc00000u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007d23u, 0x7fc00000u, 0x00007d23u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0xffc00001u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x0000fc01u, 0xffc00001u, 0x0000fc01u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fc12345u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007d00u, 0x7fc12345u, 0x00007d00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x3f800000u, 0x3f800000u, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007e00u, 0x3f800000u, 0x00007e00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x3f800000u, 0x40800000u, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x0000fe01u, 0x40800000u, 0x0000fe01u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fc00000u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007e55u, 0x40000000u, 0x00007e55u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0xffc00001u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00003c00u, 0x40000000u, 0x00003c00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fc12345u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00003c00u, 0x40000000u, 0x00004400u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x3f800000u, 0x40000000u, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007d23u, 0x40000000u, 0x00007d23u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x3f800000u, 0x40000000u, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x0000fc01u, 0x40000000u, 0x0000fc01u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7f812345u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007d00u, 0x40000000u, 0x00007d00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0xff800001u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007e00u, 0x40000000u, 0x00007e00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0x7fa00000u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x0000fe01u, 0x40000000u, 0x0000fe01u}, + {0x7f812345u, 0x7f812345u, 0x7f812345u, 0x7f812345u, 0x7f812345u, 0x7f812345u, 0x7fc00000u, 0xff7fffffu, 0x00007d23u, 0x00007d23u, 0x00007d23u, 0x00007d23u, 0x00007d23u, 0x00007d23u, 0x7f812345u, 0x00007e55u}, + {0xff800001u, 0xff800001u, 0xff800001u, 0xff800001u, 0xff800001u, 0xff800001u, 0xffc00001u, 0xff7fffffu, 0x0000fc01u, 0x0000fc01u, 0x0000fc01u, 0x0000fc01u, 0x0000fc01u, 0x0000fc01u, 0xff800001u, 0x00003c00u}, + {0x7fa00000u, 0x7fa00000u, 0x7fa00000u, 0x7fa00000u, 0x7fa00000u, 0x7fa00000u, 0x7fc12345u, 0xff7fffffu, 0x00007d00u, 0x00007d00u, 0x00007d00u, 0x00007d00u, 0x00007d00u, 0x00007d00u, 0x7fa00000u, 0x00004400u}, + {0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0x7fc00000u, 0xff7fffffu, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x00007e00u, 0x7fc00000u, 0x00007d23u}, + {0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xffc00001u, 0xff7fffffu, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0x0000fe01u, 0xffc00001u, 0x0000fc01u}, + {0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7fc12345u, 0x7f812345u, 0xff7fffffu, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x00007e55u, 0x7fc12345u, 0x00007d00u}, + {0x3f800000u, 0x3f800000u, 0x00000000u, 0x3f800000u, 0x3f000000u, 0x40000000u, 0xff800001u, 0xff7fffffu, 0x00003c00u, 0x00003c00u, 0x00000000u, 0x00004000u, 0x00003800u, 0x00007e00u, 0x3f800000u, 0x00007e00u}, + {0x40000000u, 0x3e800000u, 0x00000000u, 0x40800000u, 0x3f000000u, 0x41000000u, 0x7fa00000u, 0xff7fffffu, 0x00004000u, 0x00003400u, 0x00000000u, 0x00004800u, 0x00003800u, 0x0000fe01u, 0x40800000u, 0x0000fe01u} +}; +constexpr const char* Names[16] = { + "v_sqrt_f32", + "v_rcp_f32", + "v_fract_f32", + "v_floor_f32", + "v_frexp_mant_f32", + "v_ldexp_f32", + "v_div_fixup_f32", + "v_mullit_f32", + "v_sqrt_f16", + "v_rcp_f16", + "v_fract_f16", + "v_ldexp_f16", + "v_frexp_mant_f16", + "v_div_fixup_f16", + "v_trunc_f32", + "v_rndne_f16" +}; + +void Fill(std::uint32_t tid, std::uint32_t* words) { + std::copy(std::begin(Rows[tid]), std::end(Rows[tid]), words); +} + +std::array BufferDescriptor(const void* data, std::uint32_t bytes) { + const auto address = reinterpret_cast(data); + return {static_cast(address), static_cast((address >> 32u) & 0xffffu), bytes, 0x31016facu}; +} + +std::string Hex(std::uint32_t value) { + char text[16]; + std::snprintf(text, sizeof(text), "0x%08x", value); + return text; +} + +void Expect(std::uint32_t tid, std::uint32_t actual, std::uint32_t expected, const char* name) { + Require(actual == expected, std::string("nan quieting: lane ") + std::to_string(tid) + " " + name + " is " + Hex(actual) + ", expected " + Hex(expected)); +} + +bool IsNan32(std::uint32_t value) { + return (value & 0x7fffffffu) > 0x7f800000u; +} + +bool IsNan16(std::uint32_t value) { + return (value & 0x7fffu) > 0x7c00u; +} + +void Run(AgcDriver::VulkanDevice& device, const std::optional& floatMode) { + for (std::uint32_t tid = 0; tid < Threads; ++tid) Fill(tid, &Input[tid * Inputs]); + Output.fill(0xdeadbeefu); + std::vector userData(8, 0u); + const auto input = BufferDescriptor(Input.data(), static_cast(Input.size() * 4u)); + const auto output = BufferDescriptor(Output.data(), static_cast(Output.size() * 4u)); + std::copy(input.begin(), input.end(), userData.begin()); + std::copy(output.begin(), output.end(), userData.begin() + 4); + const std::span code(Code); + const std::array memory{{{reinterpret_cast(code.data()), std::as_bytes(code)}}}; + const ShaderRecompiler::ShaderComputeStageInfo compute{{Threads, 1, 1}, 0u, {false, false, false}, false, 1}; + ShaderRecompiler::RecompileRequest request{ + {ShaderStage::Compute, reinterpret_cast(code.data()), code, 0, {}}, + {32, 0, userData, compute, std::nullopt, std::nullopt, memory}, + device.Target(), + {0, 0, 0, 128} + }; + request.useCache = false; + request.context.floatMode = floatMode; + const auto result = ShaderRecompiler::Recompile(request); + device.Dispatch(result, 1, 1, 1, {}, reinterpret_cast(code.data())); + device.WaitIdle(); +} + +void Check(const std::uint32_t (&expected)[32][16], const char* mode) { + for (std::uint32_t tid = 0; tid < Threads; ++tid) { + const std::uint32_t* out = &Output[tid * Results]; + for (std::uint32_t i = 0; i < 16; ++i) { + const std::string name = std::string(mode) + " " + Names[i]; + const bool half = i >= 8u && i != 14u; + const std::uint32_t got = half ? out[i] & 0xffffu : out[i]; + const std::uint32_t want = half ? expected[tid][i] & 0xffffu : expected[tid][i]; + const bool approximate = i == 0u || i == 1u || i == 8u || i == 9u; + if (approximate && !(half ? IsNan16(want) : IsNan32(want))) continue; + Expect(tid, got, want, name.c_str()); + } + } +} + +} + +int main() { + try { + const auto device = OpenVulkanTestDevice(); + if (!device) return VulkanTestSkipped; + Run(*device, std::nullopt); + Check(ExpectedNoIeee, "no float mode"); + Run(*device, ShaderRecompiler::ShaderFloatMode{0xc0u, true, false, false}); + Check(ExpectedNoIeee, "IEEE=0"); + Run(*device, ShaderRecompiler::ShaderFloatMode{0xc0u, true, true, false}); + Check(ExpectedIeee, "IEEE=1"); + std::puts("nan quieting tests passed"); + return 0; + } catch (const std::exception& error) { + std::cerr << error.what() << '\n'; + return 1; + } +} diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/SdwaLdexpF16.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/SdwaLdexpF16.cpp index 40b871324..ec46c5b46 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/SdwaLdexpF16.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/SdwaLdexpF16.cpp @@ -155,6 +155,7 @@ ShaderRecompiler::RecompileResult Compile(AgcDriver::VulkanDevice& device, std:: {0, 0, 0, 128} }; request.useCache = false; + request.context.floatMode = ShaderRecompiler::ShaderFloatMode{0xf0u, true, true, false}; return ShaderRecompiler::Recompile(request); } diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/Vop1FloatUnary.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/Vop1FloatUnary.cpp index d90b742f5..4deb73f4d 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/Vop1FloatUnary.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/Vop1FloatUnary.cpp @@ -186,6 +186,7 @@ void Run(AgcDriver::VulkanDevice& device) { {0, 0, 0, 128} }; request.useCache = false; + request.context.floatMode = ShaderRecompiler::ShaderFloatMode{0xf0u, true, true, false}; const auto result = ShaderRecompiler::Recompile(request); device.Dispatch(result, 1, 1, 1, {}, reinterpret_cast(code.data())); device.WaitIdle(); diff --git a/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp b/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp index d1d94b4ea..ac5698c0e 100644 --- a/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp +++ b/core/shader/recompiler/Translation/include/Translation/TranslationContext.hpp @@ -59,6 +59,8 @@ private: IrU32 readU32(const RdnaOperand& operand); IrU32 flushF32Denormal(IrU32 bits); IrF32 flushTinyProduct(IrValue* lhs, IrValue* rhs, IrValue* product, IrValue* addend = nullptr); + IrU32 quietNan32(IrU32 bits); + IrU32 quietNan16(IrU32 bits); std::array readU32Pair(const RdnaOperand& operand); IrU64 readU64(const RdnaOperand& operand); std::array readF64Bits(const RdnaOperand& operand); diff --git a/core/shader/recompiler/Translation/src/FloatInstructions.cpp b/core/shader/recompiler/Translation/src/FloatInstructions.cpp index f904367e4..86a354934 100644 --- a/core/shader/recompiler/Translation/src/FloatInstructions.cpp +++ b/core/shader/recompiler/Translation/src/FloatInstructions.cpp @@ -92,7 +92,7 @@ bool TranslationContext::float16Unary(const RdnaInstruction& inst, IrOpcode opco } const IrU32 half = readF16Bits(operand); const IrU1 nan(ir.UGreaterThan(ir.BitwiseAnd(half.Value(), ir.Constant(0x7fffu)), ir.Constant(0x7c00u))); - const IrU32 special(ir.Select(nan.Value(), ir.BitwiseOr(half.Value(), ir.Constant(0x0200u)), ir.Constant(0xfe00u))); + const IrU32 special(ir.Select(nan.Value(), quietNan16(half).Value(), ir.Constant(0xfe00u))); const IrU32 value(ir.Select(ir.LogicalOr(nan.Value(), invalid.Value()), inst.destination.clamp && dx10Clamp() ? ir.Constant(0u) : special.Value(), bits.Value())); write16Bits(inst.destination, value); return true; @@ -194,8 +194,8 @@ bool TranslationContext::vDivFixupF16(const RdnaInstruction& inst) { const IrU1 bothZero(ir.LogicalAnd(isZero(1u).Value(), isZero(2u).Value())); const IrU1 bothInf(ir.LogicalAnd(isInf(1u).Value(), isInf(2u).Value())); result = IrU32(ir.Select(ir.LogicalOr(bothZero.Value(), bothInf.Value()), ir.Constant(0xfe00u), result.Value())); - result = IrU32(ir.Select(isNan(1u).Value(), ir.BitwiseOr(bits[1].Value(), ir.Constant(0x0200u)), result.Value())); - result = IrU32(ir.Select(isNan(2u).Value(), ir.BitwiseOr(bits[2].Value(), ir.Constant(0x0200u)), result.Value())); + result = IrU32(ir.Select(isNan(1u).Value(), quietNan16(bits[1]).Value(), result.Value())); + result = IrU32(ir.Select(isNan(2u).Value(), quietNan16(bits[2]).Value(), result.Value())); write16Bits(inst.destination, clampF16Bits(inst.destination, result)); return true; } @@ -285,7 +285,7 @@ bool TranslationContext::vLdexpF16(const RdnaInstruction& inst) { const IrF16 scaled(ir.Emit(IrOpcode::ConvertF16F32, IrType::F16, {&ir.Emit(IrOpcode::FPMul32, IrType::F32, {&value.Value(), &power})})); const IrU32 result(ir.Emit(IrOpcode::ConvertU32U16, IrType::U32, {&ir.Emit(IrOpcode::BitCastU16F16, IrType::U16, {&scaled.Value()})})); const IrU1 nan(ir.UGreaterThan(ir.BitwiseAnd(bits.Value(), ir.Constant(0x7fffu)), ir.Constant(0x7c00u))); - write16Bits(inst.destination, clampF16Bits(inst.destination, IrU32(ir.Select(nan.Value(), ir.BitwiseOr(bits.Value(), ir.Constant(0x200u)), result.Value())))); + write16Bits(inst.destination, clampF16Bits(inst.destination, IrU32(ir.Select(nan.Value(), quietNan16(bits).Value(), result.Value())))); return true; } @@ -304,7 +304,7 @@ bool TranslationContext::vFrexpF16(const RdnaInstruction& inst, bool exponent) { const IrF16 half(ir.Emit(IrOpcode::ConvertF16F32, IrType::F16, {&ir.BitCastF32(mantissa.Value())})); const IrU32 converted(ir.Emit(IrOpcode::ConvertU32U16, IrType::U32, {&ir.Emit(IrOpcode::BitCastU16F16, IrType::U16, {&half.Value()})})); const IrU1 nan(ir.UGreaterThan(ir.BitwiseAnd(bits.Value(), ir.Constant(0x7fffu)), ir.Constant(0x7c00u))); - const IrU32 kept(ir.Select(nan.Value(), ir.BitwiseOr(bits.Value(), ir.Constant(0x200u)), bits.Value())); + const IrU32 kept(ir.Select(nan.Value(), quietNan16(bits).Value(), bits.Value())); write16Bits(inst.destination, clampF16Bits(inst.destination, IrU32(ir.Select(special.Value(), kept.Value(), converted.Value())))); return true; } @@ -359,7 +359,7 @@ bool TranslationContext::vMullitF32(const RdnaInstruction& inst) { IrU1 lowest(ir.LogicalOr(rhsNegativeMax.Value(), ir.LogicalOr(isNan(limit).Value(), limitNotPositive.Value()))); lowest = IrU1(ir.LogicalOr(lowest.Value(), isNan(rhs).Value())); const IrU32 product(ir.BitCastU32(ir.Emit(IrOpcode::FPMul32, IrType::F32, {&ir.BitCastF32(lhs.Value()), &ir.BitCastF32(rhs.Value())}))); - IrU32 result(ir.Select(isNan(lhs).Value(), ir.BitwiseOr(lhs.Value(), ir.Constant(0x00400000u)), product.Value())); + IrU32 result(ir.Select(isNan(lhs).Value(), quietNan32(lhs).Value(), product.Value())); result = IrU32(ir.Select(ir.LogicalOr(isZero(lhs).Value(), isZero(rhs).Value()), ir.Constant(0u), result.Value())); result = IrU32(ir.Select(lowest.Value(), ir.Constant(0xff7fffffu), result.Value())); writeOperand(inst.destination, &result.Value()); @@ -485,8 +485,8 @@ bool TranslationContext::vDivFixupF32(const RdnaInstruction& inst) { result = IrU32(ir.Select(ir.LogicalOr(isZero(denominator).Value(), isInf(numerator).Value()), infinity.Value(), result.Value())); const IrU1 invalid(ir.LogicalOr(ir.LogicalAnd(isZero(denominator).Value(), isZero(numerator).Value()), ir.LogicalAnd(isInf(denominator).Value(), isInf(numerator).Value()))); result = IrU32(ir.Select(invalid.Value(), ir.Constant(0xffc00000u), result.Value())); - result = IrU32(ir.Select(isNan(denominator).Value(), ir.BitwiseOr(denominator.Value(), ir.Constant(0x400000u)), result.Value())); - result = IrU32(ir.Select(isNan(numerator).Value(), ir.BitwiseOr(numerator.Value(), ir.Constant(0x400000u)), result.Value())); + result = IrU32(ir.Select(isNan(denominator).Value(), quietNan32(denominator).Value(), result.Value())); + result = IrU32(ir.Select(isNan(numerator).Value(), quietNan32(numerator).Value(), result.Value())); writeOperand(inst.destination, &ir.BitCastF32(result.Value())); return true; } @@ -496,7 +496,7 @@ bool TranslationContext::floatUnary(const RdnaInstruction& inst, IrOpcode opcode const IrF32 argument(ir.BitCastF32(bits.Value())); const auto [result, invalid] = unaryFloatSpecials(opcode, argument, IrF32(ir.Emit(opcode, IrType::F32, {&argument.Value()}))); const IrU1 nan(ir.UGreaterThan(ir.BitwiseAnd(bits.Value(), ir.Constant(0x7fffffffu)), ir.Constant(0x7f800000u))); - const IrU32 special(ir.Select(nan.Value(), ir.BitwiseOr(bits.Value(), ir.Constant(0x00400000u)), ir.Constant(0xffc00000u))); + const IrU32 special(ir.Select(nan.Value(), quietNan32(bits).Value(), ir.Constant(0xffc00000u))); const IrF32 value(ir.Select(ir.LogicalOr(nan.Value(), invalid.Value()), ir.BitCastF32(special.Value()), result.Value())); writeOperand(inst.destination, &value.Value()); return true; @@ -585,7 +585,7 @@ bool TranslationContext::vFrexpMantF32(const RdnaInstruction& inst) { const IrU32 zeroOrSubnormal(ir.Select(zero.Value(), bits.Value(), subnormal.Value())); const IrU32 finite(ir.Select(exponentNonZero.Value(), normal.Value(), zeroOrSubnormal.Value())); const IrU1 exponentAllOnes(ir.IEqual(exponent.Value(), ir.Constant(0xffu))); - const IrU32 special(ir.Select(zero.Value(), bits.Value(), ir.BitwiseOr(bits.Value(), ir.Constant(0x00400000u)))); + const IrU32 special(ir.Select(zero.Value(), bits.Value(), quietNan32(bits).Value())); const IrU32 result(ir.Select(exponentAllOnes.Value(), special.Value(), finite.Value())); writeOperand(inst.destination, &ir.BitCastF32(result.Value())); return true; @@ -602,7 +602,8 @@ bool TranslationContext::vLdexpF32(const RdnaInstruction& inst) { const IrU32 overflow(ir.BitwiseOr(sign.Value(), ir.Constant(0x7f800000u))); IrU32 result(ir.Select(ir.Emit(IrOpcode::SGreaterThanEqual32, IrType::U1, {&scaled.Value(), &ir.Constant(255u)}), overflow.Value(), normal.Value())); result = IrU32(ir.Select(ir.Emit(IrOpcode::SLessThanEqual32, IrType::U1, {&scaled.Value(), &ir.Constant(0u)}), sign.Value(), result.Value())); - result = IrU32(ir.Select(ir.IEqual(exponent.Value(), ir.Constant(0xffu)), bits.Value(), result.Value())); + const IrU1 nan(ir.UGreaterThan(ir.BitwiseAnd(bits.Value(), ir.Constant(0x7fffffffu)), ir.Constant(0x7f800000u))); + result = IrU32(ir.Select(ir.IEqual(exponent.Value(), ir.Constant(0xffu)), ir.Select(nan.Value(), quietNan32(bits).Value(), bits.Value()), result.Value())); result = IrU32(ir.Select(ir.IEqual(exponent.Value(), ir.Constant(0u)), sign.Value(), result.Value())); writeOperand(inst.destination, &ir.BitCastF32(result.Value())); return true; diff --git a/core/shader/recompiler/Translation/src/TranslationContext/OperandAccess.cpp b/core/shader/recompiler/Translation/src/TranslationContext/OperandAccess.cpp index 3e949f17c..0e1cda62c 100644 --- a/core/shader/recompiler/Translation/src/TranslationContext/OperandAccess.cpp +++ b/core/shader/recompiler/Translation/src/TranslationContext/OperandAccess.cpp @@ -282,6 +282,14 @@ void TranslationContext::rejectHalfOrDoubleOutputModifier(const RdnaOperand& ope } } +IrU32 TranslationContext::quietNan32(IrU32 bits) { + return ieeeMode ? IrU32(ir.BitwiseOr(bits.Value(), ir.Constant(0x00400000u))) : bits; +} + +IrU32 TranslationContext::quietNan16(IrU32 bits) { + return ieeeMode ? IrU32(ir.BitwiseOr(bits.Value(), ir.Constant(0x0200u))) : bits; +} + IrF32 TranslationContext::applyF32ResultModifiers(const RdnaOperand& operand, IrF32 value) { if (operand.omod != 0u && outputModifierApplies(4u)) { IrValue& bits = ir.BitCastU32(value.Value()); diff --git a/docs/dev/TechnicalDebt.md b/docs/dev/TechnicalDebt.md index ce81a835a..81b674366 100644 --- a/docs/dev/TechnicalDebt.md +++ b/docs/dev/TechnicalDebt.md @@ -286,10 +286,11 @@ Throughout the project, every function at every stage either **does exactly what - A [COND_EXEC range](../../core/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cpp) must hold whole packets and end inside its command buffer. A chained INDIRECT_BUFFER or a REWIND inside a range throws, as what the CP does with the skipped dwords then is unknown. - A [COND_INDIRECT_BUFFER](../../core/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cpp) (`sceAgcCbBranch`) runs only with the always-pass compare function; a comparison or a predicated packet throws. Modes 1 and 2 run the first buffer, assumed to be the if-then and if-then-else modes of AMD's PM4 packet. [sceAgcCbBranch](../../core/libs/prx/libSceAgc/Cb/src/Branch.cpp) does not check the compare address of an always-pass branch or the address of an empty buffer, as PPSA14632 passes an uninitialised compare address and a null else buffer of 0 dwords. - [SET_*_REG_INDIRECT](../../core/libs/prx/libSceAgcDriver/Execution/src/Driver/Queues/Submission.cpp) (libSceAgcDriver) reads its register list when the command buffer is submitted, with the packets. The console's graphics PFP reads it when it reaches the packet, so a list written after the submission (by the CPU, or by GPU work ahead of the packet behind PFP_SYNC_ME) is read here before that write. -- The [shader float mode](../../core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp) (`FLOAT_MODE`, `DX10_CLAMP`, `IEEE_MODE` and `FP16_OVFL` of `COMPUTE_PGM_RSRC1` and `SPI_SHADER_PGM_RSRC1_PS/GS/HS`, bit positions from Mesa's `gfx10.json` and `gfx103.json`) is decoded into `GuestContext::floatMode` and is part of the shader cache keys and the serialized request (#981). `IEEE_MODE` is read by `v_min_f32`, `v_max_f32`, `v_min3_f32`, `v_max3_f32` and `v_med3_f32`, `IEEE_MODE` and the `FLOAT_MODE` output denormal bits by the output modifier, `DX10_CLAMP` by the clamp modifier, and the whole mode by the 16-bit interpolation instructions (see their entries). With IEEE=1 a signaling NaN operand returns that NaN quieted (the first operand checked first, min3/max3 as two nested pairs, med3 as min3 when any operand is NaN), measured on RDNA2 (gfx1035) over every combination of ±0, ±1, ±inf, denormals, quiet and signaling NaNs with f32 denormals kept and flushed. IEEE=0 and unknown modes keep the previous lowering, which matches IEEE=0. The f16 and f64 min/max/med3, NaN quieting in arithmetic, `FP16_OVFL` and `FLOAT_MODE` (f32 denormals flushed before the min/max compare in Astro's Playroom's 0xc0) still follow a single mode, as the entries below record. The mode comes from the registered shader header's `sh_registers`, the same source at registration and at draw/dispatch so the prepared artifact keys match. A title that rewrites RSRC1 at run time, or a raw compute program with no header, compiles with that mode or none. -- [v_mullit_f32](../../core/shader/recompiler/Translation/src/FloatInstructions.cpp) follows the hardware measured with the MODE register at IEEE=1 and denormals kept (a signaling NaN src0 is quieted, a positive denormal src2 counts as positive): the recompiler does not read MODE, so other IEEE/denormal settings are not modelled. +- The [shader float mode](../../core/libs/prx/libSceAgcDriver/Execution/src/Driver/Shaders/ShaderRegistry.cpp) (`FLOAT_MODE`, `DX10_CLAMP`, `IEEE_MODE` and `FP16_OVFL` of `COMPUTE_PGM_RSRC1` and `SPI_SHADER_PGM_RSRC1_PS/GS/HS`, bit positions from Mesa's `gfx10.json` and `gfx103.json`) is decoded into `GuestContext::floatMode` and is part of the shader cache keys and the serialized request (#981). `IEEE_MODE` is read by `v_min_f32`, `v_max_f32`, `v_min3_f32`, `v_max3_f32` and `v_med3_f32`, `IEEE_MODE` and the `FLOAT_MODE` output denormal bits by the output modifier, `DX10_CLAMP` by the clamp modifier, and the whole mode by the 16-bit interpolation instructions (see their entries). With IEEE=1 a signaling NaN operand returns that NaN quieted (the first operand checked first, min3/max3 as two nested pairs, med3 as min3 when any operand is NaN), measured on RDNA2 (gfx1035) over every combination of ±0, ±1, ±inf, denormals, quiet and signaling NaNs with f32 denormals kept and flushed. IEEE=0 and unknown modes keep the previous lowering, which matches IEEE=0. The f16 and f64 min/max/med3, NaN quieting in binary and ternary arithmetic (the unary instructions follow it, see below), `FP16_OVFL` and `FLOAT_MODE` (f32 denormals flushed before the min/max compare in Astro's Playroom's 0xc0) still follow a single mode, as the entries below record. The mode comes from the registered shader header's `sh_registers`, the same source at registration and at draw/dispatch so the prepared artifact keys match. A title that rewrites RSRC1 at run time, or a raw compute program with no header, compiles with that mode or none. +- [v_mullit_f32](../../core/shader/recompiler/Translation/src/FloatInstructions.cpp) follows the hardware measured with the MODE register at IEEE=1 and denormals kept (a signaling NaN src0 is quieted only with IEEE=1, as measured at IEEE=0 too; a positive denormal src2 counts as positive): other denormal settings are not modelled. - [v_fma_legacy_f32](../../core/shader/recompiler/Translation/src/FloatInstructions.cpp) (VOP3 0x140) is assumed to be fused, which has not been measured on hardware. LLVM decodes this encoding as `v_mad_legacy_f32` for gfx1013, and `v_mac_legacy_f32` (VOP2 0x06) was measured to round its product before the add, so 0x140 may do the same. - [v_fma_f16, v_pk_fma_f16 and v_pk_fmac_f16](../../core/shader/recompiler/Translation/src/FloatInstructions.cpp) are an f32 FMA rounded to f16, which rounds twice: 0x62e9 * 0xd159 + 0x23ec gives 0xf89e, the hardware 0xf89f. +- [Signaling NaN inputs](../../core/shader/recompiler/Translation/src/FloatInstructions.cpp) of the f32 and f16 unary instructions (`v_sqrt/rcp/rsq/log/exp/sin/cos/fract/floor/ceil/trunc/rndne/rcp_iflag/frexp_mant`), `v_ldexp_f32/f16`, `v_frexp_mant_f16`, `v_div_fixup_f32/f16` and `v_mullit_f32` are returned quieted only with IEEE=1 and unchanged with IEEE=0, measured on RDNA2 (gfx1035) in both modes; shaders without a known float mode follow IEEE=0. The binary and ternary arithmetic (`v_add/mul/fma_f32/f16`, `v_mul_legacy`, `v_fma_mix`, `v_cubema`) follows the same rule on hardware but its NaN bits are left to the driver. `v_cvt_f16_f32` and `v_dot2_f32_f16` always quiet and `v_div_scale_f32` never does. - [Packed f16 NaN results](../../core/shader/recompiler/Translation/src/FloatInstructions.cpp) (`v_pk_add/mul/fma/min/max_f16`) follow the hardware measured on RDNA2 (gfx1035) at IEEE=0 and IEEE=1 with f16 round-to-nearest-even and f16 denormals kept: with IEEE=1 a signaling NaN input is quieted and min/max return the other operand only for a quiet NaN; with IEEE=0 NaN inputs pass through unquieted and min/max ignore signaling. In `v_pk_fma_f16` an invalid product (inf * 0) gives the default NaN even when src2 is a NaN. A shader without a known float mode is translated as IEEE=0, the mode titles use; a mode with another f16 rounding or that flushes f16 denormals throws. - [f32 denormals](../../core/shader/recompiler/Translation/src/TranslationContext/OperandAccess.cpp) follow the shader's `FLOAT_MODE` f32 denormal field (bits 5:4) when it flushes them (0, and shaders without a known float mode, as in the 0xc0 most titles use), measured on RDNA2 (gfx1035) over 1444 rows per instruction at IEEE=0 and IEEE=1. `v_add/sub/subrev/mul/mul_legacy/fma/fmac/fmamk/fmaak/min/max/min3/max3/med3/fract/floor/ceil/frexp_mant/sin/cos_f32` flush their f32 inputs and their result to a zero of the same sign; the f32 compares, `v_cvt_i32/u32/rpi_i32/flr_i32_f32`, `v_frexp_exp_i32_f32`, `v_cvt_f64_f32`, `v_cvt_f16_f32`, `v_cvt_pkrtz_f16_f32`, `v_cvt_pknorm_i16/u16_f32` and `v_cvt_pk_u8_f32` flush their f32 inputs. Tininess is detected before rounding: a product whose exact value is below 2^-126 gives zero even when it rounds to 2^-126, computed exactly from the significands for `v_mul_f32`, `v_mul_legacy_f32`, and for `v_fma_f32`, `v_fmac_f32`, `v_fmamk_f32`, `v_fmaak_f32` and `v_fma_mix_f32` when the addend is zero; with a nonzero addend the fused result is kept, so an exact result just below 2^-126 that rounds to it is not flushed. `v_fma_mix_f32` was measured with f32 sources only; its f16 sources are not flushed. Denormal modes 1 and 2 throw. Not covered, and not measurable on RDNA2 (no such opcodes) or not measured: `v_mac_f32`, `v_mad_f32`, `v_madak_f32` and `v_madmk_f32` (rounded separately), `v_mac_legacy_f32`, `v_dot2_f32_f16`, the division steps (on hardware `v_div_fixup_f32` flushes only src1 and src2, `v_div_fmas_f32` only its result), f32 interpolation and LDS float atomics keep the previous lowering. With f32 denormals kept (3) the results depend on the driver's default denormal behaviour, as no `DenormPreserve` execution mode is requested, and `v_ldexp_f32` flushes in every mode. - The executable file that [relinker](../../core/relinker/elfpatcher/src/windows/WindowsPeWriter.cpp) generates opens the console when launched, which is inconvenient for playability.