fix(libSceAgc): match firmware atomic GDS arguments and unversioned aliases #8314
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/8314"
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-20T09:48:09Z.
What
Fixes the atomic GDS builders and adds two unversioned aliases, using the decrypted
libSceAgc.sprxexports as evidence.DCB argument layout.
sceAgcDcbAtomicGds(pH3-dfRpfA0) andsceAgcDcbAtomicGds_0900(zARR5aCmkoY) take one more argument than upstream declares:esiis shifted left by 30 into the operation dword (shl ebx, 0x1e).controlis inedx(and r13d, 0x20; shl r13d, 0xd).ecx(xor ecx, 1), gdsOp inr8and src inr9.+0x10..+0x38.Upstream's signature started at
control, so every argument a title passed was shifted by one. The new leadingengineargument is written to ENGINE_SEL (bits 30-31).Seven-bit op mask. The unversioned builders mask the atomic op to seven bits. The DCB variant computes
mov r9d, edx; shl r9d, 7; or r9d, edx; and r9d, 0x1007f, which is(control & 0x7f) | ((control & 0x200) << 7); the ACB variant does the same inedi._0900computes(control & 0xff) | ((control << 7) & 0x10000)(movzx eax, dl, thenshl esi, 7; and esi, 0x10000). So the only difference is control bit 7, which feeds nothing else, and both unversioned exports forwardcontrol & ~0x80uto_0900.New
sceAgcAcbAtomicGds(cduV1f0dcGQ). Apart from that mask, it is the same assceAgcAcbAtomicGds_0900, with the same argument registers.New
sceAgcGetFusedShaderSize(nQT5kYLv0cg). Its body is the same as_0080, except that it stores the alignment withmov dword ptr [rdi + 8], 4instead ofmov qword ptr [rdi + 8], 4. It does not call_0080: like the firmware body, it checks the halves and writesback->num_sh_registers * 8and the 32-bit alignment of 4 itself, without the geometry layout_0080computes. Mismatched halves return 0x8a6c0008 before the output is touched.Tested
Linux (CachyOS, GCC, Release). All four targets pass:
agc_end_of_shader_action_size_testsnow passes an engine. It checks operation dword0x801500e1for_0900and0x80150061for the unversioned call.agc_atomic_gds_size_testschecks that the ACB unversioned packet clears bit 7 and that the rest of its payload matches_0900.agc_shader_fusion_testschecks that the unversioned size query leaves the upper dword ofm_alignuntouched.agc_command_testsis unchanged.main0a0ed72167, head ef101701f1):agc_commands,agc_atomic_gds_size,agc_end_of_shader_action_size_testsandagc_shader_fusionran underctest -VwithVK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation,ANYPS5_NO_SHADER_CACHE=1andANYPS5_REQUIRE_VULKAN=1, onmainand on this change, 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). All four pass on both. Neither log reports the missing-layer warning, the loader inserted the layer in both, and neither has aVUID-error or any other validation message. Onlyagc_shader_fusioncreates a Vulkan device; the other three build command buffers on the CPU, so the layer has nothing to check there.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)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_01RbLgECLQ2bpDM7oe2urGZK
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-23T04:43:37Z.
Review: CHANGES_REQUESTED
I found a null-output regression in the new
sceAgcGetFusedShaderSizewrapper. It calls_0080with a localresult, so_0080’s existingdst == nullptrvalidation never sees the caller’s pointer. On a successful query the wrapper then unconditionally writesdst->m_sizeanddst->m_align; a nulldsttherefore dereferences null instead of taking the establishedAPS5_INVALID_ARG_EXpath. The existing_0080test already expects that path for a null destination, but the new unversioned entry point has no corresponding case. Please validatedstbefore delegating (or otherwise preserve the same invalid-argument behavior) and add a regression forsceAgcGetFusedShaderSize(nullptr, validFront, validBack).Pull request closed