[PR #1992] Rebase pending flips when the frame interval changes #2000

Open
opened 2026-11-26 21:19:41 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/1992
Author: @lgr123
Created: 11/25/2026
Status: 🔄 Open

Base: main ← Head: lgr123/frame-interval-pending-vblank


📝 Commits (2)

  • a14f74c Rebase pending flips when the frame interval changes
  • 61c3421 Keep queued flips when reapplying the frame period

📊 Changes

2 files changed (+88 additions, -2 deletions)

View changed files

📝 runtime/src/frame_pacer.h (+12 -2)
📝 runtime/test/frame_pacer_test.cpp (+76 -0)

📄 Description

Claimed as RT-FRAME-INTERVAL-PENDING-VBLANK.

In a native fake-clock reproduction, changing from 30 to 60 FPS with one old frame still queued placed the next flip at 83,333 µs. The new vblanks were at 56,667, 73,334 and 90,001 µs. The no-pending control displayed at 73,334 µs. Both cases now display at 73,334 µs.

At the interval change, retire flips whose original time already passed, then assign the remaining flips consecutive slots on the rebased grid in FIFO order. The regression asserts that the first retired timestamp is preserved, two pending frames keep their order, and a new frame gets the next slot. This changes rate transitions. The separate mailbox-overflow behavior in #671 is outside the patch. I ran the same reproduction on that branch and it still produced 83,333 µs.

Tested

  • Windows x64, MSVC, native frame_pacer_test. The new test fails with the unchanged header and the full suite passes with the patch.
  • Standalone fake-clock 30-to-60 FPS control and reproduction both reported 73,334 µs with the patch.
  • Rebased onto public main fd33a31, whose pacing and test files are identical to the measured fe15534 base. git diff --check and the source-only policy check passed.
  • This verifies the runtime timing model with synthetic data. No game files or GPU are needed.

GPUs tested: n/a.

AI-assisted: yes.

Checklist

  • Based on current main.
  • One topic.
  • No game data, keys or decryption.

Independent review follow-up

The independent review on an RTX 4060 confirmed the changed-period regression and found that reapplying the same 16,000 µs period moved a frame from 32,000 to 40,000 µs. The follow-up keeps existing flip deadlines on a repeated period while preserving the event epoch update. The new manual-clock check observes the frame at 32,000 µs and the next origin at 40,000 µs. The previous PR head failed the new frame assertion. The native frame-pacer suite passed three runs with the follow-up.

Independent review


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/1992 **Author:** [@lgr123](https://github.com/lgr123) **Created:** 11/25/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `lgr123/frame-interval-pending-vblank` --- ### 📝 Commits (2) - [`a14f74c`](https://github.com/ubiquitarianism/leonida/commit/a14f74c2b2b2716148e853219ba787fd4ae035b1) Rebase pending flips when the frame interval changes - [`61c3421`](https://github.com/ubiquitarianism/leonida/commit/61c34218759c7e27e52e9d56395d42d3c6736217) Keep queued flips when reapplying the frame period ### 📊 Changes **2 files changed** (+88 additions, -2 deletions) <details> <summary>View changed files</summary> 📝 `runtime/src/frame_pacer.h` (+12 -2) 📝 `runtime/test/frame_pacer_test.cpp` (+76 -0) </details> ### 📄 Description Claimed as [RT-FRAME-INTERVAL-PENDING-VBLANK](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7169639524). In a native fake-clock reproduction, changing from 30 to 60 FPS with one old frame still queued placed the next flip at **83,333 µs**. The new vblanks were at **56,667, 73,334 and 90,001 µs**. The no-pending control displayed at 73,334 µs. Both cases now display at 73,334 µs. At the interval change, retire flips whose original time already passed, then assign the remaining flips consecutive slots on the rebased grid in FIFO order. The regression asserts that the first retired timestamp is preserved, two pending frames keep their order, and a new frame gets the next slot. This changes rate transitions. The separate mailbox-overflow behavior in #671 is outside the patch. I ran the same reproduction on that branch and it still produced 83,333 µs. ### Tested - Windows x64, MSVC, native `frame_pacer_test`. The new test fails with the unchanged header and the full suite passes with the patch. - Standalone fake-clock 30-to-60 FPS control and reproduction both reported 73,334 µs with the patch. - Rebased onto public main `fd33a31`, whose pacing and test files are identical to the measured `fe15534` base. `git diff --check` and the source-only policy check passed. - This verifies the runtime timing model with synthetic data. No game files or GPU are needed. GPUs tested: n/a. AI-assisted: yes. ### Checklist - [x] Based on current main. - [x] One topic. - [x] No game data, keys or decryption. ### Independent review follow-up The independent review on an RTX 4060 confirmed the changed-period regression and found that reapplying the same 16,000 µs period moved a frame from 32,000 to 40,000 µs. The follow-up keeps existing flip deadlines on a repeated period while preserving the event epoch update. The new manual-clock check observes the frame at 32,000 µs and the next origin at 40,000 µs. The previous PR head failed the new frame assertion. The native frame-pacer suite passed three runs with the follow-up. [Independent review](https://github.com/ubiquitarianism/leonida/pull/1992#pullrequestreview-6062814451) --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
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.

Dependencies

No dependencies set

Reference
starred/leonida#2000
No description provided.