Repository navigation
OLD-9189: restore old upstream PR 9189 - FramePacer: at most latency frames in flight while armed (mailbox replace) - #671
Merged
aslan2142 merged 3 commits intoNov 25, 2026
Conversation
…eplace) commit_present_token and note_untokened_present appended a slot for every present, each one period after the last, so presents made with no WaitFrameEventX between them grew the queue without limit and the next wait blocked until the first of them was shown: at latency 2, 1000 blank presents left 1000 frames in flight and the next wait passed 999 periods later. A present into a full queue now replaces the newest queued frame and takes its vblank, like a mailbox: the replaced frame is never shown (no display statistic), the older frames keep their vblanks, and the queue never reaches further than `latency` vblanks ahead, so the next wait passes when the oldest frame is shown. A queue longer than a lowered latency is cut back the same way at the next present. Presents before the event is armed stay unpaced (old upstream PR 4419), and a frame behind a queued one still cannot be shown at once. frame_pacer_test: 1000 untokened presents after one wait at latency 1, 2 and 3, tokened presents beyond the latency (the older ones keep their vblanks, the replaced one has no display statistic), the one-present-per-wait cadence, and a lowered latency. xbox_present_test expected the blank present after a frame at latency 1 to make 2 frames in flight; it is 1 now. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ida#891, BL-6) # Conflicts: # runtime/src/frame_pacer.h Both branches added a private helper in the same place: queue_flip_locked (the bounded queue) and record_present_timing_locked (BL-6 pacing statistics). Both are kept; note_untokened_present records its timing first and then queues through queue_flip_locked. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The pacing statistics are recorded at PresentX, before the frame is queued, so a frame replaced in a full queue (never shown) still counts as a present with its real present-to-present interval; the replacement adds and removes no interval. frame_pacer_test pins that at latency 1: four presents, two replaced, three intervals with known nearest-rank percentiles and mean, two origin-to-present latencies (the replaced token included), and the shown frames keep their vblanks. docs/d3d12_vulkan.md says the intervals are between PresentX calls, not frames shown. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Collaborator
Author
|
Merged Conflict
Dropped frames and the BL-6 statistics
Tests (Linux, portable runtime subset)
AI-assisted (Claude Code, Claude Opus 5.5). |
This was referenced Nov 25, 2026
This was referenced Nov 25, 2026
Collaborator
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Claimed in the coordination issue as: OLD-9189 #14 (comment)
Restoration of my original pull request, old upstream PR 9189 in
ItsNotRexed/Leonida, which was closed unmerged when that repository went private on 2026-11-23 (old numbers link nowhere now). Rebased onto main at 21625bc; the commit applied without changes. The only edit is in the commit message, where an old issue number is now plain text. The uncap mode added tomainsince then (LEONIDA_PRESENT_UNCAP) is untouched: an uncapped present still returns before it reaches the queue.What and why
main,commit_present_tokenandnote_untokened_presentadd one queued frame for every present, each one period after the last.WaitFrameEventXbetween them grow the queue without limit, and the next wait blocks until the first of them is shown.runtime/src/frame_pacer.h): at mostlatencyframes are in flight while the event is armed.SetFrameIntervalXsets a latency below the number of frames already queued, the next present cuts the queue back to the new latency from the newest end.frame_pacer_testnow covers:xbox_present_test: it expected a blank present after a frame at latency 1 to leave 2 frames in flight. That is now 1.docs/d3d12_vulkan.md: documents the limit.Tested
Linux, with gcc for the native build and clang 23 targeting mingw x64, run under Wine 11.22. MSVC is left to CI.
frame_pacer_test(gcc, Linux)frame_pacer_test(clang mingw, Wine)xbox_present_test(clang mingw, Wine)mainmainwith only this PR's test changesxbox_present_teston this branch passed 26 cases on both GPUs. The HDR10 swapchain case was skipped because the display lists no ST.2084 format.xbox_present.his the only other file that includesframe_pacer.h.d3d12_boot_movie_testalso uses it, but it needs the retail package, so I didn't run it.git diff --checkandpython -I scripts/check_no_game_data.pyon the changed files: clean.frame_pacer.hor the present path: d3d12_xs: add multi-event FramePacer TOKEN_ON_TIMEOUT and wire XboxPresentation to device/queue slots (RT-XS-FRAME-PACING-PRESENTX) #402, d3d12_xs: the queue's slot 32 is PresentX, wired to the presentation core with a shared token source (RT-PRESENTX) #414, d3d12_xs: keep the Win32 PresentX window responsive during rendering #526, d3d12_xs_device: wire measured queue SuspendX/ResumeX/PresentX (23/24… #551, d3d12_xs: bridge device/queue Xbox present slots (78-81, 23, 24, 32) to XboxPresentation #553.GPUs tested: AMD Radeon RX 7900 XTX (RADV NAVI31) and AMD Ryzen 9 7950X3D integrated GPU (RADV RAPHAEL_MENDOCINO), both Mesa 26.3.1, Arch Linux, through Wine 11.22 (
xbox_present_testonly;frame_pacer_testneeds no GPU)AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a)AI-assisted (Claude Code, Claude Opus 5.5).