Repository navigation
fix(agc): settle registration preparations before a preparation scope locks - #5023
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). |
3bd81bc to
bcec58b
Compare
920721c to
54a10dc
Compare
… locks sceAgcCreateInterpolantMapping resolved the pixel shader's ABI, which takes the process-wide shader preparation lock until the scope ends, and then waited under that lock for the vertex shader's background registration preparation. sceAgcCreatePrimState and sceAgcLinkShaders could wait the same way. Every other shader registration and ABI resolution queued behind that one compile: on PPSA07411 the lock was held 8 to 10 s of every 10 s, almost all of it waiting for registration preparations, while its loader threads waited 13 to 45 s per 10 s to take it. A preparation scope now names the shaders it resolves and waits for their registration preparations before it can take the lock. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
54a10dc to
11ef8e6
Compare
|
Checked on Linux: build and scoped ctest (libSceAgc + libSceAgcDriver) pass, and |
What
A shader preparation transaction takes the process-wide
writerslock on its firstRead,EditorHoldand keeps it until the outermost transaction ends (#3159).ReadandEdittake the lock before they wait for the snapshot's background registration preparation (AwaitRegisteredPreparation).sceAgcCreateInterpolantMappingresolves the pixel shader's ABI first, which takes the lock, and then resolves the rectangle ABI, which reads the vertex shader and waits for its registration preparation while holding the lock.sceAgcLinkShadersandsceAgcCreatePrimStatewait the same way inResolveGraphicsStagesAbi. While one such wait lasts, every otherRegisterShaderand every other ABI resolution in the process waits for the lock.ShaderPreparationScopenow takes the shaders it will resolve.AgcDriverBeginShaderPreparation_nid_postfix(shaders, count)callsDriver::SettleShaderPreparations, which looks up the registered snapshot of each named shader and waits for its registration preparation before the scope's transaction exists, so before it can take the lock. A preparation never becomes pending again once it has settled. If a header is replaced between the settle and the read, the new snapshot is awaited under the lock, as before.sceAgcCreateInterpolantMappingnames the vertex and pixel shaders (the vertex shader only when there is a pixel shader).sceAgcLinkShadersnames both.sceAgcCreatePrimStatenow opens a scope around its graphics ABI resolution and names the hull and vertex shaders.ResolveGraphicsStagesAbifinds by code address and not by header (another header registered for the same code, a tessellation local stage), and fragments linked earlier to the same vertex shader when a rect-list ABI is requested.Related:
ReadandEdittake the lock. It does not move the wait for the registration preparation (pending), which still runs afterHold, so the rectangle ABI read of the vertex shader still waits under the lock. The two merge without conflicts. With both, the settle also runs or waits for the named shaders' queued ABI jobs before the lock.Driver::Submit, before a submission is accepted. That is a different path and does not involve the preparation lock. The two merge without conflicts.Tested
agc_driver_preparation_scope_settle(tests/execution/PreparationScopeSettle.cpp). It holds every registration pool thread, registers a vertex shader whose preparation is then queued, and startssceAgcCreateInterpolantMappingfor it on another thread. It then checks that another shader can be registered while that call waits.a link waiting for a registration preparation blocked the registration of another shader.BUILD_TESTING=ON, rebased onmain637ade8:ctest -R "^agc_|^guest_shader_link$" -j 6: 463 tests, no failures, 1 skipped (agc_driver_stencil_ref_export).tools/check_test_registration.pyandtools/check_conventions.py --base upstream/mainpass.Checklist
main; no other open PR implements the same functions (perf(agc): resolve static shader ABIs on the background pool #2589, fix(agc): prioritize demanded shader preparation #4404 and fix(agc): wait for queued registration preparations before accepting a submission #5007 are related; see above)NotImplemented_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