fix(agc): poll for completions with a high-resolution timer on Windows #1474
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1474"
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 popcoder565 on 2026-10-08T08:45:19Z.
What
On Windows, an end-of-pipe interrupt for a submission with GPU work reached the guest's equeue about 15 ms after the GPU had finished. The label written by the same
RELEASE_MEMwas visible within 0.5 ms.The interrupt waits for the recorded work to be reaped (
AfterRecordedWorkinPacketMemory.cpp). With the queues idle, that reap comes from the queue worker, which waits onchangedfor 1 ms and then callsreapCompletionLabels(). With MinGW, thatwait_forgoes through winpthreads. winpthreads ends a timed wait only onceGetTickCount64has advanced by the timeout, andGetTickCount64moves in 15.6 ms steps (#1471). The worker therefore reaped about every 15.6 ms instead of every millisecond. Any guest wait on a GPU completion event paid that delay.On Windows, the worker now sleeps with
PollSleep, the driver's 200 µs high-resolution timer sleep that WAIT_REG_MEM polling and the rewind-tail wait already use, and then checks again. On other platforms it still waits onchangedfor 1 ms.The wait for a wait-free submission's order release (
orderReleased) uses the same poll. One of the things that releases it, completions reaped by another thread, is not notified, so it was also checked only every 15.6 ms.Trade-off on Windows: a submission or release that arrives while the worker sleeps in
PollSleepis seen when the sleep ends, about 0.5 ms later, instead of on the notify. This only happens while completions are pending.Tested
Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release, Intel Core i7-12700H, RTX 3060 Laptop (driver 616.92).
I added a probe mode to
video_out_flip_testslocally (not in this PR):RELEASE_MEMthat writes a label withINT_SEL2.sceAgcDriverAddEqEvent(eq, 0).Medians per run:
main8388121amainsleep_for(5 ms)between rounds (15.6 ms on Windows), 1000 iterationsThe event itself arrived 15.6 to 15.9 ms after the submit on
main, and 0.60 ms after it with this change (back to back, 1000 iterations).agc_driver_srgb8_color_targetfailed (#1434).guest_raise_exceptiontimed out; it loads onlylibcandlibkernel, and this is the Windows hang #1421 fixes. I then ran the 203agc_tests twice more: one run passed all of them, and in the other onlyagc_driver_dcc_keys_first_write(#1434) failed.video_out_flip_tests(not in ctest, #1040), run twice, gives the same results as onmain(d549f768):decode,controls,present,backtoback,dcc,pacingandaftergpupass,unavailablefails, andlifetimeandreopenterminate.Not run on Linux, whose code path is unchanged. No title tested.
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-08T11:57:54Z.
Review: APPROVED
Reviewed the complete diff, PR description, and current Linux, Windows, Conventions, and Progress report checks. The Windows polling path releases and reacquires the queue mutex around PollSleep, while non-Windows keeps the condition-variable wait. The polling latency trade-off is documented. I found no issues.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-08T14:20:19Z.
Checked the diff, build and full ctest (462/462) on the PR merged onto current
main, and CI (Linux, Windows, conventions) is green.PollSleepis the existing helper from WaitMemory, the queue lock is released around the sleep, and the non-Windows path keeps the 1 mswait_for. The Windows latency numbers are yours and we couldn't run them here (no Windows host). Merging.