OLD-9189: restore old upstream PR 9189 - FramePacer: at most latency frames in flight while armed (mailbox replace) #671
No reviewers
No assignees
Labels
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
No project
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
No due date set.
Reference
leonida/mandy!671
Loading…
Reference in a new issue
No description provided.
Delete branch "frame-pacer-bounded-queue"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Pull request successfully merged and closed
Claimed in the coordination issue as: OLD-9189 https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7129812657
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 21625bca8c675c62f9dbffc318ce6a59d57faf31; 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: #402, #414, #526, #551, #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).
Merged
mainafter #891 (BL-6) to clear the conflict.Conflict
runtime/src/frame_pacer.h: both PRs add a private helper in the same place,queue_flip_locked(this PR) andrecord_present_timing_locked(#891). Both are kept.note_untokened_presentmerged on its own: it records its timing first (#891), then queues throughqueue_flip_locked(this PR).Dropped frames and the BL-6 statistics
PresentX, before the frame is queued. A frame the bounded queue replaces was still presented, so it counts with its real present-to-present interval. The replacement adds no interval and removes none.docs/d3d12_vulkan.mdnow says this next to the BL-6 text.frame_pacer_test, at latency 1: four presents, two of them replaced. It checksframes4,samples3, mean, drift, nearest-rankp50/p95/p99, two origin-to-present latencies (the replaced token included), and that the frames that are shown keep their vblanks.Tests (Linux, portable runtime subset)
ctest: 74/74 passed, 2 skipped (shader_library_corpus,vk_sync_validation), the same asmainalone. Vulkan tests ran on the AMD iGPU (RDNA2, RADV).frame_pacer_test: passes, including the new case and this PR's bounded-queue cases.python -I tests/test_boot_trace.py: 33/33.check_no_game_data.pyon every changed file: clean.xbox_present_testis Windows-only and was not run here.AI-assisted (Claude Code, Claude Opus 5.5).
Merged:
FramePacerkeeps at mostlatencyframes in flight while armed (mailbox replace).main. The BL-6 statistics still describe the title's present cadence, as that comment explained.main5fab93967with all nine of these runtime PRs merged together (#634, #643, #684, #657, #677, #638, #710, #688, #671), on llvmpipe and the gfx1036 iGPU (RADV): no test went from pass to fail.frame_pacerpasses on both.main8564bb48b+6f9ee9a81: it merges cleanly; the semantic suite passes (493 files, 6,318 tests, 0 files failed); the 15 docs and writer tests pass;check_no_game_data.pyis clean on the 4 changed files.AI-assisted (Claude Code, Claude Opus 5.5).