perf(agc): rule out pending write overlaps from the published union #6609
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/6609"
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 meh7an on 2026-10-15T22:47:43Z.
What
Recorder::PendingWriteOverlapsanswers whether a range overlaps a GPU write the recorder has noted for its open or in-flight batches. It walks every noted write of every batch, and the draw path asks it from 25 places (in-place draw inputs, texture refreshes, DCC keys, descriptor builds among them).The recorder already merges those writes into the snapshot it publishes (
publishPendingWrites). It now also keeps the union it last published,published, for as long as that union covers every write noted since:publishPendingWritessets it to the union it publishes;noteWriteandnoteWriteOn, which add every batch write, drop it when the new write falls outside it;PendingWriteOverlapsanswers no overlap from that union with one binary search when the range is clear of it, and walks the batches otherwise. The union may still hold the writes of batches that finished since it was built; that only sends a query to the walk. #4889'spublishedWriteRangesis a weak reference that only lets the next publish extend the snapshot, and it is not dropped when a write falls outside it, so this keeps its own strong pointer.On the S2 page of Sonic Origins Plus's main menu,
PendingWriteOverlapscost the queue worker (APS5 sampler, 15 s, samples per frame):That is about 1% of the worker's frame (34 to 37 samples), so the frame times below move within run-to-run noise.
Tested
Windows 11 (10.0.26300), WinLibs GCC 15.2.0 (UCRT), Release, NVIDIA GeForce RTX 2080 Ti, driver 617.14.
5d9dcc42dwith this change, the full ctest suite passes 1298 of 1300 tests.agc_driver_gpu_indirect_arguments_misaligned_writer_aheadis not run: main itself does not compile it with MinGW (alignas(65536)).agc_driver_multisample_fill_host_onlyfailed once ("the sentinel fill did not land"). That is main's own race, #6512, which #6522 fixes. With this change it failed 42 of 200 runs (8 at a time), as main does (46 of 200 onb7cedd900). With #6522's line added it failed 0 of 200.APS5_TRACE_SECONDS=200:15on the same machine in one session, caches warm. Traces attached.The FPS shown in the title went from 9.38 to 9.53 (median of six readings). The p90 gap comes from slower frames in the baseline's window; the median moved within noise.
I captured the baseline twice. The first window caught a stretch where the page's draws repeated exactly and the draw cache hit: frames of 74 ms, no
shader_compile_and_linkphase, and the GPU fence as the limit. The second, used above, shows the moving background like the change's window.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)Traces and summary lines (baseline e3b8d1c52, whose summary says a21a3ce81e18; this change a0dd42cf9, whose summary says e3b8d1c5245e):
union-traces.zip
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T23:30:03Z.
Some 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/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppcore/libs/prx/libSceAgcDriver/Graphics/include/Recorder.hppcore/libs/prx/libSceAgcDriver/Graphics/src/Recorder.cppImported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-19T08:15:22Z.
Checked the published-union fast path against
noteWrite,noteWriteOnandpublishPendingWrites: the union always covers every noted write (full rebuild includes open, in-flight and finishing batches; a write outside it drops the pointer; an inactive recorder publishes nothing), and a union that still holds finished batches only sends the query to the old walk. Re-checked against current main: the new Recorder changes there (barrier batching) add no noted writes. Merging through the queue.