feat(agc): store pending storage-image results at each flip with APS5_STORE_AT_FLIP #1995
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1995"
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 lubaxe on 2026-10-09T04:14:26Z.
What
Addresses #1970. Pending storage-image results are stored only when something reads their memory. PPSA12544 frees render targets after its GPU work, and Unity's allocator reuses that memory. A write trap on the image pages caught
HollowKnight.exe+0x1a578feand+0x1a57931writing block headers at page boundaries (+0x1fe000, then+0x1fdff8) into a 1920x1080 target while its results were pending. The late store then:+0x1a5771d,+0x1a57ad7) whiletut_01loads.On hardware the results land as the GPU writes them, before the title can reuse the memory.
APS5_STORE_AT_FLIP=1stores every pending result when a display buffer is flipped (PresentDisplayBuffer), through the existingStorageTexture::FlushAllPending, which had no caller. A title has to wait for GPU work before reusing its memory, so a flip is a point where the results are due at the latest. Storing them at the title's own waits (labels, fences) would be the general fix; it is recorded in TechnicalDebt.md as unimplemented. Off by default.Tested
storeAtFlipTestsinagc_driver_graphics(ctest) checks the switch: unset is off,1is on, and0, empty,trueand11are rejected. With the oldgetenv(...) != nullptrcheck it fails.PresentDisplayBufferneeds a swapchain, so the flip call itself is covered only by the title runs. (Updated in 4d0042b3 after review; rebased ontomaind70b8998.)ctest: 487 of 488 passed. The failure isagc_driver_pixel_lds, which also fails on unmodifiedmainon this GPU.APS5_WRITE_WATCH_IMPORTS=watch:tut_01loaded in 3 of 4 runs.tools/check_conventions.py --base origin/mainpasses.Conflicts with #1994 only in
docs/user/USAGE.md. I'll rebase whichever merges second.Update (
maind70b8998): #1994 is closed, since #2096 restores the frame rate onmain. With this flag alone, PPSA12544 runs gameplay at 600 presents / 10 s with correct rendering (Windows 11, RTX 5090, with #846, #425, #1836, #1599, #1968 and #1969).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 MarcZX10 on 2026-10-09T04:16:07Z.
The regression evidence is unusually strong, especially the page-write trap and title run. One remaining attribution gap: the reported correct 60 fps run uses both
APS5_STORE_AT_FLIP=1and #1994’sAPS5_WRITE_WATCH_IMPORTS=watch, while the bad run is described without the combination. Could you report the four-way result (neither, each switch alone, both) or otherwise isolate which change prevents the allocator overwrite? That will show whether this flag independently fixes #1970 and how it composes with #1994.Imported from boykopovar/AnyPS5. Originally posted by lubaxe on 2026-10-09T04:33:17Z.
Thanks, here is the four-way result. Same build for all four:
mainf1451396with #846, #425, #1918, #1968, #1969, this PR and #1994. Same machine (Windows 11, RTX 5090). Each run starts the title and lets the intro play intotut_01with no input, for up to 180 s, withAPS5_PROFILE_DRAW=1and frame dumps (APS5_DUMP_FRAMES=60 APS5_DUMP_FRAMES_EVERY=200).APS5_STORE_AT_FLIPAPS5_WRITE_WATCH_IMPORTSAGC driver: null or misaligned addresstut_01frames render correctlywatchtut_01loaded:vertex fetch exceeds descriptor record count; the frames before it are blackwatchtut_01frames render correctlyEarlier runs without either switch on the same stack:
tut_01loaded, in the allocator code at+0x1a5771d/+0x1a57ad7. One of those was in this matrix's first pass.So:
One caveat: the frame dumps themselves change timing, which probably explains why the neither-switch run failed earlier here (23 s) than without dumps (in
tut_01).(AI-assisted: Claude Code; the runs are on my machine.)
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-09T04:39:14Z.
Thanks, this four-way matrix closes the attribution gap. It shows
APS5_STORE_AT_FLIP=1fixes the corruption on its own, whileAPS5_WRITE_WATCH_IMPORTS=watchalone is fast but can consume stale memory and crash; the combined setting is both fast and stable in this run. The updated #1994 description now makes the pairing requirement clear. I still see no upstream checks on either PR head, so I will hold formal review until Build and Conventions run.Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-09T09:22:47Z.
APS5_STORE_AT_FLIP=0turns the store on too:VulkanDevice.cpp:2034only checksgetenv(...) != nullptr. Please accept1and throw on any other value, asAPS5_WRITE_WATCH_IMPORTSdoes.The new check in
metadataPassTestspasses on main as well, sinceFlushAllPendingis already there, so it doesn't cover this change; drop it or test the flip path.Imported from boykopovar/AnyPS5. Originally posted by lubaxe on 2026-10-09T12:59:02Z.
Thanks, both addressed in 4d0042b3 (on top of a rebase onto
maind70b8998):StorageTexture::StoreAtFlipRequestedreadsAPS5_STORE_AT_FLIP: unset is off,1is on, anything else throwsAPS5_STORE_AT_FLIP=<value>: expected 1, at the first flip. USAGE.md says so.metadataPassTestscheck.PresentDisplayBufferneeds a swapchain, and no test reaches it headless, so the flip call itself is covered only by the title runs above. The newstoreAtFlipTestsinagc_driver_graphics(ctest) covers what this PR adds: unset,1, and that0, empty,trueand11are rejected. With the old!= nullptrcheck it fails.Also: on current
main,agc_driver_recorder_testsstops instorageRefreshTests(the refresh's store of the results did not reach guest memory), with or without this PR, on Windows (RTX 5090).(AI-assisted: Claude Code.)
Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-10T05:17:27Z.
Same as #1969: it conflicts with main in
tests/Graphics.cppnow; please rebase.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-10T07:03:48Z.
Rebased onto current
mainas requested (conflicts intests/Graphics.cppandTechnicalDebt.md, both adjacency: kepthighestDrawIndexTestsand the other new TechnicalDebt entry next to ours).Rebuilt, libSceAgcDriver ctest 303/303. Merging on green CI.
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-10T07:05:43Z.
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/tests/Graphics.cppL3599