D3D12-AHEAD-OF-FRAME-CUT: skip the texture pass the previous list already did #3029

Closed
github-bot wants to merge 1 commit from github-bot/gh-3029 into main AGit
Owner

@⁠bobcatchris on GitHub · 2026-12-02 02:13 UTC · original
bobcatchris:fix/d3d12-ahead-of-frame-cut → main · +95 −7 · 2 files · 1 commits · closed without merging

Claimed in the coordination issue as: D3D12-AHEAD-OF-FRAME-CUT

What and why

docs/findings.md measures the submitting thread waiting ~12 ms of an ~80 ms frame in queue::ahead_of_frame, while the helper pools that record the list ahead of the frame stand 95–99% idle. Most of that recording is State::heap_textures, which walks due texture slots and uploads them every frame even when the previous ahead-of-frame pass already covered the next frame.

This change records the texture queue's write counter before each textures pass. If the heap is unchanged, no pages were written, remapped or baked, no view was made again or cast flipped, and no slot is held back or due by the next frame, the following list-ahead recording skips heap_textures and returns no list when there is nothing else to record. AHEAD_DID still advances, so asking lists keep skipping the pass that was already done. All invalidation signals come from the heap's existing bookkeeping; a write arriving during a pass is stamped as unserved by sampling the counter before it.

The heap lock is held while the served state is stored, in the same order as done_ahead, so a concurrent heap switch cannot leave stale state.

Tested

  • draw::tests::ahead_textures_skip_only_when_nothing_is_pending covers every invalidation signal and the frame + 1 boundary. Red/green: dropping the dirty-page signal makes the test fail; restoring it passes.
  • cargo test -p leonida-gpu --locked (659 passed, 59 ignored) and the full cargo test --workspace --exclude xtask --locked with the documented skip — green.
  • python -I scripts/check_no_game_data.py on both changed files and git diff --check — clean.
  • Independent read-only review: Gemini 4 Neon (mode review, thinking low) found one lock-order TOCTOU in the served-state store; fixed by holding the heap lock across the update.

No in-game FPS measurement was made for this pull request. The 12 ms wait is from the existing profile in docs/findings.md; this change removes work on quiet frames by construction.

GPUs tested: n/a (offline Rust unit tests)

AI-assisted: yes — Gemini 4 Neon (architecture direction and independent review).

Checklist

  • Based on current main and merges cleanly.
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption.
  • No translator rule changed; nothing to add to the contract table.
**@⁠bobcatchris** on GitHub · 2026-12-02 02:13 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3029) `bobcatchris:fix/d3d12-ahead-of-frame-cut` → `main` · +95 −7 · 2 files · 1 commits · closed without merging Claimed in the coordination issue as: D3D12-AHEAD-OF-FRAME-CUT ### What and why `docs/findings.md` measures the submitting thread waiting ~12 ms of an ~80 ms frame in `queue::ahead_of_frame`, while the helper pools that record the list ahead of the frame stand 95–99% idle. Most of that recording is `State::heap_textures`, which walks due texture slots and uploads them every frame even when the previous ahead-of-frame pass already covered the next frame. This change records the texture queue's write counter before each textures pass. If the heap is unchanged, no pages were written, remapped or baked, no view was made again or cast flipped, and no slot is held back or due by the next frame, the following list-ahead recording skips `heap_textures` and returns no list when there is nothing else to record. `AHEAD_DID` still advances, so asking lists keep skipping the pass that was already done. All invalidation signals come from the heap's existing bookkeeping; a write arriving during a pass is stamped as *unserved* by sampling the counter before it. The heap lock is held while the served state is stored, in the same order as `done_ahead`, so a concurrent heap switch cannot leave stale state. ### Tested - `draw::tests::ahead_textures_skip_only_when_nothing_is_pending` covers every invalidation signal and the `frame + 1` boundary. Red/green: dropping the dirty-page signal makes the test fail; restoring it passes. - `cargo test -p leonida-gpu --locked` (659 passed, 59 ignored) and the full `cargo test --workspace --exclude xtask --locked` with the documented skip — green. - `python -I scripts/check_no_game_data.py` on both changed files and `git diff --check` — clean. - Independent read-only review: Gemini 4 Neon (mode review, thinking low) found one lock-order TOCTOU in the served-state store; fixed by holding the heap lock across the update. No in-game FPS measurement was made for this pull request. The 12 ms wait is from the existing profile in `docs/findings.md`; this change removes work on quiet frames by construction. GPUs tested: n/a (offline Rust unit tests) AI-assisted: yes — Gemini 4 Neon (architecture direction and independent review). ### Checklist - [x] Based on current `main` and merges cleanly. - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption. - [x] No translator rule changed; nothing to add to the contract table.
The list recorded ahead of a frame re-ran State::heap_textures every frame even when the previous pass still covered the next one. The line thread waits for that recording (~12 ms of an ~80 ms frame in the measured profile) while helper pools sit idle. Remember the texture queue's write counter before each pass and skip it when the queue has no new writes, dirty pages, remaps, bakes, remade views, cast flip, held slots or slots due by the next frame. AHEAD_DID still advances so asking lists keep skipping the earlier pass; when neither pass records commands, no list is submitted. The heap lock is held while storing the served state, in the same order as done_ahead.

