D3D12.X: replace busy copy scratch within budget #1411
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1421"
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 hajduzsolt on 2026-11-24T15:47:17Z.
Runtime fix verified with unit tests and RX 9070 XT smoke run.
What is in it
crates/xcl/src/hle/d3d12x/list_x.rs: retain busy scratch until GPU completion and test replacement and accounting with synthetic D3D12 resources.Tested
cargo test -p xcl --lib copy_scratch -- --test-threads=4: 3 passed, 0 failed.cargo test --workspace -- --test-threads=4 --nocapture: 752 passed, 0 failed, 41 ignored. The reported passes include tests that return early.test_title_draws_with_a_root_signature_under_the_debug_layeranduploads_start_from_each_subresources_state(D3D12 debug layer unavailable).Regression run
main:
PR:
Not tested
AI use
Imported from ivall/xcl. Originally posted by pvfreis on 2026-11-24T16:34:32Z.
Test report for
7124a95392(this PR's head) merged onto main1d027e5c76(git auto-mergedlist_x.rs, no conflict). (Edited after a rerun. The first version covered4c65020ontob7aa9f3: 770 passed, 1 failed, 41 ignored; main 769/1/41, and noted the log line was missing;7124a95added it.) The new test passes on NVIDIA; no other test result changed. I opened #1408. Of its "Expected": a busy scratch moves toreleased, still charged to the budget, and a new one is made within it; the log line when the budget forces the fallback is now there.Tested
cargo build --workspace --locked --offline, thencargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4:1d027e5: 958 passed, 1 failed, 43 ignored1d027e5: 959 passed, 1 failed, 43 ignored. The difference isbusy_copy_scratch_is_retired_when_budget_allows_a_replacement, which passes; the other two copy-scratch tests pass too, and the log has the new warning (emitted once per process) for a request of 67108864 bytesno wave64(16 ingpu::recomp::lower/lower_dxil,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware), 3 refused wave32 per-lane cases inf16_programs_on_the_gpu/f32_programs_on_the_gpu, andheap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)test_title_runs_and_game_folder_is_untouched(e2e,presents0), because these runs are in an isolated non-interactive session whereCreateSwapChainForHwndreturns 0x887A0022.Not tested
1d027e5(689f2dbnow; the commits since touch onlygpu/dxilandgpu/recomp)kickoff_x/copy_memory_xend to end, the debug layer on this pathRun and written with Claude Code (Claude Opus 5.5); counts recomputed from the logs by a second agent (Claude Opus 5.5); text reviewed with Claude Fable 5.2. The runs are real, on the hardware above.
Imported from ivall/xcl. Originally posted by srcamarda on 2026-11-24T16:54:00Z.
Test report for
4c65020merged ontomain2008399: AMD RDNA3, with the debug layer installed; the retail title does not reach the #1408 path in its first 150 sTested
main2008399locally (clean merge, not pushed).cargo test --workspace --no-fail-fast -- --test-threads=4: 752 passed, 0 failed, 41 ignored. NoSKIPPEDlines. The two debug-layer tests your description lists as skipped ran and passed here:test_title_draws_with_a_root_signature_under_the_debug_layer(which asserts no "invalid for use as a source buffer" since #993) anduploads_start_from_each_subresources_state. The three copy-scratch tests pass, includingbusy_copy_scratch_is_retired_when_budget_allows_a_replacement.Retail title under the debug layer
XCL_D3D12_DEBUG=1 XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_RUN_SECONDS=150, Enter (= A) at 30 / 40 / 50 s (title screens into the start of loading). Interleavedmain, this PR,main, this PR.CopyBufferRegionare logged with no cap.CopyBufferRegionstate errors: 0 in all four runs,mainand this PR alike. No device removal or crash; frames shown:main2157 / 2008, this PR 1698 / 2009.The id 538 errors the title does hit (same in both builds, and on
main47efa2ebefore #993; for whoever looks at them, not this PR's):ClearRenderTargetViewon a resource inUNORDERED_ACCESS(also once inCOPY_SOURCE);CopyResourcewith its source inRENDER_TARGET;Drawwith a render target inNON_PIXEL_SHADER_RESOURCE | PIXEL_SHADER_RESOURCE.Not tested
+0x23cf683, #534, comes after these 150 s on this machine).Claude Code (Claude Opus 5.5), from runs on the hardware above.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T17:21:23Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~21 ignored.Thanks!
Imported from ivall/xcl. Originally posted by enderrr9 on 2026-11-24T18:00:31Z.
Test report: NVIDIA, 32-lane waves, head
4c65020Tested
cargo test -p xcl --lib copy_scratch -- --test-threads=4 --nocapture: 3 passed, 0 failed (a_new_list_takes_no_copy_scratch_of_an_earlier_one,busy_copy_scratch_is_retired_when_budget_allows_a_replacement,copy_scratch_budget_counts_resources_until_gpu_completion), none SKIPPEDcargo test --workspace -- --test-threads=4: 752 passed, 0 failed, 41 ignored. SKIPPED:gpu_geometry_wave32_prefix_count_over_a_mask(no wave64),gpu_wave32_program_in_wave64_hardware(no wave64)Not tested
Report written and the tests run with Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by hajduzsolt on 2026-11-24T19:23:35Z.
Thanks for noting the missing diagnostic. Budget-driven scratch refusals now emit a one-time warning before using the in-place fallback, including requests larger than the budget. The existing budget-exhaustion test and
cargo test --workspace -- --test-threads=2passed (708 library tests passed, 21 ignored).Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-26T05:13:07Z.
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
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:41:50Z.
Triage (#1607) – head
7124a95No open or merged PR makes the same change; main's
CopyScratchCache::acquirestill returnsNonewhen the list's scratch is still in flight. #3111 also touches the copy scratch, but only moves the drop outside the lock.No problems found in the diff: the busy scratch moves to
releasedand stays charged until its fence passes, and the budget is checked before the replacement is made.Recommendation: keep open.
AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
Imported from ivall/xcl. Originally posted by fromthemoonx on 2026-12-01T13:27:25Z.
merge-check
base:
b2b1f109d2head:
7124a95392merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2902 passed, 1 failed, 51 ignored (second run; base alone: 2902 passed, 0 failed, 51 ignored); SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 no GPU_UPLOAD heaps), same set as base; failing: not this PR. Run 2:
hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime(left: 2, right: 1at xaudio2.rs:1793) failed once; it passes 3 of 3 alone on both the merge and base, andhle::xaudio2::5 of 5 at 8 threads on both. Run 1: the lib binary was ended with exit code 0x7C10003 byuma_driver::tests::mixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment("coherent window could not be restored"), the known problem #3187 addresses.review: no correctness problem found after reading the whole diff (1 file, +61 -8). A list reset while its scratch is still in flight now moves that scratch to
released(charged until its fence passes) and makes a new one when the budget allows, instead of returningNone; budget refusals warn once.busy_copy_scratch_is_retired_when_budget_allows_a_replacementand the two older copy-scratch tests pass 30 of 30 alone each on this GPU (it creates a real device and fence, not skipped).return None(main's behaviour) fails the new test. Good.list_x::tests::60 runs at --test-threads=8: no copy-scratch test failed.bundle_generations_propagate_and_final_release_runs_outside_lists("final COM Release ran under LISTS") failed 7 of 60 on the merge and 8 of 60 on base (2 of 30 on the merge with the new test skipped), so it is a pre-existing flake, not this PR. One E_OUTOFMEMORY inwrite_buffer_immediate_on_open_existing_heap_visible_to_cpu, a known parallel flake.untracked_submission, whenCreateFence/Signalfails incopy_scratch_submitted) never becomes idle. On main that list keeps its one stuck scratch and getsNone. With this PR each reset moves it toreleased, where it stays charged for good, and a new one is made, so repeated resets can fill the 64 MB budget for every list. Only reached when fencing fails (e.g. a lost device). Keeping the old behaviour whenuntracked_submissionis set would avoid it.performance: not measured here. Up to one extra scratch per list in flight, inside the existing 64 MB budget; copies that used to take the in-place fallback while the scratch was busy now get a scratch.
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)
Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T00:54:03Z.
merge-check claim
head:
7124a95392Imported from ivall/xcl. Originally posted by vasanex on 2026-12-02T01:07:16Z.
merge-check
base:
1c8b551475head:
7124a95392merge: clean (merged tree a0b9a608,
git diff --checkclean)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2910 passed, 0 failed, 51 ignored; SKIPPED: 25 (22 no wave64, 2 no heap windows, 1 cannot disable the driver cache), the same set as on the base; failing: none. Base alone, same machine: 2909 passed, 0 failed, 51 ignored. The new test
busy_copy_scratch_is_retired_when_budget_allows_a_replacementand the two existing copy-scratch tests pass.review: whole diff read (one file, list_x.rs, +61/-8), in the merge result. No blocking finding. Before, a list whose scratch was still in flight on another queue got no scratch (
None, the in-place fallback); now the busy buffer moves toreleased, stays counted inself.bytesuntil its fences are done (collect_released), and a new one is made if the 64 MiB budget has room for both, elseNoneas before. The budget is checked before the move and again before the allocation, so the total cannot pass the cap. The idle and recorded cases are unchanged apart from the indentation. The warning is logged once per process. Small points: the test builds the busy state by hand (recorded = falseplus a fence mark), so the real reset-while-executing path is covered by reasoning only; the once-only warning gives the first request's size, later ones are silent.performance: 60 s smoke of the same title, release, default settings, same machine, one run each. Base
1c8b5514: 1608 frames shown, presents per 2 s (last 3) 60 60 61, 0 device removals, 0 crashes, peak commit 19911 MB. Merge result (local merge commit): 1539 frames shown, 60 60 60, 0 device removals, 0 crashes, peak commit 19677 MB. 96 % of the base's frames with the same rate at the end; I take the difference as start-up spread (one run each), not as an effect. The run logged no copy-scratch warning, so it did not reach the budget. By default the change can hold up to 64 MiB of scratch, the existing cap, where main fell back to the in-place path.verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 3080 10 GB (driver 621.40), AMD Ryzen 9 7950X, Windows 11 Pro 26200, rustc 1.100.0, debug suite and release smoke / Claude Code with Claude Fable 5.2. Run and posted without a human check of each point.
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.