Skip to content

Recompiler: an access may take its base address's window (XCL_WINDOW_NO_CARRY) - #2496

Open
S1m0ne1997 wants to merge 1 commit into
xcl-dev:mainfrom
S1m0ne1997:window-no-carry
Open

S1m0ne1997 wants to merge 1 commit into
xcl-dev:mainfrom
S1m0ne1997:window-no-carry

Conversation

@S1m0ne1997

@S1m0ne1997 S1m0ne1997 commented Nov 25, 2026 •

Copy link
Copy Markdown

The direct DXIL translator selects the memory window of every access from its 64-bit address, with the offsets added and carried into the high dword (window_at). Each access then gets its own window index, range check and heap handle, and accesses off the same base share none of them. XCL's allocations never straddle windows (gpu::uma), and with the switch the title's reservations do not either. So an access inside the allocation its base points into never carries or borrows: its window is its base's. With XCL_WINDOW_NO_CARRY=1 and heap windows (XCL_HEAP_WINDOWS=1) the window is taken from the base address, which makes the driver's code for big compute programs smaller. Root-UAV windows keep the carry: they have no bounds, so an access that leaves its allocation and wraps inside its base's window could hang the GPU (a window test did on an RTX 3090, below); heap views read 0 past the window's end. Off by default.

Part of #2403: on NVIDIA the code of the pipelines in use is limited, and the retail title's world needs more than that.

What is in it

  • crates/xcl/src/gpu/dxil/lower_window.rs: no_carry() (XCL_WINDOW_NO_CARRY=1, or with_no_carry for a thread); with it and heap windows, window_at selects the window from the base's high dword.
  • crates/xcl/src/gpu/dxil/kernel.rs: window_no_carry(); the translator thread takes its caller's setting.
  • crates/xcl/src/gpu/recomp/pso.rs: the setting is part of the translation cache's identity, as XCL_DIRECT_COMPACT is, and of the direct translator's output identity (programs that go direct as enormous without XCL_DIRECT_DXIL).
  • crates/xcl/src/gpu/uma.rs: with the switch, a title reservation (sparse_reserve) of 4 GiB or less that would cross a window boundary starts at the next window, so nothing the title places in it spans two windows (pointed out by @Kalmarv below). A larger reservation cannot stay in one window and is logged. Where no window has room for a reservation in one piece, it is placed across a boundary as without the switch (and logged) rather than refused: a reservation the sparse windows refuse goes to plain memory (kernelx), which the switch must not make more frequent. Test a_reservation_crosses_a_boundary_when_no_window_has_room (fails without this). Test title_reservations_stay_in_one_window_without_the_carry.
  • crates/xcl/src/gpu/recomp/tests.rs: the two carry tests pin the switch off (with_no_carry(false)). gpu_window_no_carry_reads_inside_allocations_alike. Accesses inside an allocation (global loads with positive and negative offsets, an s_load with an offset) read the same words with and without the switch, with the windows in root UAVs and in the descriptor heap, the DXIL is smaller with it with heap windows and unchanged with root UAVs. A 32-bit (hi == 0) pointer still reads window 0, and a base outside the UMA still reads 0.

Tested

  • NVIDIA GeForce RTX 4090 24 GB (driver 621.40), AMD Ryzen 9 9950X3D, Windows 11 Home 26300, rustc 1.100.0, debug for the tests, release for the runs.
  • cargo build --workspace, then cargo test --workspace -- --test-threads=4 at the head: 1438 passed, 0 failed, 47 ignored. SKIPPED: the wave64 cases (no wave64 on this card), pso_measurement_compiles_an_exact_synthetic_record (no Developer Mode), the D3D12 debug layer tests (no d3d12SDKLayers.dll), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • With XCL_DIRECT_DXIL=1 XCL_WINDOW_NO_CARRY=1, the whole suite again: 1438 passed, 0 failed, 47 ignored. The two existing tests that check the 64-bit sum on purpose (gpu_window_at_32bit_carry_edge_cases, memory_windows_reject_out_of_uma_aliasing) now pin the switch off for their translations, so they test the carry path whatever the environment; the new test covers the path without it.
  • Driver code (GetCachedBlob) of the retail title's compute programs, as the runtime translates them (direct DXIL, heap windows), 12 programs of each family:
family without with XCL_WINDOW_NO_CARRY=1 change
CS_RaytracingResolve 8129 KB 6692 KB −17.7 %
CS_IrradianceCache_Shade 2747 KB 2411 KB −12.2 %
CS_ShadowRenderTiled 7854 KB 7393 KB −5.9 %

Regression run (the switch is off by default, so this run is the default path)

main:

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1318 (PresentX 1318)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 17225 MB

PR:

xcl-smoke v1
commit: 816406772fcc319fac5f535e1753c966a0146d8b
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1595 (PresentX 1595)
presents per 2 s (last 3): 51 53 40
device removals: 0
crashes: 0
peak commit: 21394 MB

PR with XCL_WINDOW_NO_CARRY=1 XCL_HEAP_WINDOWS=1 (the switch on; same head, same script):

xcl-smoke v1
commit: 816406772fcc319fac5f535e1753c966a0146d8b
gpu: NVIDIA GeForce RTX 4090
title: 9cc6a39e
seconds: 60
exit: 0x0
frames shown: 1624 (PresentX 1624)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18680 MB

The switch-off peak commit (21,394 MB) is 124 % of main's in this pair; with the switch off this PR's code paths are main's, and the same arm read 16,474–18,374 MB in the runs of the earlier heads.

