Skip to content

D3D12.X: the committed window gets a copy in video memory - #1329

Open
vakaobr wants to merge 3 commits into
xcl-dev:mainfrom
vakaobr:uma/copy-path
Open

vakaobr wants to merge 3 commits into
xcl-dev:mainfrom
vakaobr:uma/copy-path

Conversation

@vakaobr

@vakaobr vakaobr commented Nov 24, 2026 •

Copy link
Copy Markdown

Stacked 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 each ExecuteCommandLists (the window's write watch), GPU writes come back on Map and 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 when OpenExistingHeapFromAddress returns E_NOTIMPL; XCL_UMA_SHADOW=1 forces it on a GPU that has such heaps, =0 turns it off. Windows hosts open the heaps and are unchanged.

Based on Ahmet-Dedeler's c70bf8a on mac-on-main-wip, which he handed over in #258 (comment). #1327 makes predication_e2e skip 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_uma falls back to the video-memory copy on E_NOTIMPL (shadow_choice, XCL_UMA_SHADOW); check_uma_import reports "not run: the coherent window has a copy in video memory" for a shadowed window; sanitize_coherent_buffer and place_at_title_address drop CROSS_ADAPTER for it.
  • crates/xcl/src/hle/d3d12x/sparse.rs: shadow_window and 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's run_in_region uploads the arena before a dispatch and reads it back after when OpenExistingHeapFromAddress returns E_NOTIMPL.
  • crates/xcl/src/gpu/recomp/tests.rs: gpu_uma_import_check_at_init accepts the "not run" result only when the window is shadowed; gpu_sparse_vram_descriptors_buffers_and_xmem reads the shader's output back on a shadowed window.

Tested

  • MacBook Pro M5 Pro (20-core GPU), 48 GB, macOS 27.2.1, CrossOver 26.3.0.39832 with D3DMetal 3.0 ("AMD Compatibility Mode"), Rosetta 2. Rust 1.100.0, 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).
  • On main 930e8b4 (and in my full per-test run of 9aec53d), these fail on this host; at this PR's head they pass (4a11de6, and again at ac4b997 after the rebase below; D3D12.X: prepare for the unified memory copy path #1326 and Tests: skip predication_e2e when the host runs predicated copies #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" on main, passes. predication_e2e skips with "host ignores SetPredication for copies" (Tests: skip predication_e2e when the host runs predicated copies #1327).
  • Which part each test covers: with XCL_UMA_SHADOW=0 (the copy path off), gpu_uma_import_check_at_init and gpu_sparse_vram_descriptors_buffers_and_xmem fail again, so they exercise the runtime path; the five run_in_arena tests still pass, because they run through the runner's own copy fallback above, not through real.rs.
  • Unchanged here: gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes (hangs on this host for another reason, see macOS (Apple Silicon, CrossOver + D3DMetal): the newer retail game reaches its first-run menus at 30 fps #258) and placed_title_textures_share_vram_and_preserve_pixels (fails as on main).
  • Rebased onto main 4178e88: one conflict in open_uma, where main now 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 at ac4b997, same results as above, including XCL_UMA_SHADOW=0, sparse_reinit and predication_e2e.
  • Independent runs at 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, D3D12.X: the committed window gets a copy in video memory #1329 (comment)); a second Mac (M4 Pro, CrossOver 26.3, D3DMetal): the seven UMA tests 0/7 on 930e8b4 and 7/7 here, 5 passed and 2 failed with XCL_UMA_SHADOW=0 (the same two), sparse_reinit passing and predication_e2e skipping as above, and the e2e test title starting with the shadowed window, 31 PASS / 2 FAIL on both commits (@Lucasyudi, D3D12.X: the committed window gets a copy in video memory #1329 (comment)).

Regression run

This changes the Mac's runtime path, so it needs an xcl-smoke pair from a Mac with a title (main and this head); I have no title. Windows hosts don't take the path, but a Windows pair would confirm it.

Not tested

AI use

  • Claude Code with Claude Opus 4.6 ported c70bf8a onto main and 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 the XCL_UMA_SHADOW=0 runs) on this machine and wrote this description.

