D3D12.X: mirror buffer views outside unified memory into UMA #637
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!637
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-637"
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?
@WTactic on GitHub · 2026-11-24 02:45 UTC · original
WTactic:buffer-views-outside-uma→main· +270 −28 · 3 files · 1 commits · openWhen a title allocates resources outside XCL's mapped unified memory (UMA) windows and attempts to bind them into vertex or index buffers, native D3D12 device calls previously failed or produced invalid GPU virtual addresses.
This change transparently mirrors buffer views that fall outside the UMA memory windows into the coherent UMA pool (via
safe_copy_from_title), allowing games with custom out-of-pool heap layouts to bind buffers cleanly.What is in it
crates/xcl/src/hle/d3d12x/device_x.rs,crates/xcl/src/hle/d3d12x/list_x.rs,crates/xcl/src/hle/d3d12x/real.rs: mirror buffer views residing outside the 3 sparse UMA windows into the coherent memory region.Tested
rustc 1.97.1, release/debugcargo test -p xcl --lib list_x::tests: 27 passed, 0 failedRegression run
main(1d027e5):PR (
3217101):Not tested
AI use
@MesshM on GitHub · 2026-11-24 03:33 UTC · original
Test run of
0f418b034490020422a44a7662cedb58b5bca2cbon AMD RDNA4. I merged it onto currentmain91f9a5elocally (clean merge) and tested that tree.Tested
stable-x86_64-pc-windows-msvc, debugcargo build --workspace+cargo test --workspace -- --test-threads=4on the merge: 694 passed, 0 failed, 41 ignored, exit code 0;xcllib tests 654 passed, 0 failed, 21 ignoredSKIPPED;buffer_views_outside_uma_are_mirroredandcbv_outside_uma_is_mirrored_and_refreshedpass.Review: A view of a buffer outside unified memory now gets a mirror in UMA, and every path that fills the mirror copies from
mirrors::source(va)(the title's current source for a moved page) after areadablecheck, so the copy cannot fault. The mirror is filled when a view is created and by the existing refresh path; I did not trace every CPU write path, so whether a title write between view creation and submit always reaches the mirror is not something this run shows.Not tested: no retail title or regression run (I have no unpacked game), no
XCL_SAMPLE_*tests, release build; the PR's head on its old base was not run, only its merge ontomain.Run and review by Claude Code (Claude Opus 5.5) on this machine; the review points were checked against the code.
@iggyvilla on GitHub · 2026-11-24 04:00 UTC · original
Tested (PR head
0f418b0, not merged onto currentmain; RDNA2/wave64, which the PR lists under Not tested)Windows 11 build 26300,
rustc 1.100.0 (0ef1bc386 2026-11-09) stable-x86_64-pc-windows-msvc.cargo build --release -p xcl— ok.cargo build --workspace— ok (debug test title built).cargo test --workspace --no-fail-fast -- --test-threads=4on the PR head, debug:679 passed, 3 failed, 41 ignored, 0 skipped.
xcllib: 639 passed, 3 failed, 21 ignoredconsole_dlls_e2e13;console_shaders3 passed, 4 ignored;disasm_e2e1;e2e3;gpu_compute_e2e2;gpu_pso_e2e7;heap_probe4 ignored;pls_quota1;predication_e2e1;rpf_e2e2;texture_states1;xg_oracle6 passed, 12 ignored.SKIPPEDlines.mainon this card, not new ones:placed_title_textures_share_vram_and_preserve_pixels— also fails alone:assertion left == right failed: 3D 64x64x64 4 mips: subresource 2 mismatch(#470).transitions_apply_when_their_list_is_submittedandd32s8_targets_take_their_own_size_of_video_memory—PoisonErrorin the suite (the lock-poisoncascade #673 fixes); both pass when run alone. Not caused by this PR.
buffer_views_outside_uma_are_mirroredandcbv_outside_uma_is_mirrored_and_refreshed.XCL_NETWORK=0,scripts/smoke.ps1 -Game D:\GTA6.Xbox.v1.0.2.1-CYBERLEEK,as printed:
For reference, a
mainrun on this machine the same way (commitdd2ae9a, not this PR's base508a0c7) is 569 frames, 23 24 23 presents per 2 s, peak commit 15856 MB, exit0x0, 0 crashes. Thedifference is reported as measured; this run does not attribute it to the PR.
Not tested
mainhere; only the head as fetched was built and run.XCL_SAMPLE_*tests (none set).AI use
opencode with DeepSeek V4.1 Flash (opencode-go/deepseek-v4.1-flash) ran the build, the tests and the smoke
run and wrote this report.
@Dukiverse on GitHub · 2026-11-24 04:03 UTC · original
Retail regression run of this PR: the retail title 1.0.2.1 (the same title as #675 and #616) crashes about 18–23 s in, inside
mirror_of, with no input.mainruns the full 60 s.Tested
XCL_NETWORK=0, nothing touched during the runs.scripts/smoke.ps1 -Seconds 60, run on four builds:mainf4ce27c: full 60 s, 1465 frames, no crash, 14632 MB peak.f4ce27c(local merge723b057, clean):0xc0000005at 17.8 s.0f418b0on its own base, two runs:0xc0000005at 22.9 s and 23.5 s.maindd2ae9a, for the head-only runs: full 60 s, 1464 frames, no crash.0x3200000) copy into a new mirror at0x469a00000, and it faults on the first byte of its source. The source is the title's memory outside unified memory. Just before it, two mirrors are made for small views (118060 and 44048 bytes, at0x463a70000/0x463a90000). The third view, the one being mirrored here, is never logged, because the copy runs before the log line.copy_nonoverlapping(src, p, len)at the end ofmirror_of).readable(src_start, len)fails, the fallback usesmirrors::source(va)without its ownreadablecheck. The caller checkedva, not that source. I have not confirmed this is the path taken.cargo test --workspace -- --test-threads=4(debug build present) on0f418b0: 663 passed, 0 failed, 25 ignored. SKIPPED: 2 wave64 tests (32-lane GPU).Regression run
main
f4ce27c:this PR merged onto it:
Not tested
mirror_ofthe crashing copy took.title:lines in the smoke blocks are redacted; nothing else in them is edited.Runs and report by Claude Code (Claude Opus 5.5) on my machine.
Generated by Claude Code
@WTactic on GitHub · 2026-11-24 12:07 UTC · original
Thanks for finding and reporting this @Dukiverse!
Root Cause
The 50 MB buffer view was placed in
MEM_RESERVEmemory (e.g. an unwritten GPU UAV output buffer) that had not been committed yet on the CPU. The previous fallback attemptedcopy_nonoverlappingdirectly from reserved memory without ensuring lazy page commit or verifying per-page commit status, triggering the0xc0000005fault.Fix
safe_copy_from_title:kernelx::lazy::ensure(src, len)to commit any pending lazy pages.MEM_RESERVE), queries page states viaVirtualQuery: committed readable pages are copied, while uncommitted pages are safely zeroed in the mirror rather than faulting.uncommitted_buffer_view_does_not_crashinreal.rsverifying that views over uncommittedMEM_RESERVEmemory mirror cleanly without faulting.Squashed and force-pushed head
8d051f3. All workspace tests pass (cargo test --workspace -- --test-threads=4: 664 passed inxcllib).@pvfreis on GitHub · 2026-11-24 13:49 UTC · original
Re-read at
cfc848f(nothing built or run here). Point 1 of my review is fixed another way: the copies now go throughsafe_copy_from_title, which zeroes uncommitted pages instead of faulting. Points 2-4 still apply at this head:sync_title_buffers,list_x.rs:3208-3220); a CBV/SRV/UAV mirror is copied again only when a view of the same range is created (mirror_offromreal.rs:1195,:1827,:2224). The description still says the views are "refreshed on CPU writes".mirror_ofhit copies the whole requested range again (list_x.rs:3159-3161, and the second lookup under the lock).TITLE_BUFFER_BYTES(real.rs:1566-1573) still has no removal inres_release(:1587).Reply by Claude Code (Claude Opus 5.5); checked by a person before posting.
@crosettiremi on GitHub · 2026-11-24 16:28 UTC · original
RX 7900 XT downstream test of cb4a9ae on a build based on
930e8b4. The three focused tests for non-UMA buffers, constant-buffer refresh, and uncommitted views passed. The comparison build logged an empty buffer descriptor during startup. With this PR the title reached the new mirror path: one logged view was 118,060 bytes, and the last power-of-two sample showed 8,192 mirrors totaling 1,408 MB.Both runs had matching initial caches, scripted Player1 input at 33 seconds, two DXC workers and a 28 GiB whole-job limit. The comparison build later had a GPU page fault during world loading. The mirrored build exited at about 190 s with Rust allocation-error handling on a DirectStorage queue worker; peak sampled process commit was 27,560 MB and no device removal was logged. The title exercised the implementation. These two runs do not establish that mirroring fixed the GPU fault, or that mirrors alone caused the allocation failure.
@relativespace2K on GitHub · 2026-11-24 03:48 UTC · original · edited 2026-11-25 04:10 UTC
Tested -
3217101onmain3da2abb, retail GTA6 1.0.2.1Tool: OpenCode with DeepSeek V4.1 Flash 1017
0xc0000409; stdoutmemory allocation of 2073600 bytes failed(host OOM), peaks31,964 MB and 35,116 MB.
peak 40,020 MB, mirrors active, 0 failed pipelines, 0 DXIL failures, 40 refusals as
main.main240 s exit 0 at 33,429 MB; #684 240 s exit 0 at 35,380 MB.feature raises peak memory to ~40 GB; with enough headroom the run is clean.
Tested - re-tested at the new head, independent AMD RDNA2 validation
cfc848f934f1ba13dff0f31121718a226702e493, based on47efa2e(the branch wasrebased; the previous report was for
0f418b0). Applied as a cherry-pick withoutcommitting onto current
mainb8b1f49(clean;real.rsauto-merged).Windows 11 IoT Enterprise LTSC 26100; Rust 1.100.0
stable-x86_64-pc-windows-msvc;DXC 1.9.2602.17 (Windows SDK 10.0.26100.0); debug; no
XCL_SAMPLE_*.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4.mainb8b1f49main+ this PRbuffer_views_outside_uma_are_mirrored,cbv_outside_uma_is_mirrored_and_refreshedanduncommitted_buffer_view_does_not_crash(lib tests go 702 -> 705; the integration binaries are unchanged).
3D 64x64x64 4 mips: subresource 2 mismatch(#470) and the twoPoisonErrorfollow-ons (#673).
cargo test -p xcl --lib outside_uma: 2 passed, 0 failed, 0 ignored, and thelog shows both paths active - the CBV and the buffer view outside unified memory are
mirrored at
0x420010000/0x420020000, "each draw copies what it reads".SKIPPEDGPU tests on this adapter.Not tested: retail title /
smoke.ps1, release build, NVIDIA / Intel.AI use: OpenCode with DeepSeek V4.1 Flash 1017 ran the tests and drafted this report.
@JJAutoCompare on GitHub · 2026-11-25 06:36 UTC · original
Empirical test report (
32171011)Hardware / environment
32171011d20dacd2f87de84865be3ef1fcb96e86, verified on a clean detached HEAD.Commands and results
cargo test --workspace --no-runexited 0 and built the workspace test executables. This command compiled tests only.XCL_ADAPTER=NONE_CPU_ONLYandRUST_TEST_NOCAPTURE=1.$unitTestExerefers to the prebuilt library harness,xcl-77aca8ccb20e299f.exe.All three commands exited 0. Each reported 1 passed, 0 failed and 0 ignored. The focused log totals were 3 passed, 0 failed, 0 ignored and 0 skipped (case-sensitive
^SKIPPEDlines).Observed behavior
Not tested
The full GPU workspace suite, shader execution against these descriptors and game smoke runs were omitted.
AI use
Verified with T3 Code / Codex (gpt-6.2-sol, reasoningEffort: high). Coordinator #2 (T3 Code / Antigravity, gemini-4-neon) verified counts against pr637-focused.log and published.
@CharlyRien on GitHub · 2026-11-25 08:59 UTC · original
A test of this PR's idea on the retail title, done with an equivalent local change rather than this branch: copies of out-of-window buffer views are enough to get world geometry rasterised, with three conditions this PR may want to know about. Numbers: #697
Setup in short (the full block is in the linked comment):
main689f2db+ #1329 (+ #1326, #1327), #1448, #1323, #889, #684, #929, #640, #1850, #765, #1982, #1405, #1464, three allocator-lifetime commits fromwondercrash/xcl, then #541, #2092's3442b58state, #1887, #1803, plus local changes;XCL_UMA_SHADOW=1 XCL_HEAP_WINDOWS=1; RTX 3090 24 GB (driver 616.56), Windows 11 22631; one clean run and one partial run.buffer_words_atpath this PR also changes): 94 412 distinct ranges in the first 25 s of the world, 1 156 MB, every one an SRV, 71 % of them 4 KiB or less. The title's GPU-driven culling and its mesh programs read through them.Not tested: this branch itself; writes through UAV copies going back to the title (none of the by-address views in the GPU view was a UAV here).
AI use: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 for the ports and the runs) did this and drafted the comment.
@DavidM1911 on GitHub · 2026-11-25 12:43 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@throny on GitHub · 2026-11-25 20:14 UTC · original
Two contributors checked independently and found that #2384 solves the same problem in a different way: #1607, group D110. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.
This is a hint from the community triage in #1607, not a maintainer decision.
AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.