One unit test covers every invalidation signal and the frame+1 boundary; red when the dirty-page signal is ignored. Full leonida-gpu and workspace test suites pass.

AI-assisted: yes (Gemini 4 Neon for architecture direction and independent review).
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-02 02:17:24 +00:00
Author
Owner

@⁠ecox982745 on GitHub · 2026-12-02 02:44 UTC · original

CPU-only source review at e49404808: texture_ahead_clean can skip the routine path that publishes completed deferred descriptor flips. texture_slot_show_ahead pushes a ready entry into FLIPS from its upload completion callback (descriptor/host.rs:3461) without bumping TextureQueue::writes. Once that slot is retired or its next recheck is later than frame + 1, the heap can look clean even though texture_slots_flip (:3636, called by heap_textures at draw.rs:4242) still needs to replace the neutral descriptor. Each subsequent skip refreshes AHEAD_DID, so ordinary draws can keep deferring their own pass.

I’d make a ready flip for this heap veto the skip and add a regression with unchanged writes and a completed flip. The immediate RESHOWN queue filled by levels_changed (descriptor/host.rs:417) is also consumed by that pass and is separate from RESHOWN_AFTER, which the predicate already checks.

AI-assisted source review. No game data or GPU used.

**@⁠ecox982745** on GitHub · 2026-12-02 02:44 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3029#issuecomment-7333141964) CPU-only source review at `e49404808`: `texture_ahead_clean` can skip the routine path that publishes completed deferred descriptor flips. `texture_slot_show_ahead` pushes a ready entry into `FLIPS` from its upload completion callback (`descriptor/host.rs:3461`) without bumping `TextureQueue::writes`. Once that slot is retired or its next recheck is later than `frame + 1`, the heap can look clean even though `texture_slots_flip` (`:3636`, called by `heap_textures` at `draw.rs:4242`) still needs to replace the neutral descriptor. Each subsequent skip refreshes `AHEAD_DID`, so ordinary draws can keep deferring their own pass. I’d make a ready flip for this heap veto the skip and add a regression with unchanged writes and a completed flip. The immediate `RESHOWN` queue filled by `levels_changed` (`descriptor/host.rs:417`) is also consumed by that pass and is separate from `RESHOWN_AFTER`, which the predicate already checks. AI-assisted source review. No game data or GPU used.
Author
Owner

@⁠OreoFR on GitHub · 2026-12-02 06:09 UTC · original

RUN by OreoFR (oreofr-agent, AI-assisted): two in-game ABBAs, main against main + this PR (head e49404808784af77c5804c848174aa7c04ac19d6, merged into main 8422def759cda12c89f918438eeb8d53dd5972a6 with no conflicts).

Setup: RTX 4070 Laptop 8 GB, driver 621.40, Core Ultra 7 155H. Series S, no DLSS, no frame generation, the same warm data. Each run is 450 s walking (lift at 340 s). Frame rate comes from the 5-second recording per frame (N frames) windows.

ABBA window before the end main 1 PR 1 PR 2 main 2
1st last 100 s 23.4 20.3 20.7 24.6
1st 200 to 110 s 25.4 16.4 21.7 24.2
2nd last 100 s 26.4 22.4 23.4 24.7
2nd 200 to 110 s 23.9 23.8 24.7 25.3

Numbers are fps.

  • The first ABBA is skewed: the PR build was new, so the NVIDIA shader cache started cold. It waited 4 to 5 s for pipelines in the last 200 s, against almost none on main.
  • The second ABBA ran with that cache warm. Only PR 1 still waited, 2.7 s.
  • Over both ABBAs the PR is never faster. In the last 100 s it is 5 to 15 % slower. In the earlier window it ties main.

Verdict: no gain measured on this card, possibly a loss. I am not putting it in the merge queue. This is PROVISIONAL (one card, two ABBAs). A paired in-run A/B behind a switch (LEONIDA_AB) would settle it with much less noise, if the change can be turned off at run time.

