D3D12.X: use a valid empty BVH for unaddressable SRVs #3688
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3688"
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 jeroenhaentjens on 2026-12-02T11:24:19Z.
What & Why
Unaddressable non-null acceleration-structure SRVs could produce an all-zero descriptor. Translated traversal can read that descriptor as a root in memory window 0. Use a valid empty root in coherent UMA so traversal reports a miss. Extracted from #3681 after the review by Foniass.
What is in it
dev_create_srv_inneruses the shared empty BVH for non-null addresses outside addressable UMA and preserves explicit null SRVs in normal mode.Tested
4ede28030c87b1a36518b25f7924f7073b952cedon an Intel Core i7-9750H and NVIDIA Quadro RTX 3000 (6 GB, driver 597.06 /32.0.15.9706). Windows 11 Pro 25H2 build26200.9974, Rust1.100.0MSVC, DXC1.9.2602.17.cargo build --locked --workspaceandcargo test --locked --workspace -- --test-threads=4passed. The harnesses reported 2,910 passed, 0 failed and 51 ignored. That total includes 19 tests with 26 explicit skip entries for wave64, heap windows, GPU_UPLOAD heaps or the driver-cache control that needs Windows Developer Mode. A temporary high-performance Windows preference selected the Quadro for test executables that use the default D3D12 adapter.hle::d3d12x::real::srv_tests::gpu_out_of_uma_bvh_srv_returns_a_miss --exact --nocapturewithXCL_D3D12_DEBUG=1. All rays missed and the Quadro reported 0 Debug Layer messages. The regression failed against the old implementation.cargo build --locked --releasebuilds and matched 60-secondscripts/smoke.ps1runs onmainand the exact head.Regression run
Not tested
AMD, Linux or gameplay past the startup/menu. The menu smoke does not establish that the specific fallback was reached in the title.
AI use
OpenAI Codex (GPT-6, specific revision unavailable) assisted with the implementation, tests and PR draft. The author reviewed the diff and the recorded test results.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T11:28:26Z.
Review (head
4ede2803, diff read, not a merge-check):8ff1db17, with the samefallback = (empty || va != 0).then(empty_bvh)decision indev_create_srv_inner(real.rs~3309) and the samerunner.rssampler-heap hunk (~1604); whichever merges second conflicts in both files or applies it twice, so that commit should be dropped from #3681.Fine: the new
gpu_out_of_uma_bvh_srv_returns_a_misscallsdev_create_srv_xwith a VA outside unified memory and with VA 0, so it covers the decision that #3681's test missed: it fails onmain, which writes a zero descriptor there, and checks that an explicit null SRV stays zero. The shared empty BVH is allocated once from a committed window of the process-wide UMA and never freed, and the device reaches that memory through the opened heap, the driver window or the shadow copy.AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by gut0to on 2026-12-02T15:57:18Z.
Review: COMMENTED
AI-assisted review (model: GPT-6). I traced the out-of-UMA SRV fallback and its allocation failure path.
Imported from ivall/xcl. Originally posted by gut0to on 2026-12-02T15:57:19Z.
Code review location:
crates/xcl/src/hle/d3d12x/real.rs; line 3311If
empty_bvh()cannot allocate its 64 KiB root,fallbackisNoneand this function falls through to writing a zero descriptor. The comment above says a zero descriptor can make traversal read the root from window 0—the behavior this change aims to prevent. Sinceempty_bvh()cachesOption<u64>in aOnceLock, a transient allocation failure is permanent for this process, even if UMA space becomes available later. Could this path avoid publishing a zero descriptor for a non-null out-of-UMA SRV and retry after allocation pressure clears? A failure-then-retry test would cover the case.Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-03T01:51:22Z.
merge-check
base:
078358a058head:
4ede28030cmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 3007 passed, 0 failed, 52 ignored (base: 3006 passed, 0 failed, 52 ignored); SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), the same set as base; failing: none in this run. In a first run the lib binary ended with 0xc0000005 after 10 of the 40 dumps of
thread_dumps_while_threads_run_and_exit, before this PR's test had started. That is #3586, which is on base too (#3743 fixes it)review: read the whole diff (4 files, +141 -10). No blocking finding.
XCL_BVH_EMPTY=1behave as on base.empty_bvh()now runs withoutXCL_BVH_EMPTY, under the tracked-SRV write lock. The allocation takes only the arena's own lock and releases it before it returns, so I see no lock-order risk.srv_tests::at--test-threads=8, and 10 of 10 withXCL_D3D12_DEBUG=1(all rays missed, 0 messages).runner.rsis test support: without it the test still passes, but the debug layer reports 1 message.empty_bvh()keepsNonefor the rest of the process and the zero descriptor is written. Base writes that descriptor every time, so it is a remaining gap and not a regression.performance: none expected (reasoned, not measured): one 64 KiB allocation, made the first time such an address is seen.
verdict: safe to merge
hardware / tool and model: RTX 3060 12 GB (610.88), Ryzen 7 5700X, Windows 11 Pro 26300 / Claude Code (Claude Opus 5.5)
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.