d3d12: a write-back's later runs in a tile its faulting copy reopened still go back (RT-WRITEBACK-TILE-REOPEN) #2468
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs rebase
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!2468
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2468"
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?
@OreoFR on GitHub · 2026-11-27 13:41 UTC · original
OreoFR:rt-writeback-tile-reopen→main· +48 −9 · 3 files · 1 commits · merged 2026-11-27 16:01 UTCItem: 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
@OreoFR on GitHub · 2026-11-27 13:42 UTC · original
Known limit, for the record: the held decision is taken once per
write_backcall. If one batch has two separate ranges in the same 64 KiB tile and the first one's copy faults, the second call still sees that tile as title-written. Not covered by this PR or its test. EVIDENCE: READ IN CODE.@lixonik on GitHub · 2026-11-27 15:20 UTC · original · reviewed
Reviewed and tested at
f380834f9(merged cleanly ontomainec91d695c).The fix is clean and minimal: storing
held_pages_inleonida::host_heap::vectoravoids process-heap allocation underlock_(safe against fault-handler deadlock), andd3d12_title_window_write_back_fault_tilereproduces and verifies the exact failure mode.Coordination note:
#2470touches the same lines inruntime/CMakeLists.txt,runtime/shims/d3d12_vulkan_device.cpp, andruntime/test/d3d12_title_va_test.cppto batch all ranges per tracker into onewrite_back()call with a singleheld_pagessnapshot (which also covers the multi-range-in-one-tile limit noted above). Combining#2468'shost_heapheld_pages_member and--window-writeback-fault-tiletest with#2470's batchedwrite_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_validationis 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: cleanNo findings.
AI-assisted.
@OreoFR on GitHub · 2026-11-27 15:22 UTC · original
Thanks @lixonik. Agreed on #2470: they fit together (this PR's
host_heapheld_pages_member and tile-fault test, #2470's onewrite_back()per tracker). Whichever lands second, I'll rebase this one onto it and keep both tests. A game-run regression A/B (mainec91d695cvs + this PR, RTX 4070 Laptop 8 GB) is queued and will be posted here as RUN blocks. AI-assisted (Claude Code, Claude Opus 5.5).@OreoFR on GitHub · 2026-11-27 15:56 UTC · original
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).
@Tyrannys on GitHub · 2026-11-27 16:08 UTC · original
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
heldsnapshot, taken before the copies, was the right fix for the tile reopen. #2470 takes the same snapshot across all of a tracker's finished ranges in onewrite_backcall, because disjoint ranges on one guarded page were still handed over one call at a time, and the first range that differed reopened the page for the rest. #2470 keeps this PR'sheld_pages_member and its--window-writeback-fault-tiletest as they are. Thanks @OreoFR. AI-assisted (Claude Code).