d3d12: keep RDNA2's 2 GB aperture segment from filling (device lost at the first heavy scene with relay 2) #2670

Closed
amujark wants to merge 9 commits from upstream-pr/2670 into main
amujark commented 2026-11-30 01:27:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by amujark on 2026-11-30T01:27:45Z.


Claimed in the coordination issue as: D3D12-RDNA2-APERTURE-SEGMENT (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7266137587)

What and why

On an RDNA2 card with the default play settings (LEONIDA_RELAY=2) the host device is removed at the first heavy scene (the opening cinematic): 0x887A0007, DRED breadcrumbs empty, "nothing of ours was running on the card", with about 1,250-1,270 host lists alive. It happened in every run, and main alone does it 72 s in even with LEONIDA_BURY_LAG=16. LEONIDA_RELAY=0 survives, at about 8 fps.

This is the failure of PastiiJay/klbf-lab#127. The video memory manager's 2 GB aperture segment, which DXGI's budgets leave out, holds the driver's command buffers (1 MB and more per command list). land() kept the lists of the last bury_lag() flights, and every host list kept its own prelude for life, so the segment ran full and the scheduler marked the device faulted.

The fix is ported by hand from kyokyotosh/VIctory-6700XT (GPL-3.0, as this tree), one commit each, attributed in the messages and the doc comments:

  1. f173347: the host lists of landed flights go back to the pool at once (list::recycle_landed). What their commands named (Held: the whole Deferred, the texture states, twins and refreshes being found, and the Detached's descriptor state and uploads) waits bury_lag() through retire. Both the reaper thread and the path without it use it.
  2. 018d372: host/segments.rs reads the adapter's segments with D3DKMTQueryStatistics (Wdk_Graphics_Direct3D feature). They are logged once at device creation and looked at every 100 ms at most. While an aperture segment holds more than LEONIDA_SEGMENT_TIGHT percent of its limit, send_late lands the flights in the air.
  3. e3c0703: it is looked at on every send, with hysteresis: tight from 80 % by default, clear below 70 % (0: never). While tight, idle host lists are trimmed to 64, with their bytes taken out of the pool's count. The threshold is a pure function (is_tight) with unit tests.
  4. 63a773e: preludes come from a pool. One is taken when a list is first submitted with transitions and given back at its reset; 128 are kept idle, 16 while tight. The pool keeps each allocator's creation instant, so LEONIDA_ALLOCATOR_TRIM still sees its real age. LEONIDA_LAZY_PRELUDE=0 still makes one with the list.

There is one more change, in the launcher. With the fix and relay 2 on the same card, the lighting rose and fell with where the camera looked and went black, which looks like the automatic exposure reading a late value. The same build in the same place with LEONIDA_RELAY_COPY=0 looked right at 17-20 fps. d3d12/scripts/play-nvidia.ps1 sets LEONIDA_RELAY_COPY=1 for every card; it now leaves it out on Radeon RX 6000 cards. -More @{LEONIDA_RELAY_COPY='1'} still puts it back (checked with -DryRun). Only the RX 6800 XT is measured.

Tested

RX 6800 XT, one run each, Series S profile, -Log, pipelines already cached:

device lighting fps
main 452d1d1b6, relay 2, LEONIDA_BURY_LAG=16 removed 72 s in (1,253 host lists alive) (not reached) -
this PR, relay 0 no removal right 8
this PR, relay 2, launcher defaults before the last commit no removal in 11 min rises and falls, goes black 18-20
this PR, relay 2, LEONIDA_RELAY_COPY=0 (the last commit's default here) no removal right 17-20 in the world, 10-15 in cinematics
  • With the fix, host lists alive settle at 1,353-1,378 and stay there. They are not fewer than at the removal, but the segment no longer fills: preludes made fell to 126-154 for the whole run, and the back-off never fired (segment 1, the 2,048 MB aperture).
  • cargo test -p leonida-gpu: 556 passed, 1 failed, 47 ignored. The failure, descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in, fails the same way on main 452d1d1b6. The new host::segments::tests::* and list::tests::a_trim_keeps_the_first_and_takes_the_rest pass.
  • cargo check -p leonida-gpu and --features diagnostics: ok. cargo clippy -p leonida-gpu --features diagnostics: no new warnings in the changed lines.
  • cargo build --locked --profile diag -p leonida --features diagnostics,mimalloc: ok.
  • python -I scripts/check_no_game_data.py on the changed files: pass. The branch is on main 452d1d1b6 and merges cleanly with main 0eab02a8b.

GPUs tested: AMD Radeon RX 6800 XT, Adrenalin 32.0.21045.29003, Windows 11 (Ryzen 9 5950X, 32 GB)

AI-assisted: yes (Claude Code)

Checklist

  • Based on current main and merges cleanly (a conflicting pull request is labeled needs rebase).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (n/a: no translator change)
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5557352543 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2670). Originally posted by [amujark](https://github.com/amujark) on 2026-11-30T01:27:45Z. --- Claimed in the coordination issue as: D3D12-RDNA2-APERTURE-SEGMENT (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7266137587) ### What and why On an RDNA2 card with the default play settings (`LEONIDA_RELAY=2`) the host device is removed at the first heavy scene (the opening cinematic): `0x887A0007`, DRED breadcrumbs empty, "nothing of ours was running on the card", with about 1,250-1,270 host lists alive. It happened in every run, and `main` alone does it 72 s in even with `LEONIDA_BURY_LAG=16`. `LEONIDA_RELAY=0` survives, at about 8 fps. This is the failure of PastiiJay/klbf-lab#127. The video memory manager's 2 GB aperture segment, which DXGI's budgets leave out, holds the driver's command buffers (1 MB and more per command list). `land()` kept the lists of the last `bury_lag()` flights, and every host list kept its own prelude for life, so the segment ran full and the scheduler marked the device faulted. The fix is ported by hand from kyokyotosh/VIctory-6700XT (GPL-3.0, as this tree), one commit each, attributed in the messages and the doc comments: 1. `f173347`: the host lists of landed flights go back to the pool at once (`list::recycle_landed`). What their commands named (`Held`: the whole `Deferred`, the texture states, twins and refreshes being found, and the `Detached`'s descriptor state and uploads) waits `bury_lag()` through `retire`. Both the reaper thread and the path without it use it. 2. `018d372`: `host/segments.rs` reads the adapter's segments with `D3DKMTQueryStatistics` (`Wdk_Graphics_Direct3D` feature). They are logged once at device creation and looked at every 100 ms at most. While an aperture segment holds more than `LEONIDA_SEGMENT_TIGHT` percent of its limit, `send_late` lands the flights in the air. 3. `e3c0703`: it is looked at on every send, with hysteresis: tight from 80 % by default, clear below 70 % (`0`: never). While tight, idle host lists are trimmed to 64, with their bytes taken out of the pool's count. The threshold is a pure function (`is_tight`) with unit tests. 4. `63a773e`: preludes come from a pool. One is taken when a list is first submitted with transitions and given back at its reset; 128 are kept idle, 16 while tight. The pool keeps each allocator's creation instant, so `LEONIDA_ALLOCATOR_TRIM` still sees its real age. `LEONIDA_LAZY_PRELUDE=0` still makes one with the list. There is one more change, in the launcher. With the fix and relay 2 on the same card, the lighting rose and fell with where the camera looked and went black, which looks like the automatic exposure reading a late value. The same build in the same place with `LEONIDA_RELAY_COPY=0` looked right at 17-20 fps. `d3d12/scripts/play-nvidia.ps1` sets `LEONIDA_RELAY_COPY=1` for every card; it now leaves it out on Radeon RX 6000 cards. `-More @{LEONIDA_RELAY_COPY='1'}` still puts it back (checked with `-DryRun`). Only the RX 6800 XT is measured. ### Tested RX 6800 XT, one run each, Series S profile, `-Log`, pipelines already cached: | | device | lighting | fps | |---|---|---|---| | `main` `452d1d1b6`, relay 2, `LEONIDA_BURY_LAG=16` | removed 72 s in (1,253 host lists alive) | (not reached) | - | | this PR, relay 0 | no removal | right | 8 | | this PR, relay 2, launcher defaults before the last commit | no removal in 11 min | rises and falls, goes black | 18-20 | | this PR, relay 2, `LEONIDA_RELAY_COPY=0` (the last commit's default here) | no removal | right | 17-20 in the world, 10-15 in cinematics | - With the fix, host lists alive settle at 1,353-1,378 and stay there. They are not fewer than at the removal, but the segment no longer fills: preludes made fell to 126-154 for the whole run, and the back-off never fired (segment 1, the 2,048 MB aperture). - `cargo test -p leonida-gpu`: 556 passed, 1 failed, 47 ignored. The failure, `descriptor::host::tests::views_are_made_beside_the_heap_and_copied_in`, fails the same way on `main` `452d1d1b6`. The new `host::segments::tests::*` and `list::tests::a_trim_keeps_the_first_and_takes_the_rest` pass. - `cargo check -p leonida-gpu` and `--features diagnostics`: ok. `cargo clippy -p leonida-gpu --features diagnostics`: no new warnings in the changed lines. - `cargo build --locked --profile diag -p leonida --features diagnostics,mimalloc`: ok. - `python -I scripts/check_no_game_data.py` on the changed files: pass. The branch is on `main` `452d1d1b6` and merges cleanly with `main` `0eab02a8b`. GPUs tested: AMD Radeon RX 6800 XT, Adrenalin 32.0.21045.29003, Windows 11 (Ryzen 9 5950X, 32 GB) AI-assisted: yes (Claude Code) ### Checklist - [x] Based on current `main` and merges cleanly (a conflicting pull request is labeled `needs rebase`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here. - [ ] A new translator rule is in the contract table of `docs/design.md`, with how it was confirmed. (n/a: no translator change)
merzleckeier commented 2026-11-30 01:34:55 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-11-30T01:34:55Z.


I reproduced a launcher edge case with mixed Radeon and NVIDIA adapters. With both an RTX 4070 SUPER and RX 6800 XT in the controller inventory, -Adapter 'RTX 4070' still emits LEONIDA_ADAPTER=RTX 4070, but LEONIDA_RELAY_COPY is now unset at launch and after replaying the F1 command. A saved LEONIDA_ADAPTER=RTX 4070 produces the same result.

  • MEASURED Three fresh PowerShell 7.4.21 dry runs per tree with mocked CIM, on main 40e7fe69 and after merging 1462e3e8 (6be18311). Main emits LEONIDA_RELAY_COPY=1 in all controls. The PR retains 1 with the RTX alone, omits the setting with the RX 6800 XT alone, and omits it on the mixed setup with either card selected. An explicit saved LEONIDA_RELAY_COPY=1 still wins on the mixed setup.
  • READ IN CODE The launcher tests a joined list of controller names against the Radeon pattern. The runtime resolves the requested card separately through DXGI, including the F1 menu’s #index selectors. Basing the default on the resolved DXGI adapter would keep the workaround scoped to the selected card. Launcher rule · DXGI selection
  • MEASURED Adding #2626 on top (845e0208) gives the same relay settings. In all six cases across three runs, -MotionBlur survives the F1 replay, and the four motion-blur passes stay enabled.

This checks launcher settings with synthetic inputs. Aperture pressure and rendering were outside the probe. AI-assisted with OpenAI Codex.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7266259715 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2670#issuecomment-7266259715). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-11-30T01:34:55Z. --- I reproduced a launcher edge case with mixed Radeon and NVIDIA adapters. With both an RTX 4070 SUPER and RX 6800 XT in the controller inventory, `-Adapter 'RTX 4070'` still emits `LEONIDA_ADAPTER=RTX 4070`, but `LEONIDA_RELAY_COPY` is now unset at launch and after replaying the F1 command. A saved `LEONIDA_ADAPTER=RTX 4070` produces the same result. - **MEASURED** Three fresh PowerShell 7.4.21 dry runs per tree with mocked CIM, on `main` `40e7fe69` and after merging `1462e3e8` (`6be18311`). Main emits `LEONIDA_RELAY_COPY=1` in all controls. The PR retains `1` with the RTX alone, omits the setting with the RX 6800 XT alone, and omits it on the mixed setup with either card selected. An explicit saved `LEONIDA_RELAY_COPY=1` still wins on the mixed setup. - **READ IN CODE** The launcher tests a joined list of controller names against the Radeon pattern. The runtime resolves the requested card separately through DXGI, including the F1 menu’s `#index` selectors. Basing the default on the resolved DXGI adapter would keep the workaround scoped to the selected card. [Launcher rule](https://github.com/ProjectLeonida/mandy/blob/1462e3e8d2ff3522ba6dca5dbce20ae232b072a5/d3d12/scripts/play-nvidia.ps1#L354-L379) · [DXGI selection](https://github.com/ProjectLeonida/mandy/blob/1462e3e8d2ff3522ba6dca5dbce20ae232b072a5/d3d12/crates/leonida-gpu/src/host.rs#L1374-L1398) - **MEASURED** Adding #2626 on top (`845e0208`) gives the same relay settings. In all six cases across three runs, `-MotionBlur` survives the F1 replay, and the four motion-blur passes stay enabled. This checks launcher settings with synthetic inputs. Aperture pressure and rendering were outside the probe. AI-assisted with OpenAI Codex.
bobcatchris commented 2026-11-30 01:50:52 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-11-30T01:50:52Z.


Independent verification on native Windows 11 Pro (10.0.26200) + AMD Radeon RX 7900 XTX (gfx1100, driver 32.0.32029.2010, Rust 1.98):

  • Merged PR head 1462e3e8d cleanly onto main (40e7fe69d) — zero conflicts.
  • cargo test -p leonida-gpu --lib -- --test-threads=4 — 558 passed; 0 failed; 47 ignored (12.93s), including the new host::segments tests.
  • python -I scripts/check_no_game_data.py on all 6 touched files — PASS.

AI-assisted: Antigravity (Gemini 4 Neon)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7266490966 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2670#issuecomment-7266490966). Originally posted by [bobcatchris](https://github.com/bobcatchris) on 2026-11-30T01:50:52Z. --- Independent verification on native Windows 11 Pro (`10.0.26200`) + **AMD Radeon RX 7900 XTX** (`gfx1100`, driver `32.0.32029.2010`, Rust `1.98`): - Merged PR head `1462e3e8d` cleanly onto `main` (`40e7fe69d`) — zero conflicts. - `cargo test -p leonida-gpu --lib -- --test-threads=4` — **`558 passed; 0 failed; 47 ignored`** (`12.93s`), including the new `host::segments` tests. - `python -I scripts/check_no_game_data.py` on all 6 touched files — **PASS**. AI-assisted: Antigravity (Gemini 4 Neon)
amujark commented 2026-11-30 08:12:19 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by amujark on 2026-11-30T08:12:19Z.


Thanks, you were right: the launcher judged by every controller in the PC, not by the card the game plays on. Fixed in 077d6084c, as you suggested, by moving the decision to the runtime:

  • The launchers (play-nvidia.ps1, and play.ps1, which had the same default) now set LEONIDA_RELAY_COPY=auto instead of 1, and play-nvidia.ps1 no longer removes it by the controller list.
  • host.rs: when the host device is made, the adapter it is on (EnumAdapterByLuid(device.GetAdapterLuid()), so the default card, LEONIDA_ADAPTER by name and the F1 menu's #index all count) is checked: AMD vendor id 0x1002 and RX, optional spaces, 6 and three digits in DXGI's description (the launcher's old RX\s*6\d\d\d). Under auto, relay_copy() is off only on such a card and logs which way it went. If the adapter cannot be read it stays on, which was the default before this branch. Its one caller (make_relay_fetch) runs on a Host, after the device exists.
  • An explicit 1 or 0 still wins: the F1 file and -More are applied over the launcher's auto, and the runtime only treats auto by card.
  • The F1 menu's RELAY COPY QUEUE cycles OFF / ON / BY CARD (RX 6000 OFF); d3d12/README.md lists the variable.

What was tested:

  • MEASURED cargo test -p leonida-gpu --lib -- rx6000 every_line_fits values_cycle: 3 passed (a new table test of the name rule: RX 6800 XT, RX 6700M, RX6600 yes; RX 7900 XTX, RX 580, Radeon(TM) Graphics, an NVIDIA name, "RX 6800" with NVIDIA's vendor id and WARP no; plus the menu's width and cycling tests).
  • MEASURED play-nvidia.ps1 -DryRun: LEONIDA_RELAY_COPY=auto plain and with -Adapter 'RTX 4070' (which also prints LEONIDA_ADAPTER=RTX 4070); -More @{LEONIDA_RELAY_COPY='1'} prints 1.
  • NOT MEASURED The mixed NVIDIA + Radeon case on real hardware, and a game run with this commit: the only card here is an RX 6800 XT (Adrenalin driver 32.0.21045.29003). On that card auto should give what the previous commit gave (relay copy off), which is what the light was measured with.

Left as it is: the frame-generation default a few lines below ($card -match 'RTX\s*(40|50)\d\d') reads the same joined list, so on a mixed PC it can turn on DLSS frame generation while the game runs on the Radeon. That is on main already and outside this PR.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7272610988 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2670#issuecomment-7272610988). Originally posted by [amujark](https://github.com/amujark) on 2026-11-30T08:12:19Z. --- Thanks, you were right: the launcher judged by every controller in the PC, not by the card the game plays on. Fixed in 077d6084c, as you suggested, by moving the decision to the runtime: - The launchers (`play-nvidia.ps1`, and `play.ps1`, which had the same default) now set `LEONIDA_RELAY_COPY=auto` instead of `1`, and `play-nvidia.ps1` no longer removes it by the controller list. - `host.rs`: when the host device is made, the adapter it is on (`EnumAdapterByLuid(device.GetAdapterLuid())`, so the default card, `LEONIDA_ADAPTER` by name and the F1 menu's `#index` all count) is checked: AMD vendor id `0x1002` and `RX`, optional spaces, `6` and three digits in DXGI's description (the launcher's old `RX\s*6\d\d\d`). Under `auto`, `relay_copy()` is off only on such a card and logs which way it went. If the adapter cannot be read it stays on, which was the default before this branch. Its one caller (`make_relay_fetch`) runs on a `Host`, after the device exists. - An explicit `1` or `0` still wins: the F1 file and `-More` are applied over the launcher's `auto`, and the runtime only treats `auto` by card. - The F1 menu's RELAY COPY QUEUE cycles OFF / ON / BY CARD (RX 6000 OFF); `d3d12/README.md` lists the variable. What was tested: - **MEASURED** `cargo test -p leonida-gpu --lib -- rx6000 every_line_fits values_cycle`: 3 passed (a new table test of the name rule: RX 6800 XT, RX 6700M, RX6600 yes; RX 7900 XTX, RX 580, Radeon(TM) Graphics, an NVIDIA name, "RX 6800" with NVIDIA's vendor id and WARP no; plus the menu's width and cycling tests). - **MEASURED** `play-nvidia.ps1 -DryRun`: `LEONIDA_RELAY_COPY=auto` plain and with `-Adapter 'RTX 4070'` (which also prints `LEONIDA_ADAPTER=RTX 4070`); `-More @{LEONIDA_RELAY_COPY='1'}` prints `1`. - **NOT MEASURED** The mixed NVIDIA + Radeon case on real hardware, and a game run with this commit: the only card here is an RX 6800 XT (Adrenalin driver 32.0.21045.29003). On that card `auto` should give what the previous commit gave (relay copy off), which is what the light was measured with. Left as it is: the frame-generation default a few lines below (`$card -match 'RTX\s*(40|50)\d\d'`) reads the same joined list, so on a mixed PC it can turn on DLSS frame generation while the game runs on the Radeon. That is on `main` already and outside this PR. AI-assisted (Claude Code).
lerapeurdu62280-debug commented 2026-11-30 18:25:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lerapeurdu62280-debug on 2026-11-30T18:25:45Z.


Game-run A/B on Windows AMD RDNA2 (RX 6600 8 GB), the profile this PR is about. n=1 each, and one difference in the caches I could not avoid (below), so read it as a first data point, not a proof.

RUN rx6600-warm-2 (A) | 2026-11-30 18:16-18:19 UTC | lerapeurdu62280-debug | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        afb511541 + none
MACHINE:     AMD Radeon RX 6600 8 GB, desktop | 32.0.21045.29003 | Windows 11 26300 | 32 GB, Ryzen 5 3600
RECIPE:      README "Playing it": scripts\play-d3d12.ps1 -Log, its defaults (Series X, 2560x1440, diag + diagnostics,mimalloc) + DEVIATIONS: none | relay chosen: LEONIDA_RELAY=1
MEASURED:    story load, 1 frame line in the world | ~180 s in the title
END:         device lost (0x887A0007, device-removed data none, nothing of ours on the card)
CACHES:      warm; leonida warm made 1,719 pipelines before the start; 69 more made in play, each with the library refusing its entry (E_INVALIDARG)
INSTRUMENTS: none

RUN rx6600-pr2670-1 (B) | 2026-11-30 18:20-18:25 UTC | lerapeurdu62280-debug | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        afb511541 + #2670 (head merged, no conflicts)
MACHINE:     same
RECIPE:      same + DEVIATIONS: none | relay chosen: LEONIDA_RELAY=1; segments logged: id 1 aperture 2048 MB (8 MB resident at start)
MEASURED:    world load into play, 30 frame lines in the world (1000+ draws), median 1.9 fps there (slowest tenth 0.3, fastest tenth 9.6) | ~290 s in the title
END:         time limit (closed by the player), no device lost, no ERROR line in the log
CACHES:      warm; leonida warm made 1 pipeline before the start; 0 made in play
INSTRUMENTS: none

tested: #2670 on RX 6600 8 GB (Windows, AMD 32.0.21045.29003), better: story load + device lost at ~180 s / play for ~290 s, closed by hand, no device lost.

The caveat: B started with every pipeline A and the warm step had made, and made none in play, while A still made 69 in play. Both device losses on main on this card (also the cold run in #2464) came while pipelines were being made in play, so part of the difference may be the cache, not this PR. A cleaner pair would be A and B both from the same emptied pipeline cache; I can run that if it helps.

Contribution : EI S.O.S INFO LUDO

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7287835786 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2670#issuecomment-7287835786). Originally posted by [lerapeurdu62280-debug](https://github.com/lerapeurdu62280-debug) on 2026-11-30T18:25:45Z. --- Game-run A/B on Windows AMD RDNA2 (RX 6600 8 GB), the profile this PR is about. `n=1` each, and one difference in the caches I could not avoid (below), so read it as a first data point, not a proof. ``` RUN rx6600-warm-2 (A) | 2026-11-30 18:16-18:19 UTC | lerapeurdu62280-debug | AI-assisted: Claude Code (Claude Opus 5.5) BASE: afb511541 + none MACHINE: AMD Radeon RX 6600 8 GB, desktop | 32.0.21045.29003 | Windows 11 26300 | 32 GB, Ryzen 5 3600 RECIPE: README "Playing it": scripts\play-d3d12.ps1 -Log, its defaults (Series X, 2560x1440, diag + diagnostics,mimalloc) + DEVIATIONS: none | relay chosen: LEONIDA_RELAY=1 MEASURED: story load, 1 frame line in the world | ~180 s in the title END: device lost (0x887A0007, device-removed data none, nothing of ours on the card) CACHES: warm; leonida warm made 1,719 pipelines before the start; 69 more made in play, each with the library refusing its entry (E_INVALIDARG) INSTRUMENTS: none RUN rx6600-pr2670-1 (B) | 2026-11-30 18:20-18:25 UTC | lerapeurdu62280-debug | AI-assisted: Claude Code (Claude Opus 5.5) BASE: afb511541 + #2670 (head merged, no conflicts) MACHINE: same RECIPE: same + DEVIATIONS: none | relay chosen: LEONIDA_RELAY=1; segments logged: id 1 aperture 2048 MB (8 MB resident at start) MEASURED: world load into play, 30 frame lines in the world (1000+ draws), median 1.9 fps there (slowest tenth 0.3, fastest tenth 9.6) | ~290 s in the title END: time limit (closed by the player), no device lost, no ERROR line in the log CACHES: warm; leonida warm made 1 pipeline before the start; 0 made in play INSTRUMENTS: none ``` tested: #2670 on RX 6600 8 GB (Windows, AMD 32.0.21045.29003), better: story load + device lost at ~180 s / play for ~290 s, closed by hand, no device lost. The caveat: B started with every pipeline A and the warm step had made, and made none in play, while A still made 69 in play. Both device losses on `main` on this card (also the cold run in #2464) came while pipelines were being made in play, so part of the difference may be the cache, not this PR. A cleaner pair would be A and B both from the same emptied pipeline cache; I can run that if it helps. Contribution : EI S.O.S INFO LUDO
lerapeurdu62280-debug commented 2026-11-30 18:46:08 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lerapeurdu62280-debug on 2026-11-30T18:46:08Z.


The cleaner pair, as offered above: A and B from the same emptied caches (Leonida's pipelines folder and AMD's DxcCache moved aside before each run), so neither starts with pipelines the other made.

RUN rx6600-ab-A | 2026-11-30 18:30-18:34 UTC | lerapeurdu62280-debug | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        afb511541 + none
MACHINE:     AMD Radeon RX 6600 8 GB, desktop | 32.0.21045.29003 | Windows 11 26300 | 32 GB, Ryzen 5 3600
RECIPE:      README "Playing it": scripts\play-d3d12.ps1 -Log, its defaults + DEVIATIONS: none | precompile: shaders yes; pipelines 0 (emptied)
CACHES:      shaders warm; pipelines and driver cache emptied | RUN 1 of 2
TARGET:      device lost or not | PREDICTED: not written down before the run (expected: device lost, as the cold run in #2464)
MEASURED:    world load, 17 frame lines in the world, 0.2 fps there (pipelines made in play) | ~267 s in the title
END:         device lost (0x887A0007, device-removed data none; the submitting thread was preparing a submission, nothing of ours on the card, pipeline makes in flight)
VERDICT:     n/a (no prediction written before)

RUN rx6600-ab-B | 2026-11-30 18:35-18:45 UTC | lerapeurdu62280-debug | AI-assisted: Claude Code (Claude Opus 5.5)
BASE:        afb511541 + #2670
MACHINE:     same
RECIPE:      same + DEVIATIONS: none | precompile: shaders yes; pipelines 0 (emptied)
CACHES:      same state as A | RUN 2 of 2
TARGET:      device lost or not | PREDICTED: not written down before the run (expected: no device lost)
MEASURED:    world load into play, 32 frame lines in the world, 0.2 fps there (pipelines made in play, as A) | ~625 s in the title, ~380 s after the story pack opened
END:         time limit (closed by the player), no device lost, no ERROR line
VERDICT:     n/a (no prediction written before)

tested: #2670 on RX 6600 8 GB, better: device lost ~240 s after the story pack opened / no device lost through ~380 s, closed by hand. Same caches state this time, so the cache caveat of my first comment does not apply here. Still n=1 per side. The frame rate is the same in both (0.2 fps while pipelines are made in play); this PR does not change that, nor should it.

Contribution : EI S.O.S INFO LUDO

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7288335120 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2670#issuecomment-7288335120). Originally posted by [lerapeurdu62280-debug](https://github.com/lerapeurdu62280-debug) on 2026-11-30T18:46:08Z. --- The cleaner pair, as offered above: A and B from the **same emptied caches** (Leonida's `pipelines` folder and AMD's `DxcCache` moved aside before each run), so neither starts with pipelines the other made. ``` RUN rx6600-ab-A | 2026-11-30 18:30-18:34 UTC | lerapeurdu62280-debug | AI-assisted: Claude Code (Claude Opus 5.5) BASE: afb511541 + none MACHINE: AMD Radeon RX 6600 8 GB, desktop | 32.0.21045.29003 | Windows 11 26300 | 32 GB, Ryzen 5 3600 RECIPE: README "Playing it": scripts\play-d3d12.ps1 -Log, its defaults + DEVIATIONS: none | precompile: shaders yes; pipelines 0 (emptied) CACHES: shaders warm; pipelines and driver cache emptied | RUN 1 of 2 TARGET: device lost or not | PREDICTED: not written down before the run (expected: device lost, as the cold run in #2464) MEASURED: world load, 17 frame lines in the world, 0.2 fps there (pipelines made in play) | ~267 s in the title END: device lost (0x887A0007, device-removed data none; the submitting thread was preparing a submission, nothing of ours on the card, pipeline makes in flight) VERDICT: n/a (no prediction written before) RUN rx6600-ab-B | 2026-11-30 18:35-18:45 UTC | lerapeurdu62280-debug | AI-assisted: Claude Code (Claude Opus 5.5) BASE: afb511541 + #2670 MACHINE: same RECIPE: same + DEVIATIONS: none | precompile: shaders yes; pipelines 0 (emptied) CACHES: same state as A | RUN 2 of 2 TARGET: device lost or not | PREDICTED: not written down before the run (expected: no device lost) MEASURED: world load into play, 32 frame lines in the world, 0.2 fps there (pipelines made in play, as A) | ~625 s in the title, ~380 s after the story pack opened END: time limit (closed by the player), no device lost, no ERROR line VERDICT: n/a (no prediction written before) ``` tested: #2670 on RX 6600 8 GB, **better**: device lost ~240 s after the story pack opened / no device lost through ~380 s, closed by hand. Same caches state this time, so the cache caveat of my first comment does not apply here. Still `n=1` per side. The frame rate is the same in both (0.2 fps while pipelines are made in play); this PR does not change that, nor should it. Contribution : EI S.O.S INFO LUDO
amujark commented 2026-11-30 20:54:29 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by amujark on 2026-11-30T20:54:29Z.


Added aace3e264: while an aperture segment is tight, the trim this PR adds froze the line of submissions and the title's present for 150-260 ms.

What happened. trim_idle() and trim_preludes() ran inline on the submitting thread at the first submission after segments::tight turned true. They freed up to ~448 idle host lists and ~112 preludes there, and freeing them is the graphics kernel's time. Two LEONIDA_TIMELINE captures showed it:

  • the line and the title's present stood still for 153 ms and 262 ms;
  • the stall matched the tight=true / tight=false pair in the log exactly;
  • resident memory fell 242-370 MB during it.

The change. The same objects are taken out under the same locks, by the same decision. Only their drop moves to a thread of its own, leonida-trim. It is not the reaper, which can sit in 70-100 ms spans.

  • If that thread cannot be spawned, they are freed inline as before.
  • LEONIDA_TRIM_ASYNC=0 gives the old behaviour.
  • In diagnostics builds LEONIDA_AB can switch it live.
  • A per-second line gives the time and count freed.

Measured on an RX 6800 XT (driver 32.0.21045.29003), Ryzen 9 5950X, Series S profile, relay 2, FSR 3.1:

  • In a 35-minute run of normal play, A/B every 8 s, 182 phases in the world, there were only 3 tight episodes.
  • In those, the thread freed about 37 lists and preludes a frame, 25-32 ms of freeing a frame, off the submitting thread.
  • Frames over 100 ms overall were 3.9 % vs 4.3 %: the same, because the episodes were rare in that run.
  • So it removes a real stall when the segment fills, but it does not change average fps.
  • No device removal in any run.

Tests. trim_tests, host::segments and the trim test in list.rs: 9 passed, with and without --features diagnostics. The diag build passes.

AI-assisted.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7291638043 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2670#issuecomment-7291638043). Originally posted by [amujark](https://github.com/amujark) on 2026-11-30T20:54:29Z. --- Added aace3e264: while an aperture segment is tight, the trim this PR adds froze the line of submissions and the title's present for 150-260 ms. **What happened.** `trim_idle()` and `trim_preludes()` ran inline on the submitting thread at the first submission after `segments::tight` turned true. They freed up to ~448 idle host lists and ~112 preludes there, and freeing them is the graphics kernel's time. Two `LEONIDA_TIMELINE` captures showed it: - the line and the title's present stood still for 153 ms and 262 ms; - the stall matched the `tight=true` / `tight=false` pair in the log exactly; - resident memory fell 242-370 MB during it. **The change.** The same objects are taken out under the same locks, by the same decision. Only their drop moves to a thread of its own, `leonida-trim`. It is not the reaper, which can sit in 70-100 ms spans. - If that thread cannot be spawned, they are freed inline as before. - `LEONIDA_TRIM_ASYNC=0` gives the old behaviour. - In diagnostics builds `LEONIDA_AB` can switch it live. - A per-second line gives the time and count freed. **Measured on an RX 6800 XT** (driver 32.0.21045.29003), Ryzen 9 5950X, Series S profile, relay 2, FSR 3.1: - In a 35-minute run of normal play, A/B every 8 s, 182 phases in the world, there were only 3 tight episodes. - In those, the thread freed about 37 lists and preludes a frame, 25-32 ms of freeing a frame, off the submitting thread. - Frames over 100 ms overall were 3.9 % vs 4.3 %: the same, because the episodes were rare in that run. - So it removes a real stall when the segment fills, but it does not change average fps. - No device removal in any run. **Tests.** `trim_tests`, `host::segments` and the trim test in `list.rs`: 9 passed, with and without `--features diagnostics`. The diag build passes. AI-assisted.
merzleckeier commented 2026-12-01 13:43:38 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T13:43:38Z.


Checked the release-thread behavior with a real D3D12 buffer at aace3e264 + 9f27ba2e1. I passed a 64 KiB hardware buffer through let_go_apart and held its destruction behind a channel handshake. With LEONIDA_TRIM_ASYNC=1, the caller returned while the destructor was still held on leonida-trim. With 0, the destructor ran on the caller and it returned only after release. Both arms passed on AMD RADV and RTX 4070 SUPER under Wine 11.22. The seven aperture-policy unit tests passed as well. This isolates ownership and scheduling of the release. Native RDNA2 aperture pressure and frame times remain outside this run.

AI-assisted with OpenAI Codex (GPT-6).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7313077494 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2670#issuecomment-7313077494). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T13:43:38Z. --- Checked the release-thread behavior with a real D3D12 buffer at `aace3e264` + `9f27ba2e1`. I passed a 64 KiB hardware buffer through `let_go_apart` and held its destruction behind a channel handshake. With `LEONIDA_TRIM_ASYNC=1`, the caller returned while the destructor was still held on `leonida-trim`. With `0`, the destructor ran on the caller and it returned only after release. Both arms passed on AMD RADV and RTX 4070 SUPER under Wine 11.22. The seven aperture-policy unit tests passed as well. This isolates ownership and scheduling of the release. Native RDNA2 aperture pressure and frame times remain outside this run. AI-assisted with OpenAI Codex (GPT-6).
KelboLive commented 2026-12-01 14:49:11 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T14:49:11Z.

Review: COMMENTED


Independent check on Windows (Ryzen 9 7950X3D, RTX 4070 Ti SUPER, rustc 1.98.1) at aace3e264.

  • cargo test --locked -p leonida-gpu --lib -- --test-threads=4: 559 passed, 0 failed, 47 ignored; the author's views_are_made_beside_the_heap_and_copied_in failure passes here, so it is not a regression from this PR. Merged onto current main (tree 18cdc655): 641 passed, 0 failed, 59 ignored, merge-tree clean, check_no_game_data and diff --check clean, both launcher scripts parse.
  • The claim holds in the code: landed flights are recycled at once with take_held retired (host.rs:5030-5047, list.rs:398-408, :8599-8606), the aperture is polled at most every 100 ms (segments.rs:115-124), 80/70 hysteresis is enforced with strict > and safe at 0 (:95-101, :149-199), and the 64-list/16-prelude trims fire only while tight (list.rs:353-365, host.rs:1726, :1745).
  • Mutation: removing the ten-point hysteresis reddens it_stays_tight_ten_points_below_the_percent and a_percent_under_ten_does_not_wrap_when_it_was_tight (7 → 5 passed, 2 failed). The guard is covered.

One gap worth closing, because it is the actual fix: the lifetime change has no test that would go red if landed lists were held again. A test that counts a landed flight returning its list to the pool (drop/recycle counter) would cover recycle_landed/take_held, which is the part that stops the aperture filling — the segment polling and hysteresis are well covered by comparison.

As the body says, the device-loss and perf claims are RX 6800 XT-only; this machine cannot reproduce them, and the code-level evidence above is what can be checked without that card.

<!-- greyfinch-sync:ubiquitarianism/leonida:review:6133662449 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2670#pullrequestreview-6133662449). Originally posted by [KelboLive](https://github.com/KelboLive) on 2026-12-01T14:49:11Z. **Review:** COMMENTED --- Independent check on Windows (Ryzen 9 7950X3D, RTX 4070 Ti SUPER, rustc 1.98.1) at `aace3e264`. - `cargo test --locked -p leonida-gpu --lib -- --test-threads=4`: **559 passed, 0 failed, 47 ignored**; the author's `views_are_made_beside_the_heap_and_copied_in` failure passes here, so it is not a regression from this PR. Merged onto current main (tree `18cdc655`): **641 passed, 0 failed, 59 ignored**, `merge-tree` clean, `check_no_game_data` and `diff --check` clean, both launcher scripts parse. - The claim holds in the code: landed flights are recycled at once with `take_held` retired (`host.rs:5030-5047`, `list.rs:398-408`, `:8599-8606`), the aperture is polled at most every 100 ms (`segments.rs:115-124`), 80/70 hysteresis is enforced with strict `>` and safe at 0 (`:95-101`, `:149-199`), and the 64-list/16-prelude trims fire only while tight (`list.rs:353-365`, `host.rs:1726`, `:1745`). - Mutation: removing the ten-point hysteresis reddens `it_stays_tight_ten_points_below_the_percent` and `a_percent_under_ten_does_not_wrap_when_it_was_tight` (7 → 5 passed, 2 failed). The guard is covered. One gap worth closing, because it is the actual fix: **the lifetime change has no test that would go red if landed lists were held again.** A test that counts a landed flight returning its list to the pool (drop/recycle counter) would cover `recycle_landed`/`take_held`, which is the part that stops the aperture filling — the segment polling and hysteresis are well covered by comparison. As the body says, the device-loss and perf claims are RX 6800 XT-only; this machine cannot reproduce them, and the code-level evidence above is what can be checked without that card.
lerapeurdu62280-debug commented 2026-12-01 20:20:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lerapeurdu62280-debug on 2026-12-01T20:20:47Z.


Test report on RDNA 2 (RX 6600 8 GB), PR head aace3e264 merged on top of main locally (rebuilt at 18:41 UTC+1 today, with #2764 / #2828 / #2865 / #2904 from main).

Setup: AMD Radeon RX 6600 8 GB (driver 32.0.21045.29003), Ryzen 5 3600, 32 GB RAM, Windows 11 build 26300. scripts/play-d3d12.ps1 -SeriesS with FSR 3.1, LEONIDA_SUBMIT_FRAMES=0. Retail game data.

What I saw (5 sessions today, about 2 h of play in total, longest 51 min):

Result
host::segments at device creation reads the three segments correctly: id 0 local 8146 MB, id 1 aperture 2048 MB, id 2 aperture 30614 MB
Aperture segment (2048 MB) residency 24–27 MB at the logged points, never close to the 80 % mark
Tight-segment path never entered (no related lines in any log)
Device removed / 0x887A0007 0 in all 5 sessions
Frame times (one 24 min session) 13.6 fps average, median 79 ms, 8.2 % of frames over 100 ms, 2 over 1 s

Relay stage: stage 2 in every session (LEONIDA_RELAY=2 in the settings line, or unset = default; exact=true). Side note: with relay 2 set, the host info line "what shaders wrote is copied back by a thread of its own … (LEONIDA_RELAY=1)" reads as if relay 1 were set, which confused me at first.

Guard off (A/B): same build, same save, LEONIDA_RELAY=2 + LEONIDA_SEGMENT_TIGHT=0, 12 min of play: aperture segment at most 30 MB / 2048 MB, no device removed, 17.3 fps average, 4.3 % of frames over 100 ms.

Reading: on this RX 6600 with current main + this PR, the 2 GB aperture segment never comes close to filling, with or without the guard, and I could not reproduce the device loss. So on this card the guard is harmless but I can't confirm it is what prevents the loss; the other parts of the PR were not turned off in the A/B. A run of plain main without the PR would be the next step if you want one.

AI-assisted (Claude). EI S.O.S INFO LUDO

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7324522166 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2670#issuecomment-7324522166). Originally posted by [lerapeurdu62280-debug](https://github.com/lerapeurdu62280-debug) on 2026-12-01T20:20:47Z. --- Test report on RDNA 2 (RX 6600 8 GB), PR head `aace3e264` merged on top of `main` locally (rebuilt at 18:41 UTC+1 today, with #2764 / #2828 / #2865 / #2904 from main). **Setup:** AMD Radeon RX 6600 8 GB (driver 32.0.21045.29003), Ryzen 5 3600, 32 GB RAM, Windows 11 build 26300. `scripts/play-d3d12.ps1 -SeriesS` with FSR 3.1, `LEONIDA_SUBMIT_FRAMES=0`. Retail game data. **What I saw (5 sessions today, about 2 h of play in total, longest 51 min):** | | Result | |---|---| | `host::segments` at device creation | reads the three segments correctly: id 0 local 8146 MB, **id 1 aperture 2048 MB**, id 2 aperture 30614 MB | | Aperture segment (2048 MB) residency | 24–27 MB at the logged points, never close to the 80 % mark | | Tight-segment path | never entered (no related lines in any log) | | Device removed / `0x887A0007` | **0 in all 5 sessions** | | Frame times (one 24 min session) | 13.6 fps average, median 79 ms, 8.2 % of frames over 100 ms, 2 over 1 s | **Relay stage:** stage 2 in every session (`LEONIDA_RELAY=2` in the settings line, or unset = default; `exact=true`). Side note: with relay 2 set, the `host` info line "what shaders wrote is copied back by a thread of its own … (LEONIDA_RELAY=1)" reads as if relay 1 were set, which confused me at first. **Guard off (A/B):** same build, same save, `LEONIDA_RELAY=2` + `LEONIDA_SEGMENT_TIGHT=0`, 12 min of play: aperture segment at most **30 MB / 2048 MB**, **no device removed**, 17.3 fps average, 4.3 % of frames over 100 ms. **Reading:** on this RX 6600 with current `main` + this PR, the 2 GB aperture segment never comes close to filling, with or without the guard, and I could not reproduce the device loss. So on this card the guard is harmless but I can't confirm it is what prevents the loss; the other parts of the PR were not turned off in the A/B. A run of plain `main` without the PR would be the next step if you want one. AI-assisted (Claude). EI S.O.S INFO LUDO
MoonEyes commented 2026-12-02 11:50:26 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T11:50:26Z.


Closing: this pull request no longer applies to current main (merge conflict in d3d12/crates/leonida-gpu/src/host.rs), and open pull requests that have fallen out of step with main are being closed so the list stays workable. If you still want this change, rebase it on current main and reopen it (or open a new pull request); it will be looked at again.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7344478539 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2670#issuecomment-7344478539). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T11:50:26Z. --- Closing: this pull request no longer applies to current `main` (merge conflict in `d3d12/crates/leonida-gpu/src/host.rs`), and open pull requests that have fallen out of step with `main` are being closed so the list stays workable. If you still want this change, rebase it on current `main` and reopen it (or open a new pull request); it will be looked at again. AI-assisted (Claude Code).
lerapeurdu62280-debug commented 2026-12-02 12:26:14 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lerapeurdu62280-debug on 2026-12-02T12:26:14Z.


@amujark this was closed only for the host.rs conflict, and the fix is still needed on RDNA 2 (my report above: RX 6600 8 GB, about 2 h of play without the device lost at the first heavy scene).

In case it saves you time: I resolved that conflict on 2 December (main's reaper kept, with this PR's recycle_landed and preludes in reserve) on lerapeurdu62280-debug/mandy:notre/2670, based on 2705632c5. It still merges cleanly on today's main (f6dd2242e). Your commits are kept as they are, so you can rebase onto it or take only the resolution, and reopen.

Contribution : EI S.O.S INFO LUDO

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345336708 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2670#issuecomment-7345336708). Originally posted by [lerapeurdu62280-debug](https://github.com/lerapeurdu62280-debug) on 2026-12-02T12:26:14Z. --- @amujark this was closed only for the `host.rs` conflict, and the fix is still needed on RDNA 2 (my report above: RX 6600 8 GB, about 2 h of play without the device lost at the first heavy scene). In case it saves you time: I resolved that conflict on 2 December (main's reaper kept, with this PR's `recycle_landed` and preludes in reserve) on [`lerapeurdu62280-debug/mandy:notre/2670`](https://github.com/lerapeurdu62280-debug/mandy/tree/notre/2670), based on `2705632c5`. It still merges cleanly on today's main (`f6dd2242e`). Your commits are kept as they are, so you can rebase onto it or take only the resolution, and reopen. Contribution : EI S.O.S INFO LUDO

Pull request closed

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!2670
No description provided.