**@⁠OreoFR** on GitHub · 2026-12-02 06:09 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3029#issuecomment-7336698881) **RUN by OreoFR** (oreofr-agent, AI-assisted): two in-game ABBAs, main against main + this PR (head `e49404808784af77c5804c848174aa7c04ac19d6`, merged into main `8422def759cda12c89f918438eeb8d53dd5972a6` with no conflicts). Setup: RTX 4070 Laptop 8 GB, driver 621.40, Core Ultra 7 155H. Series S, no DLSS, no frame generation, the same warm data. Each run is 450 s walking (lift at 340 s). Frame rate comes from the 5-second `recording per frame (N frames)` windows. | ABBA | window before the end | main 1 | PR 1 | PR 2 | main 2 | |---|---|---|---|---|---| | 1st | last 100 s | 23.4 | 20.3 | 20.7 | 24.6 | | 1st | 200 to 110 s | 25.4 | 16.4 | 21.7 | 24.2 | | 2nd | last 100 s | 26.4 | 22.4 | 23.4 | 24.7 | | 2nd | 200 to 110 s | 23.9 | 23.8 | 24.7 | 25.3 | Numbers are fps. - The first ABBA is skewed: the PR build was new, so the NVIDIA shader cache started cold. It waited 4 to 5 s for pipelines in the last 200 s, against almost none on main. - The second ABBA ran with that cache warm. Only PR 1 still waited, 2.7 s. - Over both ABBAs the PR is never faster. In the last 100 s it is 5 to 15 % slower. In the earlier window it ties main. **Verdict: no gain measured on this card, possibly a loss.** I am not putting it in the merge queue. This is PROVISIONAL (one card, two ABBAs). A paired in-run A/B behind a switch (`LEONIDA_AB`) would settle it with much less noise, if the change can be turned off at run time.
Author
Owner

@⁠lixonik on GitHub · 2026-12-02 07:14 UTC · original

RUN

Independent verification of #3029 (e49404808) merged cleanly onto main (f37c4a87d) on Windows 10 Pro 22H2 (build 19045), AMD Ryzen 9 5950X, 64 GiB RAM, NVIDIA GeForce RTX 5070 12 GB (driver 621.40), MSVC toolchain (1.98.1).

Offline checks & code review

  • python -I scripts/check_no_game_data.py on both changed files: PASS.
  • cargo test -p leonida-gpu --locked --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws (including draw::tests::ahead_textures_skip_only_when_nothing_is_pending): PASS.
  • Source check confirms @ecox982745's finding: HostHeap::texture_ahead_clean (descriptor/host.rs:2898) checks RESHOWN_AFTER (host.rs:428), but does not check RESHOWN (host.rs:413) or pending ready flips in FLIPS (host.rs:863) / PENDING_LIST_FLIPS (host.rs:889).

In-game 4-leg ABBA (main f37c4a87d vs main + e49404808)

Setup: Series S, DLSS Quality, -NoFrameGen, warm cache (0 pipeline waits across all 4 legs), same save snapshot restored before every leg, 75 s in world per leg (17 world samples each, 0 errors / 0 device removals).

Leg Median FPS Median ms/frame Preparing / textures ms Ahead-of-frame record med / mean ms Submit-thread wait med / mean ms Ahead lists sent/frame (med / min)
main 1 19.8 50.4 36.1 / 1.5 6.20 / 9.08 3.60 / 6.10 1.00 / 0.89
PR 1 19.7 50.8 35.0 / 1.7 5.70 / 8.10 3.20 / 5.20 1.00 / 0.90
PR 2 20.5 48.8 37.0 / 1.2 5.10 / 8.44 3.00 / 5.73 1.00 / 0.92
main 2 20.9 47.9 35.2 / 1.4 5.70 / 8.05 3.10 / 5.15 1.00 / 0.93
main avg 20.35 49.15 -- 5.95 / 8.57 3.35 / 5.63 1.00
PR avg 20.10 49.80 -- 5.40 / 8.27 3.10 / 5.47 1.00

Observations

  • Consistent with @OreoFR's RTX 4070 Laptop ABBA, no frame-rate gain was measured on RTX 5070 (20.10 vs 20.35 fps, -1.2%, within run-to-run noise), and ahead-of-frame recording/wait time changed by only ~0.25-0.55 ms median (1.00 ahead lists/frame sent in every leg).
  • In active world frames, watched texture writes/guard faults (~220-240 guard faults/frame, ~0.1 MB watched & changed, ~0.8-1.7 MB hashed per frame) appear to keep texture_ahead_clean false almost every frame; note HEAP_TEXTURES_SKIPPED (draw.rs:508,1529) is currently never printed in any stats line, so exposing it (alongside a LEONIDA_AB switch and the FLIPS/RESHOWN fix) would directly show the actual skip rate in the world.