Not tested

  • Title reservations over 4 GiB: the retail title makes two (24,576 and 6,236 MB). They still span windows; an access from a base in one that crosses a boundary stays in its base's window. No placed title buffer crossing a boundary was seen (reported below), but raw accesses were not checked.
  • Root-UAV windows: the switch does nothing there.
  • AMD, Intel, other NVIDIA cards and drivers; wave64 hardware (see the reports below for other cards).
  • The HLSL path: it keeps the 64-bit sum (the switch applies to direct DXIL only).
  • Accesses that leave their allocation: with the switch they wrap inside their base's window instead of reaching the next window (or reading 0 past the UMA). No title access of that kind was seen, but I did not check every program for it.
  • The title in the world on this head with the switch on (the world run above was on the older local tree); the 60 s run with the switch covers the menus only. How much address space the single-window reservations skip over a session: no reservation failed in that run, but the log does not record each one.

AI use

  • Claude Code (Claude Opus 5.5): measured where the code size comes from, wrote the change and the test, ran the suite, the smoke runs and the title, and wrote this description. I checked the results and pressed through the title's menus.

🤖 Generated with Claude Code

@Kalmarv

Kalmarv commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

@S1m0ne1997 one point on the premise "Allocations never straddle windows (gpu::uma)", from reading main 6d12f58a. XCL's own allocations hold to it. The title's own reservations may not:

  • Uma::sparse_reserve (gpu/uma.rs:390) calls take_sparse_in(..., single_window: false) both times. Only single_window: true keeps a block inside one 4 GiB window (uma.rs:154), so a sparse reservation is first fit at 64 KiB grain and can cross a boundary.
  • The title's reservations go through it. In hle/kernelx.rs, VirtualAlloc of 64 KiB pages lands at line 271, and graphics reservations without the top type bit at line 307. Titles reserve a range, then commit or map pages and place resources inside it, so a buffer the title places in such a range can span two windows.

For an access whose base is in window k and whose final address is in k + 1, window_at with carry picks k + 1, while no-carry picks k. We have not seen such an access in the retail title. We only checked the allocator, so this is a possibility, not an observed failure. One way to keep the saving would be single_window: true for title reservations of 4 GiB or less, or a carry only where the base is in sparse title space. Either would need a run to see what it costs in address space.

AI use: Claude Code (Claude Opus 5.5) read the allocator and the reservation paths on main and wrote this comment.

@SlopTart

Copy link
Copy Markdown

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

S1m0ne1997 added a commit to S1m0ne1997/xcl that referenced this pull request Nov 25, 2026
With XCL_WINDOW_NO_CARRY=1 shaders take an access's window from its base
address, which assumes that nothing a shader reads spans two windows.
XCL's own allocations hold to that, but the title's sparse reservations
did not: sparse_reserve took the first fit across window boundaries, and
a title places resources inside its reservations (Kalmarv, xcl-dev#2496).

With the switch on, a reservation of 4 GiB or less now starts at the next
window when it would cross a boundary. Without the switch nothing changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@S1m0ne1997

S1m0ne1997 commented Nov 25, 2026 •

Copy link
Copy Markdown
Author

@Kalmarv Thanks, you're right. I checked sparse_reserve and the two kernelx.rs paths: title reservations were first fit across window boundaries, so the premise held for XCL's own allocations only.

The change now makes it hold for the title's too, the way you suggested: with XCL_WINDOW_NO_CARRY=1, a title reservation of 4 GiB or less that would cross a boundary starts at the next window instead. Without the switch nothing changes. Test: title_reservations_stay_in_one_window_without_the_carry (with the switch the second reservation starts in the next window; without it, it crosses as before).

The PR is now one commit, 78bba5c (the code is the same as the two commits it replaced). Results at it (RTX 4090, driver 621.40):

  • cargo test --workspace -- --test-threads=4: 1425 passed, 0 failed, 46 ignored (on the same tree before the squash).
  • scripts/smoke.ps1 -Seconds 60 on the retail title, switch off (the default path): 1615 frames, 0 removals, 0 crashes. Block in the description.
  • The same with XCL_WINDOW_NO_CARRY=1: 1661 frames, 0 removals, 0 crashes, and no title reservation failed in the log.

What these runs don't show: that run covers the start and the menus, not a session in the world. The log does not record each reservation, so I can't put a number on the address space the skipped window tails cost.

AI use: Claude Code (Claude Opus 5.5) checked the allocator, wrote the change and the test, ran the suite and the smoke runs, and drafted this reply.

@S1m0ne1997

Copy link
Copy Markdown
Author

@SlopTart Thanks for the run on your machine.

S1m0ne1997 added a commit to S1m0ne1997/xcl that referenced this pull request Nov 25, 2026
…NO_CARRY)

The direct DXIL translator adds every offset of a memory access to its
64-bit address with a carry into the high dword, then selects the memory
window from the high dword (window_at). Every access then gets its own
window index, range check and heap handle, and accesses off the same base
share none of them.

