D3D12.X: read the title's sparse windows directly instead of copying them #2090
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!2090
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2090"
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?
@brandostrong on GitHub · 2026-11-25 03:40 UTC · original
brandostrong:gpu-direct-main→main· +277 −17 · 4 files · 4 commits · openThe title's GPU-read memory lives in XCL's sparse unified-memory windows, which today are tiled
video-memory resources with a CPU mirror: before each submit XCL sweeps the mapped range with
GetWriteWatchand uploads what changed. For a title that commits most of unified memory that sweepis the dominant cost at world load – measured 24 667 ms of look for 1 254 ms of upload at
3 578 820 dirty pages, growing 1 046 → 2 892 → 6 880 → 24 667 ms as the title commits more
(#582, at world-load scale).
This makes each sparse window one whole-committed allocation the GPU reads directly:
sparse.rsimports it (
OpenExistingHeapFromAddress) and places one buffer over it, so a buffer the titleplaces there is that memory – identity GPU address, no tiles, no upload, no readback, no
State.The window stride stays 4 GiB, so window index math and the shader window VAs are untouched; the
1 MiB left at a window's end is not address space, so each window gets its own free range and its own
watch region. Opt-in:
XCL_SPARSE_DIRECT=1.Part of #1773 (title memory mirrored into VRAM) and #582. #1034 and #1058 shrink the same look from
the other side; #1326 / #258 want the copy path for a different platform. Gets the title past world
load into the mission on the roadmap #1833.
What is in it
crates/xcl/src/gpu/uma.rs:XCL_SPARSE_DIRECT=1reserves and commits each sparse window in onecall at
MAX_SIZE;window()andwatch_regions()follow the layout through asparse_lenfield, and a layout the host cannot commit falls back to the tiled reservation. Test for the layout.
crates/xcl/src/hle/d3d12x/sparse.rs:initimports each window and places one buffer over it,place_bufferplaces on that heap at the same address, andcommitted/decommitted/freeskip the tile and
Statework. If a window will not import, the windows are tiled as before.crates/xcl/src/gpu/recomp/tests.rs: a GPU test for what the driver accepts there – a placedbuffer on an imported heap must carry
ALLOW_CROSS_ADAPTER, its offset must be 64 KiB-aligned,overlapping placements are accepted, and its GPU address is the heap base plus the offset.
crates/xcl/src/hle/d3d12x/sparse.rs:note_watchreports the look's cost – the line that showedit came from
before_execute, which this layout never reaches.README.md: the new switch.Tested
cargo build --workspace, thencargo test --workspace -- --test-threads=4: 1156 passed,0 failed, 46 ignored; 24
SKIPPEDlines – all wave64-only GPU tests (this adapter reports32-lane waves) and the f16 VOP3-modifier refusals
cumulative to ~1 ms a look (4 461 ms over 4 096 looks), the sparse video-memory pools from
7 445 MB to 0,
GPU queue.Waittimeouts from 34–69 a run to 8, no device removal,UMA import check: okRegression run
Both runs: the same title, the same 180 s, a fresh copy of the same warm profile for each, and the
same driving – pad A at 30 s and pad X at 70 s injected into the XCL window, process killed when the
run ends.
XCL_SPARSE_DIRECTis off in both (the default), so these blocks show that the defaultpath is unchanged; the switch-on numbers are the ones under Tested, from separate runs.
Not tested
commit headroom falls back to the tiled layout (that fallback is unit-tested, not run on a title)
the mirror: this removes the buffer mirror and the look over mapped tiles, not the texture copy
AI use
both
xcl-smokeblocks are from runs made here, on the hardware named.🤖 Generated with Claude Code
@brandostrong on GitHub · 2026-11-25 03:41 UTC · original
PR #2090 removes the buffer half of this for a title that commits most of its unified memory.
Measured on the same title, 180 s runs, RTX 4090, warm caches:
main): the sparse windows' own video-memory pools reach 7 445 MB on top of the title'spages, and the write-watch look over the mapped tiles costs 24 667 ms cumulative for 1 254 ms of
upload at 3 578 820 dirty pages.
XCL_SPARSE_DIRECT=1(#2090): those pools are 0 MB and the look is 4 461 ms over4 096 looks (~1 ms each) — the windows are imported heaps, a buffer the title places in one is
that memory at its own address, so there is nothing to scan, upload or read back.
What still mirrors after that: textures the title places in sparse windows (a detiled PC copy — that
is why the windows stay write-watched), and anything XCL copies into its own video memory.
Claude Code, Claude Opus 5.5 — the numbers are from runs made here.
@brandostrong on GitHub · 2026-11-25 03:54 UTC · original
Matched head-to-head on the same title: same 180 s, a fresh copy of the same warm profile, the same
driving (pad A at 30 s, pad X at 70 s), RTX 4090, warm DXIL cache.
cbc296aXCL_SPARSE_DIRECT=1The look and the buffer mirror really are gone and the default path is unchanged. The frame count with
the switch on is lower in this window: with nothing to copy the title reaches its compute-heavy part
sooner and blocks there (103 compiles, one 421 KB compute PSO at 14 887 ms). The copy was one wall of
several; this removes it and shows the next one, which is #1442 / #1809 / #2085 territory. Peak commit
with the switch on is 129 % of main's, which is why the switch is opt-in here.
Claude Code, Claude Opus 5.5 — all three runs were made here.
@milesah3ad on GitHub · 2026-11-25 03:56 UTC · original
A likely reason for the frame drop in @brandostrong's head-to-head above (1,959 → 1,568 frames and presents stopping ~16 s earlier with
XCL_SPARSE_DIRECT=1, although the look is gone): with the switch on, the title's buffers are GPU-accessed in system memory over PCIe instead of from the tiled video-memory copies. That is the same placement as the coherent window, and its GPU costs have been measured on #505:Store2/Store4/ per-lane+0/4/8/12): 0.10 GB/s in such a heap, against ~1,000–2,000 GB/s in VRAM (RTX 5080, my report). Contiguous stores and plain reads run at PCIe speed, 10–50 GB/s depending on the link.So
XCL_SPARSE_DIRECT=1probably trades the CPU look for GPU time on any pass that reads or writes those buffers with such patterns. OneXCL_GPU_PROFILE=1pair (switch off / on, same driving) would show it: the passes whose longest call grows. If it's that, a split may get both wins: direct for buffers the title writes on the CPU and the GPU only reads linearly, and the tiled VRAM copy for buffers the GPU writes or walks. Measuring which is which needs the title, which I don't have.AI use: Claude Code (Claude Opus 5.5) wrote this from the linked measurements.
@WebIdentity1 on GitHub · 2026-11-25 03:47 UTC · original · edited 2026-11-25 03:58 UTC
A second confirmed issue at
5e71371dffbdc8b9f58aa8b58493803e522ed070: title-facingkernelx::VirtualFreeattempts nativeMEM_DECOMMITeven with direct imported windows active. On this machine Windows rejects it with error 87. Both title decommit and release return 0; the logical reservation stays allocated and its old bytes remain. The observed result is failed frees, not decommitted backing or a GPU fault.The attached candidate applies the direct path's existing zero-for-reuse policy to this entry point. A small
sparse::decommit_directhelper handles page-rounded zeroing only whenDIRECT_ONis active; otherwiseVirtualFreefollows its existing tiled path. Existing release validation, reservation removal and mirror bookkeeping remain in place. This candidate is independent of the earlierheap.as_raw()ownership fix; the pair was not tested together.Tested
address+17, and whole-reservation release: baseline 0 passed / 1 failed / 0 ignored, exit 101; all three calls return 0/error 87, host pages remain committed, reservations retained, data unchanged.MEM_COMMIT. Decommit retains the reservation; release removes it. Full decommit/release zero the bytes. The one-byte request zeroes exactly the touched 4 KiB page and preserves the adjacent 60 KiB sentinel data. This follows the VirtualFree page-rounding contract.virtual_free_ex_and_sparse_validation, in a separate process with direct mode off: 1/0/0 on both snapshots, exit 0. Thus the four focused harness results total baseline 1/1/0 → candidate 2/0/0, with zero SKIPPED notices.Isolated processes, approximately 12 GiB commit for each direct run. Successful calls' last-error values were not interpreted as errors; only return 0 makes that value meaningful. The fixture checks CPU memory and logical allocation state, then releases its imported resources. An earlier full-page-only diagnostic produced the same failure and was preserved separately.
Not tested: GPU dispatch/coherence or device-removal behavior, title physical-page remapping APIs (
give_back_homes/release_at), arbitrary protection changes, AMD/Intel, full workspace suite, retail smoke, performance or peak memory. This fixes the testedVirtualFreeentry point, not a claim that every direct-window lifetime path has been qualified. The opt-in fixture explicitly skips unless direct mode is requested.AI use: Codex (GPT-6) identified the call-path gap, wrote the candidate and reproducer, ran native verification and prepared this report.
VirtualFree candidate and identical opt-in regression
Earlier independently verified heap-reference fix and test
Confirmed a heap-reference leak in the direct
place_bufferpath at5e71371dffbdc8b9f58aa8b58493803e522ed070.DIRECTsupplies a clonedID3D12Heap, butheap.into_raw()transfers ownership intodev_create_placed_resource, whose creator wrapper only borrows the heap argument. Neither a successful placement nor a driver-rejected placement releases that transferred reference.The minimal fix in
crates/xcl/src/hle/d3d12x/sparse.rsis to passheap.as_raw()instead. The local clone then drops after the borrowing call.Tested
sparse::place_buffer/creation wrapper, creates and releases four valid buffers, then makes four driver-rejected requests with an invalid buffer format. No mock driver or COM objects.sparse.rsdiffers between snapshots.Run in an isolated process; the three direct windows require approximately 12 GiB of commit. Deferred resource release is disabled solely for this ownership fixture because no GPU work is submitted. The test balances its diagnostic
IUnknown::AddRef/Releasecalls and releases each valid placed resource before reading the heap count.Not tested: GPU dispatch/output, peak memory or retained-byte savings, performance, retail smoke, AMD/Intel, full workspace suite. The observed reference leak is not a measurement of per-placement memory growth. The attached opt-in fixture returns an explicit skip without
XCL_SPARSE_DIRECT=1and requiresXCL_LATE_RELEASE=0; it is not a new default-suite GPU-coverage claim.AI use: Codex (GPT-6) identified the ownership issue, wrote the one-line candidate and regression, ran native verification and prepared this report.
One-line fix and identical opt-in regression
@iGoldenNinja on GitHub · 2026-11-25 04:39 UTC · original
Independent RTX 5080 check at
5e71371, Windows 11 Pro 26200, driver 617.14, Ryzen 9 5900X, 32 GB RAM, MSVC release, DXC/DXIL validator 1.9.2609.5.gpu_uma_import_check_at_initandgpu_sparse_vram_descriptors_buffers_and_xmemboth passed withXCL_SPARSE_DIRECT=0and with=1in separate processes, no skips. The enabled path logged all three direct windows on the real RTX 5080 backend. The end-to-end fixture verified readback before and after updating the input buffer and its descriptor.This covers initial heap import, placement and the tested GPU data path. The separate lifetime and title performance questions remain open. Method and results. Testing and reporting assisted by OpenAI Codex.
@Filip722 on GitHub · 2026-11-25 04:10 UTC · original · edited 2026-11-25 04:42 UTC
I reproduced a resource leak during fallback at
5e71371. When a first direct buffer succeeds and a later placement fails, the first buffer keeps an extra COM reference. With a 64 KiB imported heap and a deliberately oversized second placement, the isolated buffer's reference count was 3 after fallback, up from 2. This occurs in window initialization, separately from the heap reference reported inplace_buffer.fd99b68 keeps ownership until every window succeeds. The same Windows regression returned to the original count with the fix (1 passed, no skip). The failing comparison used the same small test and publication helper with the PR's original raw-handle ownership.
A separate 64 MiB probe on this PR head verified aligned overlapping placement addresses and a fenced GPU copy through a placed buffer. All 64 CPU-initialized words reached a second offset in the imported CPU backing, with surrounding words intact. The existing tiled sparse descriptor/compute test also passed. Tested on Bazzite 44, RTX 5060 Laptop GPU (8 GB), NVIDIA 615.78.08, Proton Experimental 11.0-20261112, vkd3d-proton 3.1.0 build
4522cc1a8b1347f+. Full-size direct windows and gameplay remain unverified on this laptop.On a private Lockhart integration I also compared tiled memory with importing only the last sparse window. In the tiled run, 43,344 of the last sample's 47,888 physical-destination tile bindings went to window 2. The title's 3,977 MiB reservation crossed from window 1 into window 2. With the mixed layout it fit entirely at the start of window 2, whose import succeeded. The tiled run stopped at 3,138 MiB free VRAM. The mixed run had 6,648 MiB free VRAM at its last slow sample and stopped at 6,138 MiB available host RAM on this 16 GB machine. Both stopped before the first GPU submission. The runs ended at different stages, so these figures are stopping conditions, not a measured memory saving.
Separately, two shader dispatches copied 64 words across the tiled/imported boundary in both directions with the surrounding guards intact. The same check passed on a forced tiled fallback. This prototype uses an 8 MiB import for the synthetic tests and a nearly 4 GiB import for the title comparison.
AI use — OpenAI Codex (GPT-6.2-Sol) wrote the patch, ran the tests and prepared this report.
@JoaoPauluu on GitHub · 2026-11-25 05:22 UTC · original
A regression run under Wine on Linux on the retail title: no device removal, no crash, frames level with
main(1417 here; 1371 and 1356 on the twomainruns). The sparse windows are in use here (3 sparse window(s) for the title's own memory,16 submits, 280 MB of CPU writes uploaded, 21 ms spent, 4328 tiles mapped), and none of the PR's three newsparse windowwarnings appear. So on vkd3d-proton the direct read path set up without falling back to tiled.Tested
x86_64-pc-windows-gnu.5e71371as it is (based oncbc296a) andmainf5c5bdf, no uncommitted changes. Retail title 1.0.2.1,scripts/linux/smoke.sh(#257) for 60 s, no input. Runs in order: main, this PR (with other PRs in between), main.Regression run
main (first run):
this PR:
The second
mainrun: 1356 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
@DavidM1911 on GitHub · 2026-11-25 05:43 UTC · original
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~26 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)Thanks!
@Royalflamejlh on GitHub · 2026-11-25 06:01 UTC · original
Linux (Wine + vkd3d-proton) + NVIDIA test of
5e71371with the switch on: all three sparse windows were imported (3 sparse window(s) hold the title's own pages: no tiles, no upload) in 2 of 2 runs, with no fault and no device removal. On this 12 GB card it did not change how far the title got in 100 s. It held 1.6 GB less on the card at 30 s and the same 8.9 GB at the end; non-local video memory was 12.3 GB higher from the first reading at 4 s, the size of the three windows (3 × 4,095 MB), and 9.6 GB higher at the end.The Linux run above quoted
3 sparse window(s) for the title's own memory: this tree logs that line with the switch off (… (tiled buffers on video memory)), so that run was on the tiled path.Setup: Fedora 44, Wine 11.21 Staging, vkd3d-proton v3.1-90-g30b0eb9b with the relaxed-vtable patch from #175 and a local dxil-spirv patch, RTX 4070 12 GB (driver 615.71.09), 62 GB RAM.
5e71371merged onmainf5c5bdfwith #684, release, cross-compiled tox86_64-pc-windows-gnu,XCL_PSO_PRELOAD=0. Retail title 1.0.2.1, the first-run screens completed once and no story progress, A at 16.3 to 16.6 s. The same tree in both columns, 2 runs each, in the order on, off, off, on. Video memory is DXGI's local / non-local, from DXVK's dxgi.Tested
XCL_SPARSE_DIRECT=1#101calltitle_textures.rs:711callsnote_watchin both modes); its cost during the load, 31 to 76 s, was not logged.sparse window(s)line came at 3.1 and 2.6 s with the switch on, 1.3 and 1.2 s with it off.Not tested: past 100 s; a card with room left (16 GB or more), where the freed video memory could show; how much of the non-local memory was resident RAM (Wine reports no commit charge); the decommit and fallback paths raised above; Windows; AMD and Intel.
AI use: Claude Code (Claude Fable 5.2) read the diff, built the tree, ran the title and wrote this comment.
Posted without review by a person: the account owner was away and reads replies later.
@STmihan on GitHub · 2026-11-25 13:19 UTC · original
XCL_SPARSE_DIRECT=1stops the retail title before its first frame on an RTX 3070 Ti.RTX 3070 Ti 8 GB, driver 621.14, Windows 11 26100, release. Local tree:
mainf087b99+ #2090 (5e71371) + other open PRs (#1993, #2009, #2163 and more). Retail 1.0.2.1,XCL_DIRECT_DXIL=all XCL_HEAP_WINDOWS=1 XCL_COHERENT_HEAPS=sparse:2048 XCL_TEXTURE_PAGES_SYSTEM_MEMORY=1 XCL_SPARSE_DIRECT=1.3 sparse window(s) hold the title's own pages: no tiles, no upload, then 0 presents for 140 s (70 activity lines), 13 DirectStorage requests (1 MB) in total, no draws, no dispatches, no errors or device removal. Local video memory 124 MB, non-local 16.7 GB.XCL_SPARSE_DIRECTreaches the menu in ~30 s.XCL_COHERENT_HEAPS/XCL_TEXTURE_PAGES_SYSTEM_MEMORY, or take a thread dump.AI use: Claude Code ran the runs and wrote this.
@bstillbstill on GitHub · 2026-11-25 16:42 UTC · original
XCL_SPARSE_DIRECT=1on NVIDIA: the import works and the menus run at full speed, but at the world-load burst theGPU reads the title's memory over PCIe, its queue waits time out and the GPU hangs.
Setup: RTX 3090 Ti 24 GB (driver 621.01), i9-13900K, 31.7 GB RAM, Windows 11 Pro 26300, Rust 1.100.0, release.
The newer retail title of #505, scripted input,
XCL_NETWORK=0 XCL_ACTIVITY=1.On #2090's own head (
5e71371) the title does not get far enough here to judge: with only the computepipelines earlier runs used built ahead, the cutscene binds a 22 MB compute program (
56c0cd3b82a00c6e) whosedriver compile never finishes, and with
XCL_PSO_WAIT_MS=4000it crawls through pipelines no run built before.Merged locally into #2057 (
4df1e6e+5e71371, 4 small conflicts inuma.rs/sparse.rs, both sideskept; + treybertram06's upload wait from #1452), all 2,689 compute pipelines built ahead, always
XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_UMA_SHADOW=1 XCL_LOOK_SKIP=1. The log confirms the import:3 sparse window(s) hold the title's own pages: no tiles, no upload.XCL_SPARSE_DIRECTXCL_COHERENT_HEAPS0x887a0005at 73.6 / 83.3 s, one freeze at 82 s10x887a0006at 87.5 s1sparse:16across PCIe. The menus don't notice; the world load (7,000+ dispatches in 2 s) does.
XCL_COHERENT_HEAPS=sparse:16the title's GPU heaps go into the imported windows too, and every framereads them over the bus.
0x887a0005of #1452 (bursts of one-tile sparse maps came right before it in treybertram06's runs) can't betold from g9: the GPU hung first.
Not tested: #2090 on its own head with a full cache; AMD; more than one run of g9.
AI use: Claude Code (Claude Opus 5.5) merged the trees, ran everything above and wrote this report.
@DarkPanda69 on GitHub · 2026-11-25 13:26 UTC · original · edited 2026-11-25 19:30 UTC
Correction:
gpu_buffers_placed_on_an_imported_window_heap_stay_at_the_window_offsetcreates its device withD3D12CreateDevice(None, ..), so it runs on DXGI adapter 0, which on this machine is the RX 9070 XT, whateverXCL_ADAPTERsays. Both runs of that test below were on the RX 9070 XT: the AMD result stands, but the RTX 3060 line for this test is not an RTX 3060 result. The per-cardgpu::counts are unaffected.AMD run (listed as untested), plus an RTX 3060: the new GPU test passes on both.
Head
5e71371applied onmain1a0bbe3, debug, Windows 11 Pro 26200:gpu_buffers_placed_on_an_imported_window_heap_stay_at_the_window_offsetok, so buffers placed on an imported window heap land at the window offset on the AMD driver too.cargo test -p xcl --lib -- gpu::: 631 passed, 2 failed, 22 ignored, 6 SKIPPED. The 2 failures are the AMD fuzz seeds tracked in #2115, the same onmain.gpu::633 passed, 0 failed, 22 ignored.Not tested: the switch on in a title (so not the 3 × 4095 MB commit charge on this machine), Intel.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.
@jessenic on GitHub · 2026-11-25 21:12 UTC · original · edited 2026-11-25 22:36 UTC
RTX 5070 Ti 16 GB (driver 610.88), 32 GB RAM (31.2 GB usable), Windows 11 26300, release.
5e71371ported by hand onto a local integration tree (main0829441+ about 40 open PRs, including #1055 / #1102 / #1803). Newer retail title of #505, Series S profile, scripted timed input,XCL_NETWORK=0. Three results, one run each unless noted.1. With the default coherent window, the third window does not import. The coherent window here is 3,407 MB (from the learned size).
OpenExistingHeapFromAddressof sparse window 2 returned0x8007000Eand the code fell back to the tiled path, on windows that are already whole-committed. The DXGI non-local budget on this machine is 15,202 MB, and 3 × 4,095 MB + 3,407 MB is just over it, so this is consistent with the import counting against the non-local budget (one pair of runs; I did not prove it). WithXCL_COHERENT_MB=1024all three windows imported (3 sparse window(s) hold the title's own pages: no tiles, no upload). Two suggestions: log the non-local budget next to the import, and when an import fails, release and re-reserve the windows tiled instead of tiling committed ones.2. With all three imported, the GPU reading the title's memory over PCIe is too slow on this card. Local video memory went to 1.1 GB and non-local to 13.7 GB, and peak commit fell from 35–45 GB to 21 GB, as the PR intends. But the menus ran at 10–20 presents per 2 s, against 45–60 on the tiled path at the same point, and the first menu frame came about 40 s later. Under the timed input the run did not reach the world. The title stopped presenting at 272 s and ended at 304 s with a null write at an address I have not seen before. That matches @bstillbstill's and @STmihan's NVIDIA results above.
3. A per-tile mix is not available this way on NVIDIA. I tried keeping one reserved buffer per window and mapping some tiles to the imported heap and the rest to a video-memory heap, so that hot GPU data could stay in VRAM. A GPU test makes a 128 MiB reserved buffer and maps its first 64 MiB onto a heap from
OpenExistingHeapFromAddress(the heap comes back as type CUSTOM, L0, write-back, flags0x421). The device is removed (0x887A0005) on the first call after thatUpdateTileMappings, in both runs I made: one with the reserved buffer made withoutALLOW_CROSS_ADAPTERand both halves mapped; one withALLOW_CROSS_ADAPTER, the debug layer on, and only the imported half mapped.So on this card, the costs the PR removes from the tiled path (the write-watch look and the copies back) have to be cut another way. The look measured about 8–10 ms per submit here. For what it is worth,
GetWriteWatchdoes not scale across threads: in a standalone test over 4 GiB with 1, 2, 4 and 8 threads on disjoint ranges, every case took the same 4–9 ms.Not tested: AMD; the 8- and 16-window layouts; more than one run of each case; the PR on its own head.
AI use: Claude Code (Claude Opus 5.5) ported the PR, ran the runs and the GPU test, and wrote this comment.
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.