d3d12: model the memory-value writers lists have besides ranks 71/72, read the waits' mask and engine (D3D12-LIST-VALUE-PRODUCERS) #3439

Merged
leonida/mandy
MoonEyes merged 5 commits from fix/list-value-producers into main 2026-12-04 11:37:48 +00:00

Pull request successfully merged and closed

Member

Change

  • Commit 1 (diagnostic, no switch): every memory-value wait a queue passes unmet at a present is counted by address
    and by cause (no write seen at the address / a write seen that does not meet it / a write by a method not modelled
    whose value would have met it / one whose value would not). One cumulative log line at most every 10 s, 30 a run, with
    the waits recorded by engine. Addresses and counters only.
  • Commit 2 (LEONIDA_LIST_VALUE_PRODUCERS, on by default, =0 is the old behaviour):
    • ranks 90/91 (top of pipe 32/64), 92 (bottom of shader), 137/138 (bottom of pipe "2X") store their value when the
      list has run, as 71/72 do; 64-bit clock flags are decoded (bottom of pipe 1 GPU / 2 system, top of pipe bit 4 / 8);
    • the 32-bit wait is (address, comparison, reference, mask, engine) and applies the mask to the value read; the
      64-bit wait is (address, comparison, reference, engine), no mask. The engine (0 ME, 1 PFP, 2 CE) is kept in
      the wait, logged and counted. The compare stays unsigned;
    • a wait at a fence's GPU address is met by a signal of that fence queued behind the flights in the air.
  • Not changed: the passing of a wait at a present (no change to the expiry), the cuts, comparison "never" (still
    never met, logged once). The wait calls' extra stack arguments follow console behaviour (hypothesis, not measured in Leonida).
  • d3d12/docs/findings.md has the note and the prediction; switches.md regenerated.

Tests

  • cargo test -p leonida-gpu --locked: 742 passed (CARGO_TARGET_DIR outside the repo). New: one test per producer
    (newer_lists_write_the_values_of_ranks_90_to_92_137_and_138, every_producer_writes_its_value_and_clocks; with
    the commit 1 tree those slots store nothing, the test asserts they do), mask/engine decoding
    (a_wait_applies_its_mask_to_the_value_only, the_engine_is_kept_and_counted), fence-address signal
    (a_signal_meets_a_wait_at_the_fence_address), and the diagnostic book (cause, bounds, rate limit).
    LEONIDA_LIST_VALUE_PRODUCERS=0 also run on the table test: nothing stored, as before.
  • python -I tests/test_d3d12_switches.py, python -I scripts/check_no_game_data.py on the touched files: pass.
  • Not covered by a test: host::late_met_known with a real queued signal (it needs the global line); only its
    matching helper is tested.

In-game run

Game gate (scripts/game-gate.ps1), switch on (default), -SeriesS, RTX 4060 8 GB, driver 32.0.16.1088, Windows 11,
build with diagnostics: PASS, 322 s in the world, no device loss (VRAM peak 6 686 MB for a 6 709 MB budget, 0 s
over it; median 17.5 fps). One warning, fault_after_stop: access violations in the runtime after the gate had
stopped the run (exit clean); not yet compared with a run of main, so not attributed to this change.

Not done yet: the A/B with LEONIDA_LIST_VALUE_PRODUCERS=0 on the same route, and a run on a card that loses its
device today (0x887A0005 reports). Volunteers with an 8 GB card are welcome: docs/game_gate.md.

AI-assisted

Written with Claude Opus 5.5 (Anthropic); reviewed by a separate Claude Opus 5.5 reviewer instance (not the author),
whose medium point (a global lock taken even with the switch off) is fixed in the last commit. Tested with
cargo test and the in-game gate above.

🤖 Generated with Claude Code

