Skip to content

Direct DXIL: memory windows through the descriptor heap (XCL_HEAP_WINDOWS) - #1693

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
bmjask:dxil/heap-windows
Nov 24, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
bmjask:dxil/heap-windows

Conversation

@bmjask

@bmjask bmjask commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Follow-up to #1426.

The direct RDNA2→DXIL translator used to refuse programs that take their memory windows from the descriptor heap (XCL_HEAP_WINDOWS=1, recomp::HEAP_WINDOWS in the window count) and sent them to the HLSL path. With this PR it translates them.

What is in it

  • gpu/dxil/lower_window.rs (new file): window w is a RWByteAddressBuffer from ResourceDescriptorHeap[NonUniformResourceIndex(MEM_HEAP_BASE + w)] (createHandleFromHeap + annotateHandle, globallycoherent in compute mode, like the root windows). It sits behind one w < windows check instead of a switch over the root UAVs u2... A w outside the windows reads 0 and drops its stores and atomics, as the HLSL xcl_m* heap accessors do. All memory accesses (loads, stores, atomics including 64-bit and CAS loops, format and typed buffer loads, SMEM, BVH) go through with_mem, so they all use it. 64-bit atomics on heap handles set AtomicInt64Heap.
  • Window selection now matches the HLSL kernel's window_read / window_write (gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 still used hi & 3). The window comes from the 64-bit effective address (carry / borrow, V# stride bits masked) minus the UMA base (IO_UMA_BASE_HI). A read with hi == 0 goes to window 0; any other address outside the windows matches none. This applies to the root-UAV form too, so out-of-UMA pointers no longer alias a live window there either.
  • kernel.rs: the refusal is removed; mem_windows() builds the root or heap windows. TRANSLATOR_VERSION goes 4 → 5, so cached direct translations are rebuilt.
  • Small call-site edits in lower_mem.rs / lower_image.rs (window(..) → window_at / buffer_window / flat_window(.., write)), one heap_mem field in Lw, and Shader::heap_raw_buffer_uav.
  • Tests: direct_or passes HEAP_WINDOWS when Options::heap_windows is set. gpu_memory_windows_from_the_heap, gpu_heap_windows_reject_out_of_uma_aliasing and gpu_memory_windows_reject_out_of_uma_aliasing now run through the direct path under XCL_DIRECT_DXIL and are checked on the GPU. The 64-bit atomics test also validates the heap form.

Tested

  • RTX 4090, Windows 11 26200, rustc 1.100.0, debug tests / release smoke.
  • cargo test -p xcl --lib gpu::dxil: 80 passed, 0 failed, 1 ignored.
  • cargo test -p xcl --lib gpu::recomp with XCL_DIRECT_DXIL=1 and =all, each with XCL_HEAP_WINDOWS=0 and =1: 194 passed, 0 failed, 18 ignored in all four. The GPU window tests (gpu_memory_windows_*, gpu_heap_windows_reject_out_of_uma_aliasing, mesh, BVH64) ran on the GPU through the direct path, validator-clean.
  • cargo test --workspace -- --test-threads=4: 858 passed, 0 failed, 42 ignored (SKIPPED GPU tests: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware – no wave64 path on this adapter; heap_window_out_of_memory_falls_back_to_the_switch_form – no heap windows by default).
  • DXIL size, direct path, root vs heap form: memory_windows_above_4_gib 5608 → 5328 B (−5 %).
  • Title run with XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 (PR head, A pressed at 10/15/20/25/30/40 s, 60 s): 1454 frames shown (presents per 2 s at the end 43 46 40), 0 device removals, 0 crashes, peak commit 19441 MB. Fallback counts and PSO times were not collected.

Regression run
Both runs were back to back on a quiet machine, with XCL_PRESS_A_AT=10,15,20,25,30,40 (A pressed at those seconds).

main:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: NVIDIA GeForce RTX 4090
title: game
seconds: 60
exit: 0x0
frames shown: 1451 (PresentX 1451)
presents per 2 s (last 3): 40 39 14
device removals: 0
crashes: 0
peak commit: 21068 MB

PR:

xcl-smoke v1
commit: b5d63226df1fe6044e50054310109f96790b6a3f
gpu: NVIDIA GeForce RTX 4090
title: game
seconds: 60
exit: 0x0
frames shown: 1468 (PresentX 1468)
presents per 2 s (last 3): 42 47 19
device removals: 0
crashes: 0
peak commit: 20203 MB

Not tested

  • Direct-path fallback counts (XCL_DIRECT_DXIL_STATS=1) and PSO build times in the title run.
  • Heap windows on a GPU without wave64 / with only Shader Model 6.6 heap indexing limits other than the 4090's.

AI use

  • Claude Code (Claude Opus 5.5): wrote the implementation and tests, ran the tests and the smoke runs, and wrote this description.

🤖 Generated with Claude Code

…DOWS)

The direct translator no longer refuses heap windows: with recomp::HEAP_WINDOWS
in the window count, window w is a RWByteAddressBuffer from
ResourceDescriptorHeap[NonUniformResourceIndex(MEM_HEAP_BASE + w)]
(globallycoherent in compute mode, as the root windows), behind one bounds
check instead of a switch over u2.. root UAVs.

