fix(libSceAgc): fuse geometry halves with the back half's register lists #10048
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/10048"
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 hypermoist on 2026-10-23T06:21:23Z.
What
For geometry halves,
sceAgcFuseShaderHalves_0200wrote the back half's SH registers into the caller's memory plus every front-half SH register the back half lacks (except the front checksum).sceAgcGetFusedShaderSize_0080reported that longer list. The fused context register list merged in the front half's context registers the same way.The decrypted PS5 13.60
libSceAgc.sprx(read from disassembly, not measured on a console) does neither:sceAgcFuseShaderHalves, 0xf7d0): for both pair types (4 with 6, and 5 with 7) it copies the back half's 0x60-byte header into the result and sets the fused type. When memory is passed, it copiesback->num_sh_registers× 8 bytes of the back half's registers there and points the result at them. It then patches those registers in place. Its only writes to the result header are that copy, the type byte and the SH register pointer, so the fused header keeps the back half's SH count and the back half's context register pointer and count. No front register is added to either list, and the context registers are not patched._0080, 0xf750): both pair types reportback->num_sh_registers× 8, alignment 4.This brings us in line:
Why it matters: a title that sizes the memory from the size query was fine before, because both sides used the longer list. But on the console that memory only ever holds the back half's list. A front-only register would therefore make our fusion write past a buffer sized the console's way. The test shows this: with the old list restored, the fusion writes past the reported size.
Unchanged and recorded in the new debt entry: the fused program is still rebuilt in memory libSceAgc owns, so the header's tables are copies beside the fused code rather than the back half's own. Hull halves are not changed.
The code is written from the observed behaviour; nothing from the module is copied.
Tested
agc_shader_fusionnow checks:Restoring the old SH register loop makes the test fail ("fusion wrote past the reported size"), and so does restoring the old context register merge ("fused register counts are wrong"). The rejection cases (no final jump, no trailer, embedded constants) still throw from the size query.
agc_shader_fusionpasses; the NID-patchedlibSceAgc.prxbuilds.agc_shader_fusionpasses and the NID-patched prx builds.ctest -V -R '^agc_shader_fusion$'withVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1, onmain0a0ed72167and on this change (fd6782a638), on the same machine and GPU (NVIDIA GeForce RTX 3060, driver 615.78.08, CachyOS Linux 7.2.9, vulkan-validation-layers 1.4.363). Both pass. Neither log reports the missing-layer warning, the loader's layer debug output shows the layer inserted at instance and device level in both, and neither log has aVUID-error or any other validation message. Logs are in the review reply.d6f67d1be2,258e4d526d), were not run.tools/check_conventions.pyis clean. Overlap (tools/pr_overlap.py):tests/ShaderFusion.cpp. Its new assertions compare withsize.m_sizeand hold with this change, so whichever lands second only needs that hunk merged.docs/dev/debt/libSceAgc.mdand could not be compared.Checklist
main; no other open PR implements the same functionsNotImplemented_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)ShaderFusion.cpp; this lands second and keeps both assertions)Assisted With AI: Yes. All tests were run locally on computer hardware (AMD Ryzen 5 5600G, 32 GB RAM, NVIDIA GeForce RTX 3060, CachyOS Linux 7.3, GCC 16.2), not on an actual console.
https://claude.ai/code/session_01SNqSvnFwRBz3D76n476yw6
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T06:25:03Z.
Review: CHANGES_REQUESTED
The SH-list change is consistent with the described 12.00 disassembly: the fused geometry header and caller buffer now use the back half's count, while resource and program-address patches are retained. I also checked that
ComputeGeometryLayoutstill validates the unsupported geometry layouts before the size query returns, and that the revised test keeps the reported-size boundary assertion.I could not run
agc_shader_fusionlocally: the available checkout is a source snapshot without Git metadata or a configured AnyPS5 build, and the repository checkout has no configured build tree. The reported GCC/Linux and Windows/Wine runs are useful, and the current hosted PR checks report success for eligibility, conventions, intake, labels and progress report; the hosted product build jobs are skipped.Before approval, please attach the repository-required matched
mainand changeagc_shader_fusionruns withANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, from the same machine and GPU. Please include the GPU vendor/model/driver/OS and confirm the logs contain no missing-layer warning and no newVUID-errors. The PR currently describes an RTX 3060 test device but no validation-layer comparison or title run. Also, the branch is 2 commits behind currentmain; please refresh it and rerun the focused checks so the review covers the current base. The reported #8314 test overlap appears manageable as described, but should be rechecked after the refresh.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T06:28:05Z.
Review: CHANGES_REQUESTED
Re-reviewed exact head
f6483c444400a6be0b42ffdc471a1c3a1c9fe9eb. The added context-register change is consistent with the PR's described header behavior:ComputeGeometryLayoutnow retains the back half's SH and CX lists, while the existing geometry code/resource patching remains. The updated regression checks that the front-only context register is absent. Localgit diff --checkandtools/check_conventions.py --base upstream/main --head HEADpass;tools/check_main_sync.pyreports 2 commits ahead / 20 behind currentupstream/main, with a clean merge.The outstanding validation request remains: the repo requires matched
agc_shader_fusionruns on main and the change usingANYPS5_REQUIRE_VULKAN=1,ANYPS5_NO_SHADER_CACHE=1, andVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation, from the same GPU/machine, including a VUID comparison. The reported Linux and Windows/Wine focused tests are useful but do not include that baseline/head validation evidence. Hosted eligibility, conventions, labels, and report checks pass; hosted product build jobs are skipped. No configured local build is available here, so I did not run the focused runtime test. Please refresh against current main, rerun the required matched checks on the resulting head, and recheck the #8314 test overlap after the refresh.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T13:24:12Z.
Review: CHANGES_REQUESTED
Re-reviewed exact head
cb3bfca6dd6bf2556dcc0e7459c4c3b07f5037e9. The author has supplied the required matchedagc_shader_fusionmain/head validation-layer runs on the same RTX 3060 machine: both pass, the layer is present, no missing-layer warning or VUID appears, and the description records the GPU. A direct merge preview with open #8314 now reports a content conflict incore/libs/prx/libSceAgc/tests/ShaderFusion.cpp; both checklists sayDepends on: none. Please agree the landing order with #8314’s author and declare it withDepends onif needed, preserving both assertions after rebase. This is a keep-both sequencing requirement, not a closure request.Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-29T08:23:43Z.
Review: APPROVED
Re-reviewed exact head
be777913bd7f9b781082e9c4b668f3ab65f46baaagainst livemain4c7d275bef89d309313d16bc2bc05d37a1b50be2.The earlier #8314 sequencing blocker is resolved: #8314's author confirmed it lands first, and this PR records
Depends on: #8314, preserving both test assertions on rebase. The separate #10919 debt ordering is also resolved because #10919 merged first and this branch retains both debt entries.The geometry fusion change still validates back-half register counts and bounds writes to the queried size. The reported negative controls fail for the intended reasons. The same-machine validation-layer A/B run on the earlier feature revision showed
agc_shader_fusionpassing on both main and the change, the layer loaded in both logs, and no VUIDs. The subsequent changes do not alter the shader fusion source or test; the latest post-rebase report says the focused test and full Linux AGC suite passed, with the expected GPU-less skip behavior.Current-main checks:
40a6f192387b79ab9f7c5cb2ed06e29e48bc999a).git diff --checkand current-main conventions pass.I did not run GPU tests locally. No blocking finding remains.