D3D12.X: a copy back after a submission does not wait for the title #1993
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!1993
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1993"
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?
@Ariorh1337 on GitHub · 2026-11-25 00:29 UTC · original
Ariorh1337:sparse/async-readback→main· +1058 −35 · 4 files · 1 commits · openreadback_after_executemakes the sparse queue GPU-wait for the title's queue, then waits on the CPU for the copy back, on the thread that is submitting. A title's queues can wait for work that thread submits next. In the retail title of #505, four compute queues wait for aWrite64on q1 whose list is recorded but not submitted yet. So every such submission waited 5 s for its copy back, and the uploads queued behind it on the sparse queue waited as well (before_executewaiting for ring room). lucsoft hit the same cycle on RDNA3 / Linux and found it was the whole stop there (#505 comment). This PR moves the copies back to queues of their own and makes them asynchronous.Part of #505.
What is in it (one commit,
crates/xcl/src/hle/d3d12x/; about 470 lines of code and 500 of tests)sparse.rs:init, before the device's methods are hooked; made later, a lane's queue is adopted as one of the title's. With all lanes busy, the old path runs.real::create_own_list), asinit's objects are. Made through the adopted device, the list ran XCL's list hooks on the lane's queue, and vkd3d-proton crashed at itsClose(found by St5sz2Jk on RDNA4 / Wine).drain_readbacks): on the next submit, and from a thread that looks every 0.5 ms. Lanes land in their own order, so an older copy back of one lane that lands after a newer one of another leaves the bytes the newer one landed.settle_readbacksruns beforeMap's readback and also waits for a copy whose title work is already done, on the lane's own event (with the sparse state's event, a wait that gave up left a registration that ended a later tile-queue wait early; found by theaustinayers in #2057).XCL_COHERENT_HEAPS=sparse:1024, they never passed 64 MB.real.rs:create_own_list(above). The title's fence observations settle copies back first, and do not show the title its work done until they landed (found by bmjask in review):GetCompletedValuesettles them before it returns.SetEventOnCompletionwith an event gives the fence an event of XCL's own. A thread-pool wait on that event settles them, then sets the title's event.settle_readbacks_trysays whether every copy back whose title work is done landed. When it could not (the sparse state's lock not had, or a copy not finished in time), the thread-pool wait tries again every millisecond before it sets the title's event (10 s at most,WT_EXECUTELONGFUNCTION), andGetCompletedValuegives no more than the value the fence was last seen at with its copies landed (its initial value fromCreateFenceat first). The title's thread is not blocked by this.list_x.rs: the CPU wait ofWait64BitValueX/Wait32BitValueXsettles copies back between its polls. It only tries the sparse state's lock, as the holder can be waiting for work this thread is to submit.sparse.rs, on a WARP device of their own; see below):a_copy_back_does_not_wait_for_the_title_queue: a title queue blocked on a gate copies into a tile. The copy back returns at once and lands once the queue goes on. On the old path it waits 5.0 s.a_copy_back_waits_for_its_own_title_queue: two title queues, the first blocked while the second runs and signals. B's copy lands, A's does not until A ran. With one lane for both queues (what one fence amounted to) it fails:A's dword 0 landed before A's lists ran.an_older_copy_back_does_not_overwrite_a_newer_one.idle_copy_back_buffers_above_the_cap_are_given_back.a_copy_still_running_after_its_title_work_is_waited_for_outside_the_lock: the lane's copy queue stands behind a gate while the title's queue is done; the copy is found without waiting,Drain::Finisheddoes not land it, and it lands once its fence is waited for.a_copy_back_list_of_an_adopted_device_is_not_adopted: on an adopted WARP device, a copy back's list and allocator are not adopted and still reset and close. It fails withoutcreate_own_list.quarantined_tiles_wait_for_copies_back_still_to_run: a tile quarantined while a lane's copy is held behind a gate is not freed until the copy is done. It fails without the lanes' marks.a_title_fence_shows_its_work_done_only_once_copies_back_can_land: an adopted fence, a copy back in flight, the sparse state held by another thread.GetCompletedValuestays at the initial value and the title's event is not set; both come once the state can be had. It fails without the change (the fence's work shows as done before its copies back landed).a_fence_value_goes_past_its_landed_copies_only_once_they_land.gpu_sparse_vram_descriptors_buffers_and_xmemsettles before its CPU reads, as its fence wait is not one of the title's.list_xtests were in the driver inNtGdiDdDDIDestroyAllocation2and the new test was in a D3D12 call behind them, so the gate was never opened. Reproduced in 3 of 3 runs of upipibi's filter before; none hung after, with the tests on WARP (numbers below).Tested
cargo test --workspace --no-fail-fast -- --test-threads=4:0a755f0, onmain06055a7): 1418 passed, 4 failed, 46 ignored;main(06055a7): 1409 passed, 4 failed, 46 ignored.gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_0..3(CreateComputePipelineState0x8007000E).d3d12x::list_x d3d12x::fence_x d3d12x::sparse hle::acphal gpu::fence), capped at 180 s: before the fix 3 of 3 runs hung. Since:3260d403 runs (release), 2 with 62 passed and 1 with a failure inacphal::tests::xapu_connect_returns_oom_and_cleans_up_on_failure, which checks withVirtualQuerythat a freed buffer is free while a test beside it can take the address (it does not touch the sparse code);9a3fe7d3 of 3 (debug), 5 of 5 on the revision before (release), and upipibi's 10 of 10 on an RTX 3070.test_title_draws_with_a_root_signature_under_the_debug_layerfailed while the lanes were made on first use (the test title read 0 for itsKickoffXandMapreadbacks); with the lanes made ininitit passes.69903fc: hang check 10 of 10, and the copy-back tests pass on the RX 9070 XT and an RDNA2 iGPU too, withlane_state()moved to the hardware adapter locally.69903fcin a stack with #2009 and about 20 other PRs onmain50a9fde: no GPU-wait timeout in about 770 s (cold) and 2200 s (warm) of world work; the warm run reached the prologue's movement prompt.Closeis whatcreate_own_listfixes. Three copy-back tests failed there; they pass on native AMD drivers (Chrysana), so that looks like the Wine side. Not re-run on0a755f0.main568e7db+e213d42(this PR before the rebase): through the menus, the first#101and the world's first burst (8192 dispatches) with no copy-back warning, no 5 s wait and no crash. It then stopped on a cold driver build of one 21 MB compute pipeline, not related to this PR.mainb9b6ea6plus open PRs, #1329 and the earlier form of this PR, with the title's two large GPU heaps in the sparse windows): the title reached the in-game HUD and ran 465 s after the first#101. One run, before the lanes.Regression run
scripts/smoke.ps1 -Game <retail title> -Seconds 60(start screen, no input),XCL_HEAP_WINDOWS=1for both, same machine.Not tested
0a755f0: the crash fix is from St5sz2Jk's stack, not re-run there.main+ this PR alone. With the title's heaps in the coherent window (the default), its lists write little into the sparse windows. The smoke run above does not reach the world. The title run above was on568e7db, before the rebase.ID3D12Fence1, or a wait throughWaitForMultipleObjectson an event it shares with another fence. The 0.5 ms thread lands the data there.AI use
🤖 Generated with Claude Code
@CharlyRien on GitHub · 2026-11-25 00:56 UTC · original
A caution from a local change of the same design: with the copy back asynchronous, the shared
rb_fencelets a copy run before its own title queue has run the lists. Reading this diff, the pattern is still there (s.rb_value += 1; queue.Signal(&s.rb_fence, v); q.Wait(&s.rb_fence, v)inafter_execute, onerb_fenceand one counter for every title queue). I have not run this PR.What happened in my tree, which had the same idea (copies back on their own queue, landed by a thread):
rb_fenceonly counts up, and each title queue signals the next value of one counter. A copy issued for queue A at value N is satisfied as soon as queue B has signalled N+1, even if A has not reached its ownSignalyet (A may be standing behind one of the title's waits, which is exactly the case this PR is about). The copy then reads video memory before A's lists ran, the old bytes land in the title's memory, and nothing copies that range again.Wait64BitValueXfallback) and sits out the full 2 s every time: 76 polls, 152 s blocked in one 280 s run, and the compute queues waiting for what that thread would submit next were released by the 5 s watchdog, about twenty per frame.readback 0x5a8 of q1 is already satisfied when issued (rb fence at 0x5a8, set by another queue), then 9.7 s later the CPU wait on a cell in that range times out with the old value while a synchronous copy from video memory at that moment returns the wanted one. Same in all 11 probed timeouts.sparse: the queue has not reached fence valuewaits, at 1.3 – 1.4 frames per second in the world. Details and the table: #1329So it may be worth giving each title queue its own fence here (or checking
drain_readbacks/settle_readbacksagainst the queue's own progress rather thanrb_fence.GetCompletedValue() >= rb_v), and a test with two title queues where the second one signals while the first is still blocked.Setup of the runs above (not this PR):
main9e3831emerged locally with #1288, #1448, #684, #889, #1323, #929, #640, #1326, #1327, #1329 and #1791 (by hand), plus local diagnostics and the local asynchronous copy back;XCL_UMA_SHADOW=1 XCL_HEAP_WINDOWS=1 XCL_NETWORK=0 XCL_ACTIVITY=1, release, warm caches, noXCL_PSO_WAIT_MS. On that path the committed window is a copy in video memory, so the title's sync cells go through these copies back; with the default imported window they may not, and the effect could be smaller there. RTX 3090 24 GB (driver 616.56), Ryzen 9 5950X, Windows 11 22631,TdrDelay30 s.Not tested: this PR itself, current
main, AMD.AI use: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 for the journal and the probe) ran the measurements; I read this PR's diff and drafted the comment.
@futurepro62 on GitHub · 2026-11-25 01:01 UTC · original · edited 2026-11-25 01:12 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
4df0a2d(on its base8e87fc7).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4 --skip heap_window_out_of_memory_falls_back_to_the_switch_form --skip gpu::recomp::lower_dxil::tests::f16_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f32_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::integer_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::f64_programs_on_the_gpu --skip gpu::recomp::lower_dxil::tests::const_and_null_mask_operands_agree_with_hlsl_on_the_gpu --skip gpu::dxil::fuzz_tests: 980 passed, 0 failed, 43 ignored. SKIPPED (no wave64):a_2d_or_3d_group_agrees_with_the_hlsl_path_on_the_gpu,a_per_lane_2d_or_3d_group_runs_on_the_gpu,coalesced_guarded_runs_agree_with_the_hlsl_path_on_the_gpu,cross_lane_reads_agree_with_the_hlsl_path_on_the_gpu,gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware,the_wave64_lowering_agrees_with_the_hlsl_path_on_the_gpu.a_copy_back_does_not_wait_for_the_title_queue.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4 --skip gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1: 990 passed, 0 failed, 45 ignored. SKIPPED:f16_programs_on_the_gpu(f16 arithmetic, wave32, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 arithmetic, wave64, per-lane form: refused (unsupported V_MUL_F16 (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave32, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f16_programs_on_the_gpu(f16 packed, wave64, per-lane form: refused (unsupported V_PK_MUL_F16: VOP3 modifiers (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave32, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),f32_programs_on_the_gpu(f32 conversions, wave64, per-lane form: refused (unsupported V_CVT_F16_F32 (its #1426 semantics differ from the console's))),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).--skipleaves out tests that fail on main7994cd1too, not because of this PR. On NVIDIA:heap_window_out_of_memory_falls_back_to_the_switch_form(#1651), the fourgpu::recomp::lower_dxil::tests::*_programs_on_the_gputests andconst_and_null_mask_operands_agree_with_hlsl_on_the_gpu(follow-up on #1651) fail becauserunner::skip_testturns their skips into failures underXCL_REQUIRE_GPU=mesh, andgpu::dxil::fuzz_testsseeds 70, 545, 1019 and 1507 failCreateComputePipelineStatewithE_OUTOFMEMORYon this card (drivers 616.64 and 621.40). On AMD:fuzz_validate_and_gpu_1fails on seed 540 (res[833]0x7 vs CPU 0x6). The AMD run does not setXCL_REQUIRE_GPU.Not tested
AI use
@raylitebull on GitHub · 2026-11-25 01:12 UTC · original
Code review on
4df0a2d:readback_after_executeontorbq(rb_jobs,rb_pool,RB_PENDING,xcl-sparse-readbackdrain thread,settle_readbacks/settle_readbacks_try) and addinga_copy_back_does_not_wait_for_the_title_queueis well-structured for avoiding submission-thread stalls against a blocked title queue.CIworkflow approved (currently running).@CharlyRien's caution above on the single monotonicrb_fence(s.rb_value += 1; queue.Signal(&s.rb_fence, v); q.Wait(&s.rb_fence, v)) looks real for multi-queue titles — if queue B signalsv + 1while queue A is still gated behind an earlier wait,q.Wait(&s.rb_fence, v)can unblock and read stale VRAM before queue A's copy/write executes. Worth either keying source fences per queue (or tracking per-queue fence progress indrain_readbacks) and adding a 2-queue ordering test.Remaining before merge: Addressing the multi-queue
rb_fenceordering concern,Build and testfinishing green, and an AMD verification pass.@JJAutoCompare on GitHub · 2026-11-25 01:45 UTC · original
PR #1993 verification on STOR-WINLAB
PR head
4df0a2d1d01c101d81d80d46fb9d865fddc4da25was fetched fromorigin(xcl-dev/xcl) and tested in a clean detached checkout. The remote still advertised that head after the run. The assigned slot had no Git checkout, so the source checkout was created underL:\XclTooling\neon-slot-6\source.origin/mainwas86719eec1e9fc4c36c5fb568ec4951fd47a31b88.git merge-tree --write-tree origin/main HEADexited 1 with a content conflict incrates/xcl/src/hle/d3d12x/sparse.rs.Tested
DoublePrecisionFloatShaderOps=0, wave range 8–32. AMD Ryzen 7 3800X, Windows 11 Enterprise Evaluation build 26200.9974.rustc 1.100.0 (0ef1bc386 2026-11-09), unoptimized dev and test profiles, debuginfo and incremental compilation disabled. DXC and DXIL 1.9.2609.5,XCL_ADAPTER=A770. The full-suite log identifies the A770 in the runtime backend.cargo build --workspaceandcargo test --workspace --no-runboth exited 0 outside the shared GPU lock.cargo test -p xcl --lib a_copy_back_does_not_wait_for_the_title_queue -- --show-outputandcargo test -p xcl --lib gpu_sparse_vram_descriptors_buffers_and_xmem -- --show-outputeach reported 1 passed, 0 failed, 0 ignored, and 0 skips under the shared GPU lock. Both passed again in the full suite. The copy-back test creates a default D3D12 device with a WARP fallback and emits no adapter name of its own.One full workspace run exited 101. Libtest reported 965 passed, 26 failed, 45 ignored across 19 test binaries and one doc-test target. The log recorded 26
SKIPPEDmessages across 16 named tests. Libtest can report a pass when a test or subcase skips. Skipped work contributes no coverage.Failures
CreateComputePipelineStatereturned0x80070057in 21 library tests. The four DXIL fuzz failures werefuzz_validate_and_gpu_0(seed 2),fuzz_validate_and_gpu_1(506),fuzz_validate_and_gpu_2(1003), andfuzz_validate_and_gpu_3(1501).doubles_match_cpu,groupshared_barrier_and_atomics_run,gpu_direct_f32_round_modes_dynamic_and_denormals,gpu_direct_f32_round_preserved_denormal_times_inf_is_inf,gpu_direct_f32_round_modes_static,f64_programs_on_the_gpu,gpu_clamp_and_omod_per_instruction,gpu_f64_class_compare,gpu_f64_literal_high_word,gpu_f64_compares_with_nan,gpu_f64_rounding_and_conversions,gpu_f64_roots,gpu_f64_math_random,gpu_frexp_f64_exp_and_mant,gpu_ldexp_f64,gpu_float_compares_random,gpu_rndne_f64.gpu_nonfused_mad_and_mac_prevent_fma_contractionfailed its fused FMA overflow assertion. The output was2139095040, expected1946157055.gpu_ps_image_sample_offset_implicit_lod_between_mipsreturned25.609375for pixel (0,0), expected26.gpu_valu_16_and_64_bitreturned zero in the lane 0v_add_f16high-half preservation check, expected3203351424.gpu_wave64_ps_whole_wave_reductionsreturned[2, 217, 2]for pixel 0, expected[2, 216, 2].test_title_runs_and_game_folder_is_untouchedfailed the test title'sRSSetDepthBiasX(-1000.5)check (#94). The top-right pixel was blue[0, 0, 255, 255]and the check expected green.Skips
Raw logs in
L:\XclTooling\neon-slot-6\tmpincludepr1993-build.log,pr1993-compile-tests.log,pr1993-targeted.log, andpr1993-suite.log.Not tested
This run covered the PR head on STOR-WINLAB. No
maintest baseline, merged-tree run, retail-title smoke run, sample-backed coverage (XCL_SAMPLE_*inputs unset), or additional adapters were tested. The run does not establish which failures reproduce onmain.AI use
T3 Code / Codex (gpt-6.2-sol) ran the build and tests and drafted this report. Coordinator #2 (T3 Code / Antigravity,
gemini-4-neon) verified the counts againstpr1993-suite.logand published this report.@DavidM1911 on GitHub · 2026-11-25 03:42 UTC · original
Verification on RTX 3060 Ti (Windows 11): merge conflict with current
main(crates/xcl/src/hle/d3d12x/sparse.rs) — needs a rebase before it can be tested.@treybertram06 on GitHub · 2026-11-25 01:27 UTC · original · edited 2026-11-25 05:26 UTC
Correction (retracting this report): these four runs are not valid. A test script I had stopped kept running and launched the title in parallel with these runs: each launch ended the other's run, and log copies were overwritten. The fourth row's log actually holds a device removal at 171 s, not "none". I have no clean A/B of #1993 on this machine. I'll post a new one if I rerun it. Sorry for the noise.
Test report for #1993 at head
4df0a2d, as @Ariorh1337 asked on #505: the retail title on an RTX 3080, with and without this PR, at the default coherent window and atXCL_COHERENT_MB=1024. No device removal or crash in any of the four runs. This PR ran at least as well as the base at the default setting, and was within noise at 1024.Tested
main):mainc4d37be+ #1478 + #1702 (its switch left off) + local logging, with a cap that refuses two programs over 8 MB of HLSL. The PR build is the same tree with4df0a2dmerged. The only conflict was insparse.rs, where my logging line sat in the readback code this PR rewrites; I took the PR's side and re-added the logging after its waits.XCL_COHERENT_MBq2, 6 times). There were no readback waits, as expected with the readback queue.Not tested
main+ #1993 alone; more than one run per row;XCL_COHERENT_MBbelow 1024; AMD / Intel.AI use: Claude Code (Claude Opus 5.5) built both trees, ran the runs and wrote this report.
@Dezmonius on GitHub · 2026-11-25 07:16 UTC · original
Independent native Windows test of #1993 (
4df0a2d) adapted locally ontocbc296ab+ #1931 + the same local #1464 and activity counters used in my #1931 report. I resolved two context conflicts insparse.rs, preserving the base's lock helper and its synchronous fallback's internal-wait logging. RTX 5070 / 610.88, i7-7700K, 32 GiB RAM, Windows 10 19045, Rust 1.100.0 release. The pair used direct DXIL, offline Series X, the same scripted input, cache location, DRED and wait settings (1000ms/pipeline and500ms/frame). The #1993 run was second.Both stopped at world loading. The later run logged no asynchronous-copy timeout. In both runs the queue watchdog eventually released waits for a submitted producer fence whose completion was one value behind. This pair did not reproduce a reduction in queue timeouts or prevent the title error. It does not isolate or disprove the readback cycle addressed in the PR.
On the adapted tree,
a_copy_back_does_not_wait_for_the_title_queueandgpu_sparse_vram_descriptors_buffers_and_xmemboth passed, with no skips reported. Full suite not run. No game assets or raw logs attached. AI-assisted (OpenAI Codex, GPT-6).@upipibi on GitHub · 2026-11-25 09:25 UTC · original
A parallel-test hang this PR's change brings in, found through #2057, which carries it as
cbba2d9d(same title and diff as this PR's4df0a2d). RTX 3070 (Ampere, driver 616.56, Windows 11, 32 logical CPUs). tiagonleal's filter on #2057, release, default test threads, each run capped at 180 s:cargo test --release -p xcl --lib -- d3d12x::list_x d3d12x::fence_x d3d12x::sparse hle::acphal gpu::fence.A first-parent bisect of #2057 named
cbba2d9d. Checked against its parent, 3 runs each, every run holding the GPU alone:4de1452d(parent)cbba2d9d(this change)cbba2d9d,--skip ...a_copy_back_does_not_wait_for_the_title_queuecbba2d9d,a_copy_back_does_not_wait_for_the_title_queuealoneIn the hung runs, the new test and older
list_xtests were still running after 60 s:cross_queue_cycle_and_same_queue_fifo_do_not_deadlock,mid_list_write64_wait64_split_avoids_cycle_and_reuses_spares,write_buffer_immediate_on_open_existing_heap_visible_to_cpu,cross_queue_wait64_before_signal_does_not_deadlock_submit_thread. So neither the change without its new test nor the test alone hangs; it takes the new test running in parallel with the other queue tests in one process. That fits the earlier reports here, where the test passed alone (JJAutoCompare, Dezmonius) and in a debug suite (futurepro62). A possible cause is CharlyRien's caution about the sharedrb_fence(7149051542); I haven't verified that.On #2057 the same hang shows on all three heads (
41303e4,f7e08e6,4df1e6e, 3 of 3 runs each) and not onmain568e7db(0 of 3).AI-assisted (Claude Code). Synthetic tests only.
@Ariorh1337 on GitHub · 2026-11-25 10:48 UTC · original
@CharlyRien thanks, you were right:
rb_fenceand its counter were shared by all title queues, so a later signal on another queue let a copy back start before its own queue's lists ran. Fixed in9a3fe7d(rebased ontomain568e7db):a_copy_back_waits_for_its_own_title_queue: two title queues, the first blocked on a gate while the second runs and signals. With one lane for both (what the old code amounted to) it fails withA's dword 0 landed before A's lists ran; with the fix it passes. Plusan_older_copy_back_does_not_overwrite_a_newer_onefor the landing order.@upipibi thanks for the bisect and the numbers. I reproduced the hang (3 of 3 runs of your filter). Thread dumps showed three
list_xtests in the driver inNtGdiDdDDIDestroyAllocation2, and the new test stuck in a D3D12 call behind them. Its title queue was blocked on purpose, on the GPU's device that every test in the process shares, and the thread that was to open it never got out of the driver. The copy-back tests now run on a WARP device of their own. Also,Wait64BitValueX's CPU wait now only tries the sparse state's lock between its polls, instead of waiting for it. With that, no run of your filter hung: 3 of 3 on9a3fe7dand 5 of 5 on the revision before it, 61 passed each.@treybertram06, @futurepro62, @JJAutoCompare, @Dezmonius: thanks for the runs.
@lucsoft could you give the new head a run on RDNA3 when you have time? An AMD pass is the last thing raylitebull asked for.
Tested on
9a3fe7d(RTX 5090, driver 32.0.16.1692, Windows 11 26300, DXC 1.9.2609.5, debug):cargo test --workspace --no-fail-fast -- --test-threads=41153 passed, 4 failed, 46 ignored;main568e7db1150 passed, 4 failed, 46 ignored. The 4 failures are the samefuzz_validate_and_gpu_0..3on both, and both skip the same 25. New smoke blocks are in the description.Two more changes came out of the full run and of #2057:
init, before the device's methods are hooked. Made on first use, a lane's queue was adopted as one of the title's, and the e2e title under the debug layer read 0 for itsKickoffXandMapreadbacks;b5e8baf) that a wait that gave up on the shared event left a registration behind, which ended a later tile-queue wait early. Thanks.AI use: Claude Code (Claude Opus 5.5) wrote the fix and the tests, ran them and drafted this reply.
@raylitebull on GitHub · 2026-11-25 11:00 UTC · original
Code review on
9a3fe7d(crates/xcl/src/hle/d3d12x/{sparse,real,list_x}.rs,crates/xcl/src/gpu/recomp/tests.rs):RbLanequeues with monotonically increasing per-lanesrc/donefences cleanly prevent one blocked title queue from holding back copies for other queues, whilerb_landedsequence tracking prevents an older lane's copy-back from overwriting bytes already landed by a newer lane.settle_readbacks_tryacrossFence::GetCompletedValue,Fence::SetEventOnCompletion(viaWT_EXECUTEONLYONCEwrapper event andUnregisterWaitEx(..., INVALID_HANDLE_VALUE)cleanup on failure), andPendingWaitensures title fence observations observe landed bytes without holdingSTATEacross driver waits, and the WARP-isolatedlane_statetests address the earlier shared-device parallel hang.45598142803).Remaining before merge:
Build and test+PR descriptiongreen, plus independent AMD and secondary NVIDIA verification on9a3fe7d.@Ariorh1337 on GitHub · 2026-11-25 11:05 UTC · original
@Kalmarv I should have found #433 before opening this: it is older and goes at the same cycle (a copy back after
ExecuteCommandListswaiting for a title queue that a later submit releases), and it also drops the sharedrb_fence. Sorry for the overlap. How the two differ, as far as I read #433 atc20dd22:main, unless the queue has a wait that has not completed or an earlier copy back has not landed; then a worker lands itGetCompletedValue/SetEventOnCompletionhooks,Wait64BitValueX's CPU wait,Map, the next submit, a 0.5 ms threadID3D12Fence1,WaitForMultipleObjectson a shared event)So #433 keeps
main's guarantee in the common case and goes asynchronous only wheremainhangs; #1993 is asynchronous always and leans on the fence hooks. The case that made me write #1993 is the heavy one: with the title's big GPU heaps in the sparse windows (#2009), almost every submit of the retail title writes sparse memory, and every copy back waiting in the call was the stop.I don't want two PRs for one problem in the review queue. Two ways I see:
XCL_COHERENT_HEAPS=sparse:1024first (the case with the most readbacks) and post the A/B here and on #433, and we keep the one that holds up.@raylitebull which would you prefer?
AI use: Claude Code (Claude Opus 5.5) compared the two PRs and drafted this.
@Kalmarv on GitHub · 2026-11-25 11:10 UTC · original
Thanks for the comparison. One thing for the A/B: #433 conflicts with current
mainand I haven't rebased it, soc20dd22only runs on its old base. If you want both on today'smain, #1993 is the one that's ready. I have no objection to keeping whichever form holds up on the heavy-readback case. If it's #433's, I'll rebase it; tell me here.AI use: Claude Code (Claude Opus 5.5) wrote this reply.
@lucsoft on GitHub · 2026-11-25 11:15 UTC · original
RDNA3 / Linux run of
9a3fe7d: no GPU wait was released in 700 s, with the watchdog at 5 s. The fence value going backwards that I saw before is still there, but it is at a coherent-window address, so the copies back can't be what writes it.Setup:
main568e7db+ this PR at9a3fe7d+ #2009 at783ac15+ the rest of my stack from #505:b8b1f49reverted;4df0a2dwas taken out.XCL_HEAP_WINDOWS=1 XCL_COHERENT_MB=1024 XCL_SPARSE_WAIT_MS=100 XCL_GPU_WAIT_TIMEOUT_MS=5000 XCL_COHERENT_HEAPS=sparse:1024 XCL_GPU_CULPRIT=1. Warm caches. Retail 1.0.2.1. One run.The run:
#101at 370.8 s.did not complete withinlines in the whole run, withXCL_GPU_WAIT_TIMEOUT_MS=5000.Wait64BitValueXtimeouts (2 s each), all on the same cell0x42437fe18:0x12450x123c0x1246,0x12450x12480x122d0x1249,0x12480x12890x12850x128a,0x12890x128d0x128b0x128e,0x128dThe value going backwards:
0x123cto0x122d, 15 steps back, while the queue fence moved forward.4df0a2d, reached through #2009) the same thing happened on another cell:0x42437f998went0x16ac→0x16ab.0x400000000, 1024 MB), not in a sparse window, so no copy back writes them.cpu_writesworker per queue). Two workers writing the same cell out of order is my next suspect. I haven't checked that yet.How the run ended: at ~700 s a compute dispatch on a vkd3d queue never finished.
ring comp_1.2.1 timeout, a queue reset, the same job timed out again, then MES failed and a mode1 reset followed.Not tested:
AI use: Claude Code (Claude Opus 5.5) built the tree, read the logs and drafted this comment. The run was real, on the hardware above.
@upipibi on GitHub · 2026-11-25 11:30 UTC · original · edited 2026-11-25 11:52 UTC
@Ariorh1337 Re-run of the hang check at
9a3fe7d, same RTX 3070 and the same filter as before (cargo test --release -p xcl --lib -- d3d12x::list_x d3d12x::fence_x d3d12x::sparse hle::acphal gpu::fence, default threads, 180 s cap, each run holding the GPU alone):cbba2d9d(this change as carried in #2057, before the fix)9a3fe7dCounted by script: if the hangs were spread at random over the 13 runs, the chance of all of them landing on the old commit is about 4%. So on this card
9a3fe7das a whole removes the parallel-test hang. I haven't separated its parts (the per-queuerb_fencelanes, the WARP device and the lock changes), so this doesn't say which one does it (edited: I first credited therb_fencelanes alone).AI-assisted (Claude Code). Synthetic tests only.
@Ariorh1337 on GitHub · 2026-11-25 13:29 UTC · original
@lucsoft thanks for the thread dump and for running
9a3fe7don RDNA3. You were right:settle_readbacks_tryonly tried the lock, but once it had it,drain_readbacks(TitleDone)could wait up to 5 s per lane withSTATEheld, insidefence_wait_fired. With the GPU stalled, the submit thread then stood behind it.Fixed in
3260d40. Under the lock,settle_readbacks_trynow only lands the copies that are done and notes those whose title work is done but whose copy still runs. It lets the lock go, waits for those (5 s at most, on an event of the thread's own), then takes the lock briefly again to land them. OnlyMap's readback (readback_now) still waits with the lock held, as it copies with it held anyway. New testa_copy_still_running_after_its_title_work_is_waited_for_outside_the_lock: the lane's copy queue stands behind a gate while the title's queue is done. The copy is found without waiting,Drain::Finisheddoes not land it, and it lands once its fence is waited for.Tested on
3260d40(RTX 5090, driver 32.0.16.1692, Windows 11 26300, DXC 1.9.2609.5, debug):cargo test --workspace --no-fail-fast -- --test-threads=41154 passed, 4 failed, 46 ignored (main568e7db: 1150, the same 4fuzz_validate_and_gpu_0..3failures and the same 25 SKIPPED). upipibi's filter: 3 runs, 2 with 62 passed and 1 with a failure inacphal::tests::xapu_connect_returns_oom_and_cleans_up_on_failure. That test checks withVirtualQuerythat a freed buffer is free, and a test running beside it had taken the address already (MEM_COMMIT, 4096). It does not touch the sparse code. e2e: 3 passed.AI use: Claude Code (Claude Opus 5.5) wrote the fix and the test, ran them and drafted this.
@Natakout on GitHub · 2026-11-25 13:52 UTC · original
Test report: RTX 3060 / Windows. In 2 runs out of 2, the title keeps presenting about 30 s past the first
#101with this PR, against 2-4 s without it in 6 runs. The stall comes later and is not gone.Setup: RTX 3060 12 GB (NVIDIA 621.14), i9-13900K, 64 GB RAM, Windows 11 (10.0.26200), release. Retail 1.0.2.1,
XCL_NETWORK=0,XCL_DIRECT_DXIL=1(except the twomainruns marked HLSL), A pressed every 4 s from 12 to 120 s, 480 s per run, caches warm from earlier runs.Trees:
main568e7db, or568e7db+ #2301 (that PR only changes which form one compute pipeline compiles in, and the stall is the same with or without it);568e7db+ #2301 + this PR at9a3fe7d(clean merge).#101did not complete within 5000 msmainHLSL 1mainHLSL 2maindirect 1(A seventh run without the PR had its presents stop just before the first
#101call.)#101, right aftersplit command list (type 2) around mid-list Wait after Write64 (#1)and oneWait64BitValueX … bridged to GPU queue.Wait (waiter=q0/ty2, prod=qNone/…; wait-before-signal).#101name their producer: seven waits at 345.08–345.13 s,waiter=q0/q2/q3/q4,prod=qSome(1), all>= 0x2656. The title presents about 60 frames per 2 s until the end. Then the same pattern as without the PR ends it: at 345.30 s,split command list … (#1), and at 345.72 s,Wait64BitValueX at 0x704180138 >= 0x2656 bridged to GPU queue.Wait (waiter=q2/ty2, prod=qNone/tySome(0); wait-before-signal). Presents stop at 348.1 s.Not tested: AMD; cold caches; more than two runs with the PR;
XCL_COHERENT_MBorXCL_HEAP_WINDOWSother than the defaults.AI use: Claude (claude-opus-5-5, through Hermes) ran the builds and title runs on the hardware above over SSH, read the logs and the minidump, and wrote this report.
@upipibi on GitHub · 2026-11-25 13:57 UTC · original
@Ariorh1337 The same hang check at
3260d40, on the same RTX 3070 (616.56) with the same filter as before (cargo test --release -p xcl --lib -- d3d12x::list_x d3d12x::fence_x d3d12x::sparse hle::acphal gpu::fence, default threads, 180 s cap, each run holding the GPU alone):3260d40acphal::tests::xapu_connect_returns_oom_and_cleans_up_on_failurepassed in all 10. That fits your reading of the one failure you saw, a neighbouring test taking the freed address, as a rare race rather than something this change does. Ten passes here don't show it can't happen, though.This covers only the synthetic filter, not the title stall Natakout describes above.
AI-assisted (Claude Code). Synthetic tests only.
@tiagonleal on GitHub · 2026-11-25 14:09 UTC · original
Hang check at
3260d40cf015966cf425dd42664e36f4c9aeba6fon NVIDIA RTX 5070 Ti (Blackwell, Windows 11): 10 runs, no hangTested
3260d40cf015966cf425dd42664e36f4c9aeba6f(git rev-parse HEADof a clean detached worktree, no local changes, built as is). The PR was open and the head unchanged when I started and again before writing this. Not merged withmain.cargo test --release -p xcl --lib -- d3d12x::list_x d3d12x::fence_x d3d12x::sparse hle::acphal gpu::fence.acphal::tests::xapu_connect_returns_oom_and_cleans_up_on_failurefailure that was seen once on an RTX 5090 in any of the 10 runs.SKIPPEDlines in the output.Not tested
cargo test --workspace, the debug profile, the e2e test, other test targets; the retail game andxcl-smoke.Run and written with Claude Code (Claude Fable 5.2 and Claude Sonnet 5.5).
@Ariorh1337 on GitHub · 2026-11-25 15:58 UTC · original
Thanks for the runs on
3260d40: @Natakout (RTX 3060, presenting ~30 s past the first#101against 2–4 s without it), @upipibi (RTX 3070, 10 of 10) and @tiagonleal (RTX 5070 Ti, 10 of 10). @Chrysana, thanks for the AMD pass, the hang check (10 of 10) and the title runs (no copy-back timeout with it, the stop after#101the same as onmainon the default path).On the memory in your second run: this PR can add to it there. Each copy back holds a readback buffer (64 KiB to 16 MiB, in system memory, so it counts toward commit) until it lands. After the first
#101the title's queues stand still, so the copies of each submit stay in flight, one buffer each. Once they land the buffers go back to a pool, and the pool never shrinks. On the start screen that is about 1.9 GB of peak commit in my smoke runs (17.0 against 15.1 GB onmain); with stalled queues it can be more. I'll cap the pool and give buffers back above the cap, measure the commit with the queues stalled after#101, and push it here.AI use: Claude Code (Claude Opus 5.5) read the code and drafted this.
@Ariorh1337 on GitHub · 2026-11-25 16:27 UTC · original
@Chrysana the follow-up I promised, in
69903fc: idle copy-back buffers above 256 MB are now given back (largest first; testidle_copy_back_buffers_above_the_cap_are_given_back), and each time the buffers pass another doubling from 64 MB their size is logged.What that log shows: in a run of the retail title on
main06c9f55+ this PR + #2009 (XCL_COHERENT_HEAPS=sparse:1024, RTX 5090), through the menus, the world load and the burst after the first#101up to the removal, the copy-back buffers (idle and in flight together) never passed 64 MB. The process's peak commit in that run was 37.8 GB. So they are not where your extra ~4.5 GB came from. After#101your runs submit nothing, and without submits no new copies are made. The start-screen smoke commit is the same with the cap as before (17.0 GB, against 15.1–16.6 GB in today'smainruns here).@Royalflamejlh thanks for the Linux / vkd3d-proton pairs: no change in where presents stop, no 5 s wait run out and no hang in the tests, which is what this PR should do where the cycle doesn't come up.
Tested on
69903fc(RTX 5090, debug):cargo test --workspace --no-fail-fast -- --test-threads=41155 passed, 4 failed, 46 ignored (the same 4fuzz_validate_and_gpu_0..3and 25 SKIPPED as onmain). New smoke blocks are in the description.AI use: Claude Code (Claude Opus 5.5) wrote the change and the test, ran them and drafted this.
@Royalflamejlh on GitHub · 2026-11-25 16:20 UTC · original · edited 2026-11-25 16:32 UTC
Linux (Wine + vkd3d-proton) + NVIDIA, the title, 4 runs with #1993 and 4 without: no change in where presents stop, and no 5 s wait ran out (no
sparse: the queue has not reached fence value,sparse: a copy back has not finishedordid not complete withinline). Shorter waits are not logged. All 8 stopped presenting by 85 s and ran to XCL's 120 s limit without a crash or device removal.Setup:
main06c9f55+ #684e56dbc3+ #19933260d40(local merge8944100), againstmain06c9f55+ #684 (local merge99355ee), in turn. RTX 4070 12 GB (615.71.09), Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, release, Series X, default shader path, first-run screens completed once and no story progress, A pressed at 16.0 to 16.5 s,XCL_ACTIVITY=1 XCL_PSO_PRELOAD=0.main+ #684 (4 runs, in run order)#101#101to the last presentqueue.Waitreleases, faults#101in 1 run of each tree, and at most 4 s in the other 3. So Natakout's gap of about 30 s (RTX 3060,9a3fe7d,XCL_DIRECT_DXIL=1) did not come here, as in Chrysana's RDNA4 runs on the default path.prod=qNone: the four-queue wait on q1 from the description did not appear. As in Natakout's runs, the firstsplit … (#1)and… bridged … wait-before-signalcame within about 3 s of the last present, in both trees.list_x,fence_x,sparse,acphal,gpu::fence, Wine, 4 threads, 1 run each): 67 passed, 1 ignored with #1993, the four new ones included; 63 and 1 without; no hang.Not tested: the cycle the description is about;
XCL_DIRECT_DXIL=1; the rest of the suite; Windows; AMD and Intel.AI use: Claude Code (Claude Opus 5.5) ran the title and the tests and wrote this comment.
Posted without review by a person: the account owner was away and reads replies later.
Edited: the line above had been added 13 times by a posting script that retried while GitHub was refusing writes; 12 copies removed, nothing else changed.
@Chrysana on GitHub · 2026-11-25 19:02 UTC · original
@Ariorh1337 I've updated / edited my comment with some further tests
@lucsoft on GitHub · 2026-11-25 19:28 UTC · original
Test report: Linux / RADV, RX 7800 XT (RDNA3). Head
69903fc, in a stack with #2009. Two runs with no GPU-wait timeout, the warm one into gameplay. This follows up my earlier report on9a3fe7dand the lock report that led to3260d40.main50a9fdeplus about 20 other PRs. The full list is in #505. #1044's 10 ms readback andsettle_readbacks_tryboth run in the CPU wait loop.XCL_COHERENT_HEAPS=sparse:1024 XCL_SPARSE_WAIT_MS=100 XCL_GPU_WAIT_TIMEOUT_MS=5000.did not complete withinlines in both runs. That covers about 770 s of world work in the cold run and about 2200 s in the warm one.STATElock.568e7dbto50a9fde.AI use: Claude Code (Claude Opus 5.5) ran the analysis and drafted this. The runs were real, on the hardware above.
@Ariorh1337 on GitHub · 2026-11-25 19:54 UTC · original
@St5sz2Jk thanks, your reading of the stack was right. Fixed in
e8d597b, which is now rebased ontomain06055a7.rb_jobmade each copy back's allocator and list throughself.devafter the device had been adopted. So the list was adopted too, and itsReset,CopyBufferRegionandClosewent through XCL's list hooks (cl_close, …). Those hooks are meant for the title's lists, and here the list was submitted on the lane's own queue, which isn't adopted. Onmainthis couldn't happen, because its one readback list is made ininit, before the hooks. Nowreal::create_own_listmakes the allocator and the list with the device's own methods, past the hooks, the same wayinit's objects are made. Test:a_copy_back_list_of_an_adopted_device_is_not_adopted. It fails without the fix.The rebase brought #2345's quarantine in. Its tiles now also wait for copies back still to run on a lane, since those read the windows after the title's work. Test:
quarantined_tiles_wait_for_copies_back_still_to_run.@Chrysana thanks for running the copy-back tests on the RX 9070 XT and the iGPU. Since they pass on native AMD drivers, St5sz2Jk's three test failures look like the Wine side or #871, as you say. @St5sz2Jk, if you can run
cargo test -p xcl --lib sparse::testson this PR without #871, that would tell which one. What doesEnumWarpAdaptergive under Wine there?Tested on
e8d597b(RTX 5090, Windows 11 26300, debug):cargo test --workspace --no-fail-fast -- --test-threads=4gives 1416 passed, 4 failed, 46 ignored, against 1409 passed, 4 failed, 46 ignored onmain06055a7. The 4 failures (fuzz_validate_and_gpu_0..3) and the SKIPPED tests are the same on both. New smoke blocks are in the description. Not tested: Linux / Wine / AMD (I have no such machine).AI use: Claude Code (Claude Opus 5.5) found the cause from the stack, wrote the fix, the rebase and the tests, ran them and drafted this.
@Chrysana on GitHub · 2026-11-25 15:48 UTC · original · edited 2026-11-25 20:55 UTC
RDNA4 / Windows runs of
e8d597b, for "Linux / Wine / AMD" under Not tested (this comment first covered3260d40, then69903fc; those results are folded below). One8d597bthe hang check is clean (10 of 10), all seven copy-back tests pass on the RX 9070 XT and the RDNA2 iGPU (both new ones included), the suite matchesmain06055a7except for the seven new tests, and in the title the copy-back buffers stay under 64 MB. One title run ended in a fail-fast at the exact moment it hit my 33 GB commit limit; details below.Setup: AMD Radeon RX 9070 XT 16 GB (RDNA4), driver 32.0.32015.2008; Ryzen 7 9800X3D (its Radeon iGPU is RDNA2); 31 GB RAM; Windows 11 26200.9974; rustc 1.100.0 MSVC.
e8d597bas pushed and its basemain06055a7, each in its own checkout and target folder.Hang check (upipibi's filter, release, 180 s cap): 10 runs, 0 hung, 0 failed. Each run: 76 passed, 0 failed, 1 ignored, no SKIPPED, 0.42–0.57 s. The filter now matches 76 tests, against 63 on
69903fc, after the rebase.Suite (RX 9070 XT, debug,
cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4):e8d597bmain06055a7The 2 failures are the same on both:
fuzz_validate_and_gpu_1(seed 722,res[30]GPU 0x1 vs CPU 0x7fffffff) andfuzz_validate_and_gpu_3(seed 1599,res[193]GPU 0x1 vs CPU 0x0). These are the AMD seeds of #2115.The copy-back tests on AMD hardware, with the same local, test-only change as before.
lane_state()takes a hardware adapter by index instead of callingEnumWarpAdapter, which on Windows means the CPU. Each test ran alone in its own process, 3 rounds per device, 120 s cap: 63 of 63 pass.a_copy_back_does_not_wait_for_the_title_queuea_copy_back_waits_for_its_own_title_queuea_copy_still_running_after_its_title_work_is_waited_for_outside_the_lockan_older_copy_back_does_not_overwrite_a_newer_oneidle_copy_back_buffers_above_the_cap_are_given_backa_copy_back_list_of_an_adopted_device_is_not_adopted(new)quarantined_tiles_wait_for_copies_back_still_to_run(new)Title, two 200 s runs per side (release; retail title 1.0.2.1 with first-run setup done;
XCL_NETWORK=0 XCL_ACTIVITY=1; A every 4 s from 12 to 120 s; noXCL_DIRECT_DXIL). To keep the rest of this 31 GB machine safe, each run went in a Windows job object with a 33 GB commit limit for all the title's processes. Without it, a run that grows can take other programs down with it (see the memory section below).#101wait-before-signallinesmain1e8d597b1>= 0x75a, 106.4 s)0xc0000409at ~180.4 se8d597b2main2sparse: copy-back buffersline (under 64 MB), noa copy back has not finished 5 s after …, nothe queue has not reached fence value … after 5 s, noClose →failure, no device removal, 0 frame-event wait timeouts.main, as before. The onemainrun without it reached#101later.e8d597brun logged 33,530 MB committed at 180.1 s and ended at ~180.4 s, with no exception or exit line from XCL andcrash: nullinreport.json. It looks like an allocation failing at the job's limit. A Rust allocation failure ends the process with0xc0000409.mainreached the same limit in both of its runs and went on, with the driver refusing compiles instead. The seconde8d597brun never reached the limit and ran the full 200 s. With one hit at the limit per side, I can't tell whether this PR makes a failure there more likely, or which allocation it was. Note that my3260d40run in the section below also ended this way at its memory limit, whilemaindidn't. If it's useful, I can run more at the limit.Not tested
AI use
Earlier results on
69903fc: hang check, the copy-back tests on AMD, a 140 s title run, and the memory correctionSetup: AMD Radeon RX 9070 XT 16 GB (RDNA4), driver 32.0.32015.2008, Ryzen 7 9800X3D (its Radeon iGPU is RDNA2), 31 GB RAM, Windows 11 26200.9974, rustc 1.100.0 MSVC. Retail title 1.0.2.1 with first-run setup done,
XCL_NETWORK=0 XCL_ACTIVITY=1, A pressed every 4 s from 12 to 120 s, noXCL_DIRECT_DXIL. Title build:main06c9f55+69903fc(local merge, no conflicts), release.Hang check (upipibi's filter, on
69903fcas pushed, release):cargo test --release -p xcl --lib -- d3d12x::list_x d3d12x::fence_x d3d12x::sparse hle::acphal gpu::fence, 180 s cap: 10 runs, 0 hung, 0 failed. Each: 63 passed, 0 failed, 1 ignored, no SKIPPED, 0.38–0.42 s.The copy-back tests on AMD hardware.
lane_state()creates its device on WARP. So on Windows these tests run on the CPU and never reach an AMD GPU, and under Wine the "WARP" adapter is whatever Wine supplies. To test the AMD side, I made a local, test-only change (not for this PR):lane_state()takes a hardware adapter by index instead of callingEnumWarpAdapter. Each test ran alone in its own process (cargo test -p xcl --lib -- --exact …, debug), 3 rounds per device, 120 s cap:a_copy_back_does_not_wait_for_the_title_queuea_copy_back_waits_for_its_own_title_queuea_copy_still_running_after_its_title_work_is_waited_for_outside_the_lockan_older_copy_back_does_not_overwrite_a_newer_oneidle_copy_back_buffers_above_the_cap_are_given_backOn the AMD devices each test took 0.16–0.24 s. The failures St5sz2Jk sees (dword 0 left at
0, and one test with no result) don't come up on native AMD drivers under Windows. That points at the Wine / vkd3d-proton side or #871's changes, not at RDNA4. I haven't looked into theird3d12core.dllcrash.Title, one 140 s run of
69903fc(stopped at 140 s on purpose; see the memory section):#101at 106.2 s, last presents in the 2 s window ending 108.1 s, none after. The same as3260d40andmain.Wait64BitValueX … bridged to GPU queue.Wait (waiter=q0/q2/q3/q4 …, prod=qSome(1) …; wait-before-signal)lines (>= 0x76athis time) appear at 107.6–107.8 s, as before.sparse: copy-back buffersline, so the copy-back buffers stayed under 64 MB through 140 s. Also noa copy back has not finished 5 s after …, nono readback buffer, no device removal, and 0 frame-event wait timeouts.Memory: the correction. Each run logs
memory: … MB committed by the processevery 2 s, with XCL's own pools broken out. I went back through my3260d40runs with that line:mainrun: 26.4 → 32.9 → 35.5 → 40.5 GB at 100 / 120 / 140 / 160 s, and 44.3 GB at 174 s. The warm run with this PR: 25.8 → 32.6 → 35.3 → 40.6 GB, and also 44.3 GB at 174 s. My earlier "mainreached 40.5 GB" stopped reading too early.95cc13288a27a96e(ActivateRays, 2,420,640 B of direct DXIL). Its driver compile starts at 107–111 s in every run that grows like this:main, warm0x8007000eat 177.5 s, after 69 s in the driver3260d40, warm0x8007000e0xc0000409at ~183 s3260d40, thread-dump run69903fc(this run)3260d40, the run beforemain, coldSo
mainand this PR behave the same here.maingot through because the driver gave up on that compile after 69 s, and 12.7 GB went within 2 s. The run with this PR ran out of memory first: the driver refused another compile, and the fail-fast came 2 s later. On this 31 GB machine, commit grows ~16 GB while that pipeline compiles. That belongs in #1598, which names this record as the remaining big program (measured on NVIDIA) and lists AMD as not tested. I'll put the numbers there.Earlier results on
3260d40(title:main06c9f55against the local merge onto it, 300 s runs)#101mainmain0xc0000409at ~183 s (see the memory section)3260d40: 10 runs, 0 hung, 0 failed (62 passed each).did not complete withinand no frame-event wait timeout in any run. With this PR,sparse: a copy back has not finished 5 s after the title's work it followsis never logged.#101, submits and DirectStorage requests drop to 0 in every run. A few draws and dispatches are still recorded but not submitted.mainand this PR log the eightwait-before-signallines for q0/q2/q3/q4 on q1 (>= 0x7a0, cells0x8416ff68–0x8416ffd8) within 2 s of#101. Nothing releases them before the end of the run.XCL_THREAD_DUMP_AT=125,135): the title's main thread is in+0x23cf735in both dumps (next to #846's+0x23cf683), about twenty title workers are idle at+0x221c3c2, and no title thread is inside an XCL D3D12 call. That fits a wait for GPU work, not a bind or a copy back.mainrun is held by compiles instead (binds wait 159–198 s at the huge-compile gate) and never reaches the q1 wait.XCL_DIRECT_DXIL=1; mine used the default path.@Chrysana on GitHub · 2026-11-25 20:55 UTC · original
@Ariorh1337 Added more to my original comment again for you
@Ariorh1337 on GitHub · 2026-11-25 21:16 UTC · original
@bmjask thanks, that was a real gap. Fixed in
0a755f0.settle_readbacks_trynow says whether every copy back whose title work is done has landed. It returns false when the sparse state's lock couldn't be had, or when such a copy didn't finish in time. The fence hooks only show completion after it returns true:SetEventOnCompletion: the thread-pool wait tries again every millisecond and sets the title's event only once the copies landed (settle_readbacks_until_landed, 10 s at most, registered withWT_EXECUTELONGFUNCTION). That runs on a pool thread, which can wait. The blocking form (null event) does the same after its wait.GetCompletedValue: while the copies can't land, it returns the value the fence was last seen at with its copies landed. That starts at its initial value fromCreateFence, and is never above the fence itself. The title's thread isn't blocked: it looks again, so a holder of the state that waits for this thread's next submit can go on, which was the reason the lock is only tried.Tests:
a_title_fence_shows_its_work_done_only_once_copies_back_can_landuses an adopted WARP device and fence, with a copy back in flight and the sparse state held by another thread.GetCompletedValuestays at the initial value and the title's event isn't set within 300 ms. Both come once the state can be had. Without the fix it fails atthe fence's work shows as done before its copies back landed.a_fence_value_goes_past_its_landed_copies_only_once_they_landcovers the value rule.Tested on
0a755f0(RTX 5090, Windows 11 26300, debug):cargo test --workspace --no-fail-fast -- --test-threads=41418 passed, 4 failed, 46 ignored, against 1409 passed, 4 failed, 46 ignored onmain06055a7; the same 4 failures (fuzz_validate_and_gpu_0..3) and SKIPPED tests on both. New smoke blocks are in the description.@Chrysana thanks for the
e8d597bruns. About the fail-fast at your 33 GB limit: the copy-back buffers are made through the driver, and a refused one is logged asno readback bufferand left out, not fatal. Beyond that, at a hard commit limit any Rust allocation anywhere in XCL ends the process the same way,main's code included. So one hit doesn't tell us much, and I'd be glad of a few more runs at the limit, ideally on0a755f0: if the PR's side ends there andmain's doesn't, that's worth finding.AI use: Claude Code (Claude Opus 5.5) wrote the fix and the tests, ran them and drafted this.
@St5sz2Jk on GitHub · 2026-11-25 18:36 UTC · original · edited 2026-11-26 00:42 UTC
Update: the crash below is a missing
UnadoptGuard, fixed with one line. With it, this PR takes the title on AMD / Wine through the world load and into the opening cutscene, with no copy-back waits.readback_asyncsubmits the copy-back list straight to the lane queue:own_work(|| q.ExecuteCommandLists(&[Some(l)])). That is still the same in0a755f0.d3d12_command_queue_ExecuteCommandLists.cold(d3d12core.dll+0x597fbd, read of0x2b28) instead of failing the check.real::q_execute_command_listswraps each list in #871'sUnadoptGuardfor exactly this reason. The copy-back submit does not:UnadoptGuardis #871's, notmain's, so this line belongs to whichever of the two PRs lands second (@Ariorh1337 / @gustavsi).UnadoptGuard::newdoes nothing outside Wine, so Windows behaviour does not change.69903fc+ the line, same tree as below,XCL_TARGET_PAGES_MB=6144; one run):sparse: the queue has not reached fence value,a copy back has not finishedordid not complete withinlines at all;ucrtbasememcpy crash intitle_textures(a read of a title page that is unmapped by then). That crash happens without this PR too.AMD / Linux / Wine with #871: the title crashes in vkd3d-proton 7–8 s after start with this PR (2 of 2). Without this PR the same tree runs past the menus and into the world load.
#871 is needed to start the title on AMD under Wine at all (see my comment there), so this PR can't be tested alone on this machine. The result comes from the combination.
Setup:
ec207194.main55d64c2+ #87134cd677+ #684e56dbc3+ #1502 (rebased,bf50b13) + #2357889008f+ this PR69903fc.XCL_HEAP_WINDOWS=1,XCL_DXC_THREADS=4,XCL_TARGET_PAGES_MB=6144.1. The title:
0xc0000005ind3d12core.dll+0x597fbd, reading0x2b28, at 7–8 sd3d12core.dll+0x8b9b0).list_x::reset_copy_scratchreal::cl_closesparse::State::readback_async(theq.ExecuteCommandLists/job.list.Close()part,sparse.rs:1270)State::after_executereadback_after_executereal::cl_closeis in the stack, so the list made byrb_jobgoes through XCL's list hooks.init, before the device's methods are hooked.rb_job, though, makes its allocator and list later, throughself.dev.src/donefences withreal::create_raw_fence(as #871 does forfence/rb_fence) gives the same crash, at the same address.the queue has not reached fence value … after 5 sabout every 5 s. Presents fell to about 1 every 10 s, which is the stall this PR is for.2. Tests (edited: withdrawn). My first version listed three failing sparse tests. Those runs did not set
WINEDLLOVERRIDES, so they used Wine's built-in vkd3d and not vkd3d-proton. I have withdrawn them until I rerun them properly.Where the crash is (added): with the build's DWARF,
d3d12core.dll+0x597fbdisd3d12_command_queue_ExecuteCommandLists.cold. vkd3d-proton was given a command list it does not recognise, and its release build has the vtable check compiled out.rb_job's lists are made throughself.devafter the hooks are installed, so their vtables are XCL's.Not tested:
AI use: Claude Code (Claude Opus 5.5) merged the tree, ran the title and the tests, read the stack and wrote this comment. My human API watched the runs.
@DavidM1911 on GitHub · 2026-11-26 00:49 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
github-bot referenced this pull request2026-11-26 06:18:31 +00:00
@ClosetPie107 on GitHub · 2026-11-26 06:06 UTC · original · edited 2026-11-26 06:17 UTC
Tested head
0a755f0con AMD RDNA4 / Linux (Proton Experimental), merged cleanly ontomain(b49be183) alongside #871 (8f08d7cd) and #684 (e56dbc3f) — specifically verifying0a755f0c's newreal::create_own_listWine fix (from @St5sz2Jk's report on69903fc):Hardware & environment
experimental-11.0-20261112),vkd3d-protonmasterec207194(3.2.0) +dxil-spirvb540c8a2+ relaxed-vtable patch (-Db_ndebug=true), DXVKv3.1.1-209, DXC1.9.2609.5, Rustx86_64-pc-windows-gnuTargeted unit tests (debug,
--test-threads=1):xcl.exe hle::d3d12x::sparse:: -- --test-threads=1: 25 passed, 0 failed, 1 ignored (early_commit_timing).no WARP device, expected under Wine whereEnumWarpAdapteris a stub):a_copy_back_does_not_wait_for_the_title_queue,a_copy_back_waits_for_its_own_title_queue,a_copy_back_list_of_an_adopted_device_is_not_adopted,a_copy_still_running_after_its_title_work_is_waited_for_outside_the_lock,an_older_copy_back_does_not_overwrite_a_newer_one,quarantined_tiles_wait_for_copies_back_still_to_run,idle_copy_back_buffers_above_the_cap_are_given_back,a_title_fence_shows_its_work_done_only_once_copies_back_can_land.Retail title A/B (1.0.2.1, pressing
Apast menus, 300 s, release)Flags:
XCL_DIRECT_DXIL=1,XCL_TEXTURE_LEVEL_PAGES=1,XCL_PSO_WAIT_MS=50,XCL_SPLIT_MIDLIST_WAIT=0,XCL_COHERENT_MB=1024,VKD3D_CONFIG=ignore_shared_fence,XCL_PSO_PRELOAD=0,XCL_NETWORK=0.main b49be183 + #871 8f08d7cd + #684 e56dbc3f):exit=0, 0 crashes, but hit 44sparse: the queue has not reached fence value 42916..42959 after 5 s (at 42915)warnings starting at81.609 s(5.0 s after76.609 sWait64BitValueX at 0x42437fae8bridged toq0.Waitonq1), stalling at14,256draws /2,748dispatches (4,096skipped) /0chained split dispatches.0a755f0c, no manual Wine patch needed): full 300 s (exit=0), 0 crashes (confirmingcreate_own_listfixes the 7 svkd3d-protoncrash without needing an extraUnadoptGuard), 0 device removals, and 0sparse: the queue has not reached fence valuewarnings. All 8Wait64BitValueX at 0x42437f...bridges in75.5–76.4 scompleted with 0 stalls; reached16,384translated draws (48skipped),22,268dispatches (73skipped),195chained split-compute dispatches (207split programs /2,320pieces),1,620PresentXframes,63,477Opus packets (0 errors),15,140 MiBpeak VRAM /12,543 MiBpeak RSS (swap=0).Not tested
main.AI use
main, ran the Proton tests and A/B retail runs on this machine, and drafted this report.@upipibi on GitHub · 2026-11-26 06:30 UTC · original · edited 2026-11-26 07:04 UTC
NVIDIA test report for
0a755f0: RTX 3070 8 GB (Ampere, driver 616.56), Windows 11 26100, Rust 1.100.0, debug. One intermittent failure in a test this PR adds.cargo test -p xcl --lib -- --skip hle::xaudio2 --test-threads=4(thehle::xaudio2tests hang on this machine, onmaintoo): 1288 passed, 0 failed, 26 ignored; 25 SKIPPED lines (21 no wave64, 3 per-lane forms refused under #1426, 1 driver cache needs Developer Mode).d3d12x::list_x d3d12x::fence_x d3d12x::sparse hle::acphal gpu::fence), 180 s cap: 5 of 5 finished in 6-7 s, so no hang. 4 had 77 passed, 0 failed; 1 had 76 passed, 1 failed.hle::d3d12x::sparse::tests::quarantined_tiles_wait_for_copies_back_still_to_run(sparse.rs:2442, "freed once the copy back is done"). It fails only with other tests running beside it:d3d12x::sparsealone: 2 of 8; the test with only the non-sparse filters beside it: 1 of 8;--test-threads=1: 0 of 5; the test alone: 0 of 10; the 4-thread full run above: passed;06055a7, parallel: 0 of 5 failed (the test isn't there).It runs on the shared WARP device (
lane_state()), so this is not NVIDIA-specific. Edit: cause checked with a local diagnostic build (the guess first written here, the newGetCompletedValuehook, is ruled out):quarantine_tilesalso signals a mark on every known queue on the same device (sparse.rs:1869-1883, viasync_known_queuesand the process-widepresent::known_queues(),present.rs:293). Every test shares one WARP device, so queues of other tests running at the same time get a mark too. The test then waits only for its lane fences (sparse.rs:2437-2441), sodrain_quarantined()(sparse.rs:1896) can still see one of those other queues' marks at 0; it reaches 1 a few ms later. In 13 failures exactly one mark was short, in 12 of 12 with owner info it was another test's queue, and the hooked and raw values were always equal; with the hook bypassed the test still failed 4 of 20 runs of the hang filter (8 of 20 with it).a_title_fence_shows_its_work_done_only_once_copies_back_can_land,--exact --test-threads=1 --nocapture, 3 runs: 3 of 3 passed, 0 SKIPPED.Lib tests only; no title run.
AI-assisted (Claude Code, Claude Opus 5.5).
@bmjask on GitHub · 2026-11-25 20:40 UTC · original · reviewed
P1: fence_wait_fired calls settle_readbacks_try() then unconditionally signals the title event. settle_readbacks_try silently returns when it cannot acquire STATE within 2 ms (or cannot reacquire it after its bounded wait), so no copyback may land but a title waking from SetEventOnCompletion can read stale sparse-window memory. GetCompletedValue has the same try-only visibility gap. Defer/retry title completion until the relevant copyback is confirmed landed, and add an adopted-fence lock-contention regression; State-only tests do not cover this hook contract.
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.