fix(gpu): by_address leaks its cap and inflates WINDOW_CARD_BYTES #2981

Closed
Luislariosss wants to merge 1 commit from upstream-pr/2981 into main
Luislariosss commented 2026-12-01 22:22:48 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Luislariosss on 2026-12-01T22:22:48Z.


Claimed in the coordination issue as: D3D12-GPU-BY-ADDRESS-ACCOUNTING (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7327718532)

What and why

shadow::by_address() kept the card-memory cap (LEONIDA_MEMORY_CARD_MB) in a function-local USED counter:

  • it was incremented before the allocation and never rolled back when the run went over the cap or when uav_buffer() returned None, so headroom leaked for the rest of the session;
  • it was never decremented when the arena went;
  • every arena, card or PC shared fallback alike, was added to WINDOW_CARD_BYTES, so by-address copies ate LEONIDA_CARD_WINDOWS_MB and the window room card_room_kept() keeps for real windows.

This moves the counter to module scope (BY_ADDRESS_USED), reserves it with fetch_update + checked_add (rollback only when the allocation fails) and releases it on drop. Card::account (CardAccount) picks which counter Drop releases, so a shadow cannot be in two accounting buckets at once. By-address arenas no longer touch WINDOW_CARD_BYTES; BY_ADDRESS_USED is included in live_span_bytes() and card_stats().

Behaviour change, both behind opt-in switches: by-address arenas no longer consume LEONIDA_CARD_WINDOWS_MB nor card_room_kept(), and PC-memory fallbacks drop out of the span and the card stats.

Tested

  • cargo test -p leonida-gpu --offline --lib -- --test-threads=1: 647 passed, 0 failed, 59 ignored.
  • cargo test -p leonida-gpu --offline --lib --features diagnostics -- --test-threads=1: 728 passed, 0 failed, 59 ignored.
  • cargo clippy -p leonida-gpu --all-targets --offline: clean (one pre-existing warning outside this file).

New tests: cap boundary (used + len == most), u64::MAX overflow, rollback, all four CardAccount variants on release and drop; land_tests now balances CARD_BYTES[0]; the shared counter tests take one lock so they can run in parallel.

GPUs tested: n/a (unit tests only; no in-game run).

AI-assisted: yes — implementation and review by coding agents, reviewed by the submitter.

Checklist

  • Based on current main and merges cleanly (rebased on c4ca5761).
  • One topic; follow-up work goes in a new pull request.
  • No game data, keys or decryption.
  • No new translator rule.
