fix(agc): share a registered shader's decoded state with its other headers #9991
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9991"
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 milescoviello on 2026-10-23T03:19:32Z.
What
Ghost of Tsushima Director's Cut (PPSA02225) registers shaders about 400 times a second during its opening. It registers the same code with the same registers over and over, each time through a header at a new address. Every registration decodes the header's registers into a
RegisteredShaderState, three dense register sets of about 10 KiB, and its snapshot keeps that copy for as long as the registry holds it. In 200 s the title made 80,000 registrations: none matched a published snapshot's header address, so all 80,000 were published, and 68,144 of them (85 %) repeated the code and decoded registers of a snapshot at another header address. Only 11,856 were distinct. A jemalloc profile at 240 s put about 1 GiB of live heap underRegisterShader's register sets (InitialContextRegisterscopies, theRegistersbuilt from the user-config initializer,Registers::mark). This title's opening is where the 20 GiB memory cap ends my runs.How
RegisteredShaderStateof a published snapshot at the same code address with the same type, the same code and equal decoded registers, instead of keeping its own copy. The lookup runs under the registry mutex, next to the existing same-header check.RegisteredShaderStategets a defaultedoperator==;Registersalready compares by entries.shared_ptr<const RegisteredShaderState>), and its users copy it into aQueueStatebefore using it.Registers::Fingerprint's cache is only written on those live copies.Tested
Ubuntu 26.04.1, GCC 15.2, NVIDIA RTX 4070 Ti (615.71.09).
Ghost of Tsushima Director's Cut (PPSA02225).
maincan't take this title past its first minutes, so these runs use @EagleBearerYS'stest/ghost-9742-9717stack with #8115, #8121, #8213, #8608 and #9318, built from release libs with and without this change, plus a local counter of registrations. Each run is warm, 200 s, with a 20 GiB cap. Both builds see the same registration stream: 90,000 registrations, 76,792 of them (85 %) repeating another header's code and registers, and 13,208 distinct.That's about 650 MB less at 190 s, and more earlier, where the registrations are densest.
Tests
agc_driver_prepared_shaders's shared-code case now checks the state at both points. While its two headers have different registers, they keep separate states. Once both are type 2 with the same code and registers, they hold the same state, with the header's context register in it.agc_driver_prepared_shadersfails: "two headers with the same code and registers decoded their registered state twice".^agc_driver_prepared_shaders|^agc_driver_graphics$|^agc_driver_submit$|draw_cachepass 3 of 3.mainagainst this branch over^agc_driver_prepared_shaders|draw_cache: 24 of 24 pass on both, with no VUID on either. GCC 15.2 crashed (an internal compiler error inPm4.hpp) buildingagc_driver_draw_cache_relocation_testson themainside, so that one test ran from an earlier build there.ANYPS5_REQUIRE_VULKAN=1): the same 25 tests pass 3 of 3 on this branch and on its merge base.Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T03:21:00Z.
Review: APPROVED
Reviewed exact head
e118657d4d. The implementation shares only immutable decoded register state across snapshots with the same code address, type, code bytes and decoded state; prepared state remains per snapshot. I found no correctness issue in the diff. The focused regression checks both non-sharing when registers differ and sharing after they match. The PR reports 25 focused tests passing 3/3 and matched main/change validation runs with no VUIDs.Eligibility, conventions, intake, labels and report checks pass. The hosted product build jobs are skipped, and I have not run the GPU tests locally because this environment has no Vulkan device.