From c8e4a17f89c0738c92cb66f1e646415ae494ccf1 Mon Sep 17 00:00:00 2001 From: Kikoarl <7354010+Kikoarl@users.noreply.github.com> Date: Tue, 6 Oct 2026 17:33:43 +0200 Subject: [PATCH 1/2] feat(shader): decode s_setkill as s_endpgm --- .../tests/execution/ScalarProgramEnd.cpp | 12 +++++++++--- .../RdnaDecoder/src/RdnaScalarOpDecoder.cpp | 1 + docs/dev/TechnicalDebt.md | 1 + tools/progress.py | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/core/libs/prx/libSceAgcDriver/tests/execution/ScalarProgramEnd.cpp b/core/libs/prx/libSceAgcDriver/tests/execution/ScalarProgramEnd.cpp index a4362f4c3..335a99a9a 100644 --- a/core/libs/prx/libSceAgcDriver/tests/execution/ScalarProgramEnd.cpp +++ b/core/libs/prx/libSceAgcDriver/tests/execution/ScalarProgramEnd.cpp @@ -30,6 +30,11 @@ alignas(256) constexpr std::array Code{ 0xe0701000, 0x80010603, 0xbf9b0000, 0xe0701004, 0x80010603, 0xbf810000, }; +alignas(256) constexpr std::array SetkillCode{ + 0x34020084, 0x34060086, 0xe0301000, 0x80000401, 0xbf8c3f70, 0x4a0a0881, 0x7e0c02ff, 0x00000bad, 0xbf060000, 0xbf840007, + 0xbf840003, 0xe0701000, 0x80010503, 0xbf8b0000, 0xe0701000, 0x80010603, 0xbf8b0001, 0xe0701004, 0x80010603, 0xbf810000, +}; + alignas(256) constexpr std::array RoundTowardZeroCode{0xbfa40003, 0xbf810000}; void Fill(std::uint32_t tid, std::uint32_t* words) { words[0] = tid * 0x01010101u + 7u; } @@ -74,7 +79,7 @@ void ExpectRefused(AgcDriver::VulkanDevice& device) { Require(refused, "scalar program end: s_round_mode 3 was translated"); } -void Run(AgcDriver::VulkanDevice& device) { +void Run(AgcDriver::VulkanDevice& device, std::span code) { for (std::uint32_t tid = 0; tid < Threads; ++tid) Fill(tid, &Input[tid * Inputs]); Output.fill(0xdeadbeefu); std::vector userData(8, 0u); @@ -82,7 +87,6 @@ void Run(AgcDriver::VulkanDevice& device) { 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 auto result = ShaderRecompiler::Recompile(Request(device, code, userData, memory)); device.Dispatch(result, 1, 1, 1, {}, reinterpret_cast(code.data())); @@ -104,7 +108,9 @@ int main() { try { const auto device = OpenVulkanTestDevice(); if (!device) return VulkanTestSkipped; - Run(*device); + Run(*device, Code); + Check(); + Run(*device, SetkillCode); Check(); ExpectRefused(*device); std::puts("scalar program end tests passed"); diff --git a/core/shader/recompiler/RdnaDecoder/src/RdnaScalarOpDecoder.cpp b/core/shader/recompiler/RdnaDecoder/src/RdnaScalarOpDecoder.cpp index de3c85f62..d774eba52 100644 --- a/core/shader/recompiler/RdnaDecoder/src/RdnaScalarOpDecoder.cpp +++ b/core/shader/recompiler/RdnaDecoder/src/RdnaScalarOpDecoder.cpp @@ -201,6 +201,7 @@ RdnaOpcode decodeSoppOpcode(std::uint32_t opcode) { case 0x08u: return RdnaOpcode::SCbranchExecz; case 0x09u: return RdnaOpcode::SCbranchExecnz; case 0x0au: return RdnaOpcode::SBarrier; + case 0x0bu: return RdnaOpcode::SEndpgm; case 0x0cu: return RdnaOpcode::SWaitcnt; case 0x0eu: return RdnaOpcode::SSleep; case 0x0fu: return RdnaOpcode::SSetprio; diff --git a/docs/dev/TechnicalDebt.md b/docs/dev/TechnicalDebt.md index 07ab6b6ad..0075459c5 100644 --- a/docs/dev/TechnicalDebt.md +++ b/docs/dev/TechnicalDebt.md @@ -44,6 +44,7 @@ Throughout the project, every function at every stage either **does exactly what - [sceVideoOutRegisterBuffers2](../../core/libs/prx/libSceVideoOut/src/Buffer.cpp) (libSceVideoOut) - DCC buffers (category 1): `dcc_control` is taken as the CB_DCC_CONTROL block layout, only bits 0x10026c are accepted; `dcc_cb_register_clear_color` as the register-clear texel, only 32-bit values are presented - [sceVideoOutIsOutputSupported](../../core/libs/prx/libSceVideoOut/src/Output.cpp) (libSceVideoOut) - output mode encoding unknown: every mode except the default reports not supported (0), and `sceVideoOutConfigureOutput` returns `VIDEO_OUT_ERROR_UNAVAILABLE_OUTPUT_MODE` for it, instead of returning `VIDEO_OUT_ERROR_UNSUPPORTED_OUTPUT_MODE` for values the console does not define. PPSA12544 probes `0xd000000a` and selects 7680 pixels when it is supported, 3840 otherwise - [sceVideoOutOpen](../../core/libs/prx/libSceVideoOut/src/Output.cpp) (libSceVideoOut) - the open param's first word is unknown (PPSA21564 passes 16; it is not the byte size, since the affinity mask is at offset 16); only 16 is accepted. Whether the param continues past offset 24 is also unknown +- S_SETKILL translation (core/shader/recompiler) - decoded as `s_endpgm`: measured on RDNA2 hardware (gfx1035) that `s_setkill` with any immediate ends the wave exactly like `s_endpgm`, with a store before it visible and nothing after it executed, matching the `s_endpgm_saved` treatment from [#436](https://github.com/boykopovar/AnyPS5/pull/436); whether the KILL status bit has an observable difference from END_PG status is unverified. S_SETHALT, S_SENDMSGHALT and S_CODE_END stay unimplemented and throw: halt freezes the wave until a debugger or the trap handler resumes it (the dispatch never completes; `s_sendmsghalt` sends its message and then halts the same way), which SPIR-V cannot represent, and `s_code_end` padding is excluded from translation by program decoding while executing it hangs the wave (AMD ISA GCN3 §12.4/§13.1 and the same measurement) - [sceRtcParseDateTime](../../core/libs/prx/libSceRtc/Export.cpp) (libSceRtc) - accepted format assumed to be the ISO 8601 subset `YYYY-MM-DDTHH:MM:SS[.ffffff]` (T/t/space separator, optional fractional seconds) with the sibling RFC 3339 zone suffix (`Z` or `±HH:MM`), plus the RFC 2822 shape `Ddd, DD Mon YYYY HH:MM:SS[ GMT| ±HHMM]` and the asctime shape `Ddd Mon DD HH:MM:SS YYYY` (day zero- or space-padded) that shadPS4 parses at fixed positions; the weekday name is not checked against the date, a `±HHMM` offset is subtracted to get UTC like the RFC 3339 path (shadPS4 adds it), a string without a zone is taken as UTC, and anything outside these shapes throws instead of returning a parse error, unverified against hardware - [sceAudio3dPortOpen](../../core/libs/prx/libSceAudio3d/Export.cpp) (libSceAudio3d) - buffer modes 0 and 1 (also selected by the 0x10 and 0x18 parameter sizes) and 3 beds depend on an SDK version check in the module ([prosper](https://github.com/mattias800/prosper)) and throw. A repeated `sceAudio3dInitialize` (`NOT_READY` in shadPS4, 0 in prosper) and `sceAudio3dPortAdvance` on a full queue (`NOT_READY` in shadPS4, unhandled in KytyPS5) throw too - [AMPR WriteAddressFromCounterPairOnCompletion](../../core/libs/prx/libSceAmpr/Export.cpp) (libSceAmpr) - the pair of an even counter n is assumed to give counter n in the low 32 bits and n + 1 in the high 32 bits. Wait compare values, wait flush and counter index ranges follow the [ampr_emu](https://github.com/drakmor/ampr_emu) reimplementation; the flush is accepted and has no effect, as commands run in order diff --git a/tools/progress.py b/tools/progress.py index a0b5ae4e4..fcb383408 100644 --- a/tools/progress.py +++ b/tools/progress.py @@ -26,7 +26,7 @@ OPCODE_ALIASES = { "VMadMixhiF16": "V_FMA_MIXHI_F16", } OPCODE_VARIANTS = { - "SEndpgm": ("S_ENDPGM_SAVED", "S_ENDPGM_ORDERED_PS_DONE"), + "SEndpgm": ("S_ENDPGM_SAVED", "S_ENDPGM_ORDERED_PS_DONE", "S_SETKILL"), "VFmaF32": ("V_FMA_MIX_F32",), "SAddI32": ("S_ADDK_I32",), "SCmpEqI32": ("S_CMPK_EQ_I32",), From c50181f6fa5d4a47d4a35a37327ffdd56a260fac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Franch?= Date: Wed, 7 Oct 2026 08:39:47 +0200 Subject: [PATCH 2/2] docs(TechnicalDebt): trim s_setkill entry to the measured behaviour Co-Authored-By: Claude --- docs/dev/TechnicalDebt.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/dev/TechnicalDebt.md b/docs/dev/TechnicalDebt.md index 0075459c5..c8561af00 100644 --- a/docs/dev/TechnicalDebt.md +++ b/docs/dev/TechnicalDebt.md @@ -44,7 +44,7 @@ Throughout the project, every function at every stage either **does exactly what - [sceVideoOutRegisterBuffers2](../../core/libs/prx/libSceVideoOut/src/Buffer.cpp) (libSceVideoOut) - DCC buffers (category 1): `dcc_control` is taken as the CB_DCC_CONTROL block layout, only bits 0x10026c are accepted; `dcc_cb_register_clear_color` as the register-clear texel, only 32-bit values are presented - [sceVideoOutIsOutputSupported](../../core/libs/prx/libSceVideoOut/src/Output.cpp) (libSceVideoOut) - output mode encoding unknown: every mode except the default reports not supported (0), and `sceVideoOutConfigureOutput` returns `VIDEO_OUT_ERROR_UNAVAILABLE_OUTPUT_MODE` for it, instead of returning `VIDEO_OUT_ERROR_UNSUPPORTED_OUTPUT_MODE` for values the console does not define. PPSA12544 probes `0xd000000a` and selects 7680 pixels when it is supported, 3840 otherwise - [sceVideoOutOpen](../../core/libs/prx/libSceVideoOut/src/Output.cpp) (libSceVideoOut) - the open param's first word is unknown (PPSA21564 passes 16; it is not the byte size, since the affinity mask is at offset 16); only 16 is accepted. Whether the param continues past offset 24 is also unknown -- S_SETKILL translation (core/shader/recompiler) - decoded as `s_endpgm`: measured on RDNA2 hardware (gfx1035) that `s_setkill` with any immediate ends the wave exactly like `s_endpgm`, with a store before it visible and nothing after it executed, matching the `s_endpgm_saved` treatment from [#436](https://github.com/boykopovar/AnyPS5/pull/436); whether the KILL status bit has an observable difference from END_PG status is unverified. S_SETHALT, S_SENDMSGHALT and S_CODE_END stay unimplemented and throw: halt freezes the wave until a debugger or the trap handler resumes it (the dispatch never completes; `s_sendmsghalt` sends its message and then halts the same way), which SPIR-V cannot represent, and `s_code_end` padding is excluded from translation by program decoding while executing it hangs the wave (AMD ISA GCN3 §12.4/§13.1 and the same measurement) +- [s_setkill](../../core/shader/recompiler/RdnaDecoder/src/RdnaScalarOpDecoder.cpp) (core/shader/recompiler) - decoded as `s_endpgm` for any immediate: measured on RDNA2 hardware (gfx1035), a store before it is visible and nothing after it runs ([#771](https://github.com/boykopovar/AnyPS5/pull/771)); whether the KILL status bit it sets is observable differently from `s_endpgm` is unverified - [sceRtcParseDateTime](../../core/libs/prx/libSceRtc/Export.cpp) (libSceRtc) - accepted format assumed to be the ISO 8601 subset `YYYY-MM-DDTHH:MM:SS[.ffffff]` (T/t/space separator, optional fractional seconds) with the sibling RFC 3339 zone suffix (`Z` or `±HH:MM`), plus the RFC 2822 shape `Ddd, DD Mon YYYY HH:MM:SS[ GMT| ±HHMM]` and the asctime shape `Ddd Mon DD HH:MM:SS YYYY` (day zero- or space-padded) that shadPS4 parses at fixed positions; the weekday name is not checked against the date, a `±HHMM` offset is subtracted to get UTC like the RFC 3339 path (shadPS4 adds it), a string without a zone is taken as UTC, and anything outside these shapes throws instead of returning a parse error, unverified against hardware - [sceAudio3dPortOpen](../../core/libs/prx/libSceAudio3d/Export.cpp) (libSceAudio3d) - buffer modes 0 and 1 (also selected by the 0x10 and 0x18 parameter sizes) and 3 beds depend on an SDK version check in the module ([prosper](https://github.com/mattias800/prosper)) and throw. A repeated `sceAudio3dInitialize` (`NOT_READY` in shadPS4, 0 in prosper) and `sceAudio3dPortAdvance` on a full queue (`NOT_READY` in shadPS4, unhandled in KytyPS5) throw too - [AMPR WriteAddressFromCounterPairOnCompletion](../../core/libs/prx/libSceAmpr/Export.cpp) (libSceAmpr) - the pair of an even counter n is assumed to give counter n in the low 32 bits and n + 1 in the high 32 bits. Wait compare values, wait flush and counter index ranges follow the [ampr_emu](https://github.com/drakmor/ampr_emu) reimplementation; the flush is accepted and has no effect, as commands run in order