fix(libSceAgcDriver): keep CPU flips in submission order #17279
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/17279"
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 amazedturnip on 2026-11-08T17:10:12Z.
What
A CPU flip that arrives while the queue worker is handing an earlier flip to its video output could be handed over first, so flips on one port reached VideoOut out of order. That is the intermittent
back-to-back flip status is wrongfailure ofvideo_out_flip_backtoback(#16956): the last completion carried the first flip'sflipArgandcurrentBuffer.The race:
flipsAhead(Submission.cpp).flipHold.Release(), which dropsflipsAhead, and only thenGpuReadyon the request.flipsAhead == 0under the driver mutex and hands its own request over directly. If the worker was preempted betweenRelease()andGpuReady, the later flip's request was queued first.The fix adds a
flipsLandingcount.Release(true)raises it in the same locked step that dropsflipsAhead, and it drops again onceGpuReadyhas returned (also on the exception path through theFlipHolddestructor). The direct hand-over now also requiresflipsLanding == 0; otherwise the flip is queued behind the worker as before. CallingGpuReadybeforeRelease()instead would keepflipsAheadraised whileGpuReadyblocks, which holds CPU flips behind a gated flip they are meant to overtake. No other ordering changes.agc_driver_cpu_flip_orderforces the interleaving without timing: its output parks the first flip insideGpuReady, then submits a second CPU flip and releases the first. Both must reach the output as 1, 2.Tested
aeaaf7367d.upstream/mainhas since moved toe0af82d615; the files it changed are in libSceLibreSsl, libSceNpCommon, libSceNpManager, libSceWebBrowserDialog,core/libs/testsanddocs/dev/debt, none of which the driver or these tests use.ctest -R '^agc_driver_cpu_flip_order$':flipsLanding == 0condition removed from the direct hand-over: 10 of 10 fail witha later CPU flip reached its output before an earlier onetools/select_tests.pyselection for the five changed files (2550 of 4549 tests; 114 skipped for lack of a Vulkan device, none failed) andctest -R 'video_out|agc'(1484 tests), 3 runs each, all passed.video_out_flip_*skip in this WSL environment (no Vulkan in the offscreen SDL driver), sovideo_out_flip_backtobackitself was not run; the new test reproduces its ordering failure at the driver.tools/pr_overlap.pyfails closed here: 17 open PRs that share the touched files conflict withmain, so it cannot compare them. I compared their diffs by hand: none changesflipsAhead,FlipHold,releaseFlipHoldor the flip hand-over (#13863, #13920 and #15136 only add lines next to them, #7642 changes none of the three driver files' flip code).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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-11-12T19:41:49Z.
Review: CHANGES_REQUESTED
The root cause and the new
agc_driver_cpu_flip_orderlook right, but this change regresses an existing test.flipsLandingis a single driver-wide counter held for the whole ofGpuReady(PacketExecution.cpp:472-474), and the shortcut inSubmit(Submission.cpp:646) now requires it to be 0 for every port.video_out_flip_cpuflip(libSceVideoOut/tests/Flip.cpp:229-258) parks a gate insideGpuReadyon port 7 and requires a CPU flip on a different port to complete meanwhile. With this head that flip waits behind the gate and the test fails after 8 s (a flip from a thread that never submitted queue-0 work waited for a held queue-0 submission). @NathanFahey23 measured it on Windows RTX 4080: 0 of 15 pass, vs 15 of 15 onmain;video_out_flip_backtobackgoes from 11/15 to 15/15.agc_driver_cpu_flip_orderand also runvideo_out_flip_cpuflipandvideo_out_flip_backtoback. These need a display/Vulkan device, so they skip on the Linux CI. Please post the result from a machine that runs them.Pull request closed