Repository navigation
fix(agc): wait for queued registration preparations before accepting a submission - #5007
Conversation
|
Windows test (MinGW GCC 15.2, Release, Windows 10, RTX 4080 SUPER). Built on main
Not tested: no game run. The batch was built once, not per PR; nothing failed, so no bisect was needed. AI-assisted (Claude Code). |
|
Rebase handoff — rebased onto current
Verified on Linux (CachyOS, kernel 7.2.9, GCC 16.2.1, Ninja, Release,
To pick it up: Head is |
3ffc557 to
fc32ebe
Compare
…a submission Since registered shaders are prepared in the background, a draw whose shader was registered just before could wait seconds for its preparation inside the queue worker. Under CPU load Goat Simulator 3's first submissions took ~3.7 s; the title treated the GPU as hung, stopped submitting, and its 10 s garbage collection timeout crashed it on every launch. Driver::Submit now waits for the preparations queued before it, on the submitting thread, before the commands reach the GPU. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto current Checked on Linux (RADV, Release): scoped libSceAgcDriver build + ctest 550/551, the only failure is |
fc32ebe to
18522ae
Compare
What
Goat Simulator 3 (PPSA04159) stops at startup with a write of 0 at a compiled-out debug hook (app.exe+0x2511b7b): the engine's garbage collector waits for a render command fence, gives up after 10 s and reaches a fatal path. With another program loading the CPU it happened on every launch (11 of 11), without load about one launch in four.
Since registered shaders are prepared in the background (6db5c13), a draw whose shader the title registered just before its submission waits for that preparation inside the queue worker, in
AwaitRegisteredPreparation. A GPU trace (APS5_TRACE_GPU=1) of a failing launch shows:The title takes a submission of seconds for a hung GPU. On the console shaders are compiled ahead of time, so a submission never waits for one.
Driver::Submitnow waits, on the submitting thread and before it accepts the commands, until the registration preparations queued before the call have run (RegistrationPreparePool::AwaitSubmitted: each queued task gets a sequence number, and the call returns once no task numbered at or before the newest one at the call is queued or running, so a later task finishing first does not end the wait). The queue worker then finds every such preparation settled, and the submission's GPU side stays short: the same submission is done in about 180 ms.APS5_SYNC_SHADER_PREPARE=1(nothing is queued) or when the pool has no threads (tasks run inline).Submitand would need a rebase against each other.agc_driver_prepared_shadersgains cases: a task queued on the registration pool that sleeps 50 ms has run whenAwaitRegistrationPreparationreturns; and with a 300 ms task queued before the wait and a fast one queued after it began, the wait does not return before the slow task is done (a count of finished tasks fails this, because the fast task finishes first).Tested
BUILD_TESTING=ON:ctest -R "agc|shader" -j6passes 473 of 473, as onmain, andagc_driver_recorder_testspasses its default run.tools/check_conventions.py --base origin/mainpasses.APS5_SYNC_SHADER_PREPARE=1instead, 0 of 3 crashed, which isolates the background wait as the cause. On currentmainthe title stops earlier, at its first draw with clip distances (clip distances, layer, viewport or auxiliary vertex exports is unsupported (register 0x207 = 0x00400001), which feat(agc): vertex clip and cull distances #423 and feat(agc): render layered draws into 3D color targets #1077 cover), so these numbers are from that local branch:mainof 2026-10-12 with feat(agc): render layered draws into 3D color targets #1077 merged.Checklist
main; no other open PR implements the same functions (fix(agc): prioritize demanded shader preparation #4404 prioritizes queued preparations; see above)NotImplemented_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