Repository navigation
d3d12-gpu: physical-page writes reach every view heap's texture pass (D3D12-GPU-PAGE-WRITES-PER-HEAP) - #2852
Kal0s-design wants to merge 1 commit into
Conversation
Writes behind the guards' back (DirectStorage reads into physical pages) were kept in one list, and so were the ones retained for one-shot bakes. The first view heap whose texture pass ran took the whole list, so when the title binds more than one view heap the placed textures of the others kept the bytes from before. The remapped ranges already have a cursor per heap (RemapQueue); the page writes now get the same treatment: a list per view heap that holds placed textures (made at its first placed texture, taken out when the heap goes), and a bake list per heap. After TaynanGT's fix in TaynanGT/Vice-Tay (bc44a9f). Co-Authored-By: TaynanGT <157688638+TaynanGT@users.noreply.github.com> Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Verified on Windows: the crate is green with it, and it adds one test - measured against
So the change is tied to its test and nothing else in the crate moved. Existence control, not mutation: I did not break the view-heap walk to watch a specific test fail. What the crate passing does say, and it is more than usual for a descriptor change: the 600 tests that were already there exercise the host descriptor paths hard, and 97 added lines through What I could not test: what "physical-page writes reach every view heap" means for a title - that needs the game writing through a view it made before the page moved. The unit tests are what I ran. AI-assisted: yes - DeepSeek v4.1 (flash), both arms on the machine above. Written with an AI assistant. |
|
Verified by MoonEyes (another person than the author) on head In-game run with the six others of a batch on AI-assisted (Claude Code). |
|
I tested c4e286f together with #2841 0729d56 on 0ff8a53, Win64 MSVC target under Wine 11.22 on Radeon Raphael (RADV 26.3.1) and RTX 4070 SUPER (620.73.04). The combined stock selection passed on both GPUs. A separate late-view-heap lifecycle check uses real host view heaps and synthetic placed-texture descriptors. Two adjacent writes inside the same texture coalesced per heap. Draining the first heap kept the second heap’s pending range. Dropping that second heap removed its pending entry, and an uploaded view in a newly enrolled heap received only the next write. The isolated test passed on both GPUs with LEONIDA_PAGE_WRITES=slots (scheduled refresh) and with 0 (bake refresh). Removing only the lease-entry deletion in Drop failed that same isolated test at the cleanup assertion. The dropped lease still held the coalesced range. MEASURED with synthetic descriptors. AI-assisted (Codex). |
KelboLive
left a comment
There was a problem hiding this comment.
The per-heap split is right, and the test kills the obvious regression: mutating heaps.values_mut() to .take(1) fails it with left: [] right: [3] at host.rs:7815, and the crate stays 600/0/55. The storage and consumption paths match the description (map at :1024-1026, append/join/compact at :1062-1078, own list at :2921-2927, per-heap bake at :315-319/:2702-2713, registration at the first placed view :3775-3777), and there is no lock inversion: PAGE_WRITTEN is never held while taking placed/textures.
Two gaps:
- The
Dropcleanup has no coverage — deleting theremove(&self.lease_id)body leaves all 600 tests green, because the new test never drops a heap after a write. Either merzleckeier's lifecycle test belongs in this PR, or the cleanup is an untested leak fix; as it stands a future change can leak a dead heap's list forever. - Registration is lazy: a heap's list is created only at its first spanned placed view, so a write arriving before that reaches no list at all. That is benign while the first upload reads title memory later, but the invariant is "from the first placed texture on", not "every write" — the doc comment should say so.
Worth stating in the body: every page write now takes the single global mutex and appends to every live heap, and each list can hold MOST = 1<<18 ranges (~4 MB), so retention and lock work now scale with the number of live heaps where the old single list did not. Also PAGE_WRITES[1] (the compaction stat) now increments per heap, which changes what that counter means.
Merge is clean against current main (383 behind, and main still has the global list, so this is not fixed elsewhere). #2908 overlaps this file but merges cleanly; #2834 conflicts only in d3d12/docs/switches.md.
Claimed in the coordination issue as: D3D12-GPU-PAGE-WRITES-PER-HEAP (#2570 (comment))
What and why
Physical-page writes behind the guards' back (
page_writtenind3d12/crates/leonida-gpu/src/descriptor/host.rs, mostly DirectStorage reads into physical pages) were kept in one list,PAGE_WRITTEN, and the ones retained for one-shot bakes in another,BAKE_PAGE_WRITTEN. The first view heap whose texture pass ran took each list whole. When the title binds more than one view heap, the placed textures of the others kept the bytes from before until something else made their slots due.The remapped ranges already have a cursor per heap (
RemapQueue, from fxceless/victory-fork 42be495). This gives the page writes the same treatment:PAGE_WRITTENbecomes a list per view heap that holds placed textures, keyed by the heap'slease_id. A heap gets its list at its first placed texture, andDrop for HostHeapremoves it.page_writtenappends to every list, with the same joining andcompactas before.bake_page_written);texture_newslooks at the heap's own lists.This ports TaynanGT's fix from the sibling VIctory tree (TaynanGT/Vice-Tay
bc44a9f, GPL-3.0), credited as co-author.Tested
descriptor::host::tests::a_page_write_reaches_each_view_heap: two heaps with an uploaded placed texture at the same address, onepage_written; after each heap's pass both slots are due (and withLEONIDA_PAGE_WRITES=guards, both bakes find them). Onmain(3bf2844a5) it fails: the second heap's slot never becomes due (left: [],right: [3]). With the change it passes, with the defaultLEONIDA_PAGE_WRITESand withguards.cargo test -p leonida-gpu --lib: 600 passed, 0 failed, 55 ignored (main: 599).cargo clippy -p leonida-gpu --lib --tests: no warning in the changed lines.GPUs tested: n/a (unit tests; no game run)
AI-assisted: yes
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed. (n/a: no translator change)🤖 Generated with Claude Code