D3D12-UPCHECK-TAKE-BLOCKS-TEST: write same 4 KiB block in upcheck undeclared-write test #2936
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2936"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ubiquitarianism/leonida. Originally posted by bobcatchris on 2026-12-01T19:59:41Z.
Claimed in the coordination issue as: D3D12-UPCHECK-TAKE-BLOCKS-TEST (https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7323731674; ref finding https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7320960276)
What and why
host::upcheck::tests::the_check_finds_an_undeclared_write_undone(d3d12/crates/leonida-gpu/src/host/upcheck.rs:911) began failing (left: (false, 0), right: (true, 16)) on both hardware GPUs and WARP afterd920d850denabledLEONIDA_TAKE_BLOCKS(4 KiB dirty-block uploads) by default:(5 << 16) + 512..576(4 KiB block 0 of page 5).(5 << 16) + 9000(4 KiB block 2 of page 5).LEONIDA_TAKE_BLOCKSon,shadow.refreshonly uploads changed 4 KiB blocks (block 2), leaving block 0 untouched on the card (undone = false) and uninspected byupcheck(found = 0).Fix: write the neighbor CPU byte at
(5 << 16) + 1000(inside block 0[0..4096)and disjoint from[512..576)), so block 0 is uploaded and checked under bothLEONIDA_TAKE_BLOCKS=1(default) andLEONIDA_TAKE_BLOCKS=0.Tested
LEONIDA_RELAY=2 LEONIDA_RELAY_COPY=1 LEONIDA_UPCOPY_CHECK=1 cargo test --locked -p leonida-gpu --features diagnostics --lib upcheck::tests::the_check_finds_an_undeclared_write_undone -- --ignored --nocapture:LEONIDA_TAKE_BLOCKS=1, AMD Radeon RX 7900 XTX):FAILED(undone on the card: false; the check found 0 words).LEONIDA_TAKE_BLOCKS=1, AMD Radeon RX 7900 XTX): 1 passed, 0 failed (undone on the card: true; the check found 16 words).LEONIDA_TAKE_BLOCKS=0, AMD Radeon RX 7900 XTX): 1 passed, 0 failed (undone on the card: true; the check found 16 words).LEONIDA_D3D12_WARP=1, defaultLEONIDA_TAKE_BLOCKS=1): 1 passed, 0 failed (undone on the card: true; the check found 16 words).python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/host/upcheck.rs: clean.GPUs tested: AMD Radeon RX 7900 XTX 24 GB (driver 32.0.32029.2010, Windows 11, profile L) and Microsoft Basic Render Driver (WARP, Windows 11).
AI-assisted: yes — Gemini 4 Neon (implementation and an independent read-only reviewer pass).
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-01T20:13:22Z.
Hardware comparison with both dirty upload switches at
68215ad0against99a29d10on RTX 4070 SUPER and Radeon RADV (Wine 11.22 / VKD3D-Proton 3.1.0). I ran the existing ignored test as a fresh process twice per GPU and switch combination. I held the relay/check settings fixed and usedLEONIDA_CARD_BUFFERS_MIN_MB=1so the existing 4 MiB fixture took its GPU-backed path on both adapters.The table reports whether the prior GPU write was overwritten and how many words the diagnostic counted. Both GPUs matched in all 32 processes. The previous cross-block fixture passes when both upload restrictions are disabled. Leaving either restriction enabled is enough for the old fixture to miss the intended overwrite. The PR’s same-block write passes under all four combinations. MEASURED with the existing synthetic fixture. AI-assisted (Codex).
Imported from ubiquitarianism/leonida. Originally posted by KelboLive on 2026-12-01T21:38:04Z.
Review: COMMENTED
Confirmed on an RTX 4070 Ti SUPER: with this PR the test passes (
undone=true, 16 words) under the defaultLEONIDA_TAKE_BLOCKS=1and under=0, and reverting only+1000→+9000on the same code fails withleft: (false, 0). The change is the right fix for a test that assumed a 64 KiB page went up whole —KERNEL_PAGEis 4096 (shadow.rs:2939) andtake_landedsends only noted blocks.One coverage note: moving the write into block 0 means nothing now pins the new cross-block behaviour. An undeclared write in a block the title did not dirty survives the refresh (
undone=false, at-sendfound=0) and is only reported by the at-restlook(). Either add a companion assertion/test for that, or say in the comment that it is expected, so a future granularity change is not mistaken for a regression.Merge is clean. The old test was red on main for exactly this reason, not for an independent off-by-one.
Imported from ubiquitarianism/leonida. Originally posted by imShangLi on 2026-12-02T07:09:33Z.
VERIFY-2936 — 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 pull request is a correction to a test that cannot run here at all — it is
#[ignore]d and wants a device — and I could not execute it, so I checked the arithmetic it depends on instead: the old offset was simply in the wrong 4 KiB block, and the new one is in the right one. It is the right fix. I also found that the harness reported one "red → green" and one "regression" for this pull request, and both are flakywatchtests on code the pull request never touches.Head
68215ad0, base the currentmain(0ae5a266), merge baseab374c7d, 1 file, +5/−3:d3d12/crates/leonida-gpu/src/host/upcheck.rs.1. What it changes
A test in
upcheck.rs,host::upcheck::tests::the_check_finds_an_undeclared_write_undone. Its story: a shader writes a piece through a view nobody declared, and later the title writes another byte of the same place — which makes the whole 4 KiB block go up with title memory's older bytes, and the up-copy check is meant to notice and undo it. The title's byte was written at the wrong offset:The changed lines are all inside
#[cfg(test)] mod tests(which starts at line 759/760 on the base), so the diff is test-only: no production code moves, andgit diffshows nothing outside the doc comment and that one write.2. The new test checks the property that matters
I could not run the changed test: it is annotated
and its first line is
let Some(host) = host() else { return; };— with no device there is no host, so even forcing it with--ignoredit would return at once and reportokwhile having tested nothing. It showsignoredon both sides of the harness. So I checked the property by arithmetic instead, which is decisive here.shadow.rs:2768setsconst KERNEL_PAGE: usize = 4096;, andLEONIDA_TAKE_BLOCKSis on by default —toggled!("LEONIDA_TAKE_BLOCKS")expands toenv var unset, or not "0"(switch.rs:31). When it is on, only the 4 KiB blocks the title changed go up.(5 << 16) + 512+ 9000+ 1000The old write landed two blocks away, so with
LEONIDA_TAKE_BLOCKSon the block carrying the undeclared write was never uploaded, the check never saw it, andundonestayed false while the test assertsassert_eq!((undone, found), (true, 16))— the test was broken. The new write is in the same block as+512, so that block goes up and the check has something to find. The doc-comment change matches: "another byte of the piece" was inaccurate, "the same 4 KiB block" is what the test needs.I also looked for a test that does exercise this and can run, and found
shadow::landing_tests::only_the_blocks_the_title_changed_go_up(not ignored, passing on both sides). It writes toKERNEL_PAGE + 100and4 * KERNEL_PAGE + 4095and asserts the dirty set is exactly[part(1, 2), part(4, 5)]— the two 4 KiB blocks holding the writes, and no more. That is the block-level selection rule the fix relies on, verified by an executable test rather than by my reasoning alone.3. What the tests do here
watch::tests::a_write_is_reported_at_every_checked_view. Not this pull request, see §4.watch::tests::a_view_being_split_leaves_its_pages_unguarded_elsewhere. Not this pull request, see §4.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.host::upcheck::tests::the_check_finds_an_undeclared_write_undone:ignoredon both sides. The test this pull request changes is not part of any of the rows above.So the harness's own "red then green" verdict for this pull request is wrong in both directions, and the pull request's own test is invisible to it.
4. Any failure I saw, and why it is not this pull request
The red and green sides of this pull request contain byte-identical runnable code: the diff is entirely inside
mod tests, so the merge base plus the test hunks and the head differ only in what an ignored test would do. A flake cannot be a regression, but a harness that reads one run each way will happily report one as "red → green" and the other as a "regression".To be sure I ran the head binary's whole suite nine more times. The three
watchfailures were constant in every run, and otherwatchtests flipped from run to run on the same binary —watch::tests::guarded_blocks_in_a_row_are_opened_togetherandwatch::tests::a_write_opens_the_view_it_goes_througheach failed once, and the totals moved between665 passed; 3 failedand664 passed; 4 failedon an identical build. None of them arehost::upcheck, and the pull request's file isupcheck.rs. It is thewatchmodule's tests that are racing each other, not this one.That leaves the three constant
watchfailures. They fail identically on the merge base through the same tool, so they predate the pull request. They are address-space bookkeeping, and they exercise mapping and decommit behaviour that Wine'sVirtualAllocemulation does not reproduce.5. What I did not check
the_check_finds_an_undeclared_write_undoneis#[ignore]d, needsLEONIDA_RELAY=2,LEONIDA_RELAY_COPY=1,LEONIDA_UPCOPY_CHECK=1, a process of its own and a device, and returns early when there is no host. I have not executed it, on either side, in either direction. My case for the fix rests on the 4 KiB block arithmetic above and ononly_the_blocks_the_title_changed_go_updemonstrating the selection rule.LEONIDA_RELAY=2andLEONIDA_RELAY_COPY=1. I did not enable the relay or the copy, so nothing here says what the test does when the relay is switched on rather than assumed to be on by default.host()isNonehere, which is precisely why the ignored test is ignored. Everything I verified is cross-compiled code under Wine.undoneandfoundtake. I argued that the old offset yieldsundone == falseand that the new one lets the check find the 16 words the assertion expects, from howSTALEand the upload path are written — not by watching them. If the lead wants that settled, it needs the relay env and a device, and I do not have either.watchfailures on native Windows. They look like Wine effects, and they are identical on the base, but I have not run this suite outside Wine.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T13:15:59Z.
RUN (in game, grouped): this head
68215ad0bwas merged withgit merge --no-ff, together with nine other rendering pull requests, ontomainf6dd2242e(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.Heads in this run: #2854
81a6e94a9, #293668215ad0b, #2939561bbc19c, #2997ef429f923, #3043915d4d5aa, #3045cb30a595a, #30460f19a0819, #3047c33e5b48e, #30482ab0b4b9d, #3051856615ce7.AI-assisted (Claude Code, Claude Opus 5.5)
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T13:19:53Z.
Merging. Head
68215ad0bmerges cleanly withmainbf7886746and does not force a rebase of #2566. Checked on head68215ad0b: all 6 CI checks green; third-party red/green by merzleckeier (RTX 4070 SUPER and RADV) on this head; an in-game run of at least 381 s with this head merged onto mainf6dd2242e(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).