feat(psml): implement the MFSR shared-resource and 800 context setup #5796
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/5796"
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 ps54all on 2026-10-14T11:23:11Z.
What
scePsmlMfsrInit, the shared-resource calls andscePsmlMfsrGetContextBufferRequirement800M3_2/scePsmlMfsrCreateContext800M3_2/scePsmlMfsrReleaseContextthrew. God of War Ragnarök (PPSA08330 v06.006) calls this setup unconditionally at start-up and stopped atscePsmlMfsrInit not implemented. It only uses the context when its cachedsceKernelIsTrinityMode()result is set (dispatch at 0x3c643d, mip bias at 0x567f97; otherwise it stores a -0.25 mip bias itself at 0x567fe2), and AnyPS5 reports 0 there. So the setup has to succeed, and the per-frame calls are never reached on non-Trinity hardware.{block bytes, alignment, block count}.{address, bytes}block list at 8 and 16.scePsmlMfsrInitsets the initialized state and returns 0.scePsmlMfsrCreateContext1300and the 900/1000/1300 dispatch packets keep main's 0x8A810001 beforescePsmlMfsrInitand throw after it. Packet size, mip bias, capture andSelectConfigstill throw.(context, uint32_t*), then the packet(context, {cursor, size in dwords}*, params), then the caller advances its command buffer by that size (0x8A810006 when the buffer cannot grow). This is recorded in the debt entry.guest_psmllinks libc and getsconfigure_windows_unwind, so it can catch the refused calls.d92a8dad3(the PR no longer carries #5651's commit: main already has its not-initialized answers for the 1100/1300 calls). #5531 edits other lines of the same debt file.Tested
BUILD_TESTING=ON:guest_psmlpasses.Export.cppand this test it fails atscePsmlMfsrGetSharedResourcesInitRequirement not implemented.d92a8dad3:guest_psmlpasses,tools/check_conventions.py --base origin/mainandtools/check_test_registration.pypass.tools/check_conventions.py --base origin/mainandtools/check_test_registration.pypass.scePsmlMfsrInit not implemented.compute shader ...: stores 16-bit data to an image of a SINT format, which main refuses on purpose.Checklist
main; no other open PR implements the same functions (open #5651 also touches the 800M3_2 calls to answer "not initialized" and conflicts with main; this PR does not depend on it)NotImplemented_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)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T11:23:55Z.
Progress report (
c842491→46fdfec)📈 System libraries: 88.94% (+0.11%, +7 implemented, -3 reverted functions)
✅ 7 implemented
scePsmlMfsrCreateContext800M3_2scePsmlMfsrCreateSharedResourcesscePsmlMfsrGetContextBufferRequirement800M3_2scePsmlMfsrGetSharedResourcesInitRequirementscePsmlMfsrInitscePsmlMfsrReleaseContextscePsmlMfsrReleaseSharedResources⚠️ 3 went back to stubs
scePsmlMfsrCreateContext1100scePsmlMfsrGetContextBufferRequirement1100scePsmlMfsrGetDispatchMfsrPacket1100Imported from boykopovar/AnyPS5. Originally posted by nikowolf123 on 2026-10-14T17:13:01Z.
Independent check on Linux, and where each "not initialized" answer comes from. This head carries #5651's commit unchanged (same patch-id as
7315fc0), so @adriadam10's review there applies here too.Linux run (WSL Ubuntu, GCC 15.2.0, Release,
BUILD_TESTING=ON, 1fa0502 merged onto maine34c479, onlyguest_psml_tests,libScePsmlandlibScePsml_debugbuilt):guest_psmlpasses, 3 of 3 repeats. No warnings from the changed files.Export.cpp: aborts atscePsmlMfsrGetContextBufferRequirement800M3_2 not implemented.Export.cpp: aborts atscePsmlMfsrGetSharedResourcesInitRequirement not implemented. That is the failure the description gives for main's file; main's file stops one call earlier.State machine (Export.cpp L97-227): before
scePsmlMfsrInit, every changed call except Init returns 0x8A810001 and writes nothing. Init sets a flag that nothing clears and returns 0, also on a second call. After Init, the shared-resource and 800M3_2 setup succeeds, while the 1100 trio,CreateContext1300and the 900/1000/1300 packets throw.The "3 went back to stubs" line in the progress report is not a regression. The 1100 trio only throws after a successful Init, and on main Init throws, so any title that reaches the new throw had already stopped at Init on main. Before Init the trio keeps the answer @Celegans12 read from Sony's libScePsml.sprx in #644. #644 could return it unconditionally because Init threw ("this is the only state a title can reach"); after an Init that succeeded, "not initialized" would be wrong, so throwing is right.
Sources for the pre-Init 0x8A810001, per call:
ReleaseContext,GetDispatchMfsrPacket900: the argument shapes come from this PR's PPSA08330/PPSA03016 call sites. KytyPS5, already linked from the debt entry, checks the init flag before any argument for each of these NIDs.GetDispatchMfsrPacket1000: the shape comes from the same call sites. KytyPS5 has no entry fors2psNHUIdjk. PS5PCEM routes it to its 900 handler, which checks init first, but its PSML file has the same magics, VA table and 0x360 context offset as KytyPS5, so I don't count it as an independent source.CreateContext1300,GetDispatchMfsrPacket1300: I found no source for either the shape or the answer.That leaves the 1300 pair, and 1000's pre-Init answer, as the open part of #5651's review. Now that Init succeeds, a title only gets those pre-Init answers if it calls them without Init, and no run in either PR reaches them (PPSA08330 only dispatches with Trinity mode set; #5651 ran no title). So keeping them throwing, or listing them under Silent stubs as the review asks, would cost no known title. @Celegans12, if the sprx you read for #644 has the 1000 and 1300 entries, do they start with the same flag check?
If this PR answers that review, #5651 could close as superseded; that is up to @klosixgaming-arch. Landing #5651 first would make this PR conflict in all three files (
git merge-tree), while on its own it still merges cleanly into main.KytyPS5 has a different object layout. Its
CreateSharedResources(eWoKNeB6V-k) writes a 0x30-byte object through the first argument. ItsCreateContext800M3_2(gxv3i+MTEzU) reads the shared resources at param+0x08, where this PR reads the block list, and writes them at +0x360 of the first argument. The description says PPSA08330 keeps both handles in adjacent 8-byte globals, which those writes would overrun, so the call sites look stronger. A half sentence in the debt entry saying KytyPS5 differs would keep the next reader from copying its layout.Nit: L158-163 looks up the shared-resources handle under one lock and inserts the context under another. A concurrent
ReleaseSharedResourcescan pass its "still used by a context" check in between. Holding one lock across both steps would close that gap.Debt file: besides the conflicts the bot lists, #5877's 1100 line still ends with "Only 0x8A810001 (not initialized) is returned", which stops being true with this PR. Whichever PR lands second should keep this PR's before/after-Init wording and add #5877's PPSA26344 sentence.
AI-assisted: written with Claude Code; I checked the Export.cpp state machine against main, #644, #5651's review and the PSML code in KytyPS5 at 9e41d83 and PS5PCEM at 78915be (NIDs recomputed with tools/nid_names.py), and ran guest_psml on Linux in the three cases above plus git merge-tree against #5651, #5531 and #5877.
Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-14T21:21:19Z.
Thanks @nikowolf123 for the independent Linux run and the state-machine walk-through. Agreed on the "-3 reverted" line in the progress report: those calls only throw after a successful Init, and on main Init itself throws, so no title gets less far than before. Nothing to change in the PR from my side; it still waits on #5651, and I will rebase to our commit only once that merges.
Imported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-15T08:21:28Z.
Rebased onto main
d92a8dad3(the head is now 00d0232f9, one commit). Main now carries the not-initialized answers for the 1100 and 1300 calls, which is what #5651 added, so this PR no longer includes #5651's commit and no longer depends on it. The body is updated to match.guest_psmlpasses on the rebased head, and the convention and test-registration checks pass.Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T08:35:21Z.
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)scePsmlMfsrCreateContext1300scePsmlMfsrCreateContext800M3_2scePsmlMfsrGetContextBufferRequirement800M3_2scePsmlMfsrGetDispatchMfsrPacket1000scePsmlMfsrGetDispatchMfsrPacket1300scePsmlMfsrGetDispatchMfsrPacket900Some comparisons could not be completed because a pull request conflicts with the base branch. Review these shared files manually before concluding that there is no overlap.
core/libs/prx/libScePsml_debug/Export.cppcore/libs/tests/GuestPsml.cppdocs/dev/debt/libScePsml_debug.mdcore/libs/prx/libScePsml_debug/CMakeLists.txtcore/libs/tests/GuestPsml.cppImported from boykopovar/AnyPS5. Originally posted by ps54all on 2026-10-15T12:45:45Z.
@nikowolf123, a follow-up on two points from your review that my earlier reply skipped (new commit 9ced189c6):
scePsmlMfsrCreateContext800M3_2now checks the shared-resources handle and inserts the context while holding the lock once (CreateMfsrObjectdoes both steps). A concurrentscePsmlMfsrReleaseSharedResourcescan no longer pass its "still used by a context" check in between.On #5877's wording: this PR already replaces the 1100 line with the before/after-Init text. Whichever PR lands second should keep that text and add #5877's PPSA26344 sentence.
Tested:
guest_psmland the convention checks pass on the new head (Windows 11, WinLibs GCC 15.2.0, Release).AI-assisted (Claude Code).
Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-15T13:02:42Z.
Checked the build and the scoped ctest (33 tests,
guest_psmlincluded) on top of current main, and thatguest_psmlfails without theExport.cppchange. The lock gap and the KytyPS5 layout difference raised earlier are addressed in 9ced189. Merging once CI is green.Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T18:44:37Z.
Head unchanged (9ced189). It conflicted with main only in
docs/dev/debt/libScePsml_debug.md(the 1100 entry); I rebased and merged the PPSA26344 note from main into this PR's wording. Scoped build and tests on the rebased tree (33,guest_psmlincluded) pass. Merging once a Build on the rebased head is green.