Recompiler: an access outside the heap windows takes a null view, no branch #1659
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/1669"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from ivall/xcl. Originally posted by milesah3ad on 2026-11-24T19:04:12Z.
With heap windows (
XCL_HEAP_WINDOWS=1, #680), every memory access was[branch] if (xcl_w >= windows) { … }around its descriptor-heap access. This replaces the branch with a select of the descriptor:xcl_w < windows ? MEM_HEAP_BASE + xcl_w : MEM_HEAP_NULL.MEM_HEAP_NULLis a new null raw UAV, placed after allMAX_WINDOWSwindow views. A null view's loads and atomics return 0 and its stores are dropped, the same as the switch form'sdefault, so the out-of-UMA rule fromf9e5ee9stays as it is. The null slot comes after all four window slots, not atwindows, so a program with fewer windows can't reach a live window's view through it. (min(xcl_w, windows)would land on descriptor 2 for a 2-window program.)This is the form @brothernog proposed and measured on #680 with retail compute programs on an RTX 3050: less driver time (23.0 → 17.5 s on an 18.7k-instruction program), and no handle
phiin the programs NVIDIA refused in #1269. Default runs (heap windows off) don't reach the new HLSL. Part of #1269.What is in it (one commit)
gpu/recomp/emit.rs: the heap accessors index with the select and have no branchgpu/recomp/mod.rs:MEM_HEAP_NULL=MEM_HEAP_BASE + MAX_WINDOWSgpu/recomp/runner.rs:set_null_window_view; the two test heaps get one more descriptor and the null viewhle/d3d12x/console_heap.rs: the shared heap reserves the slot, andset_window_viewswrites the null view after the windowsmemory_windows_above_4_gibchecks for the select and for noif (xcl_w >=;window_views_do_not_hold_global_during_device_callsexpects one more device call, a null-resource view atMEM_HEAP_NULLTested
RTX 5080 16 GB, driver 621.24, wave32 (split wave64); Ryzen 7 9800X3D, 64 GB; Windows 11 Pro 26300; rustc 1.100.0 MSVC; DXC 1.9.2609.5; debug
On this head
daaa354(onmainc160d86),cargo test --workspace --no-fail-fast -- --test-threads=4:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows)XCL_HEAP_WINDOWS=1: 858 passed, 0 failed, 42 ignored. SKIPPED: the two wave64-only testsThe out-of-window semantics in the heap form go through the null view on the GPU in
gpu_heap_windows_reject_out_of_uma_aliasing: out-of-UMA loads return 0, GLC atomics (add, buffer add) return 0, theglobal_atomic_incCAS loop ends, and stores and atomics leave the canaries in both windows untouched.Driver time, synthetic programs (the
nv680generator from #680: 4 windows, split wave64, 5 shapes × 2 sizes × 2 seeds; each program translated three ways, then a coldCreateComputePipelineStatein its own process):main)v_readlane)The null view is faster on 4 of the 5 shapes (−2 to −16 % per program). It is slower on the 64-bit-atomic shape (+12 to +19 %, DXIL +5 %), where every round has a returning
UMAX_X2and every second round aCMPSWAP_X2. Retail programs are the better measure here, and @brothernog's are faster in this form. If 64-bit atomics turn out to matter, keeping the branch only for the 64-bit accessors would be a small follow-up.Regression run
scripts/smoke.ps1. Default runs don't reach the new HLSL (heap windows are opt-in), but the shared heap now reserves one more descriptor, so a run in both settings is still needed. @brothernog, or anyone running the newer title withXCL_HEAP_WINDOWS=1: a smoke pair would let this leave draft.main:
PR:
Not tested
phiNVIDIA refused in #1269 is gone for those programs (that's @brothernog's measurement, not mine)AI use
🤖 Generated with Claude Code
https://claude.ai/code/session_01YPhfiWsdJcDBLYSS8edLyS
Imported from ivall/xcl. Originally posted by milesah3ad on 2026-11-24T19:08:55Z.
Looking for a regression pair on the newer title. I don't have a title, so I can't make the
xcl-smokeblocks this needs.@brothernog (your proposal on #680), @imnicho, @Anon64, @tiagonleal: you've each run the title with
XCL_HEAP_WINDOWS=1since #680. If one of you has a few minutes,scripts/smoke.ps1built frommainc160d86and from this headdaaa354, both withXCL_HEAP_WINDOWS=1, would let this leave draft. A pair with it unset too would cover the extra reserved descriptor in default runs.What would be most useful besides the blocks: whether any compute pipelines are refused (
E_OUTOFMEMORY/ the switch-form fallback) with this head, and the longest compute PSO build, compared withmain.AI use: Claude Code (Claude Opus 5.5) drafted this. I chose who to ask from the #680 test reports.
Imported from ivall/xcl. Originally posted by WebIdentity1 on 2026-11-24T19:17:24Z.
RTX 3090 validation of exact head
daaa354f2eb4bcd17cbe3ab41650edecc755ea36against its parent/mainc160d86ef2efe3a07e4dfb473e4fa72eafb413c0, with heap windows enabled. The focused out-of-UMA GPU oracle passes on both, and the full workspace has the same result on both revisions. This adds Ampere coverage to the RTX 5080 results in the description.Tested
XCL_ADAPTER=3090,XCL_REQUIRE_GPU=mesh,XCL_HEAP_WINDOWS=1,XCL_DIRECT_DXILunset;XCL_SAMPLE_*unset. Focused tests in fresh SSH Session 0 processes; full suite in interactive desktop Session 1, four threads.cargo test --locked -p xcl --lib gpu_heap_windows_reject_out_of_uma_aliasing -- --test-threads=1 --show-output --nocapture: parent 1 passed / 0 failed / 0 ignored, head 1 / 0 / 0; no skip or timeout. It exercises the production heap path's out-of-UMA load/atomic/store behavior and checks the GPU canaries.cargo build --locked --workspace: exit 0 on both revisions.cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --show-output: parent 857 passed / 1 failed / 42 ignored; head 857 / 1 / 42. Both exit 101 with the same knowngpu_clamp_and_omod_per_instructionlane-0v_pk_add_i16 clampfailure (#202). No timeout. Counts sum all 20 test targets.gpu_geometry_wave32_prefix_count_over_a_mask,gpu_wave32_program_in_wave64_hardware), and the two debug-layer tests (test_title_draws_with_a_root_signature_under_the_debug_layer,uploads_start_from_each_subresources_state; system SDK Layers unavailable). They are not coverage. Some workspace fixtures select the default adapter themselves, so I do not claim that every full-suite test used the 3090.Not tested: retail
xcl-smokepair, the newer title, actual large-program driver compile times, AMD/Intel, debug-layer behavior, Wine, release build, or every generated heap-accessor shape. This supports the null-view semantics on Ampere but does not satisfy the retail gate or establish merge readiness.AI use: Codex (GPT-6) ran the native tests, checked the logs and source hashes, and prepared this report.
Imported from ivall/xcl. Originally posted by throny on 2026-11-24T20:15:48Z.
Two contributors checked independently and found that #1695 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.
Imported from ivall/xcl. Originally posted by srcamarda on 2026-11-24T20:30:08Z.
Regression pair for
daaa354on AMD RDNA3 (RX 7800 XT), retail title, with and withoutXCL_HEAP_WINDOWS=1; also under the debug layer into the world load: no regression, and no new debug-layer messages from the null viewSetup
daaa354and its parentmainc160d86, each built clean, no local changes.Tests on
daaa354,cargo build --workspace && cargo test --workspace --no-fail-fast -- --test-threads=4:SKIPPED:heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows).XCL_HEAP_WINDOWS=1: 858 passed, 0 failed, 42 ignored, noSKIPPED. This includesgpu_heap_windows_reject_out_of_uma_aliasingwith the null view on AMD, and the two wave64-only tests that skip on your card.Regression run (retail title 1.0.2.1,
scripts/smoke.ps1 -Seconds 60, no input, title screens; interleavedmain/ PR, two rounds per setting):mainc160d86daaa354XCL_HEAP_WINDOWS=1: frames shownXCL_HEAP_WINDOWS=1: peak commitAll eight runs: presents per 2 s (last 3) 60 60 60, no device removal, no crash. With heap windows the PR's run built its compute programs fresh, so the new HLSL was in use. Its DXIL sizes differ from
main's, and the first round compiled every program cold in the driver. That first round's lower frame count is that compile, not a steady-state drop.The blocks with
XCL_HEAP_WINDOWS=1(round 1):main:
PR:
Debug layer (
XCL_D3D12_DEBUG=1 XCL_HEAP_WINDOWS=1 XCL_NETWORK=0 XCL_RUN_SECONDS=150, Enter (= A) at 30 / 40 / 50 s, into the world load;main, PR, PR,main):main: crashed once at 130 s in the world load,0xc0000005inVCRUNTIME140.dll+0x1c11d(a read at0xdc4871000, a memcpy), and ran 150 s the second time (2 834 frames). One crash in two runs onmainand none on the PR says nothing about this change. I note it only because it is not the title's known+0x23cf683crash (#534).Not tested
main's heap-form programs came from my driver cache of earlier runs, so I have no comparable numbers.phiNVIDIA refused in #1269 is gone (no NVIDIA here); Wine / vkd3d-proton; Intel.Claude Code (Claude Opus 5.5), from runs on the hardware above.
Imported from ivall/xcl. Originally posted by milesah3ad on 2026-11-24T20:32:06Z.
Closing in favour of #1695: the same null-view approach, from @brothernog, who proposed it on #680, plus the check for 64-bit atomics on heap views, and it already has its smoke pair and several test reports.
Thanks @srcamarda and @WebIdentity1. Your reports tested the null view itself, so they carry over to #1695: the AMD RX 7800 XT smoke pair with and without
XCL_HEAP_WINDOWS=1, the debug-layer runs into the world load with no new message ids, and the RTX 3090 suite and out-of-UMA oracle. I've linked them there.AI use: Claude Code (Claude Opus 5.5) drafted this.
Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T21:26:33Z.
Verification on RTX 3060 Ti (Windows 11), branch merged with current
main:cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored.Thanks!
Pull request closed