AvPlayer frame-buffer accounting: decide how PR #1601's held frames coexist with TestPs5ExtendedInitLayout's expected texture count #6898

Closed
opened 2026-10-16 17:08:27 +00:00 by blawesom · 3 comments
blawesom commented 2026-10-16 17:08:27 +00:00 (Migrated from github.com)
Contributor

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, commit b6f42c75d), which asserts at core/libs/tests/GuestAvPlayer.cpp:1040:

Check(WaitFor([&] { return TextureCount() == Buffers + DecodeAheadBuffers; }), "video frame buffer count at 0x228 of the PS5 extended init not used");

with Buffers = 3 (the count the test writes at offset 0x228) and DecodeAheadBuffers = 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):

"main's newer TestPs5ExtendedInitLayout waits for TextureCount() == Buffers + DecodeAheadBuffers (3 + 4 = 7), but with this change's 4 additional held framebuffers the count settles at 11, so that check never passes"

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)?

  1. Hold inside the existing pool — keep the newest handed-out frames and reuse free framebuffers oldest first; texture count stays 7 and TestPs5ExtendedInitLayout is 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.
  2. Allocate 4 more framebuffers (current #1601) — decode-ahead keeps its 4 buffers; TestPs5ExtendedInitLayout is updated to expect Buffers + DecodeAheadBuffers + 4 textures.

(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

  • PR #1601 and its comments (2026-10-11): rebase report by @blawesom, decision request by @awake-devel
  • TestPs5ExtendedInitLayout: PR #2159, commit b6f42c75d (core/libs/tests/GuestAvPlayer.cpp:1040)
  • Decode-ahead pool: PR #591; assumptions recorded in docs/dev/TechnicalDebt.md
  • Symptom discussion: #1519 (Hollow Knight: Silksong intro cinematic)
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:5888158867 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6898). Originally posted by [blawesom](https://github.com/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](https://github.com/boykopovar/AnyPS5/pull/1601#issuecomment-6108225066), 2026-10-11). ### The conflict While PR #1601 was in flight, main gained `TestPs5ExtendedInitLayout` (PR #2159, commit b6f42c75d), which asserts at `core/libs/tests/GuestAvPlayer.cpp:1040`: ```cpp Check(WaitFor([&] { return TextureCount() == Buffers + DecodeAheadBuffers; }), "video frame buffer count at 0x228 of the PS5 extended init not used"); ``` with `Buffers = 3` (the count the test writes at offset 0x228) and `DecodeAheadBuffers = 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](https://github.com/boykopovar/AnyPS5/pull/1601#issuecomment-6107335796), 2026-10-11): > "main's newer `TestPs5ExtendedInitLayout` waits for `TextureCount() == Buffers + DecodeAheadBuffers` (3 + 4 = 7), but with this change's 4 additional held framebuffers the count settles at **11**, so that check never passes" 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](https://github.com/boykopovar/AnyPS5/pull/1601#issuecomment-6108225066), 2026-10-11)? 1. **Hold inside the existing pool** — keep the newest handed-out frames and reuse free framebuffers oldest first; texture count stays 7 and `TestPs5ExtendedInitLayout` is 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. 2. **Allocate 4 more framebuffers** (current #1601) — decode-ahead keeps its 4 buffers; `TestPs5ExtendedInitLayout` is updated to expect `Buffers + DecodeAheadBuffers + 4` textures. (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 - PR #1601 and its comments (2026-10-11): rebase report by @blawesom, decision request by @awake-devel - `TestPs5ExtendedInitLayout`: PR #2159, commit b6f42c75d (`core/libs/tests/GuestAvPlayer.cpp:1040`) - Decode-ahead pool: PR #591; assumptions recorded in `docs/dev/TechnicalDebt.md` - Symptom discussion: #1519 (Hollow Knight: Silksong intro cinematic)
awake-devel commented 2026-10-16 17:51:01 +00:00 (Migrated from github.com)
Author
Contributor

Imported from boykopovar/AnyPS5. Originally posted by awake-devel on 2026-10-16T17:51:01Z.


Thanks mate

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6221433839 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6898#issuecomment-6221433839). Originally posted by [awake-devel](https://github.com/awake-devel) on 2026-10-16T17:51:01Z. --- Thanks mate
MarcZX10 commented 2026-10-16 23:03:31 +00:00 (Migrated from github.com)
Author
Contributor

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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6226317883 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6898#issuecomment-6226317883). Originally posted by [MarcZX10](https://github.com/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.
plokmklo commented 2026-10-18 05:45:52 +00:00 (Migrated from github.com)
Author
Contributor

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 (commit 919d6c6ed) so #1601's author can rebase onto it.

The contract now is: AvPlayer allocates the num_output_video_framebuffers output 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 stays max(videoBuffers − 3, 0) and behaviour matches main today.

TestPs5ExtendedInitLayout now expects Buffers + 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. TestOptionalVideoBuffersRespectMemoryLimit gained two cases: limit 9 (held group partially fits → rolled back) and limit 10 (full grant). TestHandedOutFramesStayIntact now 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 in docs/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.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6246230627 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/issues/6898#issuecomment-6246230627). Originally posted by [plokmklo](https://github.com/plokmklo) on 2026-10-18T05:45:52Z. --- **Decision: option 2** — landed on `https://github.com/plokmklo/AnyPS5/tree/contrib/6898-avplayer` (commit `919d6c6ed`) so #1601's author can rebase onto it. The contract now is: AvPlayer allocates the `num_output_video_framebuffers` output 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 stays `max(videoBuffers − 3, 0)` and behaviour matches main today. `TestPs5ExtendedInitLayout` now expects `Buffers + 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. `TestOptionalVideoBuffersRespectMemoryLimit` gained two cases: limit 9 (held group partially fits → rolled back) and limit 10 (full grant). `TestHandedOutFramesStayIntact` now 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 in `docs/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.
Sign in to join this conversation.
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
boykopovar/AnyPS5#6898
No description provided.