fix(libc): register guest heap blocks without GPU access #3213
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3213"
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 Raghav314 on 2026-10-11T01:33:34Z.
What
This is the follow-up #1905 left open: AnyPS5's own libc heap without GPU access. @TheAggie measured what it costs today in #1905: vkQuake (PPSA99010, homebrew, RADV) makes about 10,000 small blocks through this heap, every address-based build refreshes a heap mirror for each, and leaving only those blocks out took the demo from about 22 to 44 FPS, with correct rendering and no BDA faults.
AnyPS5's libc heap registered every block it hands out with GPU access, so every address-based build imported or mirrored each of the title's malloc blocks. On the console the heap is not GPU memory: a title's own
libc.prxmaps it withsceKernelMapNamedFlexibleMemoryInternaland protection3(CPU read and write, no GPU bits). PPSA36082's bundledlibc.prxdoes this at both of its heap mapping sites (+0xb2eb,+0xb4fd).GuestHeapAlignForGpu, which registers the block with GPU access.Of the local changes I listed in #1905, this is the libc heap part of the first one (GPU read and write kept apart), taken alone because of that measurement. The rest stay local. In particular, paths other than address-based builds (DMA copies, textures) still import a heap block if a title points them at one; making every path follow GPU access was the second change listed there.
Tested
Linux, RTX 4090, NVIDIA 615.71.09, local run of the Linux CI job (SPIRV tools on): ctest 754/755. The failure,
agc_driver_dcc_keys_first_write, fails the same way on main.agc_driver_graphics(tests/BdaResources.cpp): a plain heap block has no GPU access and is left out of an address-based build, a block fromGuestHeapAlignForGpuhas it and is in the build, and both keep their access through a reallocation. Registering plain blocks with GPU access again, as main does, fails it. The cached-address-space test andagc_driver's copy into host memory model memory the GPU reads, so they now allocate it with GPU access.libc.prx, so I expected no change): boot and the hub, no BDA faults, the same frame rate within noise (34.0 / 34.5 fps).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)Imported from boykopovar/AnyPS5. Originally posted by Silverash-i8 on 2026-10-11T01:51:15Z.
Windows run, since the PR has no Windows results yet: Windows 11, WinLibs GCC 15.2.0 r7, Release, merged onto
maind31b57a4in one build with #3213, #3159, #3158, #3142, #3141 and #2977, on an RTX 5060 Laptop and the Arrow Lake iGPU (ANYPS5_GPU=Intel).agc_driver_bda_device,agc_driver_bda_span_reads(BdaResources.cpp) andagc_driver(Submit.cpp) pass on both GPUs. Withmain+ this PR alone,agc_driver_dcc_keys_first_writealso passes on both.In the full
ctestof that build, the only failure not also on plainmainisagc_driver_dcc_keys_first_write, which I bisected to #3158 alone (reported there).AI-assisted (Claude Code); I ran this on my machine.
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-11T07:14:11Z.
Checked the diff: heap blocks register without GPU access, realloc/realign keep it,
GuestHeapAlignForGpuis used only where the GPU reads (AvPlayer texture fallback). Build + ctest of AgcDriver, AvPlayer and libc pass (402/402); the updated tests don't build without the change. Thanks @Silverash-i8 for the Windows run. Merging.