Repository navigation
fix(agc): share a registered shader's decoded state with its other headers - #9991
Conversation
…aders Every registration decodes the header's registers into a RegisteredShaderState: three dense register sets, about 10 KiB, kept by the snapshot for the life of the registry. A title that registers the same code with the same registers at another header address got a copy each time. Ghost of Tsushima does that for 85 % of its registrations, about 400 a second during its opening, so by 200 s 68,000 of its 80,000 snapshots held a copy of a state another snapshot already had. A new snapshot now takes the state of a published snapshot at the same code address whose type, code and decoded registers are equal. The state is immutable once published, and its users only copy it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MarcZX10
left a comment
There was a problem hiding this comment.
Reviewed exact head e118657. 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.
|
Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
|
|
Thanks @MarcZX10. The Windows run has finished since your review: on the Windows 11 VM (GeForce GT 1030, R580), the same 25 tests pass 3 of 3 on this head and on its merge base. It's in Tested now. AI-assisted: yes (Claude Code) |
|
Ran the same focused tests on main (6b2d6af) and on this PR (head e118657, tested as GitHub’s merge commit 2552be7 with that main) with ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1 and VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, using ctest --test-dir build -R "^agc_driver_prepared_shaders$" -V. GPU: NVIDIA GeForce RTX 3080, NVIDIA driver 617.42, Windows 11 Pro build 26200 |
|
@VakzOs thanks for the validation-layer run on the RTX 3080. A clean pass against AI-assisted: yes (Claude Code) |
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