fix(recompiler): emit a GPU-selected formatted buffer access through one shared function #2349
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2349"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from boykopovar/AnyPS5. Originally posted by Pipodi on 2026-10-09T16:06:35Z.
What
#1959 moves the switch over every buffer format into one function per resource when the descriptor is prepared. It keeps the inline switch for GPU-selected descriptors (
memory.gpuDescriptor). For those, everybuffer_load_format_*/buffer_store_format_*still emits all 77 cases inline, and each case inlines the address computation, bounds checks and BDA reads offormatted().A title with about 300 such accesses in one compute program (Ghost of Yōtei, PPSA26344, 0x8000289300, 102 guest blocks) compiles to 37.1M SPIR-V words: 292
OpSwitches, about 700k blocks, 287 distinct block shapes. Each pipeline takes 40 s or more to create on NVIDIA, and each shader disk-cache entry is up to ~300 MB. This is probably also the 13.4M-word module reported on #1183.formattedGpuCallemits oneDontInlineSPIR-V function per component count, direction, d16, coherence, kind and stop mode, and runsformatSwitchinside it.{value, stopped}(juststoppedfor a store). Inside it, a stop returns that throughbdaStopValue, asread_bda_spandoes. The caller callsStopBdaInvocationIfon the flag, so the pixel-shader interlock andOpKillhandling stay in the entry function.BdaInstructionPcreturns the instruction's PC, or the PC parameter inside the shared function (SpirvEmitterState::bdaPcOverride). The BDA read, write, store, atomic and overflow paths use it, so a fault records the PC of the access that faulted.Tested
Windows 11, MinGW-w64 GCC 15.2.0, RTX 4090 (driver 617.42).
agc_formatted_buffer_oncegains a GPU-selected case: dword 3 of the V# comes fromv_readfirstlane_b32 s11, v0.Checklist
main; no other open PR implements the same functions (stacked on #1959)NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:52:37Z.
Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at
0690a904:/tmp/anyps5_build) with zero warnings/errors.python3 tools/check_conventions.py --base origin/main --head HEAD-> PASS (0 errors).FormattedBufferOnce.cpptest and SPIR-V emission deduplication inSpirvBda.hpp. Generates cleaner SPIR-V without code bloat.LGTM!
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T08:44:59Z.
Rebased onto current
main: dropped the first commit (the old version of #1959, already merged asf2bd6d4af) and resolved the conflicts inSpirvBdaRead.cpp(BDA byte-write functions on main now) andFormattedBufferOnce.cpp(Compile(loads, formattedStores, gpu)), plus one moreBdaInstructionPcsite in the BDA store probe path.Checked on Linux (RADV) on the rebased tree: libSceAgc + libSceAgcDriver ctest green (334/335, the one failure is a stale registration not present on
main).agc_formatted_buffer_oncefails without the change and passes with it. The Ghost of Yōtei numbers and the NVIDIA/Windows runs are the author's and Kikoarl's (Linux, Intel); not reproduced here. Merging once CI is green on the rebased head.