d3d12-gpu: writes kept for a one-shot bake are compacted, not dropped #3048

Merged
Kal0s-design merged 1 commit from upstream-pr/3048 into main 2026-12-02 13:59:00 +00:00
Kal0s-design commented 2026-12-02 05:07:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T05:07:02Z.


Claimed in the coordination issue as: D3D12-GPU-BAKE-WRITES-KEEP-COVERAGE (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7285079681)

What and why

texture_slots_page_written in d3d12/crates/leonida-gpu/src/descriptor/host.rs keeps the physical-page writes it does not make due in the heap's bake_page_written, for the next one-shot decoration/ped bake. Past 16,384 ranges it dropped the lowest of them (drain after join's sort), so textures written there kept their old bytes through the bake. DirectStorage can finish many batches between two bakes.

The change: the ranges are made fewer with the existing compact (neighbours joined, every changed byte still covered), as the pending texture changes already are, in a small retain_bake_writes. Rebased on #2852 (writes kept per heap).

This ports the bake-writes part of TaynanGT's fix from the sibling VIctory tree (TaynanGT/Vice-Tay af7a9ed, GPL-3.0), credited as co-author.

Tested

  • New test descriptor::host::tests::bake_writes_keep_every_change_across_batches: three batches of 32,768 disjoint ranges each; after every batch at most 16,384 are kept and every changed range is still covered by one. With main's drop in place it fails (batch 0: 16,384 ranges no kept range covers); with the change it passes.
  • cargo test -p leonida-gpu --lib: 669 passed, 0 failed, 59 ignored.
  • cargo clippy -p leonida-gpu --lib --tests: no warning in the changed lines.
  • Windows only, unit tests; the title wasn't run.

GPUs tested: n/a (CPU unit tests)

AI-assisted: yes

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)

🤖 Generated with Claude Code

<!-- greyfinch-sync:ubiquitarianism/leonida:issue:5600241865 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3048). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T05:07:02Z. --- Claimed in the coordination issue as: D3D12-GPU-BAKE-WRITES-KEEP-COVERAGE (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7285079681) ### What and why `texture_slots_page_written` in `d3d12/crates/leonida-gpu/src/descriptor/host.rs` keeps the physical-page writes it does not make due in the heap's `bake_page_written`, for the next one-shot decoration/ped bake. Past 16,384 ranges it dropped the lowest of them (`drain` after `join`'s sort), so textures written there kept their old bytes through the bake. DirectStorage can finish many batches between two bakes. The change: the ranges are made fewer with the existing `compact` (neighbours joined, every changed byte still covered), as the pending texture changes already are, in a small `retain_bake_writes`. Rebased on #2852 (writes kept per heap). This ports the bake-writes part of TaynanGT's fix from the sibling VIctory tree (TaynanGT/Vice-Tay `af7a9ed`, GPL-3.0), credited as co-author. ### Tested - New test `descriptor::host::tests::bake_writes_keep_every_change_across_batches`: three batches of 32,768 disjoint ranges each; after every batch at most 16,384 are kept and every changed range is still covered by one. **With `main`'s drop in place it fails** (`batch 0`: 16,384 ranges no kept range covers); with the change it passes. - `cargo test -p leonida-gpu --lib`: 669 passed, 0 failed, 59 ignored. - `cargo clippy -p leonida-gpu --lib --tests`: no warning in the changed lines. - Windows only, unit tests; the title wasn't run. GPUs tested: n/a (CPU unit tests) AI-assisted: yes ### 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) 🤖 Generated with [Claude Code](https://claude.com/claude-code)
lixonik commented 2026-12-02 07:18:04 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T07:18:04Z.


Independent verification on Windows 10 Pro 22H2 (build 19045), NVIDIA GeForce RTX 5070 12 GB (driver 621.40), MSVC toolchain (1.98.1). Head 2ab0b4b9d merged cleanly onto main (f37c4a87d).

  • python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/descriptor/host.rs: PASS.
  • cargo test -p leonida-gpu --locked --lib bake_writes_keep_every_change_across_batches: 1 passed, 0 failed (6.12 s).
  • cargo test -p leonida-gpu --locked --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws: 668 passed, 0 failed, 59 ignored.
  • cargo clippy -p leonida-gpu --locked --lib --tests: clean (0 new warnings).
  • Source check: retain_bake_writes (descriptor/host.rs:1431-1439) passes 2 * BAKE_MOST to compact (which loops while ranges.len() > most / 2, reducing strictly to <= BAKE_MOST while preserving 100% byte coverage across batches).