Window selection now matches the HLSL kernel's window_read / window_write:
the 64-bit effective address (carry / borrow, V# stride bits masked) minus
the UMA base; a read with hi == 0 goes to window 0; any other address outside
the windows reads 0 and drops its stores and atomics (root and heap form).

TRANSLATOR_VERSION 5. The heap-window GPU tests run through the direct path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@bmjask bmjask changed the title Direct DXIL: memory windows through the descriptor heap (XCL_HEAP_WIN… Direct DXIL: memory windows through the descriptor heap (XCL_HEAP_WINDOWS) Nov 24, 2026
@raylitebull
raylitebull merged commit 9039900 into xcl-dev:main Nov 24, 2026
2 of 3 checks passed
@raylitebull

Copy link
Copy Markdown
Member

Tested on Windows 11 with an AMD Radeon RX 9070 XT (16191 MiB VRAM, RDNA4, native wave64) on a local merge branch based on c160d86.

Setup & tested configuration

  • Local test branch: c160d86 + #1693 (b5d6322, merged cleanly with zero conflicts) + #1679 (ee85bc2) + #751, #1288, #1005, #1053, #1195, #1529, #1584, #1661 (release build).
  • Flags: XCL_DIRECT_DXIL=1, XCL_HEAP_WINDOWS=1, XCL_NETWORK=0, XCL_SKIP_BINK=1, XCL_MUTE_TTS=1 (300 s run on a newer retail title).

Observed results

  • Exit: 0x0 after full 300.00 s (0 crashes, 0 device removals, 0 OOMs).
  • Frames shown: 1,914 (PresentX 1914; 651 translated PSOs, 19,207 unique shaders).
  • Memory: 25,644 MB peak commit (11,926 MB working set, 13,065 MB process VRAM / 14,515 MB adapter VRAM, 8,791 MB target pages).
  • Streaming & visuals: 75,653 DirectStorage requests (4,201 MB streamed, 2,041 failed); captured 4K loading frames showed clean output with no visual corruption.
  • Merge note for maintainers: #1693 (b5d6322) and #1679 (ee85bc2) have a small 2-line overlap in crates/xcl/src/gpu/dxil/kernel.rs (keeping both || geo.is_some() and the mem_windows(...) call resolves cleanly).

Not tested

  • Cold-cache direct-DXIL shader compilation (dxil_cache logged 1,288 hits / 0 misses / 0 compilations on pre-warmed caches).
  • Standalone #1693 without #1679/bundle PRs, cargo test --workspace, NVIDIA/Intel GPUs, and 3D in-world frames past the 300 s loading carousel.

gefydev added a commit to gefydev/xcl that referenced this pull request Nov 24, 2026
xcl-dev#1693 put memory windows through the descriptor heap in xcl-dev#1426's lowering
(XCL_HEAP_WINDOWS), so compute_with no longer refuses them: with several
windows the per-lane form's memory instructions go through Lw, which
now reads the window from the heap.
@thiagocalile

Copy link
Copy Markdown

Tested commit b5d63226df1fe6044e50054310109f96790b6a3f 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::dxil -- --test-threads=4: 80 passed, 0 failed, 1 ignored (25.1s).
  • XCL_ADAPTER=radeon XCL_HEAP_WINDOWS=1 cargo test -p xcl --test gpu_compute_e2e -- --nocapture: 4 passed, 0 failed, 0 ignored (34.86s).
  • XCL_ADAPTER=radeon cargo test --workspace --no-fail-fast -- --test-threads=4: 855 passed, 3 failed, 42 ignored (37.83s).
    • 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 D3D12.X: map and unmap 3D texture mips separately #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.

gefydev added a commit to gefydev/xcl that referenced this pull request Nov 24, 2026
xcl-dev#1693 put memory windows through the descriptor heap in xcl-dev#1426's lowering
(XCL_HEAP_WINDOWS), so compute_with no longer refuses them: with several
windows the per-lane form's memory instructions go through Lw, which
now reads the window from the heap.
@DavidM1911

Copy link
Copy Markdown
Contributor

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

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

Thanks!

@bmjask

bmjask commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @raylitebull (RX 9070 XT, 300 s, plus the kernel.rs merge note with #1679) and @thiagocalile (RX 6600: gpu::dxil 80/0/1, gpu_compute_e2e with heap windows 4/0/0; the 3 workspace failures are the ones tracked in #1028).

AI use: Claude Code (Claude Opus 5.5) wrote this comment for @bmjask.

wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
…cl-dev#1288 Sleep hold, xcl-dev#1195 ExecuteIndirect skip)

Conflicts:
- tests.rs memory_windows_reject_out_of_uma_aliasing: xcl-dev#1693 builds the switch /
  heap form through direct_or (the direct translator with XCL_DIRECT_DXIL=1);
  the flat form of our flat window loads stays a DXC compile, as in
  gpu_sparse_vram_descriptors_buffers_and_xmem.
- pso_async.rs resolve_wait: xcl-dev#1288's `Held` guard (pso_async::title_held, which
  kernelx::Sleep does not count) goes into our resolve_wait_in after note_use, so it
  covers the bind's whole wait in every form: XCL_PSO_WAIT_MS /
  XCL_PSO_WAIT_MS_GRAPHICS budgets, XCL_PSO_SKIP_HUGE, a build on the binding thread.
  Its test calls our three-argument resolve_wait_for.

xcl-dev#1195 merged without conflict: in execute_indirect our skip of a pending stand-in or
a two-pass pipeline comes first, then xcl-dev#1195's skip of a Dispatch signature with an
untranslated console compute pipeline (a failed build's stand-in, the fallback of a
console shader that failed), which we sent to the PC call, then the PC-pipeline block
with 515b576's gpu_profile::end(.., breadcrumb). xcl-dev#1195's skip leaves a breadcrumb, as
our other ExecuteIndirect skips do.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants