perf(libSceAgcDriver): keep storage surfaces tracked around unwatching host imports #4448
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4448"
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 Mouad-Scriptz-0 on 2026-10-12T11:56:11Z.
What
On Intel's i915 a
VK_EXT_external_memory_hostimport resolves the guest write watch of its pages (the start-up probe reports "host imports resolve write protection: yes"), so the driver stops trusting the watch for every imported range and a storage surface in such a range compares its whole guest copy with its snapshot at every use. Minecraft (PPSA17221) keeps about 250 such surfaces, atlases of 4 MiB among them, and its render thread ran at 89 % CPU with every stack sample inStorageTexture::Refresh→compareUntracked→memcmp, with the GPU idle. Three causes stacked up:shrinkImportWindow, 64 KiB): a buffer's import leaves its neighbours watched. The existing window test keeps the 8 MiB behaviour for other devices;agc_driver_bda_resourcesgainsunwatchedImportWindowTests: afterSetImportWatch(Unwatch)an import covers the allocation it serves, a view across two allocations is refused, and the import is reused.StorageImportForuses an existing import but does not make one for a range the watch still covers on such a device (ExistingHostImport,HostImportsUnwatch); the staged paths serve the upload and clear sites. A refresh with a pending alias, a copy source and a write-back still import: the device path needs the import, and the staged upload's CPU read would flush the alias's results instead of borrowing them.RetireIdleImports,GuestMemory::Rewatch); a surface without a guest copy under a range an import unwatches takes one at once (StorageTexture::NoteRangeUnwatched). Minecraft imports a texture's allocation only while its compute uploader writes it through a buffer binding; two frames later the range is tracked again and the comparisons end. A range the GPU writes every frame stays imported and compared. The retirement runs only on devices whose imports unwatch their range.agc_driver_graphicsgainsidleImportRetireTests.refreshImportsre-unwatched every unwatched import at every registry generation change (200,000Unwatchcalls in about a minute of Minecraft); it now checksGuestMemory::Watchedfirst.Tested
Fedora 44 (kernel 7.2.8, GCC 16.2.1, Ninja, Release,
BUILD_TESTING=ON, Intel Arc Meteor Lake, Mesa 26.2.3), worktree onmain33ae282e4:agc_driver_bda_resourcespasses with the new case;tools/check_conventions.py --base origin/mainandgit diff --checkpass. Minecraft (PPSA17221): the render thread no longer spends its time in the untracked comparisons (the 250 surfaces were in the neighbours of imported buffers); the home screen runs at the same frame rate as before the PR once an unrelated in-place vertex input sync is out of the way (separate PR), 60 fps on this device. Not tested on Windows, where imports are compared by design and the window change does not apply unless the probe says so.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 Scramblrrrr on 2026-10-12T12:10:05Z.
Windows/007 cross-test planning: the import-window and storage-import changes look relevant to the comparison hot spot. Before carrying the frame-scoped memo, could you add a regression for an unwatched surface changed by the CPU between two synchronized uses in the same frame (no flip)? A completed first draw/dispatch, CPU store, then a second draw is ordered, so it need not race the console; a frame serial alone cannot validate the old snapshot there. The new stamp also retains only ForgetSerial parity, so a completed forget/remap within that frame deserves an invalidation check. I have not built this head or reproduced a failure yet; these are source-review concerns, not measured Windows results. Preparing a focused comparison fixture while my current heap-corruption repro runs. AI-assisted: yes (Codex).
Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T12:13:53Z.
Focused Windows regression now available:
github.com/Scramblrrrr/AnyPS5@c4981fb102(fixture only, older integration base with #3991). After a completed write-back, Refresh + a readback submitted and waited populate/observe the untracked snapshot; a CPU memset follows; another Refresh + waited readback must see 0xabababab. No flip and no concurrent GPU use. Existing policy passes (0.36s); replacing only compareUntracked's stamp/cacheable expressions with your new policy, using constant frame serial1 because this fixture never flips, fails:untracked comparison missed a synchronized CPU store before a flip(CTest exit8,0.37s). Restoring policy passes (0.37s). RTX5070Ti, Windows, GCC15.2, native Vulkan; no skips. This is an isolated policy probe, NOT a build of full4448 and NOT a game FPS result. No failing production mutation left in the branch; no title data in this fixture. Happy to cross-test a refined invalidation policy. AI-assisted: yes (Codex).Imported from boykopovar/AnyPS5. Originally posted by Scramblrrrr on 2026-10-12T13:20:30Z.
Reviewed updated headbc616d758e740d0e6b3febee5d0936508a3afff8: the unsafe frame-scoped stamp is removed and the original comparison stamp restored, addressing the isolated policy regression I reported. The idle-unwatching import retirement/capture-on-unwatch approach needs its own lifetime and invalidation cross-test; not claiming the new full head tested or a Windows FPS gain. Currently running the 007 hull-v1 cross-test, so will keep this out until that completes. Thanks for retaining detection of ordered CPU stores. AI-assisted: yes (Codex).
Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-12T17:51:23Z.
Both points are right, and the fixture shows it well. The frame-scoped memo was a heuristic: for an unwatched range nothing can see a CPU store, so a comparison at every use is the only correct policy, and I had argued a race where an ordered store (completed use, store, second use) is legal. The existing
agc_driver_dcc_keys_first_writeuntracked-reuse case checks the same contract (refresh, CPU edit, refresh must see it, no GPU work between) and would have failed too; I had only run the graphics tests. The forget-serial parity has the same flaw: a completed forget inside the frame kept the parity and the stale snapshot.Commit 1b6c33d0b drops the memo and restores the original stamp, and attacks the cost from the other side instead: an unwatched import that no lookup used for two frames is retired at the flip and its range goes back under the write watch, with its blocks stamped as possibly CPU-written so a surface there compares once and is tracked from then on (
RetireIdleImports,GuestMemory::Rewatch). With the per-allocation import window andStorageImportForfrom this PR (now only at the sites that upload from CPU-written memory: a surface with a pending alias, a copy source or a write-back imports as before, since the device path needs the import and the staging path's CPU read would flush the alias), a Minecraft texture is imported only while the title's compute uploader writes it through a buffer binding; two frames later the import retires, the range is watched again, and the per-use comparison ends with it. A range the GPU writes every frame stays imported and compared, correctly. The retirement runs only on a device whose imports unwatch their range (the probe's verdict), so Windows and devices with watched imports keep today's behaviour.Your fixture passes unchanged under this policy, since the compare path is the original one. One more hole closed on the way: a watched surface created without a guest copy had nothing to compare against once a buffer import of its allocation unwatched it, so the import now reports the range and such surfaces take their copy at once (
StorageTexture::NoteRangeUnwatched), whichagc_driver_dcc_keys_first_writechecks.agc_driver_bda_resourcesgainsidleImportRetireTests: an import used this frame or one frame ago stays, one idle for sixty frames retires, its neighbour stays, the range is watched again when the write watch is available, and it can be imported again.agc_driver_storage_one_slice_aliasnow states the contract of an unwatching device explicitly: the watched block stays unimported and the alias writes back, where before it imported the block and skipped the check. Measured here on the Minecraft home screen: the retirement at two frames ping-ponged (80 imports and 80 retirements in 30 s, each re-stamping and re-snapshotting the range), so the bound is 60 frames now, and the rewatch stamps the range as possibly written like the import window does, since a definite CPU stamp made every surface with pending results write back. With that the frame rate matched the build before this PR; the gap I had chased (60 to 42 fps) turned out to be unrelated, an in-place vertex input waiting on the CPU for a compute write every frame, which I'm sending separately.I'd welcome the cross-test on the RTX 5070 Ti; the retirement should be inert there (host imports keep their watch on NVIDIA by the probe), so the interesting check is that nothing else moved.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T00:20:22Z.
On Windows
decideImportWatchsetsunwatchImports = truefor every device, without a probe, andRetireIdleImportsandStorageImportFor(throughHostImportsUnwatch) key on that flag. So both act there too, on the imports Windows compares, although the description says Windows keeps today's behaviour, and it wasn't run there. Please limit both to devices where the probe found that imports resolve the watch.Three more things:
33ae282e4, before #2802, which keys thecompareUntrackedmemo on the stores that reach the surface, for the same Intel compare hot spot. Please rebase and say what is still needed on top of it. It conflicts now anyway:docs/dev/TechnicalDebt.mdwas split, so the entry goes underdocs/dev/debt/.IdleImportFramesis 60.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-13T22:37:59Z.
Conflicts with main in
PacketExecution.cpp,GuestBufferMemory.cpp/.hpp,tests/BdaResources.cppanddocs/dev/debt/libSceAgcDriver.mdafter #3874, #4428 and #4515; please rebase. The probe-only limit and the debt entry are right now. The before/after for this change alone is still needed (#218).Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-14T06:09:18Z.
Status on the requested rebase — I attempted it and got partway, but I'm not posting a handoff branch because the result isn't correct yet. Details so the next attempt (mine or yours) starts from the real map:
Commit 1 (storage surfaces around unwatching) merges cleanly in spirit: main's newer guards kept, this PR's
Watched()-check before unwatch, and the test families both kept.leasedRangeAtmaps onto main'sleasedRangeOwner(shared_ptr form).Commit 2 (retire idle imports instead of memoizing) is the hard part: it restructures
HostImportForaround frame-serial tracking (lastUseFrame) wheremainhas since landed the LRUuseCounterhit path inside the same function, and addsRetireIdleImportswith theIdleImportFrames/PendingWriteSettledlogic. My assembled merge builds, but three tests fail on it —agc_driver_graphics,agc_driver_host_import_windows(fast assert), andagc_driver_recorded_kept_bytes(timeout — likely a hang in the restructured path) — so the interaction between the two hit-tracking designs needs the author's pass, not my guess at which semantics win.If it's useful I can push my work-in-progress branch for inspection, or take another run at it with the author's input on the hit-path semantics.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-14T21:32:59Z.
Still waiting on the two things from 10-13: a rebase onto main (conflicts in
PacketExecution.cpp,GuestBufferMemory.cpp/.hpp,tests/BdaResources.cppanddocs/dev/debt/libSceAgcDriver.mdafter #3874, #4428 and #4515), and a before/after for this change alone (#218). Main's LRU hit path inHostImportForis where the retire-idle commit needs to fit now.Imported from boykopovar/AnyPS5. Originally posted by blawesom on 2026-10-16T17:04:44Z.
Second rebase attempt — two of the three failures root-caused and fixed, one remains, branch pushed for inspection.
Following the hint that the retire-idle commit needs to fit
main's LRU hit path:HostImportFornow keepsmain'suseCounterhit path intact and layerslastUseFramestamping on both the hit and miss paths, so retirement works alongside the LRU rather than replacing it.Fixed 1 —
agc_driver_host_import_windows: the PR's keep condition in therefreshImportswalk gates on a lease range starting at the import's base (leasedRangeAt), which predatesmain's window-ownership model — mid-range windows get retired and re-created, changing their serial (exactly whatWindowsFollowTheirRangechecks). Resolution: the walk keys onmain'ssameRange(owner-identity for partial windows), with this PR'sWatched()guard and unwatched-notes layered inside it.Fixed 2 —
agc_driver_recorded_kept_byteshang: the PR'sStorageImportForwatched path routes throughExistingHostImport, which never callsensurePinWaiter()— so when itsrefreshImportscreates imports (which pin their ranges), a later guest free of those ranges spins forever inRequireUnpinnedwith no registered waiter. That looks like a genuine bug in the PR, exposed bymain's newer test; fix isensurePinWaiter()at the top ofExistingHostImport.Remaining —
agc_driver_store_over_untracked: "the pending result had saved guest bytes while its memory was write-watched". The test was substantially reworked onmainafter this PR branched (the PR passes its older version). The creation-path note (if (entry.unwatched) unwatchedNotes.emplace_back(...)) is unchanged from the PR, and gating the walk's note on range-start alignment doesn't clear it — so the question for the author is which note/capture conditions must hold for window imports undermain's keep model: the notification fires for a surface whose memory is still write-watched at the test's check.Current state on the branch: builds, conventions pass, 1284/1287 —
store_over_untrackedplus the knownmainregression (agc_driver_tessellationsegfault, #4727). Branch isblawesom:rebase/4448(2ea0a8ad8, your two commits, authorship unchanged) if it's useful as a starting point; the two fixes above are folded into the conflicted commit.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-17T00:41:46Z.
The second pass fixes
agc_driver_host_import_windowsand theagc_driver_recorded_kept_byteshang, and leaves one failure. The hang looks like a real bug in this PR:StorageImportForgoes throughExistingHostImport, which never callsensurePinWaiter(). @Mouad-Scriptz-0, can you take that branch, fix the remaining failure and post the before/after for this change alone (#218) from the 10-13 ask? If you'd rather not carry it, say so.Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-18T12:01:12Z.
Taken. The PR head is now @blawesom's
rebase/4448(2ea0a8ad8, both commits with authorship kept) plus one commit,924aaa4bf:store_over_untrackedfailure blawesom left is the staged upload.StorageImportForkeeps a watched surface out of its own import on a device whose imports unwatch, so such a surface takes the staged upload, and that path marked the guest snapshot valid unconditionally (layerOriginal.assign(trackedLayers, true)) where the direct path marks it valid only when the surface is not write-watched. The pending result then carried saved guest bytes while watched, which the test rejects. The commit makes the staged path follow the direct path's rule. Traced with gdb: nocaptureGuestBytescall touched the failing image; the flag came fromuploadalone.One failure remains in the same test, on this machine too (Fedora 44, Intel Arc Meteor Lake, Mesa 26.2, where the probe reports that imports resolve the write watch). The three single-surface leave-the-watch cases print "not run, the surface is not write-watched", since the write-back's
HostImportForstill imports and so unwatches the surface. The fourth, "a surface whose first block left the write watch with the page before it", now fails one check later:the result did not reach a block the CPU left alone. WithAPS5_LOG_SYNC=1 APS5_TRACE_FLUSH=1and gdb breakpoints:SettlesawAnyPending()true and flushed two images still pending from the previous case (their memory already unregistered), not this surface, whose image the driver thread created afterwards; so the store's result was never settled;Readat+0xe000wrote the image back:keeps 1 CPU-written 64 KiB blocks (first stored byte at +0xf000, 1 ranges stored), through an importHostImportForcreated insidewriteBackLayers(theSaveBeforeUnwatchhook andNoteRangeUnwatchedran from there);FlushAllPending, every block of the surface still holds the untouched fill (0xdeadbeef), so those stored bytes never reached guest memory;FillClearran on the driver thread after that write-back and left the image pending at destruction.So the path this PR newly takes on such a device, a watched surface uploaded staged and written back through an import created at the write-back, does not land its bytes before the CPU read. I have not yet read the write-back's segment copy and shadow publish to say where they go. @oneandonlydean, before I do: is the leave-the-watch group meant to run on a device whose imports unwatch, when the surface's own write-back imports it anyway? If the answer is that the write-back should use
StorageImportFortoo, that is the next change; if not, the fixture's "not run" exit belongs before the fill for this case as well.The branch still sits on blawesom's base (
143f13055); I will rebase onto currentmainwith the fix for this failure, and the before/after capture for this change alone follows once the test is green.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-19T09:52:15Z.
@Mouad-Scriptz-0 Thanks for the trace, it made this quick to answer.
Yes, the leave-the-watch group is meant to run on a device whose imports unwatch, and the write-back should use
StorageImportFortoo. The point of this PR is that a watched storage surface stays watched on such a device.uploadandRefreshnow keep it out of a new import, butwriteBackLayers(Texture.cpp:4691 on your head) still callsHostImportFor. So the first CPU read that stores the surface's results imports it and takes it out of the watch, and the tracking only lasts until that first write-back. The three "not run, the surface is not write-watched" lines are the test reporting exactly that: the driver's own write-back took the surface out of the watch before the test could. Moving the "not run" exit before the fill would hide the new path (staged upload, then write-back) on the only device class where it runs, so please don't do that. Those exits should stay for what they were written for: a host where the surface isn't watched at all.When you make that change, please cover all the places that can create an import for a storage surface, not only the one in your trace:
writeBackLayers: the whole-surfaceHostImportFor(Texture.cpp:4691);importSegments, which it falls back to: its per-pieceHostImportFor(Texture.cpp:2626) would otherwise import the same surface piece by piece;CopyFrom's "not imported" check (Texture.cpp:4232) also creates an import as a side effect.With no existing import, a watched surface then takes the readback write-back (
vkCmdCopyImageToBuffer, thenWriteChangedCommitted), which keeps the watch. Please include that path's cost in the before/after capture, since it is the price of staying tracked.On the remaining failure: please merge current
mainand re-run before you read the segment copy. Your step 1 is a fixture race thatmainhas already fixed. On your base,HoldPendingreturns as soon asStorageTexture::AnyPending()is true, so it accepted the two images left pending by the previous case. Main's #6744 makes it wait for this surface's own image (FindPending(surface) == FindLive(surface)), and adds a--pending-identitymode that checks this. On your base, the same race also lets the post-FillHoldPendingreturn before the fill is pending. That fits your step 4: theFillClearran after the write-back and was still pending at destruction, and that alone would explain step 3's untouched blocks. So the failing check may come entirely from the stale fixture. If it still fails on a merged head, the trace is worth repeating there.The merge is real work. It conflicts in 7 files (both GuestMemory files, VulkanDevice.hpp, PacketExecution.cpp, both GuestBufferMemory files, and the debt doc). Two points to watch:
Rewatch. Main now hasRewatch(std::span<const std::pair<std::uint64_t, std::uint64_t>>), which does the work on Windows only (restore plus CPU stamp) and is a no-op on Linux. YourRewatch(address, bytes)re-registers and stamps on Linux only and is a no-op on Windows. Both would compile side by side as overloads, so neither one would cover both platforms on its own. Please fold yours into main's span form, so thatRetireIdleImportsreturns the range to the watch on both platforms.HostImportFor. Main's hit path now starts with the Windows-onlysettleUnwatchedImportsunder the same lock. Keep that call in your restructured function (inside the locked block, before the hit lookup), and keep the drain ofunwatchedNotesoutside the lock as you have it.After you push the merged head with the write-back change, we'll review it and run full CI.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-19T22:03:08Z.
This pull request is labeled
perf, so it needs the summary line of a capture onmainand one with the change, from the same title, scene and machine, as the Performance report form asks. Please paste bothaps5-summary.jsonllines, attach the two traces and add the output oftools/trace_digest.py.Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-19T22:03:18Z.
Merged current
main(903cbbd5b) asea55323d5; the head is mergeable again.agc_driver_store_over_untrackedpasses on the merged head, all ten cases run (no "not run" exits), including "a surface whose first block left the write watch with the page before it" — so the remaining failure was the fixture race #6744 fixed, as you expected.agc_write_tracking,agc_driver_graphics(+maps_fallback),agc_host_import_unmapand the recorder tests pass on this i915 device.Rewatchis now one function inmain's span form: Windows keeps the coverage restore + CPU stamp, Linux re-registers the kernel write watch per range and stamps the blocks as an import window;RetireIdleImportspasses its retired ranges as one span, so retirement rewatches on both platforms.settleUnwatchedImportsstays at the start ofHostImportFor's locked block before the hit lookup; theunwatchedNotesdrain stays outside the lock.ExistingHostImportformain'sExistingHostImportFor. One difference to know about:main's returns null while the registry is stale instead of refreshing it, so a watched surface takes the staged path until the next ordinary lookup refreshes — I keptmain's semantics.writeBackLayers,importSegmentsandCopyFrom's "not imported" check now go throughStorageImportFor(it gained a requester parameter soimportSegmentskeeps passingSegment). A watched surface therefore takes the readback write-back.Next is the before/after capture for this change alone on Minecraft, with the readback write-back cost (
vkCmdCopyImageToBuffer+WriteChangedCommitted) included; I'll post it here.Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-19T22:23:42Z.
The before/after is blocked on this machine: Minecraft (PPSA17221) no longer starts on current
main.main903cbbd5b(Fedora 44, Meteor Lake, Mesa 26.2.3, Release libs): one minute, zero presents, one dispatch; the log stops right after the title opens/temp0/user268435456/games/com.mojang/behavior_packs. That is the start-up hang I hit last week on the rebased depth branch (a Bedrock background worker parked insceKernelWaitEqueue, drivers idle), and the depth remap is inmainsince #4650. The merged head of this PR hangs the same way, as expected.main5d50886ee+ the depth remap as it was then + the save-data fix, in-world at about 42 fps.Two options; I'd rather not guess which you prefer:
5d50886ee+ depth + save-data, with this PR's current diff applied on top), and say so in the PR. The numbers would miss a week ofmain, but the change under test is the same.maincapturesAPS5_TRACE_SECONDS=60:20on the home screen formainand for this head; I'll digest the traces and add the write-back cost from the[storage]and[texture]lines.Either way I'll open a separate issue for the start-up hang once I have a thread dump of it, so it does not stay buried here.
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-20T01:22:11Z.
@Mouad-Scriptz-0 Option 1. Capture on
5d50886ee+ depth + save-data, with and without this PR's diff on top, both arms on that same base, and say the base in the PR. That is a valid A/B for this change alone. Option 2 isn't possible on our side: we don't have PPSA17221, and our GPU hasVK_EXT_depth_range_unrestricted, so it never takes the remap path your Intel does.Before the hang gets its own issue, one cheap check may settle it. On plain
main903cbbd5b, grep stderr (not only the log file) for[gpu] driver failureand[gpu] viewport depth clamp bounds. Reading the code, a device withoutVK_EXT_depth_range_unrestrictedrunsApplyDepthRemap(#4650) for every draw whose viewport depth is outside [0, 1], and it hasRequires that throw at draw time.Driver::ReportFailureprints that line once to stderr, then clears the pending work, so the end-of-pipe event the title waits on never arrives. That would look exactly like your worker parked insceKernelWaitEqueuewith the drivers idle.903cbbd5bwith #4650 reverted (git revert -m 1 3ddbc4accc; it doesn't revert cleanly, e.g. conflicts inVulkanDevice.hpp, so say if you want the tree from us), once with and once without your save-data fix, so the two causes separate.gdb -p <pid> -batch -ex 'thread apply all bt'), naming which kqueue/filter the worker waits on.If it is that, your report found a regression on main for devices without that extension, and it belongs in its own issue with the line pasted.
Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-20T19:58:07Z.
Base correction first: the set that presents here is
5d50886ee+ the save-data fix (e8d947d31, now #4649) without the depth remap;mc-basewithd17e97e15on top is the tree that hung last week. The home screen never takes the remap path, so I'll run both arms on5d50886ee+e8d947d31, with and without this PR's net change (903cbbd5b..ea55323d5ported onto it), and name that base in the PR.Cheap check: yesterday's stderr of plain
main903cbbd5b(redirected to a file, 41 lines until the kill) has[gpu] viewport depth clamp bounds [-1, 1] on a float depth target are clipped to [0, 1]: the device has no VK_EXT_depth_range_unrestrictedand no[gpu] driver failureline, so as far as that line goes it is not a draw-time throw. Thread dump next, then the reverted tree: yes please to yours, it saves the conflicts.Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-21T00:00:33Z.
A/B done, both arms on one base, home screen only (the panorama scene, nobody touching the title). Not the base I promised:
5d50886ee+e8d947d31aborts at the first present here (viewport depth outside [0, 1] requires VK_EXT_depth_range_unrestricted, the clamp clip is not in that tree). The only tree that presents on this Intel is my 2026-10-12 integration tree, so that is the base, named in full:Base
main33ae282e4(2026-10-13) +fix/agc-flip-eop-event+perf/guest-memory-registry-lookups+feat/videoout-mouse-capture+feat/signin-dialog-npauth-signed-out+perf/recompiler-select-load-guards+fix/dmabuf-import-coherence(#4449) + the oldfeat/agc-depth-range-remap+ the clamp-bounds clip and NpAuth export from that tree, plusmain's four trace commits (5668e0d0e,5c7da226d,016b2dbe8,eb8a7255d) cherry-picked so both arms writeaps5-summary.jsonl. Arm commits: base a139a481f, change 91d63f116.Change = base + this PR as merged in that tree on 10-12 (
49578e426) + the later review deltas (unwatchProbedgating of shrink/retire/import,NoteRangeUnwatched, the refresh guard,originalValid = !Watched). It is not today's headea55323d5, which only differs bymain's own movement since.Fedora 44, Meteor Lake iGPU, Mesa 26.2.4, 1920x1080, Release libs. Per arm: one warm run with
APS5_PROFILE_DRAW=1, then two runs withAPS5_TRACE_SECONDS=60:20, each 130 s. The window was focused throughout the trace windows (unfocused, GNOME holds the title at 1 present/s, which I had to learn the hard way).The change is slower on this scene, and it draws wrong.
Per-frame slices (
tools/trace_digest.py, run 2 of each arm, ms per frame, inclusive):Driver.Draw12.6 → 15.8,Graphics.Draw9.0 → 12.9,Driver.Packet14.8 → 18.2; the presenter waits less (VideoOut.Flip13.3 → 9.2) because the worker is now the bottleneck. The extra time is in the untracked compare, which this PR was meant to shrink. From the[guestmem]10-s lines of the warm runs (focused intervals only):Every compare in the change arm is a whole 0x870000-byte image (the three 1920-wide storage images at 0x258160000, 0x242460000, 0x242cd0000); the base compares partial units averaging 5.1 MiB. Write-backs are the same in both arms (
[storage]111–147 idle write-backs / 10 s, all GPU-direct, ~1 GiB / 10 s), so the import rule does not change what is written back here, only what is compared.Rendering regression. On the change arm the rotating panorama has a solid black region covering roughly the right half of the frame with a sharp vertical edge, every run, stable while the camera turns (screenshot attached, taken during the second trace run). The base arm renders it whole. The
[textures]counter points at the mechanism:sampled created: 27 from storage images, 0 snapshotssampled created: 1 from storage images, 26 snapshotsIn the change arm the sampled-texture lookup (
ShaderResources.cpp, thesource == nullptrbranch) no longer finds the storage image that holds the panorama faces, so the texture is built from a guest-memory snapshot viaReadTextureSurface, and it is then kept as long asGuestMemory::UnchangedSinceholds. A write-back through an unwatched import does not bump the generation thatUnchangedSincechecks, so a face whose write-back landed after the snapshot stays black. The change arm also logs 80retire import/ 80import for/ 60refresh ... direct=1per run on those same three images (the[diag]prints in that tree), so the storage images are being retired and re-imported about once a second rather than staying resident.Attached: the four
aps5-trace-*.json.gz,aps5-summary.jsonlwith the four lines, the screenshot. Capture dir and the[storage]/[guestmem]/[textures]lines of every run are kept here if you want more of them.aps5-summary.jsonl
ab5-base-aps5-trace-a139a481f4ab-179456.json.gz

ab5-base-aps5-trace-a139a481f4ab-180802.json.gz
ab5-change-aps5-trace-91d63f116177-183469.json.gz
ab5-change-aps5-trace-91d63f116177-184618.json.gz
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-21T00:32:50Z.
@Mouad-Scriptz-0 Thanks for the A/B and for naming the base in full. One question before we can use it for this PR: did the change arm include the 19 Oct
StorageImportForwrite-back routing? That routing targets exactly the black region you saw. If it didn't, could you port the head's net diff (main..ea55323d5on this PR's files) onto the same base and rerun? We'd like to know whether the black region is gone and whether the compares are still whole-image. A same-base A/B is fine as evidence while plainmainhangs at start-up on your machine. If you can, add one arm without #4449 in the base, or say why it has to stay.On the abort: plain
mainalready clips the viewport depth to [0, 1] when the device has noVK_EXT_depth_range_unrestricted(your ownmainlog shows that line), so that one is fixed. The start-up hang on plainmainis worth its own issue once you have the thread dump.Imported from boykopovar/AnyPS5. Originally posted by Mouad-Scriptz-0 on 2026-10-21T19:45:55Z.
Yes, the change arm had the routing. I checked it against today's head rather than trust my notes: for every one of the nine files in
main..ea55323d5, the head's added and removed lines against the change arm's added and removed lines over its base.Call sites in
Texture.cpp(function: lookup), change arm vs head:ea55323d5Refreshdirect pathalias != nullptr ? HostImportFor : StorageImportForupload(both sites)StorageImportForStorageImportForwriteBackLayersStorageImportForStorageImportForCopyFromStorageImportForStorageImportForimportSegmentsStorageImportFor(..., ImportRequester::Segment)StorageImportForitself is the same two lines in both (HostImportsUnwatch && Watched ? ExistingHostImport : HostImportFor). The arm also hasHostImportFor'simportsStaleguard andlastUseFrame,RetireIdleImportswithIdleImportFrames = 60and the rewatch of retired ranges, the LinuxRewatchbody (kernel re-register plusStampKind::ImportWindowstamps),NoteRangeUnwatched, and 924aaa4bf's staged-upload rule asoriginalValid = !GuestMemory::Watched(...)(that base has nolayerOriginal). What the arm lacks is only what the 10-13 base does not have:ImportRequesterand its per-requester counts,importSegments,layerOriginal/cancelStoredSaves, the Windows settles. None of those changes which import a storage surface takes on Linux. So the black region and the whole-image compares are the PR's current behaviour on this scene, not a stale arm.The arm without #4449 is next: both arms with the
fix/dmabuf-import-coherencemerge reverted (d807ffc63base,b4a701ff7change), same base otherwise, same protocol. #4449 was in the base only because the 10-12 tree carried it; nothing else there depends on it, so I will post those numbers rather than argue for keeping it.Thread dump of the plain
mainstart-up hang and its own issue after that.Imported from boykopovar/AnyPS5. Originally posted by CnRJay on 2026-11-01T19:52:29Z.
Review: COMMENTED
The retirement after
IdleImportFrames = 60is where I'd look first. A retired range comes back stamped as possibly written, so its next use pays a full compare, and if the title imports it again it is unwatched again. A surface the compute uploader touches every 61 frames or so would go round that loop forever: import, unwatch, retire, compare. Is there a counter for imports retired and re-imported per 10 s, and what does it show on the Minecraft home screen?This is titled
perf, so it needs themainand change summary lines from the same machine and scene, with traces. The Tested section says the home screen runs at the same 60 fps as before, so the summary lines are also what would show the render thread time going down.The four changes in the description (one-allocation window, storage surfaces not importing their own range, idle retirement, the
Watchedcheck inrefreshImports) could each land on its own. TherefreshImportscheck alone looks like an easy split.Imported from boykopovar/AnyPS5. Originally posted by XairRrR on 2026-11-03T09:08:10Z.
Review: CHANGES_REQUESTED
Reviewed — changes requested
The merge is clean and builds, but on lavapipe five existing tests now fail. They pass with
main's production files and withAPS5_WRITE_WATCH_IMPORTS=unwatch, so the cause is the PR's probe-gated paths. Lavapipe's start-up probe reports that host imports resolve the write watch, so those paths also run on the Linux CI device.What I ran
Head
7771062935fcfb3206a0f002e77781f461a2f641,main4f41f4c375f5abb487dbd184fbc150f31994d762, merged with--no-ff(merged treea3aed2e7681a04cf99ffd245a4841fca0ebaf536). Debian 13 VM, 32 vCPU Xeon Gold 6136, GCC 14.2.0, Release, Ninja, Vulkan on lavapipe (Mesa 26.1.6, LLVM 19). Probe line in every failing test:[write-watch] host imports resolve write protection: yes (0 of 4 scratch pages written after a GPU read, 4 after a GPU write, ...).Results
git diff --checkcheck_conventions.pydocs/dev/debt/libSceAgcDriver.md:351debt entry is 1507 characters (over 1000)mainfailures, 5 new failuresmain's production filesAPS5_WRITE_WATCH_IMPORTS=unwatchagc_driver_graphics(has the newidleImportRetireTests/unwatchedImportWindowTests)VUID-vkCmdDispatch-groupCountX-00386:agc_driver_native_depth_uniform_planes, which was not run on the baseline. I get the same 8 VUID lines with and withoutAPS5_WRITE_WATCH_IMPORTS=unwatch, so they do not come from this PR's probe-gated paths. I did not count it as a finding.git status --porcelainemptyFirst failing check of each new failure (merged tree)
Negative control
The new cases (
idleImportRetireTests,unwatchedImportWindowTestsintests/BdaResources.cpp) call API this PR adds (RetireIdleImports,HostImportsUnwatch, the three-argumentSetImportWatch). Withmain's production files they cannot compile, so a "fails without the change" run is not possible beyond that compile failure. I used the reverse control for the regressions instead: withmain's production files (andmain'sBdaResources.cpp), the five failing tests pass. With the merged files restored, they fail again. The worktree matches the merged tree afterwards.Findings
Blocking
Five existing tests fail on any device whose probe says imports unwatch, including lavapipe. These are
agc_driver_copy_surface_bytes,agc_driver_host_import_proofs,agc_driver_storage_one_slice_alias,agc_map_gate_retryandagc_windowed_import_refresh. All pass withmain's production files, and all pass on the merged tree withAPS5_WRITE_WATCH_IMPORTS=unwatch(which skips the probe, sounwatchProbedstays false). Upstream Linux CI runs on lavapipe, so it should hit these failures. The NVIDIA run in the discussion passed because that probe answers "no".Part of the cause is in the import window (merged tree):
core/libs/prx/libSceAgcDriver/Graphics/src/GuestBufferMemory.cpp:1410(shrinkImportWindow) stores 64 KiB into the process-wideimportWindowatomic (line 1408). A probed device triggers it atGuestBufferMemory.cpp:1477, and nothing ever restores it.SetImportWatch(..., Watch)does not, and neither does a later device whose probe says "no". Only an explicitSetHostImportWindowdoes.host_import_proofs,map_gate_retryandwindowed_import_refreshmessages are exactly that.The rest is in the storage paths:
StorageImportFor(GuestBufferMemory.cpp:4544) now backsCopyRefusal(Texture.cpp:6004). A watched copy source on such a device is refused as "not imported", which breaks the raw byte copy thatagc_driver_copy_surface_byteschecks.agc_driver_storage_one_slice_aliashad been updated for the new contract, but this diff has no change to that test. So either the behaviour change is unintended, or the test change was lost in the merges.Suggested fix: keep the window per device state, or restore it when the decision changes, rather than as a one-way global store. Make
CopyRefusaland the one-slice alias refresh keepmain's import behaviour, or update those tests with a stated reason. Run the affected tests on lavapipe or another "probe: yes" device before pushing.The
perfevidence the rules require is still missing from the description. Theperf numbers missinglabel is still on the PR. CONTRIBUTING requires twoaps5-summary.jsonllines (frommainand from the change, same machine and scene) plus traces. Those lines are only in comments, and the latest same-base A/B (2026-10-31, ond6b8a6227a) shows both arms vsync-locked. That run also explains how the black panorama arises: a GPU-only-written surface thatStorageImportForkeeps watched is sampled from a guest snapshot that lacks unstored layers. It ends with a proposed fix ("a copy destination ... takes the import"). The commits since then are merges only, so that fix is not in this head, and the snapshot-path problem the maintainer asked to fix is still open as far as this diff shows.The checklist is missing the
Fixes:andGPUs tested:lines (required for AGC changes). I confirm the earlier reports in the discussion that these lines are missing; the description is unchanged.Non-blocking
core/libs/prx/libSceAgcDriver/Graphics/src/Texture.cpp:2440-2441("Only the direct path uploads the selected layers alone..."),core/libs/prx/libSceAgcDriver/Execution/src/GuestMemory.cpp:1990-1991, and the new comments aboveSetImportWatch,HostImportsUnwatchandStorageImportForinGuestBufferMemory.hpp. CONVENTIONS allows comments only for technical debt. The checker accepts them only because the PR also edits the debt file. Please drop them or turn them into debt text.docs/dev/debt/libSceAgcDriver.md:351, checker warning), against the 1000-character guidance. It also describes implemented behaviour at length. Please state the gap first (the unmeasured 60-frame bound, unwatched ranges compared at every use) and cut the rest.Rewatchre-registers ranges with the kernel write watch before checkingtracker.covers(GuestMemory.cpp, the#elsebranch ofRewatch). A range outside the tracker is registered but never stamped. Consider checking coverage first.agc_driver_graphicstook 35.6 s here, over the 30 s limit (the NVIDIA run in the discussion reports 37.3 s on this head). I did not measuremainfor comparison, so I cannot say how much the two new cases add.Not verified
agc_driver_graphics's run time over 30 s comes from this PR or frommain.To get this to a good state
tools/trace_digest.pyoutput formainand this head in the description, and add theFixes:andGPUs tested:checklist lines.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-11-23T03:10:58Z.
Review: APPROVED
Reviewed — looks good
Nothing blocks this change; the reported Linux test and performance results are author-supplied, and I found no verified blocking defect in the code reviewed.
What I ran
Reviewed head
820f6a468a98cec4d66ee6626d692bf28dbd69bd. No commands or tests were run; repository context was read throughrepo_read.py.Results
Findings
Blocking
None.
Non-blocking
None.
Not verified
No tests, builds, Windows behavior, or physical-console behavior were verified. The PR description reports the Fedora test and Minecraft measurements; those results were not independently run. Read all changed files listed in
review/README.mdand the targeted repository context for import retirement, rewatching, and snapshot capture. The only changed-file lines not read were pre-existing context lines; all additions inmanifest.jsonwere read.files.jsonwas not supplied;review/README.mdidentifies the changed files excluded fromfiles/asVulkanDevice.cpp,GuestBufferMemory.cpp,Texture.cpp, andRecorder.cpp, and those were read through the repository reader.To get this to a good state
Nothing is required.
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.