<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5595667513 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2981). Originally posted by [Luislariosss](https://github.com/Luislariosss) on 2026-12-01T22:22:48Z. --- Claimed in the coordination issue as: D3D12-GPU-BY-ADDRESS-ACCOUNTING (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7327718532) ### What and why `shadow::by_address()` kept the card-memory cap (`LEONIDA_MEMORY_CARD_MB`) in a function-local `USED` counter: - it was incremented before the allocation and never rolled back when the run went over the cap or when `uav_buffer()` returned `None`, so headroom leaked for the rest of the session; - it was never decremented when the arena went; - every arena, card or PC shared fallback alike, was added to `WINDOW_CARD_BYTES`, so by-address copies ate `LEONIDA_CARD_WINDOWS_MB` and the window room `card_room_kept()` keeps for real windows. This moves the counter to module scope (`BY_ADDRESS_USED`), reserves it with `fetch_update` + `checked_add` (rollback only when the allocation fails) and releases it on drop. `Card::account` (`CardAccount`) picks which counter `Drop` releases, so a shadow cannot be in two accounting buckets at once. By-address arenas no longer touch `WINDOW_CARD_BYTES`; `BY_ADDRESS_USED` is included in `live_span_bytes()` and `card_stats()`. Behaviour change, both behind opt-in switches: by-address arenas no longer consume `LEONIDA_CARD_WINDOWS_MB` nor `card_room_kept()`, and PC-memory fallbacks drop out of the span and the card stats. ### Tested - `cargo test -p leonida-gpu --offline --lib -- --test-threads=1`: 647 passed, 0 failed, 59 ignored. - `cargo test -p leonida-gpu --offline --lib --features diagnostics -- --test-threads=1`: 728 passed, 0 failed, 59 ignored. - `cargo clippy -p leonida-gpu --all-targets --offline`: clean (one pre-existing warning outside this file). New tests: cap boundary (`used + len == most`), `u64::MAX` overflow, rollback, all four `CardAccount` variants on release and drop; `land_tests` now balances `CARD_BYTES[0]`; the shared counter tests take one lock so they can run in parallel. GPUs tested: n/a (unit tests only; no in-game run). AI-assisted: yes — implementation and review by coding agents, reviewed by the submitter. ### Checklist - [x] Based on current `main` and merges cleanly (rebased on `c4ca5761`). - [x] One topic; follow-up work goes in a new pull request. - [x] No game data, keys or decryption. - [x] No new translator rule.
andrew-ai commented 2026-12-01 22:27:27 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by andrew-ai on 2026-12-01T22:27:27Z.


Verified the cap and fallback through by_address() with actual D3D12 allocations on an RTX 5070, driver 616.92, at b020637ac. I set LEONIDA_MEMORY_CARD_MB=1 in a fresh process and requested three 1 MiB arenas backed by distinct synthetic CPU ranges.

The first arena used card memory. The second used the shared fallback while the first was held. Dropping the first returned BY_ADDRESS_USED, live_span_bytes() and card_stats()[8] to zero even with the fallback still live. The third arena then used card memory. Dropping the fallback left all three counters at 1 MiB, and dropping the third returned them to zero. WINDOW_CARD_BYTES stayed zero throughout. I checked the actual CardAccount selected for each allocation and resolved the card name from the D3D12 device LUID.

This covers exact-cap allocation, fallback, and reuse on hardware. The test used small allocations to exercise the configured cap. Codex-assisted for #2570.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7327881562 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2981#issuecomment-7327881562). Originally posted by [andrew-ai](https://github.com/andrew-ai) on 2026-12-01T22:27:27Z. --- Verified the cap and fallback through by_address() with actual D3D12 allocations on an RTX 5070, driver 616.92, at b020637ac. I set LEONIDA_MEMORY_CARD_MB=1 in a fresh process and requested three 1 MiB arenas backed by distinct synthetic CPU ranges. The first arena used card memory. The second used the shared fallback while the first was held. Dropping the first returned BY_ADDRESS_USED, live_span_bytes() and card_stats()[8] to zero even with the fallback still live. The third arena then used card memory. Dropping the fallback left all three counters at 1 MiB, and dropping the third returned them to zero. WINDOW_CARD_BYTES stayed zero throughout. I checked the actual CardAccount selected for each allocation and resolved the card name from the D3D12 device LUID. This covers exact-cap allocation, fallback, and reuse on hardware. The test used small allocations to exercise the configured cap. Codex-assisted for #2570.
merzleckeier commented 2026-12-01 22:31:16 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T22:31:16Z.


Real by-address allocations regain the device heap after dropping the previous allocation.

I called production by_address with LEONIDA_MEMORY_CARD_MB=1 on main c4ca5761 and b020637ac09182f12fe0e8f70e279666e27b3676 integrated with #2975. The tested shadow.rs is identical with #2981 alone, and the D3D12 trees match after merging current main 1abef08d. Three fresh runs per tree and GPU agreed on RTX 4070 SUPER (620.73.4) and AMD Raphael (RADV 26.3.1), with Wine 11.22 and VKD3D-Proton 3.1.0.

Allocation Shader-side heap on main Shader-side heap with #2981
1 MiB at the cap DEFAULT DEFAULT
256 KiB while the first allocation is live CUSTOM L0 CUSTOM L0
1 MiB after both drop CUSTOM L0 DEFAULT
1.25 MiB with no live allocations CUSTOM L0 CUSTOM L0
256 KiB after the oversized allocation drops CUSTOM L0 DEFAULT

With the first two live, main added 1,310,720 bytes to both window and total live-span accounting. The PR added zero window bytes and counted 1,048,576 bytes in the aggregate. Oversized shared fallback added no card bytes on the PR, and all deltas were zero after drops. The three stock by-address tests passed on each GPU.

The test uses actual D3D12 resource heap properties at a small configured cap, with the separate DXGI video-memory budget check satisfied. AI-assisted, independently checked against the raw results.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7327970528 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2981#issuecomment-7327970528). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-01T22:31:16Z. --- Real by-address allocations regain the device heap after dropping the previous allocation. I called production `by_address` with `LEONIDA_MEMORY_CARD_MB=1` on main `c4ca5761` and `b020637ac09182f12fe0e8f70e279666e27b3676` integrated with #2975. The tested `shadow.rs` is identical with #2981 alone, and the D3D12 trees match after merging current main `1abef08d`. Three fresh runs per tree and GPU agreed on RTX 4070 SUPER (620.73.4) and AMD Raphael (RADV 26.3.1), with Wine 11.22 and VKD3D-Proton 3.1.0. | Allocation | Shader-side heap on main | Shader-side heap with #2981 | | --- | --- | --- | | 1 MiB at the cap | DEFAULT | DEFAULT | | 256 KiB while the first allocation is live | CUSTOM L0 | CUSTOM L0 | | 1 MiB after both drop | CUSTOM L0 | DEFAULT | | 1.25 MiB with no live allocations | CUSTOM L0 | CUSTOM L0 | | 256 KiB after the oversized allocation drops | CUSTOM L0 | DEFAULT | With the first two live, main added 1,310,720 bytes to both window and total live-span accounting. The PR added zero window bytes and counted 1,048,576 bytes in the aggregate. Oversized shared fallback added no card bytes on the PR, and all deltas were zero after drops. The three stock by-address tests passed on each GPU. The test uses actual D3D12 resource heap properties at a small configured cap, with the separate DXGI video-memory budget check satisfied. AI-assisted, independently checked against the raw results.
MoonEyes commented 2026-12-02 12:34:03 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:34:03Z.


This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).

