Recompiler: heap memory windows without a guard (min + null view), and the 64-bit atomics check #1695

Open
github-bot wants to merge 1 commit from github-bot/gh-1695 into main AGit
Owner

@⁠brothernog on GitHub · 2026-11-24 19:22 UTC · original
brothernog:heap-windows-branch-free → main · +112 −54 · 8 files · 1 commits · open

The preparation step (P0) for heap memory windows as a default, which @⁠ivall invited on #680 (comment) and @⁠Pipodi listed in #1269 (comment). Still opt-in (XCL_HEAP_WINDOWS=1); nothing changes with the variable unset. Part of #1269.

With heap windows, every memory access was [branch] if (xcl_w >= windows) { default } m = ResourceDescriptorHeap[base + xcl_w]; .... The guard gives each access two paths, and DXC's GVN can join their handles into a phi %dx.types.Handle, which NVIDIA refused in under a second with E_OUTOFMEMORY (#756). On main the programs that showed it no longer do (their translation changed with b8b1f49, as @⁠psuedo-tty found too), so this PR doesn't claim to fix a refusal today. What it changes is that the form can't produce one: the index is clamped, min(xcl_w, 16u) with all 16 heap windows in use (a select with fewer), and the slot after the window views holds a null raw UAV that reads 0 and drops stores and atomics, as the switch's default does. One path per access.

What is in it
One commit, Recompiler: heap memory windows without a guard, a null view outside them, rebased onto main cbc296a (#1992, #1998: 16 heap windows, the expanded-window checks) from @⁠WebIdentity1's integration patch (comment):

  • gpu/recomp/emit.rs (mem_accessors): the clamped index, no guard.
  • gpu/recomp/mod.rs: MEM_HEAP_NULL = MEM_HEAP_BASE + MAX_HEAP_WINDOWS (descriptor 20; + MAX_WINDOWS would clamp valid higher windows), docs.
  • hle/d3d12x/console_heap.rs: set_window_views writes the null view, and only with 64-bit atomics on heap views; the shared heap's own allocations start after it (21). The 4 null views at 0..3 (#1992) are unchanged.
  • hle/d3d12x/real.rs: no AtomicInt64OnDescriptorHeapResourceSupported → no views, and the shaders keep the switch (window_views_failed), as with no shared heap.
  • gpu/recomp/runner.rs: the two test heaps get the null view too.
  • gpu/recomp/tests.rs: the out-of-UMA aliasing and invalid-window tests cover 4 / 8 / 16 layouts and the min path.
  • gpu/uma.rs: expanded_heap_window_shaders_translate_and_validate checks the clamped index (select with 8 windows, min with 16) instead of the old guard.

Tested

  • RTX 3050 8 GB (desktop, Ryzen 7 5800XT), NVIDIA 610.88, Windows 11 build 26300, Rust 1.100.0 MSVC, release, DXC 1.9.2602.17.

  • On main cbc296a + this PR, cargo test --release -p xcl --lib -- --test-threads=4: 1100 passed, 0 failed, 26 ignored. Same with XCL_HEAP_WINDOWS=1. With XCL_DIRECT_DXIL=1, 1099 passed and 1 failed (gpu_image_get_resinfo_1d_array), which fails the same way on main cbc296a alone.

  • The new gpu_heap_windows_reject_out_of_uma_aliasing_all_slots fails with an aliasing index (xcl_w & 3u) in place of the min.

  • cargo clippy --release -p xcl --all-targets: no new warnings (772 on cbc296a and on this branch).

  • Five retail compute programs, measured before the rebase on 9e3831e (4 windows) (the list from #1269, by fnv64 of the console blob), split wave64, 4 windows, translated as the runtime does, then a cold CreateComputePipelineState with the runtime's root signature, one run each:

    Program main guarded form this PR
    4549529853faf5fd 287 KB DXIL, 3.5 s 262 KB, 2.3 s
    a3c0b8a98beee431 262 KB, 3.3 s 249 KB, 2.8 s
    c9579f1bea53bcca 242 KB, 2.8 s 229 KB, 2.8 s
    f377ca6830935314 51 KB, 0.4 s 49 KB, 0.4 s
    f7016de4c088c4be 261 KB, 3.1 s 249 KB, 2.5 s

    No handle phi in either form on these five today. Driver times on this machine vary by up to ±25 % between runs of the same DXIL, so read the time column as "not slower".

  • A title run with XCL_HEAP_WINDOWS=1 on main 9e3831e on this 8 GB card (for #680's open item 3): views made, 167 s, no device removal, no switch-form fallback, until the title's own watchdog exit.

Regression run
Both with XCL_HEAP_WINDOWS=1 XCL_NETWORK=0 XCL_PAGE_BUDGET_MB=4096, back to back:

main cbc296a:

xcl-smoke v1
commit: cbc296ab65a2661a61e3e2da109134bcd5319f60
gpu: NVIDIA GeForce RTX 3050
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1470 (PresentX 1470)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15526 MB

This PR (7372ef0): 95.0 % of main's frames, 110.9 % of its peak commit.

xcl-smoke v1
commit: 7372ef0f13fa1d123d06f9e2cb54a84a5f7757df
gpu: NVIDIA GeForce RTX 3050
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1397 (PresentX 1397)
presents per 2 s (last 3): 60 59 61
device removals: 0
crashes: 0
peak commit: 17213 MB

Not tested

  • AMD and Intel; wave64-native hardware; Linux / vkd3d-proton.
  • The RTX 4090 / 3080 Ti fast-fail with 621.24 (#680's open item 2): this card runs 610.88.
  • A device without AtomicInt64OnDescriptorHeapResourceSupported (the fallback path is not exercised here).

AI use

  • Claude Code (Claude Opus 5.5): wrote the change and the tests, ran the measurements, and drafted this description.
  • The integration onto main with #1992 / #1998 is @⁠WebIdentity1's patch (prepared with Codex), applied as posted plus the uma.rs test update; I read the diff and ran the checks above.

AI-assisted.

**@⁠brothernog** on GitHub · 2026-11-24 19:22 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695) `brothernog:heap-windows-branch-free` → `main` · +112 −54 · 8 files · 1 commits · open The preparation step (P0) for heap memory windows as a default, which @⁠ivall invited on #680 ([comment](https://git.gtahub.st/github/xcl-dev--xcl/pulls/680)) and @⁠Pipodi listed in #1269 ([comment](https://git.gtahub.st/github/xcl-dev--xcl/issues/1269)). Still opt-in (`XCL_HEAP_WINDOWS=1`); nothing changes with the variable unset. Part of #1269. With heap windows, every memory access was `[branch] if (xcl_w >= windows) { default } m = ResourceDescriptorHeap[base + xcl_w]; ...`. The guard gives each access two paths, and DXC's GVN can join their handles into a `phi %dx.types.Handle`, which NVIDIA refused in under a second with `E_OUTOFMEMORY` (#756). On `main` the programs that showed it no longer do (their translation changed with `b8b1f49`, as @⁠psuedo-tty found too), so this PR doesn't claim to fix a refusal today. What it changes is that the form can't produce one: the index is clamped, `min(xcl_w, 16u)` with all 16 heap windows in use (a `select` with fewer), and the slot after the window views holds a null raw UAV that reads 0 and drops stores and atomics, as the switch's `default` does. One path per access. **What is in it** One commit, `Recompiler: heap memory windows without a guard, a null view outside them`, rebased onto `main` `cbc296a` (#1992, #1998: 16 heap windows, the expanded-window checks) from @⁠WebIdentity1's integration patch ([comment](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1695)): - `gpu/recomp/emit.rs` (`mem_accessors`): the clamped index, no guard. - `gpu/recomp/mod.rs`: `MEM_HEAP_NULL` = `MEM_HEAP_BASE + MAX_HEAP_WINDOWS` (descriptor 20; `+ MAX_WINDOWS` would clamp valid higher windows), docs. - `hle/d3d12x/console_heap.rs`: `set_window_views` writes the null view, and only with 64-bit atomics on heap views; the shared heap's own allocations start after it (21). The 4 null views at 0..3 (#1992) are unchanged. - `hle/d3d12x/real.rs`: no `AtomicInt64OnDescriptorHeapResourceSupported` → no views, and the shaders keep the switch (`window_views_failed`), as with no shared heap. - `gpu/recomp/runner.rs`: the two test heaps get the null view too. - `gpu/recomp/tests.rs`: the out-of-UMA aliasing and invalid-window tests cover 4 / 8 / 16 layouts and the `min` path. - `gpu/uma.rs`: `expanded_heap_window_shaders_translate_and_validate` checks the clamped index (`select` with 8 windows, `min` with 16) instead of the old guard. **Tested** - RTX 3050 8 GB (desktop, Ryzen 7 5800XT), NVIDIA 610.88, Windows 11 build 26300, Rust 1.100.0 MSVC, release, DXC 1.9.2602.17. - On `main` `cbc296a` + this PR, `cargo test --release -p xcl --lib -- --test-threads=4`: 1100 passed, 0 failed, 26 ignored. Same with `XCL_HEAP_WINDOWS=1`. With `XCL_DIRECT_DXIL=1`, 1099 passed and 1 failed (`gpu_image_get_resinfo_1d_array`), which fails the same way on `main` `cbc296a` alone. - The new `gpu_heap_windows_reject_out_of_uma_aliasing_all_slots` fails with an aliasing index (`xcl_w & 3u`) in place of the `min`. - `cargo clippy --release -p xcl --all-targets`: no new warnings (772 on `cbc296a` and on this branch). - Five retail compute programs, measured before the rebase on `9e3831e` (4 windows) (the list from #1269, by `fnv64` of the console blob), split wave64, 4 windows, translated as the runtime does, then a cold `CreateComputePipelineState` with the runtime's root signature, one run each: | Program | `main` guarded form | this PR | |---|---|---| | `4549529853faf5fd` | 287 KB DXIL, 3.5 s | 262 KB, 2.3 s | | `a3c0b8a98beee431` | 262 KB, 3.3 s | 249 KB, 2.8 s | | `c9579f1bea53bcca` | 242 KB, 2.8 s | 229 KB, 2.8 s | | `f377ca6830935314` | 51 KB, 0.4 s | 49 KB, 0.4 s | | `f7016de4c088c4be` | 261 KB, 3.1 s | 249 KB, 2.5 s | No handle `phi` in either form on these five today. Driver times on this machine vary by up to ±25 % between runs of the same DXIL, so read the time column as "not slower". - A title run with `XCL_HEAP_WINDOWS=1` on `main` `9e3831e` on this 8 GB card (for #680's open item 3): views made, 167 s, no device removal, no switch-form fallback, until the title's own watchdog exit. **Regression run** Both with `XCL_HEAP_WINDOWS=1 XCL_NETWORK=0 XCL_PAGE_BUDGET_MB=4096`, back to back: `main` `cbc296a`: ``` xcl-smoke v1 commit: cbc296ab65a2661a61e3e2da109134bcd5319f60 gpu: NVIDIA GeForce RTX 3050 title: retail-title seconds: 60 exit: 0x0 frames shown: 1470 (PresentX 1470) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15526 MB ``` This PR (`7372ef0`): 95.0 % of `main`'s frames, 110.9 % of its peak commit. ``` xcl-smoke v1 commit: 7372ef0f13fa1d123d06f9e2cb54a84a5f7757df gpu: NVIDIA GeForce RTX 3050 title: retail-title seconds: 60 exit: 0x0 frames shown: 1397 (PresentX 1397) presents per 2 s (last 3): 60 59 61 device removals: 0 crashes: 0 peak commit: 17213 MB ``` **Not tested** - AMD and Intel; wave64-native hardware; Linux / vkd3d-proton. - The RTX 4090 / 3080 Ti fast-fail with 621.24 (#680's open item 2): this card runs 610.88. - A device without `AtomicInt64OnDescriptorHeapResourceSupported` (the fallback path is not exercised here). **AI use** - Claude Code (Claude Opus 5.5): wrote the change and the tests, ran the measurements, and drafted this description. - The integration onto `main` with #1992 / #1998 is @⁠WebIdentity1's patch (prepared with Codex), applied as posted plus the `uma.rs` test update; I read the diff and ran the checks above. AI-assisted.
With heap windows (XCL_HEAP_WINDOWS=1) each memory access was guarded by
`[branch] if (xcl_w >= windows)`. The guard gives every access two paths,
and DXC's GVN can join their descriptor handles into a `phi` of
`%dx.types.Handle`; NVIDIA refused such programs with E_OUTOFMEMORY in
under a second (#756). Nothing in the form prevented it.

Now the index is clamped instead: `min(xcl_w, 16)` with all heap windows
in use, or a `select` with fewer, into ResourceDescriptorHeap. Slot
MEM_HEAP_NULL = MEM_HEAP_BASE + MAX_HEAP_WINDOWS, after the window views,
holds a null raw UAV: it reads 0 and drops stores and atomics, which is
what the switch's `default` does. One path per access, so no handle `phi`
can form. The shared heap's own allocations start after it.

Heap views also need D3D12_OPTIONS11's
AtomicInt64OnDescriptorHeapResourceSupported, for the 64-bit atomics on
the windows; a device without it gets no views, and the shaders keep the
switch over the root UAVs (window_views_failed).

Rebased onto main with #1992 and #1998 (16 heap windows, expanded-window
checks) by WebIdentity1's integration: the null view at
MEM_HEAP_BASE + MAX_HEAP_WINDOWS rather than + MAX_WINDOWS, which would
clamp valid higher windows; the window tests cover 4 / 8 / 16 layouts.

Co-authored-by: WebIdentity1 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:01:55 +00:00
Author
Owner

@⁠brothernog on GitHub · 2026-11-24 19:34 UTC · original

@⁠Pipodi heads-up for your test claim: I rebased this onto main c160d86 to clear a conflict with #1426, so the head is now dd9f1ff (was 3009567). The rebase only resolved one test hunk in gpu/recomp/tests.rs; the description has the rerun suite (859 passed, 0 failed, with and without XCL_HEAP_WINDOWS=1) and a new smoke pair against c160d86.

This comment was AI-assisted.

**@⁠brothernog** on GitHub · 2026-11-24 19:34 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7142291653) @⁠Pipodi heads-up for your test claim: I rebased this onto `main` `c160d86` to clear a conflict with #1426, so the head is now `dd9f1ff` (was `3009567`). The rebase only resolved one test hunk in `gpu/recomp/tests.rs`; the description has the rerun suite (859 passed, 0 failed, with and without `XCL_HEAP_WINDOWS=1`) and a new smoke pair against `c160d86`. This comment was AI-assisted.
Author
Owner

@⁠Pipodi on GitHub · 2026-11-24 20:10 UTC · original

Test report: #1695 at dd9f1ff against main c160d86, RTX 4090. Follows my claim 7142018775 (moved to dd9f1ff in 7142428099).

Tested

  • RTX 4090 24 GB (driver 617.42), i9-13900K, 32 GB, Windows 11 Pro 26300, rustc 1.100.0. Both trees clean at their commits.
  • cargo test --workspace -- --test-threads=4 (debug), with XCL_HEAP_WINDOWS unset: 859 passed, 0 failed, 42 ignored.
    • SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64).
    • SKIPPED: heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows).
  • The same with XCL_HEAP_WINDOWS=1: 859 passed, 0 failed, 42 ignored. Only the two wave64 tests are SKIPPED, so heap_window_out_of_memory_falls_back_to_the_switch_form ran and passed.
  • Three big compute programs, cold, XCL_HEAP_WINDOWS=1 (release).
    • The command, per program: xcl shaders <record> --precompile --only cs, then --pipelines into the same cache.
    • A new XCL_DXIL_CACHE per run, one run each, a cap of 24 GB private commit and 600 s.
    • Both trees print "4 memory windows from the descriptor heap". None of these programs uses the compact form, which is not in main.
program tree DXIL DXC DXC peak driver (--pipelines)
ActivateRays #1695 — — over 24 GB at 22 s, stopped —
ActivateRays main — — over 24 GB at 23 s, stopped —
second program #1695 28,598,672 B 101.6 s 3.96 GB over 24 GB, stopped at 155 s
second program main 28,975,428 B 113.0 s 4.09 GB over 24 GB, stopped at 184 s
third program #1695 28,493,992 B 109.0 s 3.95 GB over 24 GB, stopped at 183 s
third program main 28,869,372 B 113.5 s 4.09 GB over 24 GB, stopped at 199 s
  • #1695's DXIL is 1.3 % smaller on both programs that finished, and DXC is 10 % and 4 % faster (one run each).
  • No driver build finished under the cap in either tree, so I have no driver time, no pipelines made / refused line, and no answer on the NVIDIA driver cache. The time at which each run passed 24 GB is not a measure of the driver's cost, and I don't read anything into it.
  • ActivateRays did not get through DXC within 24 GB in this form in either tree.

Regression run. The retail title, 60 s, XCL_PRESS_AT=16:A, XCL_HEAP_WINDOWS=1, a new empty XCL_DXIL_CACHE per run.

main c160d86:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: NVIDIA GeForce RTX 4090
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1271 (PresentX 1271)
presents per 2 s (last 3): 1 12 17
device removals: 0
crashes: 0
peak commit: 25021 MB

#1695 dd9f1ff:

xcl-smoke v1
commit: dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94
gpu: NVIDIA GeForce RTX 4090
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1212 (PresentX 1212)
presents per 2 s (last 3): 6 12 22
device removals: 0
crashes: 0
peak commit: 25537 MB

