perf(agc): linear color targets in registered guest memory get a resident image #1191
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1191"
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 MichonGoddijn231849 on 2026-10-07T17:03:50Z.
What
With
APS5_RESIDENT_LINEAR_TARGETS=1, a linear color target in registered guest memory gets a resident image like the tiled and 4 KiB standard targets, whose results reach memory through the image's write-back. Before, the GPU was drained before and after every draw into it. GTA V renders two small linear targets per frame.APS5_NO_RESIDENT_LINEAR_TARGETS=1copies them in and out as before.RegisteredReadableCovers, which this decision calls for every color target of every draw, copied the whole allocation registry per query. The readable ranges are now copied once per registry generation per thread (readTarget 50 to 4 µs per draw in GTA V Performance mode).APS5_NO_REGISTERED_COVER_MEMO=1takes a lease per query.It is off by default since the rebase. The resident image's host import unwatches the target's 64 KiB write-watch block, and main's
WriteWatchCoveragerestores only whole blocks when memory is committed again, so a later allocation of less than a block there stays unwatched.agc_driver_pixel_ancillary_wordandagc_driver_pixel_fixed_point_position(added onmainafter this PR) catch that; both pass with the switch off. Turning it on by default needs the coverage restore to handle partial blocks first.Tested
Windows 11 Pro, AMD Ryzen 5 7600, NVIDIA GeForce RTX 5080 (driver 32.0.16.1074), 32 GB, MinGW-w64 GCC 15.2.0.
gta-v/testingbranch (Performance mode, the prologue). GTA V Performance mode, the prologue's bank interior: about 11.0 to 11.7 fps.ctestpasses. Not run here: the relinker's Python tests (my local Python does not find their helper modules) andguest_gameupdate.maina56c905df(2026-10-13), starting from gjonn's rebase of this series onto6ac63bf0c(thanks). On Windows (MinGW GCC 15.2, RTX 5080) the wholeagc_*suite passes on the top of the series: 483 tests, 1 skipped (agc_driver_stencil_ref_export).Checklist
main; no other open PR implements the same functionsNotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-09T08:32:53Z.
Parked as a draft to keep my rebase load sane after #639. I'll rebase it when someone wants to review it.
Imported from boykopovar/AnyPS5. Originally posted by JAB-dev on 2026-10-11T16:44:16Z.
Same setup (Hot Shots Golf 2, Windows, RTX 4070 SUPER), on top of pipelined draws, with
APS5_NO_RESIDENT_LINEAR_TARGETS=1vs default (2 runs each):So the resident image helps this title too, mostly in the worst moments.
Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-13T16:25:23Z.
Rebased onto current
main(a56c905df) on top of the rebased #494, and ready for review.One change: resident linear targets are now opt-in (
APS5_RESIDENT_LINEAR_TARGETS=1). The resident image's host import unwatches the target's whole 64 KiB write-watch block, andmain'sWriteWatchCoverageonly restores whole blocks when memory is committed again. A later allocation smaller than a block there stays unwatched, whichagc_driver_pixel_ancillary_wordandagc_driver_pixel_fixed_point_position(added onmainafter this PR) caught. With the switch off by default, theagc_*suite passes on Windows. Making it the default needs the coverage restore to handle partial blocks first. TheRegisteredReadableCoversmemo is unchanged and still on.Imported from boykopovar/AnyPS5. Originally posted by fma-rc on 2026-10-13T16:26:22Z.
9c2ddf3a8 does not build on Linux here (Arch, GCC 16.2.1):
prx/libc/include/HostThreadLocal.hppis included only inside the#ifdef _WIN32block at the top of the file, and line 2061 is compiled on both platforms. I built the stack up to 1201 (31c9a0f2e): with the include moved above the#ifdefit builds, and theagcand shader tests pass (490 of 490, NVIDIA). The Linux job is skipped in this PR's checks, which is probably why it did not show up. The same error stops the builds of the PRs stacked on this one.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T00:10:29Z.
9c2ddf3a8 doesn't build on Linux:
GuestBufferMemory.cpp:2061usesHostThreadLocal, whose include is inside the#ifdef _WIN32at line 15.With resident linear targets now off behind
APS5_RESIDENT_LINEAR_TARGETS, this adds a path main doesn't run. Could you split it? TheRegisteredReadableCoversmemo on its own on main, without the opt-out switch and with the summary lines of main and of the change; the resident targets later, on by default, onceWriteWatchCoveragerestores partial blocks.Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-14T08:34:01Z.
Thanks, and @fma-rc for the Linux report: the
HostThreadLocalinclude belongs above the#ifdef _WIN32; that goes in with the next push.On the split: on
mainthe memo has no per-draw caller.RegisteredReadableCoversis called only for largeDMA_DATAcopies (PacketMemory.cpp:158) and storage write-backs (Texture.cpp:4586); the per-draw query (every color target of every draw) is the resident-linear decision this PR adds. So the memo alone would show no difference in the summary lines.I'd rather keep the two together: I'm moving this to draft until
WriteWatchCoveragerestores partial blocks, then it comes back as resident linear targets on by default with the memo and without the opt-out switches, and with the summary lines ofmainand the change (GTA V Performance, where the two linear targets per frame are). If you want the memo in earlier anyway, I can open it on its own.Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-15T15:40:46Z.
Rebased onto current
main(92e50418f). Since #494 is onmainnow, this is down to its own commit (fa87a4422).HostThreadLocalinclude moved above the#ifdef _WIN32, soGuestBufferMemory.cppbuilds on Linux (thanks @fma-rc, @oneandonlydean).RegisteredReadableCovers:mainnow walks the range across adjacent registered allocations and returns the pieces. The memo keeps that walk: it stores the readable ranges sorted with their writable and GPU flags, steps through them the same way and fillspiecesalike.APS5_NO_REGISTERED_COVER_MEMO=1runsmain's lease walk unchanged.Builds on Windows (MinGW).
agc|shaderctest: 598 of 599. The one failure,agc_driver_image_plane_address_on_line(an LOD 1.25 blend of a 1D texture read as 2D: 67.5 against 60), also fails onmain92e50418fwith this commit reverted, so it isn't from this PR.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-16T22:36:21Z.
#6892 now covers the default-on part of this on current main: a linear target whose memory already has a host import gets a resident image, and the draw stores back with
FlushPending. Itsagc_driver_linear_target_residentfails without that store-back on a 4090, a 3070 and lavapipe. The two now conflict inDraw.cppandState.cpp, so I'd like to take #6892 first. What's left here is the case that creates the import itself, which still needsWriteWatchCoverageto restore partial blocks, as you said on the 14th. Could you close this, or move it to draft, and bring that case back on top of #6892 once partial blocks are in?Imported from boykopovar/AnyPS5. Originally posted by MichonGoddijn231849 on 2026-10-17T07:50:53Z.
Makes sense, take #6892 first. I moved this to draft. Once partial blocks are in
WriteWatchCoverage, I'll bring back the case that creates the import itself, on top of #6892.Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-21T15:13:06Z.
A title that needs the case this draft is waiting to bring back, with AMD Windows numbers.
PPSA14363 (METAL GEAR SOLID Master Collection Vol. 1) draws its PS1 games into three linear 3072x2048 R8G8B8A8 color targets of 24 MiB each. None of them has a host import. On
mainevery draw into them is synchronous, and the PS1 intro makes up to about 80 of them per frame. Measured on an RX 6700 XT with AMD's Windows driver 32.0.21045.5002.I tried this draft's case as a local switch on top of #6892: the draw path calls
HostImportForinstead ofExistingHostImportForfor a linear target. The targets became resident and no draw stayed synchronous. One run each, compared on the same content by aligning the guest flip counts:main(synchronous)In the heavier scene after that, the import case drops to about 10 flips/s. What remains is #6892's store-back after every draw. Per 10 s:
linear targetwrite-backs, each of the whole 24 MiB target, 72 to 76 GB in total;So for a target that takes many draws per frame, that store-back is the next limit. #8246 changes the same store-back.
On the blocker you named: #6759 merged on 10-20. It keeps write-watch exclusions as 4 KiB page masks and restores re-committed pages inside an excluded block, which is the partial-block coverage you were waiting for. I have not run
agc_driver_pixel_ancillary_wordoragc_driver_pixel_fixed_point_positionwith the import-creating case on currentmain.Separately, #9188 and #9202 make the synchronous path cheaper for these draws without an import. They touch other parts of
Draw.cppthan the residency decision.I can rerun the title on your branch when you bring the case back.
Imported from boykopovar/AnyPS5. Originally posted by thuanquang on 2026-10-22T05:17:39Z.
@MichonGoddijn231849, partial-block coverage is in: #6759 merged on 10-20. Is bringing back the case that creates the import still on your list, as you planned on the 17th?
PPSA14363 needs it. Its three PS1 linear targets have no import, so every draw into them is synchronous, and main with #9188, #9202, #9373 and #9602 sits at about 19 fps in the PS1 codec. On the store side, I proposed in #9217 to store these targets at completion points, limited to the drawn rectangle, instead of after every draw. I'm implementing that now.
If you'd rather not take the import half now, I can open it as a separate PR on top of #6892 that credits #1191 and reuses your
RegisteredReadableCoversmemo where it fits. Would that be OK with you?Pull request closed