fix(agc): bound registered shader preparation memory #9626
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/9626"
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 MarcZX10 on 2026-10-22T04:58:04Z.
What
Bounds registration-time shader preparation by process-private memory. The default budget is half of physical RAM;
APS5_REGISTRATION_PREPARE_COMMIT_GBoverrides it in GiB, and0disables registration-time preparation. Both new registrations and queued work check the budget, deferring shader preparation until first use after the threshold is reached.If the budget cannot be established, registration-time preparation is not bounded and behaves as before this change: when the physical memory size cannot be read (
GlobalMemoryStatusExfailing on Windows,sysconffailing elsewhere)ReadPhysicalMemoryBytesreturns no value and the default budget is unlimited, and when the process-private size cannot be read the check allows the work. Once the budget is reached, later registrations are prepared when their shader is first used instead of at registration, so a title can stall on its first draws that use those shaders; the first such deferral is logged once.Tested
Before rebasing to current
main, builtlibSceAgcDriverand the budget-test target with Ninja; the focused CTest passed (1/1). On the current head based onmainda54c652e3, compiled and ran the standalone budget policy test with g++ (passed), ranpython3 tools/check_conventions.py --base upstream/main --head HEAD(passed), and rangit diff --check(passed). This host has no/dev/dridevice orvulkaninfo; the AGC GPU validation suite was not run. The repository's manual build workflow dispatch returned HTTP 403 because this account lacks the required repository admin permission. The other hosted build jobs are skipped.Checklist
main; no other open PR implements the same functions.mdfiles or images added to the repositoryImported from boykopovar/AnyPS5. Originally posted by jotitadev on 2026-10-22T07:03:20Z.
Review: COMMENTED
GPU run, since the description says the AGC suite was not run.
Machine: Ubuntu 26.04, i7-8700, 30 GiB RAM, GCC 15.2, Release, full build with
BUILD_TESTING=ON. GPUs: NVIDIA GeForce RTX 3070 (driver 595.99.02, Linux) and lavapipe (Mesa 26.0.3, LLVM 21.1.8). Head 769a25562 merged intomainda54c652e.ctest -R "^agc" -E "agc_display_buffer_dcc|agc_driver_flip|agc_driver_lds_atomics64" -j1 --timeout 30:mainThe failures are the same on both trees: the three
sample_ordertests on the 3070 (the card has no 2x2 sample-location grid at 2 samples) andmultisample_retirementon lavapipe. The fourth failure onmainon the 3070 wasagc_driver_sgpr_pattern_fill_keys, which is load-dependent (#9139).agc_driver_registration_prepare_budgetpasses.To exercise the deferred path itself, I also ran the suite on the 3070 with
APS5_REGISTRATION_PREPARE_COMMIT_GB=0. The budget message is logged once per process. Every draw and dispatch test still passes. The only new failures are 14prepared_*/preparation_scope_settletests that assert work done at registration, for examplethe null pixel program was not prepared at registrationandthe link did not wait for the vertex shader's registration preparation. That is expected with a zero budget. Seven of them pass underAPS5_LAZY_SHADER_PREPARE=1only because they check that variable. An invalid value (abc) stops withAPS5_REGISTRATION_PREPARE_COMMIT_GB must be a non-negative number of GiB.Not tested: a title that actually reaches the budget, Windows.
GPUs tested: NVIDIA GeForce RTX 3070 (595.99.02, Linux), lavapipe
Written with AI assistance (Claude Code). I ran the builds and tests above on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-22T18:57:57Z.
Review: CHANGES_REQUESTED
Checked the three registration paths (lazy, async, sync) and the background task: a null plan is handled in each, and an invalid
APS5_REGISTRATION_PREPARE_COMMIT_GBfails with a clear message. Remaining points:APS5_REGISTRATION_PREPARE_COMMIT_GB), including what is kept for a deferred shader. Nothing here shows the budget stops the growth.core/libs/prx/libSceAgcDriver/tests/RegistrationPrepareBudget.cpp:15-26only testsprocessPrivateBytes < budgeton a one-line helper. It exercises neither the env parsing (ShaderRegistry.cpp:1350-1366:0, invalid text, overflow) nor thatPlanRegistered(ShaderRegistry.cpp:916) andPrepareRegisteredInBackground(ShaderRegistry.cpp:1387) defer and leaveprepared.deferredset. Please move the budget decision (budget parsing and the allow/defer choice) into the testable header and cover those cases, or add a registry-level test with a budget of0.0the 14prepared_*/preparation_scope_settletests that assert work at registration fail. Add a test that pins the deferred behaviour (entries empty,deferredset, shader prepared on first use) so the budget path is covered by default.GlobalMemoryStatusExfails (the budget becomes unlimited) and that the preparation moves to first use, so a title may stall on its first draws.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-23T22:51:07Z.
Review: CHANGES_REQUESTED
Thanks for moving the budget parsing into
RegistrationPreparationBudget.hppand testing it; the parsing/allow cases intests/RegistrationPrepareBudget.cpplook right. Three points from the previous review are still open:mainvs this change, with the default budget and with a lowAPS5_REGISTRATION_PREPARE_COMMIT_GB.PlanRegistered(ShaderRegistry.cpp:1221) orPrepareRegisteredInBackground(ShaderRegistry.cpp:1740-1753) deferring. Add a registry-level test with a budget of0that pins the deferred behaviour (entries empty,prepared.deferredset, shader prepared on first use). With a budget of0the existingprepared_*/preparation_scope_settletests that assert work at registration fail, so they need the same treatment or to run with a large budget.GlobalMemoryStatusExfails (PerformanceOverlay.cpp:450returns nullopt, so the budget becomes unlimited) and that preparation moves to first use, so a title may stall on its first draws.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-27T01:45:45Z.
Review: CHANGES_REQUESTED
Thanks for the registry-level test (
agc_driver_prepared_shaders_lazy_budget_zero), the negative control, the MinGW link fix and the description of theGlobalMemoryStatusExfailure case; those points are settled.One point is still open:
mainvs this change, with the default budget and with a lowAPS5_REGISTRATION_PREPARE_COMMIT_GB, from the same machine and scene. If you have no title to run, a registration of many large shaders in a test harness that prints the peak is enough.