main c160d86, rerun: the first run's log was overwritten before it was saved, so I ran main again with the same setup.

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: NVIDIA GeForce RTX 4090
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1313 (PresentX 1313)
presents per 2 s (last 3): 4 32 46
device removals: 0
crashes: 0
peak commit: 25931 MB
  • Neither tree had a crash or device removal.
  • Against the first main run, #1695 had 95.3 % of the frames and 102.1 % of the peak commit. Against the rerun, it had 92.3 % and 98.5 %.
  • main's two runs differ by 3 % in frames and 4 % in peak.

Not tested

  • The driver's cost of a pipeline in this form. Each of the three driver builds passed 24 GB of commit on this 32 GB machine, in both trees.
  • The whole-pack --pipelines run in the heap form, which I claimed: I'm withdrawing it. ActivateRays alone passes 24 GB in DXC in this form, and the other two programs pass it in the driver, so the run cannot finish on this machine. With the compact form (#1316), ActivateRays builds in the heap form within 3,962 MB, and within 850 MB nested (@⁠brothernog's run on #1692). The pack run makes sense on top of that, and I'll claim it separately if I do it.
  • AMD, Intel, Linux. The title with XCL_HEAP_WINDOWS unset.

AI use: Claude Code. A Claude Sonnet 5.5 subagent ran the suite, the builds and the smoke runs. Claude Opus 5.5 (the main session) planned the series, checked the numbers and wrote this report.

**@⁠Pipodi** on GitHub · 2026-11-24 20:10 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7143135963) **Test report: #1695 at `dd9f1ff` against `main` `c160d86`, RTX 4090.** Follows my claim 7142018775 (moved to `dd9f1ff` in 7142428099). **Tested** - RTX 4090 24 GB (driver 617.42), i9-13900K, 32 GB, Windows 11 Pro 26300, `rustc 1.100.0`. Both trees clean at their commits. - `cargo test --workspace -- --test-threads=4` (debug), with `XCL_HEAP_WINDOWS` unset: 859 passed, 0 failed, 42 ignored. - SKIPPED: `gpu_geometry_wave32_prefix_count_over_a_mask` and `gpu_wave32_program_in_wave64_hardware` (no wave64). - SKIPPED: `heap_window_out_of_memory_falls_back_to_the_switch_form` (no heap windows). - The same with `XCL_HEAP_WINDOWS=1`: 859 passed, 0 failed, 42 ignored. Only the two wave64 tests are SKIPPED, so `heap_window_out_of_memory_falls_back_to_the_switch_form` ran and passed. - **Three big compute programs, cold, `XCL_HEAP_WINDOWS=1`** (release). - The command, per program: `xcl shaders <record> --precompile --only cs`, then `--pipelines` into the same cache. - A new `XCL_DXIL_CACHE` per run, one run each, a cap of 24 GB private commit and 600 s. - Both trees print "4 memory windows from the descriptor heap". None of these programs uses the compact form, which is not in `main`. | program | tree | DXIL | DXC | DXC peak | driver (`--pipelines`) | |---|---|---|---|---|---| | ActivateRays | #1695 | — | — | over 24 GB at 22 s, stopped | — | | ActivateRays | `main` | — | — | over 24 GB at 23 s, stopped | — | | second program | #1695 | 28,598,672 B | 101.6 s | 3.96 GB | over 24 GB, stopped at 155 s | | second program | `main` | 28,975,428 B | 113.0 s | 4.09 GB | over 24 GB, stopped at 184 s | | third program | #1695 | 28,493,992 B | 109.0 s | 3.95 GB | over 24 GB, stopped at 183 s | | third program | `main` | 28,869,372 B | 113.5 s | 4.09 GB | over 24 GB, stopped at 199 s | - #1695's DXIL is 1.3 % smaller on both programs that finished, and DXC is 10 % and 4 % faster (one run each). - No driver build finished under the cap in either tree, so I have no driver time, no `pipelines made / refused` line, and no answer on the NVIDIA driver cache. The time at which each run passed 24 GB is not a measure of the driver's cost, and I don't read anything into it. - ActivateRays did not get through DXC within 24 GB in this form in either tree. **Regression run.** The retail title, 60 s, `XCL_PRESS_AT=16:A`, `XCL_HEAP_WINDOWS=1`, a new empty `XCL_DXIL_CACHE` per run. `main` `c160d86`: ``` xcl-smoke v1 commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0 gpu: NVIDIA GeForce RTX 4090 title: retail-title seconds: 60 exit: 0x0 frames shown: 1271 (PresentX 1271) presents per 2 s (last 3): 1 12 17 device removals: 0 crashes: 0 peak commit: 25021 MB ``` #1695 `dd9f1ff`: ``` xcl-smoke v1 commit: dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94 gpu: NVIDIA GeForce RTX 4090 title: retail-title seconds: 60 exit: 0x0 frames shown: 1212 (PresentX 1212) presents per 2 s (last 3): 6 12 22 device removals: 0 crashes: 0 peak commit: 25537 MB ``` `main` `c160d86`, rerun: the first run's log was overwritten before it was saved, so I ran `main` again with the same setup. ``` xcl-smoke v1 commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0 gpu: NVIDIA GeForce RTX 4090 title: retail-title seconds: 60 exit: 0x0 frames shown: 1313 (PresentX 1313) presents per 2 s (last 3): 4 32 46 device removals: 0 crashes: 0 peak commit: 25931 MB ``` - Neither tree had a crash or device removal. - Against the first `main` run, #1695 had 95.3 % of the frames and 102.1 % of the peak commit. Against the rerun, it had 92.3 % and 98.5 %. - `main`'s two runs differ by 3 % in frames and 4 % in peak. **Not tested** - The driver's cost of a pipeline in this form. Each of the three driver builds passed 24 GB of commit on this 32 GB machine, in both trees. - **The whole-pack `--pipelines` run in the heap form, which I claimed:** I'm withdrawing it. ActivateRays alone passes 24 GB in DXC in this form, and the other two programs pass it in the driver, so the run cannot finish on this machine. With the compact form (#1316), ActivateRays builds in the heap form within 3,962 MB, and within 850 MB nested (@⁠brothernog's run on #1692). The pack run makes sense on top of that, and I'll claim it separately if I do it. - AMD, Intel, Linux. The title with `XCL_HEAP_WINDOWS` unset. **AI use:** Claude Code. A Claude Sonnet 5.5 subagent ran the suite, the builds and the smoke runs. Claude Opus 5.5 (the main session) planned the series, checked the numbers and wrote this report.
Author
Owner

@⁠MatyEjsr on GitHub · 2026-11-24 20:12 UTC · original

Independent NVIDIA desktop verification of PR #1695 at dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94 (both default and XCL_HEAP_WINDOWS=1).

Tested

  • OS: Windows 11 Pro for Workstations (build 26200)
  • CPU: AMD Ryzen 7 7800X3D (8-Core)
  • GPU: NVIDIA GeForce RTX 3090 (24 GB VRAM, driver 617.42 / 32.0.16.1742, wave32 / split wave64)
  • RAM: 31.4 GB
  • Toolchain: rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC, debug build, DXC dxcompiler 1.9.2602.17 (21d28f72) / dxil 1.9.2602.17
  • cargo build --workspace -j 8: succeeded (5.94s, 0 new warnings).
  • cargo test --workspace -j 8 -- --test-threads=8 --show-output (default): 859 passed, 0 failed, 42 ignored, 5 SKIPPED (gpu_geometry_wave32_prefix_count_over_a_mask: no wave64; gpu_wave32_program_in_wave64_hardware: no wave64; heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows; test_title_draws_with_a_root_signature_under_the_debug_layer: no d3d12SDKLayers.dll; uploads_start_from_each_subresources_state: no D3D12 debug layer (0x887A002D)).
  • XCL_HEAP_WINDOWS=1 cargo test --workspace -j 8 -- --test-threads=8 --show-output: 859 passed, 0 failed, 42 ignored, 4 SKIPPED (same 2 no wave64 + 2 debug-layer skips; heap_window_out_of_memory_falls_back_to_the_switch_form executed and passed).
  • Focused heap_window / memory_windows lib suite (including the new gpu_heap_windows_reject_out_of_uma_aliasing_all_slots): 8 passed, 0 failed, 0 ignored, 0 SKIPPED (0.64s). console_heap unit tests: 4 passed, 0 failed, 0 ignored, 0 SKIPPED (0.19s).
  • XCL_HEAP_WINDOWS=1 cargo test -p xcl --test gpu_compute_e2e -- --nocapture --test-threads=1: 4 passed, 0 failed, 0 ignored, 0 SKIPPED (1.23s warm / 1.29s cold). Logs confirmed D3D12.X: memory windows from the shared descriptor heap (no per-access switch) on RTX 3090 (AtomicInt64OnDescriptorHeapResourceSupported true). Comparing against base c160d86 on the same fixture (console_wave64_compute_through_the_pso_hook_dispatch_and_read_back, 4 windows, split wave64): DXIL shrunk from 5708 B (guarded branch form) to 5648 B (branchless min + null view), while the injected-OOM switch-form fallback stayed 6128 B and passed.
  • Combined XCL_HEAP_WINDOWS=1 XCL_DIRECT_DXIL=1: heap_window/memory_windows lib tests 8 passed (0.88s) and gpu_compute_e2e 4 passed (1.24s), cleanly falling back from direct DXIL to the HLSL heap-window path (5648 B DXIL) and using direct DXIL for the switch-form fallback (2892 B DXIL).

Notes from diff review

  • memory_windows_reject_out_of_uma_aliasing / _all_slots covers 32-bit out-of-UMA atomics on MEM_HEAP_NULL, but does not exercise 64-bit atomics (Interlocked*64) against the null raw UAV.
  • console_heap::tests tests set_window_views(..., true); adding a small unit check for set_window_views(..., false) verifying WINDOW_VIEWS_FAILED and 0 UAV calls would cover the new guard directly.

Not tested

  • AMD / Intel GPUs, native wave64 hardware, and Linux / Wine (vkd3d-proton).
  • D3D12 debug layer validation (d3d12SDKLayers.dll absent on this host).
  • An adapter without AtomicInt64OnDescriptorHeapResourceSupported.
  • Release build and retail title smoke run / XCL_SAMPLE_* tests.

AI use

  • agy with gemini-4-neon-high: inspected the diff, ran the builds, test suites, and base comparison on the hardware above, and drafted this report.
**@⁠MatyEjsr** on GitHub · 2026-11-24 20:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7143189709) Independent NVIDIA desktop verification of PR #1695 at `dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94` (both default and `XCL_HEAP_WINDOWS=1`). **Tested** - OS: Windows 11 Pro for Workstations (build 26200) - CPU: AMD Ryzen 7 7800X3D (8-Core) - GPU: NVIDIA GeForce RTX 3090 (24 GB VRAM, driver 617.42 / 32.0.16.1742, wave32 / split wave64) - RAM: 31.4 GB - Toolchain: `rustc 1.100.0 (0ef1bc386 2026-11-09)` MSVC, debug build, DXC `dxcompiler 1.9.2602.17 (21d28f72)` / `dxil 1.9.2602.17` - `cargo build --workspace -j 8`: succeeded (5.94s, 0 new warnings). - `cargo test --workspace -j 8 -- --test-threads=8 --show-output` (default): **859 passed, 0 failed, 42 ignored**, **5 SKIPPED** (`gpu_geometry_wave32_prefix_count_over_a_mask`: `no wave64`; `gpu_wave32_program_in_wave64_hardware`: `no wave64`; `heap_window_out_of_memory_falls_back_to_the_switch_form`: `no heap windows`; `test_title_draws_with_a_root_signature_under_the_debug_layer`: `no d3d12SDKLayers.dll`; `uploads_start_from_each_subresources_state`: `no D3D12 debug layer (0x887A002D)`). - `XCL_HEAP_WINDOWS=1 cargo test --workspace -j 8 -- --test-threads=8 --show-output`: **859 passed, 0 failed, 42 ignored**, **4 SKIPPED** (same 2 `no wave64` + 2 debug-layer skips; `heap_window_out_of_memory_falls_back_to_the_switch_form` executed and passed). - Focused `heap_window` / `memory_windows` lib suite (including the new `gpu_heap_windows_reject_out_of_uma_aliasing_all_slots`): **8 passed, 0 failed, 0 ignored, 0 SKIPPED** (0.64s). `console_heap` unit tests: **4 passed, 0 failed, 0 ignored, 0 SKIPPED** (0.19s). - `XCL_HEAP_WINDOWS=1 cargo test -p xcl --test gpu_compute_e2e -- --nocapture --test-threads=1`: **4 passed, 0 failed, 0 ignored, 0 SKIPPED** (1.23s warm / 1.29s cold). Logs confirmed `D3D12.X: memory windows from the shared descriptor heap (no per-access switch)` on RTX 3090 (`AtomicInt64OnDescriptorHeapResourceSupported` true). Comparing against base `c160d86` on the same fixture (`console_wave64_compute_through_the_pso_hook_dispatch_and_read_back`, 4 windows, split wave64): DXIL shrunk from `5708 B` (guarded branch form) to `5648 B` (branchless `min` + null view), while the injected-OOM switch-form fallback stayed `6128 B` and passed. - Combined `XCL_HEAP_WINDOWS=1 XCL_DIRECT_DXIL=1`: `heap_window`/`memory_windows` lib tests **8 passed** (0.88s) and `gpu_compute_e2e` **4 passed** (1.24s), cleanly falling back from direct DXIL to the HLSL heap-window path (`5648 B DXIL`) and using direct DXIL for the switch-form fallback (`2892 B DXIL`). **Notes from diff review** - `memory_windows_reject_out_of_uma_aliasing` / `_all_slots` covers 32-bit out-of-UMA atomics on `MEM_HEAP_NULL`, but does not exercise 64-bit atomics (`Interlocked*64`) against the null raw UAV. - `console_heap::tests` tests `set_window_views(..., true)`; adding a small unit check for `set_window_views(..., false)` verifying `WINDOW_VIEWS_FAILED` and 0 UAV calls would cover the new guard directly. **Not tested** - AMD / Intel GPUs, native wave64 hardware, and Linux / Wine (`vkd3d-proton`). - D3D12 debug layer validation (`d3d12SDKLayers.dll` absent on this host). - An adapter without `AtomicInt64OnDescriptorHeapResourceSupported`. - Release build and retail title smoke run / `XCL_SAMPLE_*` tests. **AI use** - agy with gemini-4-neon-high: inspected the diff, ran the builds, test suites, and base comparison on the hardware above, and drafted this report.
Author
Owner

@⁠throny on GitHub · 2026-11-24 20:15 UTC · original

Two contributors checked independently and found that #1669 solves the same problem (for #1269) in a different way: #1607, group D44. You may want to compare them with the other author and agree on one, or say in the PR why both are needed.

This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far.

AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.

**@⁠throny** on GitHub · 2026-11-24 20:15 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7143270656) <!-- xcl-1607-hint:D44 --> Two contributors checked independently and found that #1669 solves the same problem (for #1269) in a different way: #1607, group D44. You may want to compare them with the other author and agree on one, or say in the PR why both are needed. This is a hint, not a request from the maintainers; nobody from the project has adopted #1607 so far. AI use: Claude Code (Claude Opus 5.5), posted by a script from the #1607 table.
Author
Owner

@⁠thiagocalile on GitHub · 2026-11-24 20:27 UTC · original

Tested commit dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94 on an AMD Radeon RX 6600 (RDNA2, native 64-lane waves): all targeted tests passed.

