D3D12.X: the committed window gets a copy in video memory #1329
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!1329
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-1329"
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?
@vakaobr on GitHub · 2026-11-24 14:49 UTC · original
vakaobr:uma/copy-path→main· +363 −99 · 8 files · 3 commits · openStacked on #1326 and #1327; only the top commit (
ac4b997) belongs here. Part of #258.D3DMetal answers E_NOTIMPL for
OpenExistingHeapFromAddress, so on a Mac XCL has no GPU unified memory. With this PR the committed UMA window becomes a buffers-only heap of video memory (Uma::shadowed), kept in step like a sparse window's tiles (sparse::shadow_window): CPU writes go up before eachExecuteCommandLists(the window's write watch), GPU writes come back onMapand after the lists' memory writes, and PC copies into console buffers there are read back after the submit (list_x::note_copy_into, from #1326). The path is taken only whenOpenExistingHeapFromAddressreturns E_NOTIMPL;XCL_UMA_SHADOW=1forces it on a GPU that has such heaps,=0turns it off. Windows hosts open the heaps and are unchanged.Based on Ahmet-Dedeler's
c70bf8aonmac-on-main-wip, which he handed over in https://github.com/ivall/xcl/issues/258#issuecomment-7134093997. #1327 makespredication_e2eskip on hosts that run predicated copies; merge it first, or that test fails on the Mac once this lands. #1328 has the probes from the same commit.What is in it
crates/xcl/src/hle/d3d12x/real.rs:open_umafalls back to the video-memory copy on E_NOTIMPL (shadow_choice,XCL_UMA_SHADOW);check_uma_importreports "not run: the coherent window has a copy in video memory" for a shadowed window;sanitize_coherent_bufferandplace_at_title_addressdropCROSS_ADAPTERfor it.crates/xcl/src/hle/d3d12x/sparse.rs:shadow_windowand its pool: the window's tiles mapped from the start.crates/xcl/src/hle/d3d12x/bind.rs: no GPU buffer for a shadowed window 0.crates/xcl/src/gpu/recomp/runner.rs: the test runner'srun_in_regionuploads the arena before a dispatch and reads it back after whenOpenExistingHeapFromAddressreturns E_NOTIMPL.crates/xcl/src/gpu/recomp/tests.rs:gpu_uma_import_check_at_initaccepts the "not run" result only when the window is shadowed;gpu_sparse_vram_descriptors_buffers_and_xmemreads the shader's output back on a shadowed window.Tested
x86_64-pc-windows-gnu(mingw-w64 GCC 16.2.0), debug, DXC 1.9.2609. Each test in its own process (<test exe> --exact <test> --test-threads=1 --nocapture).main930e8b4(and in my full per-test run of9aec53d), these fail on this host; at this PR's head they pass (4a11de6, and again atac4b997after the rebase below; #1326 and #1327 under it):gpu_uma_import_check_at_init,gpu_unified_memory_arena,gpu_memory_windows_above_4_gib,gpu_mesh_mode_reads_memory_windows,gpu_bvh64_intersect_ray_across_memory_windows_and_grazing,gpu_memory_windows_reject_out_of_uma_aliasing,gpu_sparse_vram_descriptors_buffers_and_xmem.sparse_reinit, which skips with "no GPU UMA" onmain, passes.predication_e2eskips with "host ignores SetPredication for copies" (#1327).XCL_UMA_SHADOW=0(the copy path off),gpu_uma_import_check_at_initandgpu_sparse_vram_descriptors_buffers_and_xmemfail again, so they exercise the runtime path; the fiverun_in_arenatests still pass, because they run through the runner's own copy fallback above, not throughreal.rs.gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes(hangs on this host for another reason, see #258) andplaced_title_textures_share_vram_and_preserve_pixels(fails as onmain).main4178e88: one conflict inopen_uma, wheremainnow sets up the memory window views in the shared descriptor heap; the copies are set up first and the views after them, so a shadowed window's view is its copy in video memory. Rerun atac4b997, same results as above, includingXCL_UMA_SHADOW=0,sparse_reinitandpredication_e2e.4a11de6: NVIDIA RTX 5070 Ti and the AMD Radeon iGPU of a Ryzen 9800X3D (RDNA2), Windows 11, debug,cargo test --workspace -- --test-threads=4: 751 passed, 0 failed, 41 ignored on both (@futurepro62, https://github.com/ivall/xcl/pull/1329#issuecomment-7135152994); a second Mac (M4 Pro, CrossOver 26.3, D3DMetal): the seven UMA tests 0/7 on930e8b4and 7/7 here, 5 passed and 2 failed withXCL_UMA_SHADOW=0(the same two),sparse_reinitpassing andpredication_e2eskipping as above, and the e2e test title starting with the shadowed window, 31 PASS / 2 FAIL on both commits (@Lucasyudi, https://github.com/ivall/xcl/pull/1329#issuecomment-7135496468).Regression run
This changes the Mac's runtime path, so it needs an
xcl-smokepair from a Mac with a title (mainand this head); I have no title. Windows hosts don't take the path, but a Windows pair would confirm it.Not tested
gpu_uma_import_check_at_init: whichever merges second needs a one-line rebase. Once this lands, #1060's skips for the fiverun_in_arenatests no longer fire on the Mac, sincerun_in_arenastops returning E_NOTIMPL.AI use
c70bf8aontomainand split it. Claude Code with Claude Opus 5.5 reviewed it, made the import-check test accept the "not run" result only on a shadowed window, ran the tests above (including theXCL_UMA_SHADOW=0runs) on this machine and wrote this description.@futurepro62 on GitHub · 2026-11-24 14:54 UTC · original · edited 2026-11-24 14:57 UTC
Full-suite run, since this PR has no test report yet. Tested exact head
4a11de6(on its base930e8b4).Tested
cargo build --workspace, thenXCL_REQUIRE_GPU=mesh cargo test --workspace -- --test-threads=4: 751 passed, 0 failed, 41 ignored. SKIPPED (no wave64):gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware.#[test]functions in the diff.XCL_ADAPTER=radeon),cargo test --workspace -- --test-threads=4: 751 passed, 0 failed, 41 ignored, no skips.Not tested
AI use
@Lucasyudi on GitHub · 2026-11-24 15:07 UTC · original
Test report from a second Apple silicon Mac (M4 Pro; the description's runs are on an M5 Pro). Head
4a11de6againstmain930e8b4.Tested
x86_64-pc-windows-gnuwith mingw-w64 (GCC 16.2.0), Rust 1.100.0, debug, DXC 1.9.2609. Each test binary under CrossOver'swine; the GPU tests one per process (--exact, 60 s cap).gpu_uma_import_check_at_init,gpu_unified_memory_arena,gpu_memory_windows_above_4_gib,gpu_mesh_mode_reads_memory_windows,gpu_bvh64_intersect_ray_across_memory_windows_and_grazing,gpu_memory_windows_reject_out_of_uma_aliasing,gpu_sparse_vram_descriptors_buffers_and_xmem):930e8b40 passed, 7 failed;4a11de67 passed, 0 failed.XCL_UMA_SHADOW=0: 5 passed, 2 failed, the two beinggpu_uma_import_check_at_initandgpu_sparse_vram_descriptors_buffers_and_xmem, as the description says.tests/sparse_reinit.rs:930e8b4skips with "no GPU UMA",4a11de6passes without a skip.tests/predication_e2e.rs:930e8b4skips with "no GPU UMA",4a11de6skips with "host ignores SetPredication for copies" (#1327).tests/e2e.rs(the test title): 31 PASS / 2 FAIL on both commits, the same checks; on the head the log shows the title taking the path ("UMA import check: not run: the coherent window has a copy in video memory"). The run then stops at the D3DMetal crash already described in #258 on both, so this covers start-up with the shadowed window, not drawing with it.Not tested
AI use: Claude Code, Claude Opus 5.5 built both commits, ran the tests and wrote this report.
@DavidM1911 on GitHub · 2026-11-24 15:14 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: 708 passed, 0 failed, 21 ignored.Thanks!
@eizispark on GitHub · 2026-11-24 15:18 UTC · original
Hardware test report — commit
4a11de6Verified clean merge with
main(930e8b4) on4a11de6dae7d28159e2de0c42d132c98d79426d8: pass on the default Windows path (XCL_UMA_SHADOWunset); under forcedXCL_UMA_SHADOW=1, the targeted UMA/sparse/predication tests pass while the 60 s retail run hits a device removal before presenting frames.Tested
rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profileXCL_UMA_SHADOWunset):cargo test --workspace --no-fail-fast -- --test-threads=4—751 passed, 0 failed, 41 ignored(GPU tests skipped on this adapter:none), includingpredication_e2e(set_predication_buffer_state_and_kickoff),gpu_uma_import_check_at_init, andgpu_sparse_vram_descriptors_buffers_and_xmemXCL_UMA_SHADOW=1, separate processes):XCL_UMA_SHADOW=1 cargo test -p xcl --lib gpu_uma_import_check_at_init -- --nocapture:1 passed, 0 failed, 0 skippedXCL_UMA_SHADOW=1 cargo test -p xcl --lib gpu_sparse_vram_descriptors_buffers_and_xmem -- --nocapture:1 passed, 0 failed, 0 skippedXCL_UMA_SHADOW=1 cargo test -p xcl --test predication_e2e -- --nocapture:1 passed, 0 failed, 0 skippedXCL_UMA_SHADOW=160 s retail smoke run:exit: 0x80000003,frames shown: none logged (the run did not reach its end),device removals: 1,crashes: 2Regression run
main(930e8b4):PR (
4a11de6):Not tested
XCL_D3D12_DEBUG=1; gameplay past the menusAI use
XCL_UMA_SHADOW=1smoke checks, and formatted this report.@IvyNotFound on GitHub · 2026-11-24 15:23 UTC · original
Regression runs for
4a11de6on Windows, thexcl-smokepair this PR still needs. Same retail title, same 60 s, unedited, made withscripts/smoke.ps1 -Seconds 60andXCL_PRESS_A_AT=15. The PR head as is (base930e8b4) andmain930e8b4, clean trees, one after the other.Windows does not take the copy path (
OpenExistingHeapFromAddressworks here), so this only confirms that the PR changes nothing on Windows.main:
this PR:
Not tested: the suite at this head (see the other reports here); AMD.
AI use: Claude Code, Claude Opus 5.5 ran the runs and wrote this comment.
@JoaoPauluu on GitHub · 2026-11-24 15:28 UTC · original
A regression run under Wine on Linux, on a retail title.
Tested
x86_64-pc-windows-gnu.4a11de6as it is andmain930e8b4, no uncommitted changes. Retail title 1.0.2.1,scripts/linux/smoke.sh(#257) for 60 s, no input. Nine runs in a row,mainfirst and last, other PRs in between.UMA import check: ok), so the shadowed committed window this PR adds for hosts without it is not used here. This is a regression check for hosts that have it.Regression run
main (first run):
this PR:
The last
mainrun: 1338 frames,exit: 0x0, no device removal, no crash. Under Wine,peak commitreads 0 MB, so these blocks do not check memory.Not tested
AI use
@brainhay5 on GitHub · 2026-11-24 15:55 UTC · original
Retail title with the copy path forced on, on a 16 GB NVIDIA card, to add to @eizispark's
XCL_UMA_SHADOW=1run on the RX 9070 XT.Setup: this stack merged onto
main930e8b4(merge head4a11de6, clean), release, RTX 5070 Ti (driver 32.0.16.1088), Ryzen 7 5800X3D, 64 GB, Windows 11 22631,XCL_NETWORK=0,XCL_UMA_SHADOW=1, A every 3 s, 180 s window.The path engages — from the log:
It does not move the stall here:
then the usual end at 102.7 s:
unhandled exception 0xc0000005 in game_scarlett_master.exe+0x23cf683 (write at address 0x0).Against the default path on the same card (presents stop ~90 s, fault ~98 s), that is within noise — no improvement, and no device removal either.
Read (inference, not a claim about your intent): the copy path addresses the bus traffic, and it engaged, but what ends these runs is the PSO queue, not memory reads. @eizispark got a device removal on AMD rather than a stall, so the two cards are not failing the same way under this flag.
Not tested: default path on this head (IvyNotFound's Windows pair covers it), AMD, longer runs; the flag's effect on GPU dispatch time specifically, which would need the timing instrumentation rather than the run outcome.
AI use: OpenCode, DeepSeek V4.1 Flash 1017.
@Ahmet-Dedeler on GitHub · 2026-11-24 17:04 UTC · original
Checked this stack (with #1328 for the probes) against my c70bf8a. Of the 438 changed lines in the original, 423 are here as they were. The rest are comments and the log line for a window that isn't shared with the GPU, reworded. What's new on top is yours: the
XCL_UMA_SHADOWswitch,shadow_choice, and the tests. So the copy path does what the original did, and it's now possible to turn it on for a GPU that has the heaps, which I didn't have.Splitting the
predication_e2eskip into #1327 was right. That test does fail on the Mac once this is in.I can't give it a Windows pair. A Mac pair with a title from me has to wait until my port is rebased onto a
mainwith this stack, so if @mikebuckets171 gets to it first, use that.@us3r40456 on GitHub · 2026-11-24 17:33 UTC · original
The e2e test title on a Mac with this PR: it gets past the index-buffer crash, then stops at the triangle check (GPU timeout, 3 runs of 4) or at the first PresentX (1 of 4).
Tested
x86_64-pc-windows-msvc(cargo-xwin), DXC 1.9.2609.xcl_testtitle.exe+testgame_mw.dll+tests/data/testgame) run ase2e.rsruns it:xcl run <game> -- --hello, a freshXCL_DATA_ROOTfor each run, one run at a time.main9e3831e+ #750 (6569928), and the same + this PR's three commits (4a11de6). Two hunks of the top commit no longer applied as they were becausemainadded code there since930e8b4: theshadowsloop inopen_umanow goes after theheap_windowsblock, and thecopiesuploads inrun_in_regionafter itsCopyBufferRegionofio_buf. Nothing else changed.Without this PR (
9e3831e+ #750): 33 PASS, 1 FAIL (the window cloak, see #1462), then the title dies in D3DMetal at its firstIASetIndexBuffer#47 of an index buffer at a title address:With no GPU unified memory,
gpu_vahands the title's address over as it is (uma_va_ofhas nothing for it), and D3DMetal dereferences null where it finds no resource for that address instead of refusing it.With this PR, four runs:
IASetIndexBuffercrash is gone in all four;IASetIndexBuffer#47,DrawIndexedX#81, nested occlusion queries) never completes:sparse: the queue has not reached fence value 12 after 5 s (at 11), then from MetalCaused GPU Timeout Error (00000002:kIOGPUCommandBufferCallbackErrorTimeout);DXGIFactory::CreateSwapChainForHwnd(a write to null in ntdll), called frompresent::present_now(present.rs:687) on the queue thread.So on this host the PR removes the first stop, and the next ones are the GPU timeout on that list (most runs) and the swap chain creation. I have not narrowed down which command of that list the GPU stalls on.
Not tested
AI use: Claude Code (Claude Opus 5.5) helped build, run and read the logs; the runs are on my Mac.
@us3r40456 on GitHub · 2026-11-24 17:55 UTC · original
Correction to my report above: the GPU timeout at the triangle check does not come back, and I now think it came from my bench, not this PR. With this PR the test title has passed the triangle check in 20 runs since, and with
pr/native-host-vtableson top it runs to its end.What was likely wrong: after a crash, the title's process does not go away under CrossOver.
xcl runreportsGame exited with code 0xc0000005, butxcl.exeandxcl_testtitle.exestay alive, the title at 100 % of a core. My first run crashed inCreateSwapChainForHwnd, and the runs that timed out all ran while the processes of the runs before them were still there. Once those were gone, no run timed out, on the same trees and builds. Later runs that crashed elsewhere also left processes behind, without a timeout, so I can't say which leftover caused it. Since then each run ends the bottle's processes (wineserver -k). (Mac testers: checkpsfor leftoverxcl.exebetween runs.)Tested
x86_64-pc-windows-msvc, DXC 1.9.2609. The test title is run ase2e.rsruns it, with a freshXCL_DATA_ROOTeach time.main9e3831e+ #750 + this PR: the triangle check passes. The title then dies in D3DMetal, at the first PresentX (D3D12GraphicsCommandList::CopyResource+0x8afrompresent::present_now,present.rs:697) or in the next check (ID3D12CommandQueue::UpdateTileMappingsfromsparse::place_buffer,sparse.rs:1612, then a jump to0x1b84800000a6a). TheCopyResourcecrash is atmovq (%r15,%rax), after readingvtable[-0x30]of the source resource. D3DMetal reads the words in front of the method table of the resource it gets, and the resource carries XCL's extended table there.pr/native-host-vtables(ddf3be7, cherry-picked): the title runs to its end, 46 PASS / 4 FAIL, the same in 3 runs. The four are the window cloak (#1462, #794, #1481), "no GPU timestamp" (#996), XMA2GetStatectx=0 (#890), and "the DirectStorage fence was not signalled".EnqueueSignalchecks the fence withgpu::shader::readable, which asksVirtualQuery. D3DMetal's fence is at0x7fcc2d0f7540, in memory Wine'sVirtualQuerydoes not know, so the signal is dropped. With the check probing by reading whenVirtualQuerysays no, the check passes: 47 PASS / 3 FAIL in 2 runs. I'll send that as its own PR.Not tested
AI use: Claude Code (Claude Opus 5.5) helped build, run and read the logs; the runs are on my Mac.
@mikebuckets171 on GitHub · 2026-11-24 16:43 UTC · original · edited 2026-11-24 21:39 UTC
The
xcl-smokepair @vakaobr asked this bench for:930e8b4against #13294a11de6, plus the warm-root repeat and the run with the path switched off. Four runs, same title, same 60 s bound, same bottle, same sandbox, same DXC, one run at a time with local inference unloaded. All four blocks:How to read them. Nothing moves: the head matches
mainexactly, and switching the shadow path off changes nothing either. That is the expected shape on this host —mainpresents 0 frames in a bounded run here (OpenExistingHeapFromAddress→Not implemented (0x80004001), which is why your path is taken at all), so a pair onmaincan only prove nothing regressed. The honest statement for the Regression run section is that: 0 against 0, 0 crashes against 0, exit0x0on both sides, on a warm and a cold root. It does not show the copy path working, because nothing observable follows within 60 s on a host that presents nothing. The unit tests and your GPU tests are the evidence that it works; these blocks are the evidence that it does not disturb the title's start.peak commitreads 0 in every block: this bench's sampler cannot read the committed-memory counter of a process running under Wine, so treat that line as unmeasured here rather than as a zero.Not tested: Windows. Counts, exit codes and timings only; no paths, package contents or log bodies.
Host: macOS 27.2.1 (Apple silicon, M5 Pro, 48 GB), CrossOver 26 with D3DMetal, Rust 1.100.0,
x86_64-pc-windows-gnullvm(LLVM-MinGW, clang 23.1.6),--release --locked,XCL_MAC_HOST=1, one run at a time with local inference unloaded. AI use: GPT-6 Luna built the two trees and ran the four blocks; the blocks above are copied from those runs unchanged.Update — current
main/ #1329 head, Nov 24After the PR moved to
ac4b997, I reran the same bounded title smoke on current upstreammainc4d37bec1bb4286eb373aea963404a23f13401faand exact PR headac4b99784033501e28add8780cebc4f680aa1aa3. Upstreammainhad advanced from the PR's reported base4178e88via #1747. Both were release builds forx86_64-pc-windows-gnullvmfrom the Mac, with Rust 1.100.0 and LLVM-MinGW 20261117 / clang 23.1.6. Same M5 Pro / macOS 27.2.1 / Rosetta 2 / CrossOver 26.3.0.39832 / D3DMetal / DXC 1.9.2609.5 setup as above; same title, 60 s bound, network off, fresh data root per run, andXCL_UMA_SHADOWunset. Local title and data paths are omitted.Commands:
cargo build --release --locked -p xcl --target x86_64-pc-windows-gnullvm; then CrossOverwine --bottle <bottle> --no-gui --cx-app <release xcl.exe> run <same title folder>withXCL_NETWORK=0,XCL_RUN_SECONDS=60,XCL_ACTIVITY=1,XCL_DXC_DIR=<DXC 1.9.2609.5 directory>, and a freshXCL_DATA_ROOTfor each arm. Only the checkout/binary and data-root path differed between runs.The PR head logs the expected 512 MiB UMA shadow-copy fallback after D3DMetal returns
E_NOTIMPL, then completes the 60 s bound. Both runs still log zero presents and draws, so this host smoke reaches the fallback but does not reach title rendering; it does not establish visual correctness or a useful frames ratio. Wine reports process commit as 0 MB, so peak commit remains unmeasured.Not tested: native Windows D3D12 in this update, the full test suite on these exact commits, or visual output/gameplay. The PR's existing Windows reports are unchanged.
AI use for this update: OpenAI Codex with GPT-6 built the exact current
mainand PR-head binaries, ran the two Mac smokes, and drafted this update; the logs are from the named Mac.@CharlyRien on GitHub · 2026-11-24 22:36 UTC · original · edited 2026-11-24 22:37 UTC
Forced on Windows (
XCL_UMA_SHADOW=1) in a retail title's 3D world, RTX 3090: the copy removes almost all of the compute time. What is left is synchronisation.This is not about the Mac path. It is a data point for anyone thinking of the copy as an option on Windows too.
Setup (edited: the exact stack)
main9e3831emerged locally with #1288, #1448, #684, #889, #1323, #929 and #640, plus local diagnostics (GPU timestamp queries around each operation, a device-removal watcher), then this stack's three commits (#1326, #1327, #1329) cherry-picked; one conflict inlist_x.rs, kept bothnote_copy_intoand #1323's markers. The "imported from host memory" column is the same tree without them; its "#1850's rule" figures have the HLSL-path part of #1850 on top.XCL_HEAP_WINDOWS=1 XCL_NETWORK=0 XCL_ACTIVITY=1, warm DXIL and driver caches, scripted A presses, 230 – 300 s per run, noXCL_PSO_WAIT_MSunless a row says so.XCL_PSO_WAIT_MS); the title's own stall watchdog is neutralised so that long stalls can be observed.TdrDelayandTdrDdiDelayset to 30 s. With the default 2 s the driver resets the device during the multi-second dispatches (System event 4101) and nothing can be timed.XCL_UMA_SHADOW=1for the right-hand column.GPU time in the world
The reason is in #1640: a
globallycoherentload from the imported heap costs about 30 times the same load from video memory and is serialized.What goes wrong with it on Windows
sparse: the queue has not reached fence value N after 5 s (at N-1), 168 times in the first run. The readback after the lists' memory writes waited, inside the title'sExecuteCommandLists, on a fence whose work is only submitted after it. With a local change insparse.rs(the readbacks run on their own queue, in the background) two runs had none and a third had 26. I can post the diff if it helps.GPU queue.Wait … did not complete within 5000 msreleases, every queue waiting on cells produced by the others at the same value: one frame every 6 s. With the release at 250 ms instead of 5 s the world shows bursts of 1 – 1.5 frames per second. The compute queues then stop completing operations and the run stops presenting, one to two minutes after the first world frame (two runs). The same kind of release exists without the copy (49 – 87 per run here), so I do not know yet whether the copy path causes this or only exposes it. Looking into it.Wait64BitValueX timed outper run, the same count in two runs.Not tested: the Mac path, the default Windows path (unchanged by the PR, not rerun), current
main. Noscripts/smoke.ps1block: the base is old and carries local diagnostics.AI use: Claude Code (Claude Fable 5.2) ran the measurements and drafted this report.
@CharlyRien on GitHub · 2026-11-24 23:57 UTC · original
Follow-up to my comment above: the per-frame
GPU queue.Waitreleases on the copy path came from the readback fence that all title queues share insparse.rs. With one readback fence per title queue they are gone (4 runs) and the world runs at 1.3 – 1.4 frames per second, until the title faults.Setup
main9e3831emerged locally with #1288, #1448, #684, #889, #1323, #929 and #640, then this stack (#1326, #1327, #1329), then #1791 (applied by hand: twobind.rshunks), plus local diagnostics and the two localsparse.rschanges described below. One of the four runs also had three commits fromwondercrash/xcl(150e635,761ada5,9b70233: allocator lifetime); they changed nothing here.XCL_UMA_SHADOW=1 XCL_HEAP_WINDOWS=1 XCL_NETWORK=0 XCL_ACTIVITY=1, warm caches, nothing skipped (noXCL_PSO_WAIT_MS). Local switches: three compute programs of 4 MB of DXIL or more are not handed to the driver; the title's own stall watchdog is neutralised. WindowsTdrDelay/TdrDdiDelay= 30 s.Mechanism (with a journal of every Wait / Signal / Execute per queue)
rb_fencewith the next value of one shared counter, and the readback waits for its value on that fence (queue.Signal(&s.rb_fence, v)…Wait(&s.rb_fence, v)). A fence only counts up, so a readback issued for queue A at value N is already satisfied once queue B has signalled N+1, before A has run its lists. The copy runs early, the CPU view keeps the old bytes, and nothing copies them again.Wait64BitValueXfallback) and sits out the full 2 s every time: 76 polls, 152 s blocked, in one 280 s run. The work it would submit next is what the compute queues wait for, hence about twentyGPU queue.Wait … did not complete within 5000 msper frame. Those releases are a consequence of the stale readback, not a GPU cycle: in the watchdog dumps the waiting queue stands at a cell for which no GPU signal of that value has been issued yet, and every other queue is idle.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, and a synchronous copy from video memory at that moment shows the wanted value. Same in all 11 probed timeouts.One caveat about where the bug is: the shared
rb_fenceis upstream code, but in my tree the readback had already been made asynchronous (the local change from my first comment, to get rid of thesparse: the queue has not reached fence valuewaits insideExecuteCommandLists). I have not checked whether the unmodified synchronous path can also be satisfied early by another queue; by reading the code it can whenever two title queues submit close together.Change tested: one asynchronous readback per title queue, each with its own source fence that only that queue signals, and its own copy queue (so a stalled queue's copy does not hold back the others).
sparse.rsonly, about 200 lines on top of the first change. Open PR #433 removes the shared fence too, with a different design (the copy goes on the title's own queue, so the bytes are there before the title sees its own fence); I have not run it yet and will compare.Result (world = after the dispatch burst of the world load)
queue.WaitreleasesThe GPU is 70 – 98 % idle per queue in those windows. What limits the frame rate now looks CPU-side (the window's write watch took about 60 s of CPU in a 157 s run), not verified.
What still ends the runs
0xaaaaaaaahigh half). Candidate: the title reads GPU-written data before the asynchronous copy has landed (it lands up to about 20 ms after the write). That is what the comparison with #433's ordering should tell.Not tested: the Mac path; the unmodified synchronous readback; #433; current
main(being ported). Noscripts/smoke.ps1block: old base with local diagnostics. I can post both local diffs if they are useful to someone.AI use: Claude Code (Claude Fable 5.2 coordinating, Claude Opus 5.5 for the journal, the probe and the change) ran this and drafted the report.
@vakaobr on GitHub · 2026-11-25 10:15 UTC · original
@CharlyRien thanks for forcing the copy path on Windows and for the journal, that's the measurement I couldn't make here. From 7–17 s per dispatch to 4–40 ms is a clearer case for it than anything on the Mac.
On the shared
rb_fence: by readingmain, the unmodified synchronous path can be overtaken too, but only after a readback has already timed out.readback_after_executeholds the sparse lock and waits on the CPU for the copy, so no other queue's readback can come in between while it waits. When that wait gives up after 5 s, though, the copy stays queued on XCL's queue behindWait(rb_fence, v), and the next readback from any other queue signalsv + 1and lets it run, before queue A's lists. So the stale bytes you saw follow from the 5 s waits you saw first. Your asynchronous version makes that possible on every submit.#433 removes the shared fence (each title queue gets its own, and the copy goes on the title's queue). I ran its two tests on the Mac on
main568e7db, with and without this stack on top. Without #433, the waits test fails 3/3 (queue A doesn't finish in 5 s); with #433, and with #433 + this stack, both tests pass 3/3, and the seven UMA tests and the sparse tests still pass. Details on #433. So on a Mac, where this PR turns the copy path on by default, #433 should land with it or before it. Your comparison with #433's ordering will tell more than my synthetic tests can.AI use: Claude Code, Claude Opus 5.5 read the code, ran the tests and wrote this reply.
@upipibi on GitHub · 2026-11-25 10:13 UTC · original · edited 2026-11-25 10:22 UTC
NVIDIA test report for
ac4b997(part of #2057's stack; it carries its own copies of #1326 and #1327). RTX 3070 8 GB (Ampere, 32-lane waves), driver 616.56, Windows 11, debug. The PR is merged ontomain568e7db, full build (cargo build --workspace && cargo build --workspace --tests).cargo test --workspace --no-fail-fast -- --test-threads=4: 1153 passed, 1 failed, 46 ignored.hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime, the playback-timing test of #1600. A different XAudio2 voice test fails from run to run on this machine; onmain9e3831eearlier today it wasopus_source_voice_decodes_and_manages_lifetime. It's not from this change.test_title_runs_and_game_folder_is_untouchedpasses.no wave64, plusper-lane form: refused,no heap windows,cannot disable the driver cacheand Developer Mode off.XCL_UMA_SHADOW=1 cargo test -p xcl --lib gpu_uma_import_check_at_init -- --nocapture(added later, same build): 1 passed, 0 failed in 3 of 3 runs. Each logsUMA: 3 sparse VRAM window(s) (12 GiB VA) + 1 coherent window(s) (512 MB)andUMA import check: not run: the coherent window has a copy in video memory (no host-memory heaps on this D3D12). Without the variable the same test runs the check:UMA import check: ok, 1 window(s), 22237 µs.AI-assisted (Claude Code). Synthetic tests only; no title run.
@pvfreis on GitHub · 2026-11-25 16:10 UTC · original
With the copy path on (
XCL_UMA_SHADOW=1, or E_NOTIMPL on a Mac), a block of the committed window that is freed and allocated again reads zero on the CPU, but the GPU's copy still holds what a shader stored in it before the free. Tested atac4b997merged ontomain426a5a7and earlier ontocbc296a(both clean;uma.rsandsparse.rsare unchanged onmain0829441).Uma::allocclears the block on the CPU (uma.rs:591,write_bytes; its doc says "Zeroed block").sparse::scan_page(sparse.rs:324) uploads nothing for a page whose chunks are all zero and which never sent anything, andshadow_window(sparse.rs:556) maps every tile from the start, so none passes throughensure_mappedagain. So the copy keeps what a shader stored there (when the block was never read back or written by the CPU; after a readback the zeros are uploaded). A sparse window's reused tile goes throughto_zero(sparse.rs:809,:816), and the shadowed one has no such step.Steps, through the ABI root signature as
gpu_sparse_vram_descriptors_buffers_and_xmemdoes:u.alloc(0x10000, 256)givesb; a dispatch stores 1077 + l into it (no CPU write, no Map);band it is 1077 + l;u.free(b),u.allocuntil it returns the same address; the CPU view is zero;[1077, 1078, 1079, 1080], expected 0.cargo test --workspace --locked --offline --no-fail-fast -- --test-threads=4, debug, RTX 3060 (driver 617.14), as a separate sandbox user (non-interactive session, Low integrity, no display,XCL_NETWORK=0), passed / failed / ignoredmaincbc296acbc296acbc296a,XCL_UMA_SHADOW=1child red,=0child green426a5a7cbc296aThe control (not a proposed fix) pushes the block
alloczeroed intoto_zerowhen the window is shadowed. The failure common to every row is the e2e testtest_title_runs_and_game_folder_is_untouched, which fails onmainhere too. The test is a copy ofgpu_sparse_vram_descriptors_buffers_and_xmemwith the steps above, run in a child process perXCL_UMA_SHADOWvalue; I can post it.Not tested: a title (whether one reuses a block this way), a Mac, AMD. By default on Windows nothing changes.
AI use: Claude Code (Claude Opus 5.5) wrote and ran the test and drafted this; text reviewed with Claude Fable 5.2.
@DavidM1911 on GitHub · 2026-11-26 04:53 UTC · original
Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current
mainon the new head — needs another rebase before it can be tested.View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.