## Change - Commit 1 (diagnostic, no switch): every memory-value wait a queue passes unmet at a present is counted by address and by cause (no write seen at the address / a write seen that does not meet it / a write by a method not modelled whose value would have met it / one whose value would not). One cumulative log line at most every 10 s, 30 a run, with the waits recorded by engine. Addresses and counters only. - Commit 2 (`LEONIDA_LIST_VALUE_PRODUCERS`, on by default, `=0` is the old behaviour): - ranks 90/91 (top of pipe 32/64), 92 (bottom of shader), 137/138 (bottom of pipe "2X") store their value when the list has run, as 71/72 do; 64-bit clock flags are decoded (bottom of pipe 1 GPU / 2 system, top of pipe bit 4 / 8); - the 32-bit wait is `(address, comparison, reference, mask, engine)` and applies the mask to the value read; the 64-bit wait is `(address, comparison, reference, engine)`, no mask. The engine (0 ME, 1 PFP, 2 CE) is kept in the wait, logged and counted. The compare stays unsigned; - a wait at a fence's GPU address is met by a signal of that fence queued behind the flights in the air. - Not changed: the passing of a wait at a present (no change to the expiry), the cuts, comparison "never" (still never met, logged once). The wait calls' extra stack arguments follow console behaviour (hypothesis, not measured in Leonida). - `d3d12/docs/findings.md` has the note and the prediction; `switches.md` regenerated. ## Tests - `cargo test -p leonida-gpu --locked`: 742 passed (CARGO_TARGET_DIR outside the repo). New: one test per producer (`newer_lists_write_the_values_of_ranks_90_to_92_137_and_138`, `every_producer_writes_its_value_and_clocks`; with the commit 1 tree those slots store nothing, the test asserts they do), mask/engine decoding (`a_wait_applies_its_mask_to_the_value_only`, `the_engine_is_kept_and_counted`), fence-address signal (`a_signal_meets_a_wait_at_the_fence_address`), and the diagnostic book (cause, bounds, rate limit). `LEONIDA_LIST_VALUE_PRODUCERS=0` also run on the table test: nothing stored, as before. - `python -I tests/test_d3d12_switches.py`, `python -I scripts/check_no_game_data.py` on the touched files: pass. - Not covered by a test: `host::late_met_known` with a real queued signal (it needs the global line); only its matching helper is tested. ## In-game run Game gate (`scripts/game-gate.ps1`), switch on (default), `-SeriesS`, RTX 4060 8 GB, driver 32.0.16.1088, Windows 11, build with diagnostics: **PASS, 322 s in the world, no device loss** (VRAM peak 6 686 MB for a 6 709 MB budget, 0 s over it; median 17.5 fps). One warning, `fault_after_stop`: access violations in the runtime after the gate had stopped the run (exit clean); not yet compared with a run of main, so not attributed to this change. Not done yet: the A/B with `LEONIDA_LIST_VALUE_PRODUCERS=0` on the same route, and a run on a card that loses its device today (0x887A0005 reports). Volunteers with an 8 GB card are welcome: docs/game_gate.md. ## AI-assisted Written with Claude Opus 5.5 (Anthropic); reviewed by a separate Claude Opus 5.5 reviewer instance (not the author), whose medium point (a global lock taken even with the switch off) is fixed in the last commit. Tested with `cargo test` and the in-game gate above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A queue passes the oldest wait at a present whether its value is there or not. Count those by address and
cause (no write seen, a write that does not meet it, a write by a method the project does not model whose
value would have met it) and log a cumulative line every 10 s, 30 at most. The methods of ranks 90 to 92, 137
and 138 are only seen, not yet modelled. Addresses and counters only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Top-of-pipe writes (ranks 90, 91), bottom-of-shader (92) and bottom-of-pipe 2X (137, 138) now store their value
when the list has run, as 71 and 72 do; the 32-bit wait applies its mask to the value read; the engine of both
waits is kept and counted; a wait at a fence's GPU address is met by a signal of that fence behind the flights
in the air. LEONIDA_LIST_VALUE_PRODUCERS=0 keeps the old behaviour. The passing of a wait at a present is not
changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
list.rs: wait_for keeps main's #[inline(always)] and entry argument (measure_call/cut) and the branch's mask and engine; wait_value/wait_value64 pass both.
findings.md: both notes kept (main's background-work note, then the value-producers note).
switches.md regenerated.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Member

Merged current main into the branch to clear the conflict (983c7f6781): list.rs keeps main's entry argument and #[inline(always)] plus this PR's mask and engine; findings.md keeps both notes. switches.md regenerated.

After the merge: cargo test --locked -p leonida-gpu -p leonida 746 + 60 + 5 passed, 0 failed; python -I tests/test_d3d12_switches.py 22 OK; check_no_game_data.py on the touched files: pass. The in-game gate in the description ran on 1036522b82 (before the merge); a second gate run with main's changes since then is still to do.

AI-assisted (Claude Opus 5.5).

Merged current main into the branch to clear the conflict (`983c7f6781`): `list.rs` keeps main's `entry` argument and `#[inline(always)]` plus this PR's mask and engine; `findings.md` keeps both notes. `switches.md` regenerated. After the merge: `cargo test --locked -p leonida-gpu -p leonida` 746 + 60 + 5 passed, 0 failed; `python -I tests/test_d3d12_switches.py` 22 OK; `check_no_game_data.py` on the touched files: pass. The in-game gate in the description ran on `1036522b82` (before the merge); a second gate run with main's changes since then is still to do. AI-assisted (Claude Opus 5.5).
First-time contributor

Thanks, here are the results.

scripts/game-gate.ps1 run ... -PlayArgs '-SeriesS', 300 s target, default LEONIDA_THIN=1 (6 threads), RX 6800 XT, driver 32.0.21045.29003. Same data folder and caches for both runs, warmed first by a 60 s gate run on main with LEONIDA_THIN=0 (PASS, 29.5 fps median).

Build Result Device loss Mean fps
main 68427be7e FAIL (device_lost, world_not_reached) 306.7 s after the gate's start, about 4.6 s after the first frame line with world draws (808 draws/frame) none: the world was never reached by the gate's count (two frame lines in a row at 500+ draws)
#3439 983c7f678 FAIL (device_lost, world_not_reached) 64.9 s after the gate's start, about 4.3 s after the first frame line with world draws (194 draws/frame) none, same reason

Both are the same reset as in #3264: 0x887A0007 (DEVICE_RESET), game exit 0x887A0005, device-removed data; none. Removal context on #3439: the submitting thread was preparing a submission (3 submissions of ours started and not yet seen finished), of 27 lists, for 9.2 ms; on main: (11 submissions ...), of 35 lists, for 3.7 ms.

On #3439, the log has no memory-value waits passed without being met line at all, so no memory-value wait was passed unmet at a present before the reset.

The gate run folders (summary.json, run.json, events.jsonl, memory.csv, leonida.log), with the Windows user and PC names replaced: mandy-gate-main-rx6800xt.zip, mandy-gate-pr3439-rx6800xt.zip.

AI-assisted: log analysis and write-up with Claude Opus 5.5 (High).

Thanks, here are the results. `scripts/game-gate.ps1 run ... -PlayArgs '-SeriesS'`, 300 s target, default `LEONIDA_THIN=1` (6 threads), RX 6800 XT, driver 32.0.21045.29003. Same data folder and caches for both runs, warmed first by a 60 s gate run on main with `LEONIDA_THIN=0` (PASS, 29.5 fps median). | Build | Result | Device loss | Mean fps | |---|---|---|---| | main `68427be7e` | **FAIL** (`device_lost`, `world_not_reached`) | 306.7 s after the gate's start, about 4.6 s after the first frame line with world draws (808 draws/frame) | none: the world was never reached by the gate's count (two frame lines in a row at 500+ draws) | | #3439 `983c7f678` | **FAIL** (`device_lost`, `world_not_reached`) | 64.9 s after the gate's start, about 4.3 s after the first frame line with world draws (194 draws/frame) | none, same reason | Both are the same reset as in #3264: `0x887A0007` (DEVICE_RESET), game exit `0x887A0005`, `device-removed data; none`. Removal context on #3439: `the submitting thread was preparing a submission (3 submissions of ours started and not yet seen finished), of 27 lists, for 9.2 ms`; on main: `(11 submissions ...), of 35 lists, for 3.7 ms`. On #3439, the log has no `memory-value waits passed without being met` line at all, so no memory-value wait was passed unmet at a present before the reset. The gate run folders (`summary.json`, `run.json`, `events.jsonl`, `memory.csv`, `leonida.log`), with the Windows user and PC names replaced: `mandy-gate-main-rx6800xt.zip`, `mandy-gate-pr3439-rx6800xt.zip`. AI-assisted: log analysis and write-up with Claude Opus 5.5 (High).
Author
Member

Merging, with Moon's written OK as maintainer (two maintainers only: the CONTRIBUTING rule against merging one's own PR is waived for this series). Second in-game gate on 983c7f6781 (after the first main merge): PASS, 324 s in the world, no device loss, RTX 4060 8 GB, -SeriesS -PrecompileUsed. Branch updated with main 1c3570a88a (both findings.md notes kept). The merged tree is the one tested locally: cargo test --locked -p leonida-gpu -p leonida -p leonida-hle all passed, tests/test_d3d12_switches.py OK, check_no_game_data.py clean. AI-assisted (Claude Opus 5.5).