Could you, or anyone with a working setup, post a run report on the current head merged onto current main:

  • the head SHA and the main SHA it was merged onto;
  • GPU, driver and OS;
  • at least 300 s in the world after loading;
  • device lost / crashes (count), and rendered fps (median) if you have them;
  • the same run on main alone for comparison, if you can.

Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7345532539 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2981#issuecomment-7345532539). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T12:34:03Z. --- This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists). Could you, or anyone with a working setup, post a run report on the **current head** merged onto current `main`: - the head SHA and the `main` SHA it was merged onto; - GPU, driver and OS; - at least 300 s in the world after loading; - device lost / crashes (count), and rendered fps (median) if you have them; - the same run on `main` alone for comparison, if you can. Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough. AI-assisted (Claude Code).
Kal0s-design commented 2026-12-02 14:41:01 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T14:41:01Z.


Ran natively on Windows 11, head b020637ac merged into current main (69cd4106c, merges cleanly and builds; main gained the ray tracing commits in shadow.rs since this was rebased), on WARP and on one NVIDIA desktop card. The earlier comments covered a few arenas on hardware. This adds the suites on the current merge and two throwaway stress tests (not pushed) that call the real by_address() thousands of times, including from 8 threads at once.

Suites on the merge

Run Result
cargo test -p leonida-gpu --lib (default features), WARP 699 passed, 0 failed, 59 ignored
cargo test -p leonida-gpu --lib --features diagnostics, WARP 779 passed, 1 failed
same, NVIDIA card 776 passed, 4 failed
by_address tests, WARP and NVIDIA 5/5 pass
cargo clippy -p leonida-gpu --all-targets --features diagnostics no warnings in shadow.rs

The failures are unrelated to this PR. Two texture ahead tests passed when rerun alone. timeline::report::tests::real_waits_are_recorded_with_who_ended_them and frame::tests::waits_end_on_ticks_and_count_frames failed when rerun alone, and they fail the same way on main alone on this machine right now. The merge only changes shadow.rs.

Stress through the real by_address(), LEONIDA_MEMORY_CARD_MB=8, each test alone in its own process, 2 runs each on WARP and NVIDIA

Test Card / PC fallback / None Peak BY_ADDRESS_USED Counters after dropping everything
3,000 sequential allocations of mixed sizes (256 KiB, 1 MiB, cap minus 64 KiB, 9 MiB over the cap alone), up to 12 held, random drops 2,156 / 844 / 0 (every run) exactly 8 MiB, never above all zero
8 threads x 300 allocations of 1 MiB, each held for 0-2 of its own later cycles WARP 1,404-1,432 / 968-996 / 0; NVIDIA 889-900 / 1,500-1,511 / 0 exactly 8 MiB, never above all zero

What I checked after each allocation and at the end: BY_ADDRESS_USED, WINDOW_CARD_BYTES, CARD_BYTES[0], LIVE, live_span_bytes() and card_stats()[8].

  • The cap held exactly under contention. The fetch_update reservation never let concurrent threads overshoot. At most 8 card-side 1 MiB arenas were live at once, a lower bound I counted from the test side.
  • WINDOW_CARD_BYTES stayed at 0 for the whole run, card and fallback alike.
  • Allocations over the cap went to the PC fallback without touching the counter, and later small ones got card memory again. So headroom is not lost across 3,000 cycles.
  • Every counter went back to 0 after the drops, with no underflow, on both adapters.
  • In the sequential test the four counters agreed mid-run (5,505,024 bytes in BY_ADDRESS_USED, live_span_bytes() and card_stats()[8] with 12 arenas held).

