D3D12.X: two-pass mesh stages never bind a memory window at GPU VA 0 #3052
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3052"
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?
Imported from ivall/xcl. Originally posted by Raul-Paiva on 2026-11-27T18:02:22Z.
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.c685e122added.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.4a69d806("two-pass binds take window 0 as bind_abi does"). That commit added the window 0 check (first_window) but not the!= 0filter for windows 1–3.amd-devalready has the same filter in its own two-pass bind:0e19dc1d(#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
main5b0d5fa3(same commands, same machine). The head pushed here is the same change rebased ontomain9dfbe3eawithout 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.a9217399(the same change onmaind52ff48c), 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 onmaind52ff48c.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).main5b0d5fa3):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 onmain0fe06eb0as 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
Imported from ivall/xcl. Originally posted by Raul-Paiva on 2026-11-27T18:14:54Z.
Edit: the pattern in the last part of this comment does not hold. See the correction: https://github.com/xcl-dev/xcl/pull/3052#issuecomment-7226795118
I ran this fix in a retail title's 3D world. It does not stop the
page fault at GPU VA 0x0removals I get there. The fix is still correct, but those removals have another cause. The data is below in case it helps with #2920.Tree (local, not pushed)
nvidia-dev3f39671d, plus #27943c4891dd, #2905d900644d, #2967f058e4ea, #281542ae6051, #28169ae803e3, #2817a2c10b4a, and #684's change cherry-picked.bind.rs: a counter of skipped draws by call site. It is logging only.Setup
XCL_DEVICE_TYPE=lockhart XCL_TEXTURE_LEVEL_PAGES=1 XCL_SPARSE_LAZY=1 XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_WATCH_HOT=0 XCL_DRED=1 XCL_GPU_WAIT_TIMEOUT_MS=60000 XCL_TWO_PASS_MB=1024 XCL_DEPTH_UAV_TWIN=1.Result, the same tree with and without this commit:
page fault at GPU VA 0x0; allocations there: []DRED: no breadcrumbs (no list was in flight)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
nvidia-dev3f39671dwas merged in; runs of 600–900 s):XCL_TEXTURE_LEVEL_PAGES=1 XCL_SPARSE_LAZY=1(includes the run with this PR)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:
vram.rsunmap_rangecallsUpdateTileMappings(NULL)without waiting for the title's queues.XCL_SPARSE_LAZY,give_memoryruns withforce = false, so GPU writes into lazy tiles that have no memory yet are lost.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.
Imported from ivall/xcl. Originally posted by Raul-Paiva on 2026-11-27T19:42:40Z.
Correction to my comment above: the pattern I posted there does not hold. VA 0x0 removals happen with and without
XCL_TEXTURE_LEVEL_PAGES/XCL_SPARSE_LAZY, so please disregard the two code suspects I listed.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
XCL_TWO_PASS_MBand noXCL_DEPTH_UAV_TWIN:XCL_DEVICE_TYPE=lockhart XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_WATCH_HOT=0 XCL_DRED=1 XCL_GPU_WAIT_TIMEOUT_MS=60000. It was a 900 s run with A pressed every 5 s, on the same hardware.Result:
DRED page fault at GPU VA 0x0; allocations there: []; recently freed: []andDRED: no breadcrumbs (no list was in flight).XCL_TWO_PASS_MB).The only thing I can still tell apart is that the clean run was made beforeEdit: that was wrong. The clean run was built after that merge, on the same commit as this PR's parent (2b0aaa66 locally).nvidia-dev3f39671dwas merged into my stack.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
DRED page fault at GPU VA 0x0andno breadcrumbs (no list was in flight). Peak commit was 35 GB.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.
Imported from ivall/xcl. Originally posted by Raul-Paiva on 2026-11-27T20:49:22Z.
A question about the
PR descriptioncheck. It fails on this PR with:This PR targets
nvidia-dev, so I made the comparison run onnvidia-devd1be8103, the PR's base. That commit is not onmain.For PRs to
nvidia-dev, which do you prefer?maincommit as well, to satisfy the check as it is.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
amd-devgot in0e19dc1d.AI use: Claude Code (Claude Opus 5.5) read the check's output and drafted this; I checked it.
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-28T14:12:00Z.
Ran the two-pass window binding test at
01196a8fon an NVIDIA Blackwell desktop part: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
window_viewhelper used by both the ABI and two-pass binds. This is a CPU-side assertion of the address choice; it does not exercise a title's two-pass DispatchMesh or a real page fault. The thread has discussion about VA 0 removals but no RTX 5070 Ti datapoint yet.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.
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-28T19:49:52Z.
Verified the two-pass window fallback through GPU execution on RTX 5070 / NVIDIA 616.92 at
01196a8f. A test-only fixture supplied controlled lookup results toprepare_two_pass_stageand used the productionemit_two_pass_stagefor both compute and mesh. Valid window addresses referred to separate, aligned regions of a real GPU buffer. Before recording either pass, the fixture verified that all six emitted root addresses were nonzero and that each window resolved to its expected address.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.
Some(0)for 1, valid 2,Nonefor 3The 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.
Imported from ivall/xcl. Originally posted by Raul-Paiva on 2026-11-30T00:29:24Z.
Correction to my two comments above: the
page fault at GPU VA 0x0lines I quoted should not be read as GPU page faults at VA 0. In every one of those logs DRED reported device state 0 (UNKNOWN), empty allocation lists (allocations there: []; recently freed: []) and no list in flight. That is what DRED gives when it recorded no fault, though as Prime1997 pointed out on #3119 it does not rule one out. So those removals tell nothing about this PR, for or against; #3119 changes the log so it no longer reads as a fault at VA 0.The PR is now on
main(rebased onto53e85fb1, head125dc93f). The two-pass bind there still usesuma_window_va(k).unwrap_or(first), so the fix still applies. The full suite againstmainis in the description (no new failure); the smoke runs onmainand on this head are still to come.Written with Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by AAsobu on 2026-11-30T19:22:19Z.
Test report for #3052 at head
0364b388c60719f24e9043321f2c162e87a4ef5dmainff0c364b3de011c13ed45865480c21918a79ec89: clean (merge commitce1d0b13),git diff --checkclean.cargo build --workspace: ok.cargo test --workspace --no-fail-fast -- --test-threads=4: 2890 passed, 0 failed, 51 ignored.hle::d3d12x::bind::tests::windows_without_a_buffer_take_window_0passes.d3d12SDKLayers.dll, 1 noGPU_UPLOADheaps.crates/xcl/src/hle/d3d12x/bind.rs): no findings.Retail title, two runs, release build,
XCL_PREPARE=0 XCL_DIRECT_DXIL=1 XCL_PSO_WAIT_MS=1000 XCL_TEXTURE_LEVEL_PAGES=1 XCL_HUGE_PSO_CONCURRENCY=4 XCL_HUGE_PSO_WANTED_CONCURRENCY=4 XCL_DXC_THREADS=4 XCL_NETWORK=0 XCL_DRED=1:0x887a0005) at 816 s, about 130 s into the world, DRED page fault at GPU VA 0x0, allocations there[], no breadcrumbs (no list in flight). System commit at the removal: 57.3 of 66.2 GB.recorded lastlists mostly two-passExecuteIndirect(DispatchMesh)by count, but the last 24 operations in order are mainly computeDispatch/ExecuteIndirect (dispatches)after threeDispatchMesh in two passes. So the VA 0 read may come from another path too.[], no breadcrumbs; system commit 53.6 of 66.2 GB. This time all of the last 24 recorded operations in order areExecuteIndirect (DispatchMesh) in two passes, the path this PR targets, so it does not cover every case of the VA 0 fault on this title. The removal surfaced on aCreatePlacedResourceX(8x1 buffer) call.mainabec7ce9was removed at 188 s with the same VA 0 fault (before the world), andmainabec7ce9+ #1552 at 297 s, 3 s after reaching the world. One run each with different cache states, so the later removal in the first run is not evidence that this PR helps.Not tested: AMD / wave64.
AI use: run and written with Claude Code (Claude Opus 5.5); results checked by me.
Imported from ivall/xcl. Originally posted by AAsobu on 2026-12-01T00:00:41Z.
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
mainand not a regression range.xcl nvprofile status(from #2590) showed thatxcl.exehad no profile here, so the driver's default 512 MB applied. #3277 had the same signature and timing on another RTX 3090 and it went away with the profile.mainff0c364btwice, #3528 twice) stayed in the world for ~220-270 s with no removal, where before 13 of 13 runs past the loading screen lost the device, at 143-816 s from start (5-50 s after world entry in the 8 runs where I timed it).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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T09:24:59Z.
Triage (#1607) – head
0364b38No open or merged PR makes the same change. On main,
prepare_two_pass_stageinbind.rsstill usesuma_window_va(k).unwrap_or(first), so it can bind a null root view for a window whose address is 0.bind_abi_with_root_resolvedalready filters that case. The newwindow_viewhelper gives both call sites the same filter, and it has a unit test.No problems found in the diff.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T11:59:22Z.
merge-check
base:
493dbd3dd0head:
0364b388c6merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2901 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: read the whole diff (+20/-2). The two-pass stage bind (
bind.rs~3108) was the last place that could bind a memory window whose GPU VA is 0 as a root view. Such a window is neither committed nor given a buffer bysparse::init(real.rs~704-776), and a read through a null root view can remove the device. It now takes window 0 instead, asbind_abiand the replay inconsole_list.rs~1077 already do. Findings: (1) The new test (windows_without_a_buffer_take_window_0, ~7958) covers the helper, not the two-pass call site, so it doesn't fail on main; andrewDoing's GPU fixture in the comments does exerciseprepare_two_pass_stageand would make a good test. (2) When window 0 itself has VA 0,first_window(~5046-5048) returns 0 andwindow_view(~5058) still binds a null view.bind_abihas the same limit, so this PR doesn't add it (unverified that it happens). Fine: all four window slots and both passes are covered, and no other root parameters change. In the default 4-window layout every window has a buffer, so the smoke below runs the changed bind with the same addresses as main; it's a regression check, not a test of the new branch.performance: 60 s smoke of a retail title, main
493dbd3dvs this merge (0abd5935): 1670 -> 1693 frames shown (101 %; last presents per 2 s: 60 60 60), peak commit 17083 -> 17182 MB, 0 device removals, 0 crashes.verdict: safe to merge (a test through
prepare_two_pass_stage, like andrewDoing's fixture, would pin the call site)hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by cj-tomlin on 2026-12-01T18:40:08Z.
merge-check claim
head:
0364b388c6Imported from ivall/xcl. Originally posted by cj-tomlin on 2026-12-01T18:48:30Z.
merge-check
base:
6bfb5c5153head:
0364b388c6merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2905 passed, 0 failed, 51 ignored; SKIPPED: 27 (22 no wave64, 2 no heap windows, 3 no D3D12 debug layer / d3d12SDKLayers.dll); failing: none. The new
bind::tests::windows_without_a_buffer_take_window_0passes.review: none blocking, after reading the whole diff (+20/-2,
bind.rs).prepare_two_pass_stagenow filters a window address of 0 the waybind_abi_with_root_resolvedalready did, through one shared helper (window_view), so a window with no buffer gets window 0's buffer, never a null root view; addresses that are set are bound as before. As the description says, the new test checks the helper only and would not fail on the old two-pass code by itself, and on this setup every window has a buffer, so the changed path is not reached in a real title. No other open or merged PR makes this change;mainstill has the unfiltered line.performance: no cost by default: one compare per window at bind time; the bound addresses are unchanged whenever every window has a buffer (reasoned, not measured).
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3080 10 GB, driver 621.40, AMD Ryzen 7 7800X3D, Windows 11 build 26300, debug build / Claude Code (Claude Opus 5.5) merged, built, ran the suite, read the diff and drafted this; I checked it.
Imported from ivall/xcl. Originally posted by Raul-Paiva on 2026-12-03T08:07:44Z.
Thanks. On the two findings of the merge-check:
windows_without_a_buffer_take_window_0does not fail on the old code by itself. A test throughprepare_two_pass_stageneeds a GPU with mesh shaders and the unified-memory windows set up in the test process, as in andrewDoing's fixture. I left it out to keep this PR to the one bind. If the maintainer wants it pinned here, I'll add it on top of that fixture.first_windowalready refuses a window 0 without a buffer when the windows are shadowed. Otherwise it returns VA 0 as it is, and thenwindow_viewbinds a null view, the same asbind_abi. I have not seen window 0 at VA 0 in a run. If it turns up, both binds should fail the same way, in their own PR.The reply was posted by Claude Code (Claude Opus 5.5) on my behalf, and I reviewed it before it went out.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.