Tested

  • Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64 + mesh shaders, driver 32.0.21045.29003; XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.8.2502.11, debug build.
  • XCL_ADAPTER=radeon cargo test -p xcl --lib gpu::recomp::tests -- --test-threads=4: 121 passed, 0 failed, 17 ignored (36.42s).
  • XCL_ADAPTER=radeon XCL_HEAP_WINDOWS=1 cargo test -p xcl --test gpu_compute_e2e -- --nocapture: 4 passed, 0 failed, 0 ignored (37.55s).
  • XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 856 passed, 3 failed, 42 ignored (38.07s).
    • The 3 workspace failures are pre-existing on main on this RX 6600 (placed_title_textures_share_vram_and_preserve_pixels: 3D mip subresource mismatch, plus 2 mutex-poison cascades transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory; tracked by #1028).
    • SKIPPED (not counted as coverage): heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows (plus D3D12 debug-layer tests skip because d3d12SDKLayers.dll is not installed).

Not tested

  • Retail title run (scripts/smoke.ps1 — no game executable here), D3D12 debug layer, NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Antigravity (Gemini 4 Neon) ran the test suites on my RX 6600 and drafted this report; I checked the results before posting.
**@⁠thiagocalile** on GitHub · 2026-11-24 20:27 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7143568980) Tested commit `dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94` on an AMD Radeon RX 6600 (RDNA2, native 64-lane waves): all targeted tests passed. **Tested** - Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64 + mesh shaders, driver `32.0.21045.29003`; `XCL_ADAPTER=radeon`), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (`10.0.26200.0`), Rust `1.100.0` (`stable-x86_64-pc-windows-msvc`), DXC `1.8.2502.11`, debug build. - `XCL_ADAPTER=radeon cargo test -p xcl --lib gpu::recomp::tests -- --test-threads=4`: **121 passed, 0 failed, 17 ignored** (`36.42s`). - `XCL_ADAPTER=radeon XCL_HEAP_WINDOWS=1 cargo test -p xcl --test gpu_compute_e2e -- --nocapture`: **4 passed, 0 failed, 0 ignored** (`37.55s`). - `XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4`: **856 passed, 3 failed, 42 ignored** (`38.07s`). - The 3 workspace failures are pre-existing on `main` on this RX 6600 (`placed_title_textures_share_vram_and_preserve_pixels`: 3D mip subresource mismatch, plus 2 mutex-poison cascades `transitions_apply_when_their_list_is_submitted` and `d32s8_targets_take_their_own_size_of_video_memory`; tracked by #1028). - `SKIPPED` (not counted as coverage): `heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows` (plus D3D12 debug-layer tests skip because `d3d12SDKLayers.dll` is not installed). **Not tested** - Retail title run (`scripts/smoke.ps1` — no game executable here), D3D12 debug layer, NVIDIA / Intel GPUs, Linux / Wine. **AI use** - Antigravity (Gemini 4 Neon) ran the test suites on my RX 6600 and drafted this report; I checked the results before posting.
Author
Owner

@⁠milesah3ad on GitHub · 2026-11-24 20:32 UTC · original

Extra data for the null-view approach this PR shares with #1669, which I've closed in favour of this one. The two forms differ only in the index (min(xcl_w, 4u) here, xcl_w < windows ? base + xcl_w : MEM_HEAP_NULL there), with the same null raw UAV at MEM_HEAP_BASE + MAX_WINDOWS. So these reports on #1669's head daaa354 test the same mechanism, but not this PR's head or its 64-bit atomics check:

  • AMD RX 7800 XT, retail title (@⁠srcamarda, #1669): smoke pairs against main c160d86 with and without XCL_HEAP_WINDOWS=1, two rounds each, no regression or crash. Also XCL_D3D12_DEBUG=1 runs into the world load: the same debug-layer message ids as main, none new from the null view.
  • RTX 3090 (@⁠WebIdentity1, #1669): suite 857 / 1 / 42 on both main and the head (the 1 is #202), with gpu_heap_windows_reject_out_of_uma_aliasing passing through the null view.
  • RTX 5080, driver 621.24, synthetic programs (mine, on #1669): cold CreateComputePipelineState on 20 programs from the nv680 generator (4 windows, split wave64), guarded form vs null view: 253.0 → 238.4 s (−5.8 %), faster on base / loop / wave / 32-bit atomic shapes (−2 to −16 %), slower on the 64-bit-atomic shape (+12 to +19 %, DXIL +5 %). Your retail numbers are the better measure. I mention the 64-bit case in case it's worth a look on programs that use those atomics heavily.

Not tested: this PR's head dd9f1ff itself, and its AtomicInt64OnDescriptorHeapResourceSupported gate.

AI use: Claude Code (Claude Opus 5.5) wrote this. The numbers are from the reports linked above.

**@⁠milesah3ad** on GitHub · 2026-11-24 20:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7143697714) Extra data for the null-view approach this PR shares with #1669, which I've closed in favour of this one. The two forms differ only in the index (`min(xcl_w, 4u)` here, `xcl_w < windows ? base + xcl_w : MEM_HEAP_NULL` there), with the same null raw UAV at `MEM_HEAP_BASE + MAX_WINDOWS`. So these reports on #1669's head `daaa354` test the same mechanism, but not this PR's head or its 64-bit atomics check: - **AMD RX 7800 XT, retail title** (@⁠srcamarda, https://git.gtahub.st/github/xcl-dev--xcl/pulls/1669): smoke pairs against `main` `c160d86` with and without `XCL_HEAP_WINDOWS=1`, two rounds each, no regression or crash. Also `XCL_D3D12_DEBUG=1` runs into the world load: the same debug-layer message ids as `main`, none new from the null view. - **RTX 3090** (@⁠WebIdentity1, https://git.gtahub.st/github/xcl-dev--xcl/pulls/1669): suite 857 / 1 / 42 on both `main` and the head (the 1 is #202), with `gpu_heap_windows_reject_out_of_uma_aliasing` passing through the null view. - **RTX 5080, driver 621.24, synthetic programs** (mine, on #1669): cold `CreateComputePipelineState` on 20 programs from the `nv680` generator (4 windows, split wave64), guarded form vs null view: 253.0 → 238.4 s (−5.8 %), faster on base / loop / wave / 32-bit atomic shapes (−2 to −16 %), **slower on the 64-bit-atomic shape (+12 to +19 %, DXIL +5 %)**. Your retail numbers are the better measure. I mention the 64-bit case in case it's worth a look on programs that use those atomics heavily. **Not tested:** this PR's head `dd9f1ff` itself, and its `AtomicInt64OnDescriptorHeapResourceSupported` gate. AI use: Claude Code (Claude Opus 5.5) wrote this. The numbers are from the reports linked above.
Author
Owner

@⁠LocranKing on GitHub · 2026-11-24 20:37 UTC · original

Independent 8 GB NVIDIA Ampere (RTX 3060 Ti, wave32) check at dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94 (base main c160d86ef2efe3a07e4dfb473e4fa72eafb413c0), tested both with XCL_HEAP_WINDOWS unset and XCL_HEAP_WINDOWS=1.

Setup

  • GPU: NVIDIA GeForce RTX 3060 Ti (8024 MiB VRAM, Ampere, wave32), driver 32.0.16.2101
  • CPU / RAM: AMD Ryzen 5 5500 (6C/12T), 31.8 GB RAM
  • OS: Windows 11 Home Single Language, build 26200
  • Toolchain: rustc 1.100.0, DXC 1.9.2602.17, --release

Workspace tests (cargo test --workspace --release --no-fail-fast -- --test-threads=4)

  • XCL_HEAP_WINDOWS unset: exit 0; 859 passed, 0 failed, 42 ignored (SKIPPED: 2 no wave64, 2 no D3D12 debug layer, heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows).
  • XCL_HEAP_WINDOWS=1: exit 0; 859 passed, 0 failed, 42 ignored (heap_window_out_of_memory_falls_back_to_the_switch_form ran and passed; only the 2 no wave64 and 2 no D3D12 debug layer skips remained).

Regression runs (scripts/smoke.ps1, 60 s, XCL_NETWORK=0, title folder name redacted)

  • With XCL_HEAP_WINDOWS=1, xcl.log confirmed UMA: 3 sparse VRAM window(s) (12 GiB VA) + 4095 MB coherent window at 0x400000000 and D3D12.X: memory windows from the shared descriptor heap (no per-access switch) at 1.588 s (0 refusals, 0 switch-form fallbacks — the 64-bit atomics capability check passed on this Ampere card).
  • Default vs base c160d86: 1576 / 1538 frames (102.5%), 15200 / 16245 MB peak commit (93.6%), 0 removals, 0 crashes.
  • XCL_HEAP_WINDOWS=1 vs base c160d86: 1473 / 1538 frames (95.8%), 15763 / 16245 MB peak commit (97.0%), 0 removals, 0 crashes.

Base (main c160d86, default):

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1538 (PresentX 1538)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16245 MB

PR head (dd9f1ff, XCL_HEAP_WINDOWS unset):

xcl-smoke v1
commit: dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1576 (PresentX 1576)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15200 MB

PR head (dd9f1ff, XCL_HEAP_WINDOWS=1):

xcl-smoke v1
commit: dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94
gpu: NVIDIA GeForce RTX 3060 Ti
title: retail-1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1473 (PresentX 1474)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15763 MB

Not tested: world-loading run on dd9f1ff, hardware lacking AtomicInt64OnDescriptorHeapResourceSupported, AMD / wave64 hardware.

AI use: Antigravity (Gemini 4 Neon) built and ran the workspace suites and smoke runs on this hardware and drafted this report from the captured outputs; reviewed before posting. No game files attached.

**@⁠LocranKing** on GitHub · 2026-11-24 20:37 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7143832145) Independent 8 GB NVIDIA Ampere (`RTX 3060 Ti`, wave32) check at `dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94` (base `main` `c160d86ef2efe3a07e4dfb473e4fa72eafb413c0`), tested both with `XCL_HEAP_WINDOWS` unset and `XCL_HEAP_WINDOWS=1`. **Setup** - GPU: NVIDIA GeForce RTX 3060 Ti (`8024 MiB VRAM`, Ampere, wave32), driver `32.0.16.2101` - CPU / RAM: AMD Ryzen 5 5500 (6C/12T), `31.8 GB` RAM - OS: Windows 11 Home Single Language, build `26200` - Toolchain: `rustc 1.100.0`, DXC `1.9.2602.17`, `--release` **Workspace tests (`cargo test --workspace --release --no-fail-fast -- --test-threads=4`)** - `XCL_HEAP_WINDOWS` unset: exit `0`; **859 passed, 0 failed, 42 ignored** (`SKIPPED`: 2 `no wave64`, 2 `no D3D12 debug layer`, `heap_window_out_of_memory_falls_back_to_the_switch_form: no heap windows`). - `XCL_HEAP_WINDOWS=1`: exit `0`; **859 passed, 0 failed, 42 ignored** (`heap_window_out_of_memory_falls_back_to_the_switch_form` ran and passed; only the 2 `no wave64` and 2 `no D3D12 debug layer` skips remained). **Regression runs (`scripts/smoke.ps1`, 60 s, `XCL_NETWORK=0`, title folder name redacted)** - With `XCL_HEAP_WINDOWS=1`, `xcl.log` confirmed `UMA: 3 sparse VRAM window(s) (12 GiB VA) + 4095 MB coherent window at 0x400000000` and `D3D12.X: memory windows from the shared descriptor heap (no per-access switch)` at `1.588 s` (`0` refusals, `0` switch-form fallbacks — the 64-bit atomics capability check passed on this Ampere card). - Default vs base `c160d86`: `1576 / 1538` frames (**102.5%**), `15200 / 16245 MB` peak commit (**93.6%**), `0` removals, `0` crashes. - `XCL_HEAP_WINDOWS=1` vs base `c160d86`: `1473 / 1538` frames (**95.8%**), `15763 / 16245 MB` peak commit (**97.0%**), `0` removals, `0` crashes. Base (`main` `c160d86`, default): ``` xcl-smoke v1 commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0 gpu: NVIDIA GeForce RTX 3060 Ti title: retail-1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1538 (PresentX 1538) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 16245 MB ``` PR head (`dd9f1ff`, `XCL_HEAP_WINDOWS` unset): ``` xcl-smoke v1 commit: dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94 gpu: NVIDIA GeForce RTX 3060 Ti title: retail-1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1576 (PresentX 1576) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15200 MB ``` PR head (`dd9f1ff`, `XCL_HEAP_WINDOWS=1`): ``` xcl-smoke v1 commit: dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94 gpu: NVIDIA GeForce RTX 3060 Ti title: retail-1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1473 (PresentX 1474) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 15763 MB ``` **Not tested:** world-loading run on `dd9f1ff`, hardware lacking `AtomicInt64OnDescriptorHeapResourceSupported`, AMD / wave64 hardware. **AI use:** Antigravity (`Gemini 4 Neon`) built and ran the workspace suites and smoke runs on this hardware and drafted this report from the captured outputs; reviewed before posting. No game files attached.
Author
Owner

@⁠minimalhipster990 on GitHub · 2026-11-24 21:52 UTC · original

XCL #1695 on the RTX 4090 — BeginUpdate and ResolveVBuffer

24 November 2026 · NVIDIA driver 621.24 · Eight matched rounds per shader

With heap windows enabled, the median first driver PSO creation time for ResolveVBuffer went from 2325.2 to 2090.4 ms (-10.1%). PR creation was faster in 8/8 matched rounds. BeginUpdate went from 295.9 to 284.6 ms (-3.8%, faster in 8/8 rounds). With heap windows disabled, base and PR emitted byte-identical HLSL and DXIL for both shaders. PR #1695 · Shader optimization tracker #1269

Timing results

All times are CPU wall-clock milliseconds. Each cell gives the median of eight samples followed by the observed minimum and maximum in parentheses. “First PSO” means the first call to CreateComputePipelineState for the supplied DXIL in a new process. “Repeat PSO” uses the same device and bytecode immediately afterward.

Retail shader Revision Heap windows HLSL generation (ms) DXC to DXIL (ms) First driver PSO (ms) Repeat driver PSO (ms)
BeginUpdate Base off 2.42 (2.32–2.66) 492.6 (487.7–505.8) 390.1 (384.5–398.4) 0.81 (0.73–0.88)
BeginUpdate Base on 2.42 (2.35–2.69) 408.0 (401.5–442.7) 295.9 (289.7–300.4) 0.75 (0.67–1.00)
BeginUpdate PR off 2.41 (2.38–2.87) 491.7 (488.9–500.4) 391.0 (386.4–421.2) 0.77 (0.74–0.92)
BeginUpdate PR on 2.32 (2.29–3.96) 392.1 (384.7–415.6) 284.6 (281.3–289.2) 0.75 (0.71–0.83)
ResolveVBuffer Base off 27.43 (26.86–30.80) 2922.0 (2774.1–3214.7) 8455.6 (7818.4–9144.3) 4.44 (3.86–4.54)
ResolveVBuffer Base on 29.79 (27.58–32.84) 2405.8 (2282.6–3010.7) 2325.2 (2238.3–2905.4) 3.27 (2.64–3.63)
ResolveVBuffer PR off 27.55 (27.39–29.62) 2920.0 (2787.6–2977.9) 8396.1 (8021.3–8897.1) 4.49 (3.87–4.55)
ResolveVBuffer PR on 28.13 (27.69–28.88) 2163.1 (2110.8–2434.0) 2090.4 (1958.6–2263.9) 3.17 (2.55–3.43)

Heap-enabled PR relative to heap-enabled base

Shader HLSL median DXC median First driver PSO median Repeat driver PSO median DXIL size
BeginUpdate -4.1% -3.9% -3.8% +0.4% 52,288 → 51,196 B (-2.1%)
ResolveVBuffer -5.6% -10.1% -10.1% -3.3% 294,676 → 268,792 B (-8.8%)

Within the PR, switching from root windows to heap windows changed median first PSO creation by -27.2% for BeginUpdate and -75.1% for ResolveVBuffer. The off-to-off control gives a direct view of timing variability on identical bytecode. The measurements cover pipeline preparation. Frame time and GPU dispatch duration were outside the timing interval.
DXC was faster with the PR in 7/8 heap-enabled BeginUpdate pairs and 8/8 ResolveVBuffer pairs. The heap-enabled ResolveVBuffer DXIL shrank by 25,884 bytes. Both the old and new forms created a PSO successfully on driver 621.24 for these inputs.

Validation

  • All 64 timed DXIL compilations passed the DXIL validator. All 128 timed driver PSO creations succeeded. Each timed HLSL and DXIL matched the corresponding saved artifact by size and FNV-1a. The disassembler found 0 instructions of the form phi %dx.types.Handle across the eight saved variants.
  • BeginUpdate. Dispatched one 32×1 group for each of two counter inputs, 45 and 1,200, with 30 queued. CPU expectations covered the cleared counters and argument buffers, including the computed dispatch count changing from 1 to 2. Compared all 65,536 bytes of memory including surrounding canaries in each of the four configurations.
  • ResolveVBuffer. Dispatched one 8×4 group twice per configuration, using a background-only visibility texture and a checkerboard with 16 active pixels on a controlled zero-lighting path. All 32 prefilled RGBA values survived the background dispatch. Each checkerboard produced 16 zero RGBA pixels and preserved the other 16 distinct prefilled pixels bit-for-bit. Compared all 512 output bytes and all 65,536 bytes of fixture buffer memory against CPU expectations.
  • All 16 dispatch readbacks matched their expected outputs and matched across revisions and modes. These fixtures cover selected paths through the retail programs. A captured scene with the game’s material, lighting and streaming state would be needed for a full-frame comparison.
  • Upstream windows_ test filter on base: 11 passed. Includes the guarded-heap and root-window checks.
  • Upstream windows_ test filter on pr: 12 passed. Includes the four-slot null-UAV test covering reads, discarded stores and atomics, and canaries in two distinct memory windows.

Inputs and method

  • Compared the common ancestor c160d86ef2efe3a07e4dfb473e4fa72eafb413c0 against the two-commit PR head dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94. Both used release builds with the locked dependency set. Commit comparison
  • Both records were extracted from the same local shaders.rpf. BeginUpdate is weatherParticle:CS_BeginUpdate_f7374ac1_Wrapped, console blob FNV-1a f377ca6830935314, 1,740 bytes of ISA, wave64 translated for wave32. ResolveVBuffer is sr_tracing:CS_ResolveVBuffer_ddc66de0_Wrapped, FNV-1a 4549529853faf5fd, 32,008 bytes of ISA, wave32.
  • Windows 11 build 26300.10075, Ryzen 7 5800X3D, GeForce RTX 4090, NVIDIA 621.24. Rust 1.99.1 MSVC, DXC/DXIL 1.9.2602.17 (21d28f72) from Windows SDK 10.0.26100.0. D3D12 OPTIONS11 reported AtomicInt64OnDescriptorHeapResourceSupported = true.
  • The timing harness called each revision’s HLSL translator for compute with four memory windows, sampler base zero and split-wave64 enabled. With XCL_HEAP_WINDOWS unset both sources emitted the root-window switch. With XCL_HEAP_WINDOWS=1 the base emitted a guard and the PR emitted min(xcl_w, 4u) with a null raw UAV at slot 4.
  • The HLSL interval covers the production translation call. The DXC interval covers XCL’s synchronous, uncached compile call including worker startup, using main, cs_6_6, HLSL 2021 and XCL’s normal optimization policy (default for BeginUpdate, -O1 for ResolveVBuffer). Blob extraction, standalone DXIL validation, device and root signature creation, and all readbacks fall outside the three main timing intervals. The PSO used the runtime root signature with zero or five static samplers respectively.
  • All 64 trials ran serially. Each shader saw all four variants in each round, in four balanced orders repeated twice. Shader order alternated. Each trial used a new process and executable path with no application PSO blob. Disabling the implicit driver shader cache returned 0x887A002D on this system, so persistent driver cache effects remain possible.
  • The readback harness used the exact saved DXIL from each measured arm, one common device-binding implementation, four valid memory-window views, and the PR’s reserved null descriptor. Retail fixture addresses were in window zero. Upstream tests separately exercised actual cross-window and out-of-UMA accesses.

The first four rounds finished before the readback harness build. The last four rounds were repeated after both revisions’ test builds and GPU checks finished because some original trials overlapped that work. The tables and raw data use the eight uncontended rounds. Superseded samples are retained separately under logs/initial-overlap.

The locally retained timings.csv contains the 64 reported timing rows. results.json contains the measurements, ranges, artifact sizes and readback hashes. To reproduce from the retained checkouts and local dump, run the following commands in the benchmark directory, one at a time.

python build.py base pr
python run.py inspect base
python run.py inspect pr
python run.py measure
python verify.py build
python verify.py all
python upstream.py
python results.py
python report.py

AI assistance: OpenAI Codex prepared the harness, ran the measurements and drafted this report.

**@⁠minimalhipster990** on GitHub · 2026-11-24 21:52 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7145512238) # XCL #1695 on the RTX 4090 — BeginUpdate and ResolveVBuffer 24 November 2026 · NVIDIA driver 621.24 · Eight matched rounds per shader With heap windows enabled, the median first driver PSO creation time for ResolveVBuffer went from **2325.2 to 2090.4 ms** (-10.1%). PR creation was faster in 8/8 matched rounds. BeginUpdate went from **295.9 to 284.6 ms** (-3.8%, faster in 8/8 rounds). With heap windows disabled, base and PR emitted byte-identical HLSL and DXIL for both shaders. [PR #1695](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1695) · [Shader optimization tracker #1269](https://git.gtahub.st/github/xcl-dev--xcl/issues/1269) ## Timing results All times are CPU wall-clock milliseconds. Each cell gives the median of eight samples followed by the observed minimum and maximum in parentheses. “First PSO” means the first call to `CreateComputePipelineState` for the supplied DXIL in a new process. “Repeat PSO” uses the same device and bytecode immediately afterward. | Retail shader | Revision | Heap windows | HLSL generation (ms) | DXC to DXIL (ms) | First driver PSO (ms) | Repeat driver PSO (ms) | | --- | --- | --- | --- | --- | --- | --- | | BeginUpdate | Base | off | 2.42 (2.32–2.66) | 492.6 (487.7–505.8) | 390.1 (384.5–398.4) | 0.81 (0.73–0.88) | | BeginUpdate | Base | on | 2.42 (2.35–2.69) | 408.0 (401.5–442.7) | 295.9 (289.7–300.4) | 0.75 (0.67–1.00) | | BeginUpdate | PR | off | 2.41 (2.38–2.87) | 491.7 (488.9–500.4) | 391.0 (386.4–421.2) | 0.77 (0.74–0.92) | | BeginUpdate | PR | on | 2.32 (2.29–3.96) | 392.1 (384.7–415.6) | 284.6 (281.3–289.2) | 0.75 (0.71–0.83) | | ResolveVBuffer | Base | off | 27.43 (26.86–30.80) | 2922.0 (2774.1–3214.7) | 8455.6 (7818.4–9144.3) | 4.44 (3.86–4.54) | | ResolveVBuffer | Base | on | 29.79 (27.58–32.84) | 2405.8 (2282.6–3010.7) | 2325.2 (2238.3–2905.4) | 3.27 (2.64–3.63) | | ResolveVBuffer | PR | off | 27.55 (27.39–29.62) | 2920.0 (2787.6–2977.9) | 8396.1 (8021.3–8897.1) | 4.49 (3.87–4.55) | | ResolveVBuffer | PR | on | 28.13 (27.69–28.88) | 2163.1 (2110.8–2434.0) | 2090.4 (1958.6–2263.9) | 3.17 (2.55–3.43) | ### Heap-enabled PR relative to heap-enabled base | Shader | HLSL median | DXC median | First driver PSO median | Repeat driver PSO median | DXIL size | | --- | --- | --- | --- | --- | --- | | BeginUpdate | -4.1% | -3.9% | -3.8% | +0.4% | 52,288 → 51,196 B (-2.1%) | | ResolveVBuffer | -5.6% | -10.1% | -10.1% | -3.3% | 294,676 → 268,792 B (-8.8%) | Within the PR, switching from root windows to heap windows changed median first PSO creation by -27.2% for BeginUpdate and -75.1% for ResolveVBuffer. The off-to-off control gives a direct view of timing variability on identical bytecode. The measurements cover pipeline preparation. Frame time and GPU dispatch duration were outside the timing interval. DXC was faster with the PR in 7/8 heap-enabled BeginUpdate pairs and 8/8 ResolveVBuffer pairs. The heap-enabled ResolveVBuffer DXIL shrank by 25,884 bytes. Both the old and new forms created a PSO successfully on driver 621.24 for these inputs. ## Validation - All 64 timed DXIL compilations passed the DXIL validator. All 128 timed driver PSO creations succeeded. Each timed HLSL and DXIL matched the corresponding saved artifact by size and FNV-1a. The disassembler found 0 instructions of the form `phi %dx.types.Handle` across the eight saved variants. - **BeginUpdate.** Dispatched one 32×1 group for each of two counter inputs, 45 and 1,200, with 30 queued. CPU expectations covered the cleared counters and argument buffers, including the computed dispatch count changing from 1 to 2. Compared all 65,536 bytes of memory including surrounding canaries in each of the four configurations. - **ResolveVBuffer.** Dispatched one 8×4 group twice per configuration, using a background-only visibility texture and a checkerboard with 16 active pixels on a controlled zero-lighting path. All 32 prefilled RGBA values survived the background dispatch. Each checkerboard produced 16 zero RGBA pixels and preserved the other 16 distinct prefilled pixels bit-for-bit. Compared all 512 output bytes and all 65,536 bytes of fixture buffer memory against CPU expectations. - All 16 dispatch readbacks matched their expected outputs and matched across revisions and modes. These fixtures cover selected paths through the retail programs. A captured scene with the game’s material, lighting and streaming state would be needed for a full-frame comparison. - Upstream `windows_` test filter on base: 11 passed. Includes the guarded-heap and root-window checks. - Upstream `windows_` test filter on pr: 12 passed. Includes the four-slot null-UAV test covering reads, discarded stores and atomics, and canaries in two distinct memory windows. ## Inputs and method - Compared the common ancestor `c160d86ef2efe3a07e4dfb473e4fa72eafb413c0` against the two-commit PR head `dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94`. Both used release builds with the locked dependency set. [Commit comparison](https://github.com/xcl-dev/xcl/compare/c160d86ef2efe3a07e4dfb473e4fa72eafb413c0...dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94) - Both records were extracted from the same local `shaders.rpf`. BeginUpdate is `weatherParticle:CS_BeginUpdate_f7374ac1_Wrapped`, console blob FNV-1a `f377ca6830935314`, 1,740 bytes of ISA, wave64 translated for wave32. ResolveVBuffer is `sr_tracing:CS_ResolveVBuffer_ddc66de0_Wrapped`, FNV-1a `4549529853faf5fd`, 32,008 bytes of ISA, wave32. - Windows 11 build 26300.10075, Ryzen 7 5800X3D, GeForce RTX 4090, NVIDIA 621.24. Rust 1.99.1 MSVC, DXC/DXIL 1.9.2602.17 (21d28f72) from Windows SDK 10.0.26100.0. D3D12 OPTIONS11 reported `AtomicInt64OnDescriptorHeapResourceSupported = true`. - The timing harness called each revision’s HLSL translator for compute with four memory windows, sampler base zero and split-wave64 enabled. With `XCL_HEAP_WINDOWS` unset both sources emitted the root-window switch. With `XCL_HEAP_WINDOWS=1` the base emitted a guard and the PR emitted `min(xcl_w, 4u)` with a null raw UAV at slot 4. - The HLSL interval covers the production translation call. The DXC interval covers XCL’s synchronous, uncached compile call including worker startup, using `main`, `cs_6_6`, HLSL 2021 and XCL’s normal optimization policy (default for BeginUpdate, `-O1` for ResolveVBuffer). Blob extraction, standalone DXIL validation, device and root signature creation, and all readbacks fall outside the three main timing intervals. The PSO used the runtime root signature with zero or five static samplers respectively. - All 64 trials ran serially. Each shader saw all four variants in each round, in four balanced orders repeated twice. Shader order alternated. Each trial used a new process and executable path with no application PSO blob. Disabling the implicit driver shader cache returned `0x887A002D` on this system, so persistent driver cache effects remain possible. - The readback harness used the exact saved DXIL from each measured arm, one common device-binding implementation, four valid memory-window views, and the PR’s reserved null descriptor. Retail fixture addresses were in window zero. Upstream tests separately exercised actual cross-window and out-of-UMA accesses. The first four rounds finished before the readback harness build. The last four rounds were repeated after both revisions’ test builds and GPU checks finished because some original trials overlapped that work. The tables and raw data use the eight uncontended rounds. Superseded samples are retained separately under `logs/initial-overlap`. The locally retained `timings.csv` contains the 64 reported timing rows. `results.json` contains the measurements, ranges, artifact sizes and readback hashes. To reproduce from the retained checkouts and local dump, run the following commands in the benchmark directory, one at a time. ```powershell python build.py base pr python run.py inspect base python run.py inspect pr python run.py measure python verify.py build python verify.py all python upstream.py python results.py python report.py ``` AI assistance: OpenAI Codex prepared the harness, ran the measurements and drafted this report.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 22:02 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored.

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-24 22:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7145728830) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. Thanks!
Author
Owner

