Repository navigation
GPU: copy title writes under ranges a submission's shaders write - #1322
Conversation
|
Your depth-downsample investigation led to a reproducible neighboring-byte problem in XCL's sparse memory path. The mechanisms differ: XCL records a hash per 64-byte line. A four-byte GPU counter readback used to record the whole line as synchronized, including a CPU-written constant at byte 24 that had never been uploaded. The next dirty scan returned an empty list. In an isolated local XCL patch, a partial readback updates the hash only if that line was clean beforehand. The native D3D12 regression now queues the expected 64-byte upload. A second fixture covers a readback spanning a dirty first line, a full line and a clean trailing line. The sparse test module passed 17 tests, with one timing test ignored. This verifies the lost-upload mechanism in XCL; the identity of its stalled game dispatch is still open. Retail follow-up with only this XCL readback fix added to the previously tested integration build: Player1 input arrived at 47.017 s, assets streamed, and the last positive present sample was 228.288 s. The last captured frame remained dark. No device removal logged; the guest ended with an access violation writing zero at RVA 0x23cf683 after the 258 s sample. The last translated-pipeline counters had 22,659 skipped dispatches. Those counters do not identify the missing producer or a depth-downsample shader. One run on each build, with different account-selection timing. |
|
Thanks @KevinPratap for the exact repro and patch. I verified the corresponding stale-constant failure on exact #185 and #387, including when the CPU update lands after command recording. Their synchronous branches now defer baseline snapshots until CPU refreshes complete (f173d36 and 709647f). The fixed variants preserve both the real GPU write and an independent later CPU write on AMD, NVIDIA and WARP with full GBV. #595 has a distinct lifetime issue because an earlier native submission may still be active during the refresh. The synthetic passes do not yet attribute the title material failure. |
catminou4
left a comment
There was a problem hiding this comment.
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; this is source review plus the PR's own Windows tests.
Title writes landing inside a range this submission's shaders will write are now copied into the shadow and its snapshot (update_busy), so copy_back neither mistakes them for shader writes nor overwrites the title's later writes with stale snapshot bytes. The comment explains the GTA VI 174 MB heap case (depth-downsample reading zero sizes → device removed as hung). The test uses a real MEM_WRITE_WATCH VirtualAlloc range and asserts the title's constant reaches the host copy, the shader's write goes back, and the title's later write survives copy-back. Exactly the right regression coverage. Windows-only.
Shadow::update skipped the ranges an earlier list of the same submission declared as written by shaders, so the title's writes there (constants, sizes) stayed stale in the copy for the whole submission; on an RTX 4050 Laptop a dispatch read its sizes as zeros and looped until the device was removed. A submission waits for the one before it, so none of its shaders has run when it refreshes: update_busy copies the pages the title wrote there since they were taken (Tracked::take), and puts the same bytes into the snapshot writing() took, so copy_back neither takes them for the GPU's nor puts them back over a later title write. Test: title_writes_under_a_busy_range_are_copied fails on main and passes with this. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Rebased onto today's
AI-assisted. |
7a03753 to
ed0dbfd
Compare
Problem
Shadow::updatecopies only the gaps aroundpendingranges: ranges that lists earlier in the same submission declared as written by shaders. The world binds unordered-access views of its whole 174 MB heap, so once one is declared, nothing the title writes anywhere in that heap reaches the host copy for the rest of the submission.Constants the title writes into that heap are then read stale. Seen on an RTX 4050 Laptop (32-lane waves): a depth-downsample compute dispatch read its sizes (1024, 512, 2560, 1440 in title memory) as zeros from the host copy. 1/0 made its loop bounds about 4 billion, and the GPU ran until the device was removed as hung (DRED: the list stopped in that dispatch; the bytes were read from both sides when the device was removed).
Fix
A submission waits for the one before it (
ExecuteCommandLists, then a fence wait), so when a submission refreshes, none of its own shaders have run. Under a pending range, the pages the title wrote are now copied as they are anywhere else (update_busy). The same bytes go into the snapshotwritingtook, socopy_backdoes not take them for a shader's write and does not undo the title's later writes with them.Verified
shadow::tests::title_writes_under_a_busy_range_are_copied(write-watched memory, synthetic data): fails onmain(shadow.update(...) > 0is false, the constant never reaches the copy) and passes with this change. It also checks that a shader's byte still goes back and that a title write made after the refresh is not undone.cargo test -p victory-gpu --release --lib: 52 passed, 1 ignored;cargo clippy -p victory-gpu --all-targets: no new warnings.VICTORY_D3D12_DRED=1): the submission holding that dispatch completes instead of removing the device. The device is still removed later at other dispatches on that card; those are separate.Only
crates/victory-gpu/src/shadow.rschanges.AI-assisted.
🤖 Generated with Claude Code