Repository navigation
D3D12.X: ~43x FPS over main on Series X (0.58 -> 25.3 fps, ~7x over #2844): XCL_UMA_DRIVER=mixed keeps part of the coherent window in VRAM - #2938
Conversation
… copy The unchanged-content hash, the detile of title textures and the frame-trace sampler read the title's memory in place once it looked readable (xcl-dev#602). That bypasses the ReadProcessMemory copy of read_committed (xcl-dev#484): the title can decommit or unmap those pages from another thread at any moment, and the read then faults with 0xC0000005. with_title_bytes replaces title_bytes. A range inside the coherent committed window is still read in place: XCL's VirtualFree never decommits that window (MEM_DECOMMIT there zeroes the block in place). Everything else is read as read_committed reads it, into a buffer kept per thread and dropped after a read that grew it past 64 MiB. read_committed_into now writes every byte (copied, or zero for a page that is not readable), so the reused buffer needs no memset and nothing of an earlier read shows through a hole. Only long-lived threads reuse the buffer: the scoped workers of a parallel batch detile allocate one per batch. title_bytes_survive_concurrent_decommit hashes 1 MiB while another thread decommits and recommits its 64 KiB pages; it checks that every decommit and recommit succeeded, that some happened during the hashing and that each read holds the title's bytes or zeros. title_bytes_leave_guard_pages_alone reads a guard and a no-access page as zeros and checks that the guard stays. read_committed_into first copies the whole range with one ReadProcessMemory and walks it region by region with VirtualQuery only when that is refused (a page not committed, no-access or a guard page; the guard stays). VirtualQuery scans from the page asked about to the end of its run of like pages, and the title's memory is a few runs of hundreds of MiB: in a release microbenchmark (7600X), reading 16 KiB / 256 KiB / 4 MiB of a fully committed 64 MiB region took 128 / 125 / 280 us with the walk and 1.3 / 6.9 / 156 us now (512 MiB region: 1629 / 1179 / 1753 us, now 1.4 / 7.5 / 128 us). A range with holes pays one refused copy on top of the walk (4 MiB with one hole: ~158 us before, ~230 us now).
… on NVIDIA The title's GPU code reads and writes the coherent window (4 GiB of host memory) through a heap opened with OpenExistingHeapFromAddress. On an RTX 5070 Ti, GPU loads from such imported pages ran 8-24x and atomics 13-22x slower than from a driver CUSTOM write-back L0 heap in host memory, at the same CPU caching. A whole-frame replay of a captured title frame took 172 ms of GPU time with the window in a CUSTOM L0 heap and 1,427 ms with it imported as XCL does, the hot compute programs 18-39x slower each. At open_uma the window's written pages are copied out, the window is released, every other free stretch of 1 GiB or more is reserved for a moment so that the driver's CPU mapping of a new CUSTOM L0 heap can only land in the hole the window left, and the pages are copied back. The title keeps its pointers. If the mapping lands anywhere else, or a step fails, the window is made again at its address with its pages and imported as before; if the snapshot of its written pages fails, the window is not released at all (found in review by thehollowedone, with the test failed_write_watch_does_not_release_the_original_window). Buffers placed in it drop ALLOW_CROSS_ADAPTER. The heap is made with D3D12_HEAP_FLAG_ALLOW_WRITE_WATCH, and GetWriteWatch reads the mapped window on an RTX 5070 Ti (driver 610.74), so the window stays in the write-watched regions and the title's CPU writes reach its textures as with the import; a driver that refuses the flag, or whose mapping GetWriteWatch cannot read, keeps the import. The backend (and with it the window and any driver remap) is made once before load_main, before a title DLL's TLS callbacks or DllMain can hold a window pointer; a backend first made later only imports, so no remap happens under guest threads. A write between the snapshot and the release could otherwise be lost. If the window cannot be made again at its address after it was released, XCL logs it and ends the process rather than run the title on an unbacked window. Both found in review by thehollowedone, with their tests (the e2e order check and failed_restore_stops_before_importing_an_unbacked_window). On by default for an NVIDIA adapter outside Wine; XCL_UMA_DRIVER=0 turns it off, XCL_UMA_DRIVER=1 (or custom) turns it on elsewhere. Under Wine the whole-range ReadProcessMemory read of title texture bytes (from the commit below) went through guard and no-access pages, failing title_bytes_leave_guard_pages_alone on Wine/NVIDIA (found by SlopTart, traced by thehollowedone); there it goes region by region as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A formatted byte store normally updates the containing word with atomic AND and OR. Let one selected compute translation use a byte UAV spanning the same raw windows. Keep wider stores on the existing lowering and distinguish the translation in the offline and runtime cache keys.
A title list's extra segments (mid-list splits) are parked as spares at the list's next Reset, and the segments KickoffX takes back become spares too. A spare records again only after its own later Reset, but alloc_pool still counted it as a user of the PC allocator it last recorded on, so that allocator was never free: each later Reset of the title's allocator while those were "in use" put another PC allocator aside, and none was ever reused or released. The previous recording a stand-in replaces at Reset pinned its allocator the same way. alloc_pool::park_list drops the list from its allocator's users (its submit marks stay, so the allocator is reused only once the GPU is past them). title_list::reset parks the moved segments and the replaced recording; KickoffX parks its reclaimed segments after both submits. Measured on the title (RTX 5070 Ti, Series X profile, 240 s untimed runs, object counts from 100 to 240 s): PC allocators 1,137 -> 1,928 without, 728-753 -> 862-897 with; non-local video memory 6.2 -> 9.6 GB without, 5.0 -> 5.4-5.5 GB with (about 4 GB less at 240 s). Timed pairs showed no frame-rate cost (late window 11.99 / 10.76 fps without, 10.76 / 11.76 with; run-to-run spread ~10 %). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The direct DXIL translator gave every compute program that uses LDS the whole 8,192-dword groupshared block D3D12 allows, with the split form's exchange words at its top. With XCL_DECLARED_LDS=1 it declares what the program's header asks for instead: the static workgroup LDS from COMPUTE_PGM_RSRC2 (CsInterface::lds_dwords), plus the exchange words and counters of the split form (or the arrival counter of a native 2-D/3-D group) placed after it. A header with no size, or one too big to leave room for them, keeps the 8,192-dword layout. LDS addresses are clamped to the declared top. The translated-shader caches key the switch apart. Less groupshared memory per group lets more groups run at once. On the title (RTX 5070 Ti, Series X profile, per-program GPU timestamps over 187-229 s), the late frame's compute went from about 89 to about 78 ms per present with the switch on; 66 of the late programs translate differently (the split family and wave32 programs), and with the switch off the translation is byte-identical. Tests: compute_lds_reservation_matches_descriptor_and_lane_storage (the declared size and lane storage per mode), and declared_lds_disk_cache_separates_both_direct_routes (the cache keys). Written by reed on our team branch; split out on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every submit looks at all watched memory with GetWriteWatch, and the call is paid per byte looked at (about 0.5 ms per GiB). In a streamed world 17.6 GB are watched, and most of it is written once when it streams in and not again. With XCL_WATCH_TRAP=1 a 2 MiB block of a watched range that 64 looks in a row found clean is made read-only and left out of the looks. Its first write faults into a vectored handler, which gives the block its protection back and returns it to the looks; the write happens after that, so write-watch reports it as before. A block that cannot be made read-only (pinned, nothing committed, not all read-write) is tried again after another 64 looks, not at every look, and a block with nothing committed leaves the looks as a hole until a commit in it. A kernel write into a read-only page fails instead of faulting, so the title's ReadFile buffers get their protection back and stay pinned until the read is over, and their pages are then reported as written. Commits, decommits and protection changes through kernelx, lazy pages and sparse commits give the blocks they meet their protection back first, and so do XCL's own checks whether memory is writable. Off by default; without the variable only a sorted list gets a dedup. Measured on title ea3b5e4d on a tree with the driver-heap windows of xcl-dev#2844 (RTX 5070 Ti, one timed run per arm, the trap the only change): 5.79 against 4.01 presents/s over 107-223 s of the run, 8.45 against 4.60 over 187-229 s, the same draws per present, no device removal. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A look copied the read-only spans into a new map and then made two map queries per span to find the pieces still to look at. In the late world of title ea3b5e4d that is about 9,000 spans a look and 20 looks a present. hot_pieces now walks the spans once, under the lock, while the ranges ascend (a look's are sorted and disjoint), and starts the walk again for a range that does not. Measured without a GPU, a look with a take that does nothing, 18 GiB watched in 64 ranges, 8,861 spans, 355 blocks left to look at: 336 us before, 40 us after (RTX 5070 Ti machine, release build). In the title, on a tree with the driver-heap windows of xcl-dev#2844 (one untimed run per arm): the write-watch part of a look 1.06 ms against 1.29 ms. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
@Kalmarv, a test report from a machine without Resizable BAR: here, a failed What ran: Result: 5 of the module's tests pass. Then the test process exits with Reading of it (not verified):
Setup: RTX 3090 24 GB, driver 616.56, AI use: Claude Code, model Claude Opus 5.5. It ran the test, read the code and wrote and posted this. The person running these tests authorized overnight posts but has not reviewed this text. |
|
I reproduced the restore failure from the comment above on Windows, RTX 5070 Ti Laptop, NVIDIA 621.24, at A local guard checks OpenAI Codex (6.2sol) assisted with reproduction and verification. |
|
Independent mixed-memory check on the 12 GB RTX 5070, driver 616.92, using PR head A separate test-only fixture used five alternating 64 MiB segments. CPU-written markers survived remapping, GPU copies recovered the expected data, and four 32-byte reads crossing segment boundaries matched the CPU pattern. One test passed, no reported skips. These bounded synthetic tests do not establish full-size residency, sustained throughput or GTA VI performance. AI use: OpenAI Codex with GPT-6.2 Astra constructed and ran the checks; Codex coordinated and prepared this report. |
|
Thanks @CharlyRien, @ettehn, and @andrewDoing for testing and tracking down the ReBAR-off restore issue so quickly!\n\nFor anyone without Resizable BAR: we are working on the clean fallback fix so XCL_UMA_DRIVER=mixed falls back cleanly instead of aborting startup—we will push that update shortly.\n\nAlso, if you are on RTX 30-series / RX 6000+ with a compatible CPU and motherboard (such as RTX 3090 + Ryzen 5000), it is worth checking your motherboard BIOS for Above 4G Decoding and Resizable BAR—it is often disabled by default, and turning it on unlocks GPU_UPLOAD heaps.\n\n*(Posted by Kalmarv's AI assistant at his direction.)* |
|
On a card without Resizable BAR, the Setup: RTX 2060 SUPER 8 GB (driver 617.14), i5-9400F, Windows 11 26300. What happened: Why it may matter beyond the test: AI use: build, test and analysis by Claude Code agents (Claude Sonnet 5.5), this note by Claude Code (Claude Opus 5.5). |
With XCL_UMA_DRIVER=mixed:<start_mb>:<size_mb>[,...] the coherent window becomes several driver heaps instead of one CUSTOM heap: each listed range a GPU_UPLOAD heap (video memory the CPU writes through the BAR; on NVIDIA it stays in video memory up to 2 GiB) and the rest CUSTOM write-back L0 heaps. Each segment's CPU mapping lands at its place in the window (every slot reserved first, the rest of the address space groomed as for the single heap), and one reserved buffer over the window maps its 64 KiB tiles onto the segments' heaps, so shaders and placed resources see one window as before (UMA_HEAPS keeps the segments; uma_heap_for picks one). - The CUSTOM segments are write-watched as the single heap is; a segment that refuses it fails the remake, which restores the window and keeps the import. The GPU_UPLOAD segments are not write-watched: their write-combined pages refuse the watch trap's read-only protection. Uma::watch_regions lists only the watched segments. - CPU reads of the GPU_UPLOAD segments through the BAR ran at 12-84 MiB/s, so the title texture code reads them by a copy on the COPY queue into a readback buffer (read_vram_bytes). - An adapter without GPU_UPLOAD heaps (D3D12_OPTIONS16; Resizable BAR off) gets the single CUSTOM heap: this is asked before the window is released. A GPU_UPLOAD segment refused anyway becomes a write-watched CUSTOM segment, because the segments mapped before it cannot be given back: a dropped segment's pages stay with the driver (VirtualQuery still shows them committed seconds later, and a new heap of that size maps there again), so the window could not be reserved again (Windows error 487). - A window that cannot be made again at its address after a failure stops the process, as the single-heap remake does. On the title (RTX 5070 Ti, Series X profile, mixed:1536:1792 with the team's set: watch trap, declared LDS, A9 byte stores, level pages, parked spares), fps.py over 187-229 s: 25.28 fps (TX1) and 24.15 (CB2m3), against 11.99 with one CUSTOM heap (CB2) in the same set. Written by reed (57496b69 on our team branch); ported onto xcl-dev#2844's head. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
bc4252d to
9f99282
Compare
|
Thanks @CharlyRien, @ettehn and @3L1A5-1 for the reports and the reproduction, and @andrewDoing for the extra segment-layout check. Fixed in 9f99282 (squashed into this PR's commit; head force-pushed from bc4252d). Cause. Reproduced here (RTX 5070 Ti, 610.74) with an injected refusal. Once a CUSTOM segment has been mapped, Fix.
Tested on 9f99282: RTX 5070 Ti (610.74), Windows 11 Pro 26200, Rust 1.99.0 MSVC, debug, DXC 1.9. Not tested: an adapter without Resizable BAR (the guard takes the single-heap path before anything is released there, but I could not run it). A run of the title on this head: the smoke pair is queued. AI use: Claude Code (Claude Opus 5.5) reproduced the cause, wrote the fix and test, ran the suite and wrote this comment. |
|
Independent Windows retest of the fallback at I also ran a test-only variant forcing the initial OPTIONS16 support check false, with OpenAI Codex (6.2sol) assisted with verification. |
|
Separate placement issue on I reproduced this on Windows using the PR’s UMA allocator and placement code in a standalone fixture, with a 256 MiB window split 64/128/64 MiB. After reserving the first 63 MiB, a 2 MiB buffer returned Native D3D12 follow-up. On Windows / RTX 5070 Ti Laptop (621.24), I repeated the 63 MiB + 2 MiB case with the PR’s actual 256 MiB mixed window and native OpenAI Codex (6.2sol) assisted with verification. Originally posted by @ettehn in #2938 (comment) |
Stacked on #2844, #2926, #2936, #2937 and #2934; only the top commit (9f99282) belongs here. The others are in the head so that it reproduces the measured tree.
With
XCL_UMA_DRIVER=mixed:<start_mb>:<size_mb>[,...]the coherent window becomes several driver heaps instead of #2844's one CUSTOM heap: each listed range aGPU_UPLOADheap (video memory the CPU writes through the BAR; on NVIDIA it stays in video memory up to 2 GiB) and the rest CUSTOM write-back L0 heaps. Each segment's CPU mapping lands at its place in the window (every slot reserved first, the rest of the address space groomed as #2844 does), and one reserved buffer over the window maps its 64 KiB tiles onto the segments' heaps, so shaders and placed resources still see one window.Headline (RTX 5070 Ti, Series X profile, same title, timed runs alone; fps over 187-229 s / 107-223 s)
XCL_UMA_DRIVER=mixed:1536:1792 XCL_WATCH_TRAP=1 XCL_DECLARED_LDS=1 XCL_BYTE_STORE_CS=e166372fa54a77c7 XCL_TEXTURE_LEVEL_PAGES=1 XCL_PARK_SPARES=1XCL_PARK_SPARESand without the look-walkXCL_UMA_DRIVER=customXCL_PARK_SPARES=1was D3D12.X: segments parked as spares stop holding their PC allocator (~4 GB less non-local memory) #2936's switch then; D3D12.X: segments parked as spares stop holding their PC allocator (~4 GB less non-local memory) #2936 has none). This commit's own share is CB2 -> CB2m3 on the older base, everything else equal: 11.99 -> 24.15 fps late (2.01x). TX1 is the combined result.GPU_UPLOADpart cut PCIe traffic by about two thirds.What is in it (9f99282)
uma_driver.rs:mixed:parsing (parse_mixed, anddecidetakes it as on),build_segments,remake_window(the mixed remake or D3D12.X: UMA windows in a driver heap on NVIDIA, 4.9x FPS (0.62 -> 3.03) #2844's),remake_mixed, and the reader of theGPU_UPLOADsegments (read_vram_bytes: a copy on the COPY queue into a readback buffer, as CPU reads of that memory through the BAR ran at 12-84 MiB/s).GPU_UPLOADsegments are not write-watched: their write-combined pages refuse the watch trap's read-only protection.Uma::watch_regionslists only the watched segments (gpu/uma.rs).remake_windowasksD3D12_OPTIONS16.GPUUploadHeapSupportedbefore the window is released, and without itmixedfalls back to D3D12.X: UMA windows in a driver heap on NVIDIA, 4.9x FPS (0.62 -> 3.03) #2844's single CUSTOM heap (a warning in the log). AGPU_UPLOADsegment refused anyway becomes a write-watched CUSTOM segment in its place. A segment that was mapped cannot be given back: afterUnmapand the heap's release its pages stay with the driver (stillMEM_COMMITseconds later; a new heap of the same size maps there again), so the earlier rollback could not reserve the window again (Windows error 487) and stopped the process (found by @CharlyRien, @ettehn and @3L1A5-1).real.rs:UMA_HEAPSkeeps each window's segments anduma_heap_forpicks the one a placed resource falls in.title_textures.rs:with_title_bytesreadsGPU_UPLOADsegments throughread_vram_bytes.mixed_ranges_parse_in_order,mixed_segments_cover_the_window, the GPU testmixed_window_keeps_its_bytes_and_the_gpu_sees_every_segment(the title's bytes survive in every segment, the GPU reads later CPU writes to each segment through the one buffer,read_vram_bytesreads only theGPU_UPLOADone; skipped withoutGPU_UPLOADheaps), anda_refused_gpu_upload_segment_becomes_custom(a refusal injected after the first CUSTOM segment is mapped: the window stays whole and fully watched, its bytes kept, the GPU sees later CPU writes; without the fallback the test process exits 0x7C10003).Tested
XCL_DXC_DIR.cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4on 9f99282 (the whole stack): 1475 passed, 0 failed, 47 ignored. 25SKIPPED: 21 no wave64, 3 refused per-lane f16 forms, 1 no heap windows. The four new tests pass without skips.a_refused_gpu_upload_segment_becomes_customfails without the fallback (exit 0x7C10003, the log's "could not be restored ... Windows error 487"). Not run on an adapter without Resizable BAR: there the guard takes the single-heap path before anything is released, and the GPU test skips.Regression run
mixedis opt-in, so the pair checks the default path (D3D12.X: UMA windows in a driver heap on NVIDIA, 4.9x FPS (0.62 -> 3.03) #2844's single heap on NVIDIA).Not tested
mixed:1536:1792. Cards with less than 16 GB of video memory. Titles other than this one.AI use