With XCL_WINDOW_NO_CARRY=1 the window is taken from the base address. An
access inside the allocation its base points into never carries or
borrows, provided nothing straddles a window: XCL's allocations never do
(gpu::uma), and with the switch the title's sparse reservations of 4 GiB
or less no longer do either (sparse_reserve starts them at the next
window instead of crossing; pointed out by Kalmarv in xcl-dev#2496). Off by
default; without the switch nothing changes.

On an RTX 4090 (driver 621.40) the driver's code for 12 programs of each
family of a retail title shrinks by 17.7 % (CS_RaytracingResolve),
12.2 % (CS_IrradianceCache_Shade) and 5.9 % (CS_ShadowRenderTiled).
On NVIDIA the code of the pipelines in use is limited (xcl-dev#2403).

The setting is part of the translation cache's identity, as
XCL_DIRECT_COMPACT is, and the translator thread takes its caller's
setting so a test can choose it.

Part of xcl-dev#2403.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Eterst

Eterst commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

A run on NVIDIA as asked on #2403, with one caveat: it has this PR and #2427 (XCL_HEAP_FLAT=1) together, so the two are not separated.

Setup: RTX 4070 SUPER 12 GB, driver 616.92, Windows 10 19045, release. A local test tree (#2057 and a few other open PRs on main), before: main 06055a7; after: main 6d12f58 + 78bba5c (this PR) + d356a74 (#2427). The retail title with XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1, split programs off (XCL_DIRECT_SPLIT_INSTRUCTIONS=0), caches rebuilt by a full precompile (xcl shaders --precompile --only cs --pipelines, then xcl pipelines) with the same switches as the run.

Where the device is removed

runs end
before 4 0x887a0005 at 261–303 s, always at the same point of the title (last frame before it 2,300–2,480); DRED page fault VA 0, no event
XCL_WINDOW_NO_CARRY=1 XCL_HEAP_FLAT=1 1 no removal: frame 2,630 at 395 s, stopped at 418 s by my own RAM guard (free RAM 0.4 GB), not by the title or the driver

Driver code of the compute programs the precompile rebuilt (.pso files, the GetCachedBlob bytes):

programs total median 90th pct ≥ 1 MB
before 2,227 905 MB 215 KB 1,055 KB 308 (343 MB)
with both switches 2,565 757 MB 136 KB 848 KB 32 (40 MB)

The two rows are not the same set of programs (each counts what that precompile built anew), so read them as distributions, not as a per-program saving.

Not tested: this PR without #2427 and the other way round; more than one run; AMD / Intel; a bound-code counter in the title (the sizes above are of what was built, not of what was in use at once).

AI use: Claude Code (Claude Opus 5.5) merged the PRs into the test tree, ran the precompiles and the runs, and wrote this; posted with my OK.

@pvfreis

pvfreis commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

By reading only, at 78bba5c:

  1. Cache identity. direct_output_identity (pso.rs:503) lacks the switch, and identity() adds it only when the backend is not HLSL. With XCL_DIRECT_DXIL unset, compute programs over 8 MiB of HLSL still go direct (enormous), without the carry when the switch is set, and are stored under rerouted_identity. A later run without the switch loads that DXIL while its reservations cross windows again; the other way round, the switch does nothing for those programs. I have not seen a crossing access. Recompiler: key rerouted DXIL by compact nesting policy #2257 fixed the same gap for the nesting tag.
  2. Description. Reservations over 4 GiB still span windows (uma.rs:332 describes one of 8 GiB + 4 MiB); that case is missing under Not tested.

AI use: Claude Code (Claude Opus 5.5) found this; a second Claude Opus 5.5 re-derived it; Claude Fable 5.2 reviewed the text; checked by a person before posting.

@KDenKC

KDenKC commented Nov 25, 2026 •

Copy link
Copy Markdown

@S1m0ne1997 the NVIDIA in-title A/B you asked for, RTX 5090. XCL_WINDOW_NO_CARRY=1 makes the driver code smaller (about −5 to −6 % of the code bound in the title, −10 % per split piece), but both arms lost the device at the same point in the title. One run per arm.

Tested

  • RTX 5090 32 GB (driver 621.24), Ryzen 7 9800X3D, 62 GB RAM, Windows 11 26200, release. Tree: main 2898511 + D3D12.X: an ExecuteIndirect of a split program runs its pieces #2404 (5ca9c23) + this PR (78bba5c, cherry-picked), plus a local diagnostic not in any PR: XCL_LOCAL_CODE_SUM=1 calls GetCachedBlob on each PC pipeline at its first bind (the PC list's SetPipelineState hook) and logs the running sum.
  • Both arms: XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_NETWORK=0, default XCL_PSO_WAIT_MS. Each started from its own copy of the same warm cache, ran xcl shaders --precompile --only cs --pipelines with its switches, then the retail title for 600 s.
switch off XCL_WINDOW_NO_CARRY=1
precompile: pipelines made / split programs (pieces) 8,687 / 816 (6,814) 8,311 / 811 (6,433)
mean .chain.pso blob (driver code per split piece) 121.7 KiB 109.9 KiB (−9.7 %)
bound code at 2,400 / 2,800 / 3,005 pipelines 338 / 382 / 406 MB 317 / 358 / 384 MB (−5.4 to −6.4 %)
world rendering 128–186 s (88 presents) 124–182 s (83 presents)
device removed 0x887a0005 409.9 s 324.6 s
last logged bound code before it 416 MB (3,082 pipelines) 384 MB (3,005 pipelines)
  • Both arms rendered the same ~58 s of the opening, then stalled on the same cold graphics pipelines (one title thread building them serially, see [OFFICIAL] Swarm: cold PSO compilation to first playable frame #2088), and lost the device 1.6–2.4 s after the last of them finished and world submission resumed. So the removal is tied to the same point in the title in both, not to the clock. The 85 s difference is order: the switch-off arm ran first and paid 91 s of driver time for 30 graphics pipelines that the second arm then got from NVIDIA's cache (0.1 s).
  • No nvlddmkm / Display events at the removal.

Not tested / caveats

  • One run per arm, with the diagnostic on (its GetCachedBlob calls add CPU time at each first bind). An earlier run on the same cache lineage without the diagnostic or this PR was removed at 123.8 s, right at world start, so the run-to-run spread is large.
  • The counter does see the pieces XCL binds itself (split pieces, the slicer, whole forms): XCL patches the PC list's SetPipelineState slot in place, so its own calls go through the hook (checked in the code). Only pipelines set at CreateCommandList / Reset / ClearState and never set again are missed.
  • This PR's own tests, graphics-only effects (the switch doesn't change graphics DXIL), other GPUs.

So on this card the saving is real but not enough to move the #2403 removal. With ~400 MB logged at the end, a 6 % cut buys tens of MB against a cliff the title crosses anyway at this scene.

AI use: Claude Code (Claude Opus 5.5) built and ran both arms and wrote this; Antigravity CLI (Gemini 4 Neon) analysed the logs and cache.

@Oliwettoo

Copy link
Copy Markdown

Review on 78bba5c (read from the diff, not run), following up @Kalmarv's point: the fix keeps title reservations of ≤ 4 GiB in one window, but one case of the "allocations never straddle windows" premise is still open. take_sparse_in lets a reservation larger than a window (size > WINDOW) cross a boundary even with single_window: true (uma.rs:154). A buffer the title places across that boundary inside such a reservation is within its allocation, yet with XCL_WINDOW_NO_CARRY=1 its accesses wrap into the base's window and touch the wrong memory, with no warning.

Since the switch is opt-in, a log line when a reservation over 4 GiB is made with no_carry on (or a note in the README entry) would make such runs easy to spot.

@pvfreis

pvfreis commented Nov 25, 2026

Copy link
Copy Markdown
Contributor

Test report for 78bba5c with #2428 ab2855f (#2427 d356a74 in it) on main e1d84b7d (tree 76fc443d): outputs and driver code size with XCL_WINDOW_NO_CARRY=1.

Tested

  • RTX 3060 (617.14), Ryzen 9 5900XT, Windows 11 26300. Sandbox: non-interactive session, Low integrity, debug, --test-threads=4, NVIDIA 32-lane waves only. One run each.
  • Suite (plus our test arms and a test-build-only fault switch in two runtime files): 1429 passed, 1 failed, 46 ignored, 24 SKIPPED. main e1d84b7d: 1422 / 1 / 46, 25. The failure on both is e2e presents.
  • Outputs: no carry with root UAV, guarded and flat heap windows, wave32 and split wave64, in a new test (offsets of both signs, window edges, out of range, inactive lanes): all expected values met. Three no-carry arms in Recompiler: direct DXIL reads heap memory windows without a branch #2427's test equal its switch-form run. Three one-line breaks of the no-carry path each fail the new test.
  • Expected values: our arithmetic from AMD's public RDNA2 ISA (sections 7.2.1, 8.1.5, 9.1–9.4, 12.18.3); out of range is XCL's contract; a load leaving its base's window follows this PR's documentation, not the 64-bit sum.
  • Size only: GetCachedBlob bytes, 60 compute programs (30 largest, 30 sampled, chosen first), unsplit, built at opt-level 3 without debug assertions; plain debug gives the same DXIL and root signatures (60/60, every arm).
    • guarded heap 42.19 → 35.96 MB (0.852; per program 0.797–0.991)
    • flat heap 41.11 → 34.76 MB (0.845; 0.785–0.987)
  • Failed check: repeats of the flat arm without the switch gave equal sizes 60/60 but different contents in 18/60, and 8/60 in a second job; cause not investigated.

Not tested: outputs in release, split chains, GS, mesh, graphics; reservations over 4 GiB; code in use in a title; timing; other GPUs.

AI use: Claude Code. Claude Opus 5.5 wrote the test, ran it and wrote this; Claude Fable 5.2 rechecked it.

MacieGx added a commit to MacieGx/xcl that referenced this pull request Nov 26, 2026
…cl-dev#2496), zeroed target pages

XCL_WINDOW_NO_CARRY=1: the direct translator's compute programs take an access's
memory window from its base address (ported from xcl-dev/xcl pull request 2496 by
S1m0ne1997: less driver code for the big compute programs, whose total is what
removes the device on NVIDIA). Here the switch is a flag in the compute programs'
window count, so only their cache entries are new.

XCL_ZERO_TARGET_PAGES=1: a pool tile given to a render target, depth buffer or UAV
texture is zeroed first (a reserved buffer mapped over the tiles, zeros copied in):
tiles come back from evicted streamed textures with their bytes.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@DavidM1911

Copy link
Copy Markdown
Contributor

Re-verification on RTX 3060 Ti (Windows 11), new head merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, 27 ignored. The earlier merge conflict is resolved.

Thanks!

— Devin

@bielfreedom

Copy link
Copy Markdown

AMD Windows driver timing for #2496: on the RX 9070 XT, XCL_WINDOW_NO_CARRY=1 makes AMD's CreateComputePipelineState about 13 % faster over 26 large retail compute programs, with 11 % less direct DXIL over all 2,689. Nothing failed in either arm. This measures cost only, not whether the window premise holds (the thread above).

Setup

  • GPU: RX 9070 XT 16 GB (RDNA4, native wave64), AMD driver 32.0.32029.2010.
  • CPU and memory: Ryzen 7 7700 (16 threads), 32 GB RAM, Windows 11, release.
  • Build: this PR at 78bba5c merged onto main 08db802, plus a local timing patch in xcl shaders that writes each program's DXIL size and each CreateComputePipelineState time to a file. One binary for both arms; only the switch differs.
  • Offline: xcl shaders <retail shaders.rpf> --precompile --only cs --pipelines with XCL_DIRECT_DXIL=1, XCL_PSO_DISK_CACHE=0, one driver thread, a fresh translation cache and a fresh executable name for every run (the AMD driver keys its own cache on the exe name, so every build is cold).

DXIL size, all 2,689 compute programs (translation only)

windows switch off XCL_WINDOW_NO_CARRY=1 change programs changed
switch (default) 885.9 MB 788.1 MB −11.0 % 2,659
heap (XCL_HEAP_WINDOWS=1) 728.9 MB 674.0 MB −7.5 % 2,659

With the switch off the output matches main byte for byte.

Driver time, 26 large programs (switch windows), 2 interleaved rounds (off, on, then on, off)

arm pipelines (incl. split pieces) DXIL to driver driver time r1 / r2 peak memory
off 76 9.63 MB 78.7 / 83.3 s 1.51 GB
XCL_WINDOW_NO_CARRY=1 66 8.28 MB 67.5 / 73.2 s 1.43 GB

Mean 81.0 → 70.4 s (−13 %). Every one of the 20 unsplit programs in the set was faster with the switch, by 3–24 %. The largest ones:

program DXIL off → on driver ms off driver ms on
620491641aa9bad6 378 → 346 KB 10,830 / 11,334 9,486 / 10,579
6d1e4583f8129771 638 → 590 KB 6,819 / 6,994 5,974 / 6,336
6fd9a5ebc95aee46 322 → 289 KB 3,055 / 2,960 2,403 / 2,601
d2d3c6c5d8463f50 151 → 135 KB 1,405 / 1,471 1,126 / 1,246

The pieces also change: with the switch, the six programs that are split produce 46 pieces instead of 56.

Not tested: heap windows in the driver, GPU output, and a title run.

AI use: Claude Code (Claude Opus 5.5) built the binaries, ran the measurements and wrote this report; I posted it.

@CharlyRien

Copy link
Copy Markdown
Contributor

Test report, RTX 3090 (616.56), one run per arm. With XCL_WINDOW_NO_CARRY=1 the title ran 187 s into the world, through the heavy scene where our earlier run without the switch lost the device, and the run ended on its time limit with no removal. The witness, same settings without the switch, lost the device (0x887a0005) earlier than that: at world + 44 s. The code we count as bound was lower with the switch: 406 MB at most, against 420 MB at the witness's removal. Two more things measured:

  • the title makes two reservations over 4 GiB (the case @Oliwettoo raised);
  • with the switch set for the whole test process, two window tests hang the GPU on this card. Both use root-UAV windows, and both put an address below its base's window on purpose.

In the title, same settings, only the switch differs

VNIGHT2, switch off VNC2, XCL_WINDOW_NO_CARRY=1
world (first 2 s with > 7,000 draws) 120.2 s 122.5 s
end 0x887a0005 at 164.4 s, world + 44 s, in busy world rendering (1,100-2,400 draws per 2 s) ran to 309 s, world + 187 s, stopped by its time limit; no removal
heavy scene (2 s with ~4,500 draws and ~13,000 dispatches after about a minute of near-idle frames) not reached 230.3 s, passed
bound code, world + 0 to + 44 s (10 s reports and budget warnings) 361.6 → 383.7 MB; compute 235.4 → 253.1 MB 312.5-378.8 MB; compute 188.8-227.4 MB
bound code at the end at the removal: 366.2 MB bound + 54.2 MB awaiting release = 420.4 MB. Compute 255.4, mesh 46.4, graphics 64.5 peak over the run 406.2 MB (bound + awaiting). Compute peak 257.6 MB, in the heavy scene (389.2 MB bound then)
process commit, peak in the log 44.1 GB 45.0 GB
  • "Bound code" is our local pipeline budget's count: the GetCachedBlob size of each pipeline XCL built for a stand-in, from its first bind to its release.
  • Earlier pair, same trees, with more memory for page and GPU-view buffers (2048 / 1536 MB) and frame dumps:
    • without the switch (VNIGHT1): 0x887a0005 0.2 s into the heavy scene, world + 158 s, at 437.1 MB with compute 273.6 MB;
    • with the switch (VNC1): ran 6 s into the same scene, with 427.1 MB at most and compute 254.1 MB. Then our own memory guard stopped it (free system commit under 5 GB), not the driver.
    • The two witnesses were lost at different points of the title (world + 44 s and + 158 s), so the point of removal moves from run to run.
  • The switch run had one long stall in the heavy scene: 0 submits and 0 presents from 238 to 248 s.
    • Measured: in that window one compute pipeline of 22,188 bytes of DXIL was compiled with no blob on disk, in 14.8 s ("kept on disk", 32 KB of code). Our budget's longest rebuild of a released pipeline, 14.4 s, ended at the same time.
    • Its DXIL has no blob in the cache we used without the switch, so it is a program whose DXIL the switch changed and that our precompile and warm-up run had not built. Probably a mesh or GS compute pass: the offline tool does not build those as pipelines. That last part is our reading, not checked.
    • So switching costs some cold compiles in the title until the cache is warm. We did not see a cost of the switch's code itself.
  • With the switch, 0 placed title buffers crossed a window boundary in VNC2 (local log at CreatePlacedResourceX).
    • But the title reserves 24,576 MB and 6,236 MB in its first 10 s, in both switch runs (5.2 / 6.9 s in VNC1, 6.1 / 9.1 s in VNC2). These reservations span window boundaries even with this PR.
    • We did not check raw accesses that cross a boundary from one base inside them.
    • VNC2 made no frame dumps, so its image was not compared. In VNC1 the image showed no clear difference against VNIGHT1, but it was 3 frames against 6.

Window tests in our tree (cargo test --release -p xcl --lib -- window, 42 tests)

  • Switch unset: 42 passed. That includes gpu_window_no_carry_reads_inside_allocations_alike (it runs both arms itself, root and heap windows) and title_reservations_stay_in_one_window_without_the_carry.
  • XCL_DIRECT_DXIL=1 XCL_WINDOW_NO_CARRY=1 for the whole process, all tests at once: 12 failed. 10 of them failed with "GPU fence still pending after 10000 ms", then 0x887a0006: one test hung the GPU and the others followed, the HLSL arms included.
  • The same, one process per test (--exact --test-threads=1): 37 passed, 5 failed. All 5 pass with the switch unset, run the same way. Each one crosses a window on purpose:
test with the switch what it builds
window_at_lowers_to_32bit_carry_without_int64 assertion "expected UMul in DXIL" checks the DXIL shape of the carry
raw_loads_in_root_windows_respect_exec_and_bounds assertion at wave32 lane 7 (slot 7), global_load_dwordx2 a 64-bit load at a window edge
gpu_heap_windows_reject_out_of_uma_aliasing assertion "64-bit carry global_load must cross from w0 into w1" (w0 + 0xFFFF_FFF0) + 0x20: it reads w0 + 0x10
gpu_memory_windows_reject_out_of_uma_aliasing GPU fence still pending after 10 s the same program, windows in root UAVs
gpu_window_at_32bit_carry_edge_cases GPU fence still pending after 10 s root-UAV windows
  • The two hangs are the two root-UAV tests. The heap form of the same program only gives a wrong value.
    • Our reading of the test code, not instrumented: both root-UAV tests contain an access that borrows below the start of its base's window. The out-of-UMA test does w0 + 0 - 16; the edge-case test does a store at (w0 + 0x30) - 0x30 - 16.
    • Without the switch that access leaves the UMA: it reads 0 and its store is dropped.
    • With the switch it stays in window 0 at offset 0xFFFF_FFF0. The test arena backs 1 MB per window and a root UAV has no bounds, so we take it to be a page fault.
  • So, as far as these tests show: the switch only misses data when an access leaves its base's window, unless the windows are root UAVs. Then an access that lands on unbacked memory hangs the GPU on this card instead of reading 0.
    • We did not get the removal reason for these two processes.
    • @pvfreis's out-of-range cases met their expected values with root UAVs on a 3060. We did not compare the addresses those cases use.

Setup

Not measured

  • More than one run per arm. The witnesses lost the device at two different points (world + 44 s and + 158 s).
  • Whether the switch run would hold past 187 s of world.
  • Raw accesses that cross a window boundary inside the two big reservations.
  • The image in VNC2.
  • The removal reason in the two hanging tests.
  • Other cards and drivers.
  • This PR without our local pipeline budget.

AI use: Claude Code with Claude Opus 5.5, as the coordinating session and as its agents. The agents ported the PR, resolved the conflicts, wrote the diagnostic and the test and run jobs, read the logs and drafted this report. The coordinating session ran the builds, the tests and the runs, and checked the numbers quoted here.

S1m0ne1997 added a commit to S1m0ne1997/xcl that referenced this pull request Nov 26, 2026
…NO_CARRY)

The direct DXIL translator adds every offset of a memory access to its
64-bit address with a carry into the high dword, then selects the memory
window from the high dword (window_at). Every access then gets its own
window index, range check and heap handle, and accesses off the same base
share none of them.

With XCL_WINDOW_NO_CARRY=1 and heap windows, the window is taken from the
base address. An access inside the allocation its base points into never
carries or borrows, provided nothing straddles a window: XCL's
allocations never do (gpu::uma), and with the switch the title's sparse
reservations of 4 GiB or less no longer do either (sparse_reserve starts
them at the next window instead of crossing; Kalmarv in xcl-dev#2496). A larger
reservation still spans windows and is logged. Root-UAV windows keep the
carry: they have no bounds, so an access that leaves its allocation and
wraps inside its base's window could hang the GPU (a window test did on
an RTX 3090, xcl-dev#2496); heap views read 0 past the window's end. Off by
default; without the switch nothing changes.

On an RTX 4090 (driver 621.40) the driver's code for 12 programs of each
family of a retail title shrinks by 17.7 % (CS_RaytracingResolve),
12.2 % (CS_IrradianceCache_Shade) and 5.9 % (CS_ShadowRenderTiled).
On NVIDIA the code of the pipelines in use is limited (xcl-dev#2403).

The setting is part of the translation cache's identity, in the direct
translator's output identity too (programs that go direct as enormous
without XCL_DIRECT_DXIL; pvfreis in xcl-dev#2496), and the translator thread
takes its caller's setting so a test can choose it.

Part of xcl-dev#2403.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@S1m0ne1997

Copy link
Copy Markdown
Author

Updated to ae56502 (rebased onto main b49be18, still one commit). What changed, from the review points above:

  • Root-UAV windows keep the carry. With the switch for the whole test process, two root-UAV window tests hung the GPU on an RTX 3090 (@CharlyRien). An access that leaves its allocation wraps inside its base's window. A root UAV has no bounds, so that access can land past the window's buffer. A heap view is bounds-checked and reads 0 there. The switch now applies to heap windows only. The new test checks both forms: same results with and without the switch, less DXIL with heap windows, identical DXIL with root UAVs.
  • Cache identity (@pvfreis): the switch is now part of direct_output_identity too, so the enormous programs that go direct without XCL_DIRECT_DXIL are kept apart as well.
  • Reservations over 4 GiB (@Oliwettoo, @pvfreis, @CharlyRien: the title makes two, of 24,576 and 6,236 MB) still span windows. They can't fit in one. With the switch, each is logged once, and the description lists the case under Not tested. @CharlyRien saw no placed title buffer cross a boundary with the switch. An access from a base in such a reservation that crosses a boundary would stay in its base's window.

Tests at ae56502 (RTX 4090, driver 621.40):

  • cargo test --workspace -- --test-threads=4: 1437 passed, 0 failed, 47 ignored.
  • The same with XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_WINDOW_NO_CARRY=1 (--no-fail-fast): 1436 passed, 1 failed, 47 ignored. The failure is gpu_heap_windows_reject_out_of_uma_aliasing, on the case it builds on purpose (an address that crosses into another window). No GPU hang.
  • Smoke, 60 s, retail title: main 1318 frames; this PR 1662 frames with the switch off and 1531 with it on; 0 removals and 0 crashes in all three. Blocks in the description.

Results so far, from the reports above:

  • Driver code is smaller everywhere it was measured: −5 to −6 % of the code bound in the title on an RTX 5090, −15 % over 60 programs on an RTX 3060, and on an RX 9070 XT −11 % of DXIL with switch-form windows and −7.5 % with heap windows, plus 13 % faster driver compiles.
  • On the removal itself, the results are mixed. It moved past the point where it came before on an RTX 4070 SUPER (with Recompiler: direct DXIL reads heap memory windows without a branch #2427) and on an RTX 3090. On the RTX 5090 both arms were removed at the same point of the title. One run per arm everywhere, and the point of removal moves between runs, so this reduces the code but does not remove the limit.

AI use: Claude Code (Claude Opus 5.5) made the changes, ran the suite and the smoke runs, and drafted this.

@S1m0ne1997
S1m0ne1997 marked this pull request as ready for review November 26, 2026 06:37
S1m0ne1997 added a commit to S1m0ne1997/xcl that referenced this pull request Nov 26, 2026
…NO_CARRY)

The direct DXIL translator adds every offset of a memory access to its
64-bit address with a carry into the high dword, then selects the memory
window from the high dword (window_at). Every access then gets its own
window index, range check and heap handle, and accesses off the same base
share none of them.

With XCL_WINDOW_NO_CARRY=1 and heap windows, the window is taken from the
base address. An access inside the allocation its base points into never
carries or borrows, provided nothing straddles a window: XCL's
allocations never do (gpu::uma), and with the switch the title's sparse
reservations of 4 GiB or less no longer do either (sparse_reserve starts
them at the next window instead of crossing; Kalmarv in xcl-dev#2496). A larger
reservation still spans windows and is logged. Root-UAV windows keep the
carry: they have no bounds, so an access that leaves its allocation and
wraps inside its base's window could hang the GPU (a window test did on
an RTX 3090, xcl-dev#2496); heap views read 0 past the window's end. Off by
default; without the switch nothing changes.

On an RTX 4090 (driver 621.40) the driver's code for 12 programs of each
family of a retail title shrinks by 17.7 % (CS_RaytracingResolve),
12.2 % (CS_IrradianceCache_Shade) and 5.9 % (CS_ShadowRenderTiled).
On NVIDIA the code of the pipelines in use is limited (xcl-dev#2403).

The setting is part of the translation cache's identity, in the direct
translator's output identity too (programs that go direct as enormous
without XCL_DIRECT_DXIL; pvfreis in xcl-dev#2496), and the translator thread
takes its caller's setting so a test can choose it.

Part of xcl-dev#2403.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@S1m0ne1997

Copy link
Copy Markdown
Author

Follow-up to the summary above: 2e8ff6b makes the two existing carry tests pin the switch off for their own translations, so they always test the 64-bit sum. With the switch set for the whole process (XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_WINDOW_NO_CARRY=1), the suite is now 1437 passed, 0 failed, 47 ignored, the same as without it. Smoke blocks for 2e8ff6b are in the description.

@bielfreedom

Copy link
Copy Markdown

AMD Windows rerun for #2496 at 2e8ff6b: on the RX 9070 XT, with the root-UAV windows now keeping the carry, the switch no longer changes anything with the default switch windows. With heap windows it still cuts AMD's CreateComputePipelineState time by about 15 % over 26 large retail compute programs. No failures in any arm. This replaces my earlier numbers, which were from 78bba5c.

Setup: as in my comment above, with this PR at 2e8ff6b merged onto main b49be18. One binary for both arms; only XCL_WINDOW_NO_CARRY differs.

DXIL, all 2,689 compute programs (translation only)

windows switch off XCL_WINDOW_NO_CARRY=1 programs changed
switch (default) 885.9 MB 885.9 MB, the same bytes 0
heap (XCL_HEAP_WINDOWS=1) 728.9 MB 674.0 MB (−7.5 %) 2,659

With the switch off, both forms match main byte for byte.

Driver, 26 large programs, 2 interleaved rounds (off, on, then on, off)

windows arm pipelines (incl. split pieces) DXIL to the driver driver time r1 / r2 peak memory
switch off 76 9.63 MB 100.9 / 100.3 s 1.47 GB
switch on 76 9.63 MB 103.2 / 102.0 s 1.47 GB
heap off 66 7.94 MB 93.3 / 98.8 s 1.61 / 1.62 GB
heap on 63 7.43 MB 85.0 / 79.0 s 1.28 / 1.35 GB

With heap windows the mean is 96.1 → 82.0 s (−15 %); the six split programs make 43 pieces instead of 46. The switch-window arms differ by 2 %, which is noise for identical DXIL.

This machine is busier today than when I measured 78bba5c, so compare within a row pair, not across reports.

AI use: Claude Code (Claude Opus 5.5) built the binary, ran the measurements and wrote this; I posted it.

…NO_CARRY)

The direct DXIL translator adds every offset of a memory access to its
64-bit address with a carry into the high dword, then selects the memory
window from the high dword (window_at). Every access then gets its own
window index, range check and heap handle, and accesses off the same base
share none of them.

With XCL_WINDOW_NO_CARRY=1 and heap windows, the window is taken from the
base address. An access inside the allocation its base points into never
carries or borrows, provided nothing straddles a window: XCL's
allocations never do (gpu::uma), and with the switch the title's sparse
reservations of 4 GiB or less start at the next window instead of
crossing, where a window has room (Kalmarv in xcl-dev#2496). Where none has,
the reservation is placed across a boundary as without the switch and
logged, rather than refused: a reservation the sparse windows refuse goes
to plain memory (kernelx), which the switch must not make more frequent.
A reservation larger than 4 GiB still spans windows and is logged.
Root-UAV windows keep the carry: they have no bounds, so an access that
leaves its allocation and wraps inside its base's window could hang the
GPU (a window test did on an RTX 3090, xcl-dev#2496); heap views read 0 past the
window's end. Off by default; without the switch nothing changes.

On an RTX 4090 (driver 621.40) the driver's code for 12 programs of each
family of a retail title shrinks by 17.7 % (CS_RaytracingResolve),
12.2 % (CS_IrradianceCache_Shade) and 5.9 % (CS_ShadowRenderTiled).
On NVIDIA the code of the pipelines in use is limited (xcl-dev#2403).

The setting is part of the translation cache's identity, in the direct
translator's output identity too (programs that go direct as enormous
without XCL_DIRECT_DXIL; pvfreis in xcl-dev#2496), and the translator thread
takes its caller's setting so a test can choose it. The two tests that
check the 64-bit sum on purpose pin the switch off.

Part of xcl-dev#2403.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Decodere

Copy link
Copy Markdown
Contributor

Independent RTX 4060 (8 GB) / Windows 11 release verification of PR #2496 updated head 816406772fcc319fac5f535e1753c966a0146d8b (exact parent & merge-base b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7). Measurements, targeted GPU/unit tests, and paired default + XCL_WINDOW_NO_CARRY=1 60 s smokes only; not a full source review.

Setup

  • GPU: NVIDIA GeForce RTX 4060 (8 GB / 7956 MiB reported by D3D12), driver 32.0.16.2114 (NVIDIA 621.14, WDDM 3.2)
  • CPU / RAM / OS: Intel Core i5-11400F (6 cores / 12 threads), 32 GB RAM (31.9 GiB usable), Windows 11 Home 26200
  • Toolchain / caches: rustc 1.100.0 (0ef1bc386 2026-11-09), DXC 1.9.2609.5, release builds, quiet machine (zero concurrent builds/tests during timed runs; note gpu/dxil/* edits give 81640677 a fresh XCL_DIRECT_DXIL_SOURCE_ID namespace)
  • Workload: Retail workload title: 29640639 via scripts/smoke.ps1 -Seconds 60 (XCL_NETWORK=0, default flags and XCL_WINDOW_NO_CARRY=1, no input)

Targeted RTX 4060 release unit & GPU tests (81640677)

  • cargo test --release -p xcl --lib gpu_window_no_carry_reads_inside_allocations_alike -- --nocapture: 1 passed, 0 failed, 0 ignored (0.26 s, executed on RTX 4060, 0 SKIPPED).
  • cargo test --release -p xcl --lib memory_windows_reject_out_of_uma_aliasing -- --nocapture: 1 passed, 0 failed, 0 ignored (0.23 s, executed on RTX 4060, 0 SKIPPED).
  • cargo test --release -p xcl --lib a_reservation_crosses_a_boundary_when_no_window_has_room -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib title_reservations_stay_in_one_window_without_the_carry -- --nocapture: 1 passed, 0 failed, 0 ignored (0.00 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib gpu::uma:: (3 consecutive parallel passes): 14 passed, 0 failed, 0 ignored on all 3 passes (0.01 s / 0.01 s / 0.01 s, 0 SKIPPED).
  • cargo test --release -p xcl --lib gpu::dxil::: 184 passed, 0 failed, 3 ignored (3.32 s; 1 SKIPPED: gpu::dxil::kernel::dispatch_chain_native_wave64_builds_whole skipped no wave64 on NVIDIA wave32 RTX 4060).

Paired 60 s RTX 4060 smokes (b49be183 vs 81640677 default and XCL_WINDOW_NO_CARRY=1)

All three runs completed cleanly at steady 60/2 s pacing with 0 device removals and 0 crashes (81640677 default vs XCL_WINDOW_NO_CARRY=1 xcl.log: 6,174/6,114 MB vs 6,176/6,115 MB peak/end local VRAM, 4,651 vs 4,650 MB end non-local VRAM, 19,630 vs 19,570 translated draws / 1,024 dispatches with 0 skipped, 4096 sparse submits in 294 ms vs 254 ms).

Exact parent (b49be183):

xcl-smoke v1
commit: b49be1836844fe0b0cdb3211dce3cb7fb4e21ac7
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1518 (PresentX 1518)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14018 MB

PR #2496 head (81640677, default flags):

xcl-smoke v1
commit: 816406772fcc319fac5f535e1753c966a0146d8b
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1604 (PresentX 1604)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13986 MB

PR #2496 head (81640677, with XCL_WINDOW_NO_CARRY=1):

xcl-smoke v1
commit: 816406772fcc319fac5f535e1753c966a0146d8b
gpu: NVIDIA GeForce RTX 4060
title: 29640639
seconds: 60
exit: 0x0
frames shown: 1586 (PresentX 1586)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 13988 MB

Limits of coverage

  • Full workspace test suite was not run on 81640677 (only the 4 targeted tests individually, 3 parallel passes of gpu::uma::, all 184 passing tests in gpu::dxil::, release build, and paired 60 s smokes); dispatch_chain_native_wave64_builds_whole skipped no wave64 on wave32 NVIDIA hardware.
  • Both default and XCL_WINDOW_NO_CARRY=1 runs passed the 60 s no-input menu/intro smoke cleanly; visual inspection of extended interactive in-world gameplay under XCL_WINDOW_NO_CARRY=1 was not performed on this host.
  • Single discrete NVIDIA 8 GB GPU (RTX 4060) on native Windows 11; no AMD, Intel, or Wine/Linux run on this host.

AI use

Ran the targeted release GPU/unit tests, release build, and paired default + XCL_WINDOW_NO_CARRY=1 quiet 60 s smoke runs with assistance from Google Antigravity (Gemini 4 Neon); all test counts, timings, memory figures, and smoke blocks were extracted directly from cargo test, xcl.log, and scripts/smoke.ps1 outputs.

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.