Verdict: No measurable FPS improvement on RTX 5070 (flat vs main, matching @OreoFR's result); @ecox982745's FLIPS/RESHOWN skip hazard is confirmed in source.

AI-assisted: yes (Antigravity).

**@⁠lixonik** on GitHub · 2026-12-02 07:14 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3029#issuecomment-7337943833) RUN Independent verification of `#3029` (`e49404808`) merged cleanly onto `main` (`f37c4a87d`) on Windows 10 Pro 22H2 (build 19045), AMD Ryzen 9 5950X, 64 GiB RAM, NVIDIA GeForce RTX 5070 12 GB (driver `621.40`), MSVC toolchain (`1.98.1`). ### Offline checks & code review - `python -I scripts/check_no_game_data.py` on both changed files: PASS. - `cargo test -p leonida-gpu --locked --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws` (including `draw::tests::ahead_textures_skip_only_when_nothing_is_pending`): PASS. - Source check confirms `@ecox982745`'s finding: `HostHeap::texture_ahead_clean` (`descriptor/host.rs:2898`) checks `RESHOWN_AFTER` (`host.rs:428`), but does not check `RESHOWN` (`host.rs:413`) or pending ready flips in `FLIPS` (`host.rs:863`) / `PENDING_LIST_FLIPS` (`host.rs:889`). ### In-game 4-leg ABBA (`main` `f37c4a87d` vs `main + e49404808`) Setup: Series S, DLSS Quality, `-NoFrameGen`, warm cache (`0` pipeline waits across all 4 legs), same save snapshot restored before every leg, 75 s in world per leg (`17` world samples each, `0` errors / `0` device removals). | Leg | Median FPS | Median ms/frame | Preparing / textures ms | Ahead-of-frame record med / mean ms | Submit-thread wait med / mean ms | Ahead lists sent/frame (med / min) | |---|---:|---:|---:|---:|---:|---:| | `main 1` | 19.8 | 50.4 | 36.1 / 1.5 | 6.20 / 9.08 | 3.60 / 6.10 | 1.00 / 0.89 | | `PR 1` | 19.7 | 50.8 | 35.0 / 1.7 | 5.70 / 8.10 | 3.20 / 5.20 | 1.00 / 0.90 | | `PR 2` | 20.5 | 48.8 | 37.0 / 1.2 | 5.10 / 8.44 | 3.00 / 5.73 | 1.00 / 0.92 | | `main 2` | 20.9 | 47.9 | 35.2 / 1.4 | 5.70 / 8.05 | 3.10 / 5.15 | 1.00 / 0.93 | | **`main` avg** | **20.35** | **49.15** | -- | **5.95 / 8.57** | **3.35 / 5.63** | **1.00** | | **`PR` avg** | **20.10** | **49.80** | -- | **5.40 / 8.27** | **3.10 / 5.47** | **1.00** | ### Observations - Consistent with `@OreoFR`'s RTX 4070 Laptop ABBA, **no frame-rate gain was measured on RTX 5070** (`20.10` vs `20.35` fps, `-1.2%`, within run-to-run noise), and ahead-of-frame recording/wait time changed by only `~0.25-0.55 ms` median (`1.00` ahead lists/frame sent in every leg). - In active world frames, watched texture writes/guard faults (`~220-240` guard faults/frame, `~0.1 MB` watched & changed, `~0.8-1.7 MB` hashed per frame) appear to keep `texture_ahead_clean` false almost every frame; note `HEAP_TEXTURES_SKIPPED` (`draw.rs:508,1529`) is currently never printed in any stats line, so exposing it (alongside a `LEONIDA_AB` switch and the `FLIPS`/`RESHOWN` fix) would directly show the actual skip rate in the world. **Verdict:** No measurable FPS improvement on RTX 5070 (flat vs `main`, matching `@OreoFR`'s result); `@ecox982745`'s `FLIPS`/`RESHOWN` skip hazard is confirmed in source. AI-assisted: yes (Antigravity).
Author
Owner

@⁠Kal0s-design on GitHub · 2026-12-02 13:54 UTC · original

Ran natively on Windows 11, head e49404808 merged into current main (128648cfe, no conflicts), leonida-gpu with --features diagnostics, --locked, toolchain 1.98.1. I ran the tests on the hardware card and again on WARP, with the same results.

The source review above already names FLIPS and RESHOWN. Two more queues are missing from texture_ahead_clean, and I ran a probe that shows the skipped pass leaving them waiting while main clears them.

Suite

Check Result
cargo test -p leonida-gpu --lib (merge) 773 passed, 0 failed, 59 ignored
draw::tests::ahead_textures_skip_only_when_nothing_is_pending pass
cargo clippy -p leonida-gpu --all-targets one new warning in the PR's code: too_many_arguments (8/7) on ahead_textures_clean (draw.rs:566)

The predicate against queued work (throwaway test in descriptor/host.rs, not committed). The setup is a HostHeap of 8 slots with placed spans noted for slots 2 to 4. I settled the remap cursor and cast, emptied the queue, took served = texture_news().0 and queued one item at a time.

Queued item texture_ahead_clean(served, frame) Next step of the pass
nothing true nothing
read_short(start) (SHORT) true texture_slots_short made 1 slot due
a WAITING entry for the start, back-dated 2 frames and waited 1.2 s (what levels_waiting leaves) true texture_slots_waiting made 1 slot due
levels_changed(start) (RESHOWN) true texture_views_remade drained it
a hand-built ready Flip for this heap pushed into FLIPS true not run in the probe; per the code, texture_slots_flip takes it

Neither read_short nor levels_waiting increments TextureQueue::writes or sets any flag that texture_news reads. Only the pass itself turns them into queue entries.

End to end through test_record_passes_ahead (same heap made with create_heap, frame::test_advance() before each list, SHORT and WAITING filled as above after list 2, queue otherwise empty):

List PR: recorded / SHORT pending / WAITING pending / due main: recorded / SHORT / WAITING / due
1 true / - / - / 0 true / - / - / 0
2 false (skip) / - / - / 0 true / - / - / 0
3 false / yes / yes / 0 true / no / no / 2
4 to 7 false / yes / yes / 0 true / no / no / 0

On main the next list's pass turns both into due slots. On the PR they stay queued until something else makes the heap not clean. Each skip also stores AHEAD_DID[1] = frame + 1 (read in code), so done_ahead(1) stays true and draws that are not baking also leave out their own textures' pass.

This probe's queue is empty, so it shows the worst case. In a live heap, the slot whose filling queued the item was just uploaded, and by default it keeps a look on the queue (frame + 1 when uploaded in part, otherwise RECHECK_FRAMES 4, 12, 40, 120, 400). That look makes next_due <= frame + 1 and forces a pass, which drains both queues. So in a live heap, I expect a delay until the next due look in the heap, not a permanent stall. The delay grows as a slot's looks spread out, and has no bound with LEONIDA_HEAP_RECHECK=0. I did not measure it.

A possible fix: count a non-empty SHORT, an eligible WAITING entry, a non-empty RESHOWN, or a ready FLIPS/pending flip for this heap as "not clean". Each needs a regression test like the one in the second table.

Not checked: how often these queues are non-empty on a quiet heap in game. An earlier in-game run in this thread found texture_ahead_clean false almost every world frame anyway, so menus and still scenes are where this would show. I made no in-game run. The main column of the end-to-end probe ran on WARP only.

GPUs tested: one NVIDIA desktop card + WARP.
AI-assisted: yes (Claude Code).

**@⁠Kal0s-design** on GitHub · 2026-12-02 13:54 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3029#issuecomment-7347654083) Ran natively on Windows 11, head `e49404808` merged into current `main` (`128648cfe`, no conflicts), `leonida-gpu` with `--features diagnostics`, `--locked`, toolchain 1.98.1. I ran the tests on the hardware card and again on WARP, with the same results. The source review above already names `FLIPS` and `RESHOWN`. Two more queues are missing from `texture_ahead_clean`, and I ran a probe that shows the skipped pass leaving them waiting while `main` clears them. **Suite** | Check | Result | |---|---| | `cargo test -p leonida-gpu --lib` (merge) | 773 passed, 0 failed, 59 ignored | | `draw::tests::ahead_textures_skip_only_when_nothing_is_pending` | pass | | `cargo clippy -p leonida-gpu --all-targets` | one new warning in the PR's code: `too_many_arguments` (8/7) on `ahead_textures_clean` (`draw.rs:566`) | **The predicate against queued work** (throwaway test in `descriptor/host.rs`, not committed). The setup is a `HostHeap` of 8 slots with placed spans noted for slots 2 to 4. I settled the remap cursor and cast, emptied the queue, took `served = texture_news().0` and queued one item at a time. | Queued item | `texture_ahead_clean(served, frame)` | Next step of the pass | |---|---|---| | nothing | true | nothing | | `read_short(start)` (`SHORT`) | **true** | `texture_slots_short` made 1 slot due | | a `WAITING` entry for the start, back-dated 2 frames and waited 1.2 s (what `levels_waiting` leaves) | **true** | `texture_slots_waiting` made 1 slot due | | `levels_changed(start)` (`RESHOWN`) | **true** | `texture_views_remade` drained it | | a hand-built ready `Flip` for this heap pushed into `FLIPS` | **true** | not run in the probe; per the code, `texture_slots_flip` takes it | Neither `read_short` nor `levels_waiting` increments `TextureQueue::writes` or sets any flag that `texture_news` reads. Only the pass itself turns them into queue entries. **End to end through `test_record_passes_ahead`** (same heap made with `create_heap`, `frame::test_advance()` before each list, `SHORT` and `WAITING` filled as above after list 2, queue otherwise empty): | List | PR: recorded / `SHORT` pending / `WAITING` pending / due | `main`: recorded / `SHORT` / `WAITING` / due | |---|---|---| | 1 | true / - / - / 0 | true / - / - / 0 | | 2 | false (skip) / - / - / 0 | true / - / - / 0 | | 3 | false / **yes** / **yes** / 0 | true / no / no / **2** | | 4 to 7 | false / **yes** / **yes** / 0 | true / no / no / 0 | On `main` the next list's pass turns both into due slots. On the PR they stay queued until something else makes the heap not clean. Each skip also stores `AHEAD_DID[1] = frame + 1` (read in code), so `done_ahead(1)` stays true and draws that are not baking also leave out their own textures' pass. This probe's queue is empty, so it shows the worst case. In a live heap, the slot whose filling queued the item was just uploaded, and by default it keeps a look on the queue (`frame + 1` when uploaded in part, otherwise `RECHECK_FRAMES` 4, 12, 40, 120, 400). That look makes `next_due <= frame + 1` and forces a pass, which drains both queues. So in a live heap, I expect a delay until the next due look in the heap, not a permanent stall. The delay grows as a slot's looks spread out, and has no bound with `LEONIDA_HEAP_RECHECK=0`. I did not measure it. A possible fix: count a non-empty `SHORT`, an eligible `WAITING` entry, a non-empty `RESHOWN`, or a ready `FLIPS`/pending flip for this heap as "not clean". Each needs a regression test like the one in the second table. Not checked: how often these queues are non-empty on a quiet heap in game. An earlier in-game run in this thread found `texture_ahead_clean` false almost every world frame anyway, so menus and still scenes are where this would show. I made no in-game run. The `main` column of the end-to-end probe ran on WARP only. GPUs tested: one NVIDIA desktop card + WARP. AI-assisted: yes (Claude Code).
Author
Owner

@⁠MoonEyes on GitHub · 2026-12-02 18:18 UTC · original

Verification of #3029 (third party, code review on Linux; not built: Windows-only leonida-gpu)

  • Head verified: e49404808784af77c5804c848174aa7c04ac19d6 (2 files: draw.rs +72/-7, descriptor/host.rs +23).
  • Merge base 393901a5b. git merge-tree --write-tree origin/main pr/3029 against main 45dc41f95 is clean
    (210 commits behind). CI on the head: 6/6 success.
  • python -I scripts/check_no_game_data.py on both files: exit 0.
  • The head has not changed since the two review findings below (2026-12-02 02:44 and 13:54 UTC).

Review

The skip (draw.rs:503-509) is gated by texture_ahead_clean (descriptor/host.rs:2890-2911). It treats the
heap as clean when TextureQueue::writes is unchanged and nothing in texture_news, by_due, held,
RESHOWN_AFTER or the cast has moved. The heap_textures pass it skips does more than that predicate looks at:

  1. Open, unaddressed: ready deferred flips in FLIPS (descriptor/host.rs:863, pushed at :3469 from an
    upload completion callback without bumping writes) are only published by texture_slots_flip inside the
    pass. ecox982745 raised this.
  2. Open, unaddressed: RESHOWN (filled by levels_changed), SHORT (read_short) and WAITING
    (levels_waiting) are also consumed only by the pass, and none of them bumps writes. Kal0s-design's probe
    shows SHORT and WAITING staying pending for lists 3 to 7 on the PR, where main makes those slots due at
    the next list.
  3. Each skip still stores AHEAD_DID for the frame (the comment at draw.rs:506-507), so the frame's own
    draws keep deferring to a pass that did not run. Items 1 and 2 can then wait indefinitely while the heap is
    otherwise quiet. That is a texture that never flips from its neutral descriptor, not just one late frame.

Root-cause fix, not a workaround: the predicate should be derived from the same queues the pass drains. One
option is a single "pass has work" query on HostHeap that includes FLIPS for this heap, RESHOWN, SHORT
and WAITING. Another is to bump TextureQueue::writes wherever those queues are pushed. A regression test
should keep writes unchanged and leave one item in each queue.

Smaller points:

  • ahead_textures_clean takes 8 arguments, so clippy reports too_many_arguments (draw.rs:566, per
    Kal0s-design). A struct, or the query above, would remove it.
  • record_passes_ahead_part now returns recorded instead of true (draw.rs:545), so AHEAD_STATS[0..2]
    stop counting skipped lists. That is fine, but findings.md figures based on those counters change meaning.

Process

  • AI disclosure is present (Gemini 4 Neon).

Verdict: defects. The skip can leave queued flips and slot work undone (items 1-3). Fix the predicate and add
the regression test before merge. The OreoFR and lixonik in-game ABBAs on this head do not cover these queues.

AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.


Generated by Claude Code

**@⁠MoonEyes** on GitHub · 2026-12-02 18:18 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3029#issuecomment-7354345474) **Verification of #3029 (third party, code review on Linux; not built: Windows-only `leonida-gpu`)** - Head verified: `e49404808784af77c5804c848174aa7c04ac19d6` (2 files: `draw.rs` +72/-7, `descriptor/host.rs` +23). - Merge base `393901a5b`. `git merge-tree --write-tree origin/main pr/3029` against `main` `45dc41f95` is clean (210 commits behind). CI on the head: 6/6 success. - `python -I scripts/check_no_game_data.py` on both files: exit 0. - The head has not changed since the two review findings below (2026-12-02 02:44 and 13:54 UTC). **Review** The skip (`draw.rs:503-509`) is gated by `texture_ahead_clean` (`descriptor/host.rs:2890-2911`). It treats the heap as clean when `TextureQueue::writes` is unchanged and nothing in `texture_news`, `by_due`, `held`, `RESHOWN_AFTER` or the cast has moved. The `heap_textures` pass it skips does more than that predicate looks at: 1. **Open, unaddressed:** ready deferred flips in `FLIPS` (`descriptor/host.rs:863`, pushed at `:3469` from an upload completion callback without bumping `writes`) are only published by `texture_slots_flip` inside the pass. ecox982745 raised this. 2. **Open, unaddressed:** `RESHOWN` (filled by `levels_changed`), `SHORT` (`read_short`) and `WAITING` (`levels_waiting`) are also consumed only by the pass, and none of them bumps `writes`. Kal0s-design's probe shows `SHORT` and `WAITING` staying pending for lists 3 to 7 on the PR, where `main` makes those slots due at the next list. 3. Each skip still stores `AHEAD_DID` for the frame (the comment at `draw.rs:506-507`), so the frame's own draws keep deferring to a pass that did not run. Items 1 and 2 can then wait indefinitely while the heap is otherwise quiet. That is a texture that never flips from its neutral descriptor, not just one late frame. Root-cause fix, not a workaround: the predicate should be derived from the same queues the pass drains. One option is a single "pass has work" query on `HostHeap` that includes `FLIPS` for this heap, `RESHOWN`, `SHORT` and `WAITING`. Another is to bump `TextureQueue::writes` wherever those queues are pushed. A regression test should keep `writes` unchanged and leave one item in each queue. Smaller points: - `ahead_textures_clean` takes 8 arguments, so clippy reports `too_many_arguments` (`draw.rs:566`, per Kal0s-design). A struct, or the query above, would remove it. - `record_passes_ahead_part` now returns `recorded` instead of `true` (`draw.rs:545`), so `AHEAD_STATS[0..2]` stop counting skipped lists. That is fine, but `findings.md` figures based on those counters change meaning. **Process** - AI disclosure is present (Gemini 4 Neon). **Verdict: defects.** The skip can leave queued flips and slot work undone (items 1-3). Fix the predicate and add the regression test before merge. The OreoFR and lixonik in-game ABBAs on this head do not cover these queues. AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
github-bot closed this pull request 2026-12-02 21:04:24 +00:00
Author
Owner

@⁠EdenBendheim on GitHub · 2026-12-02 21:02 UTC · original

RUN (in-game RTX 3090 300 s stress gate, 14-PR combined batch) — PASS covering exact head e49404808784af77c5804c848174aa7c04ac19d6.

  • Base & build: Merged cleanly via git merge --no-ff onto main b41763227 (diagnostics,dlss,mimalloc, exe_sha16 = c47eeb717f761d9d; changed-file clean-room scan exit 0; standalone Windows unit checks also passed default & diagnostics with compile-time red on ahead_textures_clean).
  • Batch heads (14 PRs): #3200 d1a91afd1, #3198 80a627bb1, #3191 93b47ac9d, #3189 c182fc392, #3176 ae0075d9a, #3168 337388052, #3164 1065952da, #3146 ebc0253ff, #3124 64600ef0c, #3069 311d33a40, #3031 8df1bfce7, #3029 e49404808, #3054 ff53fd8b9, #3010 d645712a3.
  • Hardware & setup: Windows 11, Ryzen 9 5900X (32 GB RAM), NVIDIA GeForce RTX 3090 24 GB, driver 610.88, Series X profile, 2560x1440, -NoFrameGen, LEONIDA_UPLOAD_AHEAD=1, scripts/game-gate.ps1 (301.3 s in world) with downtown street-level teleport + 8-leg dynamic sprint/turn/strafe stress mod (GATE CONTROL moved=2.51 m, max_from_ctrl=5,053.9 m).
Metric 14-PR Batch (c47eeb717f761d9d) main b41763227 baseline (cf499737bf684f6a)
Gate verdict / exit PASS (clean, 0 reasons, 0 warnings) PASS (clean, 0 reasons, 0 warnings)
World time 301.3 s (4,504 frames) 305.6 s
Device lost / crashes / missed pipeline waits 0 / 0 / 0 0 / 0 / 0
Rendered FPS (median) / p95 frame time 20.10 FPS / 69.76 ms 19.13 FPS / 74.01 ms
Median draws/frame / longest present gap 8,048 / 5.222 s 7,983 / 2.358 s

Verdict: PASS for the 300 s in-game stability gate on e49404808. (Single combined-batch stability check, not an isolated single-PR FPS gain claim.)

(AI-assisted verification: gemini-4-neon + gpt-6.2-astra.)

**@⁠EdenBendheim** on GitHub · 2026-12-02 21:02 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3029#issuecomment-7358704766) **RUN (in-game RTX 3090 300 s stress gate, 14-PR combined batch)** — **PASS** covering exact head `e49404808784af77c5804c848174aa7c04ac19d6`. - **Base & build:** Merged cleanly via `git merge --no-ff` onto `main` `b41763227` (`diagnostics,dlss,mimalloc`, `exe_sha16 = c47eeb717f761d9d`; changed-file clean-room scan exit `0`; standalone Windows unit checks also passed default & diagnostics with compile-time red on `ahead_textures_clean`). - **Batch heads (`14` PRs):** `#3200` `d1a91afd1`, `#3198` `80a627bb1`, `#3191` `93b47ac9d`, `#3189` `c182fc392`, `#3176` `ae0075d9a`, `#3168` `337388052`, `#3164` `1065952da`, `#3146` `ebc0253ff`, `#3124` `64600ef0c`, `#3069` `311d33a40`, `#3031` `8df1bfce7`, `#3029` `e49404808`, `#3054` `ff53fd8b9`, `#3010` `d645712a3`. - **Hardware & setup:** Windows 11, Ryzen 9 5900X (32 GB RAM), NVIDIA GeForce RTX 3090 24 GB, driver `610.88`, Series X profile, `2560x1440`, `-NoFrameGen`, `LEONIDA_UPLOAD_AHEAD=1`, `scripts/game-gate.ps1` (`301.3 s` in world) with downtown street-level teleport + 8-leg dynamic sprint/turn/strafe stress mod (`GATE CONTROL moved=2.51 m`, `max_from_ctrl=5,053.9 m`). | Metric | 14-PR Batch (`c47eeb717f761d9d`) | `main` `b41763227` baseline (`cf499737bf684f6a`) | |---|---:|---:| | Gate verdict / exit | **PASS** (`clean`, `0` reasons, `0` warnings) | **PASS** (`clean`, `0` reasons, `0` warnings) | | World time | `301.3 s` (`4,504` frames) | `305.6 s` | | Device lost / crashes / missed pipeline waits | `0` / `0` / `0` | `0` / `0` / `0` | | Rendered FPS (median) / p95 frame time | `20.10 FPS` / `69.76 ms` | `19.13 FPS` / `74.01 ms` | | Median draws/frame / longest present gap | `8,048` / `5.222 s` | `7,983` / `2.358 s` | **Verdict:** **PASS** for the 300 s in-game stability gate on `e49404808`. *(Single combined-batch stability check, not an isolated single-PR FPS gain claim.)* *(AI-assisted verification: `gemini-4-neon` + `gpt-6.2-astra`.)*
Author
Owner

@⁠bobcatchris on GitHub · 2026-12-02 21:02 UTC · original

Closing this optimization attempt as net-negative.

Thank you @ecox982745, @Kal0s-design, @OreoFR, @lixonik, and @MoonEyes for the thorough source reviews and in-game ABBA measurements:

  • Two independent ABBAs (@OreoFR on RTX 4070 Laptop and @lixonik on RTX 5070) measured zero gain / slight regression (-1.2% to -15%) because active frames mark nearly every frame (1.00 ahead lists/frame).
  • As @ecox982745 and @Kal0s-design showed, texture_ahead_clean would also need to check FLIPS/PENDING_LIST_FLIPS, RESHOWN, SHORT, and WAITING (reducing skips even further) and avoid refreshing AHEAD_DID on skip.

AI-assisted: Gemini 4 Neon

**@⁠bobcatchris** on GitHub · 2026-12-02 21:02 UTC · [original](https://github.com/ProjectLeonida/mandy/pull/3029#issuecomment-7358707244) Closing this optimization attempt as net-negative. Thank you `@ecox982745`, `@Kal0s-design`, `@OreoFR`, `@lixonik`, and `@MoonEyes` for the thorough source reviews and in-game ABBA measurements: - Two independent ABBAs (`@OreoFR` on RTX 4070 Laptop and `@lixonik` on RTX 5070) measured zero gain / slight regression (`-1.2%` to `-15%`) because active frames mark nearly every frame (`1.00` ahead lists/frame). - As `@ecox982745` and `@Kal0s-design` showed, `texture_ahead_clean` would also need to check `FLIPS`/`PENDING_LIST_FLIPS`, `RESHOWN`, `SHORT`, and `WAITING` (reducing skips even further) and avoid refreshing `AHEAD_DID` on skip. AI-assisted: Gemini 4 Neon

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/ubiquitarianism--leonida!3029
No description provided.