d3d12: uncap rendering and use measured simulation steps (D3D12-UNCAPPED-SIMULATION) #3204

Merged
ubiquitarianism merged 1 commit from upstream-pr/3204 into main 2026-12-02 20:41:21 +00:00
ubiquitarianism commented 2026-12-02 19:09:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by ubiquitarianism on 2026-12-02T19:09:26Z.


Claimed as D3D12-UNCAPPED-SIMULATION.

What and why

  • Let the D3D12 frame events pace the title. On 1.0.2.1 the loader skips the title's internal deadline wait while preserving its timestamp update. Selecting NONE in F1 or F4 makes runtime frame events immediate, and numeric caps still apply live.
  • Use the engine's measured frame duration for the simulation and camera clocks. The loader redirects both nominal-duration floors to the timer's built-in minimum. The existing ceiling still bounds long frames and LEONIDA_SIM_MAX_STEP_MS can adjust it.
  • The timer floor comes from the repository's earlier implementation at 2694497e8.

Tested

  • On the baseline frame clock, the new uncapped origin-poll assertion failed because the poll returned a timeout. It passed with the patch, including the live return to capped pacing.
  • The loader suite passed all 91 tests, including the synthetic patch-group test and the local 1.0.2.1 byte checks. The GPU library run had 782 passes, 59 ignored tests, and one descriptor test failure. That descriptor test also fails in isolation on the baseline binary. The known depth-bounds test was filtered per AGENTS.md.
  • The D3D12 diagnostic build, 57 documentation tests, switch inventory, and clean-room scan passed.
  • Live Windows test with Series S at 480p and frame generation off. In a six-second loading window where title clock updates matched presents, the game clock advanced at 1.832× wall time at 54.5 FPS on baseline and 0.998× at 59.4 FPS with the patch. With the cap off the patched run observed up to 138.9 presents per second during loading. A controlled in-world physics test at high rendered FPS is pending.

GPUs tested — Windows 11 Pro, Radeon RX 6800 system with AMD driver 32.0.21030.2001. Adapter selection was automatic.

AI-assisted — Codex GPT-6.2 Sol for implementation, read-only timing investigation, and a separate read-only code review. The reviewer verified the limiter branch, both timer floors and the clean-room diff.