@⁠brothernog on GitHub · 2026-11-24 22:21 UTC · original

@⁠minimalhipster990 thanks, this is the 4090 / 621.24 data the PR was missing. Two things from it matter beyond the timing:

  • On 621.24, both the guarded form and this PR's form made their PSOs on this card for both programs. The fast-fail on the 4090 / 3080 Ti with 621.24 (#680's open item 2) didn't show up here. These are two programs, not the title, so it narrows that item but doesn't close it.
  • With XCL_HEAP_WINDOWS unset, the HLSL and DXIL were byte-identical, as intended. With it set, there were no handle phis and the readbacks matched, on a second NVIDIA generation.

Your −8.8 % DXIL and −10 % first PSO on ResolveVBuffer (4549529853faf5fd) are close to what I saw on the 3050 (287 → 262 KB, 3.5 → 2.3 s, one run each, so noisier).

This comment was AI-assisted.

**@⁠brothernog** on GitHub · 2026-11-24 22:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7146132936) @⁠minimalhipster990 thanks, this is the 4090 / 621.24 data the PR was missing. Two things from it matter beyond the timing: - On 621.24, both the guarded form and this PR's form made their PSOs on this card for both programs. The fast-fail on the 4090 / 3080 Ti with 621.24 (#680's open item 2) didn't show up here. These are two programs, not the title, so it narrows that item but doesn't close it. - With `XCL_HEAP_WINDOWS` unset, the HLSL and DXIL were byte-identical, as intended. With it set, there were no handle `phi`s and the readbacks matched, on a second NVIDIA generation. Your −8.8 % DXIL and −10 % first PSO on ResolveVBuffer (`4549529853faf5fd`) are close to what I saw on the 3050 (287 → 262 KB, 3.5 → 2.3 s, one run each, so noisier). This comment was AI-assisted.
Author
Owner

@⁠WebIdentity1 on GitHub · 2026-11-25 02:18 UTC · original · edited 2026-11-25 02:22 UTC

Prepared and tested a current-main integration of your existing two commits, preserving the #1992 null-T# reservation and #1998 expanded-window layout. This is an integration patch for your PR, not a competing implementation or a claim to fix the retail heap-window hang.

Base: cbc296ab65a2661a61e3e2da109134bcd5319f60. Source PR: dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94 (both c33782a and dd9f1ff). The original optimization and atomic64 feature gate remain yours.

The important integration detail is MEM_HEAP_NULL = MEM_HEAP_BASE + MAX_HEAP_WINDOWS, not MAX_WINDOWS. On current main those limits are 16 and 4 respectively. Preserve MEM_HEAP_BASE=4, put the null raw UAV at descriptor20 and start subsequent allocations at21. Keeping the old limit would clamp valid higher windows and place the null view on window4. The integration also preserves main's active/unused expanded-window checks and updates the mock's descriptor-call counts.

Tested — native Windows10 Home19045, Ryzen7800X3D, RTX3090 driver591.74, Rust/Cargo1.98.1MSVC, DXC/DXIL1.8.2502.11, debug; actual adapter printed. XCL_ADAPTER=3090, XCL_SPLIT_WAVE64=1.

cargo test --locked -p xcl --lib -- gpu_memory_windows_ gpu_heap_windows_reject_out_of_uma_aliasing window_views_do_not_hold_global_during_device_calls zero_tsharp_does_not_reach_window_views --test-threads=1 --show-output
  • XCL_DIRECT_DXIL=0: 8 passed / 0 failed / 0 ignored / 0 skipped.
  • XCL_DIRECT_DXIL=1: 8 / 0 / 0 / 0. Expanded tests call the direct translator explicitly, bypassing the fixture's old silent HLSL fallback above four windows.
  • Valid window7/15 scalar/buffer/global loads, stores and atomic results pass. Invalid-window reads return0, stores preserve canaries, and atomic/CAS-loop results terminate with0 for 2/4/8/16 layouts. The existing two-window switch controls and null-T#/descriptor-lock checks pass.
  • Focused HLSL negative control: same integration, changing only the emitter clamp limit back to4, gives 0 / 1 / 0 / 0 in gpu_memory_windows_beyond_the_root_uavs: window7 scalar read is (0,0) instead of (0xC0FFEE,0x1234). Descriptor capacity/placement stay correct in that control, avoiding an out-of-bounds descriptor-write experiment. This isolates clamping; it is not an execution of the old PR branch.

The high-window fixture reuses the previously published #1998 probe, adapted from XCL #822 (e9705bb, GPL-2.0-only; attribution retained). Your invalid-window helper now uses addresses beyond the selected layout, covers4/8/16, and passes the actual window count to both translators. Both322-file source manifests matched before/after and local snapshots; XCL rebuilt both sources. Patch reverse-application check passes.

Not tested — full workspace suite, retail smoke/hang, other GPUs, hardware without heap atomic64 support, current compile-time/memory gains, or byte-identical heap-disabled output against main. Direct DXIL retains its existing guarded accessors; its run checks compatibility with the changed shared descriptor layout. Existing performance reports remain tied to their original revisions. No source commit/push or new PR; original branches/worktrees preserved.

AI use — Codex (GPT-6) resolved this isolated integration, extended/reused the synthetic fixtures, ran the native comparisons and prepared the patch/report. The patch retains the existing PR's implementation and provenance.

