feat(libSceVideoOut): deliver pre-vblank start events #2152

Merged
MathiasDevelopes merged 1 commit from upstream-pr/2152 into main 2026-10-10 04:44:24 +00:00
MathiasDevelopes commented 2026-10-09 10:07:06 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by MathiasDevelopes on 2026-10-09T10:07:06Z.


What

[sceVideoOutAddPreVblankStartEvent](https://github.com/boykopovar/AnyPS5/blob/main/core/libs/prx/libSceVideoOut/src/Event.cpp) threw VideoOut: physical pre-vblank timing is not implemented. Planet Coaster (PPSA01736) registers a pre-vblank start event at startup and does not catch the exception, so it aborts:

[libc] unhandled exception 'St13runtime_error' thrown from ...
terminate called after throwing an instance of 'std::runtime_error'
FATAL: abort() (SIGABRT)

(what() is not printed on this path. A temporary print in __cxa_throw showed it as VideoOut: physical pre-vblank timing is not implemented.)

The event is now registered through the same registerVideoOutEvent path as the vblank event, so re-registration updates udata and sceVideoOutDeletePreVblankStartEvent (already implemented) removes it. In [VideoOutDriver::vblankEnd](https://github.com/boykopovar/AnyPS5/blob/main/core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp), each emulated vblank tick increments the port's preVblankStatus count, which already existed and was unused, and stamps its process time. It then triggers the pre-vblank start events with that count as data, just before the vblank events of the same tick.

How long before the vblank the console signals pre-vblank start is unknown. The vblank here is a host timer with no scanout, so the event fires at the vblank tick. This is recorded in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md) under unknown function info. [shadPS4](github.com/shadps4-emu/shadPS4@0fe263a476/src/core/libraries/videoout/video_out.h (L52)) defines the event ID but neither registers nor triggers the event, so it gives no reference timing either.

Tested

Windows 11, MinGW-w64 15.2.0, RTX 3060.

  • video_out_flip_tests controls: after the existing vblank checks, the test subscribes a pre-vblank start event with its own udata and waits for a vblank. It checks that both a pre-vblank start and a vblank event are delivered and that the pre-vblank event carries its udata, then unsubscribes. Without the change, it fails with VideoOut: physical pre-vblank timing is not implemented.
  • The present and backtoback modes still pass. video_out_flip_tests opens a real window and is in KNOWN_UNRUN, so I ran these modes by hand.
  • Full ctest suite: 505/505 passed. tools/check_conventions.py --base origin/main passes.
  • PPSA01736: with the change, the title gets past the registration and goes on to render its intro. It needs other fixes to get that far: #1782, #1775, #1777, #1836, #1673 and some local commits.

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 in TechnicalDebt
  • No notes, investigation .md files or images added to the repository
  • New third-party code is a submodule built from source (none added)
  • Generic behaviour, not specific to one title
  • Depends on: none
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4798977029 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2152). Originally posted by [MathiasDevelopes](https://github.com/MathiasDevelopes) on 2026-10-09T10:07:06Z. --- ### What [`[sceVideoOutAddPreVblankStartEvent](https://github.com/boykopovar/AnyPS5/blob/main/core/libs/prx/libSceVideoOut/src/Event.cpp)`](https://github.com/boykopovar/AnyPS5/blob/main/core/libs/prx/libSceVideoOut/src/Event.cpp) threw `VideoOut: physical pre-vblank timing is not implemented`. Planet Coaster (PPSA01736) registers a pre-vblank start event at startup and does not catch the exception, so it aborts: ``` [libc] unhandled exception 'St13runtime_error' thrown from ... terminate called after throwing an instance of 'std::runtime_error' FATAL: abort() (SIGABRT) ``` (`what()` is not printed on this path. A temporary print in `__cxa_throw` showed it as `VideoOut: physical pre-vblank timing is not implemented`.) The event is now registered through the same `registerVideoOutEvent` path as the vblank event, so re-registration updates `udata` and `sceVideoOutDeletePreVblankStartEvent` (already implemented) removes it. In [`[VideoOutDriver::vblankEnd](https://github.com/boykopovar/AnyPS5/blob/main/core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp)`](https://github.com/boykopovar/AnyPS5/blob/main/core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp), each emulated vblank tick increments the port's `preVblankStatus` count, which already existed and was unused, and stamps its process time. It then triggers the pre-vblank start events with that count as data, just before the vblank events of the same tick. How long before the vblank the console signals pre-vblank start is unknown. The vblank here is a host timer with no scanout, so the event fires at the vblank tick. This is recorded in [[TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md)](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md) under unknown function info. [[shadPS4](https://github.com/shadps4-emu/shadPS4/blob/0fe263a4760dfbfa973366890061749b4af0de97/src/core/libraries/videoout/video_out.h#L52)](https://github.com/shadps4-emu/shadPS4/blob/0fe263a4760dfbfa973366890061749b4af0de97/src/core/libraries/videoout/video_out.h#L52) defines the event ID but neither registers nor triggers the event, so it gives no reference timing either. ### Tested Windows 11, MinGW-w64 15.2.0, RTX 3060. - `video_out_flip_tests controls`: after the existing vblank checks, the test subscribes a pre-vblank start event with its own `udata` and waits for a vblank. It checks that both a pre-vblank start and a vblank event are delivered and that the pre-vblank event carries its `udata`, then unsubscribes. Without the change, it fails with `VideoOut: physical pre-vblank timing is not implemented`. - The `present` and `backtoback` modes still pass. `video_out_flip_tests` opens a real window and is in `KNOWN_UNRUN`, so I ran these modes by hand. - Full ctest suite: 505/505 passed. `tools/check_conventions.py --base origin/main` passes. - PPSA01736: with the change, the title gets past the registration and goes on to render its intro. It needs other fixes to get that far: #1782, #1775, #1777, #1836, #1673 and some local commits. ### Checklist - [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 - [x] Unimplemented paths throw (`NotImplemented_nid_no_patch`); silent stubs are listed in TechnicalDebt - [x] No notes, investigation `.md` files or images added to the repository - [x] New third-party code is a submodule built from source (none added) - [x] Generic behaviour, not specific to one title - [x] Depends on: none - [x] AI-assisted: yes
copilot-pull-request-reviewer[bot] commented 2026-10-09 10:07:12 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by copilot-pull-request-reviewer[bot] on 2026-10-09T10:07:12Z.

Review: COMMENTED


Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

<!-- greyfinch-sync:boykopovar/AnyPS5:review:5468647336 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/2152#pullrequestreview-5468647336). Originally posted by [copilot-pull-request-reviewer[bot]](https://github.com/apps/copilot-pull-request-reviewer) on 2026-10-09T10:07:12Z. **Review:** COMMENTED --- Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.
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!2152
No description provided.