Checklist

  • Based on current main.
  • One topic.
  • Clean-room scan passed. Only aggregate timing measurements are shared.
  • Translator contract is unaffected.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5612969575 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3204). Originally posted by [ubiquitarianism](https://github.com/ubiquitarianism) on 2026-12-02T19:09:26Z. --- Claimed as [D3D12-UNCAPPED-SIMULATION](https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7355337141). ### What and why - Let the D3D12 frame events pace the title. On 1.0.2.1 the loader skips the title's internal deadline wait while preserving its timestamp update. Selecting `NONE` in F1 or F4 makes runtime frame events immediate, and numeric caps still apply live. - Use the engine's measured frame duration for the simulation and camera clocks. The loader redirects both nominal-duration floors to the timer's built-in minimum. The existing ceiling still bounds long frames and `LEONIDA_SIM_MAX_STEP_MS` can adjust it. - The timer floor comes from the repository's earlier implementation at `2694497e8`. ### Tested - On the baseline frame clock, the new uncapped origin-poll assertion failed because the poll returned a timeout. It passed with the patch, including the live return to capped pacing. - The loader suite passed all 91 tests, including the synthetic patch-group test and the local 1.0.2.1 byte checks. The GPU library run had 782 passes, 59 ignored tests, and one descriptor test failure. That descriptor test also fails in isolation on the baseline binary. The known depth-bounds test was filtered per AGENTS.md. - The D3D12 diagnostic build, 57 documentation tests, switch inventory, and clean-room scan passed. - Live Windows test with Series S at 480p and frame generation off. In a six-second loading window where title clock updates matched presents, the game clock advanced at 1.832× wall time at 54.5 FPS on baseline and 0.998× at 59.4 FPS with the patch. With the cap off the patched run observed up to 138.9 presents per second during loading. A controlled in-world physics test at high rendered FPS is pending. **GPUs tested** — Windows 11 Pro, Radeon RX 6800 system with AMD driver 32.0.21030.2001. Adapter selection was automatic. **AI-assisted** — Codex GPT-6.2 Sol for implementation, read-only timing investigation, and a separate read-only code review. The reviewer verified the limiter branch, both timer floors and the clean-room diff. ### Checklist - [x] Based on current `main`. - [x] One topic. - [x] Clean-room scan passed. Only aggregate timing measurements are shared. - [x] Translator contract is unaffected.
x2Tweek commented 2026-12-02 20:15:31 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by x2Tweek on 2026-12-02T20:15:31Z.


Game run on a large machine, Series X profile at 4K: standing still, the 30 fps ceiling is gone.

Setup: RTX 5090 32 GB, driver 621.40, i9-14900KS, 64 GB DDR5, Windows 11 (26300). Base: upstream main
0d7a451ab plus #3113 and #3182, diag build. This PR merged on top at pr-3204. Series X profile, 3840x2160
output, render scale 0.6667, the title's upscaler, hardware ray tracing (-HardwareRT -SmoothMotion -PrecompileAll -Log), LEONIDA_FPS_CAP=0, fullscreen.

Tests: cargo test -p leonida-loader gives 94 passed and 0 failed. The log has
hook applied what="frame pacing: leave the wait to the runtime's frame events" and
frame pacing and measured simulation steps places=4.

Frame log (5 s lines) base, earlier runs with this PR
standing still, after loading 30.4-31.0 fps (32.3-32.9 ms), flat 38.7 fps median (26.2 ms; frame times median 25.5-26.0 ms, p99 29.7 ms, longest 30.1 ms)
city driving about 19-21 fps median 19.3 fps median (51.7 ms), no frame over 1 s
  • Standing: about +27 %, and the frame times are tight (0 over 100 ms). The standing spot was not the same
    as in the base runs, so take the exact figure loosely; the base sat at the 30 fps line on every standing run.
  • Driving: no change. The frame is host-bound there (about 28 ms of preparation and 50 ms or more a frame),
    above the title's deadline, so there was no wait to remove.
  • Simulation speed: the player saw nothing sped up (cars, people, camera), standing or driving. That is an observation by eye, not a measurement.

AI-assisted: the build, the test run, the log reading and the write-up were done with Claude Opus 5.5 (Claude
Code); the numbers are the runtime's own log lines, and the simulation-speed observation is the player's.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7357460076 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3204#issuecomment-7357460076). Originally posted by [x2Tweek](https://github.com/x2Tweek) on 2026-12-02T20:15:31Z. --- Game run on a large machine, Series X profile at 4K: standing still, the 30 fps ceiling is gone. **Setup:** RTX 5090 32 GB, driver 621.40, i9-14900KS, 64 GB DDR5, Windows 11 (26300). Base: upstream main `0d7a451ab` plus #3113 and #3182, diag build. This PR merged on top at `pr-3204`. Series X profile, 3840x2160 output, render scale 0.6667, the title's upscaler, hardware ray tracing (`-HardwareRT -SmoothMotion -PrecompileAll -Log`), `LEONIDA_FPS_CAP=0`, fullscreen. **Tests:** `cargo test -p leonida-loader` gives 94 passed and 0 failed. The log has `hook applied what="frame pacing: leave the wait to the runtime's frame events"` and `frame pacing and measured simulation steps places=4`. | Frame log (5 s lines) | base, earlier runs | with this PR | |---|---|---| | standing still, after loading | 30.4-31.0 fps (32.3-32.9 ms), flat | **38.7 fps median** (26.2 ms; frame times median 25.5-26.0 ms, p99 29.7 ms, longest 30.1 ms) | | city driving | about 19-21 fps median | 19.3 fps median (51.7 ms), no frame over 1 s | - **Standing:** about +27 %, and the frame times are tight (0 over 100 ms). The standing spot was not the same as in the base runs, so take the exact figure loosely; the base sat at the 30 fps line on every standing run. - **Driving:** no change. The frame is host-bound there (about 28 ms of preparation and 50 ms or more a frame), above the title's deadline, so there was no wait to remove. - **Simulation speed:** the player saw nothing sped up (cars, people, camera), standing or driving. That is an observation by eye, not a measurement. AI-assisted: the build, the test run, the log reading and the write-up were done with Claude Opus 5.5 (Claude Code); the numbers are the runtime's own log lines, and the simulation-speed observation is the player's.
icdmkg2 commented 2026-12-02 20:23:42 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by icdmkg2 on 2026-12-02T20:23:42Z.


Third-party Windows (NVIDIA) verification of #3204 (D3D12-UNCAPPED-SIMULATION) on head ab3bf6ece

  • Head / base: ab3bf6eceeb3f87807f71a0fd42872d503a0a208 merged cleanly (git merge --no-ff) onto origin/main b41763227.
  • Machine: NVIDIA GeForce RTX 5060 Laptop GPU (8 GB, Profile M laptop), driver 621.24 (32.0.16.2124), AMD Ryzen 7 H 260 w/ Radeon 780M, 32 GB RAM, Windows 11 10.0.26300.9974, rustc 1.98.1.
  • Scope: synthetic / unit / docs / clean-room suites on an NVIDIA host (no retail title run; complements the author's RX 6800 run and the RTX 5090 live run above).

Results (MEASURED)

Check Result
python -I scripts/check_no_game_data.py (all 5 touched files) exit 0
python -I tools/d3d12_switches.py --check d3d12/docs/switches.md exit 0
python -m unittest discover -s tests -p "test_docs_*.py" 57/57 OK
LEONIDA_ADAPTER=5060 python -I scripts/red_green.py 3204 --mutate green: 856 passed, 0 failed across leonida-gpu and leonida-loader (0 descriptor test failures on RTX 5060); red: verdict: red does not build (cannot find function measured_frame_timing_patches in this scope, expected for the new loader helper)
LEONIDA_ADAPTER=5060 cargo test -p leonida-gpu --features diagnostics --locked --lib -- frame:: 1 passed, 0 failed (frame::tests::waits_end_on_ticks_and_count_frames)
cargo test -p leonida-loader --locked 94 passed, 0 failed (91 unit + 2 load_probe + 1 title_dlls, including measured_steps_and_the_title_wait_are_patched_together)

Review notes (READ IN CODE)

  • frame.rs: CAP_NONE (-1) cleanly separates uncapped (Duration::ZERO, immediate S_OK even on timeout_ms == 0 polls) from CAP_UNREAD (-2) and title-interval (0); switching back to capped (set_cap("")) resets c.first = last_tick() under the clock lock so subsequent ticks remain monotonic.
  • hooks.rs: apply_all pre-checks all bytes and restores VirtualProtect flags in reverse order if any page protection call fails, avoiding partial patch application on shared pages.

AI-assisted: Gemini 4 Neon (High) via Antigravity (test execution, diff review, and write-up).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7357667233 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3204#issuecomment-7357667233). Originally posted by [icdmkg2](https://github.com/icdmkg2) on 2026-12-02T20:23:42Z. --- **Third-party Windows (NVIDIA) verification of #3204 (`D3D12-UNCAPPED-SIMULATION`) on head `ab3bf6ece`** - **Head / base:** `ab3bf6eceeb3f87807f71a0fd42872d503a0a208` merged cleanly (`git merge --no-ff`) onto `origin/main` `b41763227`. - **Machine:** NVIDIA GeForce RTX 5060 Laptop GPU (8 GB, Profile M laptop), driver `621.24` (`32.0.16.2124`), AMD Ryzen 7 H 260 w/ Radeon 780M, 32 GB RAM, Windows 11 `10.0.26300.9974`, `rustc 1.98.1`. - **Scope:** synthetic / unit / docs / clean-room suites on an NVIDIA host (no retail title run; complements the author's RX 6800 run and the RTX 5090 live run above). ### Results (MEASURED) | Check | Result | |---|---| | `python -I scripts/check_no_game_data.py` (all 5 touched files) | exit `0` | | `python -I tools/d3d12_switches.py --check d3d12/docs/switches.md` | exit `0` | | `python -m unittest discover -s tests -p "test_docs_*.py"` | `57/57` OK | | `LEONIDA_ADAPTER=5060` `python -I scripts/red_green.py 3204 --mutate` | green: `856` passed, `0` failed across `leonida-gpu` and `leonida-loader` (0 descriptor test failures on RTX 5060); red: `verdict: red does not build` (`cannot find function measured_frame_timing_patches in this scope`, expected for the new loader helper) | | `LEONIDA_ADAPTER=5060` `cargo test -p leonida-gpu --features diagnostics --locked --lib -- frame::` | `1 passed, 0 failed` (`frame::tests::waits_end_on_ticks_and_count_frames`) | | `cargo test -p leonida-loader --locked` | `94 passed, 0 failed` (`91` unit + `2` `load_probe` + `1` `title_dlls`, including `measured_steps_and_the_title_wait_are_patched_together`) | ### Review notes (READ IN CODE) - `frame.rs`: `CAP_NONE` (`-1`) cleanly separates uncapped (`Duration::ZERO`, immediate `S_OK` even on `timeout_ms == 0` polls) from `CAP_UNREAD` (`-2`) and title-interval (`0`); switching back to capped (`set_cap("")`) resets `c.first = last_tick()` under the clock lock so subsequent ticks remain monotonic. - `hooks.rs`: `apply_all` pre-checks all bytes and restores `VirtualProtect` flags in reverse order if any page protection call fails, avoiding partial patch application on shared pages. AI-assisted: Gemini 4 Neon (High) via Antigravity (test execution, diff review, and write-up).
fiestorra commented 2026-12-02 21:22:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T21:22:44Z.


VERIFY-3204 — Windows nativo: el test nuevo muerde, y el cambio arregla una discrepancia que ya existía

Head (this PR)
Merge base b41763227 = current main
Merged onto main — clean

Ran

cargo test -p leonida-gpu --lib     702 passed; 1 failed; 59 ignored
  frame::tests::waits_end_on_ticks_and_count_frames ... ok

The one failure is this machine's, unchanged all day: descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in (the iGPU artefact of D3D12CreateDevice(None, ..) that #2995 addresses).

Negative control (synthetic): I put the old Some(0) => 500 back, rebuilt and ran → FAILED: waits_end_on_ticks_and_count_frames, assertion left == right failed at frame.rs:326. The test bites on exactly the semantics this PR changes.

What I checked around the change, because 0 is a live switch

  • The F1 menu already called 0 "Unlimited": host/trainer.rs has its own cap_of (Some(0) => Cap::Unlimited) and cap_text writes "0" for Cap::Unlimited, while frame.rs on main treated 0 as a 500 µs tick. This PR is what makes the clock agree with the menu — the change is not redefining "0" arbitrarily, it is fixing a mismatch that was already there.
  • CAP_UNREAD/CAP_NONE are distinct now (-2/-1): previously -1 meant both "not read yet" and "the title's". Splitting them is what lets 0 mean "no interval" instead of borrowing -1.

What I would watch, and cannot test

  • Duration::ZERO is now what an uncapped frame waits: no pacing at all, so the cost moves to the CPU (a busy loop if the title's own sync does not block). The README and docs/vi_patch.md are updated, but whether an uncapped run burns a core is a run, not a unit test.
  • Existing configs that used 0 as "fast but paced" now get "unpaced": that is the point of the PR, and it is a behaviour change for anyone who set it — worth a line in the body's "what changes for you", if it is not there already.

Written with an AI assistant.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7359194075 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3204#issuecomment-7359194075). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-02T21:22:44Z. --- ## VERIFY-3204 — Windows nativo: el test nuevo muerde, y el cambio arregla una discrepancia que ya existía | | | |---|---| | Head | `(this PR)` | | Merge base | `b41763227` = current `main` | | Merged onto | `main` — clean | **Ran** ``` cargo test -p leonida-gpu --lib 702 passed; 1 failed; 59 ignored frame::tests::waits_end_on_ticks_and_count_frames ... ok ``` **The one failure is this machine's**, unchanged all day: `descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in` (the iGPU artefact of `D3D12CreateDevice(None, ..)` that #2995 addresses). **Negative control (synthetic)**: I put the old `Some(0) => 500` back, rebuilt and ran → `FAILED: waits_end_on_ticks_and_count_frames`, `assertion left == right failed` at `frame.rs:326`. **The test bites on exactly the semantics this PR changes.** ## What I checked around the change, because `0` is a live switch - **The F1 menu already called `0` "Unlimited"**: `host/trainer.rs` has its own `cap_of` (`Some(0) => Cap::Unlimited`) and `cap_text` writes `"0"` for `Cap::Unlimited`, while **`frame.rs` on `main` treated `0` as a 500 µs tick**. **This PR is what makes the clock agree with the menu** — the change is not redefining "0" arbitrarily, it is fixing a mismatch that was already there. - **`CAP_UNREAD`/`CAP_NONE` are distinct now** (`-2`/`-1`): previously `-1` meant both "not read yet" and "the title's". Splitting them is what lets `0` mean "no interval" instead of borrowing `-1`. ## What I would watch, and cannot test - **`Duration::ZERO` is now what an uncapped frame waits**: no pacing at all, so the cost moves to the CPU (a busy loop if the title's own sync does not block). The README and `docs/vi_patch.md` are updated, but **whether an uncapped run burns a core is a run**, not a unit test. - **Existing configs that used `0` as "fast but paced" now get "unpaced"**: that is the point of the PR, and it is a behaviour change for anyone who set it — worth a line in the body's "what changes for you", if it is not there already. Written with an AI assistant.
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!3204
No description provided.