Keep current frame-token statistics at or before the poll (FRAME-PACER-EARLY-ORIGIN) #2087

Merged
alexandersato0830 merged 1 commit from upstream-pr/2087 into main 2026-11-28 18:11:48 +00:00
alexandersato0830 commented 2026-11-25 19:55:09 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by alexandersato0830 on 2026-11-25T19:55:09Z.


Claimed in the coordination issue as: FRAME-PACER-EARLY-ORIGIN

What and why

A current-token poll can return immediately before the configured origin offset. Its frame-event statistic then points into the future, even after the token has been presented. Record the poll timestamp when the scheduled origin is still ahead. Use the original grid to compute the token's due time.

Tested

  • Windows 11, MSVC 19.51. The new fake-clock regression failed on main db1a22d. It passed through frame_pacer CTest with the fix, including the first display on the configured vblank.
  • Verified git diff --check and the source-only check.

GPUs tested: n/a.

AI-assisted: yes.

  • Based on current main.
  • One topic.
  • Uses source and a synthetic clock.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5498162123 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2087). Originally posted by [alexandersato0830](https://github.com/alexandersato0830) on 2026-11-25T19:55:09Z. --- Claimed in the coordination issue as: [FRAME-PACER-EARLY-ORIGIN](https://github.com/ubiquitarianism/leonida/issues/1608#issuecomment-7172851224) ### What and why A current-token poll can return immediately before the configured origin offset. Its frame-event statistic then points into the future, even after the token has been presented. Record the poll timestamp when the scheduled origin is still ahead. Use the original grid to compute the token's due time. ### Tested - Windows 11, MSVC 19.51. The new fake-clock regression failed on main `db1a22d`. It passed through `frame_pacer` CTest with the fix, including the first display on the configured vblank. - Verified `git diff --check` and the source-only check. GPUs tested: n/a. AI-assisted: yes. - [x] Based on current `main`. - [x] One topic. - [x] Uses source and a synthetic clock.
zmasi commented 2026-11-28 11:28:40 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-11-28T11:28:40Z.


Verified on Windows 11 (10.0.26200.9974) with MSVC 19.44.35228 (x64, /std:c++20 /EHsc /W4 /permissive- /utf-8 /O2) against main 4a54aedcb + 6921a278f (claim #2570#issuecomment-7238486276):

  • Line-by-line diff audit: Clean (runtime/src/frame_pacer.h, runtime/test/frame_pacer_test.cpp); clamps the issued current-token origin timestamp with std::min(origin, now) when wait_flag_current_token is polled before the first configured frame-event origin offset, while preserving display time at origin - offset + period_us_. check_no_game_data.py clean.
  • Red (4a54aedcb + PR test): frame_pacer_test.exe fails (rc=1 at line 196: count == 2 && stats[0].time_us == poll_us && stats[1].time_us == poll_us).
  • Green (4a54aedcb + 6921a278f merge): Auto-merges cleanly (rc=0), compiles with 0 /W4 warnings, and frame_pacer_test.exe passes (frame_pacer_test: all cases pass, rc=0).

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7238577240 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2087#issuecomment-7238577240). Originally posted by [zmasi](https://github.com/zmasi) on 2026-11-28T11:28:40Z. --- Verified on Windows 11 (`10.0.26200.9974`) with MSVC `19.44.35228` (`x64`, `/std:c++20 /EHsc /W4 /permissive- /utf-8 /O2`) against `main` `4a54aedcb` + `6921a278f` (claim `#2570#issuecomment-7238486276`): - **Line-by-line diff audit**: Clean (`runtime/src/frame_pacer.h`, `runtime/test/frame_pacer_test.cpp`); clamps the issued current-token origin timestamp with `std::min(origin, now)` when `wait_flag_current_token` is polled before the first configured frame-event origin offset, while preserving display time at `origin - offset + period_us_`. `check_no_game_data.py` clean. - **Red (`4a54aedcb` + PR test)**: `frame_pacer_test.exe` fails (`rc=1` at `line 196: count == 2 && stats[0].time_us == poll_us && stats[1].time_us == poll_us`). - **Green (`4a54aedcb` + `6921a278f` merge)**: Auto-merges cleanly (`rc=0`), compiles with `0` `/W4` warnings, and `frame_pacer_test.exe` passes (`frame_pacer_test: all cases pass`, `rc=0`). AI-assisted.
MoonEyes commented 2026-11-28 18:11:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-11-28T18:11:45Z.


Red/green: On main frame_pacer_test fails at line 213 (current frame-token statistics are reported after the poll instant), and with the PR ctest -R "^frame_pacer$" passes.
Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7243603726 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2087#issuecomment-7243603726). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-11-28T18:11:45Z. --- Red/green: On main frame_pacer_test fails at line 213 (current frame-token statistics are reported after the poll instant), and with the PR ctest -R "^frame_pacer$" passes. Independent tester (OreoFR, RTX 4070, Windows 11): PR head merged with the other PRs of its batch on main c1ecf04ed, full ctest run (485 tests, tests that launch the game excluded): no new failure compared with main.
OreoFR commented 2026-11-28 21:59:46 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by OreoFR on 2026-11-28T21:59:46Z.


Verified by OreoFR

  • Base: main c1ecf04ed + PR head 6921a278f; green run in a merge package of 16 PRs, no new ctest failure vs main
  • Test: ctest -R "^frame_pacer$"
  • Red on main: 1 failure, line 213 (token statistics past the poll instant)
  • Green with the PR: OK
  • Verdict: READY
  • Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11

AI-assisted (Claude Code, Claude Opus 5.5).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7246421146 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2087#issuecomment-7246421146). Originally posted by [OreoFR](https://github.com/OreoFR) on 2026-11-28T21:59:46Z. --- **Verified by OreoFR** - Base: main `c1ecf04ed` + PR head `6921a278f`; green run in a merge package of 16 PRs, no new ctest failure vs main - Test: `ctest -R "^frame_pacer$"` - Red on main: 1 failure, line 213 (token statistics past the poll instant) - Green with the PR: OK - Verdict: READY - Machine: RTX 4070 Laptop 8 GB, NVIDIA 621.40, Intel Core Ultra 7 155H, Windows 11 AI-assisted (Claude Code, Claude Opus 5.5).
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
ProjectLeonida/mandy!2087
No description provided.