Verdict: PASS (unit tests & source review; title not run).

AI-assisted: yes (Antigravity).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7338015929 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3048#issuecomment-7338015929). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T07:18:04Z. --- Independent verification on Windows 10 Pro 22H2 (build 19045), NVIDIA GeForce RTX 5070 12 GB (driver `621.40`), MSVC toolchain (`1.98.1`). Head `2ab0b4b9d` merged cleanly onto `main` (`f37c4a87d`). - `python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/descriptor/host.rs`: PASS. - `cargo test -p leonida-gpu --locked --lib bake_writes_keep_every_change_across_batches`: **1 passed, 0 failed** (6.12 s). - `cargo test -p leonida-gpu --locked --lib -- --skip depth_bounds_pipeline_loads_and_filters_draws`: **668 passed, 0 failed, 59 ignored**. - `cargo clippy -p leonida-gpu --locked --lib --tests`: clean (0 new warnings). - Source check: `retain_bake_writes` (`descriptor/host.rs:1431-1439`) passes `2 * BAKE_MOST` to `compact` (which loops while `ranges.len() > most / 2`, reducing strictly to `<= BAKE_MOST` while preserving 100% byte coverage across batches). **Verdict: PASS** (unit tests & source review; title not run). AI-assisted: yes (Antigravity).
imShangLi commented 2026-12-02 07:56:36 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-02T07:56:36Z.


VERIFY-3048 — Linux, Fedora 45, Rust 1.98.1, cross-compiled for x86_64-pc-windows-gnu, Wine 11.21, no GPU device, no game files

Verdict: PASS. The change removes a silent data loss: past a limit the kept write-ranges were dropped, and the textures written in the dropped ranges kept their old bytes through the next one-shot bake. The fix keeps the same limit and the same bound on the number of ranges, and makes the list fewer (neighbouring ranges merged) instead of shorter, so nothing that was written is forgotten. The new test states exactly that property and passes with the pull request. No regression: the base's 727 tests all still pass with the pull request (0 regressions); the only three failures are the watch tests that fail on the base as well.

head 2ab0b4b9d4b24543dced7351a385b5b4327defb4 ("d3d12-gpu: writes kept for a one-shot bake are compacted, not dropped"), base origin/main = 0ae5a2664b9cd2fd30abfb1f6096f1c07b030f39, merge base 8422def759cda12c89f918438eeb8d53dd5972a6 (4 commits behind main). One file, +46/−10: d3d12/crates/leonida-gpu/src/descriptor/host.rs.

1. What it changes

HostHeap keeps a list of the title-memory ranges that were written behind the guards' back (DirectStorage completions) in bake_page_written: Mutex<Vec<(u64, u64)>>, so that the slots holding those bytes can be woken up right before a one-shot ped/decoration bake draw:

  • texture_slots_page_written (host.rs:3111) takes the frame's ranges and, when the bake is not due yet, keeps them for the bake.
  • texture_slots_bake_written (host.rs:3132) takes the kept ranges, joins them and finds the placed-texture slots that hold bytes of them; those slots are marked changed, so their textures are re-uploaded before the bake draw.

The old way of keeping them (in texture_slots_page_written) was:

kept.extend(ranges);
if kept.len() > 256 {
    join(&mut kept);
    const MOST: usize = 1 << 14;
    if kept.len() > MOST {
        let drop_n = kept.len() - MOST;
        kept.drain(..drop_n);      // <-- the lowest-addressed ranges are dropped
    }
}

