d3d12-gpu: mapped_bytes counts readable pages between unmapped ends #3046

Merged
Kal0s-design merged 1 commit from upstream-pr/3046 into main 2026-12-02 13:45:22 +00:00
Kal0s-design commented 2026-12-02 05:04:55 +00:00 (Migrated from github.com)

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


Claimed in the coordination issue as: D3D12-GPU-MAPPED-BYTES-INTERIOR-PAGES (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7283293483)

What and why

mapped_bytes(at, len) in d3d12/crates/leonida-gpu/src/texture.rs returned 0 as soon as neither the first nor the last page of the range was committed, without looking at the pages between. A streaming texture's first resident level can lie in the middle of its memory, so such a texture counted as not there and was not uploaded until one of its ends was mapped too.

The change: the early return is gone; with the first page not committed the host's regions are walked (one VirtualQuery a region, a few for a texture that is away). A page that is committed but PAGE_GUARD or PAGE_NOACCESS is not counted, since it can't be read.

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

Tested

  • New test texture::title_memory_tests::mapped_bytes_counts_readable_pages_between_unmapped_ends: reserves 8 pages, commits pages 2-3 read/write and page 5 no-access, then asks for 7 pages from an unaligned start. With main's code (8422def75) it fails (left: 0, right: 8192); with the change it gets the two readable pages, and 0 for the unmapped head.
  • 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:5600217894 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3046). Originally posted by [Kal0s-design](https://github.com/Kal0s-design) on 2026-12-02T05:04:55Z. --- Claimed in the coordination issue as: D3D12-GPU-MAPPED-BYTES-INTERIOR-PAGES (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7283293483) ### What and why `mapped_bytes(at, len)` in `d3d12/crates/leonida-gpu/src/texture.rs` returned 0 as soon as neither the first nor the last page of the range was committed, without looking at the pages between. A streaming texture's first resident level can lie in the middle of its memory, so such a texture counted as not there and was not uploaded until one of its ends was mapped too. The change: the early return is gone; with the first page not committed the host's regions are walked (one `VirtualQuery` a region, a few for a texture that is away). A page that is committed but `PAGE_GUARD` or `PAGE_NOACCESS` is not counted, since it can't be read. This ports the `texture.rs` part of TaynanGT's fix from the sibling VIctory tree (TaynanGT/Vice-Tay `af7a9ed`, GPL-3.0), credited as co-author. ### Tested - New test `texture::title_memory_tests::mapped_bytes_counts_readable_pages_between_unmapped_ends`: reserves 8 pages, commits pages 2-3 read/write and page 5 no-access, then asks for 7 pages from an unaligned start. **With `main`'s code (`8422def75`) it fails** (`left: 0, right: 8192`); with the change it gets the two readable pages, and 0 for the unmapped head. - `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:02 +00:00 (Migrated from github.com)

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


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

  • python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/texture.rs: PASS.
  • cargo test -p leonida-gpu --locked --lib mapped_bytes_counts_readable_pages_between_unmapped_ends: 1 passed, 0 failed.
  • 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: mapped_bytes (texture.rs:2876-2936) preserves the fast 64 KiB block walk when committed(at, 1) holds, falls through to the VirtualQuery region walk when the first page is uncommitted so interior resident levels are counted, and excludes PAGE_GUARD | PAGE_NOACCESS.

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

AI-assisted: yes (Antigravity).

<!-- greyfinch-sync:ubiquitarianism/leonida:comment:7338015512 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3046#issuecomment-7338015512). Originally posted by [lixonik](https://github.com/lixonik) on 2026-12-02T07:18:02Z. --- Independent verification on Windows 10 Pro 22H2 (build 19045), NVIDIA GeForce RTX 5070 12 GB (driver `621.40`), MSVC toolchain (`1.98.1`). Head `0f19a0819` merged cleanly onto `main` (`f37c4a87d`). - `python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/texture.rs`: PASS. - `cargo test -p leonida-gpu --locked --lib mapped_bytes_counts_readable_pages_between_unmapped_ends`: **1 passed, 0 failed**. - `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: `mapped_bytes` (`texture.rs:2876-2936`) preserves the fast 64 KiB block walk when `committed(at, 1)` holds, falls through to the `VirtualQuery` region walk when the first page is uncommitted so interior resident levels are counted, and excludes `PAGE_GUARD | PAGE_NOACCESS`. **Verdict: PASS** (unit tests & source review; title not run). AI-assisted: yes (Antigravity).
imShangLi commented 2026-12-02 07:56:30 +00:00 (Migrated from github.com)

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


VERIFY-3046 — 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 shortcut that returned the wrong answer for a streaming texture whose first resident level lies in the middle of its memory, and it also stops counting committed-but-unreadable pages as resident. Both are fixed in mapped_bytes itself, not worked around. The new test fails on the merge base with exactly that mismatch (0 against 8192) and passes with the pull request. No regression: 728 tests on each side, 0 regressions; the only failures are the watch tests that fail on the base too (one of them flaked once in an earlier run — see section 4, where I give the per-side rates).

head 0f19a08194f3322c10a2310ce2d3e04b5db1ac3d ("d3d12-gpu: mapped_bytes counts readable pages between unmapped ends"), base origin/main = 0ae5a2664b9cd2fd30abfb1f6096f1c07b030f39, merge base 8422def759cda12c89f918438eeb8d53dd5972a6 (4 commits behind main). One file, +35/−12: d3d12/crates/leonida-gpu/src/texture.rs.

1. What it changes

texture::mapped_bytes(at: *const u8, len: usize) -> u64 answers "how many bytes of [at, at + len) are committed, readable memory". Its callers (texture.rs:1550, :1592, :2491) use it as "how much of this title texture has arrived" — the number is compared against what was read back to decide whether the texture is fully resident, and it is stored as staging.expected.

The old body had a shortcut and an over-count:

if !committed(at, 1) && !committed((end - 1) as *const u8, 1) {
    return 0;                       // "the answer is none without a look at the pages between"
}
if !by_query() { ... by page or by 64 KiB block ... }
... walk of VirtualQuery regions ...
if info.State == MEM_COMMIT { there += (next - p) as u64; }

The new body:

if !by_query() && committed(at, 1) { ... by page or by 64 KiB block ... }
... walk of VirtualQuery regions ...
if info.State == MEM_COMMIT && info.Protect & (PAGE_GUARD | PAGE_NOACCESS) == 0 { there += (next - p) as u64; }

Two defects, both fixed at the source:

  1. The "neither end is committed ⇒ nothing is committed" shortcut was wrong. A streaming texture's first resident level need not lie at the start of its memory — the smaller mips are mapped first, but the first resident level can be in the middle. In that state neither the first nor the last page of the texture's memory is committed while the pages in between are, and the old code answered 0 for a texture that is partly there. The shortcut is gone; instead the cheap per-block path is used only when the first page of the range really is committed (the case it is valid for), and otherwise the region walk runs and counts what is between. The cost is bounded: one VirtualQuery per region, a few for a texture that is away — which is what the new doc comment says.
  2. A committed but unreadable region was counted as resident. MEM_COMMIT with PAGE_NOACCESS or PAGE_GUARD is not readable memory; the walk counted it. The new condition excludes both. (The PAGE_NOACCESS half matters for the title's own memory: a region can be committed and made inaccessible on purpose.)

2. The new test checks the property that matters

texture::title_memory_tests::mapped_bytes_counts_readable_pages_between_unmapped_ends builds the exact situation the fix is about, with plain Windows memory calls and no GPU device and no game files:

  • VirtualAlloc(8 * PAGE, MEM_RESERVE, PAGE_NOACCESS) — the reservation of a texture's memory whose first and last pages are not committed.
  • VirtualAlloc(base + 2 * PAGE, 2 * PAGE, MEM_COMMIT, PAGE_READWRITE) — two readable pages in the middle: the first resident level.
  • VirtualAlloc(base + 5 * PAGE, PAGE, MEM_COMMIT, PAGE_NOACCESS) — one page committed but not readable.
  • mapped_bytes(base + 19, 7 * PAGE) must be exactly 2 * PAGE (8192): the two readable pages in the middle are counted, the reserved pages at the ends are not, and the committed-but-PAGE_NOACCESS page is not counted as readable.
  • mapped_bytes(base, 2 * PAGE) must be 0: a range that is only reserved reads as nothing.

That is the property the callers depend on — "how much of this texture is really there and readable" — and not an implementation detail of the walk.

The test body really runs here; it is not a "no device ⇒ ok" no-op. I built the red side alone and ran the new test by name under Wine (lane/red_3046.log): the binary reported 1 failed; 727 filtered out with

thread 'texture::title_memory_tests::mapped_bytes_counts_readable_pages_between_unmapped_ends' panicked at crates/leonida-gpu/src/texture.rs:3473:13:
assertion `left == right` failed: the two readable pages in the middle
  left: 0
 right: 8192

i.e. the old shortcut answered 0 where 8192 is the truth, exactly as analysed. The second assertion (the fully reserved range reads as 0) is never reached on the red side — the first one fails first — and passes on the green side, so the test is discriminating the middle-pages property and not merely tripping over the fixture.

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 3046 --crate leonida-gpu (run from /home/shangli/oc-workspace/gta6); the red side is built the way scripts/red_green.py builds it (merge base + only the PR's test hunks), the green side from the PR head, and every test binary of the crate is run under Wine on both sides.

side commit tests new test regressions
red merge base 8422def7 + the PR's test hunks 728 FAILED — "the two readable pages in the middle", 0 against 8192 —
green 0f19a081 (PR head) 728 ok 0

The tool's verdict: "red then green" — red→green 2, regressions 0, 3 failing on both sides, 665 passing on both sides, no test on one side only. The second red→green entry is watch::tests::a_write_opens_the_view_it_goes_through, a watch test that has nothing to do with texture.rs; section 4 shows it fails on the base too.

I also ran the crate's whole suite several times on each side to tell the watch failures from a real regression (numbers in section 4).

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

The three watch tests that 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. Per-side rates I measured (full suite, six runs per side, lane/flake_3046_full.json):

test green 0f19a081 red 8422def7
watch::many_askers_tests::holes_are_known_until_the_runtime_tells 6/6 failed 6/6 failed
watch::many_askers_tests::no_mapping_is_lost_between_askers 6/6 failed 6/6 failed
watch::tests::what_is_left_alone_is_no_known_hole 6/6 failed 6/6 failed
watch::tests::a_block_just_written_rests 1/6 failed 0/6
watch::tests::what_is_put_in_beside_the_guards_is_told_at_every_view 1/6 failed 0/6

A flaky watch test that made an earlier run of the tool report a false regression. The first run of tools/wine_red_green.py 3046 reported the verdict "NOT red-then-green" with one regression, watch::tests::kernel_reads_into_guarded_blocks_after_opening, and one flaky failure, watch::tests::a_range_that_begins_in_an_unmapped_block_is_guarded. The second run of the same command reported 0 regressions. The difference is the flakiness of the watch guard-page tests under Wine, not the change:

  • With the filter watch::tests::, eight runs per side: only what_is_left_alone_is_no_known_hole fails, 8/8 on both sides; a_write_opens_the_view_it_goes_through and kernel_reads_into_guarded_blocks_after_opening pass 8/8 on both sides.
  • With the filter watch (the many_askers tests included), six runs per side: the three always-failing tests fail 6/6 on both sides, and one different test failed once on each side (a_refresh_leaves_open_what_the_kernel_is_writing on green, other_memory_at_a_guarded_address_keeps_its_protection on red).
  • watch::tests::a_write_opens_the_view_it_goes_through is the clearest case: it failed on the red (base) side in both runs of the tool for this pull request, and it failed on the green side in the tool's run for pull request #3005, whose red side is a different commit entirely. A test that fails on the base in one run and on the head in another, with the same code, is flaky, not a regression.

The root of the flakiness is the watch module's guard pages and the exceptions they raise, which behave differently under Wine without a real GPU; nothing in this pull request touches that module.

One thing I noticed while reading, not a failure: the change makes the region walk run in the "the texture is away" case (the first page is not committed) where the old shortcut answered 0 after two cheap questions. The walk costs one VirtualQuery per region and the range of an absent texture is usually one or two regions, so the cost is small — but it is a change in the hot path of a per-texture, per-frame query, and I could not measure it (no GPU, no title).

5. What I did not check

  • No GPU, no game files, no title: mapped_bytes exists to say how much of a streaming title texture has arrived. I could not check that a real streamed texture with its first resident level in the middle is now measured correctly, nor that the upload path reacts to the new number; the test only exercises the function over host memory it allocates itself.
  • No performance measurement: the extra region walk in the "first page not committed" case (the common case for a texture that is away) is not measured here. The author's note that it costs "one query a region, a few for a texture that is away" is a claim I did not measure on a real run.
  • The LEONIDA_COMMITTED_QUERY=1 path (by_query()): with that switch the code now always takes the region walk, where the old code still applied the shortcut. I did not run the suite with that switch set, so the behaviour under it is only checked by reading.
  • The LEONIDA_MAPPED_BY_PAGE=1 path: likewise only read, not run.
  • The crate::inplace::shown_bytes fast path at the top of mapped_bytes: it short-circuits before any of this and is unaffected by the change; I did not exercise it.
  • No Windows build and no MSVC: everything is cargo test --target x86_64-pc-windows-gnu under Wine 11.21 on Fedora 45. VirtualQuery's Protect value for a PAGE_GUARD region and Wine's fidelity for K32QueryWorkingSetEx are the parts most likely to differ from a real Windows run.
  • The attribution in the doc comments ("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:7338802811 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3046#issuecomment-7338802811). Originally posted by [imShangLi](https://github.com/imShangLi) on 2026-12-02T07:56:30Z. --- ## VERIFY-3046 — 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 shortcut that returned the wrong answer for a streaming texture whose first resident level lies in the middle of its memory, and it also stops counting committed-but-unreadable pages as resident. Both are fixed in `mapped_bytes` itself, not worked around. The new test fails on the merge base with exactly that mismatch (`0` against `8192`) and passes with the pull request. No regression: 728 tests on each side, 0 regressions; the only failures are the `watch` tests that fail on the base too (one of them flaked once in an earlier run — see section 4, where I give the per-side rates). head `0f19a08194f3322c10a2310ce2d3e04b5db1ac3d` ("d3d12-gpu: mapped_bytes counts readable pages between unmapped ends"), base `origin/main` = `0ae5a2664b9cd2fd30abfb1f6096f1c07b030f39`, merge base `8422def759cda12c89f918438eeb8d53dd5972a6` (4 commits behind `main`). One file, +35/−12: `d3d12/crates/leonida-gpu/src/texture.rs`. ### 1. What it changes `texture::mapped_bytes(at: *const u8, len: usize) -> u64` answers "how many bytes of `[at, at + len)` are committed, readable memory". Its callers (`texture.rs:1550`, `:1592`, `:2491`) use it as "how much of this title texture has arrived" — the number is compared against what was read back to decide whether the texture is fully resident, and it is stored as `staging.expected`. The old body had a shortcut and an over-count: ```rust if !committed(at, 1) && !committed((end - 1) as *const u8, 1) { return 0; // "the answer is none without a look at the pages between" } if !by_query() { ... by page or by 64 KiB block ... } ... walk of VirtualQuery regions ... if info.State == MEM_COMMIT { there += (next - p) as u64; } ``` The new body: ```rust if !by_query() && committed(at, 1) { ... by page or by 64 KiB block ... } ... walk of VirtualQuery regions ... if info.State == MEM_COMMIT && info.Protect & (PAGE_GUARD | PAGE_NOACCESS) == 0 { there += (next - p) as u64; } ``` Two defects, both fixed at the source: 1. **The "neither end is committed ⇒ nothing is committed" shortcut was wrong.** A streaming texture's first resident level need not lie at the start of its memory — the smaller mips are mapped first, but the first *resident* level can be in the middle. In that state neither the first nor the last page of the texture's memory is committed while the pages in between are, and the old code answered 0 for a texture that is partly there. The shortcut is gone; instead the cheap per-block path is used only when the first page of the range really is committed (the case it is valid for), and otherwise the region walk runs and counts what is between. The cost is bounded: one `VirtualQuery` per region, a few for a texture that is away — which is what the new doc comment says. 2. **A committed but unreadable region was counted as resident.** `MEM_COMMIT` with `PAGE_NOACCESS` or `PAGE_GUARD` is not readable memory; the walk counted it. The new condition excludes both. (The `PAGE_NOACCESS` half matters for the title's own memory: a region can be committed and made inaccessible on purpose.) ### 2. The new test checks the property that matters `texture::title_memory_tests::mapped_bytes_counts_readable_pages_between_unmapped_ends` builds the exact situation the fix is about, with plain Windows memory calls and **no GPU device and no game files**: - `VirtualAlloc(8 * PAGE, MEM_RESERVE, PAGE_NOACCESS)` — the reservation of a texture's memory whose first and last pages are *not* committed. - `VirtualAlloc(base + 2 * PAGE, 2 * PAGE, MEM_COMMIT, PAGE_READWRITE)` — two readable pages in the **middle**: the first resident level. - `VirtualAlloc(base + 5 * PAGE, PAGE, MEM_COMMIT, PAGE_NOACCESS)` — one page committed but **not readable**. - `mapped_bytes(base + 19, 7 * PAGE)` must be exactly `2 * PAGE` (8192): the two readable pages in the middle are counted, the reserved pages at the ends are not, and the committed-but-`PAGE_NOACCESS` page is not counted as readable. - `mapped_bytes(base, 2 * PAGE)` must be 0: a range that is only reserved reads as nothing. That is the property the callers depend on — "how much of this texture is really there and readable" — and not an implementation detail of the walk. **The test body really runs here; it is not a "no device ⇒ ok" no-op.** I built the red side alone and ran the new test by name under Wine (`lane/red_3046.log`): the binary reported `1 failed; 727 filtered out` with ``` thread 'texture::title_memory_tests::mapped_bytes_counts_readable_pages_between_unmapped_ends' panicked at crates/leonida-gpu/src/texture.rs:3473:13: assertion `left == right` failed: the two readable pages in the middle left: 0 right: 8192 ``` i.e. the old shortcut answered 0 where 8192 is the truth, exactly as analysed. The second assertion (the fully reserved range reads as 0) is never reached on the red side — the first one fails first — and passes on the green side, so the test is discriminating the middle-pages property and not merely tripping over the fixture. ### 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 3046 --crate leonida-gpu` (run from `/home/shangli/oc-workspace/gta6`); the red side is built the way `scripts/red_green.py` builds it (merge base + only the PR's test hunks), the green side from the PR head, and every test binary of the crate is run under Wine on both sides. | side | commit | tests | new test | regressions | |---|---|---|---|---| | red | merge base `8422def7` + the PR's test hunks | 728 | **FAILED** — "the two readable pages in the middle", 0 against 8192 | — | | green | `0f19a081` (PR head) | 728 | **ok** | **0** | The tool's verdict: **"red then green"** — red→green 2, regressions 0, 3 failing on both sides, 665 passing on both sides, no test on one side only. The second red→green entry is `watch::tests::a_write_opens_the_view_it_goes_through`, a `watch` test that has nothing to do with `texture.rs`; section 4 shows it fails on the base too. I also ran the crate's whole suite several times on each side to tell the `watch` failures from a real regression (numbers in section 4). ### 4. Any failure I saw and why it is not this PR **The three `watch` tests that 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. Per-side rates I measured (full suite, six runs per side, `lane/flake_3046_full.json`): | test | green `0f19a081` | red `8422def7` | |---|---|---| | `watch::many_askers_tests::holes_are_known_until_the_runtime_tells` | 6/6 failed | 6/6 failed | | `watch::many_askers_tests::no_mapping_is_lost_between_askers` | 6/6 failed | 6/6 failed | | `watch::tests::what_is_left_alone_is_no_known_hole` | 6/6 failed | 6/6 failed | | `watch::tests::a_block_just_written_rests` | 1/6 failed | 0/6 | | `watch::tests::what_is_put_in_beside_the_guards_is_told_at_every_view` | 1/6 failed | 0/6 | **A flaky `watch` test that made an earlier run of the tool report a false regression.** The first run of `tools/wine_red_green.py 3046` reported the verdict "NOT red-then-green" with one regression, `watch::tests::kernel_reads_into_guarded_blocks_after_opening`, and one flaky failure, `watch::tests::a_range_that_begins_in_an_unmapped_block_is_guarded`. The second run of the same command reported 0 regressions. The difference is the flakiness of the `watch` guard-page tests under Wine, not the change: - With the filter `watch::tests::`, eight runs per side: only `what_is_left_alone_is_no_known_hole` fails, 8/8 on **both** sides; `a_write_opens_the_view_it_goes_through` and `kernel_reads_into_guarded_blocks_after_opening` pass 8/8 on both sides. - With the filter `watch` (the `many_askers` tests included), six runs per side: the three always-failing tests fail 6/6 on both sides, and one different test failed once on each side (`a_refresh_leaves_open_what_the_kernel_is_writing` on green, `other_memory_at_a_guarded_address_keeps_its_protection` on red). - `watch::tests::a_write_opens_the_view_it_goes_through` is the clearest case: it failed on the **red** (base) side in both runs of the tool for this pull request, and it failed on the **green** side in the tool's run for pull request #3005, whose red side is a different commit entirely. A test that fails on the base in one run and on the head in another, with the same code, is flaky, not a regression. The root of the flakiness is the `watch` module's guard pages and the exceptions they raise, which behave differently under Wine without a real GPU; nothing in this pull request touches that module. **One thing I noticed while reading, not a failure**: the change makes the region walk run in the "the texture is away" case (the first page is not committed) where the old shortcut answered 0 after two cheap questions. The walk costs one `VirtualQuery` per region and the range of an absent texture is usually one or two regions, so the cost is small — but it is a change in the hot path of a per-texture, per-frame query, and I could not measure it (no GPU, no title). ### 5. What I did not check - **No GPU, no game files, no title**: `mapped_bytes` exists to say how much of a *streaming title texture* has arrived. I could not check that a real streamed texture with its first resident level in the middle is now measured correctly, nor that the upload path reacts to the new number; the test only exercises the function over host memory it allocates itself. - **No performance measurement**: the extra region walk in the "first page not committed" case (the common case for a texture that is away) is not measured here. The author's note that it costs "one query a region, a few for a texture that is away" is a claim I did not measure on a real run. - **The `LEONIDA_COMMITTED_QUERY=1` path** (`by_query()`): with that switch the code now always takes the region walk, where the old code still applied the shortcut. I did not run the suite with that switch set, so the behaviour under it is only checked by reading. - **The `LEONIDA_MAPPED_BY_PAGE=1` path**: likewise only read, not run. - **The `crate::inplace::shown_bytes` fast path** at the top of `mapped_bytes`: it short-circuits before any of this and is unaffected by the change; I did not exercise it. - **No Windows build and no MSVC**: everything is `cargo test --target x86_64-pc-windows-gnu` under Wine 11.21 on Fedora 45. `VirtualQuery`'s `Protect` value for a `PAGE_GUARD` region and Wine's fidelity for `K32QueryWorkingSetEx` are the parts most likely to differ from a real Windows run. - **The attribution in the doc comments** ("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:10 +00:00 (Migrated from github.com)

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


RUN (in game, grouped): this head 0f19a0819 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:7346609387 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3046#issuecomment-7346609387). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T13:16:10Z. --- RUN (in game, grouped): this head `0f19a0819` 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:21:23 +00:00 (Migrated from github.com)

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


Merging. Head 0f19a0819 merges cleanly with main bf7886746 and does not force a rebase of #2566. Checked on head 0f19a0819: 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:7346745581 --> Imported from [ubiquitarianism/leonida](https://github.com/ProjectLeonida/mandy/pull/3046#issuecomment-7346745581). Originally posted by [MoonEyes](https://github.com/MoonEyes) on 2026-12-02T13:21:23Z. --- Merging. Head `0f19a0819` merges cleanly with `main` `bf7886746` and does not force a rebase of #2566. Checked on head 0f19a0819: 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!3046
No description provided.