D3D12.X: stage CopyMemoryToMemoryX from title memory via upload buffers #468
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/473"
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 7ROBE on 2026-11-24T00:48:46Z.
What is in it
Fixes #319. When
CopyMemoryToMemoryXcopies from title CPU memory outside unified memory (crate::gpu::shader::readable) into a unified memory window,copy_memory_xnow recordsCopyBufferRegionfrom a per-list persistently mappedD3D12_HEAP_TYPE_UPLOADbuffer (sharingcreate_mapped_uploadwithpattern_buffer), copies fromsrcinto the upload buffer right before submission (ExecuteCommandListsandKickoffX), and keeps the upload buffer alive until the queue's fence completes viacpu_writes::Write::KeepAlive. Adds test cases intests/testtitle/src/gpu.rs(console_list_methods) writing to the title heap after recording and before bothExecuteCommandListsandKickoffX.Regression run
Main (
2997c9aca6ebf4577fed34ebdb3cb0a77dd9ec21):PR head (
388cf3baec605cef572f6966cb1b34b07fc655fb):Tested
cargo test --workspace -- --test-threads=4on Windows 11 Pro (26H2), Intel Core i5-14600KF, AMD Radeon RX 9060 XT (Adrenalin 26.11.2,XCL_ADAPTER=radeon): 676 passed, 0 failed, 41 ignored (SKIPPED: none). Includestest_title_runs_and_game_folder_is_untouchedexercisingCopyMemoryToMemoryXfrom title heap into graphics memory on bothExecuteCommandListsandKickoffX.Not tested
Linux / Wine / NVIDIA / Intel GPU paths.
AI use
AI-assisted: Antigravity (Gemini 3.1 Pro). Human reviewed and ran tests and smoke runs on Windows 11 Pro + Intel Core i5-14600KF + AMD Radeon RX 9060 XT (26.11.2).
Imported from ivall/xcl. Originally posted by Icey-Glitch on 2026-11-24T01:02:09Z.
High: upload buffer is refilled while an earlier submission may still read it (reviewed at
388cf3b)fill_uploads(crates/xcl/src/hle/d3d12x/list_x.rs:944) copiessrcinto eachPendingUpload'smappedpointer on everyExecuteCommandLists. Becausepending_uploadsis intentionally kept after submission (a closed list may be executed again), a second execution of the same list writes into the same mapped buffer with no fence check. If the first submission'sCopyBufferRegionhasn't run yet, it copies the second snapshot.Scenario: the title executes list L, updates the source CPU memory, then executes L again on the same or another queue. The first execution's copy can land the second execution's data, or a torn mix of both.
Possible fixes: allocate (or pool) a fresh upload buffer per submission, or wait on or check the previous submission's fence before refilling.
Related (perf): each
CopyMemoryToMemoryXfrom title memory callscreate_mapped_upload(list_x.rs:1020), so each copy creates its own committed resource (at least 64 KB) on the recording thread. A per-list or pooled buffer, as the description says, would address both issues. The description currently says "a per-list persistently mapped upload buffer", but the code creates one buffer per copy.Imported from ivall/xcl. Originally posted by H0UNDZER0 on 2026-11-24T01:32:09Z.
Tested on an RTX 5080: pass, the same counts as
main, and the test title's new copies take the new path.388cf3baec605cef572f6966cb1b34b07fc655fb, this PR's head as is (on its base2997c9a), release build.XCL_*variables set.cargo build --release --workspace --locked: OK, the same singlefetch_updatewarning asmain.cargo test --workspace --release --no-fail-fast --locked -- --test-threads=4, run twice (the second with--show-output): 676 passed, 0 failed, 41 ignored both times, the same asmain2997c9aon this PC.SKIPPED: the usual 2,gpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware(no wave64).e2e):[PASS] D3D12.X: console command list memory methods (…), the check that holds the two new copies. 50[PASS], 0[FAIL],failures: 0. XCL logsCopyMemoryToMemoryX from memory outside unified memory goes through an upload buffer (0x40 bytes), so the copies went through the new path on this GPU.test_title_draws_with_a_root_signature_under_the_debug_layerpasses. The test title logs the same 5 errors and 9 warnings asmain's on this PC, none new. The only difference is in the live-object report at exit: the device's reference count is 123, against 122 onmain.Not tested
main. At the time of the run that was7ebf1b8;git merge-treeshowed no conflict with it.scripts/smoke.ps1.AI use: Claude Code (Claude Opus 5.5, Claude Fable 5.2)
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T14:05:19Z.
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main— needs a rebase before it can be tested.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T03:34:10Z.
Triage (#1607) – head
388cf3b#768 is stacked on this PR: its bottom commit is this change rebased onto main, and its top commits replace the
cpu_writes::Write::KeepAliveretirement with queue fencing.Problem in the diff: list_x.rs
cpu_writes_after/kickoff_xhand the upload buffers to the singlexcl-cpu-writesworker asKeepAlive. That worker waits at mostWAIT_MS(10 s) per job, then drops the buffer even if the GPU still reads it, and a job blocked on one queue's fence delays CPU writes queued for every other queue. #768 fixes both.The PR conflicts with main.
Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Pull request closed