fix(agc): read user-data callees up to the 1 MiB raw shader program limit #10140
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10140"
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 frankea on 2026-10-23T10:40:30Z.
What
ReadUserDataCallee(6d9321fc5) reads a compute shader's user-data or table callee from guest memory until it can prove the return, and throws once it has read 16,384 dwords (64 KiB) without one. Persona 3 Reload (PPSA10872) calls a 17,369-dword callee from compute shader 0x2014960000, so the dispatch throwsits callee at ... does not return within 65536 bytesbefore the shader is recompiled; @zaidhawk raised the limit to 32,768 dwords locally to get past it (#9068 comment).ShaderRegistryalready uses for the raw shader program it reads at the same address range (limit = 1024 * 1024in the snapshot reader). A callee that does not return within it still throws the same message with the new size, and an unreadable page before the return still throwsis not readable at.UserDataCalleeLengthdecodes the callee from its start each time it is asked, and the reader asked after every 4 KiB page, so reading n dwords cost O(n²/1024) decoded dwords. With a window 16 times larger, the reader now asks when the read size has doubled since the last check, at the limit, and when the next page is unreadable, so a callee costs at most about twice its length in decoded dwords. The result is the same:UserDataCalleeLengthreturns at the firsts_setpc_b64through the link register, so words read past it never change the answer, and the checks before an unreadable page and at the limit keep every callee that returned before.Tested
Windows 11 (build 26200), NVIDIA GeForce RTX 4090 (driver 616.92), MinGW GCC (WinLibs 15.2) Release build with
BUILD_TESTING=ON.agc_driver_compute_user_data_calls(both modes, plain and--registered, wave32 and wave64 where the test runs them): a 20,000-dword callee (v_add_nc_u32 v1, 1, v1, 19,998s_nop 0,s_setpc_b64 s[14:15]) in 20 committed pages of a reservation whose 21st page is not committed, called with the existing 64-adding callee: every lane gets 3 x (1 + 64). The return lies in the last page, which is read after the last size check, so the case also covers the check before an unreadable page.agc_driver_compute_user_data_calls(2),agc_driver_compute_table_calls,agc_driver_compute_fs_table_callsandscalar_call:947329467onmain513ca7e55): 5/5, each test run three times (ctest --repeat until-fail:3).main513ca7e55with only this PR'sComputeUserDataCalls.cpp: bothagc_driver_compute_user_data_callsentries fail withmain'sits callee at 0x1f044a90000 does not return within 65536 bytes; the other three pass.main513ca7e55: 5/5.VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation(Vulkan SDK 1.4.363.0),ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1withctest -V, on this PR and onmain513ca7e55: 5/5 each, neither log haswas not found but was requested by env var VK_INSTANCE_LAYERS, and neither has aVUID-line or any other validation message.tools/check_conventions.py --base origin/mainpasses.Checklist
main; no other open PR implements the same functions. #8140 (tv7) also editsReadUserDataCallee, for a different change (it lets table callees read their program counter); #9068 and #8070 change how callees are linked and matched, not how far one is read.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)mainafter it and keeps itsDrainShaderWritescalls). Also overlaps #8140 inReadUserDataCallee: proposed order #8140 first, then this PR mergesmainand passes #8140'sallowGetpcthroughfinishtoUserDataCalleeLength(asked on #8140).Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T10:44:20Z.
Review: APPROVED
The reader change raises the bound to the existing raw-program 1 MiB limit and replaces per-page full rescans with geometric checks; it still checks for a return before reporting an unreadable next page and retains the bounded no-return error. The regression allocates 20,000 dwords across committed pages followed by an unreadable page and checks both registered/unregistered dispatch paths where supported. The author reports repeated focused CTest passes, explicit main-control failures for the new long-callee cases, unchanged-main controls, and validation-layer runs on Windows/RTX 4090. Those runtime results are author-reported; I could not run the GPU test locally, and a local syntax-only compile was blocked by absent decoder/SPIR-V development headers. In the exact worktree, conventions, diff-check, and main-sync checks pass (1 ahead/4 behind current main; merge clean). Hosted eligibility/intake/conventions/labels pass; product jobs are skipped by the workflow.
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T11:00:33Z.
Review: CHANGES_REQUESTED
A current overlap was missed in the checklist: open #8140 also edits
ReadUserDataCalleeinShaderRegistry.cpp(adding theallowGetpcparameter and using it for table callees). I fetched its current head and pairwisegit merge-treereports a content conflict in this same function. The behavior is distinct, but whichever merges second must reconcile both changes; please coordinate the order with #8140’s author and record the integration dependency/overlap in the checklist. This is required by the repository overlap rule. Your local checks and reported RTX 4090 focused runs remain relevant; I did not run a GPU test locally.