Paths I looked at in the code

  • Rollback: the reservation is only undone when uav_buffer returns None. If the staging shared_buffer fails, that happens before the reservation. If the fallback shared_buffer fails, no reservation is held. I could not make uav_buffer fail on demand, so this path is covered only by the PR's unit test with a closure.
  • Replace: nothing in the crate swaps or takes a Card out of a live Shadow (card is set once, at creation), so release happens only in Drop.
  • The PR's CounterGuard writes the three counters back to their starting values on drop. A leak inside those tests would therefore be wiped before the next test sees it. The stress tests above don't reset anything.

Overlap with #3139

Both PRs edit shadow.rs, and they conflict when merged together (5 hunks). Three hunks are only the two new test modules at the end of the file. The other two are real: #3139 moves the buffer and window copy construction out of the table locks and rewrites both Card { .. } literals there, without this PR's account field. Whichever lands second has to add account: CardAccount::Buffer (buffer copy) and account: CardAccount::Window (window). Otherwise it won't compile, and Drop would release from the wrong counter. I did not resolve or build the combination.

Not checked: the in-game run requested above; the combination with #3139; a real uav_buffer failure; the debug layer.

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

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7348961590 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2981#issuecomment-7348961590). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T14:41:01Z. --- Ran natively on Windows 11, head `b020637ac` merged into current `main` (`69cd4106c`, merges cleanly and builds; `main` gained the ray tracing commits in `shadow.rs` since this was rebased), on WARP and on one NVIDIA desktop card. The earlier comments covered a few arenas on hardware. This adds the suites on the current merge and two throwaway stress tests (not pushed) that call the real `by_address()` thousands of times, including from 8 threads at once. **Suites on the merge** | Run | Result | | --- | --- | | `cargo test -p leonida-gpu --lib` (default features), WARP | 699 passed, 0 failed, 59 ignored | | `cargo test -p leonida-gpu --lib --features diagnostics`, WARP | 779 passed, 1 failed | | same, NVIDIA card | 776 passed, 4 failed | | `by_address` tests, WARP and NVIDIA | 5/5 pass | | `cargo clippy -p leonida-gpu --all-targets --features diagnostics` | no warnings in `shadow.rs` | The failures are unrelated to this PR. Two texture `ahead` tests passed when rerun alone. `timeline::report::tests::real_waits_are_recorded_with_who_ended_them` and `frame::tests::waits_end_on_ticks_and_count_frames` failed when rerun alone, and they fail the same way on `main` alone on this machine right now. The merge only changes `shadow.rs`. **Stress through the real `by_address()`, `LEONIDA_MEMORY_CARD_MB=8`, each test alone in its own process, 2 runs each on WARP and NVIDIA** | Test | Card / PC fallback / `None` | Peak `BY_ADDRESS_USED` | Counters after dropping everything | | --- | --- | --- | --- | | 3,000 sequential allocations of mixed sizes (256 KiB, 1 MiB, cap minus 64 KiB, 9 MiB over the cap alone), up to 12 held, random drops | 2,156 / 844 / 0 (every run) | exactly 8 MiB, never above | all zero | | 8 threads x 300 allocations of 1 MiB, each held for 0-2 of its own later cycles | WARP 1,404-1,432 / 968-996 / 0; NVIDIA 889-900 / 1,500-1,511 / 0 | exactly 8 MiB, never above | all zero | What I checked after each allocation and at the end: `BY_ADDRESS_USED`, `WINDOW_CARD_BYTES`, `CARD_BYTES[0]`, `LIVE`, `live_span_bytes()` and `card_stats()[8]`. - The cap held exactly under contention. The `fetch_update` reservation never let concurrent threads overshoot. At most 8 card-side 1 MiB arenas were live at once, a lower bound I counted from the test side. - `WINDOW_CARD_BYTES` stayed at 0 for the whole run, card and fallback alike. - Allocations over the cap went to the PC fallback without touching the counter, and later small ones got card memory again. So headroom is not lost across 3,000 cycles. - Every counter went back to 0 after the drops, with no underflow, on both adapters. - In the sequential test the four counters agreed mid-run (5,505,024 bytes in `BY_ADDRESS_USED`, `live_span_bytes()` and `card_stats()[8]` with 12 arenas held). **Paths I looked at in the code** - Rollback: the reservation is only undone when `uav_buffer` returns `None`. If the staging `shared_buffer` fails, that happens before the reservation. If the fallback `shared_buffer` fails, no reservation is held. I could not make `uav_buffer` fail on demand, so this path is covered only by the PR's unit test with a closure. - Replace: nothing in the crate swaps or takes a `Card` out of a live `Shadow` (`card` is set once, at creation), so release happens only in `Drop`. - The PR's `CounterGuard` writes the three counters back to their starting values on drop. A leak inside those tests would therefore be wiped before the next test sees it. The stress tests above don't reset anything. **Overlap with #3139** Both PRs edit `shadow.rs`, and they conflict when merged together (5 hunks). Three hunks are only the two new test modules at the end of the file. The other two are real: #3139 moves the buffer and window copy construction out of the table locks and rewrites both `Card { .. }` literals there, without this PR's `account` field. Whichever lands second has to add `account: CardAccount::Buffer` (buffer copy) and `account: CardAccount::Window` (window). Otherwise it won't compile, and `Drop` would release from the wrong counter. I did not resolve or build the combination. Not checked: the in-game run requested above; the combination with #3139; a real `uav_buffer` failure; the debug layer. GPUs tested: one NVIDIA desktop card + WARP. AI-assisted: yes (Claude Code).
MoonEyes commented 2026-12-02 18:00:45 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:00:45Z.


