Repository navigation
Direct DXIL: memory windows through the descriptor heap (XCL_HEAP_WINDOWS) - #1693
Merged
Merged
Conversation
…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>
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 Setup & tested configuration
Observed results
Not tested
|
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.
|
Tested commit Tested
Not tested
AI use
|
This was referenced Nov 24, 2026
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.
Contributor
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
Contributor
Author
|
Thanks @raylitebull (RX 9070 XT, 300 s, plus the 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.
coolpersonnn
added a commit
to coolpersonnn/xcl
that referenced
this pull request
Nov 25, 2026
In direct DXIL root-UAV window mode (`XCL_DIRECT_DXIL=1`, `XCL_HEAP_WINDOWS=0`), every scalar/buffer/flat read previously went through `with_mem_many_tys`, emitting a per-load `switch i32` + guard CFG and `phi` nodes over all 4 root-UAV windows (`u2..u5`). Compute shaders with hundreds of loads grew thousands of basic blocks, triggering multi-second to multi-minute cold NVIDIA driver compiles and high compiler commit memory. Replace multi-window direct DXIL read-only raw loads on non-graphics stages (`self.gfx.is_none()`, `self.heap_mem.is_none()`) with branchless straight-line loads via `with_mem_raw_loads`: - Resolve the effective window `w_eff = sel(guard, w, n)` once and compare `w_eff == k` across windows `0..n`, reading offset `0` on unselected windows/lanes and merging with `select`. - Preserve `xcl-dev#1693` semantics: out-of-range window indices and inactive lanes select `0` while emitting only valid offset-0 reads on bound windows. - Ensure `bind.rs` (`u2..u5`, filtering `v != 0`) and `runner::dispatch_with` always bind valid non-null buffers for all 4 root-UAV window slots. - Exclude graphics stages (`VS`/`PS`, `self.gfx.is_some()`), where flattening root-UAV loads regressed straight-line PS cold NVIDIA compile time by 5.64x (1,632 -> 9,203 ms on `0829441`). - Keep stores/atomics (`xcl-dev#2288`), `bvh_intersect`, `XCL_HEAP_WINDOWS` (`xcl-dev#1695`), and HLSL emission (`xcl-dev#1380`/`xcl-dev#2191`) unchanged. Measured on RTX 5090 (driver 621.01, Windows 11, release) against `3f4495a` (including PR xcl-dev#2346 non-coherent compute windows, 3 paired interleaved trials per spec with cold root-signature keys and fresh exe copies): - `cs-500-raw-w32` (non-coherent / coherent): 5,133 -> 1,748 ms (2.94x) / 5,129 -> 1,751 ms (2.93x); peak commit 309 -> 191 MiB - `cs-1000-raw-w32` (non-coherent / coherent): 19,742 -> 5,156 ms (3.83x) / 19,767 -> 5,132 ms (3.85x); peak commit 993 -> 259 MiB (-73.9%) - `cs-1000-raw-w64` (split wave64): 19,709 -> 5,171 ms (3.81x); peak 994 -> 259 MiB - `cs-1000-w32` (mixed w/ 33% FormatLoad, non-coherent / coherent): 49,431 -> 17,977 ms (2.75x) / 49,944 -> 18,058 ms (2.77x); peak 1.34 GiB -> 464 MiB - Synthetic GPU dispatch (128 loads/lane, uniform & mixed, w32 & split w64): 1.84x to 4.68x faster (3.296-6.688 us vs 9.696-22.608 us), 100% readback match. Assisted-by: T3 Code (gemini-pro-orchestrator-neon) Assisted-by: Codex in T3 Code (gpt-6.2-sol)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_WINDOWSin 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): windowwis aRWByteAddressBufferfromResourceDescriptorHeap[NonUniformResourceIndex(MEM_HEAP_BASE + w)](createHandleFromHeap+annotateHandle,globallycoherentin compute mode, like the root windows). It sits behind onew < windowscheck instead of a switch over the root UAVs u2... Awoutside the windows reads 0 and drops its stores and atomics, as the HLSLxcl_m*heap accessors do. All memory accesses (loads, stores, atomics including 64-bit and CAS loops, format and typed buffer loads, SMEM, BVH) go throughwith_mem, so they all use it. 64-bit atomics on heap handles setAtomicInt64Heap.window_read/window_write(gpu: direct RDNA2 -> DXIL backend (no HLSL / DXC), behind XCL_DIRECT_DXIL #1426 still usedhi & 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 withhi == 0goes 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_VERSIONgoes 4 → 5, so cached direct translations are rebuilt.lower_mem.rs/lower_image.rs(window(..)→window_at/buffer_window/flat_window(.., write)), oneheap_memfield inLw, andShader::heap_raw_buffer_uav.direct_orpassesHEAP_WINDOWSwhenOptions::heap_windowsis set.gpu_memory_windows_from_the_heap,gpu_heap_windows_reject_out_of_uma_aliasingandgpu_memory_windows_reject_out_of_uma_aliasingnow run through the direct path underXCL_DIRECT_DXILand are checked on the GPU. The 64-bit atomics test also validates the heap form.Tested
cargo test -p xcl --lib gpu::dxil: 80 passed, 0 failed, 1 ignored.cargo test -p xcl --lib gpu::recompwithXCL_DIRECT_DXIL=1and=all, each withXCL_HEAP_WINDOWS=0and=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_maskandgpu_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).memory_windows_above_4_gib5608 → 5328 B (−5 %).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:
PR:
Not tested
XCL_DIRECT_DXIL_STATS=1) and PSO build times in the title run.AI use
🤖 Generated with Claude Code