D3D12.X: a copy within one memory window reads through a scratch buffer (#958) #993
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!993
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/993/head"
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?
@zohaiblazuli on GitHub · 2026-11-24 10:04 UTC · original
zohaiblazuli:d3d12x-copy-within-window→main· +251 −4 · 4 files · 2 commits · merged 2026-11-24 13:38 UTCCopyMemoryToMemoryXnow copies through scratch when its source and destination share one unified-memory window. D3D12 needs the window in different states for the read and the write, which produced debug-layer error 538 on the direct copy. Fixes #958.What is in it
list_x.rscaps live and retiring scratch allocations at 64 MiB across the process. Each PC list keeps one buffer. A larger copy in the same recording can use it in chunks. The previous copy path remains available when scratch is unavailable.list_x.rsandreal.rstrack completion on the submitting queue.on_releasedrops ownership, and buffers still referenced by submitted work stay charged until their fences complete. The log counts recorded scratch copies on first use and powers of two.Tested
392dc0con Windows 11 build 26300, Intel Core i5-14600K, NVIDIA RTX 3060 (driver 32.0.16.1742), Rust 1.94.0 MSVC. Debug tests and release smoke runs.cargo test --workspace -- --test-threads=4withRUST_TEST_NOCAPTURE=1reported 742 passes, 0 failures and 41 ignored. The reported passes includegpu_geometry_wave32_prefix_count_over_a_maskandgpu_wave32_program_in_wave64_hardware, which both emittedSKIPPEDfor lack of wave64.Regression run
Not tested
AI use
@dcastell1 on GitHub · 2026-11-24 10:13 UTC · original
Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on
main@02bfd1d(baseline 727 passed, 0 failed, 41 ignored on this box):Same count as the baseline — the change is exercised by the existing coverage (the e2e is updated, not extended) and nothing regresses.
Tree restored afterwards (full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
@ivall on GitHub · 2026-11-24 11:00 UTC · original
Thanks – the fix is right, and the e2e assertion is a good guard. One thing before it can be merged: the scratch buffers' memory is not bounded in practice.
Could you:
list_x::on_releaseis the hook), and replace a list's smaller scratch instead of keeping both once its earlier executions are done – or simply keep one per list,With that I'll run it on a retail title and merge it.
@DavidM1911 on GitHub · 2026-11-24 12:22 UTC · original
Independent verification, merged onto current
main384f7f7locally (clean merge).Machine: Windows 11, Ryzen 9 7900X + RTX 3060 Ti; Rust stable MSVC, debug.
cargo test -p xcl --lib list_x: 24 passed, 0 failed.cargo build --workspace && cargo test -p xcl --test e2e: 3 passed, 0 failed — the e2e title run (which exercises the copy path on the real backend) is green.AI use: test runs by Devin (Cognition, SWE-2); no code changes.
@srcamarda on GitHub · 2026-11-24 12:22 UTC · original
Tested on AMD RDNA3 (RX 7800 XT): head
17fc02aTested
cargo test --workspace -- --test-threads=4on17fc02a: 724 passed, 0 failed, 41 ignored. NoSKIPPEDGPU tests on this adapter.test_title_draws_with_a_root_signature_under_the_debug_layerskipped: Graphics Tools were not installed (nod3d12SDKLayers.dll). ItsSKIPPEDline comes fromeprintln!, which libtest captures, so the run still shows it asok. After installing Graphics Tools I ran it again on its own:cargo test -p xcl --test e2e test_title_draws_with_a_root_signature_under_the_debug_layer: 1 passed. The debug layer reported only id 93 ×3 and id 1046 ×1, the deliberate ones.main47efa2e(releasexcl run … -- --hellowithXCL_D3D12_DEBUG=1):failures: 0, debug layer id 93 ×3, id 1046 ×1 and id 538 ×1 (CopyBufferRegion…D3D12_RESOURCE_STATE_COPY_DEST). So on AMD too, the PR removes the 538 error and nothing else changes.Regression run (retail title 1.0.2.1,
scripts/smoke.ps1 -Seconds 60, the same data folder for both runs)The PR's run: 101 % of
main's frames, the same peak commit, no device removal, no crash. No input was given during the runs.Not tested
Claude Code (Claude Opus 5.5), from runs on the hardware above.
@zohaiblazuli on GitHub · 2026-11-24 12:39 UTC · original · edited 2026-11-24 12:41 UTC
@ivall Thanks for reviewing this. The updated head
392dc0ccaps scratch at 64 MiB across the process, keeps one buffer per command list, and reclaims released buffers after the GPU finishes. The debug-layer test title logged its first scratch copy. The retail smoke run passed and emitted no scratch counter.The PR description has the workspace test results and both smoke runs. Could you approve the fork CI run when you have a chance?
Also, if possible, I’d appreciate the Contributor role on the Discord server. My Discord is
@overtimerumble(Claudenberg). :)@ivall on GitHub · 2026-11-24 13:38 UTC · original
Merged – thanks for the rework: the 64 MiB budget, one buffer per list, release after the GPU and the counter are what I asked for. Two things on top, in
930e8b4:on_creategives up a scratch buffer left at the new list's address by a list whose release was not seen; it would have been taken as the new recording's own, without asking whether the GPU is done with it. With a test that fails without it.Tested on the merged tree:
cargo test --workspace --no-fail-fast -- --test-threads=4: 751 passed, 0 failed, 41 ignored, no SKIPPED (the debug-layer e2e test ran and passed; AMD). In the e2e run the test title's copy went through the scratch buffer. Retail title, 50 s at its menu without input: exit 0, no crash, no device removal, 1353 frames against 1373 onmain, peak process commit 19.2 GB against 17.0 GB – the scratch counter logged nothing in that run, so the path was not taken and the difference is not from it.Not tested: a retail title that takes this path.
@DavidM1911 on GitHub · 2026-11-26 03:32 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