Skip to content

fix(libSceVideoOut): wait for flip room instead of failing at capacity - #18303

Merged
oneandonlydean merged 2 commits into
boykopovar:mainfrom
relativespace2K:fix/videoout-flip-backlog
Nov 16, 2026
Merged

oneandonlydean merged 2 commits into
boykopovar:mainfrom
relativespace2K:fix/videoout-flip-backlog

Conversation

@relativespace2K

@relativespace2K relativespace2K commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What

sceVideoOutSubmitFlip returned 0x80290012 as soon as VIDEO_OUT_FLIP_QUEUE_CAPACITY (16) flips were pending, so a title that submits one flip per vblank without pacing on flipPendingNum failed once the presenter fell behind the vblank (#16478). SubmitFlip now waits for room the same way the AGC path already does through VideoOutput::WaitForFlipRoom(): up to the existing 60 s FLIP_ROOM_WAIT_MICROS, rethrowing a presenter failure, throwing ProcessShutdown on shutdown, and returning FLIP_QUEUE_FULL only when the queue stays full.

The regression test video_out_flip_backlog submits 180 flips with ANYPS5_FPS_LIMIT=20 and requires all 180 presentations. It comes from Ethan Hainline's candidate/flip-backlog-test (3decc1dd66), cherry-picked with -x.

Note for merge order: #12863 (host pause) holds presentation while the flip queue fills. If it merges first, this wait needs the same PresentHold::Overlapped escape that WaitForFlipRoom has, otherwise video_out_flip_host_pause blocks on the 17th flip and times out at 30 s. Merged naively on top of #12863, that test times out and video_out_flip_backlog still passes.

Tested

Windows 11 IoT Enterprise LTSC 26100, Ryzen 5 5600, RX 6800 XT (RDNA2, subgroup 64), AMD 26.10.1, Vulkan 1.4.315, WinLibs GCC 15.2. ANYPS5_REQUIRE_VULKAN=1, ANYPS5_NO_SHADER_CACHE=1, VK_INSTANCE_LAYERS=VK_LAYER_KHRONOS_validation.

  • main d66e6aac01 with the test only: fails at flip 24 returned -2144796654.
  • This PR: video_out_flip_backlog passes 3 of 3 runs (9.34, 9.48, 9.50 s).
  • video_out_flip* and video_out_port0_presence: 30 of 30 pass (-j1).
  • Neither log has was not found but was requested by env var VK_INSTANCE_LAYERS, and both have zero VUID- lines.

Checklist

Submit 180 flips while presenting at 20 fps and require all of them to
complete. On main the queue backs up and flip 24 returns
VIDEO_OUT_ERROR_FLIP_QUEUE_FULL (0x80290012). With the two-pending limit
candidate the same run completes. Reproduces boykopovar#16478 without the showcase.

(cherry picked from commit 3decc1d)
A title that submits one flip per vblank without pacing on flipPendingNum can outrun a presenter that is slower than the vblank. The backlog then reaches VIDEO_OUT_FLIP_QUEUE_CAPACITY and sceVideoOutSubmitFlip returns VIDEO_OUT_ERROR_FLIP_QUEUE_FULL, which titles treat as fatal (boykopovar#16478).

Wait in SubmitFlip for the same room the AGC path already waits for: the existing 60 s FLIP_ROOM_WAIT_MICROS, with a presenter failure rethrown, shutdown throwing ProcessShutdown, and a timeout returning FLIP_QUEUE_FULL.

Co-authored-by: Ethan Hainline <hainline.ethan@gmail.com>
@github-actions

github-actions Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

Other open pull requests touch the same code. Merging one will break the other, or both implement the same thing. If this one builds on them, list them in Depends on.

Pull request Conflicting files (lines on main) Same exports Same new files
PR 12863 core/libs/prx/libSceVideoOut/tests/Flip.cpp L1025

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 10249 core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp
PR 15973 core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp
PR 16791 core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp
PR 17259 core/libs/prx/libSceVideoOut/CMakeLists.txt
PR 19827 core/libs/prx/libSceVideoOut/CMakeLists.txt
PR 20315 core/libs/prx/libSceVideoOut/CMakeLists.txt
core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp
core/libs/prx/libSceVideoOut/tests/Flip.cpp
PR 20988 core/libs/prx/libSceVideoOut/CMakeLists.txt
PR 21139 core/libs/prx/libSceVideoOut/CMakeLists.txt

@relativespace2K
relativespace2K force-pushed the fix/videoout-flip-backlog branch from 68f3e38 to 1ab0007 Compare November 11, 2026 05:31
@github-actions github-actions Bot added build prx fix error Closes an issue (Fixes #N) labels Nov 11, 2026
@JJenkx

JJenkx commented Nov 11, 2026

Copy link
Copy Markdown
Contributor

Windows check of head 1ab00074f4, merged onto main 85a48c99de (GPU merge ea28270254; CPU merge 78f8b5d0e6).

Setup: Windows 11 Enterprise 22621, AMD RX 6700 XT, AMD driver 26.10.1, MinGW-w64 GCC 15.2 UCRT, Release build.

  • GPU, through the shared Windows GPU FIFO with ANYPS5_REQUIRE_VULKAN=1 and APS5_NO_WGI=1: all 29 selected video_out_flip* tests passed in 3 of 3 runs, 87 of 87 outcomes. They include video_out_flip_backlog, video_out_flip_cpuflip_in_order, video_out_flip_fps_limit and video_out_flip_unavailable. The binaries matched the hashes recorded at preparation, and the receipt shows exit 0 and app_count=0 after cleanup.
  • CPU, Vulkan hidden: 2 passed and 27 skipped (they need a device), with no failures, in 3 of 3 runs.

AI-assisted: yes.

@Doorriiaann

Copy link
Copy Markdown
Contributor

An on-screen run on Linux with NVIDIA, since under plain ctest the flip tests skip without a window (SDL_VIDEODRIVER=offscreen): RTX 3070, NVIDIA 610.57.04, Ryzen 5 5600X, Debian 13, Hyprland (Wayland), GCC 13.3.0 Release, validation layer 1.4.335, ANYPS5_REQUIRE_VULKAN=1 ANYPS5_NO_SHADER_CACHE=1. Each ^video_out_flip test ran once with SDL_VIDEODRIVER=wayland, and video_out_flip_backtoback ran 5 times.

On head 1ab0007 all 29 flip tests pass, including the new video_out_flip_backlog, none skipped, and video_out_flip_backtoback passes 5/5. No VUID- line in any log.

AI-assisted: yes

@MarcZX10 MarcZX10 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the flip-room wait — no blocking findings

Nothing blocks this; the points below are optional.

What I ran

  • Head 1ab00074f414fddc427a46ef2be93477dfe7dea9, base main.
  • Read description.md, commits.md, manifest.json, files.json and diff.patch.
  • Files read: all 3 changed files (src/VideoOutDriver.cpp, tests/Flip.cpp, CMakeLists.txt), changed hunks in full, plus the head source around the changed code through the reader. Excluded by rule: none.
  • Head source read through repo_read.py: src/VideoOutDriver.cpp lines 190–280, 360–500, 712–730 and 840–862, and searches for the names the change touches.
  • No build and no test run in this pass.
repo_read.py search "flipQueue" core/libs/prx/libSceVideoOut/src
repo_read.py search "reservations" core/libs/prx/libSceVideoOut
repo_read.py search "WaitForFlipRoom" core
repo_read.py search "FLIP_QUEUE_FULL" core/libs/prx/libSceVideoOut
repo_read.py cat core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp 190 280

Results

Check Result Note
Diff read, all changed files passed Changed hunks
Wait matches the AGC path passed Same predicate and 60 s deadline
Test wiring (CMake, dispatch) passed By reading
Build not run No build in this pass
Test runs not run Author-reported only
Commands
repo_read.py search "flipQueue" core/libs/prx/libSceVideoOut/src
repo_read.py search "reservations" core/libs/prx/libSceVideoOut
repo_read.py search "WaitForFlipRoom" core
repo_read.py search "FLIP_QUEUE_FULL" core/libs/prx/libSceVideoOut
repo_read.py search "flipStatus.count" core/libs/prx/libSceVideoOut
repo_read.py cat core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp 190 280
repo_read.py cat core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp 360 500
repo_read.py cat core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp 712 730
repo_read.py cat core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp 840 862

Findings

Blocking

None.

Non-blocking

  • core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp:524 — The new wait repeats VideoOutput::WaitForFlipRoom (core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp:196, not in this diff) almost line for line. A shared helper that returns whether room appeared would keep the two paths from drifting apart. This is not a defect today.

Not verified

  • The build and the Windows test runs. The author reports 3 of 3 passes for video_out_flip_backlog and a failure on main at flip 24. I did not reproduce either run, so the negative control is author-reported only.
  • Hosted CI for this head was not checked in this pass.
  • Possible missed wakeup: the presenter's changed.NotifyAll() (core/libs/prx/libSceVideoOut/src/VideoOutDriver.cpp:857, not changed) runs without flipQueue->mutex, so a completion could land between the predicate check at VideoOutDriver.cpp:525 and the sleep. WaitForFlipRoom has the same pattern. As far as I read, the next completion wakes the waiter, so this would cost latency, not a deadlock. Not confirmed at runtime.
  • Merge-order note (#12863, PresentHold::Overlapped): PresentHold does not appear anywhere in core/ at this head, so I could not check that note.
  • CMakeLists.txt and tests/Flip.cpp: only the changed hunks were read, not the whole file. The helpers the new test uses (alignedBuffer, the buffer attribute call) match existing tests in the same file, but I did not read their full definitions.
  • "Fixes #16478" and the cherry-pick from 3decc1dd66: not checkable from the repository.

Sources

  • New wait in SubmitFlip:
    int VideoOutDriver::SubmitFlip(int handle, int index, int flipMode, int64_t flipArg) {
    if (LibcShutdownToken_nid_postfix().stop_requested()) throw ProcessShutdown{};
    if (flipQueue->reservations.load() >= VIDEO_OUT_FLIP_QUEUE_CAPACITY) {
    std::unique_lock lock(flipQueue->mutex);
    const bool room = flipQueue->changed.WaitUntil(lock, TimedWait::DeadlineNanos(FLIP_ROOM_WAIT_MICROS), [&] {
    return flipQueue->failure || flipQueue->stopping || LibcShutdownToken_nid_postfix().stop_requested() || flipQueue->reservations.load() < VIDEO_OUT_FLIP_QUEUE_CAPACITY;
    });
    if (flipQueue->failure) std::rethrow_exception(flipQueue->failure);
    if (flipQueue->stopping || LibcShutdownToken_nid_postfix().stop_requested()) throw ProcessShutdown{};
    if (!room) return VIDEO_OUT_ERROR_FLIP_QUEUE_FULL;
    }
    AgcDriverSubmitFlip_nid_postfix(AgcDriver::FlipInfo{static_cast<std::uint32_t>(handle), index, static_cast<std::uint32_t>(flipMode), flipArg});
  • Existing AGC wait it mirrors:
    void WaitForFlipRoom() override {
    std::unique_lock queueLock(queue->mutex);
    const bool room = queue->changed.WaitUntil(queueLock, TimedWait::DeadlineNanos(FLIP_ROOM_WAIT_MICROS), [&] {
    return queue->failure || queue->stopping || cfg->shutdownToken.stop_requested() || queue->reservations.load() < VIDEO_OUT_FLIP_QUEUE_CAPACITY;
    });
    if (queue->failure) std::rethrow_exception(queue->failure);
    if (queue->stopping || cfg->shutdownToken.stop_requested()) throw ProcessShutdown{};
    require(room, "flip queue stayed full for 60 s: the presenter is not completing flips");
    }

To get this to a good state

Nothing is required. The non-blocking point above is optional.

@oneandonlydean
oneandonlydean merged commit 19b7ce3 into boykopovar:main Nov 16, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build fix error Closes an issue (Fixes #N) prx

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Pending flips grow when presentation is slower than the 59.94 Hz vblank; sceVideoOutSubmitFlip then returns FLIP_QUEUE_FULL

6 participants