Repository navigation
Conversation
Translated shaders that use title memory mark every page they write (and every page they miss) with an atomic OR into their list's page bitmap. That bitmap was a shared buffer in system memory, so each of those atomics went over the bus, and the lanes of a pass writing one output region all hit the same few dwords one after another. On an NVIDIA host the title's acceleration-structure build passes (two straight-line compute programs with two root UAVs, dispatched a few thousand times in one list) then ran for seconds and the device was removed with DEVICE_HUNG. The bitmap is now a video-memory buffer: the list clears it (a copy from a shared zero buffer) where it first uses title memory and copies it into a read-back buffer when it is closed (HostList::read_back_at_close), so every run of the list, also a repeated one, starts clear and the CPU reads the marks after the run as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Translated shaders mark each page they write through views ("Write
marks") with an atomic OR into one bitmap. That bitmap was a shared
buffer in CPU-cached system memory, where on an NVIDIA host atomics cost
about 600 times what they cost in video memory (1M ORs to one dword:
18 ms against 0.03 ms), and the lanes of a pass writing one region all
OR the same few dwords.
The bitmap is now a video-memory buffer. A list recorded once and closed
copies it into a mapped read-back buffer and clears it (a copy from
zeros in upload memory); a submission runs that list after its own lists
when one of them binds the bitmap (HostList::marks_views), and the
copy-back reads the marks from the read-back buffer. Lists record
nothing more, and two runs of one list in a submission both leave their
marks. Only the last bit of the bitmap (where marks past it land) is
ignored now, not its whole last dword.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Reviewed — this is a real device-removal fix, not just perf: >2 s marking lists trip TDR, and the 600× atomic-write penalty on a shared-heap buffer explains why. Both bitmaps follow the same sound pattern:
The video-memory |
catminou4
left a comment
There was a problem hiding this comment.
Written-pages bitmap moved to video memory (+438). Static review only: victory-gpu/victory-hle are Windows-only (D3D12/windows-sys); not compiled or tested on this macOS arm64 host. rustc 1.98.1.
|
Verified on the branch (Windows 11, RTX 5070 Laptop GPU, driver 616.87, |
|
Automated triage for the maintainers. Needs rebase. This branch now conflicts with Generated by Claude Code |
Two 256.5 KiB copies, the bitmap into read-back memory and zeros over it, as the video-memory bitmaps of Marvisak#2175 and Marvisak#2465 record at a list's end or after a submission: 12.2 µs on an RTX 5070 Ti (median of 20).
…s, per way of marking (benchmark for Marvisak#2167, Marvisak#2175, Marvisak#2465, Marvisak#2755)
What
Translated shaders mark each 64 KiB page they write through views ("Write marks",
crate::shadow::copy_back_marks) with an atomic OR into one bitmap. That bitmap was a shared buffer in CPU-cached system memory. On an NVIDIA host, atomics there cost about 600 times what they cost in video memory: 1MInterlockedOrto one dword take 18 ms there and 0.03 ms in video memory. The lanes of a pass writing one region all OR the same few dwords.The bitmap now lives in video memory:
shadow::bitmap()makes aDEFAULT-heap UAV buffer (Host::uav_buffer), a mapped read-back buffer (Host::readback_buffer) and an upload buffer of zeros. It also records one list, once, and closes it: a UAV barrier, a copy of the bitmap into the read-back buffer,COPY_SOURCE -> COPY_DEST, and a copy of the zeros over the bitmap.HostList::marks_views, fromdraw.rs).Host::executethen runs that closed list after the submission's lists, andcopy_back_marksreads the marks from the read-back mapping. The CPU no longer clears them.Nothing changes in the translator, so shader cache entries stay valid.
Based on #2175 (
gpu/title-memory-bitmap-in-vram, which did the same for the title memory page bitmaps inmemory.rs). This branch includes its commit, forHost::uav_buffer/Host::readback_bufferand thememory::testsshader helper (nowpub(crate)). Review the second commit only; it rebases trivially once #2175 lands.Verification (Windows 11, NVIDIA RTX 5090)
Live runs on an integration build (this change on top of several open PRs needed to reach the world on a 32-lane host). Diag build, same settings and same 300 s script, averaged over 150–285 s in the world (about 4,900 draws per frame):
GPU and copy-back time are unchanged within noise in this scene. The frame-time difference is in "preparing", the CPU side, which this change does not touch and which varies about as much between runs of identical builds (another build of the same series measured 2.13 fps / 208 ms there). The marks' atomics are evidently not a large share of the GPU time here. With them in video memory they stay cheap where passes mark heavily, as the microbenchmark shows. Stable: no device removal, and world captures look like before.
A first version gave each list its own bitmap (cleared where the list first used it, read back at its end, as #2175 does). It cost about 5 ms more GPU time per frame (an extra barrier inside each list plus two 512 KiB copies per list), so this version uses one bitmap and one fixed list per submission.
cargo clippy -p victory-gpu --all-targets -- -D warnings,cargo clippy -p victory --features diagnostics --all-targets -- -D warnings: cleancargo test -p victory-gpu: 143 passed. Newshadow::tests::view_marks_are_read_back_and_cleared_each_submission: two lists mark from a shader, and both marks are read back; the next submission's read-back holds only its own mark.marked_pages_go_back_by_the_bytes_the_gpu_changednow takes the marks as read back. Two tests fail identically onmainon this host because they assume 2^21 view slots and NVIDIA caps heaps at 1,000,000:memory::tests::lists_share_a_table_and_copies_keep_their_viewsanddescriptor::host::tests::dynamic_slots_are_held_until_released.cargo xtask policy: ok🤖 Generated with Claude Code