Merging, with Moon's written OK as maintainer (two maintainers only: the CONTRIBUTING rule against merging one's own PR is waived for this series). Second in-game gate on `983c7f6781` (after the first main merge): **PASS, 324 s in the world, no device loss**, RTX 4060 8 GB, `-SeriesS -PrecompileUsed`. Branch updated with main `1c3570a88a` (both `findings.md` notes kept). The merged tree is the one tested locally: `cargo test --locked -p leonida-gpu -p leonida -p leonida-hle` all passed, `tests/test_d3d12_switches.py` OK, `check_no_game_data.py` clean. AI-assisted (Claude Opus 5.5).
First-time contributor

Thanks @MoonEyes, here are the results.

Same gate recipe as above (-PlayArgs '-SeriesS', 300 s), this time with the LEONIDA_THIN=0 workaround so the runs get past world entry. Same data folder and caches, one run per build.

Build Result Time in the world Device loss Mean fps Median fps p5 fps Frame p95
main 68427be7e PASS 302 s none 19.9 21.5 15.5 64.7 ms
#3439 983c7f678 PASS 305 s none 22.1 22.1 17.7 56.4 ms

The mean fps is the gate's frame count divided by the time it covers (the world minus its first 60 s); the other columns are the gate's own. Both runs stopped cleanly on the target, cache saved, no crash, no ERROR line, no missed pipeline wait, video memory under budget the whole time.

