Repository navigation
d3d12: a write-back's later runs in a tile its faulting copy reopened still go back (RT-WRITEBACK-TILE-REOPEN) - #2468
Conversation
… still go back (RT-WRITEBACK-TILE-REOPEN) ShadowPages::write_back decided page by page, inside its loop, whether a page's GPU result goes back. A copy that faults on another guard (a geometry watch cell) makes the handler reopen the whole 64 KiB tile on the write-back's own thread (reopen_range, under the lock ProjectLeonida#2418 lets it reuse), which clears kClean and kProtected there. The runs after it in the tile then read as written by the title: their GPU results were dropped from a batch already taken off the queue, and the next forward copy put the title's older bytes over them. The decision is now taken for every page of the range before the first copy, into a host-heap vector the tracker keeps. A page the title wrote before the write-back (not guarded and not clean after the asking) is still held, so the title's words win as before. Test: d3d12_title_window_write_back_fault_tile (d3d12_title_va_test --window-writeback-fault-tile), the ProjectLeonida#2418 fault case with a second dispatch on the third page of the tile and a title write on the second. Found by DadaCap's review of ProjectLeonida#2418. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Known limit, for the record: the held decision is taken once per |
lixonik
left a comment
There was a problem hiding this comment.
Reviewed and tested at f380834f9 (merged cleanly onto main ec91d695c).
The fix is clean and minimal: storing held_pages_ in leonida::host_heap::vector avoids process-heap allocation under lock_ (safe against fault-handler deadlock), and d3d12_title_window_write_back_fault_tile reproduces and verifies the exact failure mode.
Coordination note: #2470 touches the same lines in runtime/CMakeLists.txt, runtime/shims/d3d12_vulkan_device.cpp, and runtime/test/d3d12_title_va_test.cpp to batch all ranges per tracker into one write_back() call with a single held_pages snapshot (which also covers the multi-range-in-one-tile limit noted above). Combining #2468's host_heap held_pages_ member and --window-writeback-fault-tile test with #2470's batched write_back() would resolve both together without conflict.
Verified locally on Windows 11 (MSVC 19.44.35230.0, Ninja Release, NVIDIA GeForce RTX 5070, driver 610.88, Vulkan 1.4.341; note VK_LAYER_KHRONOS_validation is not installed locally so Vulkan validation layers did not run):
d3d12_title_window_write_back,d3d12_title_window_write_back_fault,d3d12_title_window_write_back_fault_tile(64/64 words on page 2 returned, title's word on page 1 kept),d3d12_placed_write_back: 4/4 passedscripts/check_no_game_data.pyandgit diff --check: clean
No findings.
AI-assisted.
|
Thanks @lixonik. Agreed on #2470: they fit together (this PR's |
|
Game-run regression A/B for @aslan2142's request. Same build recipe, shader pack, settings and caches in both arms; only this PR differs. AI-assisted (Claude Code, Claude Opus 5.5). |
…ck-same-page-ranges ubiquitarianism#2468 (RT-WRITEBACK-TILE-REOPEN) took write_back's per-page held decision before the copies for one range. This branch takes it for all of a tracker's ranges in one call, so the two are now one snapshot over every range, kept in ubiquitarianism#2468's host-heap member held_pages_ (sized before lock_ is taken). Both tests stay: d3d12_title_window_write_back_fault_tile and d3d12_title_window_write_back_ranges; submit_write takes both va2 and base. Also from lixonik's review: a run whose pages an earlier range already reopened (none still kProtected) skips reopen_locked and its VirtualQuery. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
For anyone following the write-back path: #2470 (RT-TITLE-WRITEBACK-SAME-PAGE-RANGES, 73N1X's finding in #1608) builds on this PR. This PR's per-page |
Item: RT-WRITEBACK-TILE-REOPEN. Depends on: none (follows #2418).
The bug (EVIDENCE: READ IN CODE,
runtime/shims/d3d12_vulkan_device.cppat the base commitf5c3ea2e0):ShadowPages::write_backdecided inside its loop whether each page's GPU result goes back (held(), lines 449-460). When a copy faults on another guard (a geometry watch cell),shadow_write_faultreopens the whole 64 KiB tile and callsreopen_rangeon the writing tracker (line 1534). On the write-back's own thread that runs under the lock #2418 lets it reuse (lines 880-887), and it clearskClean, andkProtectedthroughreopen_locked, across the tile. The later runs in that tile then read as written by the title, so their GPU results are dropped from a batch that is already off the queue, and the next forward copy writes the title's older bytes over them. The #2418 test missed this because it has only one run per tile.The fix: the per-page decision is taken for the whole range before the first copy, into a host-heap vector the tracker keeps (it allocates under
lock_, as the tracker's other containers already do). A page the title wrote before the write-back (not guarded and not clean after the asking) is still held, so the title's words still win.Test:
d3d12_title_window_write_back_fault_tile(d3d12_title_va_test --window-writeback-fault-tile) is the #2418 fault case with a second dispatch on the third page of the tile and a title write on the second page. That gives the write-back three runs: [page 0] faults, [page 1] is the title's and is held, [page 2] must go back. EVIDENCE: MEASURED, 3 runs each:f5c3ea2e0: fails 3/3, 0 of 64 words on page 2 go backOther checks:
d3d12_title_va,d3d12_title_va_shadow,d3d12_geometry_views,d3d12_title_window_cap,d3d12_title_window_write_back,d3d12_title_window_write_back_fault,d3d12_placed_write_backandd3d12_shadow_keep_refill(_off)pass. Of the 208 ctest tests matchingd3d12_|shadow|title|write_watch|geometry, two failed:d3d12_queue_wait_timeouttimed out under-j 4and passes when run alone.d3d12_set_descriptor_heapsalso fails on the base commit without this change, so it is unrelated.check_no_game_data.pyand thetests/test_docs_*checks pass.Touches the slot-133 write-back, which #2464 lists under the performance rewrite: @aslan2142 feel free to fold it into your rewrite instead of merging it.
Found by DadaCap's review.
GPUs tested: profile M, RTX 4070 Laptop 8 GB, NVIDIA 621.40, Windows 11 (unit tests only, no game run).
AI-assisted (Claude Code).
🤖 Generated with Claude Code