feat(libSceVideoOut): register PS4 display buffers #5991

Merged
Get-fix merged 1 commit from upstream-pr/5991 into main 2026-10-17 00:45:00 +00:00
Get-fix commented 2026-10-14 18:36:53 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-14T18:36:53Z.


What

Adds the PS4 functions sceVideoOutSetBufferAttribute and sceVideoOutRegisterBuffers on top of the existing registration. PS4 programs built with the OpenOrbis toolchain import these instead of the ...2 functions; the graphics, input, pngdec and exceptions samples stop at FAIL: unresolved ELF import i6-sR91Wt-4 and w3BY+tAEiQY without them.

  • The PS4 call uses the first free attribute set and returns its index.
  • It accepts linear A8R8G8B8_SRGB (0x80000000) and A8B8G8R8_SRGB (0x80002200) buffers, which map to the PS5 formats 0x8000000000000000 and 0x8000000022000000. Other formats and tiled buffers throw; the PS4 tiled layout differs from the PS5 one.
  • Linear PS4 buffers may be 4 KiB aligned: the OpenOrbis graphics sample places its second 1920x1080 buffer 8,294,400 bytes after the first. DisplayBuffer carries the alignment, so registration and the reads at flip time check 4 KiB for these buffers. PS5 buffers keep the 64 KiB rule.
  • A handle with PS4 buffers writes the PS4 flip status (64 bytes) and vblank status (32 bytes). Writing the 128-byte PS5 flip status into the graphics sample's stack structure overwrote its saved frame pointer.

The libSceVideoOut debt file records the limits. A handle counts as PS4 once PS4 buffers are registered, so a PS4 title that reads a status before that gets the PS5 layout. Only the two linear formats are accepted. The PS4 alignment rule itself is not known.

Part of the PS4 homebrew work tracked in #3093.

Tested

Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, full build with BUILD_TESTING=ON, on main e442f4c2e:

  • ctest for libSceVideoOut and the display-buffer tests: 23/23.
  • The video_out_flip_* modes, which ctest skips under the offscreen driver, run in a window (ANYPS5_REQUIRE_DISPLAY=1): all 12 pass, including the new ps4 mode. It registers PS4 buffers at 4 KiB and 64 KiB offsets, checks the attribute fields, set indices, format mapping, rejected options, tiled buffers and unknown formats, flips the 4 KiB-aligned buffer, and checks that the PS4 flip and vblank status stay within 64 and 32 bytes while a PS5 handle still fills 128.
  • Each of these changes makes the ps4 or labels mode fail: keeping the 64 KiB rule for PS4 buffers at registration or at flip time; not widening the format; not marking the handle as PS4; dropping the label reset; starting the set search at 1; accepting tiled PS4 buffers; writing the PS5 flip or vblank status for PS4; accepting 4 KiB for tiled buffers; ignoring the alignment in the address check.
  • OpenOrbis samples with the other changes listed in #3093 (left out one at a time on main 84b01f9cd, all together on e442f4c2e): graphics (Mandelbrot set, CPU-drawn), input and pngdec (its decoded logo.png) present correct frames in their windows; exceptions passes its test case.
  • tools/check_conventions.py --base origin/main passes.