Both runs are one each, and I played freely rather than on a fixed route, so I wouldn't read the fps gap as a gain from #3439. On main, the gate's under_2_at_s is 200 s (one second with fewer than 2 frames; the longest gap with no frame was 1.4 s), against none on #3439.

With THIN=0, the log again has no memory-value waits passed without being met line, over the whole run.

So on this card #3439 does no harm, but it does not stop the device loss with the default THIN=1 (my results above, #3264). What avoids it here is #3031's pooled command allocators: the DONE on #3031.

Logs: mandy-gate-main-thin0-rx6800xt.zip, mandy-gate-pr3439-thin0-rx6800xt.zip (Windows user and PC names replaced).

AI-assisted: log analysis and write-up with Claude Opus 5.5 (High).

Thanks @MoonEyes, here are the results. Same gate recipe as above (`-PlayArgs '-SeriesS'`, 300 s), this time with the `LEONIDA_THIN=0` workaround so the runs get past world entry. Same data folder and caches, one run per build. | Build | Result | Time in the world | Device loss | Mean fps | Median fps | p5 fps | Frame p95 | |---|---|---|---|---|---|---|---| | main `68427be7e` | **PASS** | 302 s | none | 19.9 | 21.5 | 15.5 | 64.7 ms | | #3439 `983c7f678` | **PASS** | 305 s | none | 22.1 | 22.1 | 17.7 | 56.4 ms | The mean fps is the gate's frame count divided by the time it covers (the world minus its first 60 s); the other columns are the gate's own. Both runs stopped cleanly on the target, cache saved, no crash, no `ERROR` line, no missed pipeline wait, video memory under budget the whole time. Both runs are one each, and I played freely rather than on a fixed route, so I wouldn't read the fps gap as a gain from #3439. On main, the gate's `under_2_at_s` is 200 s (one second with fewer than 2 frames; the longest gap with no frame was 1.4 s), against none on #3439. With `THIN=0`, the log again has no `memory-value waits passed without being met` line, over the whole run. So on this card #3439 does no harm, but it does not stop the device loss with the default `THIN=1` (my results above, #3264). What avoids it here is #3031's pooled command allocators: [the DONE on #3031](https://git.leonida.now/leonida/mandy/pulls/3031#issuecomment-26062). Logs: `mandy-gate-main-thin0-rx6800xt.zip`, `mandy-gate-pr3439-thin0-rx6800xt.zip` (Windows user and PC names replaced). AI-assisted: log analysis and write-up with Claude Opus 5.5 (High).
Sign in to join this conversation.
No description provided.