fix(videoout): pace the next flip from the vblank a flip was released at #416

Merged
oneandonlydean merged 1 commit from upstream-pr/416 into main 2026-10-03 06:34:20 +00:00
oneandonlydean commented 2026-10-02 22:34:38 +00:00 (Migrated from github.com)

Imported from boykopovar/AnyPS5. Originally posted by oneandonlydean on 2026-10-02T22:34:38Z.


What

processFlip waits until the vblank count reaches lastFlipVblank + flipRate + 1, releases the flip, presents it, and then set lastFlipVblank to the vblank count after the host present returned. When the image acquire, the wait for an earlier presentation or the present itself crossed the next vblank, the recorded vblank was one too late, so the next flip's target moved out by one vblank even when that flip was already queued. A frame that was ready in 17 ms was then shown for 33 ms, and a title that advances its logic by a fixed step per presented frame runs in slow motion.

A flip takes effect at the vblank it is released at, so lastFlipVblank is now recorded at release, right after the vblank wait, instead of after the present. Flip events, flipStatus and flipPendingNum are unchanged.

This pairs with #417: that change makes a flip complete only once the frame's GPU work has finished, so presents end later and, without this fix, more flips would miss a vblank.

Tested

  • Linux (CachyOS, RTX 4090): full build with BUILD_TESTING=ON and ctest pass.
  • New by-hand mode video_out_flip_tests pacing (needs a GPU and a display, like the file's other presentation modes): submits the first flip of a port at flip rate 2. It is released at vblank 3, and its presentation opens the device and swapchain, so it ends several vblanks later; the test checks that lastFlipVblank is 3. Three runs each: with this change lastFlipVblank is 3 while the vblank count at completion is 10 or 11; on main it is the count after the present (10 or 11) and the test fails.
  • video_out_flip_tests present and backtoback pass.
  • PPSA21564: the change has been on my integration branch through repeated passes of my visual regression check (checkpoint frames, flicker, shimmer, video tearing, FPS).

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 (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
  • AI-assisted: yes
<!-- greyfinch-sync:boykopovar/AnyPS5:issue:4722168314 --> Imported from [boykopovar/AnyPS5](https://github.com/boykopovar/AnyPS5/pull/416). Originally posted by [oneandonlydean](https://github.com/oneandonlydean) on 2026-10-02T22:34:38Z. --- ### What `processFlip` waits until the vblank count reaches `lastFlipVblank + flipRate + 1`, releases the flip, presents it, and then set `lastFlipVblank` to the vblank count *after* the host present returned. When the image acquire, the wait for an earlier presentation or the present itself crossed the next vblank, the recorded vblank was one too late, so the next flip's target moved out by one vblank even when that flip was already queued. A frame that was ready in 17 ms was then shown for 33 ms, and a title that advances its logic by a fixed step per presented frame runs in slow motion. A flip takes effect at the vblank it is released at, so `lastFlipVblank` is now recorded at release, right after the vblank wait, instead of after the present. Flip events, `flipStatus` and `flipPendingNum` are unchanged. This pairs with #417: that change makes a flip complete only once the frame's GPU work has finished, so presents end later and, without this fix, more flips would miss a vblank. ### Tested - Linux (CachyOS, RTX 4090): full build with `BUILD_TESTING=ON` and `ctest` pass. - New by-hand mode `video_out_flip_tests pacing` (needs a GPU and a display, like the file's other presentation modes): submits the first flip of a port at flip rate 2. It is released at vblank 3, and its presentation opens the device and swapchain, so it ends several vblanks later; the test checks that `lastFlipVblank` is 3. Three runs each: with this change `lastFlipVblank` is 3 while the vblank count at completion is 10 or 11; on main it is the count after the present (10 or 11) and the test fails. - `video_out_flip_tests present` and `backtoback` pass. - PPSA21564: the change has been on my integration branch through repeated passes of my visual regression check (checkpoint frames, flicker, shimmer, video tearing, FPS). ### 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 in [TechnicalDebt](https://github.com/boykopovar/AnyPS5/blob/main/docs/dev/TechnicalDebt.md#silent-stubs) - [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] AI-assisted: yes
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!416
No description provided.