fix(libkernel): submit APR command buffers that were not constructed #2357
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2357"
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 NahuelGenchi on 2026-10-09T16:14:34Z.
What
sceKernelAprSubmitCommandBufferreturnedEINVALfor any buffer object thatsceAmprAprCommandBufferConstructorhad not tagged withBufferType::Apr. That tag is AnyPS5's own. In the retail object, as ampr_emu lays it out, the type word only holds state bits (gather/scatter valid, map active). TheCommandBufferconstructor writes 0 there and theAprCommandBufferconstructor only zeroes the map and gather/scatter state. So a zero-filled object that was bound withSetBufferis a valid APR buffer, and ampr_emu's submit does not check the type.CRI's file system, as linked into Sonic Origins (PPSA05324), relies on this. It lays out its 0x28-byte
AprCommandBufferobjects in its own zeroed work memory and never calls either constructor: it only callsSetBuffer,Resetand the record functions. Its first read is aReadFile, aWriteAddressand aWriteKernelEventQueue, submitted with priority 1. That submit returned0x80020016, CRI loggedFS:Failed in submitCommandBufferand stopped. No movie was ever opened, and the title stayed on a white screen after the SEGA logo (#2021).The submit now only rejects a null buffer.
sceAmprAprCommandBufferConstructorstill sets the tag, andsceAmprCommandBufferGetTypestill returns it. ampr_emu returns 0 there, but that is a separate change.Tested
Ubuntu 26.04, GCC 15.2, Release build, AMD Radeon R9 380 (RADV, Mesa 26.0.8).
guest_ampr_markerspasses. The new check builds a buffer object as CRI does: zero-filled, no constructor,SetBufferandReset. It then records aReadFile, a completion write and an AMPR event, and submits with priority 1. It checks the read data, the written value and the event on the queue. Without the change it fails at the submit (GuestAmpr.cpp:542).guest_equeue_eventspasses.--res_x=960 --res_y=540):raw/movie/sonicteam_logo_4k.usmand the H.264 decoder is created ([videodec2] decoder 1: codec=1 max 3840x2160).tools/check_conventions.py --base origin/mainandgit diff --checkpass.Checklist
main; no other open PR implements the same functions (#1616 reorders this object but keeps the check)NotImplemented_nid_no_patch); silent stubs are listed in TechnicalDebt.mdfiles or images added to the repository (attach them to this PR)🤖 Generated with Claude Code
Imported from boykopovar/AnyPS5. Originally posted by Kikoarl on 2026-10-09T17:52:31Z.
Tested on Linux (CachyOS x86_64, Intel RPL-S iGPU / Mesa 26.3.0-devel / Vulkan 1.4.363, GCC 16.2.1) at
6c81134f:/tmp/anyps5_build) with zero warnings/errors.python3 tools/check_conventions.py --base origin/main --head HEAD-> PASS (0 errors).GuestAmpr.cpptest suite. Unconstructed APR command buffers now gracefully handle submission without asserting or crashing.LGTM!
Imported from boykopovar/AnyPS5. Originally posted by popcoder565 on 2026-10-09T19:41:53Z.
Native Windows run, since no Windows results were posted. Setup: Windows 10 (19045), MinGW-w64 GCC 15.2.0 (WinLibs r7), Release. Head
6c81134f, merged ontomain8b393b6ein one build with 31 other PRs that had no Windows run.guest_ampr_markers.guest_offline_imports, broken by #2359 (reported there).No title was run.
🤖 Addressed by Claude Code