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>
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; source review of the diff.
Title memory page bitmaps in video memory — bitmap placement change; check readback paths still work.
|
Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present, so the hardware-only shader checks run. I merged this PR's head AI-assisted (Claude Code); no game data. |
What
Translated shaders that use title memory mark each page they write (and each page they miss) with an atomic OR into their list's page bitmap (
crate::memory). The bitmap was a shared buffer in system memory, so every one of those atomics crossed the bus, and the lanes of a pass writing one output region all hit the same few bitmap dwords one after another.The bitmap now lives in video memory:
memory::bindmakes aDEFAULT-heap UAV buffer, records a clear in the list (aCopyBufferRegionfrom one shared zeroed upload buffer, thenCOPY_DEST -> UNORDERED_ACCESS), and asks for it to be read back.HostList::read_back_at_close(new): atclose(), the list copies the bitmap into a mapped read-back buffer (UNORDERED_ACCESS -> COPY_SOURCE,CopyBufferRegion).defer_missed/defer_afterread the marks from the read-back mapping as before. Because the clear and the copy are recorded in the list, a closed list that runs again starts with a clear bitmap too.Host::uav_buffer/Host::readback_bufferare small helpers for the two buffers.Per list that uses title memory, that adds two 256 KiB copies on the GPU. Nothing changes in the translator (shader cache entries stay valid).
Why
On an NVIDIA host the title's acceleration-structure build passes use title memory: two straight-line compute programs with two root UAVs, dispatched a few thousand times in one list. With the bitmap in system memory that list ran for seconds and the device was removed with
DXGI_ERROR_DEVICE_HUNG. DRED stopped in those dispatches in every run, with no page fault reported. This matches the hangs reported in #294 for programs with two raw root UAVs. Their code has no loops that could spin: the only loops are bounded by a byte, a popcount or 4.Verification (Windows 11, NVIDIA RTX 5090)
On an integration build (this branch + a few open PRs needed to reach the world on a 32-lane host), diag build,
VICTORY_D3D12_DRED=1, with and withoutVICTORY_GPU_TIMING=1:GPU_TIMING), and in every runNot fixed here: 1.86 s of that remaining 1.87 s is a single 2-group dispatch of another build program (most likely a loop running to the 2^20 limit). A later list also stops at an
ExecuteIndirect(with the stopping program skipped, the next one at the same position stops instead), and that one is still open.cargo clippy -p victory-gpu --all-targets -- -D warnings,cargo clippy -p victory --features diagnostics --all-targets -- -D warnings: cleancargo test -p victory-gpu: 77 passed. Newmemory::tests::marked_pages_go_back_after_each_run(a shader writes title memory through the page table and marks its page; the page goes back after the first run and again after a second run of the same closed list). Two tests fail identically onmainon this host:memory::tests::lists_share_a_table_and_copies_keep_their_viewsanddescriptor::host::tests::dynamic_slots_are_held_until_released(both assume a view heap of 2^21 slots, and NVIDIA caps them at 1,000,000).cargo xtask policy: okRelated
memory::bind. It conflicts with this PR textually; with the bitmap in video memory, the pool would holdDEFAULT+ read-back pairs instead.🤖 Generated with Claude Code