AvPlayer frame-buffer accounting: decide how PR #1601's held frames coexist with TestPs5ExtendedInitLayout's expected texture count #6898
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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 blawesom on 2026-10-16T17:08:27Z.
Context
PR #1601 ("fix(avplayer): keep handed-out video frames until later frames are handed out", by @awake-devel) keeps the newest handed-out video frames intact so a title drawing a frame does not have it overwritten by the decoder (reported in Hollow Knight: Silksong, PPSA12544 — see discussion #1519). The author is currently updating the branch and asked for this issue to be opened so a maintainer can decide how to resolve a semantic conflict with main (comment, 2026-10-11).
The conflict
While PR #1601 was in flight, main gained
TestPs5ExtendedInitLayout(PR #2159, commitb6f42c75d), which asserts atcore/libs/tests/GuestAvPlayer.cpp:1040:with
Buffers = 3(the count the test writes at offset 0x228) andDecodeAheadBuffers = 4(AnyPS5's own decode-ahead pool from PR #591). Total expected textures: 7.PR #1601 allocates 4 additional framebuffers to hold handed-out frames, so with the change the count settles at 11 and the check above never passes. This was first spotted by @blawesom while rebasing (comment, 2026-10-11):
Per @awake-devel, the console's true total texture count for AvPlayer is unknown (no documentation sets it; TechnicalDebt already lists the #591 pool as an assumption) — the point of the #2159 check is only that the field at 0x228 is read.
Decision needed
Which design should land (per @awake-devel's comment, 2026-10-11)?
TestPs5ExtendedInitLayoutis unchanged. Cost: for a title with 2 output framebuffers, only 1 of 6 buffers remains for decode-ahead, which PR #591 added for Unity titles in no-sync mode.TestPs5ExtendedInitLayoutis updated to expectBuffers + DecodeAheadBuffers + 4textures.(A third, "exact" option — tying a frame's lifetime to GPU completion via an AvPlayer↔AGC link — is noted in the PR but not proposed, since the console's rule is undocumented.)
The PR author will update #1601 to match whichever option is chosen.
References
TestPs5ExtendedInitLayout: PR #2159, commitb6f42c75d(core/libs/tests/GuestAvPlayer.cpp:1040)docs/dev/TechnicalDebt.mdImported from boykopovar/AnyPS5. Originally posted by awake-devel on 2026-10-16T17:51:01Z.
Thanks mate
Imported from boykopovar/AnyPS5. Originally posted by MarcZX10 on 2026-10-16T23:03:31Z.
I favor option 2 for the current implementation: keep the four decode-ahead buffers and the additional optional hold buffers. Option 1 would reduce decode-ahead capacity to one buffer in the two-output-buffer case, changing the behavior added for Unity titles that fall behind without sync. Since the console total is undocumented, the test should describe the implementation contract rather than claim a console allocation count: keep checking that changing the field at 0x228 changes the requested output-buffer count, and account for the four optional held-frame buffers in the expected total when allocation succeeds. The existing memory-pressure fallback should remain covered separately. This is a recommendation from the reported behavior and code paths, not console evidence.
Imported from boykopovar/AnyPS5. Originally posted by plokmklo on 2026-10-18T05:45:52Z.
Decision: option 2 — landed on
https://github.com/plokmklo/AnyPS5/tree/contrib/6898-avplayer(commit919d6c6ed) so #1601's author can rebase onto it.The contract now is: AvPlayer allocates the
num_output_video_framebuffersoutput framebuffers first (the 0x228 field stays authoritative); after the decoders open it requests 4 optional decode-ahead framebuffers, and only if that group succeeds it requests 4 more optional held-frame framebuffers. Each group is all-or-nothing: if the memory replacement refuses any buffer, that group is rolled back completely. When the held group is granted, the player keeps the current frame plus the 4 newest handed-out frames intact regardless of the output-buffer count, and reuses free buffers oldest first so a just-released buffer is the last one rewritten. When it is refused, retention staysmax(videoBuffers − 3, 0)and behaviour matches main today.TestPs5ExtendedInitLayoutnow expectsBuffers + DecodeAheadBuffers + HeldFrameBuffers(3 + 4 + 4 = 11) — it keeps proving that the field at 0x228 is read, while describing the implementation contract instead of claiming a console allocation count.TestOptionalVideoBuffersRespectMemoryLimitgained two cases: limit 9 (held group partially fits → rolled back) and limit 10 (full grant).TestHandedOutFramesStayIntactnow runs with 2 and 6 output buffers. The unknown console rule — how long a handed-out frame stays valid, and whether the console ties reuse to GPU completion — is recorded indocs/dev/debt/libSceAvPlayer.md.Still needs title validation on hardware: re-run the Silksong intro cinematic against a build with this landed to confirm the retention numbers hold.