@futurepro62

futurepro62 commented Nov 24, 2026 •

Copy link
Copy Markdown

Full-suite run, since this PR has no test report yet. Tested exact head 4a11de6 (on its base 930e8b4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 616.64, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.100.0 MSVC, debug, D3D12 debug layer installed.
  • cargo build --workspace, then XCL_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.
  • No new #[test] functions in the diff.
  • Same head on the AMD Radeon iGPU of the 9800X3D (RDNA2, XCL_ADAPTER=radeon), cargo test --workspace -- --test-threads=4: 751 passed, 0 failed, 41 ignored, no skips.

Not tested

  • a release build, a game (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.

@Lucasyudi

Copy link
Copy Markdown

Test report from a second Apple silicon Mac (M4 Pro; the description's runs are on an M5 Pro). Head 4a11de6 against main 930e8b4.

Tested

  • Apple M4 Pro, macOS 27.2.1, CrossOver 26.3 with D3DMetal, Rosetta 2. Cross-built for x86_64-pc-windows-gnu with mingw-w64 (GCC 16.2.0), Rust 1.100.0, debug, DXC 1.9.2609. Each test binary under CrossOver's wine; the GPU tests one per process (--exact, 60 s cap).
  • The seven GPU tests the description lists (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): 930e8b4 0 passed, 7 failed; 4a11de6 7 passed, 0 failed.
  • Same head with XCL_UMA_SHADOW=0: 5 passed, 2 failed, the two being gpu_uma_import_check_at_init and gpu_sparse_vram_descriptors_buffers_and_xmem, as the description says.
  • tests/sparse_reinit.rs: 930e8b4 skips with "no GPU UMA", 4a11de6 passes without a skip. tests/predication_e2e.rs: 930e8b4 skips with "no GPU UMA", 4a11de6 skips with "host ignores SetPredication for copies" (Tests: skip predication_e2e when the host runs predicated 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 macOS (Apple Silicon, CrossOver + D3DMetal): the newer retail game reaches its first-run menus at 30 fps #258 on both, so this covers start-up with the shadowed window, not drawing with it.

Not tested

  • A retail title (I have none), Windows, the whole suite.

AI use: Claude Code, Claude Opus 5.5 built both commits, ran the tests and wrote this report.

@DavidM1911

Copy link
Copy Markdown
Contributor

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

eizispark commented Nov 24, 2026 •

Copy link
Copy Markdown

Hardware test report — commit 4a11de6

Verified clean merge with main (930e8b4) on 4a11de6dae7d28159e2de0c42d132c98d79426d8: pass on the default Windows path (XCL_UMA_SHADOW unset); under forced XCL_UMA_SHADOW=1, the targeted UMA/sparse/predication tests pass while the 60 s retail run hits a device removal before presenting frames.

Tested

  • Hardware: Windows 11 x64, AMD Ryzen 7 9800X3D, AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), 32 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • Default Windows path (XCL_UMA_SHADOW unset): cargo test --workspace --no-fail-fast -- --test-threads=4 — 751 passed, 0 failed, 41 ignored (GPU tests skipped on this adapter: none), including predication_e2e (set_predication_buffer_state_and_kickoff), gpu_uma_import_check_at_init, and gpu_sparse_vram_descriptors_buffers_and_xmem
  • Forced copy path (XCL_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 skipped
    • XCL_UMA_SHADOW=1 cargo test -p xcl --lib gpu_sparse_vram_descriptors_buffers_and_xmem -- --nocapture: 1 passed, 0 failed, 0 skipped
    • XCL_UMA_SHADOW=1 cargo test -p xcl --test predication_e2e -- --nocapture: 1 passed, 0 failed, 0 skipped
    • XCL_UMA_SHADOW=1 60 s retail smoke run: exit: 0x80000003, frames shown: none logged (the run did not reach its end), device removals: 1, crashes: 2

Regression run
main (930e8b4):

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1667 (PresentX 1667)
presents per 2 s (last 3): 60 60 61
device removals: 0
crashes: 0
peak commit: 14861 MB

PR (4a11de6):

xcl-smoke v1
commit: 4a11de6dae7d28159e2de0c42d132c98d79426d8
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1679 (PresentX 1679)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14854 MB

Not tested

  • D3DMetal / macOS where host-memory heaps are unavailable natively; retail run under XCL_D3D12_DEBUG=1; gameplay past the menus

AI use

  • Antigravity (Google DeepMind, Gemini 4 Carbon) — ran the workspace test suite, default and XCL_UMA_SHADOW=1 smoke checks, and formatted this report.

@IvyNotFound

Copy link
Copy Markdown

Regression runs for 4a11de6 on Windows, the xcl-smoke pair this PR still needs. Same retail title, same 60 s, unedited, made with scripts/smoke.ps1 -Seconds 60 and XCL_PRESS_A_AT=15. The PR head as is (base 930e8b4) and main 930e8b4, clean trees, one after the other.

Windows does not take the copy path (OpenExistingHeapFromAddress works here), so this only confirms that the PR changes nothing on Windows.

  • NVIDIA GeForce RTX 5080 16 GB (32-lane waves), driver 621.24; Ryzen 7 7800X3D; Windows 11 25H2 (26200.9974); rustc 1.100.0 MSVC; DXC 1.9.2602.17; release.

main:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 5080
title: game
seconds: 60
exit: 0x0
frames shown: 1331 (PresentX 1332)
presents per 2 s (last 3): 19 43 38
device removals: 0
crashes: 0
peak commit: 26748 MB

this PR:

xcl-smoke v1
commit: 4a11de6dae7d28159e2de0c42d132c98d79426d8
gpu: NVIDIA GeForce RTX 5080
title: game
seconds: 60
exit: 0x0
frames shown: 1365 (PresentX 1365)
presents per 2 s (last 3): 16 37 47
device removals: 0
crashes: 0
peak commit: 26825 MB

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

Copy link
Copy Markdown

A regression run under Wine on Linux, on a retail title.

Tested

Regression run

main (first run):

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1371 (PresentX 1371)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

this PR:

xcl-smoke v1
commit: 4a11de6dae7d28159e2de0c42d132c98d79426d8
gpu: NVIDIA GeForce RTX 3060
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1378 (PresentX 1378)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 0 MB

The last main run: 1338 frames, exit: 0x0, no device removal, no crash. Under Wine, peak commit reads 0 MB, so these blocks do not check memory.

Not tested

  • the test suite on this head; native Windows; AMD.

AI use

  • Claude Code (Claude Opus 5.5) built both commits, ran the runs and wrote this report. The account owner asked for test reports to be posted and has not reviewed this one.

@brainhay5

Copy link
Copy Markdown

Retail title with the copy path forced on, on a 16 GB NVIDIA card, to add to @eizispark's XCL_UMA_SHADOW=1 run on the RX 9070 XT.

Setup: this stack merged onto main 930e8b4 (merge head 4a11de6, 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:

D3D12.X: UMA import check: not run: the coherent window has a copy in video memory (no host-memory heaps on this D3D12)
D3D12.X: UMA window 3 is not shared with the GPU (XCL_UMA_SHADOW=1) - 4095 MB of video memory at VA 0x2e0000000 stand for it

It does not move the stall here:

t FPS DXC running done queued
30 s 30.1 1 0 56,881
60 s 2.7 1 0 57,817
90 s 0.0 1 0 57,514

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.

@mikebuckets171

mikebuckets171 commented Nov 24, 2026 •

Copy link
Copy Markdown

The xcl-smoke pair @vakaobr asked this bench for: 930e8b4 against #1329 4a11de6, 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:

xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56
gpu: AMD Compatibility Mode
title: retail (Xbox Series X|S package, private drive)
seconds: 60
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB
xcl-smoke v1
commit: 4a11de6dae7d28159e2de0c42d132c98d79426d8
gpu: AMD Compatibility Mode
title: retail (Xbox Series X|S package, private drive)
seconds: 60
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB
xcl-smoke v1
commit: 930e8b49c1c2ec683d22c724a398b39111cd0e56        # second run, warm data root
gpu: AMD Compatibility Mode
title: retail (Xbox Series X|S package, private drive)
seconds: 60
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB
xcl-smoke v1
commit: 4a11de6dae7d28159e2de0c42d132c98d79426d8        # XCL_UMA_SHADOW=0
gpu: AMD Compatibility Mode
title: retail (Xbox Series X|S package, private drive)
seconds: 60
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB

How to read them. Nothing moves: the head matches main exactly, and switching the shadow path off changes nothing either. That is the expected shape on this host — main presents 0 frames in a bounded run here (OpenExistingHeapFromAddress → Not implemented (0x80004001), which is why your path is taken at all), so a pair on main can only prove nothing regressed. The honest statement for the Regression run section is that: 0 against 0, 0 crashes against 0, exit 0x0 on 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 commit reads 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 24

After the PR moved to ac4b997, I reran the same bounded title smoke on current upstream main c4d37bec1bb4286eb373aea963404a23f13401fa and exact PR head ac4b99784033501e28add8780cebc4f680aa1aa3. Upstream main had advanced from the PR's reported base 4178e88 via #1747. Both were release builds for x86_64-pc-windows-gnullvm from 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, and XCL_UMA_SHADOW unset. Local title and data paths are omitted.

Commands: cargo build --release --locked -p xcl --target x86_64-pc-windows-gnullvm; then CrossOver wine --bottle <bottle> --no-gui --cx-app <release xcl.exe> run <same title folder> with XCL_NETWORK=0, XCL_RUN_SECONDS=60, XCL_ACTIVITY=1, XCL_DXC_DIR=<DXC 1.9.2609.5 directory>, and a fresh XCL_DATA_ROOT for each arm. Only the checkout/binary and data-root path differed between runs.

xcl-smoke v1
commit: c4d37bec1bb4286eb373aea963404a23f13401fa
gpu: AMD Compatibility Mode
title: retail (Xbox Series X|S package, private drive)
seconds: 60
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB
xcl-smoke v1
commit: ac4b99784033501e28add8780cebc4f680aa1aa3
gpu: AMD Compatibility Mode
title: retail (Xbox Series X|S package, private drive)
seconds: 60
exit: 0x0
frames shown: 0 (PresentX 0)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 0 MB

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 main and PR-head binaries, ran the two Mac smokes, and drafted this update; the logs are from the named Mac.

@Ahmet-Dedeler

Copy link
Copy Markdown

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_SHADOW switch, 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_e2e skip 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 main with this stack, so if @mikebuckets171 gets to it first, use that.

@us3r40456

Copy link
Copy Markdown

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

  • MacBook Pro M5 Pro, macOS 27.2.1, CrossOver 26.3.0.39832 with D3DMetal 3.0 ("AMD Compatibility Mode"), Rosetta 2. Release, cross-built for x86_64-pc-windows-msvc (cargo-xwin), DXC 1.9.2609.
  • The test title (xcl_testtitle.exe + testgame_mw.dll + tests/data/testgame) run as e2e.rs runs it: xcl run <game> -- --hello, a fresh XCL_DATA_ROOT for each run, one run at a time.
  • Trees: main 9e3831e + D3D12.X: a stage the PC cannot run goes to the fallback without the driver #750 (6569928), and the same + this PR's three commits (4a11de6). Two hunks of the top commit no longer applied as they were because main added code there since 930e8b4: the shadows loop in open_uma now goes after the heap_windows block, and the copies uploads in run_in_region after its CopyBufferRegion of io_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 first IASetIndexBuffer #47 of an index buffer at a title address:

=>0 D3D12GraphicsCommandList::IASetIndexBuffer(D3D12_INDEX_BUFFER_VIEW const*)+0x129 in d3dmetal: movq 0xa8(%rax), %rax   (rax = 0)
  1 xcl::hle::d3d12x::list_x::set_index_buffer      list_x.rs:3417
    xcl::hle::d3d12x::list_x::ia_set_index_buffer_x list_x.rs:3554

With no GPU unified memory, gpu_va hands the title's address over as it is (uma_va_of has nothing for it), and D3DMetal dereferences null where it finds no resource for that address instead of refusing it.

With this PR, four runs:

  • the log has "UMA window 3 is not shared with the GPU (OpenExistingHeapFromAddress is not implemented) – 512 MB of video memory at VA 0x10010330000 stand for it";
  • the IASetIndexBuffer crash is gone in all four;
  • runs 2, 3 and 4 (33 PASS, 1 FAIL, then no further output until the 120–150 s bound): the triangle check's list (console + derived pipeline, IASetIndexBuffer XNetworking: read CERT_CHAIN_CONTEXT at its real offsets #47, DrawIndexedX hle/dstorage: fix queue error reset, event handle duplication, close/release races, and pointer validation #81, nested occlusion queries) never completes: sparse: the queue has not reached fence value 12 after 5 s (at 11), then from Metal Caused GPU Timeout Error (00000002:kIOGPUCommandBufferCallbackErrorTimeout);
  • run 1 (34 PASS, 1 FAIL): the triangle check passes, and the title dies at its first PresentX, in D3DMetal's DXGIFactory::CreateSwapChainForHwnd (a write to null in ntdll), called from present::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

  • A retail title.
  • Debug builds; the rest of the suite.

AI use: Claude Code (Claude Opus 5.5) helped build, run and read the logs; the runs are on my Mac.

@us3r40456

Copy link
Copy Markdown

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-vtables on top it runs to its end.

What was likely wrong: after a crash, the title's process does not go away under CrossOver. xcl run reports Game exited with code 0xc0000005, but xcl.exe and xcl_testtitle.exe stay alive, the title at 100 % of a core. My first run crashed in CreateSwapChainForHwnd, 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: check ps for leftover xcl.exe between runs.)

Tested

Not tested

AI use: Claude Code (Claude Opus 5.5) helped build, run and read the logs; the runs are on my Mac.

vakaobr and others added 3 commits November 24, 2026 17:48
Helpers for the copy path that changes no behaviour yet:

- sparse.rs: extract new_state from the inline closure in init, so
  shadow_window (next commit) can call it when no sparse windows exist
- uma.rs: Uma::shadowed flag and is_gpu_copy(p): a sparse window or a
  committed one the GPU has a copy of. Never set to true in this commit.
- list_x.rs: note_copy_into tracks PC copies into console buffers whose
  memory the GPU has a copy of; note_write uses is_gpu_copy
- real.rs: uma_shadowed helper, res_map and dev_create_placed_resource_x
  use is_gpu_copy (= is_sparse while shadowed is false)

Based on Ahmet-Dedeler's c70bf8a on mac-on-main-wip.

Co-authored-by: Ahmet Dedeler <105894172+Ahmet-Dedeler@users.noreply.github.com>
Assisted-by: Claude Code (Claude Opus 4.6 ported it; Claude Opus 5.5 reviewed it)
D3DMetal 3.0 applies SetPredication for draws, dispatches and
ExecuteIndirect but not for copies: a predicated CopyBufferRegion runs
unconditionally. The UMA shadow path (next commit) makes UMA available
on this host, so the predication test would run and fail.

A one-copy probe detects whether a predicated copy is skipped (Windows,
any real D3D12) or run (D3DMetal). When run, the test skips with
"host ignores SetPredication for copies" instead of failing.

Based on us3r40456's bisect and measurement in xcl-dev#258.

Co-authored-by: Ahmet Dedeler <105894172+Ahmet-Dedeler@users.noreply.github.com>
Assisted-by: Claude Code (Claude Opus 4.6 ported it; Claude Opus 5.5 reviewed it)
D3DMetal answers E_NOTIMPL for OpenExistingHeapFromAddress. A committed
UMA window is then 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 each ExecuteCommandLists (the window's write watch),
GPU writes come back on Map and after the lists' memory writes, and PC
copies into console buffers there are read back after the submit
(list_x::note_copy_into). XCL_UMA_SHADOW=1 forces the path on a GPU
that has such heaps, =0 never.

On main 930e8b4: the start-up check that the GPU sees CPU writes
(check_uma_import) is not run for a shadowed window (it is a copy by
design); sparse::new_state carries the new parked list. The runner's
run_in_region falls back to upload/readback copies per window on
E_NOTIMPL. The sparse test's shadowed readback and constant-rewrite
stress validate the data path.

Part of xcl-dev#258.

Based on Ahmet-Dedeler's c70bf8a on mac-on-main-wip.

Co-authored-by: Ahmet Dedeler <105894172+Ahmet-Dedeler@users.noreply.github.com>
Assisted-by: Claude Code (Claude Opus 4.6 ported it; Claude Opus 5.5 reviewed and fixed the import-check assertion)
@CharlyRien

CharlyRien commented Nov 24, 2026 •

Copy link
Copy Markdown

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)

GPU time in the world

committed window imported from host memory this PR forced
heaviest compute dispatches 7 – 17 s each; with #1850's rule 2.1 – 2.4 s and 0.8 – 1.5 s 4 – 40 ms (two runs)
GPU time per world frame, main queue about 5 s with #1850's rule about 0.35 s (two runs)

The reason is in #1640 (comment): a globallycoherent load from the imported heap costs about 30 times the same load from video memory and is serialized.

What goes wrong with it on Windows

  1. 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's ExecuteCommandLists, on a fence whose work is only submitted after it. With a local change in sparse.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.
  2. Each world frame then waits for about twenty GPU queue.Wait … did not complete within 5000 ms releases, 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.
  3. 40 Wait64BitValueX timed out per run, the same count in two runs.

Not tested: the Mac path, the default Windows path (unchanged by the PR, not rerun), current main. No scripts/smoke.ps1 block: the base is old and carries local diagnostics.

AI use: Claude Code (Claude Fable 5.2) ran the measurements and drafted this report.

@CharlyRien

Copy link
Copy Markdown

Follow-up to my comment above: the per-frame GPU queue.Wait releases on the copy path came from the readback fence that all title queues share in sparse.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

Mechanism (with a journal of every Wait / Signal / Execute per queue)

  • Every title queue signals the same rb_fence with 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.
  • On the copy path the title's own sync cells are in the copied window. Its direct-queue submit thread polls such a cell on the CPU (the Wait64BitValueX fallback) 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 twenty GPU queue.Wait … did not complete within 5000 ms per 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.
  • Seen directly with a probe: 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_fence is upstream code, but in my tree the readback had already been made asynchronous (the local change from my first comment, to get rid of the sparse: the queue has not reached fence value waits inside ExecuteCommandLists). 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.rs only, 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)

run world window frames per second queue.Wait releases 2 s CPU polls timed out sparse 5 s waits
before 162 s 0.07 16 expiries 76 –
1 49 s 1.26 0 0 0
2 42 s 1.38 0 0 0
3 (+ the three fork commits) 20 s 1.35 0 0 0
4 9 s 1.40 0 0 0

The 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

  • A title access violation in three of five runs, at a different place each time (bad or null pointers read from memory; one non-canonical with a 0xaaaaaaaa high 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 D3D12.X: sparse readbacks don't wait for a queue held by a later signal #433's ordering should tell.
  • One run stopped submitting with no warning at all; not reproduced yet with a thread dump.
  • The 3D picture is still flat grey in these runs. That has another cause: the main depth target stays at its clear value (almost nothing is rasterised; every mesh pipeline of the title is refused), so it is not a property of the copy path.

Not tested: the Mac path; the unmodified synchronous readback; #433; current main (being ported). No scripts/smoke.ps1 block: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.