feat(agc): run COND_INDIRECT_BUFFER branches whose comparison always passes #898
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/898"
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 alfalfa-star on 2026-10-06T14:20:29Z.
What
Run
COND_INDIRECT_BUFFERbranches whose comparison always passes, and stopsceAgcCbBranchfrom rejecting fields that such a branch never reads.PPSA14632 (LEGO Horizon Adventures, Unreal Engine) calls
sceAgcCbBranch(cb, mode 1, compare function 0, compareAddress, mask 0, reference 0, 0, then, n, 0, nullptr, 0)from one place (eboot 0x5084ea4, through a wrapper at 0x50ff640). The caller never setsrcx, so the compare address is whatever the register holds: it was 0x300d5f4ac8 in one run and 0x300d5f4e84 (only 4-byte aligned) in another. Onmain:sceAgcCbBranch: null or misaligned address 0x0for the null else buffer, and, once that is relaxed, for the misaligned compare address.INDIRECT_BUFFER(invalid INDIRECT_BUFFER size), so the 14-dword branch would fail at submission.Changes:
sceAgcCbBranchchecks the compare address only when the compare function is not 0 (always), and a buffer address only when its size is not 0. The packet is written as before.copySegmentruns the first buffer of an always-passCOND_INDIRECT_BUFFERin modes 1 and 2 in place of the packet, as it does for a non-chainedINDIRECT_BUFFER. Modes 1 and 2 are assumed to be AMD's if-then and if-then-else. A real comparison, a predicated branch and other modes throw. A comparison would have to read memory that earlier packets of the queue may still write, so it is left for a title that needs it.TechnicalDebt lists both.
Tested
agc_branch_patch_tests: an always-pass branch with an unaligned compare address and a null else buffer of 0 dwords, and an empty branch, are written; a comparison with a misaligned address, or a null buffer with a size, still throws without advancing the buffer. Fails onmain.agc_driver_pm4: an always-pass if-then and if-then-else run only the first buffer, an empty branch skips to the next packet, and a comparison or mode 0 rejects the whole submission. Fails onmainwithinvalid INDIRECT_BUFFER size.storage image access to depth/stencil surface ... is not implemented, which #425 may address.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 github-actions[bot] on 2026-10-07T11:46:16Z.
Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.
main)docs/dev/TechnicalDebt.mdL231Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-07T16:26:56Z.
Checked the packet layout, modes 1/2 and compare function 0 against AMD's
si_ci_vi_merged_pm4defs.h(COND_INDIRECT_BUFFER_MODE_IF/IF_ELSE,FUNC_ALWAYS), build + full ctest on Linux (398/398), and that both new tests fail without the change; merging.