Triage of head b020637ac (merge base c4ca57615, 329 commits behind; git merge-tree against current main 45dc41f95: no conflicts).

1 file: d3d12/crates/leonida-gpu/src/shadow.rs (+297/-25).

CI is at action_required on this head (fork workflow approval).

Existing verification: Verified on this head with real D3D12 allocations by @andrew-ai (RTX 5070), @merzleckeier, and natively by @Kal0s-design on 69cd4106c (WARP and an NVIDIA card).

This check: Not re-reviewed in depth. It merges cleanly both with main and with #3163, the other open shadow.rs change (merge-tree of the two heads: no conflict), so the order between them does not matter textually; a combined test run after the first lands would be prudent since both touch shadow.rs.

I did not build it: the crate is Windows-only (or the C++ runtime's Windows build), so no red/green was run here.

Verdict: ready (verified three times on this head; needs CI approval).

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


Generated by Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7353859232 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2981#issuecomment-7353859232). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T18:00:45Z. --- **Triage of head `b020637ac` (merge base `c4ca57615`, 329 commits behind; `git merge-tree` against current `main` `45dc41f95`: no conflicts).** 1 file: `d3d12/crates/leonida-gpu/src/shadow.rs` (+297/-25). CI is at `action_required` on this head (fork workflow approval). **Existing verification:** Verified on this head with real D3D12 allocations by @andrew-ai (RTX 5070), @merzleckeier, and natively by @Kal0s-design on `69cd4106c` (WARP and an NVIDIA card). **This check:** Not re-reviewed in depth. It merges cleanly both with `main` and with #3163, the other open `shadow.rs` change (`merge-tree` of the two heads: no conflict), so the order between them does not matter textually; a combined test run after the first lands would be prudent since both touch `shadow.rs`. I did not build it: the crate is Windows-only (or the C++ runtime's Windows build), so no red/green was run here. **Verdict: ready** (verified three times on this head; needs CI approval). AI-assisted verification: Claude Opus (Claude Code), separate agent per batch. --- _Generated by [Claude Code](https://claude.ai/code)_
fiestorra commented 2026-12-03 05:20:54 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-03T05:20:54Z.


VERIFY-2981 — 69 tests de shadow pasan, y el cambio es un contador que se quedaba alto

d3d12/crates/leonida-gpu/src/shadow.rs   1 file changed, 297 insertions(+), 25 deletions(-)
cargo test -p leonida-gpu --lib shadow    69 passed; 2 ignored

El título: «by_address leaks its cap and inflates WINDOW_CARD_BYT…» — o sea, una tabla cuyo límite de capacidad se pierde y un contador que crece de más.

Y es el mismo género que cinco PRs de esta noche: #3003, #2994, #2946, #2947, #2587 — estado que se libera mal. La diferencia es que este no es un HANDLE: es una capacidad — un número que decide cuánto se reserva y que, si sólo crece, convierte una tabla acotada en una que nunca encoge.

Por qué importa y por qué es difícil de ver: un contador que se queda alto no rompe nada — no hay un crash, no hay un test rojo, sólo una asignación que crece con el tiempo. En un juego de sesiones largas es el tipo de fuga que se nota a la hora y se atribuye a otra cosa. Y 297 líneas en un fichero para arreglarlo sugiere que el autor tuvo que instrumentar la tabla antes de poder verlo.

Lo que verifiqué: 69 tests de shadow en verde con el cambio.
Lo que no: la fuga de verdad — necesita una sesión con el juego cargando y descargando sombras durante horas, y ese es precisamente el caso que ningún test de 1,4 segundos ejerce. Si el autor midió el contador con el título y tiene el número antes/después, ese número vale más que los 69 tests juntos, y no está en el comentario de la PR.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7368641602 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2981#issuecomment-7368641602). Originally posted by [fiestorra](https://github.com/fiestorra) on 2026-12-03T05:20:54Z. --- ## VERIFY-2981 — 69 tests de `shadow` pasan, y el cambio es un contador que se quedaba alto ``` d3d12/crates/leonida-gpu/src/shadow.rs 1 file changed, 297 insertions(+), 25 deletions(-) cargo test -p leonida-gpu --lib shadow 69 passed; 2 ignored ``` **El título**: **«`by_address` leaks its cap and inflates `WINDOW_CARD_BYT…`»** — **o sea, una tabla cuyo límite de capacidad se pierde y un contador que crece de más.** **Y es el mismo género que cinco PRs de esta noche**: **`#3003`, `#2994`, `#2946`, `#2947`, `#2587`** — **estado que se libera mal.** **La diferencia es que este no es un `HANDLE`: es una **capacidad** — un número que decide cuánto se reserva y que, si sólo crece, convierte una tabla acotada en una que nunca encoge.** **Por qué importa y por qué es difícil de ver**: **un contador que se queda alto no rompe nada** — **no hay un crash, no hay un test rojo, sólo una asignación que crece con el tiempo.** **En un juego de sesiones largas es el tipo de fuga que se nota a la hora y se atribuye a otra cosa.** **Y 297 líneas en un fichero para arreglarlo sugiere que el autor tuvo que instrumentar la tabla antes de poder verlo.** **Lo que verifiqué**: **69 tests de `shadow` en verde con el cambio.** **Lo que no**: **la fuga de verdad** — **necesita una sesión con el juego cargando y descargando sombras durante horas, y ese es precisamente el caso que ningún test de 1,4 segundos ejerce.** **Si el autor midió el contador con el título y tiene el número antes/después, ese número vale más que los 69 tests juntos, y no está en el comentario de la PR.**
EdenBendheim commented 2026-12-03 10:16:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by EdenBendheim on 2026-12-03T10:16:13Z.


RTX 3090 exact-head compatibility report — Series S/title RT passed (one completed run per arm).

PR head b020637ac09182f12fe0e8f70e279666e27b3676 was merged locally onto main d9b618f10150f275c30088e4769c1acbf1d8d689, producing bb356fc5c8145354d32b0e00fffff4e6f3a4212f (tree 1e4d92f002a63d795c624d98ad2333e6b9a234f0). Nothing was pushed or merged upstream. Existing claim: D3D12-GPU-BY-ADDRESS-ACCOUNTING.

Machine/recipe: Windows 11 Home build 26200, Ryzen 9 5900X, 32 GiB RAM, RTX 3090 24 GiB, NVIDIA 610.88. Rust 1.98.1; diag build with diagnostics,dlss,mimalloc. Stock game gate and prepared local freeroam/idle driver; -SeriesS -RayTracing -NoFrameGen -NoPrecompile, 1920×1080 output, LEONIDA_MEMORY_CARD_MB=128. Separate processes, identical 10-file pipeline seeds (1,882,183,380 bytes), shared warm shader cache; the later arm inherits driver-cache warmth. Existing glyph files were used. Native control and destination readback were verified. A supported timed native teleport at 300 seconds after launch recovered placement after loading.

Measured result Main only Main + #2981
World time 302.302 s 300.830 s
Gate / actual exit PASS / 0 PASS / 0
Reported device losses / abnormal exits 0 / 0 0 / 0
Median / p5 rendered FPS 12.57 / 4.06 12.55 / 3.93
Frame p95 / p99 246.30 / 501.85 ms 254.65 / 548.97 ms
Longest in-world present gap 4.350 s 4.518 s
Median draws/frame 5,925 4,957
Peak / end private memory 27,975 / 27,975 MiB 29,573 / 29,544 MiB
Minimum system commit headroom 1,811 MiB 542 MiB
Peak VRAM / budget 6,878 / 23,558 MiB 7,876 / 23,558 MiB
Peak shared GPU memory 9,409 MiB 9,840 MiB
Peak by-address arenas 19 21

FPS uses present intervals from world+60 seconds until the target stop (2,236 / 2,152 intervals). Both processes suspended and saved their caches cleanly. Hard-fault telemetry was unavailable.

Placement scope: Loading overwrote the candidate's first placement; the timed second teleport restored it. The final consecutive near-target suffix was 19 / 20 marks, at most 0.3 / 0.2 m from the destination, covering 188.134 / 195.749 seconds from the first such mark to stop. The 300-second world durations include time before final placement; this is not a claim of 300 seconds continuously at the destination.

Accounting mechanism: Real title structure-builder/by-address activity was observed. Final samples were 17,420 / 20,260 pages (1,088 / 1,266 MiB) in 19 / 21 arenas. The source uses 64 MiB arenas and a 16 MiB directory: the configured 128 MiB card cap permits the directory plus one arena, while total arena demand exceeded it. This exercises by-address allocation with cap pressure and fallback demand. Per-resource heap/account selection and hardware drop/reuse transitions were not instrumented; no claim of hardware cap reuse is made. The unit tests cover the cap boundary, overflow, rollback and release accounting.

Verification: Serial shadow:: diagnostics tests: 69 passed, 2 ignored, including all three by-address accounting tests. Both locked/offline builds, clean-room scan and diff check passed. Independent read-only source review found no production blocker; a separate agent recomputed the reported numbers from private evidence. The pre-existing dirty submodule was preserved.

Earlier attempts retained: Main-only Series X/title RT exited 0xC0000409 after 61.346 world seconds, with 138 MiB last/minimum sampled commit headroom and no reported device loss; the cause was not established. A Series S main placement-recovery attempt was deliberately stopped after 99.680 world seconds (clean exit 0) when loading moved it off route. Neither is counted as a pass. This report establishes the completed Series S compatibility passes, not Series X stability or a speed/memory improvement: one pair, different draw workloads and loading/camera behavior prevent attribution.

Executable SHA-256:

  • Main: e044c701e9876d2087e3f14dadf7f9427adaca4120c627d7ea6a53fb5926290a
  • Candidate: a88e9671315b2376855dd456f3c756a8da6dbddc02e1275f36cbfba224cfc163

CI on this head still has three workflows awaiting maintainer approval. No game content, logs, screenshots or machine-local paths are attached.

AI-assisted testing/source integration: GPT-6.1 Sol (high reasoning). Independent read-only source and numerical review: GPT-6.2 Sol.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7374987975 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2981#issuecomment-7374987975). Originally posted by [EdenBendheim](https://github.com/EdenBendheim) on 2026-12-03T10:16:13Z. --- **RTX 3090 exact-head compatibility report — Series S/title RT passed (one completed run per arm).** PR head `b020637ac09182f12fe0e8f70e279666e27b3676` was merged locally onto main `d9b618f10150f275c30088e4769c1acbf1d8d689`, producing `bb356fc5c8145354d32b0e00fffff4e6f3a4212f` (tree `1e4d92f002a63d795c624d98ad2333e6b9a234f0`). Nothing was pushed or merged upstream. Existing claim: D3D12-GPU-BY-ADDRESS-ACCOUNTING. **Machine/recipe:** Windows 11 Home build 26200, Ryzen 9 5900X, 32 GiB RAM, RTX 3090 24 GiB, NVIDIA 610.88. Rust 1.98.1; diag build with `diagnostics,dlss,mimalloc`. Stock game gate and prepared local freeroam/idle driver; `-SeriesS -RayTracing -NoFrameGen -NoPrecompile`, 1920×1080 output, `LEONIDA_MEMORY_CARD_MB=128`. Separate processes, identical 10-file pipeline seeds (1,882,183,380 bytes), shared warm shader cache; the later arm inherits driver-cache warmth. Existing glyph files were used. Native control and destination readback were verified. A supported timed native teleport at 300 seconds after launch recovered placement after loading. | Measured result | Main only | Main + #2981 | |---|---:|---:| | World time | 302.302 s | 300.830 s | | Gate / actual exit | PASS / 0 | PASS / 0 | | Reported device losses / abnormal exits | 0 / 0 | 0 / 0 | | Median / p5 rendered FPS | 12.57 / 4.06 | 12.55 / 3.93 | | Frame p95 / p99 | 246.30 / 501.85 ms | 254.65 / 548.97 ms | | Longest in-world present gap | 4.350 s | 4.518 s | | Median draws/frame | 5,925 | 4,957 | | Peak / end private memory | 27,975 / 27,975 MiB | 29,573 / 29,544 MiB | | Minimum system commit headroom | 1,811 MiB | 542 MiB | | Peak VRAM / budget | 6,878 / 23,558 MiB | 7,876 / 23,558 MiB | | Peak shared GPU memory | 9,409 MiB | 9,840 MiB | | Peak by-address arenas | 19 | 21 | FPS uses present intervals from world+60 seconds until the target stop (2,236 / 2,152 intervals). Both processes suspended and saved their caches cleanly. Hard-fault telemetry was unavailable. **Placement scope:** Loading overwrote the candidate's first placement; the timed second teleport restored it. The final consecutive near-target suffix was 19 / 20 marks, at most 0.3 / 0.2 m from the destination, covering 188.134 / 195.749 seconds from the first such mark to stop. The 300-second world durations include time before final placement; this is not a claim of 300 seconds continuously at the destination. **Accounting mechanism:** Real title structure-builder/by-address activity was observed. Final samples were 17,420 / 20,260 pages (1,088 / 1,266 MiB) in 19 / 21 arenas. The source uses 64 MiB arenas and a 16 MiB directory: the configured 128 MiB card cap permits the directory plus one arena, while total arena demand exceeded it. This exercises by-address allocation with cap pressure and fallback demand. Per-resource heap/account selection and hardware drop/reuse transitions were not instrumented; **no claim of hardware cap reuse** is made. The unit tests cover the cap boundary, overflow, rollback and release accounting. **Verification:** Serial `shadow::` diagnostics tests: 69 passed, 2 ignored, including all three by-address accounting tests. Both locked/offline builds, clean-room scan and diff check passed. Independent read-only source review found no production blocker; a separate agent recomputed the reported numbers from private evidence. The pre-existing dirty submodule was preserved. **Earlier attempts retained:** Main-only Series X/title RT exited `0xC0000409` after 61.346 world seconds, with 138 MiB last/minimum sampled commit headroom and no reported device loss; the cause was not established. A Series S main placement-recovery attempt was deliberately stopped after 99.680 world seconds (clean exit 0) when loading moved it off route. Neither is counted as a pass. This report establishes the completed Series S compatibility passes, not Series X stability or a speed/memory improvement: one pair, different draw workloads and loading/camera behavior prevent attribution. Executable SHA-256: - Main: `e044c701e9876d2087e3f14dadf7f9427adaca4120c627d7ea6a53fb5926290a` - Candidate: `a88e9671315b2376855dd456f3c756a8da6dbddc02e1275f36cbfba224cfc163` CI on this head still has three workflows awaiting maintainer approval. No game content, logs, screenshots or machine-local paths are attached. AI-assisted testing/source integration: GPT-6.1 Sol (high reasoning). Independent read-only source and numerical review: GPT-6.2 Sol.
merzleckeier commented 2026-12-03 10:22:47 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T10:22:47Z.


Combined check with #3163 on current main d9b618f10. Exact heads b020637ac and f063f5b33 merge without conflicts in either order and yield the same tree (e7ebf93ca986). git diff --check passed.

The combined leonida-gpu diagnostics build passed the shadow:: suite on Wine 11.22 with vkd3d-proton 3.1.0 and AMD Radeon Graphics (RADV 26.3.1). 71 passed, 0 failed, 2 ignored. This includes the PC-memory copy-back regression from #3163. I reran the drop-accounting test with a local test-only change that makes missing D3D12 initialization or a failed buffer allocation fail the test. All four accounting cases ran and passed.

This used synthetic unit tests with no game data. AI-assisted combined verification.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7375146829 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2981#issuecomment-7375146829). Originally posted by [merzleckeier](https://github.com/merzleckeier) on 2026-12-03T10:22:47Z. --- Combined check with #3163 on current `main` `d9b618f10`. Exact heads `b020637ac` and `f063f5b33` merge without conflicts in either order and yield the same tree (`e7ebf93ca986`). `git diff --check` passed. The combined `leonida-gpu` diagnostics build passed the `shadow::` suite on Wine 11.22 with vkd3d-proton 3.1.0 and AMD Radeon Graphics (RADV 26.3.1). **71 passed, 0 failed, 2 ignored.** This includes the PC-memory copy-back regression from #3163. I reran the drop-accounting test with a local test-only change that makes missing D3D12 initialization or a failed buffer allocation fail the test. All four accounting cases ran and passed. This used synthetic unit tests with no game data. AI-assisted combined verification.
Luislariosss commented 2026-12-03 17:58:44 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Luislariosss on 2026-12-03T17:58:44Z.


Paused to free the one open pull request an account without write access may have, for the image work on this host. The branch stays as it is; the change was verified on hardware by two reviewers above.

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7387389823 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/2981#issuecomment-7387389823). Originally posted by [Luislariosss](https://github.com/Luislariosss) on 2026-12-03T17:58:44Z. --- Paused to free the one open pull request an account without write access may have, for the image work on this host. The branch stays as it is; the change was verified on hardware by two reviewers above.

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