Repository navigation
Fix/agc hold flip behind worker - #1745
Conversation
7e5ad0a to
878d7ca
Compare
|
I checked the failed conventions run (37825811506). It reports that |
|
Linux results, since this was tested on Windows only. Everything passes here. Nobara 44 (Linux 7.2), GCC 16.2.1, Release,
The CPU failure is |
|
Three things before this can go in:
|
|
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), RTX 3060 Laptop (NVIDIA 616.92), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
No title was run. 🤖 Addressed by Claude Code |
adriadam10
left a comment
There was a problem hiding this comment.
Thanks for the investigation and the measurements. Still open before this can go in:
- Dean's three points from the previous comment are not addressed yet: drop
APS5_NO_FLIP_HOLD(Submission.cpp:141), wake the hold by notifyingchangedwhererunningWorkers,orderHoldersand the pending completions drop instead of the 1 mswait_forpoll (Submission.cpp:148), and hold writers coming from queues other than 0 (Submission.cpp:142). conventionsis red: the PR body is a pasted HTML document followed by a plain-text copy, so theWhat/Tested/Checklistsections are not recognized. Please replace it with one plain-Markdown copy of the template, and retitle asfix(agc): hold flips behind the worker(Conventional Commits).- The new test in
Flip.cppshould also cover the notify path (hold released by worker progress with no extra submission) once the polling is gone.
Rebase on current main when you push; the Linux (fisherjoey) and Windows (popcoder565) runs on this head were clean.
…evious one A title that paces itself on pending flips assumes what hardware gives it: the command processor consumes a submitted buffer at once, so a pending flip is a frame whose commands have been read and that only waits for the display. The queue worker is slower than that. With three flips pending it can still be recording the oldest frame while the title rewrites that frame's slot of a three-deep ring of per-frame memory for the frame after next, and the draws are then recorded with the later frame's (or half-written) constants. A submission on queue 0 that carries a flip now waits until the worker has reached the flip of every earlier one. The wait ends early when queue 0 is blocked on memory that no running or pending work writes, since only the title can end that wait. APS5_NO_FLIP_HOLD=1 submits as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_017MPYE7P9ob12aAE1H4JtHF
The hold no longer polls every millisecond and has no switch to turn it off. A held submission waits on the driver's condition variable until no flip is ahead of it, or until queue 0 waits for memory that only the title can store. The queue 0 worker reports the second case from its memory and rewind waits, and the worker that reaches a flip wakes the holders. agc_driver_flip_tests: a flip held behind a rendering wait is released when the worker goes on to wait for a label only the title stores, with no further submission.
878d7ca to
5d888ab
Compare
|
I rebased this on current
I left the other-queue point out. The hold blocks the title's thread at its flip submission, so that thread's later submissions on any queue come after the held one anyway. Tested: Linux, RTX 4090, Release, full |
What
A title that paces itself on pending flips can get further ahead of the queue 0 worker than its per-frame memory allows, and the worker then records a frame from memory the title has already rewritten.
Astro Bot (PPSA21564) keeps per-frame data in a ring of three slots, polls
sceVideoOutIsFlipPending, and submits the next flip as soon as fewer than three are pending. On hardware a pending flip is a frame whose commands have been read. Here submissions waited 98 to 110 ms in queue 0, so the worker was still recording frame N while the title wrote frame N+3 into the same slot. A block of per-frame constants that holds the title's frame counter read0x17ein the frame right after one that read0x17a: the worker recorded frame0x17bfrom the slot of frame0x17e. When the slot was half rewritten the draw bound the wrong block, and the frame came out black, without the movie quad, or with the quad at half size: 8 to 16 of 48 window captures in each of five runs.APS5_FLIP_READ_CHECK=1counted 141,478 of 158,640 in-place reads as overwritten before execution. The same overrun producedguest snapshot differs from registered memoryin compute shader0x5005e7b00.A submission on queue 0 that carries a flip now waits until the worker has reached the flip of every earlier one. The wait ends early when queue 0 is blocked on memory that no running, held or pending work writes, the criterion
orderReleaseduses, since only the title can end that wait. The presenter stays asynchronous: the title still has three flips pending when the display is the limit.APS5_NO_FLIP_HOLD=1submits as before.tests/Flip.cppgains a case: a flip behind a closed rendering wait holds the next flip submission until the wait opens, and a flip behind aWAIT_REG_MEMon a label only the test stores does not hold it.Not established: what the console returns from
sceVideoOutIsFlipPendingwhile its GPU is behind. The change does not depend on it.Tested
b3fcd6d6(an oldermain) with this change. 45 s runs through the intro, 48 window captures each in bursts 70 ms apart:With the change the snapshot check passes through the whole intro without
APS5_NO_SNAPSHOT_CHECK. The title still needs a local workaround for an unrelated failure in the same shader at the first frame (guest memory is not readable at 0x30) andAPS5_HOST_IMPORT_MIB=16384.4ddbf049(this branch's base):agc_driver_flip,agc_driver_pm4andagc_driver_pm4_failurepass;agc_driveris skipped there because the machine has no Vulkan device. The new case fails withAPS5_NO_FLIP_HOLD=1and passes without it.tools/check_conventions.py --base origin/mainpasses. The rest of the test suite was not built or run.4ddbf049itself (the Windows runs used the older base; rebasing needed two textual conflict resolutions next to the new timing fields), any title on Linux, any title other than Astro Bot.Checklist
- Based on current
- One topic per PR; follow-ups go in a new PR
- No comments in code except technical debt
- Unimplemented paths throw (
- No notes, investigation
- New third-party code is a submodule built from source (none added)
- Generic behaviour, not specific to one title
- Depends on: none
- AI-assisted: yes. The investigation, the change, the test and this description were written with Claude; the Windows runs were made on my PC with my own copy of the game.
Whatmain; no other open PR implements the same functions (unmerged pull requests from fix(agc): turn off dma-buf import on the NVIDIA proprietary driver #1380 to ci: warn about tests that take more than 30 s #1744 were checked through their refs; older ones were not)NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)A title that paces itself on pending flips can get further ahead of the queue 0 worker than its per-frame memory allows, and the worker then records a frame from memory the title has already rewritten.
Astro Bot (PPSA21564) keeps per-frame data in a ring of three slots, polls sceVideoOutIsFlipPending, and submits the next flip as soon as fewer than three are pending. On hardware a pending flip is a frame whose commands have been read. Here submissions waited 98 to 110 ms in queue 0, so the worker was still recording frame N while the title wrote frame N+3 into the same slot. A block of per-frame constants that holds the title's frame counter read 0x17e in the frame right after one that read 0x17a: the worker recorded frame 0x17b from the slot of frame 0x17e. When the slot was half rewritten the draw bound the wrong block, and the frame came out black, without the movie quad, or with the quad at half size: 8 to 16 of 48 window captures in each of five runs. APS5_FLIP_READ_CHECK=1 counted 141,478 of 158,640 in-place reads as overwritten before execution. The same overrun produced guest snapshot differs from registered memory in compute shader 0x5005e7b00.
A submission on queue 0 that carries a flip now waits until the worker has reached the flip of every earlier one. The wait ends early when queue 0 is blocked on memory that no running, held or pending work writes, the criterion orderReleased uses, since only the title can end that wait. The presenter stays asynchronous: the title still has three flips pending when the display is the limit. APS5_NO_FLIP_HOLD=1 submits as before.
tests/Flip.cpp gains a case: a flip behind a closed rendering wait holds the next flip submission until the wait opens, and a flip behind a WAIT_REG_MEM on a label only the test stores does not hold it.
Not established: what the console returns from sceVideoOutIsFlipPending while its GPU is behind. The change does not depend on it.
Tested
Windows 11, RTX 5070 Ti, Astro Bot (PPSA21564, 01.007.000), built from b3fcd6d (an older main) with this change. 45 s runs through the intro, 48 window captures each in bursts 70 ms apart:
Build Odd captures Frames presented
Without the change (five runs) 8 to 16 730 to 795
With the change (two runs) 0 868, 999
With the change and APS5_NO_FLIP_HOLD=1 12 795
With the change the snapshot check passes through the whole intro without APS5_NO_SNAPSHOT_CHECK. The title still needs a local workaround for an unrelated failure in the same shader at the first frame (guest memory is not readable at 0x30) and APS5_HOST_IMPORT_MIB=16384.
Linux, on 4ddbf04 (this branch's base): agc_driver_flip, agc_driver_pm4 and agc_driver_pm4_failure pass; agc_driver is skipped there because the machine has no Vulkan device. The new case fails with APS5_NO_FLIP_HOLD=1 and passes without it. tools/check_conventions.py --base origin/main passes. The rest of the test suite was not built or run.
Not tested: the title on 4ddbf04 itself (the Windows runs used the older base; rebasing needed two textual conflict resolutions next to the new timing fields), any title on Linux, any title other than Astro Bot.
Checklist
Based on current main; no other open PR implements the same functions (unmerged pull requests from #1380 to #1744 were checked through their refs; older ones were not)
One topic per PR; follow-ups go in a new PR
No comments in code except technical debt
Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt
No notes, investigation .md files or images added to the repository (attach them to this PR)
New third-party code is a submodule built from source (none added)
Generic behaviour, not specific to one title
Depends on: none
AI-assisted: yes. The investigation, the change, the test and this description were written with Claude; the Windows runs were made on my PC with my own copy of the game.