fix(agc): keep a build's own texture lookup records past the log bound #6944
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6944"
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 EagleBearerYS on 2026-10-16T20:45:38Z.
What
The sampled-texture lookup log (
logLookup,Graphics/src/ShaderResources.cpp) keeps at most 1,024 records and drops its oldest half when it's full. Its comment assumed one build's lookups were "a few dozen at most".captureValidationthen finds no record for those textures. Every laterRevalidatefails the fast proof withno recordand walks every texture.The fix:
buildCompleteandRevalidate's full walk mark where their own records start, through a small RAII guard,BuildLookups.[rescache] revalidateprofile line counts the builds and full walks that kept their records past the bound.The title. Resident Evil Village (PPSA01556) binds about 2,000 textures per draw at its main menu.
logLookupis byte-identical there, in mainf474fb7768, and in our three-title base: main plus only what Resident Evil Village needs to reach the menu. So the bound is hit the same way on all three. The base's own line, and an unprofiled before/after pair at the menu (presents per 10 s and p50), will be added with the next Resident Evil Village run; none is scheduled yet.no record, at 2.32 ms each against 0.078 ms for a fast proof.Driver::commitDrawholds it acrossVulkanDevice::Draw, so the other queues wait on it too.Cost of the fix:
be77a9d7bd(from CnRJay's review), when the outermost build ends the log keeps only its newest 1,024 records, aslogLookupwould, and gives back its capacity once that is over 1.5 times the bound. A thread therefore holds at most the bound's 139,264 bytes after an oversized build. The trigger is 1.5 times rather than twice the bound because libstdc++ doubles the vector, so every build of 1,025 to 2,048 records ends at a capacity of exactly 2,048 (twice the bound). A log within the bound never reaches 1.5 times it: at most 1,024 records with libstdc++ and libc++, and 1,066 with MSVC's growth by half.captureValidation, which searches the log backwards for each texture. On main, that build searched only the half of its records it still had. It then paid a ~4.3 ms full walk on every later use.captureValidation, which this PR changes, so it opens as its own PR once this one lands.How: one commit,
fix(agc): keep a build's own texture lookup records past the log bound. It holds the fix and the new testagc_driver_lookup_log_fits_build(tests/execution/LookupLogFitsBuild.cpp).ShaderResourcesfor it, which must be reusable and bind 1,500 sampled textures.Tested
Linux (lavapipe, Mesa 25.2.8, gcc 13.3, CI's Linux configure), on main
f474fb7768:logLookup: 5/5 fail withctest -R '^agc' --parallel 4 --timeout 120: 627/627 with the fix, against 626/626 on main, with the same 44 skips.tools/check_test_registration.py: 919 test executables, none new and unrecorded.be77a9d7bd, the shrink (Linux, lavapipe, CI's configuration): after its 1,500-texture build,agc_driver_lookup_log_fits_buildnow requires the thread's log capacity to be at or under the bound, and again after the full walk. The fourRevalidatechecks are unchanged.^agcpasses 626 of 627 (44 skipped) twice; the one failure both times isagc_driver_preparation_scope_settle, a timing check under the sweep's parallel load that passes 11/11 alone.agc_driver_graphicspass 10/10; on Windowsagc_driver_graphicspasses 10/10 and the lookup log test skips without a Vulkan device. The^agcsweeps' only failures are the settle check on Linux andagc_driver_pm4_replay_tool(0xc0000139) on Windows, which fails onmainthere too, and the suites' areprecise_waiton Linux andguest_kqueueon Windows.GitHub runners (run 38961983024):
logLookup; green 20/20. The libc and libkernel suites show no new failures.precise_waitfailed once on main's side there, a known flake on that runner.guest_kqueuefails there with and without the change.Cost on a dispatch-binding harness (lavapipe; a plain compute program indexing a texture heap; µs per dispatch, median of 5 windows). The harness isn't part of this PR.
no record. With the fix it made 63,230 fast proofs and no full walk.Draws take the same path (
buildComplete, andRevalidate's full walk), so Resident Evil Village's draws are covered. The title hasn't been run with the fix yet; the before/after pair above comes with its next run.AMD Radeon 780M (RDNA 3, AMD driver 25.10.20.01), Windows 11 (WinLibs GCC 15.2.0, Release), run by keravyn-ops at
be77a9d7b(comment):agc_driver_lookup_log_fits_buildpasses.tools/check_conventions.py: passed.Overlap. On main
36c69d5cc6, the overlap check finds two open PRs that conflict with this one. 13 others that touch this file conflict with main themselves, so it couldn't compare them. Merged against this PR's head by hand:refreshForView, and alayersparameter to thecachedStorageTexturedeclaration, right afterlogLookup. That's where this PR addsBuildLookups. Keeping both sides resolves it, and those three PRs meet at that same declaration themselves.maininShaderResources.cpp, far from this PR's lines, and with this PR only there.logLookup, the lookup log's bound orRevalidate.Revalidate, so the two compose.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.mdfiles or images added to the repository (attach them to this PR)Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-16T20:53:35Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL434-435core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppL434-435Some 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.
core/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppcore/libs/prx/libSceAgcDriver/Graphics/include/ShaderResources.hppcore/libs/prx/libSceAgcDriver/Graphics/src/ShaderResources.cppImported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-10-16T22:07:32Z.
Review: COMMENTED
Good PR: the cause is shown with the title's own profile line (15,528 full walks at the menu, 97.7% of them
no record, 2.32 ms each against 0.078 ms for a fast proof, about 1.0 s of every 10 s under the GPU mutex), the test fails onmain5/5 and passes 20/20, and the cost of the fix is stated.Remaining points are small:
captureValidationnow searches back through the whole build's records for every texture, so cost per build is quadratic in the texture count (the +0.3 ms at 2,000). The description defers the one-pass capture to a follow-up; that follow-up is worth opening now, since a title with a bigger table than Village's pays more than 0.3 ms.APS5_PROFILE_*, since the profile switch adds its own cost to the full walk) would turn "about 1.0 s of 10 s" into a measured gain. The description says the base's own line follows; please add it.Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-17T00:41:59Z.
@CnRJay Thanks for the review.
be77a9d7bdtrims the log when the outermost build ends. It keeps the newest 1,024 records, aslogLookupwould, and gives back the capacity once that is over 1.5 times the bound, so a thread keeps at most 139,264 bytes after an oversized build. The trigger is 1.5 times the bound because libstdc++ doubles the vector: every build of 1,025 to 2,048 records ends at exactly twice the bound, so a "more than twice" rule would never fire for your 2,000-texture example. The test now checks the capacity after its 1,500-texture build: 2,048 records without the shrink, 0 with it.captureValidationagain, so I'll open it as its own PR once this one lands.Imported from boykopovar/AnyPS5. Originally posted by keravyn-ops on 2026-10-17T09:59:29Z.
AMD / Windows run of this PR at
be77a9d7b: Radeon 780M (RDNA 3, 0x15bf), AMD driver 25.10.20.01 (32.0.21020.1007), Windows 11 Home 10.0.26100, WinLibs GCC 15.2.0 r7, Release.Every ctest entry built from the test targets this PR changes passes (1):
agc_driver_lookup_log_fits_build(2.37 s):537: lookup log fits build tests passedAI-assisted: yes (runs made on the device above).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T14:49:04Z.
Checked the
BuildLookupsguard (nesting viaoutermost, the trim never drops past the build's mark, capacity released after an oversized build), the new test (registered through thetests/executionglob; it pins fast / full / fast / full-and-refused over 1,500 textures) and the author's red/green runs plus the Windows/AMD run from keravyn-ops; merged.