Not tested on Linux.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Unblocks: OpenOrbis PS4 toolchain samples, #3093
  • GPUs tested: NVIDIA GeForce RTX 5060 Ti, driver 610.88 (32.0.16.1088), Windows 11 Pro 26200
  • AI-assisted: yes (Claude Code)

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4862685896 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5991). Originally posted by [Get-fix](https://github.com/Get-fix) on 2026-10-14T18:36:53Z. --- ### What Adds the PS4 functions `sceVideoOutSetBufferAttribute` and `sceVideoOutRegisterBuffers` on top of the existing registration. PS4 programs built with the OpenOrbis toolchain import these instead of the `...2` functions; the graphics, input, pngdec and exceptions samples stop at `FAIL: unresolved ELF import i6-sR91Wt-4` and `w3BY+tAEiQY` without them. - The PS4 call uses the first free attribute set and returns its index. - It accepts linear A8R8G8B8_SRGB (`0x80000000`) and A8B8G8R8_SRGB (`0x80002200`) buffers, which map to the PS5 formats `0x8000000000000000` and `0x8000000022000000`. Other formats and tiled buffers throw; the PS4 tiled layout differs from the PS5 one. - Linear PS4 buffers may be 4 KiB aligned: the OpenOrbis graphics sample places its second 1920x1080 buffer 8,294,400 bytes after the first. `DisplayBuffer` carries the alignment, so registration and the reads at flip time check 4 KiB for these buffers. PS5 buffers keep the 64 KiB rule. - A handle with PS4 buffers writes the PS4 flip status (64 bytes) and vblank status (32 bytes). Writing the 128-byte PS5 flip status into the graphics sample's stack structure overwrote its saved frame pointer. The libSceVideoOut debt file records the limits. A handle counts as PS4 once PS4 buffers are registered, so a PS4 title that reads a status before that gets the PS5 layout. Only the two linear formats are accepted. The PS4 alignment rule itself is not known. Part of the PS4 homebrew work tracked in #3093. ### Tested Windows 11 Pro 26200, WinLibs GCC 15.2.0 r7, Release, full build with `BUILD_TESTING=ON`, on `main` `e442f4c2e`: - ctest for libSceVideoOut and the display-buffer tests: 23/23. - The `video_out_flip_*` modes, which ctest skips under the offscreen driver, run in a window (`ANYPS5_REQUIRE_DISPLAY=1`): all 12 pass, including the new `ps4` mode. It registers PS4 buffers at 4 KiB and 64 KiB offsets, checks the attribute fields, set indices, format mapping, rejected options, tiled buffers and unknown formats, flips the 4 KiB-aligned buffer, and checks that the PS4 flip and vblank status stay within 64 and 32 bytes while a PS5 handle still fills 128. - Each of these changes makes the `ps4` or `labels` mode fail: keeping the 64 KiB rule for PS4 buffers at registration or at flip time; not widening the format; not marking the handle as PS4; dropping the label reset; starting the set search at 1; accepting tiled PS4 buffers; writing the PS5 flip or vblank status for PS4; accepting 4 KiB for tiled buffers; ignoring the alignment in the address check. - OpenOrbis samples with the other changes listed in #3093 (left out one at a time on `main` `84b01f9cd`, all together on `e442f4c2e`): graphics (Mandelbrot set, CPU-drawn), input and pngdec (its decoded `logo.png`) present correct frames in their windows; exceptions passes its test case. - `tools/check_conventions.py --base origin/main` passes. Not tested on Linux. ### Checklist <!-- Rules behind each item: https://github.com/boykopovar/AnyPS5/blob/main/CONTRIBUTING.md --> - [x] Based on current `main`; no other open PR implements the same functions - [x] One topic per PR; follow-ups go in a new PR - [x] No comments in code except [technical debt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/CONVENTIONS.md) - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed under Silent stubs in their library's [technical debt](https://github.com/boykopovar/AnyPS5/tree/main/docs/dev/debt) file - [x] No notes, investigation `.md` files or images added to the repository (attach them to this PR) - [x] New third-party code is a submodule built from source - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] Unblocks: OpenOrbis PS4 toolchain samples, #3093 - [x] GPUs tested: NVIDIA GeForce RTX 5060 Ti, driver 610.88 (32.0.16.1088), Windows 11 Pro 26200 - [x] AI-assisted: yes (Claude Code) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
github-actions[bot] commented 2026-10-14 18:37:29 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-14T18:37:29Z.


Progress report (73efd94 → 901b92c)

➖ System libraries: 88.86% (+0.0%, +2 implemented functions)

✅ 2 implemented
Library Name
libSceVideoOut sceVideoOutRegisterBuffers
libSceVideoOut sceVideoOutSetBufferAttribute
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6175595099 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5991#issuecomment-6175595099). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-14T18:37:29Z. --- <!-- progress-report --> ### Progress report (73efd94 → 901b92c) ➖ **System libraries**: 88.86% (+0.0%, +2 implemented functions) <details> <summary>✅ 2 implemented</summary> | Library | Name | | - | - | | libSceVideoOut | `sceVideoOutRegisterBuffers` | | libSceVideoOut | `sceVideoOutSetBufferAttribute` | </details>
github-actions[bot] commented 2026-10-15 12:12:51 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by github-actions[bot] on 2026-10-15T12:12:51Z.


Some 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.

Pull request Shared files not compared
PR 674 core/libs/prx/libSceVideoOut/CMakeLists.txt
PR 4040 core/libs/prx/libSceVideoOut/src/Output.cpp
docs/dev/debt/libSceVideoOut.md
PR 5021 core/libs/prx/libSceVideoOut/CMakeLists.txt
core/libs/prx/libSceVideoOut/tests/Flip.cpp
PR 6044 core/libs/prx/libSceVideoOut/CMakeLists.txt
core/libs/prx/libSceVideoOut/tests/Flip.cpp
PR 6170 core/libs/SceTypes.hpp
PR 6222 core/libs/prx/libSceVideoOut/include/VideoOutDriver.hpp
PR 6507 core/libs/prx/libSceVideoOut/CMakeLists.txt
core/libs/prx/libSceVideoOut/tests/Flip.cpp
docs/dev/debt/libSceVideoOut.md
PR 6879 core/libs/prx/libSceVideoOut/include/VideoOutDriver.hpp
<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6191761724 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5991#issuecomment-6191761724). Originally posted by [github-actions[bot]](https://github.com/apps/github-actions) on 2026-10-15T12:12:51Z. --- <!-- pr-overlap --> Some 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. | Pull request | Shared files not compared | |---|---| | [PR 674](https://www.github.com/boykopovar/AnyPS5/pull/674) | `core/libs/prx/libSceVideoOut/CMakeLists.txt` | | [PR 4040](https://www.github.com/boykopovar/AnyPS5/pull/4040) | `core/libs/prx/libSceVideoOut/src/Output.cpp`<br>`docs/dev/debt/libSceVideoOut.md` | | [PR 5021](https://www.github.com/boykopovar/AnyPS5/pull/5021) | `core/libs/prx/libSceVideoOut/CMakeLists.txt`<br>`core/libs/prx/libSceVideoOut/tests/Flip.cpp` | | [PR 6044](https://www.github.com/boykopovar/AnyPS5/pull/6044) | `core/libs/prx/libSceVideoOut/CMakeLists.txt`<br>`core/libs/prx/libSceVideoOut/tests/Flip.cpp` | | [PR 6170](https://www.github.com/boykopovar/AnyPS5/pull/6170) | `core/libs/SceTypes.hpp` | | [PR 6222](https://www.github.com/boykopovar/AnyPS5/pull/6222) | `core/libs/prx/libSceVideoOut/include/VideoOutDriver.hpp` | | [PR 6507](https://www.github.com/boykopovar/AnyPS5/pull/6507) | `core/libs/prx/libSceVideoOut/CMakeLists.txt`<br>`core/libs/prx/libSceVideoOut/tests/Flip.cpp`<br>`docs/dev/debt/libSceVideoOut.md` | | [PR 6879](https://www.github.com/boykopovar/AnyPS5/pull/6879) | `core/libs/prx/libSceVideoOut/include/VideoOutDriver.hpp` |
Get-fix commented 2026-10-15 13:35:03 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by Get-fix on 2026-10-15T13:35:03Z.


I checked the overlap the bot lists. I fetched each listed pull request and, for every file it shares with this one, merged its change with git merge-file into current main (a5e2a80c6) and into main with this pull request merged. A conflict that appears only in the second case is one this pull request adds.

The bot lists 25 pull requests, with 46 shared files between them (mostly libSceVideoOut's CMakeLists.txt, tests/Flip.cpp and src/Output.cpp). This pull request adds no conflict to any of them. Two of them already conflict with main in those files, and this pull request doesn't change that.

AI-assisted: yes (Claude Code). I ran these checks myself on Windows 11.

🤖 Generated with Claude Code

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6193361888 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5991#issuecomment-6193361888). Originally posted by [Get-fix](https://github.com/Get-fix) on 2026-10-15T13:35:03Z. --- I checked the overlap the bot lists. I fetched each listed pull request and, for every file it shares with this one, merged its change with `git merge-file` into current `main` (`a5e2a80c6`) and into `main` with this pull request merged. A conflict that appears only in the second case is one this pull request adds. The bot lists 25 pull requests, with 46 shared files between them (mostly `libSceVideoOut`'s `CMakeLists.txt`, `tests/Flip.cpp` and `src/Output.cpp`). This pull request adds no conflict to any of them. Two of them already conflict with `main` in those files, and this pull request doesn't change that. AI-assisted: yes (Claude Code). I ran these checks myself on Windows 11. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
adriadam10 commented 2026-10-16 20:46:45 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by adriadam10 on 2026-10-16T20:46:45Z.


Checked the PS4 attribute layout (40 bytes) and the 64/32-byte flip and vblank status against prosper and shadPS4, ran the ps4, labels and lifetime flip modes with a display on RADV, and confirmed that disabling the PS4 status path makes ps4 fail. Debt entry and tests look right; merging once the full Build is green.

<!-- greyfinch-sync:boykopovar/AnyPS5:comment:6224384392 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/5991#issuecomment-6224384392). Originally posted by [adriadam10](https://github.com/adriadam10) on 2026-10-16T20:46:45Z. --- Checked the PS4 attribute layout (40 bytes) and the 64/32-byte flip and vblank status against prosper and shadPS4, ran the `ps4`, `labels` and `lifetime` flip modes with a display on RADV, and confirmed that disabling the PS4 status path makes `ps4` fail. Debt entry and tests look right; merging once the full Build is green.
Sign in to join this conversation.
No reviewers
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!5991
No description provided.