fix(agc): keep sampled views that hold no cache bytes out of the released set #17573
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17573"
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 NFSS10 on 2026-11-08T23:02:30Z.
What
A sampled texture that the texture cache drops while a descriptor set still holds it is marked released, and
ResourceCache::Insertrefuses every descriptor set that holds a released texture and removes the entries that do. The marking also covered the entries that account for no cache bytes: the views of cached storage images. Dropping such an entry frees nothing, but it invalidated every descriptor set that sampled the surface, so those descriptor sets were built again on every use.In The Bendy and the Ink Machine the 4K RGBA16F scene surface is written by a compute dispatch and sampled by the draw that follows. Its storage image leaves the storage cache every frame, so its sampled view was dropped and marked released every frame, and the descriptor set that sampled the surface was discarded and built again every frame. The main menu then washed out to white about 30 s after the title reached it, the symptom PR #4794 had fixed before the released-texture mechanism landed in #6492.
Only the entries that account for cache bytes are marked released now. A view of a cached storage image is dropped from the sampled cache without marking its texture, so the descriptor sets that sample the surface stay cached and the menu keeps its colour. A view of a storage image that is not cached accounts the image's bytes and is still marked released, so the memory the released-texture mechanism reclaims is unchanged.
The debt entry for the released-texture mechanism names the exemption.
Tested
mainand on this branch, same machine and build tree: onmainthe menu washes out to white (mean RGB 249, 249, 246 over the frames dumped from the menu onwards); on this branch it keeps the menu colour (mean RGB 120, 87, 16.5) for the whole 55 s the game watched the menu.ctest --test-dir build -R 'sampled_cache|staged_clear|resource_cache|texture_cache': 16/16 pass onmainand on this branch, withANYPS5_REQUIRE_VULKAN=1andANYPS5_NO_SHADER_CACHE=1. The check added toviewEvictionTestsfails without the fix ("a view that accounted for no cache bytes was marked released when its entry left the sampled cache, which frees nothing and rebuilds every descriptor set that holds it").ctest --test-dir build -R '^agc_driver_': 1047/1058 pass, 15 skipped. The 11 failures are the fp16, mesh, sdwa and vop2 shader tests that fail on this machine without this change: the same 11 were run againstmainin the same build tree and 10 fail there too (agc_driver_unregistered_label_on_gpuis flaky and fails onmainin other runs).python3 tools/check_conventions.py --base upstream/main: 0 errors (the debt entry it warns about was already over the 1000-character limit onmain).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)Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-20T15:58:23Z.
Review: COMMENTED
Reviewed — no blocking findings
Nothing in the inspected change shows a blocking defect; the patch exempts sampled cache entries with zero accounted bytes from released-texture marking.
What I ran
Reviewed head
e23c6c759b0e7dbdc7d8dfc7ba4758d8debbecd4usingrepo_read.pyto inspect the prepared diff and relevant source lines. No commands or tests were run.Results
Findings
Blocking
None in the inspected code.
Non-blocking
None.
Not verified
The full text of
ShaderResources.cppwas excluded from the review folder; only lines 270–355 and targeted search matches were read throughrepo_read.py. The test file’s relevant changed function and the new debt entry were read in full. No test output, full-file behavior, or Vulkan validation was independently verified. Files in the prepared bundle:ShaderResources.cpp(excluded as too large),SampledCacheBudget.cpp, andfix-agc-uncached-view-release.md(both included).To get this to a good state
Nothing is required.