join sorts the list by address, so drain(..drop_n) removes the lowest-addressed ranges — the writes that happened to sit at the bottom of the address space — and those writes are then invisible to texture_slots_bake_written: the slot that holds them is not marked changed, and its texture keeps its old bytes through the bake. DirectStorage can finish many batches between two bakes, so the list crosses 16 384 ranges easily (the file's own comment elsewhere says several threads map and write "some 5,000 ranges a frame").

The new code introduces the named limit and one function:

const BAKE_MOST: usize = 1 << 14;

fn retain_bake_writes(kept: &mut Vec<(u64, u64)>, ranges: Vec<(u64, u64)>) {
    kept.extend(ranges);
    if kept.len() > 256 {
        join(kept);
        if kept.len() > BAKE_MOST {
            compact(kept, 2 * BAKE_MOST);   // neighbours merged, nothing dropped
        }
    }
}

compact already existed on main (host.rs:1414) and already had tests (host.rs:7448-7459): it halves the list by merging each pair of neighbours into one range that spans both, until the list is short enough. The limit is unchanged (1 << 14) and so is the bound on the number of ranges (kept.len() <= BAKE_MOST); what changes is that past the limit the list is made smaller (wider ranges) instead of shorter (missing ranges). The trade-off — "a bake looks at a little more memory than changed", so some slots that did not change are marked due — is stated in the new doc comment and is the price of not losing a write.

2. The new test checks the property that matters

descriptor::host::tests::bake_writes_keep_every_change_across_batches states the property in the terms the caller depends on: every range that was written is still covered by some range the bake will look at, and the list stays within its bound. It feeds three batches of 2 * BAKE_MOST = 32 768 non-overlapping ranges (each two bytes long, eight bytes apart, so join cannot merge them), and after each batch asserts:

  • kept.len() <= BAKE_MOST — the bound the old code also had; and
  • lost == 0, where lost counts the changed ranges (s, e) for which no kept range (ks, ke) satisfies ks <= s && e <= ke — i.e. no change is forgotten.

The test is pure logic over Vec<(u64, u64)>: no GPU device, no game files, no title are needed, and it really runs here (it is present in the green binary and is the one test the base does not have).

The red side cannot be built, so I checked the property against the old code directly. The new test calls retain_bake_writes and BAKE_MOST, which the pull request introduces; the red side (merge base + the PR's test hunks) therefore does not compile — the tool reports

error[E0425]: cannot find value `BAKE_MOST` in this scope
error[E0425]: cannot find function `retain_bake_writes` in this scope

That is the expected shape of a red side for a pull request that introduces the function its test exercises (the same thing happens for a test of a new API), and it means the red/green comparison for this pull request is not "the same test, failing then passing" but "the base's tests still pass with the pull request" (section 3). To establish that the new test would fail on the base, I wrote the old expression and the new one side by side in a scratch program (/tmp/opencode/bake_old_vs_new.rs, both functions copied verbatim from the two revisions) and ran the same three batches through both:

old (main):     batch 0: kept 16384, changed 32768, lost 16384
old (main):     batch 1: kept 16384, changed 65536, lost 49152
old (main):     batch 2: kept 16384, changed 98304, lost 81920
new (PR #3048): batch 0: kept 16384, changed 32768, lost 0
new (PR #3048): batch 1: kept 16384, changed 65536, lost 0
new (PR #3048): batch 2: kept 16384, changed 98304, lost 0

So on the base the very first batch already loses half of the writes (16 384 of 32 768 changed ranges are no longer covered by any kept range) and three batches lose 81 920 of 98 304; with the pull request nothing is lost. The new test's two assertions are exactly these two numbers ("no kept range covers" / "kept <= BAKE_MOST"), so the test does fail on the base and passes with the pull request.

3. What the tests do here

I cross-compiled the crate for x86_64-pc-windows-gnu and ran the test binaries under Wine with python3 tools/wine_red_green.py 3048 --crate leonida-gpu (run from /home/shangli/oc-workspace/gta6). The red side does not compile, so the tool falls back to its "merge base vs PR head" mode and reports:

side commit tests new test regressions
red (not buildable with the new test) merge base 8422def7 + the PR's test hunks — compile error (BAKE_MOST, retain_bake_writes not found) —
base 8422def7 727 absent —
green 2ab0b4b9 (PR head) 728 ok 0

The tool's verdict: "no regression against the base" — 0 regressions, 3 failing on both sides, 665 passing on both sides, and 1 test present only on the green side (descriptor::host::tests::bake_writes_keep_every_change_across_batches, the new one).

4. Any failure I saw and why it is not this PR

  • Three watch tests fail on both sides: watch::many_askers_tests::holes_are_known_until_the_runtime_tells, watch::many_askers_tests::no_mapping_is_lost_between_askers, watch::tests::what_is_left_alone_is_no_known_hole. They are in watch.rs, which this pull request does not touch, and they fail identically with the pull request reverted (measured 6/6 failures per side on the base of PR #3046, which has the same merge base). They are environment failures of the guard-page/exception machinery of watch under Wine without a real GPU.
  • The red side does not compile. This is the pull request's own doing (its test uses the function and the constant the pull request adds), not a defect of the change, but it does mean the repository's own red/green harness cannot produce a "fails on main, passes with the pull request" comparison for it; I did that comparison by hand with the scratch program in section 2.
  • One observation, not a failure: texture_slots_bake_written takes the kept ranges and joins them, then looks for the slots that hold bytes of them. With the merged (wider) ranges the bake now marks more slots due than strictly changed — the trade-off the doc comment names. I could not measure how many extra slots that is on a real run (no GPU, no title).
  • Another observation: the new function is called with the mutex guard taken inline (&mut self.bake_page_written.lock().unwrap_or_else(|e| e.into_inner())), which reads a little densely but is the same expression the old code used, and the lock is released at the end of the statement.

5. What I did not check

  • No GPU, no game files, no title: the whole point of the kept ranges is a DirectStorage completion between two bakes in a running title. I could not check that a real streamed texture written in a dropped range now really is re-uploaded before the bake draw, nor how many extra slots the wider ranges make due; the test exercises the pure function over a Vec, not HostHeap.
  • The end-to-end path is not covered by the test: retain_bake_writes is called directly, so the test does not show that texture_slots_page_written keeps the ranges and that texture_slots_bake_written then uses them. The link between the two is the existing code and I only read it.
  • The 2 * BAKE_MOST argument to compact: compact(ranges, most) stops when ranges.len() <= most / 2, so passing 2 * BAKE_MOST stops at BAKE_MOST. That is the only reason the two constants differ by a factor of two, and it is not obvious at the call site; I checked it by reading compact (host.rs:1414-1420) and by the test's own kept.len() <= BAKE_MOST assertion, but I did not add a test for compact with most = 2 * BAKE_MOST itself.
  • No Windows build and no MSVC: everything is cargo test --target x86_64-pc-windows-gnu under Wine 11.21 on Fedora 45; the change is pure logic and does not depend on the platform, but no native Windows run was made.
  • Performance: after a compaction the kept list holds the same number of ranges at most, but each range is wider, so the per-range slot lookup in slots_holding covers more memory than before; not measured.
  • The attribution in the doc comment ("After TaynanGT's fix in TaynanGT/Vice-Tay (af7a9ed)") — I did not fetch that repository or commit and cannot confirm it.
  • The other crates of the workspace and the repository's Python test suite were not run; only leonida-gpu was, because the change is confined to it.
  • The PR's GitHub discussion (comments, review threads, the coordination issue) was not read: I was asked not to touch GitHub.
<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7338805027 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3048#issuecomment-7338805027). Originally posted by [imShangLi](https://github.com/imShangLi) on 2026-12-02T07:56:36Z. --- ## VERIFY-3048 — Linux, Fedora 45, Rust 1.98.1, cross-compiled for x86_64-pc-windows-gnu, Wine 11.21, no GPU device, no game files **Verdict: PASS.** The change removes a silent data loss: past a limit the kept write-ranges were dropped, and the textures written in the dropped ranges kept their old bytes through the next one-shot bake. The fix keeps the same limit and the same bound on the number of ranges, and makes the list *fewer* (neighbouring ranges merged) instead of *shorter*, so nothing that was written is forgotten. The new test states exactly that property and passes with the pull request. No regression: the base's 727 tests all still pass with the pull request (0 regressions); the only three failures are the `watch` tests that fail on the base as well. head `2ab0b4b9d4b24543dced7351a385b5b4327defb4` ("d3d12-gpu: writes kept for a one-shot bake are compacted, not dropped"), base `origin/main` = `0ae5a2664b9cd2fd30abfb1f6096f1c07b030f39`, merge base `8422def759cda12c89f918438eeb8d53dd5972a6` (4 commits behind `main`). One file, +46/−10: `d3d12/crates/leonida-gpu/src/descriptor/host.rs`. ### 1. What it changes `HostHeap` keeps a list of the title-memory ranges that were written behind the guards' back (DirectStorage completions) in `bake_page_written: Mutex<Vec<(u64, u64)>>`, so that the slots holding those bytes can be woken up right before a one-shot ped/decoration bake draw: - `texture_slots_page_written` (host.rs:3111) takes the frame's ranges and, when the bake is not due yet, keeps them for the bake. - `texture_slots_bake_written` (host.rs:3132) takes the kept ranges, joins them and finds the placed-texture slots that hold bytes of them; those slots are marked changed, so their textures are re-uploaded before the bake draw. The old way of keeping them (in `texture_slots_page_written`) was: ```rust kept.extend(ranges); if kept.len() > 256 { join(&mut kept); const MOST: usize = 1 << 14; if kept.len() > MOST { let drop_n = kept.len() - MOST; kept.drain(..drop_n); // <-- the lowest-addressed ranges are dropped } } ``` `join` sorts the list by address, so `drain(..drop_n)` removes the **lowest-addressed** ranges — the writes that happened to sit at the bottom of the address space — and those writes are then invisible to `texture_slots_bake_written`: the slot that holds them is not marked changed, and its texture keeps its old bytes through the bake. DirectStorage can finish many batches between two bakes, so the list crosses 16 384 ranges easily (the file's own comment elsewhere says several threads map and write "some 5,000 ranges a frame"). The new code introduces the named limit and one function: ```rust const BAKE_MOST: usize = 1 << 14; fn retain_bake_writes(kept: &mut Vec<(u64, u64)>, ranges: Vec<(u64, u64)>) { kept.extend(ranges); if kept.len() > 256 { join(kept); if kept.len() > BAKE_MOST { compact(kept, 2 * BAKE_MOST); // neighbours merged, nothing dropped } } } ``` `compact` already existed on `main` (host.rs:1414) and already had tests (host.rs:7448-7459): it halves the list by merging each pair of neighbours into one range that spans both, until the list is short enough. The limit is unchanged (`1 << 14`) and so is the bound on the number of ranges (`kept.len() <= BAKE_MOST`); what changes is that past the limit the list is made *smaller* (wider ranges) instead of *shorter* (missing ranges). The trade-off — "a bake looks at a little more memory than changed", so some slots that did not change are marked due — is stated in the new doc comment and is the price of not losing a write. ### 2. The new test checks the property that matters `descriptor::host::tests::bake_writes_keep_every_change_across_batches` states the property in the terms the caller depends on: **every range that was written is still covered by some range the bake will look at**, and **the list stays within its bound**. It feeds three batches of `2 * BAKE_MOST` = 32 768 non-overlapping ranges (each two bytes long, eight bytes apart, so `join` cannot merge them), and after each batch asserts: - `kept.len() <= BAKE_MOST` — the bound the old code also had; and - `lost == 0`, where `lost` counts the changed ranges `(s, e)` for which no kept range `(ks, ke)` satisfies `ks <= s && e <= ke` — i.e. **no change is forgotten**. The test is pure logic over `Vec<(u64, u64)>`: **no GPU device, no game files, no title** are needed, and it really runs here (it is present in the green binary and is the one test the base does not have). **The red side cannot be built, so I checked the property against the old code directly.** The new test calls `retain_bake_writes` and `BAKE_MOST`, which the pull request introduces; the red side (merge base + the PR's test hunks) therefore does not compile — the tool reports ``` error[E0425]: cannot find value `BAKE_MOST` in this scope error[E0425]: cannot find function `retain_bake_writes` in this scope ``` That is the expected shape of a red side for a pull request that introduces the function its test exercises (the same thing happens for a test of a new API), and it means the red/green comparison for this pull request is not "the same test, failing then passing" but "the base's tests still pass with the pull request" (section 3). To establish that the new test would fail on the base, I wrote the old expression and the new one side by side in a scratch program (`/tmp/opencode/bake_old_vs_new.rs`, both functions copied verbatim from the two revisions) and ran the same three batches through both: ``` old (main): batch 0: kept 16384, changed 32768, lost 16384 old (main): batch 1: kept 16384, changed 65536, lost 49152 old (main): batch 2: kept 16384, changed 98304, lost 81920 new (PR #3048): batch 0: kept 16384, changed 32768, lost 0 new (PR #3048): batch 1: kept 16384, changed 65536, lost 0 new (PR #3048): batch 2: kept 16384, changed 98304, lost 0 ``` So on the base the very first batch already loses half of the writes (16 384 of 32 768 changed ranges are no longer covered by any kept range) and three batches lose 81 920 of 98 304; with the pull request nothing is lost. The new test's two assertions are exactly these two numbers ("no kept range covers" / "kept <= BAKE_MOST"), so the test does fail on the base and passes with the pull request. ### 3. What the tests do here I cross-compiled the crate for `x86_64-pc-windows-gnu` and ran the test binaries under Wine with `python3 tools/wine_red_green.py 3048 --crate leonida-gpu` (run from `/home/shangli/oc-workspace/gta6`). The red side does not compile, so the tool falls back to its "merge base vs PR head" mode and reports: | side | commit | tests | new test | regressions | |---|---|---|---|---| | red (not buildable with the new test) | merge base `8422def7` + the PR's test hunks | — | compile error (`BAKE_MOST`, `retain_bake_writes` not found) | — | | base | `8422def7` | 727 | absent | — | | green | `2ab0b4b9` (PR head) | 728 | **ok** | **0** | The tool's verdict: **"no regression against the base"** — 0 regressions, 3 failing on both sides, 665 passing on both sides, and 1 test present only on the green side (`descriptor::host::tests::bake_writes_keep_every_change_across_batches`, the new one). ### 4. Any failure I saw and why it is not this PR - **Three `watch` tests fail on both sides**: `watch::many_askers_tests::holes_are_known_until_the_runtime_tells`, `watch::many_askers_tests::no_mapping_is_lost_between_askers`, `watch::tests::what_is_left_alone_is_no_known_hole`. They are in `watch.rs`, which this pull request does not touch, and they fail identically with the pull request reverted (measured 6/6 failures per side on the base of PR #3046, which has the same merge base). They are environment failures of the guard-page/exception machinery of `watch` under Wine without a real GPU. - **The red side does not compile.** This is the pull request's own doing (its test uses the function and the constant the pull request adds), not a defect of the change, but it does mean the repository's own red/green harness cannot produce a "fails on main, passes with the pull request" comparison for it; I did that comparison by hand with the scratch program in section 2. - **One observation, not a failure**: `texture_slots_bake_written` takes the kept ranges and `join`s them, then looks for the slots that hold bytes of them. With the merged (wider) ranges the bake now marks more slots due than strictly changed — the trade-off the doc comment names. I could not measure how many extra slots that is on a real run (no GPU, no title). - **Another observation**: the new function is called with the mutex guard taken inline (`&mut self.bake_page_written.lock().unwrap_or_else(|e| e.into_inner())`), which reads a little densely but is the same expression the old code used, and the lock is released at the end of the statement. ### 5. What I did not check - **No GPU, no game files, no title**: the whole point of the kept ranges is a DirectStorage completion between two bakes in a running title. I could not check that a real streamed texture written in a dropped range now really is re-uploaded before the bake draw, nor how many extra slots the wider ranges make due; the test exercises the pure function over a `Vec`, not `HostHeap`. - **The end-to-end path is not covered by the test**: `retain_bake_writes` is called directly, so the test does not show that `texture_slots_page_written` keeps the ranges and that `texture_slots_bake_written` then uses them. The link between the two is the existing code and I only read it. - **The `2 * BAKE_MOST` argument to `compact`**: `compact(ranges, most)` stops when `ranges.len() <= most / 2`, so passing `2 * BAKE_MOST` stops at `BAKE_MOST`. That is the only reason the two constants differ by a factor of two, and it is not obvious at the call site; I checked it by reading `compact` (host.rs:1414-1420) and by the test's own `kept.len() <= BAKE_MOST` assertion, but I did not add a test for `compact` with `most = 2 * BAKE_MOST` itself. - **No Windows build and no MSVC**: everything is `cargo test --target x86_64-pc-windows-gnu` under Wine 11.21 on Fedora 45; the change is pure logic and does not depend on the platform, but no native Windows run was made. - **Performance**: after a compaction the kept list holds the same number of ranges at most, but each range is wider, so the per-range slot lookup in `slots_holding` covers more memory than before; not measured. - **The attribution in the doc comment** ("After TaynanGT's fix in TaynanGT/Vice-Tay (af7a9ed)") — I did not fetch that repository or commit and cannot confirm it. - **The other crates of the workspace** and the repository's Python test suite were not run; only `leonida-gpu` was, because the change is confined to it. - **The PR's GitHub discussion** (comments, review threads, the coordination issue) was not read: I was asked not to touch GitHub.
MoonEyes commented 2026-12-02 13:16:13 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T13:16:13Z.


RUN (in game, grouped): this head 2ab0b4b9d was merged with git merge --no-ff, together with nine other rendering pull requests, onto main f6dd2242e (no conflicts), and the d3d12 layer was rebuilt from that tree (diag profile, with DLSS). RTX 4060 8 GB, driver 610.88, Windows 11; scripts/play-d3d12.ps1 -SeriesS -Resolution 1080 -FrameGen 2, low-memory profile, keyboard-driven entry into the world and a walking route.

  • At least 381 s in the world (time limit 330 s, then the run script stopped the game): no device loss, no unhandled exception, no hang or GPU stall in the log.
  • Rendering 14.7 frames/s median over the last 240 s (a single earlier run with the same launcher options on a different tree: 15.2).
  • Limits: one run, grouped, so a failure would not have named one pull request; the picture was not checked; free RAM was about 1.2 GB during the run.

Heads in this run: #2854 81a6e94a9, #2936 68215ad0b, #2939 561bbc19c, #2997 ef429f923, #3043 915d4d5aa, #3045 cb30a595a, #3046 0f19a0819, #3047 c33e5b48e, #3048 2ab0b4b9d, #3051 856615ce7.

AI-assisted (Claude Code, Claude Opus 5.5)

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7346610759 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3048#issuecomment-7346610759). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T13:16:13Z. --- RUN (in game, grouped): this head `2ab0b4b9d` was merged with `git merge --no-ff`, together with nine other rendering pull requests, onto `main` `f6dd2242e` (no conflicts), and the d3d12 layer was rebuilt from that tree (diag profile, with DLSS). RTX 4060 8 GB, driver 610.88, Windows 11; `scripts/play-d3d12.ps1 -SeriesS -Resolution 1080 -FrameGen 2`, low-memory profile, keyboard-driven entry into the world and a walking route. - At least 381 s in the world (time limit 330 s, then the run script stopped the game): no device loss, no unhandled exception, no hang or GPU stall in the log. - Rendering 14.7 frames/s median over the last 240 s (a single earlier run with the same launcher options on a different tree: 15.2). - Limits: one run, grouped, so a failure would not have named one pull request; the picture was not checked; free RAM was about 1.2 GB during the run. Heads in this run: #2854 81a6e94a9, #2936 68215ad0b, #2939 561bbc19c, #2997 ef429f923, #3043 915d4d5aa, #3045 cb30a595a, #3046 0f19a0819, #3047 c33e5b48e, #3048 2ab0b4b9d, #3051 856615ce7. AI-assisted (Claude Code, Claude Opus 5.5)
MoonEyes commented 2026-12-02 13:22:02 +00:00 (Migrated from github.com)

Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T13:22:02Z.


Merging. Head 2ab0b4b9d merges cleanly with main bf7886746 and does not force a rebase of #2566. Checked on head 2ab0b4b9d: all 6 CI checks green; third-party red/green by imShangLi on this head; an in-game run of at least 381 s with this head merged onto main f6dd2242e (grouped with nine other rendering pull requests, comment above) showed no device loss, no unhandled exception and no hang; item claimed in the coordination issue; author has earlier merged pull requests; conflict-free merge against main. Merged by MoonEyes.

AI-assisted (Claude Code).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7346762412 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3048#issuecomment-7346762412). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T13:22:02Z. --- Merging. Head `2ab0b4b9d` merges cleanly with `main` `bf7886746` and does not force a rebase of #2566. Checked on head 2ab0b4b9d: all 6 CI checks green; third-party red/green by imShangLi on this head; an in-game run of at least 381 s with this head merged onto main f6dd2242e (grouped with nine other rendering pull requests, comment above) showed no device loss, no unhandled exception and no hang; item claimed in the coordination issue; author has earlier merged pull requests; conflict-free merge against main. Merged by MoonEyes. AI-assisted (Claude Code).
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!3048
No description provided.