perf(agc): reuse a texture the sampled cache refuses while frames keep using it #12575
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/12575"
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 QRMOE on 2026-10-28T21:15:47Z.
What
When the sampled-texture cache is full of textures used in the current present,
admitTexturerefuses a new texture. Before this change the refused texture was returned for that one lookup and dropped, so it was built again from guest memory at its next lookup. A title that looks up the same image-table textures in many draws rebuilt each such texture many times per present.In RESIDENT EVIL requiem (PPSA31246), the counted rebuilds in its first level, at default settings, were:
Diagnosis and per-run numbers are in #12190 and in the bring-up thread #11599.
This PR keeps a refused texture in a table on the
TextureCache(transient) for as long as each frame keeps using it:serves: the view and source checks,unchanged,kept,equalsCommitted). A transient view also needs its storage image to still be cached.admitTextureagain, so the existing second-use rule still moves the texture into the cache when the LRU entry was not used this present.ClearCachedTexturesclears the device's textures. Under memory pressure,ReleaseTextureCachesfrees transient textures nothing else holds before it evicts cache entries. A dropped texture still held elsewhere is marked released, as an evicted cache entry is, so resource sets binding it are not reused.TransientSnapshotBytes); beyond that they go to the spare pool, and such an entry is reused only when a write-generation proof holds.cache.bytes. They were already alive for as long as a recorded batch held them.Fixes #12190.
Tested
Windows 11 (26200), Ryzen 7 9800X3D, RX 9070 XT (AMD 26.6.2 / 32.0.31021.1015), MinGW GCC 15.2, Release. The base is
main4f41f4c375(merged into the branch asfd4f1433b5; the one conflict, incachedTexture, keeps thetransientlookup beforemain'sSampledClearColor/noSnapshotlines).New and changed tests (
tests/execution/SampledCacheBudget.cpp):refusedReuseTests:frameTestsandsecondUseTestsasserted the old rebuild-per-use behaviour; they now assert reuse.frameTestschecks that the next frame over 6 textures, with room for 4, finds all 6: the 4 cached and the 2 refused in the frame before. The second-use admission check is unchanged.main'sShaderResources.cppand these tests, both sampled-cache suites fail at "surface 4, refused by a cache full of this frame's textures, was not kept for the rest of the frame".408f4375cc), they fail at "the next frame over the same 6 textures found 4 of them".Validation layer,
ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1 VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation VK_LOADER_DEBUG=layer ctest --test-dir build -R "agc_driver_sampled_cache_budget|agc_driver_resource_cache|agc_driver_recover_" -V, same machine and GPU:maincode, these testsmain's own tests pass 15 of 15)fd4f1433b5)VUID-linesThe loader log shows
VK_LAYER_KHRONOS_validationinserted in both runs.Keeping refused textures across presents (
44bd48ea5f), requiem's first level, same local integration branch withAPS5_PROFILE_DRAW:Astro Bot (PPSA21564), A/B by mrfelek with paired
mainand PR traces and summary lines, on Linux with an RTX 3080 Ti: comment, traces in themrfelek/AnyPS5release perf-12575-traces.Sky Garden (
underwater_aerial_garden), Astro Bot 01.007.000, the same machine, scene and trace window (APS5_TRACE_SECONDS=200:20).mainiscbed915291; the PR side is thatmainwith this PR's head44bd48ea5fmerged, built ase83e266d99c9. Both runs are by mrfelek; the files areastro-skygarden-M1-*(main) andastro-skygarden-P1-*(PR) in the release above.tools/trace_digest.pyheadlines:main: seconds 200:20 from present 726: 4 presents, frame p50 6178.0 / p90 7223.4 / p99 7223.4 / max 7223.4 ms, GPU busy 1467.8 ms per presentPaired
aps5-summary.jsonllinesmain:PR:
Title run (not yet a clean A/B): RESIDENT EVIL requiem on a local integration branch (
main74acfad65bplus several open PRs needed to reach the level). With an earlier version of this change, plus a local sampled-budget experiment not in this PR, the first level held 10.5–13.6 s/frame, flat for 45 minutes. The same integration without the change reached 30–60 s within 26 minutes. In the level, texture creations fell to about 1 per texture per present. Atools/trace_digest.pycomparison ofmainand this PR alone, from the same machine and scene, is still to be done, so this PR does not claim a number yet.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
Summary by CodeRabbit
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-28T21:21:23Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The cache reuse change and reported correctness validation are reviewable, but this
perfPR is missing the required same-title, same-scene, same-machine captures andtrace_digest.pyoutput, so the performance result is not established.What I ran
408f4375cc57b5f1a9574d14b0791031ed7e7d30against base319621ba2e578bd053b0baba2877fe70520e0737; merge preview is clean (55ddb65cd67428522cc44982942a203623b26527).Results
mainVUID-lines and no missing-layer messagetrace_digest.pyCommand and CI output
Negative control
main'sShaderResources.cppand unchanged testsFindings
Blocking
perf(...), and the repository requires amainand changeaps5-summary.jsonlline from the same machine and scene, attached traces, andtools/trace_digest.pyoutput. The description explicitly says themain/change trace comparison is still to be done, and the automaticperfcheck also reports those artifacts missing. Please add the paired captures and digest output before this performance change is considered ready.Non-blocking
Sources
CONTRIBUTING.mdlines 68–70, pinned to current baseNot verified
I did not run a local build, CTest, GPU validation, or performance capture. The PR's GPU test and title observations are author-reported; the hosted Linux product workflow was skipped.
To get this to a good state
Please attach the matching
mainand PR-head captures from the same title, scene, and machine, include both summary lines, and addtools/trace_digest.pyoutput. I will recheck the new head and verify the report artifacts and relevant checks.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-31T12:54:28Z.
Review: CHANGES_REQUESTED
Re-checked — changes requested
The new comment adds useful measurements, but the required paired capture artifacts are still not available for verification.
What I ran
Reviewed head
44bd48ea5f2cf29fb5b65e61d68f5fea65eb7bf2against base319621ba2e578bd053b0baba2877fe70520e0737; both remained unchanged during precheck. No local GPU test or capture was run.Results
Negative control
Not applicable to this performance-evidence re-check; no code or tests changed.
Findings
Blocking
aps5-summary.jsonllines formainand this PR from the same title, scene, and machine. The linkedperf-12575-tracesrelease does not resolve, so I could not inspect attached traces or verifytools/trace_digest.pyoutput. Please attach the traces and digest output and paste the matching summary lines. The repository's performance-report rule requires paired summaries and attached traces for aperfPR.Non-blocking
Sources
Not verified
No local build, GPU validation, console test, trace digest, or performance capture was run. The reported GPU validation results are author-reported.
To get this to a good state
Please add accessible trace files, the output of
tools/trace_digest.py, and the matching raw summary lines. I will recheck the artifacts and relevant checks on the exact head.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-14T06:30:14Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reviewed implementation and tests support the transient reuse and release behavior.
What I ran
Reviewed head
a05ea8be2a43b8f4e0c716468d7b7446bae6033cwithrepo_read.pythrough the pinned reader. No commands or tests were run. The author reports validation-layer and performance runs in the PR description; I did not run them.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
I read every added line listed for
ShaderResources.hppandSampledCacheBudget.cpp, and all changed implementation hunks inShaderResources.cpp, plus the related cache admission, release, resource-cache, present-count, and caller code. The full text ofShaderResources.cppwas excluded from the review bundle because it was too large; I read only targeted ranges through the pinned reader. I did not run tests, builds, physical console checks, or independently verify author-reported performance measurements. The referenced issue and external traces were not inspected.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-28T17:42:23Z.
Review: COMMENTED
Actionable comments posted: 6
ca122b42-95d1-417c-945d-26545ad770b3Reviewing files that changed from the base of the PR and between
073e0313f3and71eef3b862.core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/cmake/agc_driver_sampled_cache_budget_tests.cmakecore/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by coderabbitai[bot] on 2026-11-28T17:55:33Z.
Review: COMMENTED
Actionable comments posted: 4
fd85b07d-0906-4393-a284-89142ae2aa7eReviewing files that changed from the base of the PR and between
71eef3b862and34ca8fbf8d.core/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/tests/execution/SampledCacheBudget.cppIncluded review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-28T17:59:08Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the review covered the sampled texture cache logic, pressure release path, and changed sampled cache tests.
What I ran
Reviewed head
34ca8fbf8d9b3d4d7be3cc7f18b57517c90ba5ffusing the prepared diff and pinned reader. No commands or tests were run.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
Full text of
ShaderResources.cppwas excluded from the review folder; targeted ranges covering transient lookup, insertion, and pressure release were read throughrepo_read.py. The included changed files read wereShaderResources.hpp,agc_driver_sampled_cache_budget_tests.cmake, andSampledCacheBudget.cpp. No files were excluded by other rules; the oversizedShaderResources.cppwas excluded from the folder but inspected at relevant ranges. Tests and performance measurements described in the PR body were not independently run.To get this to a good state
Nothing is required.
Imported from boykopovar/AnyPS5. Originally posted by ligmaSec on 2026-12-03T22:56:32Z.
Review: COMMENTED
The trial merge conflicts in
ShaderResources.cppand sampled-cache budget test registration. The new pressure fixture proves unreferenced refused textures can expire. Please also retain a refused texture through an open batch, alter its guest backing, and check that the next lookup gives current data while the first batch keeps its original image. The weak reuse map must preserve both in-flight lifetime and freshness.AI-assisted: yes.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.