D3D12.X: copy from the backing pages of GPU-only views #768
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!768
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-768"
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?
@philip-roy-jones on GitHub · 2026-11-24 04:58 UTC · original
philip-roy-jones:d3d12x-mirrored-copy-sources→main· +339 −50 · 5 files · 3 commits · openStacked on #473 by 7ROBE: the bottom commit is #473's and the top two belong here. Part of #319. Rebased onto
mainat08db802.CopyMemoryToMemoryXdropped copies from a GPU-only reservation even when the paired CPU view held the data. The staged copy also put its upload buffer on a worker that gives up after ten seconds. A blocked copy could lose XCL's last reference while the GPU still needed it and delay a CPU write on another queue.What is in it
Read backing spans at submission, prefer directly mapped pages and zero the holes. Fill each submitted segment, including split lists and
KickoffX. The upload shares the submitting queue's fence with its copy scratch buffer. The bundled title checks late source writes on both submission paths. CuteBooty reported the timeout and cross-queue delay on an RTX 3070. The retirement code reuses zohaiblazuli's queue fencing. Review and measurements · Copy scratch fencing in #993Tested
Clean head
953f9eeand cleanmain08db802, each in its own checkout and target directory. Radeon RX 580 8 GB (driver 31.0.21925.1001), Ryzen 7 7700X, 32 GB, Windows 11 Pro 26200, Rust 1.100.0 MSVC, Windows SDK DXC 1.8.2502.11. Debug tests and release title runs.XCL_SAMPLE_*were unset.cargo build --locked --release -p xcl,cargo build --locked --workspaceandcargo test --locked --workspace --no-runsucceeded on both.cargo test --locked -p xcl --lib -- staged_copy_waits_for_its_own_queue_without_blocking_cpu_writes copy_gpu_view_reads_each_mapping_and_leaves_holes_zero copy_scratch_budget_counts_resources_until_gpu_completion --test-threads=1 --nocaptureon head: 3 passed, 0 failed, no skips. The independent write took 1.098 ms, the upload references went 1/2/1 and the readback was0x1234abcd. Before the rebase, on the unfixed merge7cb9599with only that test added, the write took 10.010 s and the test failed.cargo test --locked -p xcl --lib -- hle::d3d12x:: --test-threads=4: main 253 passed, 0 failed, 2 ignored. Head 255 passed, 0 failed, 2 ignored; the two extra are this PR's tests. Each printed one SKIPPED (no mesh shaders).cargo test --locked --workspace --no-fail-fast -- --test-threads=4exited 101 on both, with the same result for every test binary. Thexcllib binary exits0xc0000005on this GPU. A single-threaded run on head stops ingpu::dxil::lanes::ps_ballot_tests::gpu_direct_ps_masks_hold_helper_lanes_on_triangle_edges, and with that test skipped neither build exits early. The other binaries gave 124 passed, 1 failed and 20 ignored on both, includinge2ewith the bundled title (4 passed). The failure isconsole_compute_without_an_exec_write_has_the_wave_size_of_its_headeringpu_compute_e2e: the driver refuses its compute pipeline (0x80070057).--skip gpu::dxil::lanes::ps_ballot_tests::gpu_direct_ps_masks_hold_helper_lanes_on_triangle_edges): main 1,176 passed, 127 failed, 27 ignored; head 1,178 passed, 127 failed, 27 ignored. The same 127 tests failed on both, all GPU tests ingpu::recompandgpu::dxil: 118 by device removal (0x887A0005), 8 by0x80070057andgpu_sparse_vram_descriptors_buffers_and_xmemby its GPU address assertion. Both printed the same 100 SKIPPED lines from 84 tests, which libtest counts as passed. 79 are missing features of this GPU (wave32, mesh shaders, 64-bit heap atomics). 21 found no usable device after the removals; thehle::d3d12xrun above covers those in that module.Regression run
scripts/smoke.ps1 -Game <retail folder> -Seconds <n> -Title Retail -OutDir <run folder>on this RX 580 with default settings. Each run had an emptyXCL_DATA_ROOTand its own copy of the same shader and driver cache (XCL_DXIL_CACHE). On this GPU both builds fast-fail inamdxc64.dllabout 8 s in (0xc0000409at offset0x14e8d85, the crash #2038 fixes). With-Seconds 60, main stopped at 7.98 s and the PR at 8.29 s, both after 60 presents between 4 and 6 s and before a final frame count. The blocks are therefore of 7-second runs, which end before that point.The 7 frames between them come from when the first frames appeared: 1 present against 12 between 2 and 4 s. In the 60-second pair it was the other way round (15 against 8). The previous head
f13de96, which had the same changes before this rebase, ran for 60 s on an RX 9070 with 1,631 frames against 1,618 onmain. Toons29's RX 9070 resultsNot tested
CopyMemoryToMemoryXfrom outside unified memory. Only the unit tests and the bundled title exercise it.AI use
claude-opus-5-5; its reasoning-effort setting is not visible to it) rebased the PR ontomain08db802and resolved the conflicts inreal.rsandtitle_textures.rs, keeping both sides. It checked that the rebase left the PR's added and removed lines unchanged, ran the RX 580 builds, tests and retail runs above and updated this description. Reviewed on Philip's behalf.🤖 Generated with Claude Code
github-bot referenced this pull request2026-11-26 04:59:09 +00:00
@crosettiremi on GitHub · 2026-11-24 05:15 UTC · original
RX 7900 XT, Windows 11 build 26100, native D3D12, offline Series S title profile.
70dfae4, isolated empty application caches, 60-second retail smoke at the menu, no input. Exit 0, 1,109 frames shown, last three 2-second present counts 60 / 60 / 60, zero crashes or device removals, peak process commit 18,831 MB.AI use: Codex (GPT-6) ran the checks and prepared this report.
@CuteBooty on GitHub · 2026-11-24 18:05 UTC · original
Two effects of keeping the upload buffers alive through
cpu_writes(head6c0066b), when the queue of such a copy is held by a long wait.1. XCL's last reference to the buffer can go before the copy has run. The worker gives a job up after
WAIT_MS(10 s from when it starts to wait for it) and drops theKeepAlivealthough the fence is not there. Until the list is reset, its state holds another reference. AfterKickoffXhas returned (it takespending_uploadsout of the state) or after aResetof the list, I found nothing else that does. The copy may then still be ahead on the GPU.2. The copy can hold up other queues' CPU writes. The worker is one thread and takes jobs one after the other, so
Immediate/ReadbackU64jobs behind the copy's job wait with it, whichever queue they are for, up to 10 s for each such job. Lists with CPU writes already do that onmain; this adds lists whose only job is the copy. (mainskips these copies and queues nothing for them.)Seen with a scratch test in
cpu_writes.rs: queue B waits for a fence and executes a list with aCopyBufferRegionfrom an upload buffer, thenafter(B, [KeepAlive(buf)])andafter(A, [Immediate(..)]); on the base without the firstafter. Times are from after theafter(A, ..)call until the test sees the value.47efa2e6c0066bThe test holds one reference itself, so nothing was freed early in it. That no other reference is left after
KickoffXorResetis from reading the code.Possible fix: keep an upload buffer until its fence is reached, without a time limit and outside the worker's queue (for example a list of (fence, value, buffer) looked at on each submit). #562 (a worker per queue) would end the second effect, not the first.
Tested:
cargo test -p xcl --libwith that one test on both commits; RTX 3070, NVIDIA 621.24, Windows 11 Pro 26200, rustc 1.100.0 MSVC, debug.Not tested:
copy_memory_x/KickoffXend to end, an actual use after free, the whole suite, a retail title, whether a title's queue is held that long with such a copy in it.AI use: Claude Code (Claude Opus 5.5) found this, ran the test and wrote the comment; Codex (GPT-6.2 Astra) checked the claims and the draft by reading the code, without running anything.
@philip-roy-jones on GitHub · 2026-11-24 16:24 UTC · original · edited 2026-11-24 18:35 UTC
@crosettiremi, thanks for the 1,109-frame menu run on
70dfae4. Could you repeat that 60-second comparison on your RX 7900 XT using clean upstreammain(c160d86is the base of this revision) and the current #768 headf13de96?On each clean checkout, build with
cargo build --release --locked -p xcland run.\scripts\smoke.ps1 -Game '<your local game folder>' -Seconds 60. Please use the same title, cache state, settings and menu inputs on both builds. Could you paste the two generatedxcl-smokeblocks here? Those summaries are all we need.Posted at Philip’s request via Codex (GPT-6.2 Astra, max reasoning effort).
@CuteBooty on GitHub · 2026-11-24 19:07 UTC · original
Both points are fixed in
f13de96as far as my test shows. Same setup as before (queue B held by a fence, a copy from an upload buffer on it), now throughcopy_buffers_submitted(B, [list], [buf]):6c0066bf13de96Tested: that one scratch test and
cargo test -p xcl --lib list_xonf13de96(28 passed, 0 failed,staged_copy_waits_for_its_own_queue_without_blocking_cpu_writesamong them); RTX 3070, NVIDIA 621.24, Windows 11 Pro 26200, rustc 1.100.0 MSVC, debug.Not tested:
copy_memory_x/KickoffXend to end, the whole suite, a retail title.AI use: Claude Code (Claude Opus 5.5) read the change, ran the tests and wrote this.
@philip-roy-jones on GitHub · 2026-11-24 19:34 UTC · original
@coolpersonnn, could you run one 60-second retail smoke test on your RTX 5090 using clean #768 head
f13de96bcd3e505bac3684c2e24d9f7fc3a99b3d? Your cleanmainrun onc160d86recorded 1,670 frames in 60 seconds and gives us the comparison. Your baseline in #1439Please use the same title, warm shader caches, default switch-window mode, settings and inputs as that run. On the clean head, build with
cargo build --release --locked -p xcland run.\scripts\smoke.ps1 -Game '<your local game folder>' -Seconds 60. Could you paste just the generatedxcl-smokeblock here? We can pair it with the main block you already posted.Posted at Philip's request via Codex (GPT-6.2 Astra, max reasoning effort).
@Toons29 on GitHub · 2026-11-25 02:59 UTC · original
Regression run of
f13de96bon the retail title, for this PR's Regression run section. Both blocks are fromscripts/smoke.ps1as printed, not edited:mainon4178e888, this PR on its head commit with no uncommitted changes, same title and time.Against the limits in CONTRIBUTING.md: 101 % of
main's frames, 100 % of its peak commit, no crash, no device removal.AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0,
cargo build --release -p xcl, 60 s,XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.AI use: Claude Code (Claude Opus 5.5) built both trees and ran
scripts/smoke.ps1; I checked the blocks before posting.@DavidM1911 on GitHub · 2026-11-25 11:08 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!
@DavidM1911 on GitHub · 2026-11-26 03:00 UTC · original
Re-verification on RTX 3060 Ti (Windows 11), new head merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.Thanks!
— Devin
@upipibi on GitHub · 2026-11-26 08:11 UTC · original
RTX 3070 run of head
953f9ee(base08db802, not merged with main). As far as I can see this is the first run of the test title'sconsole_list_methodson NVIDIA; the earlier 3070 report ran only thelist_xlib tests onf13de96.NVIDIA GeForce RTX 3070 8 GB, driver 616.56, Windows 11 10.0.26100, rustc 1.100.0 MSVC, debug builds. Clean head and base each in their own worktree and target directory.
XCL_SAMPLE_*were unset.cargo test --locked -p xcl --test e2e -- test_title --nocapture --test-threads=1, 3 runs: 3 passed, 0 failed each time (test_title_runs_and_game_folder_is_untouchedand both debug-layer variants, about 575 s per run). Each run printed[PASS] D3D12.X: console command list memory methods (...)andfailures: 0, and loggedCopyMemoryToMemoryX from memory outside unified memory goes through an upload buffer (0x40 bytes)andsame-window scratch copies recorded: 1. So the GPU-view copy path ran; it was not skipped. The title change has no skips or early returns.08db802with only this PR'stests/testtitle/src/gpu.rschange applied (the runtime ande2e.rsare base's), same command, once: 3 failed. The title reported[FAIL] ... console command list memory methods ...: CopyMemoryToMemoryX from title heap,failures: 1, and the log had0x... → 0x420012100 (0x40 bytes) is not in unified memory – not doneand the same for the GPU view at0xa60000000. The new check fails without the runtime change and passes with it.cargo test --locked -p xcl --lib -- <name> --test-threads=1 --nocapture, 3 runs each, all passed:staged_copy_waits_for_its_own_queue_without_blocking_cpu_writes(independent write 2.5 / 1.6 / 1.1 ms, upload refs 1/2/1, readback0x1234abcd),copy_gpu_view_reads_each_mapping_and_leaves_holes_zeroandcopy_scratch_budget_counts_resources_until_gpu_completion.cargo test --locked -p xcl --lib -- --skip hle::xaudio2 --test-threads=4on head: 1297 passed, 0 failed, 27 ignored, no abort. 25 SKIPPED lines from 15 tests, none inhle::d3d12x: 21 no wave64 (hardware), 3 translator refusals of f16/f32 per-lane forms (#1426), and 1 PSO measurement that needs Windows Developer Mode.Not tested: the retail title, a release build, the base lib suite, and a merge with current main.
AI use: Claude Code (Claude Opus 5.5) built both trees, ran the tests and wrote this.
@oni-swr on GitHub · 2026-11-26 08:56 UTC · original
AMD RX 7800 XT test report for #768 at exact head
953f9ee0ce38eabc12bb21b1c29fa95b14ad287f, on the bundled synthetic title only. No retail smoke, game files, dumps, shader names or retail hashes were used.Setup
cargo --locked -j 4. The physical RX 7800 XT was confirmed in the runtime log (backend 'real' - AMD Radeon RX 7800 XT) and no other process was using it when the runs started.D:\xcl-768-amd-win-target: base08db8020d323bf478964fcc586152cce54959cfc, parentfb84553ef55b044f401dae5101c5ab11dfc87ca2(the PR without its top commit), head953f9ee0ce38eabc12bb21b1c29fa95b14ad287f. For every run I checked thatxcl.exe/xcl_testtitle.exe/testgame_mw.dllwere built from that run's own tree (their.dfiles name only that source tree).XCL_SAMPLE_*unset.Workspace suite,
cargo test --workspace --locked --no-fail-fast -j 4 -- --test-threads=408db802953f9eeThe one failure is
gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1(fuzz_tests.rs:1171, seed 722:res[30] = 0x1, CPU 0x7fffffff). It failed in the same way on both base and head, so it is not caused by this PR. The head run has two more passing lib tests than base (1305 vs 1303), which are the two new unit tests. The 7 skip notices are the same on both trees: 6 translator refusals of f16/f32 per-lane forms (#1426) and 1heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows. The title tests were not skipped (noSKIPPED the titlenotice).Backing-page copy, both submission paths (
console_list_methods,cargo test --locked -p xcl --test e2e -- test_title --nocapture --test-threads=1)[PASS] D3D12.X: console command list memory methods ...,failures: 0,CopyMemoryToMemoryX same-window scratch copies recorded: 1andCopyMemoryToMemoryX from memory outside unified memory goes through an upload buffer (0x40 bytes). Runs took about 11 s here.fb84553: the same 3 passed, so the top commit does not change this result.tests/testtitle/src/gpu.rscopied in (so the runtime ande2e.rsare base's): 3 failed,[FAIL] ... CopyMemoryToMemoryX from title heap,failures: 1, with... is not in unified memory - not donefor both the title-heap source and the GPU-view source0xa60000000. The new check fails without the runtime change and passes with it. (My first attempt at this control did not rebuild, because the copied file kept its old mtime and cargo reused the earlier exe; I touched the file, rebuilt, and report only the rebuilt run.)Queue retirement controls, head,
cargo test --locked -p xcl --lib -- <3 names> --nocapture --test-threads=1, run 3 times: 3 passed each time (staged_copy_waits_for_its_own_queue_without_blocking_cpu_writes: independent CPU write 1.1 / 1.3 / 1.6 ms, upload refs 1/2/1, readback0x1234abcd;copy_gpu_view_reads_each_mapping_and_leaves_holes_zero;copy_scratch_budget_counts_resources_until_gpu_completion). The staged-copy test and the scratch-budget test in this form do not exist on the parent, so no parent control was run for them.list_x::andtitle_textures::on the parent: 60 passed, 0 failed.Not tested: the retail title and smoke runs (not allowed here), a release build, a merge with current
main, NVIDIA, a long-held queue wait beyond what the unit tests cover.AI use: Claude Code (Claude Sonnet 5.5) ran the builds and tests and wrote this report; coordinated by Codex (gpt-6.2-sol).
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.