Repository navigation
D3D12.X: two-pass mesh stages never bind a memory window at GPU VA 0 - #3052
Raul-Paiva wants to merge 1 commit into
Conversation
|
Edit: the pattern in the last part of this comment does not hold. See the correction: #3052 (comment) I ran this fix in a retail title's 3D world. It does not stop the Tree (local, not pushed)
Setup
Result, the same tree with and without this commit:
With one run each, the difference in play time is within the run-to-run spread I see on this title. A pattern across all my world runs on this stack (the first two were made before
Every VA 0x0 removal I have on this stack happened with those two switches on. The only run without them ran its whole 900 s. That is a correlation from few runs, not a cause. Still, reading the code, two things could fit:
I can open separate issues for those if that's useful. AI use: Claude Code (Claude Opus 5.5) ran the builds and the runs, read the logs and drafted this comment; I checked it against the logs. |
…robes (lab) Two stalls of a retail title's world load, both with locks held that its recording threads need; the title's watchdog ended it after about 30 s without a submit (a write at address 0 at game+0x23cf683), 6 times in about 31 runs. Found with XCL_THREAD_DUMP_AT in the stall. 1. sparse::State::drain_quarantined asked each mark's fence through real::probe_completed, which without XCL_FENCE_DIRECT is the title's hook (fence_get_completed_value): the hook tries ~2 ms for the sparse state's lock, which the caller holds. A mapping call that takes thousands of tiles (XMemMapPhysicalPagesScatter -> map_pages -> unmap_away -> home_again -> sparse::committed -> take_tile) spent that per fence per tile with the page maps and the sparse state held: one thread was in that stack in two dumps 30 s apart, others waited in page_now and on view_mem's lock. It reads the PC's value (real::fence_completed) now; the value is the same. 2. gpu::shader::readable fell back to a VirtualQuery walk for a range with a page out of the working set; the walk sizes the whole region (20-25 ms in a multi-gigabyte block). view_mem::ensure asks it per tile under its lock. A short range (<= 64 pages) is probed a byte a page with ReadProcessMemory instead (XCL_READABLE_PROBE=0: not). Measured, 235 s runs, same switches: gaps without a submit between 110 and 235 s were up to 28 s before (two of six runs with only the second change), 0 s in five of five runs with both; the world's rate starts at 150-160 s instead of 230 s or later. Also: two-pass binds give a window without a buffer window 0's, as bind_abi does (xcl-dev#3052). Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Correction to my comment above: the pattern I posted there does not hold. VA 0x0 removals happen with and without I ran the same tree again (this PR on top, commit 165d3058 locally) with the default memory settings, the same env as the 900 s run that finished cleanly. This env adds no Result:
I then repeated the clean run exactly: the same commit (without this PR and without the local counter), the same env, 900 s. It removed the device after ~204 s of play, with the same So the clean 900 s run was luck. On this tree the VA 0x0 removal comes with or without this PR, with or without the two memory switches, after 150–780 s of play. This PR neither causes it nor fixes it. AI use: Claude Code (Claude Opus 5.5) ran this run, read the log and drafted this correction; I checked it against the log. |
|
A question about the
This PR targets For PRs to
I can do the second if that's what you want. It means a full shader preparation on this machine, so I'd rather ask first. I also added a note to the description: on my setup this path never triggers, because all four windows have a buffer. It is a defensive fix, in line with the same filter that AI use: Claude Code (Claude Opus 5.5) read the check's output and drafted this; I checked it. |
e4f5eeb to
01196a8
Compare
|
Ran the two-pass window binding test at Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), MSVC 14.44.35207, DXC 1.9.2609.5, debug build. The new test passes on a real NVIDIA part: a window whose GPU VA is 0, or that has no buffer, falls back to window 0's buffer in the shared Not tested: a retail title, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data. AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified; no game data was used. |
|
Verified the two-pass window fallback through GPU execution on RTX 5070 / NVIDIA 616.92 at The compute shader loaded one word through each of u2–u5 into a record. The mesh shader independently loaded the same four slots, checked them against that record, and rasterized a scissored triangle. Each row was a fresh process with a completed fence and full 4×4 RGBA32F readback.
The other eight pixels retained the blue clear in both runs. This shows both absent forms reading window 0’s data while the unaffected third slot still reads its own data. The missing windows were modeled. The Dispatch, DispatchMesh, geometry, buffer reads and pixel readbacks were native. This fixture did not reproduce sparse initialization failure, exercise ExecuteIndirect, or establish the cause of a retail device removal. AI use: OpenAI Codex adapted the fixture, ran the controls, and prepared this report. |
01196a8 to
125dc93
Compare
|
Correction to my two comments above: the The PR is now on Written with Claude Code (Claude Opus 5.5). |
125dc93 to
a921739
Compare
prepare_two_pass_stage bound windows 1-3 with `uma_window_va(k).unwrap_or(first)`. uma_window_va returns Some(0) for a window without a buffer on the GPU (real.rs starts every window at 0 and only committed or sparse windows get one), so such a window was bound as a null root UAV. Direct DXIL compute reads every window slot (with_mem_raw_loads), and the two-pass compute pass is one of those shaders, so the read goes to GPU VA 0: a page fault and a device removal. 4a69d80 added the window 0 check (first_window) but not the `!= 0` filter that bind_abi has had since c685e12. amd-dev has the same filter in its two-pass bind (0e19dc1). window_view() now holds the lookup, and both binds use it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
a921739 to
0364b38
Compare
|
Test report for #3052 at head
Retail title, two runs, release build,
Not tested: AMD / wave64. AI use: run and written with Claude Code (Claude Opus 5.5); results checked by me. |
|
Correction to my report above, about the device removal it mentions (0x887a0005, DRED "page fault at GPU VA 0x0", no breadcrumbs): on this machine it was most likely NVIDIA's 512 MB shader-heap limit (#2403), not a bug of
Hardware: NVIDIA GeForce RTX 3090 24 GB (driver 621.24), Intel Core i5-10600K, 32 GB, Windows 11 Home build 26300. Tool and model: Claude Code (Claude Opus 5.5), results checked by me. |
|
No open or merged PR makes the same change. On main, AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human. |
|
merge-check AI-written and posted by Foniass without a human check of each point. |
|
merge-check claim |
|
merge-check |
World runs of a game title on an RTX 3060 Ti lost the device (0x887a0005) after 3 to 5.5 minutes in about half of them. With XCL_DRED both faults were GPU page faults at address 0x0, which DRED placed at "window 10 + 0x0": the window table had an entry whose buffer address was 0, so uma_va_of of an address in that window gave its offset alone as the GPU address, and uma_window_buffer(_gpu) a null buffer. uma_window_va now gives None for such a window and the buffer lookups none for a null buffer, so callers fall back (most bind window 0's address in its place) or skip instead of handing the GPU address 0. This also covers the two-pass stage's window view that xcl-dev#3052 guards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DaZV7vMq866ni7pGnJC2Ew
World runs of a game title on an RTX 3060 Ti lost the device (0x887a0005) after 3 to 5.5 minutes in about half of them. With XCL_DRED both faults were GPU page faults at address 0x0, which DRED placed at "window 10 + 0x0": the window table had an entry whose buffer address was 0, so uma_va_of of an address in that window gave its offset alone as the GPU address, and uma_window_buffer(_gpu) a null buffer. uma_window_va now gives None for such a window and the buffer lookups none for a null buffer, so callers fall back (most bind window 0's address in its place) or skip instead of handing the GPU address 0. This also covers the two-pass stage's window view that xcl-dev#3052 guards. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A two-pass stage (
prepare_two_pass_stage, used by DispatchMesh and ExecuteIndirect(DispatchMesh)) binds the four memory windows as root UAVs u2–u5 withuma_window_va(k).unwrap_or(first).uma_window_vareturnsSome(0)for a window that has no buffer on the GPU. Inreal.rsthe windows start as(0, 0)and only committed or sparse windows get a buffer, so such a window is bound as a null root view.c685e12 added
.filter(|&v| v != 0)to the same lookup inbind_abi, because direct DXIL compute reads every window slot (with_mem_raw_loads). The two-pass compute pass is a direct DXIL compute shader as well, but its bind was left out, so it can read GPU VA 0, which is a page fault and a device removal.This PR moves the lookup into one helper,
window_view, and uses it in both binds.This is a defensive fix. On my setup (3 sparse windows + 1 coherent window), all four windows always have a buffer, so
uma_window_vanever returns 0 there and this path never triggers: the old and the new code bind the same addresses. It matters when a window has no buffer, for example whensparse::initfails or with a layout that has a gap.first_window) but not the!= 0filter for windows 1–3.amd-devalready has the same filter in its own two-pass bind: 0e19dc1 (Recompiler: flatten direct DXIL root-UAV loads for compute #2368).prepare_two_pass_stagenearby, but not this line. Whichever lands second needs a small rebase.What is in it
crates/xcl/src/hle/d3d12x/bind.rs:window_view(window, first): a window's buffer, or window 0's when it has none (Noneor 0);prepare_two_pass_stageandbind_abiuse it;windows_without_a_buffer_take_window_0.Tested
main5b0d5fa (same commands, same machine). The head pushed here is the same change rebased ontomain9dfbe3e without conflicts;main's newer commits also changebind.rs, which the rebase merged. CI passes on this head; the test counts below were measured before that rebase.maind52ff48), the lib tests of the modules this PR touches (hle::d3d12x::bind), release, serial, with the 20 skips: 116 passed, 1 failed, 0 ignored. The failure,bind::tests::gpu_two_pass_indirect_commands_keep_their_own_records(E_INVALIDARG from the driver on this adapter), fails the same way onmaind52ff48.cargo test --release --workspace --no-fail-fast -- --test-threads=4: the lib test binary ends early onmaintoo (exit 0x80004005 aftersparse upload preparation still failed after bounded retries), so the lib was also run alone, serially (--test-threads=1), with--skipfor the 20 tests that end the binary onmain(6list_x, 12sparse, 1texture_upload, 1uma_driver; each passes alone).main5b0d5fa):main: 139 passed, 0 failed, 20 ignored. The failure isgpu_two_pass_cache_e2e::two_pass_driver_cache_reuses_both_passes_and_recovers_corrupt_blobs("releasing the title PSOs releases their two-pass state", 1 vs 0). Run 8 times alone it failed 2 times on this head and 2 times onmain, so it is intermittent there too.main: 2604 passed, 13 failed, 29 ignored. The newwindows_without_a_buffer_take_window_0passes. The 13 failures ofmainfail here too; the 14th,list_x::tests::a_reset_while_the_last_submit_runs_records_on_another_pc_list, passes alone 5/5 on this head and onmain(it failed in the long run onmain0fe06eb as well).main): the wave64 forms (no wave64), three f16/f32 per-lane forms refused by the recompiler, and the heap-window tests (no heap windows).Regression run
scripts/smoke.ps1 -Seconds 120 -Title 'retail title A', release builds of clean trees, one after the other on the machine in Tested, withXCL_DEVICE_TYPE=lockhart XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_WATCH_HOT=0 XCL_DRED=1 XCL_GPU_WAIT_TIMEOUT_MS=60000. The title is left on its own, with no input; the shader cache was warmed by two runs ofmainbefore.main:This PR:
Not tested
page fault at GPU VA 0x0happen during mesh-heavy scenes, but I have not tied one to this bind.WindowKind::Nonegap belowshader_windows(), or sparse windows whensparse::initfails.AI use
🤖 Generated with Claude Code