Integration patch against cbc296a (existing PR plus compatibility edits and tests)
diff --git a/crates/xcl/src/gpu/recomp/emit.rs b/crates/xcl/src/gpu/recomp/emit.rs
index 8f257a0..8d0b729 100644
--- a/crates/xcl/src/gpu/recomp/emit.rs
+++ b/crates/xcl/src/gpu/recomp/emit.rs
@@ -5582,7 +5582,7 @@ fn windowed(h: &str, windows: u32, heap: Option<&str>) -> String {
 /// `default` (reads return 0, stores/atomics are dropped and zero their `out` parameter) so
 /// out-of-UMA pointers can never wrap onto live memory windows.
 /// `heap`: Some(storage class) – window k is taken from the descriptor heap
-/// (`Options::heap_windows`) and the same rule is one comparison before the access.
+/// (`Options::heap_windows`), and an out-of-range `xcl_w` takes the null view at `MEM_HEAP_NULL`.
 fn mem_accessors(windows: u32, heap: Option<&str>) -> String {
     let mut sigs: Vec<(&str, String, &str, &str, &str)> = vec![
         ("uint", "Load".into(), "uint a", "a", "return 0u;"),
@@ -5610,14 +5610,16 @@ fn mem_accessors(windows: u32, heap: Option<&str>) -> String {
     let mut s = String::new();
     if let Some(coherent) = heap {
         // one access: window k is descriptor MEM_HEAP_BASE + k; an `xcl_w` outside the windows
-        // does what the switch's `default` does
-        let _ = writeln!(s, "#define XCL_MW {coherent}RWByteAddressBuffer m = ResourceDescriptorHeap[NonUniformResourceIndex({}u + xcl_w)]", super::MEM_HEAP_BASE);
-        let _ = writeln!(s, "uint4 xcl_loadx4(uint4 a) {{ [branch] if (xcl_w >= {windows}u) {{ return uint4(0u, 0u, 0u, 0u); }} XCL_MW; return uint4(m.Load(a.x), m.Load(a.y), m.Load(a.z), m.Load(a.w)); }}");
-        for (ret, name, params, args, def) in sigs {
+        // takes the null view at MEM_HEAP_NULL, which does what the switch's `default` does. No
+        // branch: a guard gives each access two paths, DXC's GVN can join their handles into a
+        // `phi`, and NVIDIA refuses such programs at once with E_OUTOFMEMORY (#756).
+        let null = super::MEM_HEAP_NULL - super::MEM_HEAP_BASE;
+        let index = if windows >= null { format!("min(xcl_w, {null}u)") } else { format!("select(xcl_w < {windows}u, xcl_w, {null}u)") };
+        let _ = writeln!(s, "#define XCL_MW {coherent}RWByteAddressBuffer m = ResourceDescriptorHeap[NonUniformResourceIndex({}u + {index})]", super::MEM_HEAP_BASE);
+        let _ = writeln!(s, "uint4 xcl_loadx4(uint4 a) {{ XCL_MW; return uint4(m.Load(a.x), m.Load(a.y), m.Load(a.z), m.Load(a.w)); }}");
+        for (ret, name, params, args, _) in sigs {
             let r = if ret == "void" { "" } else { "return " };
-            // (the switch's `break` leaves the accessor)
-            let outside = def.replace("break;", "return;");
-            let _ = writeln!(s, "{ret} xcl_m{name}({params}) {{ [branch] if (xcl_w >= {windows}u) {{ {outside} }} XCL_MW; {r}m.{name}({args}); }}");
+            let _ = writeln!(s, "{ret} xcl_m{name}({params}) {{ XCL_MW; {r}m.{name}({args}); }}");
         }
         return s;
     }
diff --git a/crates/xcl/src/gpu/recomp/mod.rs b/crates/xcl/src/gpu/recomp/mod.rs
index d1e7d8b..3da939d 100644
--- a/crates/xcl/src/gpu/recomp/mod.rs
+++ b/crates/xcl/src/gpu/recomp/mod.rs
@@ -79,6 +79,10 @@ mod heap_window_tests;
 /// (`console_heap::null_views`).
 pub const MEM_HEAP_BASE: u32 = 4;
 
+/// The null raw UAV after the windows' views: an `xcl_w` outside the windows takes it (reads 0,
+/// stores and atomics dropped, atomics return 0: the switch's `default`).
+pub const MEM_HEAP_NULL: u32 = MEM_HEAP_BASE + crate::gpu::uma::MAX_HEAP_WINDOWS as u32;
+
 /// Flag in a memory-windows count (`pso::mem_windows`, the translation caches' keys):
 /// `Options::heap_windows`. `translate` takes it out of `mem_windows`.
 pub const HEAP_WINDOWS: u32 = 0x100;
@@ -519,8 +523,8 @@ pub struct Options {
     /// every access from the high address bits
     pub mem_windows: u32,
     /// with `mem_windows` > 1: reach window k through descriptor `MEM_HEAP_BASE + k` of the
-    /// shader-visible heap (a raw UAV of the window, `ResourceDescriptorHeap`) – one access per
-    /// site instead of a `switch` over the root UAVs `mem`, `mem1`.., which inlines every
+    /// shader-visible heap (a raw UAV of the window, `ResourceDescriptorHeap`; `MEM_HEAP_NULL`
+    /// outside the windows) – one access per site, with no branch, instead of a `switch` over the root UAVs `mem`, `mem1`.., which inlines every
     /// access once per window (HANDOFF: twice the DXC + driver time with 4 windows)
     pub heap_windows: bool,
     /// structured control flow when the program allows it (false, or `XCL_RECOMP_NO_STRUCTURED`:
diff --git a/crates/xcl/src/gpu/recomp/pso.rs b/crates/xcl/src/gpu/recomp/pso.rs
index b6dd120..31c2e17 100644
--- a/crates/xcl/src/gpu/recomp/pso.rs
+++ b/crates/xcl/src/gpu/recomp/pso.rs
@@ -105,7 +105,7 @@ pub fn in_switch_form<R>(f: impl FnOnce() -> R) -> R {
 }
 
 /// Whether translated shaders reach the memory windows through the shared descriptor heap
-/// (`Options::heap_windows`; descriptors `MEM_HEAP_BASE`.. made by `console_heap::set_window_views`)
+/// (`Options::heap_windows`; descriptors `MEM_HEAP_BASE`..=`MEM_HEAP_NULL` made by `console_heap::set_window_views`)
 /// instead of a `switch` over root UAVs. Opt-in: on with `XCL_HEAP_WINDOWS=1`, unless the views
 /// could not be made (no shared heap: then the switch, as before). Off by default: two NVIDIA
 /// setups failed with it (the driver's compiler ending the process; a device removal when the
diff --git a/crates/xcl/src/gpu/recomp/runner.rs b/crates/xcl/src/gpu/recomp/runner.rs
index ed68335..5c20dcf 100644
--- a/crates/xcl/src/gpu/recomp/runner.rs
+++ b/crates/xcl/src/gpu/recomp/runner.rs
@@ -1528,7 +1528,7 @@ fn run_in_region(dxil: &[u8], state: &KernelState, arena: &Arena) -> Result<Kern
         let dh: ID3D12DescriptorHeap = dev
             .CreateDescriptorHeap(&D3D12_DESCRIPTOR_HEAP_DESC {
                 Type: D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
-                NumDescriptors: super::MEM_HEAP_BASE + win_count as u32,
+                NumDescriptors: super::MEM_HEAP_NULL + 1,
                 Flags: D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE,
                 NodeMask: 0,
             })
@@ -1540,6 +1540,9 @@ fn run_in_region(dxil: &[u8], state: &KernelState, arena: &Arena) -> Result<Kern
             h.ptr += (super::MEM_HEAP_BASE as usize + k) * inc;
             dev.CreateUnorderedAccessView(b, None::<&ID3D12Resource>, Some(&raw_window_uav(size as u64)), h);
         }
+        let mut h = dh.GetCPUDescriptorHandleForHeapStart();
+        h.ptr += super::MEM_HEAP_NULL as usize * inc;
+        dev.CreateUnorderedAccessView(None::<&ID3D12Resource>, None::<&ID3D12Resource>, Some(&raw_window_uav(0)), h);
         list.SetDescriptorHeaps(&[Some(dh.clone())]);
         list.SetComputeRootSignature(&gpu.rs);
         list.SetComputeRootUnorderedAccessView(0, io_buf.GetGPUVirtualAddress());
@@ -1692,7 +1695,7 @@ fn dispatch_with(
         let dh: ID3D12DescriptorHeap = dev
             .CreateDescriptorHeap(&D3D12_DESCRIPTOR_HEAP_DESC {
                 Type: D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV,
-                NumDescriptors: super::MEM_HEAP_BASE + win_count as u32,
+                NumDescriptors: super::MEM_HEAP_NULL + 1,
                 Flags: D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE,
                 NodeMask: 0,
             })
@@ -1703,6 +1706,9 @@ fn dispatch_with(
             h.ptr += (super::MEM_HEAP_BASE as usize + k) * inc;
             dev.CreateUnorderedAccessView(&mem_buf, None::<&ID3D12Resource>, Some(&raw_window_uav(mem_bytes)), h);
         }
+        let mut h = dh.GetCPUDescriptorHandleForHeapStart();
+        h.ptr += super::MEM_HEAP_NULL as usize * inc;
+        dev.CreateUnorderedAccessView(None::<&ID3D12Resource>, None::<&ID3D12Resource>, Some(&raw_window_uav(0)), h);
         list.SetDescriptorHeaps(&[Some(dh.clone()), Some(bound._heaps[1].clone())]);
         list.SetComputeRootSignature(rs);
         list.SetComputeRootUnorderedAccessView(0, io_buf.GetGPUVirtualAddress());
diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs
index 527dc4e..2a56083 100644
--- a/crates/xcl/src/gpu/recomp/tests.rs
+++ b/crates/xcl/src/gpu/recomp/tests.rs
@@ -3808,23 +3808,32 @@ fn gpu_mesh_mode_reads_memory_windows() {
 /// accesses in window 0.
 #[test]
 fn gpu_memory_windows_above_4_gib() {
-    memory_windows_above_4_gib(false);
+    memory_windows_above_4_gib(2, false);
 }
 
 /// The same program with the windows taken from the descriptor heap (`Options::heap_windows`):
 /// same results, and no `switch` over windows in the HLSL.
 #[test]
 fn gpu_memory_windows_from_the_heap() {
-    memory_windows_above_4_gib(true);
+    memory_windows_above_4_gib(2, true);
 }
 
-fn memory_windows_above_4_gib(heap: bool) {
+// Adapted from XCL PR #822, e9705bb (GPL-2.0-only):
+// https://github.com/xcl-dev/xcl/pull/822. Also check 8 windows and explicit Direct DXIL.
+#[test]
+fn gpu_memory_windows_beyond_the_root_uavs() {
+    for windows in [8, 16] {
+        memory_windows_above_4_gib(windows, true);
+    }
+}
+
+fn memory_windows_above_4_gib(windows: usize, heap: bool) {
     if !gpu_ready() {
         return;
     }
-    let arena = crate::gpu::uma::Uma::with_windows(2, 1 << 20).unwrap();
-    let (w0, w1) = (arena.window(0).0 as u64, arena.window(1).0 as u64);
-    assert_eq!(w1 - w0, 1 << 32);
+    let arena = crate::gpu::uma::Uma::with_windows(windows, 1 << 20).unwrap();
+    let (w0, w1) = (arena.window(0).0 as u64, arena.window(windows - 1).0 as u64);
+    assert_eq!(w1 - w0, ((windows - 1) as u64) << 32);
     let word = |a: u64| unsafe { &mut *(a as *mut u32) };
     *word(w1 + 0x1000) = 0xC0FFEE;
     *word(w1 + 0x1004) = 0x1234;
@@ -3849,12 +3858,19 @@ fn memory_windows_above_4_gib(heap: bool) {
     let p = prog(&refs);
     let one = translate(&p, &Options::default()).unwrap();
     assert!(!one.hlsl.contains("mem1") && !one.hlsl.contains("xcl_w =") && !one.hlsl.contains("xcl_m"), "one window: the single-window HLSL");
-    let t = translate(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() })).unwrap();
+    let t = translate(&p, &on_gpu(Options { mem_windows: windows as u32, heap_windows: heap, ..Default::default() })).unwrap();
     assert!(t.hlsl.contains("RWByteAddressBuffer mem1 : register(u3)"));
     assert_eq!(t.hlsl.contains("switch (xcl_w)"), !heap, "heap windows: no switch over windows");
-    assert_eq!(t.hlsl.contains("ResourceDescriptorHeap[NonUniformResourceIndex(4u + xcl_w)]"), heap);
     let hlsl_dxil = || super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).map_err(|e| format!("{e}\n{}", t.hlsl)).unwrap();
-    let dxil = direct_or(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() }), hlsl_dxil());
+    let dxil = if windows > 4 && runner::direct_dxil() {
+        // direct_or intentionally falls back above four windows: do not count that as DXIL coverage.
+        crate::gpu::dxil::kernel::translate(&p, crate::gpu::dxil::kernel::KernelOptions {
+            wave64: true, split: runner::split_wave64(),
+            mem_windows: windows as u32 | super::HEAP_WINDOWS, sampler_base: 0,
+        }).expect("expanded direct DXIL")
+    } else {
+        direct_or(&p, &on_gpu(Options { mem_windows: windows as u32, heap_windows: heap, ..Default::default() }), hlsl_dxil())
+    };
     let hi = |a: u64| (a >> 32) as u32;
     let mut st = KernelState::default();
     st.sgpr[2..4].copy_from_slice(&[(w1 + 0x1000) as u32, hi(w1)]);
@@ -3883,6 +3899,13 @@ fn memory_windows_above_4_gib(heap: bool) {
     }
     assert_eq!(*word(w1 + 0x6000), 64, "global_atomic_add in window 1");
     assert_eq!(*word(w0 + 0x6000), 0, "nothing in window 0 at the same low address");
+    if heap {
+        let null = super::MEM_HEAP_NULL - super::MEM_HEAP_BASE;
+        let index = if windows as u32 >= null { format!("min(xcl_w, {null}u)") } else { format!("select(xcl_w < {windows}u, xcl_w, {null}u)") };
+        assert!(t.hlsl.contains(&format!("ResourceDescriptorHeap[NonUniformResourceIndex({}u + {index})]", super::MEM_HEAP_BASE)));
+        assert!(!t.hlsl.contains("if (xcl_w"), "heap windows: no branch around an access");
+    }
+    println!("{windows} windows, target {}, direct={}: scalar/buffer/global loads, stores and atomic output correct", windows - 1, runner::direct_dxil());
 }
 
 /// Out-of-UMA addresses must NEVER alias onto live UMA windows via `& 3`:
@@ -3895,24 +3918,31 @@ fn memory_windows_above_4_gib(heap: bool) {
 ///   on `global_load`/`global_store` updates the target window accurately.
 #[test]
 fn gpu_memory_windows_reject_out_of_uma_aliasing() {
-    memory_windows_reject_out_of_uma_aliasing(false);
+    memory_windows_reject_out_of_uma_aliasing(false, 2);
 }
 
 /// The same with the windows taken from the descriptor heap (`Options::heap_windows`): an
 /// address outside them reads 0 and drops its stores and atomics there too.
 #[test]
 fn gpu_heap_windows_reject_out_of_uma_aliasing() {
-    memory_windows_reject_out_of_uma_aliasing(true);
+    memory_windows_reject_out_of_uma_aliasing(true, 2);
+}
+
+/// Cover partial and complete expanded layouts; the full layout uses the min-index path.
+#[test]
+fn gpu_heap_windows_reject_out_of_uma_aliasing_all_slots() {
+    for windows in [4, 8, 16] { memory_windows_reject_out_of_uma_aliasing(true, windows); }
 }
 
-fn memory_windows_reject_out_of_uma_aliasing(heap: bool) {
+fn memory_windows_reject_out_of_uma_aliasing(heap: bool, windows: u32) {
     if !gpu_ready() {
         return;
     }
-    let arena = crate::gpu::uma::Uma::with_windows(2, 1 << 20).unwrap();
+    let arena = crate::gpu::uma::Uma::with_windows(windows as usize, 1 << 20).unwrap();
     let (w0, w1) = (arena.window(0).0 as u64, arena.window(1).0 as u64);
     assert_eq!(w1 - w0, 1 << 32);
     let base_hi = (w0 >> 32) as u32;
+    let outside = windows.max(4);
     assert!(base_hi >= 4);
     let word = |a: u64| unsafe { &mut *(a as *mut u32) };
 
@@ -3933,24 +3963,24 @@ fn memory_windows_reject_out_of_uma_aliasing(heap: bool) {
         (n, "ENC_FLAT_GLBL", f.iter().map(|&(a, b)| (unsafe { std::mem::transmute::<&str, &'static str>(a) }, b)).collect(), None)
     };
     let list = vec![
-        // 1. Out-of-UMA s_load from hi = base_hi + 4 (would alias w0 under `& 3`) -> must read 0
+        // 1. Out-of-UMA s_load from hi = base_hi + outside (would alias w0 under `& 3`) -> must read 0
         ("S_LOAD_DWORD", "ENC_SMEM", vec![("SDATA", 30), ("SBASE", 1), ("OFFSET", 0)], None), // s[2:3]
         // 2. 32-bit hi == 0 s_load at offset 0x4000 -> MUST read w0 + 0x4000
         ("S_LOAD_DWORD", "ENC_SMEM", vec![("SDATA", 31), ("SBASE", 2), ("OFFSET", 0)], None), // s[4:5]
-        // 3. Out-of-UMA buffer_store with V# hi = base_hi + 5 and stride = 4 -> must NOT touch w1 + 0x1000
+        // 3. Out-of-UMA buffer_store with V# hi = base_hi + outside + 1 and stride = 4 -> must NOT touch w1 + 0x1000
         ("BUFFER_STORE_DWORD", "ENC_MUBUF", vec![("VDATA", 1), ("VADDR", 0), ("SRSRC", 2), ("SOFFSET", 128), ("IDXEN", 1)], None), // s[8:11]
-        // 4. Out-of-UMA buffer_load with V# hi = base_hi + 5 and stride = 4 -> must read 0 (v2)
+        // 4. Out-of-UMA buffer_load with V# hi = base_hi + outside + 1 and stride = 4 -> must read 0 (v2)
         ("BUFFER_LOAD_DWORD", "ENC_MUBUF", vec![("VDATA", 2), ("VADDR", 0), ("SRSRC", 2), ("SOFFSET", 128), ("IDXEN", 1)], None),
         // 5. Valid strided V# buffer_load from w1 + 0x5000 (d1 has non-zero stride 4 in bits 29:16) -> must read 0x5566_7788 (v3)
         ("BUFFER_LOAD_DWORD", "ENC_MUBUF", vec![("VDATA", 3), ("VADDR", 0), ("SRSRC", 3), ("SOFFSET", 128), ("IDXEN", 1)], None), // s[12:15]
-        // 6. Out-of-UMA global_store with hi = base_hi + 4 (would alias w0 + 0x1000) -> dropped
+        // 6. Out-of-UMA global_store with hi = base_hi + outside (would alias w0 + 0x1000) -> dropped
         glbl("GLOBAL_STORE_DWORD", &[("ADDR", 4), ("DATA", 1), ("SADDR", 0x7D), ("OFFSET", 0)]),
         // 7. Out-of-UMA global_store with hi = 0 (null/32-bit pointer at 0x2000) -> dropped, must NOT touch w0 + 0x2000
         glbl("GLOBAL_STORE_DWORD", &[("ADDR", 6), ("DATA", 1), ("SADDR", 0x7D), ("OFFSET", 0)]),
-        // 8. Out-of-UMA global_atomic_add (hi = base_hi + 5) & global_atomic_inc CAS loop (hi = 0xFFFF_FFFF) -> dropped & terminates cleanly
+        // 8. Out-of-UMA global_atomic_add (hi = base_hi + outside + 1) & global_atomic_inc CAS loop (hi = 0xFFFF_FFFF) -> dropped & terminates cleanly
         glbl("GLOBAL_ATOMIC_ADD", &[("VDST", 10), ("ADDR", 8), ("DATA", 1), ("SADDR", 0x7D), ("OFFSET", 0), ("GLC", 1)]),
         glbl("GLOBAL_ATOMIC_INC", &[("VDST", 11), ("ADDR", 12), ("DATA", 1), ("SADDR", 0x7D), ("OFFSET", 0), ("GLC", 1)]),
-        // 9. Out-of-UMA buffer_atomic_add with V# hi = base_hi + 4 (would alias w0 + 0x3000) -> dropped
+        // 9. Out-of-UMA buffer_atomic_add with V# hi = base_hi + outside (would alias w0 + 0x3000) -> dropped
         ("BUFFER_ATOMIC_ADD", "ENC_MUBUF", vec![("VDATA", 14), ("VADDR", 0), ("SRSRC", 4), ("SOFFSET", 128), ("IDXEN", 1), ("GLC", 1)], None), // s[16:19]
         // 10. 64-bit carry on global_load: s[20:21] = (w0 + 0xFFFF_FFF0) + v16 (0x20) -> w1 + 0x10 -> must read 0x99AA_BBCC (v17)
         glbl("GLOBAL_LOAD_DWORD", &[("VDST", 17), ("ADDR", 16), ("SADDR", 20), ("OFFSET", 0)]),
@@ -3959,17 +3989,23 @@ fn memory_windows_reject_out_of_uma_aliasing(heap: bool) {
     ];
     let refs: Vec<(&str, &str, &[(&str, u64)], Option<u32>)> = list.iter().map(|(a, b, c, d)| (*a, *b, c.as_slice(), *d)).collect();
     let p = prog(&refs);
-    let t = translate(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() })).unwrap();
+    let t = translate(&p, &on_gpu(Options { mem_windows: windows, heap_windows: heap, ..Default::default() })).unwrap();
     assert_eq!(t.hlsl.contains("switch (xcl_w)"), !heap);
     let hlsl_dxil = super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).map_err(|e| format!("{e}\n{}", t.hlsl)).unwrap();
-    let dxil = direct_or(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() }), hlsl_dxil);
+    let dxil = if windows > 4 && runner::direct_dxil() {
+        crate::gpu::dxil::kernel::translate(&p, crate::gpu::dxil::kernel::KernelOptions {
+            wave64: true, split: runner::split_wave64(), mem_windows: windows | super::HEAP_WINDOWS, sampler_base: 0,
+        }).expect("expanded direct DXIL")
+    } else {
+        direct_or(&p, &on_gpu(Options { mem_windows: windows, heap_windows: heap, ..Default::default() }), hlsl_dxil)
+    };
 
     let mut st = KernelState::default();
-    st.sgpr[2..4].copy_from_slice(&[0x1000, base_hi + 4]); // s[2:3]: out-of-UMA hi = base_hi + 4
+    st.sgpr[2..4].copy_from_slice(&[0x1000, base_hi + outside]); // s[2:3]: out-of-UMA hi = base_hi + outside
     st.sgpr[4..6].copy_from_slice(&[0x4000, 0]); // s[4:5]: hi == 0 32-bit descriptor read
-    st.sgpr[8..12].copy_from_slice(&[0x1000, ((base_hi + 5) & 0xFFFF) | (4 << 16), 64, 0]); // out-of-UMA V# (aliases w1 under & 3)
+    st.sgpr[8..12].copy_from_slice(&[0x1000, ((base_hi + outside + 1) & 0xFFFF) | (4 << 16), 64, 0]); // out-of-UMA V# (aliases w1 under & 3)
     st.sgpr[12..16].copy_from_slice(&[0x5000, ((base_hi + 1) & 0xFFFF) | (4 << 16), 64, 0]); // valid strided V# in w1
-    st.sgpr[16..20].copy_from_slice(&[0x3000, ((base_hi + 4) & 0xFFFF) | (4 << 16), 64, 0]); // out-of-UMA atomic V# (aliases w0 under & 3)
+    st.sgpr[16..20].copy_from_slice(&[0x3000, ((base_hi + outside) & 0xFFFF) | (4 << 16), 64, 0]); // out-of-UMA atomic V# (aliases w0 under & 3)
     st.sgpr[20..22].copy_from_slice(&[0xFFFF_FFF0, base_hi]); // carry base
     st.sgpr[22..24].copy_from_slice(&[0, base_hi]); // borrow base (0 - 16 borrows into base_hi - 1)
     for r in st.vgpr.iter_mut() {
@@ -3980,11 +4016,11 @@ fn memory_windows_reject_out_of_uma_aliasing(heap: bool) {
         r[11] = 0x7777_7777;
         r[14] = 0xBAD0_DEAD;
         r[4] = 0x1000;
-        r[5] = base_hi + 4; // out-of-UMA global_store (aliases w0 under & 3)
+        r[5] = base_hi + outside; // out-of-UMA global_store (aliases w0 under & 3)
         r[6] = 0x2000;
         r[7] = 0; // hi == 0 global_store (null pointer -> must be dropped)
         r[8] = 0x2000;
-        r[9] = base_hi + 5; // out-of-UMA global_atomic_add (aliases w1 under & 3)
+        r[9] = base_hi + outside + 1; // out-of-UMA global_atomic_add (aliases w1 under & 3)
         r[12] = 0x3000;
         r[13] = 0xFFFF_FFFF; // out-of-UMA global_atomic_inc CAS loop
         r[16] = 0x20; // carry offset: 0xFFFF_FFF0 + 0x20 = 0x1_0000_0010 -> w1 + 0x10
@@ -4008,6 +4044,7 @@ fn memory_windows_reject_out_of_uma_aliasing(heap: bool) {
     assert_eq!(*word(w1 + 0x2000), CANARY1, "out-of-UMA global_atomic_add must not clobber w1");
     assert_eq!(*word(w0 + 0x3000), CANARY0, "out-of-UMA buffer_atomic_add must not clobber w0");
     assert_eq!(*word(w1 + 0x3000), CANARY1, "out-of-UMA global_atomic_inc must not clobber w1");
+    println!("INVALID windows={windows} heap={heap} adapter={} checks passed", runner::adapter().unwrap());
 }
 
 /// The start-up check of the coherent UMA windows (`real::check_uma_import`): the GPU sees what
diff --git a/crates/xcl/src/hle/d3d12x/console_heap.rs b/crates/xcl/src/hle/d3d12x/console_heap.rs
index 14d4f36..248a198 100644
--- a/crates/xcl/src/hle/d3d12x/console_heap.rs
+++ b/crates/xcl/src/hle/d3d12x/console_heap.rs
@@ -167,8 +167,9 @@ pub unsafe fn shared_heap(dev: &ID3D12Device) -> bool {
             inc: dev.GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV),
             heap,
             cap,
-            // the memory windows' raw UAVs (`set_window_views`) come first
-            next: crate::gpu::recomp::MEM_HEAP_BASE + crate::gpu::uma::MAX_HEAP_WINDOWS as u32,
+            // the memory windows' raw UAVs and the null view after them (`set_window_views`)
+            // come first
+            next: crate::gpu::recomp::MEM_HEAP_NULL + 1,
             free: Vec::new(),
         });
     }
@@ -212,10 +213,11 @@ pub fn window_views_failed() -> bool {
 /// shared heap, made now if need be (`Options::heap_windows`: shaders take window k from there).
 /// Active windows (`bytes > 0`) in wider layouts (8 / 16) must all have a valid buffer; unused
 /// trailing slots (`(0, 0)`) safely alias window 0's buffer.
-pub unsafe fn set_window_views(dev: &ID3D12Device, windows: &[(usize, usize)]) -> bool {
+/// `MEM_HEAP_NULL` after the windows is a null view; heap views require 64-bit atomics.
+pub unsafe fn set_window_views(dev: &ID3D12Device, windows: &[(usize, usize)], atomics64: bool) -> bool {
     let count = windows.len().max(crate::gpu::uma::MAX_WINDOWS);
     let complete = count <= crate::gpu::uma::MAX_WINDOWS || windows.iter().all(|&(raw, bytes)| raw != 0 || bytes == 0);
-    let ok = count <= crate::gpu::uma::MAX_HEAP_WINDOWS && complete && windows.first().is_some_and(|w| w.0 != 0) && shared_heap(dev) && {
+    let ok = atomics64 && count <= crate::gpu::uma::MAX_HEAP_WINDOWS && complete && windows.first().is_some_and(|w| w.0 != 0) && shared_heap(dev) && {
         let (device, cpu, inc) = {
             let g = GLOBAL.lock().unwrap();
             let s = g.as_ref().unwrap();
@@ -229,11 +231,13 @@ pub unsafe fn set_window_views(dev: &ID3D12Device, windows: &[(usize, usize)]) -
             let at = D3D12_CPU_DESCRIPTOR_HANDLE { ptr: (cpu + (crate::gpu::recomp::MEM_HEAP_BASE as u64 + k as u64) * inc as u64) as usize };
             device.CreateUnorderedAccessView(r, None::<&ID3D12Resource>, Some(&crate::gpu::recomp::runner::raw_window_uav(bytes as u64)), at);
         }
+        let at = D3D12_CPU_DESCRIPTOR_HANDLE { ptr: (cpu + crate::gpu::recomp::MEM_HEAP_NULL as u64 * inc as u64) as usize };
+        device.CreateUnorderedAccessView(None::<&ID3D12Resource>, None::<&ID3D12Resource>, Some(&crate::gpu::recomp::runner::raw_window_uav(0)), at);
         true
     };
     if !ok {
         WINDOW_VIEWS_FAILED.store(true, std::sync::atomic::Ordering::Relaxed);
-        crate::xlog_warn!("memory windows: could not bind {count} window(s) in the shared descriptor heap");
+        crate::xlog_warn!("memory windows: could not bind {count} window(s) (64-bit atomics on heap views: {atomics64}) in the shared descriptor heap");
     }
     ok
 }
@@ -654,21 +658,21 @@ mod tests {
                 dev: dev.clone(),
                 heap: ID3D12DescriptorHeap::from_raw(&mut heap as *mut _ as *mut c_void),
                 cpu: 0x1000, gpu: 0x2000, inc: 32, cap: 1024,
-                next: crate::gpu::recomp::MEM_HEAP_BASE + crate::gpu::uma::MAX_HEAP_WINDOWS as u32, free: Vec::new(),
+                next: crate::gpu::recomp::MEM_HEAP_NULL + 1, free: Vec::new(),
             });
             let window = (&mut resource as *mut _ as usize, 0x10000);
-            assert!(set_window_views(&dev, &[window]));
-            assert_eq!(CALLS.swap(0, Ordering::Relaxed), crate::gpu::uma::MAX_WINDOWS as u32);
+            assert!(set_window_views(&dev, &[window], true));
+            assert_eq!(CALLS.swap(0, Ordering::Relaxed), crate::gpu::uma::MAX_WINDOWS as u32 + 1);
             let mut windows = [window; crate::gpu::uma::MAX_HEAP_WINDOWS];
-            assert!(set_window_views(&dev, &windows));
-            assert_eq!(CALLS.swap(0, Ordering::Relaxed), windows.len() as u32);
+            assert!(set_window_views(&dev, &windows, true));
+            assert_eq!(CALLS.swap(0, Ordering::Relaxed), windows.len() as u32 + 1);
             // Unused trailing window `(0, 0)` safely aliases window 0; an active window that failed
             // to open `(0, bytes > 0)` is rejected.
             windows[7] = (0, 0);
-            assert!(set_window_views(&dev, &windows));
-            assert_eq!(CALLS.swap(0, Ordering::Relaxed), windows.len() as u32);
+            assert!(set_window_views(&dev, &windows, true));
+            assert_eq!(CALLS.swap(0, Ordering::Relaxed), windows.len() as u32 + 1);
             windows[7] = (0, 0x10000);
-            assert!(!set_window_views(&dev, &windows));
+            assert!(!set_window_views(&dev, &windows, true));
             assert_eq!(CALLS.load(Ordering::Relaxed), 0);
             assert!(UNLOCKED.load(Ordering::Relaxed), "device callback ran while GLOBAL was locked");
             *GLOBAL.lock().unwrap() = None;
diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs
index 9241a3a..88b52ea 100644
--- a/crates/xcl/src/hle/d3d12x/real.rs
+++ b/crates/xcl/src/hle/d3d12x/real.rs
@@ -370,7 +370,9 @@ unsafe fn open_uma(device: &ID3D12Device) {
     // shaders take the windows from the shared descriptor heap (`pso::heap_windows`)
     if n > 1 && crate::gpu::recomp::pso::heap_windows() {
         let views: Vec<(usize, usize)> = bufs.iter().enumerate().map(|(k, b)| (b.0, u.window(k).1)).collect();
-        if super::console_heap::set_window_views(device, &views) {
+        let mut o11 = D3D12_FEATURE_DATA_D3D12_OPTIONS11::default();
+        let atomics64 = device.CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS11, &mut o11 as *mut _ as *mut c_void, std::mem::size_of_val(&o11) as u32).is_ok() && o11.AtomicInt64OnDescriptorHeapResourceSupported.as_bool();
+        if super::console_heap::set_window_views(device, &views, atomics64) {
             crate::xlog_info!("D3D12.X: memory windows from the shared descriptor heap (no per-access switch)");
         }
     }
**@⁠WebIdentity1** on GitHub · 2026-11-25 02:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7150554948) · edited 2026-11-25 02:22 UTC Prepared and tested a current-main integration of your existing two commits, preserving the #1992 null-T# reservation and #1998 expanded-window layout. **This is an integration patch for your PR, not a competing implementation or a claim to fix the retail heap-window hang.** Base: `cbc296ab65a2661a61e3e2da109134bcd5319f60`. Source PR: `dd9f1ff1ffcfa2fb4998c3d181fd70e1510f0f94` (both `c33782a` and `dd9f1ff`). The original optimization and atomic64 feature gate remain yours. The important integration detail is `MEM_HEAP_NULL = MEM_HEAP_BASE + MAX_HEAP_WINDOWS`, **not `MAX_WINDOWS`**. On current main those limits are 16 and 4 respectively. Preserve `MEM_HEAP_BASE=4`, put the null raw UAV at descriptor20 and start subsequent allocations at21. Keeping the old limit would clamp valid higher windows and place the null view on window4. The integration also preserves main's active/unused expanded-window checks and updates the mock's descriptor-call counts. **Tested** — native Windows10 Home19045, Ryzen7800X3D, RTX3090 driver591.74, Rust/Cargo1.98.1MSVC, DXC/DXIL1.8.2502.11, debug; actual adapter printed. `XCL_ADAPTER=3090`, `XCL_SPLIT_WAVE64=1`. ```text cargo test --locked -p xcl --lib -- gpu_memory_windows_ gpu_heap_windows_reject_out_of_uma_aliasing window_views_do_not_hold_global_during_device_calls zero_tsharp_does_not_reach_window_views --test-threads=1 --show-output ``` - `XCL_DIRECT_DXIL=0`: **8 passed / 0 failed / 0 ignored / 0 skipped**. - `XCL_DIRECT_DXIL=1`: **8 / 0 / 0 / 0**. Expanded tests call the direct translator explicitly, bypassing the fixture's old silent HLSL fallback above four windows. - Valid window7/15 scalar/buffer/global loads, stores and atomic results pass. Invalid-window reads return0, stores preserve canaries, and atomic/CAS-loop results terminate with0 for 2/4/8/16 layouts. The existing two-window switch controls and null-T#/descriptor-lock checks pass. - Focused HLSL negative control: same integration, changing **only the emitter clamp limit back to4**, gives **0 / 1 / 0 / 0** in `gpu_memory_windows_beyond_the_root_uavs`: window7 scalar read is `(0,0)` instead of `(0xC0FFEE,0x1234)`. Descriptor capacity/placement stay correct in that control, avoiding an out-of-bounds descriptor-write experiment. This isolates clamping; it is **not** an execution of the old PR branch. The high-window fixture reuses the previously published #1998 probe, adapted from XCL #822 (`e9705bb`, GPL-2.0-only; attribution retained). Your invalid-window helper now uses addresses beyond the selected layout, covers4/8/16, and passes the actual window count to both translators. Both322-file source manifests matched before/after and local snapshots; XCL rebuilt both sources. Patch reverse-application check passes. **Not tested** — full workspace suite, retail smoke/hang, other GPUs, hardware without heap atomic64 support, current compile-time/memory gains, or byte-identical heap-disabled output against main. Direct DXIL retains its existing guarded accessors; its run checks compatibility with the changed shared descriptor layout. Existing performance reports remain tied to their original revisions. No source commit/push or new PR; original branches/worktrees preserved. **AI use** — Codex (GPT-6) resolved this isolated integration, extended/reused the synthetic fixtures, ran the native comparisons and prepared the patch/report. The patch retains the existing PR's implementation and provenance. <details><summary>Integration patch against cbc296a (existing PR plus compatibility edits and tests)</summary> ```diff diff --git a/crates/xcl/src/gpu/recomp/emit.rs b/crates/xcl/src/gpu/recomp/emit.rs index 8f257a0..8d0b729 100644 --- a/crates/xcl/src/gpu/recomp/emit.rs +++ b/crates/xcl/src/gpu/recomp/emit.rs @@ -5582,7 +5582,7 @@ fn windowed(h: &str, windows: u32, heap: Option<&str>) -> String { /// `default` (reads return 0, stores/atomics are dropped and zero their `out` parameter) so /// out-of-UMA pointers can never wrap onto live memory windows. /// `heap`: Some(storage class) – window k is taken from the descriptor heap -/// (`Options::heap_windows`) and the same rule is one comparison before the access. +/// (`Options::heap_windows`), and an out-of-range `xcl_w` takes the null view at `MEM_HEAP_NULL`. fn mem_accessors(windows: u32, heap: Option<&str>) -> String { let mut sigs: Vec<(&str, String, &str, &str, &str)> = vec![ ("uint", "Load".into(), "uint a", "a", "return 0u;"), @@ -5610,14 +5610,16 @@ fn mem_accessors(windows: u32, heap: Option<&str>) -> String { let mut s = String::new(); if let Some(coherent) = heap { // one access: window k is descriptor MEM_HEAP_BASE + k; an `xcl_w` outside the windows - // does what the switch's `default` does - let _ = writeln!(s, "#define XCL_MW {coherent}RWByteAddressBuffer m = ResourceDescriptorHeap[NonUniformResourceIndex({}u + xcl_w)]", super::MEM_HEAP_BASE); - let _ = writeln!(s, "uint4 xcl_loadx4(uint4 a) {{ [branch] if (xcl_w >= {windows}u) {{ return uint4(0u, 0u, 0u, 0u); }} XCL_MW; return uint4(m.Load(a.x), m.Load(a.y), m.Load(a.z), m.Load(a.w)); }}"); - for (ret, name, params, args, def) in sigs { + // takes the null view at MEM_HEAP_NULL, which does what the switch's `default` does. No + // branch: a guard gives each access two paths, DXC's GVN can join their handles into a + // `phi`, and NVIDIA refuses such programs at once with E_OUTOFMEMORY (#756). + let null = super::MEM_HEAP_NULL - super::MEM_HEAP_BASE; + let index = if windows >= null { format!("min(xcl_w, {null}u)") } else { format!("select(xcl_w < {windows}u, xcl_w, {null}u)") }; + let _ = writeln!(s, "#define XCL_MW {coherent}RWByteAddressBuffer m = ResourceDescriptorHeap[NonUniformResourceIndex({}u + {index})]", super::MEM_HEAP_BASE); + let _ = writeln!(s, "uint4 xcl_loadx4(uint4 a) {{ XCL_MW; return uint4(m.Load(a.x), m.Load(a.y), m.Load(a.z), m.Load(a.w)); }}"); + for (ret, name, params, args, _) in sigs { let r = if ret == "void" { "" } else { "return " }; - // (the switch's `break` leaves the accessor) - let outside = def.replace("break;", "return;"); - let _ = writeln!(s, "{ret} xcl_m{name}({params}) {{ [branch] if (xcl_w >= {windows}u) {{ {outside} }} XCL_MW; {r}m.{name}({args}); }}"); + let _ = writeln!(s, "{ret} xcl_m{name}({params}) {{ XCL_MW; {r}m.{name}({args}); }}"); } return s; } diff --git a/crates/xcl/src/gpu/recomp/mod.rs b/crates/xcl/src/gpu/recomp/mod.rs index d1e7d8b..3da939d 100644 --- a/crates/xcl/src/gpu/recomp/mod.rs +++ b/crates/xcl/src/gpu/recomp/mod.rs @@ -79,6 +79,10 @@ mod heap_window_tests; /// (`console_heap::null_views`). pub const MEM_HEAP_BASE: u32 = 4; +/// The null raw UAV after the windows' views: an `xcl_w` outside the windows takes it (reads 0, +/// stores and atomics dropped, atomics return 0: the switch's `default`). +pub const MEM_HEAP_NULL: u32 = MEM_HEAP_BASE + crate::gpu::uma::MAX_HEAP_WINDOWS as u32; + /// Flag in a memory-windows count (`pso::mem_windows`, the translation caches' keys): /// `Options::heap_windows`. `translate` takes it out of `mem_windows`. pub const HEAP_WINDOWS: u32 = 0x100; @@ -519,8 +523,8 @@ pub struct Options { /// every access from the high address bits pub mem_windows: u32, /// with `mem_windows` > 1: reach window k through descriptor `MEM_HEAP_BASE + k` of the - /// shader-visible heap (a raw UAV of the window, `ResourceDescriptorHeap`) – one access per - /// site instead of a `switch` over the root UAVs `mem`, `mem1`.., which inlines every + /// shader-visible heap (a raw UAV of the window, `ResourceDescriptorHeap`; `MEM_HEAP_NULL` + /// outside the windows) – one access per site, with no branch, instead of a `switch` over the root UAVs `mem`, `mem1`.., which inlines every /// access once per window (HANDOFF: twice the DXC + driver time with 4 windows) pub heap_windows: bool, /// structured control flow when the program allows it (false, or `XCL_RECOMP_NO_STRUCTURED`: diff --git a/crates/xcl/src/gpu/recomp/pso.rs b/crates/xcl/src/gpu/recomp/pso.rs index b6dd120..31c2e17 100644 --- a/crates/xcl/src/gpu/recomp/pso.rs +++ b/crates/xcl/src/gpu/recomp/pso.rs @@ -105,7 +105,7 @@ pub fn in_switch_form<R>(f: impl FnOnce() -> R) -> R { } /// Whether translated shaders reach the memory windows through the shared descriptor heap -/// (`Options::heap_windows`; descriptors `MEM_HEAP_BASE`.. made by `console_heap::set_window_views`) +/// (`Options::heap_windows`; descriptors `MEM_HEAP_BASE`..=`MEM_HEAP_NULL` made by `console_heap::set_window_views`) /// instead of a `switch` over root UAVs. Opt-in: on with `XCL_HEAP_WINDOWS=1`, unless the views /// could not be made (no shared heap: then the switch, as before). Off by default: two NVIDIA /// setups failed with it (the driver's compiler ending the process; a device removal when the diff --git a/crates/xcl/src/gpu/recomp/runner.rs b/crates/xcl/src/gpu/recomp/runner.rs index ed68335..5c20dcf 100644 --- a/crates/xcl/src/gpu/recomp/runner.rs +++ b/crates/xcl/src/gpu/recomp/runner.rs @@ -1528,7 +1528,7 @@ fn run_in_region(dxil: &[u8], state: &KernelState, arena: &Arena) -> Result<Kern let dh: ID3D12DescriptorHeap = dev .CreateDescriptorHeap(&D3D12_DESCRIPTOR_HEAP_DESC { Type: D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, - NumDescriptors: super::MEM_HEAP_BASE + win_count as u32, + NumDescriptors: super::MEM_HEAP_NULL + 1, Flags: D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, NodeMask: 0, }) @@ -1540,6 +1540,9 @@ fn run_in_region(dxil: &[u8], state: &KernelState, arena: &Arena) -> Result<Kern h.ptr += (super::MEM_HEAP_BASE as usize + k) * inc; dev.CreateUnorderedAccessView(b, None::<&ID3D12Resource>, Some(&raw_window_uav(size as u64)), h); } + let mut h = dh.GetCPUDescriptorHandleForHeapStart(); + h.ptr += super::MEM_HEAP_NULL as usize * inc; + dev.CreateUnorderedAccessView(None::<&ID3D12Resource>, None::<&ID3D12Resource>, Some(&raw_window_uav(0)), h); list.SetDescriptorHeaps(&[Some(dh.clone())]); list.SetComputeRootSignature(&gpu.rs); list.SetComputeRootUnorderedAccessView(0, io_buf.GetGPUVirtualAddress()); @@ -1692,7 +1695,7 @@ fn dispatch_with( let dh: ID3D12DescriptorHeap = dev .CreateDescriptorHeap(&D3D12_DESCRIPTOR_HEAP_DESC { Type: D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV, - NumDescriptors: super::MEM_HEAP_BASE + win_count as u32, + NumDescriptors: super::MEM_HEAP_NULL + 1, Flags: D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE, NodeMask: 0, }) @@ -1703,6 +1706,9 @@ fn dispatch_with( h.ptr += (super::MEM_HEAP_BASE as usize + k) * inc; dev.CreateUnorderedAccessView(&mem_buf, None::<&ID3D12Resource>, Some(&raw_window_uav(mem_bytes)), h); } + let mut h = dh.GetCPUDescriptorHandleForHeapStart(); + h.ptr += super::MEM_HEAP_NULL as usize * inc; + dev.CreateUnorderedAccessView(None::<&ID3D12Resource>, None::<&ID3D12Resource>, Some(&raw_window_uav(0)), h); list.SetDescriptorHeaps(&[Some(dh.clone()), Some(bound._heaps[1].clone())]); list.SetComputeRootSignature(rs); list.SetComputeRootUnorderedAccessView(0, io_buf.GetGPUVirtualAddress()); diff --git a/crates/xcl/src/gpu/recomp/tests.rs b/crates/xcl/src/gpu/recomp/tests.rs index 527dc4e..2a56083 100644 --- a/crates/xcl/src/gpu/recomp/tests.rs +++ b/crates/xcl/src/gpu/recomp/tests.rs @@ -3808,23 +3808,32 @@ fn gpu_mesh_mode_reads_memory_windows() { /// accesses in window 0. #[test] fn gpu_memory_windows_above_4_gib() { - memory_windows_above_4_gib(false); + memory_windows_above_4_gib(2, false); } /// The same program with the windows taken from the descriptor heap (`Options::heap_windows`): /// same results, and no `switch` over windows in the HLSL. #[test] fn gpu_memory_windows_from_the_heap() { - memory_windows_above_4_gib(true); + memory_windows_above_4_gib(2, true); } -fn memory_windows_above_4_gib(heap: bool) { +// Adapted from XCL PR #822, e9705bb (GPL-2.0-only): +// https://github.com/xcl-dev/xcl/pull/822. Also check 8 windows and explicit Direct DXIL. +#[test] +fn gpu_memory_windows_beyond_the_root_uavs() { + for windows in [8, 16] { + memory_windows_above_4_gib(windows, true); + } +} + +fn memory_windows_above_4_gib(windows: usize, heap: bool) { if !gpu_ready() { return; } - let arena = crate::gpu::uma::Uma::with_windows(2, 1 << 20).unwrap(); - let (w0, w1) = (arena.window(0).0 as u64, arena.window(1).0 as u64); - assert_eq!(w1 - w0, 1 << 32); + let arena = crate::gpu::uma::Uma::with_windows(windows, 1 << 20).unwrap(); + let (w0, w1) = (arena.window(0).0 as u64, arena.window(windows - 1).0 as u64); + assert_eq!(w1 - w0, ((windows - 1) as u64) << 32); let word = |a: u64| unsafe { &mut *(a as *mut u32) }; *word(w1 + 0x1000) = 0xC0FFEE; *word(w1 + 0x1004) = 0x1234; @@ -3849,12 +3858,19 @@ fn memory_windows_above_4_gib(heap: bool) { let p = prog(&refs); let one = translate(&p, &Options::default()).unwrap(); assert!(!one.hlsl.contains("mem1") && !one.hlsl.contains("xcl_w =") && !one.hlsl.contains("xcl_m"), "one window: the single-window HLSL"); - let t = translate(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() })).unwrap(); + let t = translate(&p, &on_gpu(Options { mem_windows: windows as u32, heap_windows: heap, ..Default::default() })).unwrap(); assert!(t.hlsl.contains("RWByteAddressBuffer mem1 : register(u3)")); assert_eq!(t.hlsl.contains("switch (xcl_w)"), !heap, "heap windows: no switch over windows"); - assert_eq!(t.hlsl.contains("ResourceDescriptorHeap[NonUniformResourceIndex(4u + xcl_w)]"), heap); let hlsl_dxil = || super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).map_err(|e| format!("{e}\n{}", t.hlsl)).unwrap(); - let dxil = direct_or(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() }), hlsl_dxil()); + let dxil = if windows > 4 && runner::direct_dxil() { + // direct_or intentionally falls back above four windows: do not count that as DXIL coverage. + crate::gpu::dxil::kernel::translate(&p, crate::gpu::dxil::kernel::KernelOptions { + wave64: true, split: runner::split_wave64(), + mem_windows: windows as u32 | super::HEAP_WINDOWS, sampler_base: 0, + }).expect("expanded direct DXIL") + } else { + direct_or(&p, &on_gpu(Options { mem_windows: windows as u32, heap_windows: heap, ..Default::default() }), hlsl_dxil()) + }; let hi = |a: u64| (a >> 32) as u32; let mut st = KernelState::default(); st.sgpr[2..4].copy_from_slice(&[(w1 + 0x1000) as u32, hi(w1)]); @@ -3883,6 +3899,13 @@ fn memory_windows_above_4_gib(heap: bool) { } assert_eq!(*word(w1 + 0x6000), 64, "global_atomic_add in window 1"); assert_eq!(*word(w0 + 0x6000), 0, "nothing in window 0 at the same low address"); + if heap { + let null = super::MEM_HEAP_NULL - super::MEM_HEAP_BASE; + let index = if windows as u32 >= null { format!("min(xcl_w, {null}u)") } else { format!("select(xcl_w < {windows}u, xcl_w, {null}u)") }; + assert!(t.hlsl.contains(&format!("ResourceDescriptorHeap[NonUniformResourceIndex({}u + {index})]", super::MEM_HEAP_BASE))); + assert!(!t.hlsl.contains("if (xcl_w"), "heap windows: no branch around an access"); + } + println!("{windows} windows, target {}, direct={}: scalar/buffer/global loads, stores and atomic output correct", windows - 1, runner::direct_dxil()); } /// Out-of-UMA addresses must NEVER alias onto live UMA windows via `& 3`: @@ -3895,24 +3918,31 @@ fn memory_windows_above_4_gib(heap: bool) { /// on `global_load`/`global_store` updates the target window accurately. #[test] fn gpu_memory_windows_reject_out_of_uma_aliasing() { - memory_windows_reject_out_of_uma_aliasing(false); + memory_windows_reject_out_of_uma_aliasing(false, 2); } /// The same with the windows taken from the descriptor heap (`Options::heap_windows`): an /// address outside them reads 0 and drops its stores and atomics there too. #[test] fn gpu_heap_windows_reject_out_of_uma_aliasing() { - memory_windows_reject_out_of_uma_aliasing(true); + memory_windows_reject_out_of_uma_aliasing(true, 2); +} + +/// Cover partial and complete expanded layouts; the full layout uses the min-index path. +#[test] +fn gpu_heap_windows_reject_out_of_uma_aliasing_all_slots() { + for windows in [4, 8, 16] { memory_windows_reject_out_of_uma_aliasing(true, windows); } } -fn memory_windows_reject_out_of_uma_aliasing(heap: bool) { +fn memory_windows_reject_out_of_uma_aliasing(heap: bool, windows: u32) { if !gpu_ready() { return; } - let arena = crate::gpu::uma::Uma::with_windows(2, 1 << 20).unwrap(); + let arena = crate::gpu::uma::Uma::with_windows(windows as usize, 1 << 20).unwrap(); let (w0, w1) = (arena.window(0).0 as u64, arena.window(1).0 as u64); assert_eq!(w1 - w0, 1 << 32); let base_hi = (w0 >> 32) as u32; + let outside = windows.max(4); assert!(base_hi >= 4); let word = |a: u64| unsafe { &mut *(a as *mut u32) }; @@ -3933,24 +3963,24 @@ fn memory_windows_reject_out_of_uma_aliasing(heap: bool) { (n, "ENC_FLAT_GLBL", f.iter().map(|&(a, b)| (unsafe { std::mem::transmute::<&str, &'static str>(a) }, b)).collect(), None) }; let list = vec![ - // 1. Out-of-UMA s_load from hi = base_hi + 4 (would alias w0 under `& 3`) -> must read 0 + // 1. Out-of-UMA s_load from hi = base_hi + outside (would alias w0 under `& 3`) -> must read 0 ("S_LOAD_DWORD", "ENC_SMEM", vec![("SDATA", 30), ("SBASE", 1), ("OFFSET", 0)], None), // s[2:3] // 2. 32-bit hi == 0 s_load at offset 0x4000 -> MUST read w0 + 0x4000 ("S_LOAD_DWORD", "ENC_SMEM", vec![("SDATA", 31), ("SBASE", 2), ("OFFSET", 0)], None), // s[4:5] - // 3. Out-of-UMA buffer_store with V# hi = base_hi + 5 and stride = 4 -> must NOT touch w1 + 0x1000 + // 3. Out-of-UMA buffer_store with V# hi = base_hi + outside + 1 and stride = 4 -> must NOT touch w1 + 0x1000 ("BUFFER_STORE_DWORD", "ENC_MUBUF", vec![("VDATA", 1), ("VADDR", 0), ("SRSRC", 2), ("SOFFSET", 128), ("IDXEN", 1)], None), // s[8:11] - // 4. Out-of-UMA buffer_load with V# hi = base_hi + 5 and stride = 4 -> must read 0 (v2) + // 4. Out-of-UMA buffer_load with V# hi = base_hi + outside + 1 and stride = 4 -> must read 0 (v2) ("BUFFER_LOAD_DWORD", "ENC_MUBUF", vec![("VDATA", 2), ("VADDR", 0), ("SRSRC", 2), ("SOFFSET", 128), ("IDXEN", 1)], None), // 5. Valid strided V# buffer_load from w1 + 0x5000 (d1 has non-zero stride 4 in bits 29:16) -> must read 0x5566_7788 (v3) ("BUFFER_LOAD_DWORD", "ENC_MUBUF", vec![("VDATA", 3), ("VADDR", 0), ("SRSRC", 3), ("SOFFSET", 128), ("IDXEN", 1)], None), // s[12:15] - // 6. Out-of-UMA global_store with hi = base_hi + 4 (would alias w0 + 0x1000) -> dropped + // 6. Out-of-UMA global_store with hi = base_hi + outside (would alias w0 + 0x1000) -> dropped glbl("GLOBAL_STORE_DWORD", &[("ADDR", 4), ("DATA", 1), ("SADDR", 0x7D), ("OFFSET", 0)]), // 7. Out-of-UMA global_store with hi = 0 (null/32-bit pointer at 0x2000) -> dropped, must NOT touch w0 + 0x2000 glbl("GLOBAL_STORE_DWORD", &[("ADDR", 6), ("DATA", 1), ("SADDR", 0x7D), ("OFFSET", 0)]), - // 8. Out-of-UMA global_atomic_add (hi = base_hi + 5) & global_atomic_inc CAS loop (hi = 0xFFFF_FFFF) -> dropped & terminates cleanly + // 8. Out-of-UMA global_atomic_add (hi = base_hi + outside + 1) & global_atomic_inc CAS loop (hi = 0xFFFF_FFFF) -> dropped & terminates cleanly glbl("GLOBAL_ATOMIC_ADD", &[("VDST", 10), ("ADDR", 8), ("DATA", 1), ("SADDR", 0x7D), ("OFFSET", 0), ("GLC", 1)]), glbl("GLOBAL_ATOMIC_INC", &[("VDST", 11), ("ADDR", 12), ("DATA", 1), ("SADDR", 0x7D), ("OFFSET", 0), ("GLC", 1)]), - // 9. Out-of-UMA buffer_atomic_add with V# hi = base_hi + 4 (would alias w0 + 0x3000) -> dropped + // 9. Out-of-UMA buffer_atomic_add with V# hi = base_hi + outside (would alias w0 + 0x3000) -> dropped ("BUFFER_ATOMIC_ADD", "ENC_MUBUF", vec![("VDATA", 14), ("VADDR", 0), ("SRSRC", 4), ("SOFFSET", 128), ("IDXEN", 1), ("GLC", 1)], None), // s[16:19] // 10. 64-bit carry on global_load: s[20:21] = (w0 + 0xFFFF_FFF0) + v16 (0x20) -> w1 + 0x10 -> must read 0x99AA_BBCC (v17) glbl("GLOBAL_LOAD_DWORD", &[("VDST", 17), ("ADDR", 16), ("SADDR", 20), ("OFFSET", 0)]), @@ -3959,17 +3989,23 @@ fn memory_windows_reject_out_of_uma_aliasing(heap: bool) { ]; let refs: Vec<(&str, &str, &[(&str, u64)], Option<u32>)> = list.iter().map(|(a, b, c, d)| (*a, *b, c.as_slice(), *d)).collect(); let p = prog(&refs); - let t = translate(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() })).unwrap(); + let t = translate(&p, &on_gpu(Options { mem_windows: windows, heap_windows: heap, ..Default::default() })).unwrap(); assert_eq!(t.hlsl.contains("switch (xcl_w)"), !heap); let hlsl_dxil = super::dxc::compile(&t.hlsl, "main", "cs_6_6", &[]).map_err(|e| format!("{e}\n{}", t.hlsl)).unwrap(); - let dxil = direct_or(&p, &on_gpu(Options { mem_windows: 2, heap_windows: heap, ..Default::default() }), hlsl_dxil); + let dxil = if windows > 4 && runner::direct_dxil() { + crate::gpu::dxil::kernel::translate(&p, crate::gpu::dxil::kernel::KernelOptions { + wave64: true, split: runner::split_wave64(), mem_windows: windows | super::HEAP_WINDOWS, sampler_base: 0, + }).expect("expanded direct DXIL") + } else { + direct_or(&p, &on_gpu(Options { mem_windows: windows, heap_windows: heap, ..Default::default() }), hlsl_dxil) + }; let mut st = KernelState::default(); - st.sgpr[2..4].copy_from_slice(&[0x1000, base_hi + 4]); // s[2:3]: out-of-UMA hi = base_hi + 4 + st.sgpr[2..4].copy_from_slice(&[0x1000, base_hi + outside]); // s[2:3]: out-of-UMA hi = base_hi + outside st.sgpr[4..6].copy_from_slice(&[0x4000, 0]); // s[4:5]: hi == 0 32-bit descriptor read - st.sgpr[8..12].copy_from_slice(&[0x1000, ((base_hi + 5) & 0xFFFF) | (4 << 16), 64, 0]); // out-of-UMA V# (aliases w1 under & 3) + st.sgpr[8..12].copy_from_slice(&[0x1000, ((base_hi + outside + 1) & 0xFFFF) | (4 << 16), 64, 0]); // out-of-UMA V# (aliases w1 under & 3) st.sgpr[12..16].copy_from_slice(&[0x5000, ((base_hi + 1) & 0xFFFF) | (4 << 16), 64, 0]); // valid strided V# in w1 - st.sgpr[16..20].copy_from_slice(&[0x3000, ((base_hi + 4) & 0xFFFF) | (4 << 16), 64, 0]); // out-of-UMA atomic V# (aliases w0 under & 3) + st.sgpr[16..20].copy_from_slice(&[0x3000, ((base_hi + outside) & 0xFFFF) | (4 << 16), 64, 0]); // out-of-UMA atomic V# (aliases w0 under & 3) st.sgpr[20..22].copy_from_slice(&[0xFFFF_FFF0, base_hi]); // carry base st.sgpr[22..24].copy_from_slice(&[0, base_hi]); // borrow base (0 - 16 borrows into base_hi - 1) for r in st.vgpr.iter_mut() { @@ -3980,11 +4016,11 @@ fn memory_windows_reject_out_of_uma_aliasing(heap: bool) { r[11] = 0x7777_7777; r[14] = 0xBAD0_DEAD; r[4] = 0x1000; - r[5] = base_hi + 4; // out-of-UMA global_store (aliases w0 under & 3) + r[5] = base_hi + outside; // out-of-UMA global_store (aliases w0 under & 3) r[6] = 0x2000; r[7] = 0; // hi == 0 global_store (null pointer -> must be dropped) r[8] = 0x2000; - r[9] = base_hi + 5; // out-of-UMA global_atomic_add (aliases w1 under & 3) + r[9] = base_hi + outside + 1; // out-of-UMA global_atomic_add (aliases w1 under & 3) r[12] = 0x3000; r[13] = 0xFFFF_FFFF; // out-of-UMA global_atomic_inc CAS loop r[16] = 0x20; // carry offset: 0xFFFF_FFF0 + 0x20 = 0x1_0000_0010 -> w1 + 0x10 @@ -4008,6 +4044,7 @@ fn memory_windows_reject_out_of_uma_aliasing(heap: bool) { assert_eq!(*word(w1 + 0x2000), CANARY1, "out-of-UMA global_atomic_add must not clobber w1"); assert_eq!(*word(w0 + 0x3000), CANARY0, "out-of-UMA buffer_atomic_add must not clobber w0"); assert_eq!(*word(w1 + 0x3000), CANARY1, "out-of-UMA global_atomic_inc must not clobber w1"); + println!("INVALID windows={windows} heap={heap} adapter={} checks passed", runner::adapter().unwrap()); } /// The start-up check of the coherent UMA windows (`real::check_uma_import`): the GPU sees what diff --git a/crates/xcl/src/hle/d3d12x/console_heap.rs b/crates/xcl/src/hle/d3d12x/console_heap.rs index 14d4f36..248a198 100644 --- a/crates/xcl/src/hle/d3d12x/console_heap.rs +++ b/crates/xcl/src/hle/d3d12x/console_heap.rs @@ -167,8 +167,9 @@ pub unsafe fn shared_heap(dev: &ID3D12Device) -> bool { inc: dev.GetDescriptorHandleIncrementSize(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV), heap, cap, - // the memory windows' raw UAVs (`set_window_views`) come first - next: crate::gpu::recomp::MEM_HEAP_BASE + crate::gpu::uma::MAX_HEAP_WINDOWS as u32, + // the memory windows' raw UAVs and the null view after them (`set_window_views`) + // come first + next: crate::gpu::recomp::MEM_HEAP_NULL + 1, free: Vec::new(), }); } @@ -212,10 +213,11 @@ pub fn window_views_failed() -> bool { /// shared heap, made now if need be (`Options::heap_windows`: shaders take window k from there). /// Active windows (`bytes > 0`) in wider layouts (8 / 16) must all have a valid buffer; unused /// trailing slots (`(0, 0)`) safely alias window 0's buffer. -pub unsafe fn set_window_views(dev: &ID3D12Device, windows: &[(usize, usize)]) -> bool { +/// `MEM_HEAP_NULL` after the windows is a null view; heap views require 64-bit atomics. +pub unsafe fn set_window_views(dev: &ID3D12Device, windows: &[(usize, usize)], atomics64: bool) -> bool { let count = windows.len().max(crate::gpu::uma::MAX_WINDOWS); let complete = count <= crate::gpu::uma::MAX_WINDOWS || windows.iter().all(|&(raw, bytes)| raw != 0 || bytes == 0); - let ok = count <= crate::gpu::uma::MAX_HEAP_WINDOWS && complete && windows.first().is_some_and(|w| w.0 != 0) && shared_heap(dev) && { + let ok = atomics64 && count <= crate::gpu::uma::MAX_HEAP_WINDOWS && complete && windows.first().is_some_and(|w| w.0 != 0) && shared_heap(dev) && { let (device, cpu, inc) = { let g = GLOBAL.lock().unwrap(); let s = g.as_ref().unwrap(); @@ -229,11 +231,13 @@ pub unsafe fn set_window_views(dev: &ID3D12Device, windows: &[(usize, usize)]) - let at = D3D12_CPU_DESCRIPTOR_HANDLE { ptr: (cpu + (crate::gpu::recomp::MEM_HEAP_BASE as u64 + k as u64) * inc as u64) as usize }; device.CreateUnorderedAccessView(r, None::<&ID3D12Resource>, Some(&crate::gpu::recomp::runner::raw_window_uav(bytes as u64)), at); } + let at = D3D12_CPU_DESCRIPTOR_HANDLE { ptr: (cpu + crate::gpu::recomp::MEM_HEAP_NULL as u64 * inc as u64) as usize }; + device.CreateUnorderedAccessView(None::<&ID3D12Resource>, None::<&ID3D12Resource>, Some(&crate::gpu::recomp::runner::raw_window_uav(0)), at); true }; if !ok { WINDOW_VIEWS_FAILED.store(true, std::sync::atomic::Ordering::Relaxed); - crate::xlog_warn!("memory windows: could not bind {count} window(s) in the shared descriptor heap"); + crate::xlog_warn!("memory windows: could not bind {count} window(s) (64-bit atomics on heap views: {atomics64}) in the shared descriptor heap"); } ok } @@ -654,21 +658,21 @@ mod tests { dev: dev.clone(), heap: ID3D12DescriptorHeap::from_raw(&mut heap as *mut _ as *mut c_void), cpu: 0x1000, gpu: 0x2000, inc: 32, cap: 1024, - next: crate::gpu::recomp::MEM_HEAP_BASE + crate::gpu::uma::MAX_HEAP_WINDOWS as u32, free: Vec::new(), + next: crate::gpu::recomp::MEM_HEAP_NULL + 1, free: Vec::new(), }); let window = (&mut resource as *mut _ as usize, 0x10000); - assert!(set_window_views(&dev, &[window])); - assert_eq!(CALLS.swap(0, Ordering::Relaxed), crate::gpu::uma::MAX_WINDOWS as u32); + assert!(set_window_views(&dev, &[window], true)); + assert_eq!(CALLS.swap(0, Ordering::Relaxed), crate::gpu::uma::MAX_WINDOWS as u32 + 1); let mut windows = [window; crate::gpu::uma::MAX_HEAP_WINDOWS]; - assert!(set_window_views(&dev, &windows)); - assert_eq!(CALLS.swap(0, Ordering::Relaxed), windows.len() as u32); + assert!(set_window_views(&dev, &windows, true)); + assert_eq!(CALLS.swap(0, Ordering::Relaxed), windows.len() as u32 + 1); // Unused trailing window `(0, 0)` safely aliases window 0; an active window that failed // to open `(0, bytes > 0)` is rejected. windows[7] = (0, 0); - assert!(set_window_views(&dev, &windows)); - assert_eq!(CALLS.swap(0, Ordering::Relaxed), windows.len() as u32); + assert!(set_window_views(&dev, &windows, true)); + assert_eq!(CALLS.swap(0, Ordering::Relaxed), windows.len() as u32 + 1); windows[7] = (0, 0x10000); - assert!(!set_window_views(&dev, &windows)); + assert!(!set_window_views(&dev, &windows, true)); assert_eq!(CALLS.load(Ordering::Relaxed), 0); assert!(UNLOCKED.load(Ordering::Relaxed), "device callback ran while GLOBAL was locked"); *GLOBAL.lock().unwrap() = None; diff --git a/crates/xcl/src/hle/d3d12x/real.rs b/crates/xcl/src/hle/d3d12x/real.rs index 9241a3a..88b52ea 100644 --- a/crates/xcl/src/hle/d3d12x/real.rs +++ b/crates/xcl/src/hle/d3d12x/real.rs @@ -370,7 +370,9 @@ unsafe fn open_uma(device: &ID3D12Device) { // shaders take the windows from the shared descriptor heap (`pso::heap_windows`) if n > 1 && crate::gpu::recomp::pso::heap_windows() { let views: Vec<(usize, usize)> = bufs.iter().enumerate().map(|(k, b)| (b.0, u.window(k).1)).collect(); - if super::console_heap::set_window_views(device, &views) { + let mut o11 = D3D12_FEATURE_DATA_D3D12_OPTIONS11::default(); + let atomics64 = device.CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS11, &mut o11 as *mut _ as *mut c_void, std::mem::size_of_val(&o11) as u32).is_ok() && o11.AtomicInt64OnDescriptorHeapResourceSupported.as_bool(); + if super::console_heap::set_window_views(device, &views, atomics64) { crate::xlog_info!("D3D12.X: memory windows from the shared descriptor heap (no per-access switch)"); } } ``` </details>
Author
Owner

@⁠brothernog on GitHub · 2026-11-25 04:21 UTC · original

@⁠Pipodi Thanks for running both trees under the same cap. ActivateRays hit 24 GB on its own in DXC, and the other two cases hit the cap during driver compilation. That gives us a useful baseline, but it doesn’t show a memory fix in this PR. I’d keep that investigation separate from the null-view change. AI-assisted draft.

**@⁠brothernog** on GitHub · 2026-11-25 04:21 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7152763530) @⁠Pipodi Thanks for running both trees under the same cap. ActivateRays hit 24 GB on its own in DXC, and the other two cases hit the cap during driver compilation. That gives us a useful baseline, but it doesn’t show a memory fix in this PR. I’d keep that investigation separate from the null-view change. AI-assisted draft.
Author
Owner

@⁠zohaiblazuli on GitHub · 2026-11-25 14:32 UTC · original

Cold build times of main's current heap form (1a0bbe3, with the guard) against the switch form, for 8 compute programs on an RTX 3060 (NVIDIA 617.42), driver caches off: #2088 comment.

  • 1.2–1.7 MB DXIL: 4.6–5.5× faster builds (63 → 14 s, 82 → 16 s, 136 → 25 s).
  • 5 MB outlier 219287eb2f6021fe: only 1.9× (819 → 434 s), while removing the window choice entirely (wrong results; an upper bound) gives 133 s.

If this PR's unguarded form is meant to narrow that gap, 219287eb2f6021fe is a program to show it on. I have not measured this PR's head, and I did not check the heap form's results, only its build time.

AI use: Claude Code (Claude Opus 5.5) ran the measurements and wrote this.

**@⁠zohaiblazuli** on GitHub · 2026-11-25 14:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7165434701) Cold build times of `main`'s current heap form (`1a0bbe3`, with the guard) against the switch form, for 8 compute programs on an RTX 3060 (NVIDIA 617.42), driver caches off: [#2088 comment](https://git.gtahub.st/github/xcl-dev--xcl/issues/2088). - 1.2–1.7 MB DXIL: 4.6–5.5× faster builds (63 → 14 s, 82 → 16 s, 136 → 25 s). - 5 MB outlier `219287eb2f6021fe`: only 1.9× (819 → 434 s), while removing the window choice entirely (wrong results; an upper bound) gives 133 s. If this PR's unguarded form is meant to narrow that gap, `219287eb2f6021fe` is a program to show it on. I have not measured this PR's head, and I did not check the heap form's results, only its build time. AI use: Claude Code (Claude Opus 5.5) ran the measurements and wrote this.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 06:07 UTC · original

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-26 06:07 UTC · [original](https://github.com/xcl-dev/xcl/pull/1695#issuecomment-7184122455) Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/gpu/recomp/emit.rs
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.
git fetch -u origin '+refs/pull/1695/head:github-bot/gh-1695'
git switch 'github-bot/gh-1695'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1695'
git switch 'github-bot/gh-1695'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1695'
git switch 'github-bot/gh-1695'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1695'
git switch 'main'
git merge --squash 'github-bot/gh-1695'
git switch 'main'
git merge --ff-only 'github-bot/gh-1695'
git switch 'main'
git merge 'github-bot/gh-1695'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.