fix(shader): share resource plans loaded from the same disk cache payload #10496
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10496"
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-24T04:24:34Z.
What
A shader source whose resource plan comes from the disk cache decodes its own copy of it (
getSource→ShaderDiskCache::LoadPlan), including when another source has already decoded the same plan. The same code registered under another plan key (another host subgroup size or interface) stores byte-identical plan entries, so a warm run holds the same decoded plan, its compact form and its compiled SRT tape several times.DecodePlanandbuildCompactPlanhold about 720 MiB of live memory. The title is killed by its 20 GB memory cap in its opening.How
LoadSharedPlan(key, shaderHash)replaces the load ingetSource. A loaded payload is looked up in a table of weak references, keyed by twoHashBytesof the payload (two seeds), its size and the shader address the plan is given. An equal entry that a source still uses is returned as is. Otherwise the payload is decoded, given the address and published. The table only refers to plans and never keeps one alive; expired slots are dropped every 1,024 inserts.IrResourcePlanisconstonce loaded (source->plan), and its SRT tape is compiled from its content, so sources sharing a plan share the tape too.Tested
Ubuntu 26.04.1, GCC 15.2, Release, RTX 4070 Ti, NVIDIA 615.71.09. The commit was tested as
a428c3ab4fonmain379b1dca32and is unchanged (git range-diff) on the current head38ac888dbb, rebased ontomain6c52b649e7.verifySharedPlansinagc_shader_disk_cache. It writes one plan's entry under two keys, then checks that loading both for one shader address gives the same plan, equal to a fresh decode of the payload with that address. Another address gets its own plan. Once both references are dropped, the plan is released, and a later load decodes it again.test/planshare-mut), it fails 3 of 3:two plan entries with the same payload for one shader decoded into separate plans.^agc_shader_disk_cache|^agc_shader_memory$|^agc_shader_|resource_plan|^agc_driver_graphics$pass 3 of 3 onmain379b1dca32and ona428c3ab4f.^agc_shader_disk_cache|^agc_shader_memory$|^request_serializer$pass 3 of 3 onmainat the merge base and ona428c3ab4f.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation ANYPS5_NO_SHADER_CACHE=1 ANYPS5_REQUIRE_VULKAN=1on the 5 tests matching^agc_shader_disk_cache$|^agc_shader_memory$|^agc_driver_graphics$|^agc_driver_pipeline_journal$|^request_serializer$: 5 of 5 onmain379b1dca32and ona428c3ab4f. Neither log reports the layer missing, and neither has a VUID.RssAnonat 2 / 4 / 6 / 8 / 10 / 12 min was 3,756 / 4,497 / 5,720 / 6,929 / 7,067 / 6,821 MB against 3,964 / 4,413 / 5,351 / 6,351 / 6,843 / 7,464 MB. That is within this title's run-to-run spread, which other runs show at over 1 GB in its opening, so this title doesn't resolve the saving. The disk cache duplication above is the direct measure.Not checked by me: AMD, Intel, macOS.
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