perf(agc): keep the cached address space for a read-only V# across two imports #5428
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5428"
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 alfalfa-star on 2026-10-13T19:28:03Z.
Why
Kena: Bridge of Spirits (PPSA01802, UE4) spends most of its driver time rebuilding the resources of address-based draws once its first level loads. Most of those builds hit the cached address space, but about 70% of them then dissolve it. A read-only V# crosses the boundary between two adjacent registered ranges that are imported separately, for example
0x20163a0000+0x240000over0x20163a0000-0x20165c0000and0x20165c0000-0x2016650000.addDescriptorRegionsees a partial overlap with the space and callsdissolveSpace, which merges all of the space's ranges (about 9,000 in that scene) into the build.UploadPreparethen sorts and merges them, andUploadFinishandAddressRangeswalk them, on every such draw.What
AddReadable) that partially overlaps the space's ranges no longer dissolves the space, unless one of the overlapped ranges is an image mirror. The region is added to the build's own regions and copied, as it was after a dissolve. Its BDA table entry is read-only, as the merged copied region's was.Tested
Linux (Arch, kernel 7.2), RADV RX 9070 XT, Release.
spaceReadAcrossImportsTestsinagc_driver_graphics: three 64 KiB ranges with a 128 KiB import window give two imports. A read-only V# across their boundary must bind the bytes of both ranges, keep both imports in the BDA table, and, on the second build, hit the cached space without a dissolve. It passes with the change. Without it, it fails witha read-only V# across two imports dissolved the cached address space.ctest: 1070 of 1071 pass.agc_driver_tessellationsegfaults on this machine on plainmainas well.mainagainst this branch alone, and no trace attached; I can capture them on request. The comparison switched this change off together with a second local change (reusing draws whose read-only buffers were copied), so the numbers below are for both. Address-space dissolves drop from about 38 to 0 per 10 s, and the average number of regions in an address-based build from 225 to 3; those two come from this change.Graphics::Drawdrops from 683 to 390 us per draw packet. Presents go from 10-21 to 81-89 per 10 s in the middle of the run, and from about 19 to 33-41 in the heaviest part.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
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T23:05:56Z.
Two things before this can go in:
mainand ofmainplus this PR from the same scene, with the traces.addDescriptorRegion, GuestBufferMemory.cpp:2477). Onmainboth use the one merged region. Please keep the dissolve when a write range overlaps the copied region, or add a test that shows the two views stay coherent.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T02:50:20Z.
Rebased onto main to resolve the conflict in
tests/BdaResources.cppafter #290; no other change.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T04:25:12Z.
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/include/GuestBufferMemory.hppL392-393Imported from boykopovar/AnyPS5. Originally posted by alfalfa-star on 2026-10-14T05:39:02Z.
@oneandonlydean thanks for
e5d65569eandfd2c300e4, the dissolve for a written V# over the copied read-only range and its test. That covers the coherence point.On the numbers: I can't take a
maincapture of the Kena (PPSA01802) scene yet. Plainmain(aa1927872, this PR's base) aborts before the title scene, before the trace window opens:It stops the same way with #5573 on top. My earlier numbers came from a local stack that skips draws which throw, which is why the description doesn't present them as
mainagainst this PR. I'm looking into the range-limit stop now. Once a base reaches the scene, I'll post the summary lines and traces of base and base plus this PR from the same session.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T05:42:55Z.
Pushed two commits on top so this can go in. If a written V# overlaps a read-only V# that is copied across two imports, the space now dissolves, in either order of the two, as it does on
mainwithout this branch. That way both bind the one merged region. If no written range overlaps, the space stays as before. The newspaceReadAcrossImportsWrittenTestsintests/BdaResources.cppchecks that the written and the read-only V# map the shared bytes through one buffer at matching offsets, and that the space dissolves. It fails on the previous head ("maps other bytes than it") and passes now. Full build is green onfd2c300e46.One run of
main+ this PR, as an indication only (n=1, nomainrun from the same session to compare against): PPSA21564 first level,APS5_TRACE_FRAMES=4300:80, RTX 4090, NVIDIA 610.57.04, Linux, 3840x2160. Frame time p50 21.15 ms, p90 23.30 ms; GPU busy 14.7 ms per present. Gate phases: title 23.8, menu 20.3, level 27.0 fps, in line with recentmainruns on this machine. The checkpoints look the same as onmain.This closes our earlier ask.
Imported from boykopovar/AnyPS5. Originally posted by EagleBearerYS on 2026-10-14T12:08:27Z.
Resident Evil Village (PPSA01556) stops on this change's path at the title:
Since this PR, a read-only V# that partly overlaps the cached space's base gets a region of its own, so a build's own regions can overlap base regions.
GuestBufferMemory::owner()still assumed they don't. For this 1.7 MB view it returned the base region of one 64 KiB mapping, andDescriptorrefused the view. A dissolve afterUploadPreparereaches the same lookup during the first scene load. #5815 fixes both. Its description has the details, a test that fails onmainwith this message, and the runs.Setup for the stop:
main23be5a02bwith #5688 and #5703, plus local test commits listed in #5815. Windows 11, RTX 3070 Laptop, driver 617.42.