feat(libkernel): optionally report direct memory as the game budget less the configured flexible memory #15064
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/15064"
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 JJenkx on 2026-11-02T13:28:30Z.
What
sceKernelGetDirectMemorySizereturns 13824 MiB today. #10809 changed it to the 12 GiB measured on a PS5 (inside Gran Turismo 7), and it was reverted in #12192 because ASTRO BOT (PPSA21564) allocates 12404 MiB of direct memory itself and then asserts.This PR adds that model behind
APS5_DIRECT_MEMORY_FROM_FLEXIBLEand keeps the 13824 MiB default (as asked in review: the model is not yet confirmed on a console). With the variable set,sceKernelGetDirectMemorySizereports 12736 MiB less the title's configured flexible-memory size (kernel.flexibleMemorySizeinparam.json, 448 MiB by default, already read for the flexible budget):With the variable set,
sceKernelAllocateDirectMemory,sceKernelAllocateMainDirectMemory,sceKernelAvailableDirectMemorySizeandsceKernelMemoryPoolExpandsearch no higher than that size. Without it nothing changes. The host backing stays at 13824 MiB either way.Why this split
sceKernelGetDirectMemorySizeis not a constant: it returns a dmem ioctl's answer after reading thekern.app.memconfsysctl (BunnyFl's disassembly in #10809), so it is per process.sceKernelGetDirectMemorySize()inside ASTRO BOT on a console (12408 MiB expected) would confirm or refute it.Tested
Linux (Arch, kernel 7.2.11, GCC 16.2.1, Release), AMD RX 6650 XT with RADV, head
1693c644c4onmain0278ca9831, where the model was the default, so these runs match the variable being set now (1812afb176added thesceKernelMemoryPoolExpandcheck,6f13e057abmade the model opt-in):agc_idle_publish_wait, also fails onmainhere.guest_flexible_memory_{declared,limited,none,missing}now check the reported size and thatsceKernelAllocateDirectMemory,sceKernelAvailableDirectMemorySizeandsceKernelMemoryPoolExpandstop at it (with thesceKernelMemoryPoolExpandclamp removed, all four fail);guest_memory's largest-free-block case uses the reported size as its top.APS5_TRACE_MEMORY=1:main(13824 MiB)mainwith 12288 MiB (as #10809)Can't allocate direct memoryat 6 s, exit 139Earthion (PPSA28061, 1024 MiB flexible, so 11712 MiB direct), the same inputs on
mainand this PR with the variable set: both exit 0 at 213 s with a 59.94 FPS median and allocate 1111 MiB of direct memory, with no allocation failure.Blue Prince (PPSA25009, 1024 MiB flexible): on
mainand this PR with the variable set alike it stops at 46.4 s on the unimplemented "sample-preserving guest publication of native multisample depth" path, having allocated 3678 and 3692 MiB of direct memory, with no allocation failure.Windows, independent run by @maskym (report): exact head
7d36292121merged alone intomaina4eca2a056, Windows 11 26300, Intel i7-12700K, WinLibs GCC 15.2.0 UCRT, Release, build clean. The 42 tests this PR adds or extends (including all eightguest_flexible_memory_*cases,guest_memoryandguest_mmap_*) pass in each of three runs, 126 passes. Not run on a PS5.Not tested: titles that size pools from the reported total.
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)