Repository navigation
Recompiler: an access outside the heap windows takes a null view, no branch - #1669
milesah3ad wants to merge 1 commit into
Conversation
…branch
With heap windows every memory access was `[branch] if (xcl_w >= windows)
{ <the switch's default> }` around the descriptor-heap access. The index is
now a select instead: `xcl_w < windows ? MEM_HEAP_BASE + xcl_w :
MEM_HEAP_NULL`, and MEM_HEAP_NULL (the descriptor after the MAX_WINDOWS
window views) is a null raw UAV. A null view's loads and atomics return 0
and its stores are dropped, which is what the switch form's `default` does,
so the out-of-UMA rule is unchanged; the null slot sits after all
MAX_WINDOWS views, so a program with fewer windows cannot reach a live
window's view through it.
brothernog measured this form on xcl-dev#680 against retail compute programs on an
RTX 3050: less driver time, and no handle `phi` on the programs NVIDIA
refused in xcl-dev#1269.
- emit.rs: the select and no branch in the heap accessors
- mod.rs: MEM_HEAP_NULL
- runner.rs: set_null_window_view; the test heaps hold it
- console_heap.rs: the shared heap reserves it and set_window_views makes it
- tests: the HLSL check expects the select and no branch; the window-views
test expects the null view after the windows
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YPhfiWsdJcDBLYSS8edLyS
|
Looking for a regression pair on the newer title. I don't have a title, so I can't make the @brothernog (your proposal on #680), @imnicho, @Anon64, @tiagonleal: you've each run the title with What would be most useful besides the blocks: whether any compute pipelines are refused ( AI use: Claude Code (Claude Opus 5.5) drafted this. I chose who to ask from the #680 test reports. |
|
RTX 3090 validation of exact head Tested
Not tested: retail AI use: Codex (GPT-6) ran the native tests, checked the logs and source hashes, and prepared this report. |
…g, DirectStorage, and stream tracking Cherry-picks upstream stabilization improvements across VRAM allocation, pipeline caching, DirectStorage lifetime, descriptor heap indexing, Media Foundation device bridging, and stream PSO tracking: - D3D12.X: reclaim cooling and idle tiles on pool heap OOM (xcl-dev#1663, addressing xcl-dev#1585 and xcl-dev#1668). When CreateHeap returns 0x8007000E (E_OUTOFMEMORY), Pages::take_tile waits on Pages::fence up to 1000 ms to drain cooling tiles or force-evict idle pages rather than failing immediately. (by Nikita Romanovich) - DirectStorage: close a queue when its last reference is released (xcl-dev#1675). Moves queue_close logic into QueueInner::close and invokes it when the final queue reference is released, preventing background workers from writing to freed caller buffers and marking pending entries complete with E_QUEUE_CLOSED. (by eizispark) - D3D12.X: a pipeline the driver gave up on is not built again (xcl-dev#1665). Persists driver E_OUTOFMEMORY refusal state into used-pipelines.txt (!<key>) so giant compute pipelines that the host driver refuses to compile are skipped on subsequent runs. (by zorde23) - Recompiler: access outside heap windows takes a null view without branching (xcl-dev#1669, xcl-dev#680). Replaces conditional branches in XCL_HEAP_WINDOWS=1 (if (xcl_w >= windows)) with a branchless select pointing out-of-bounds accesses to a dedicated null UAV view (MEM_HEAP_NULL). (by milesah3ad) - HLE: bridge ID3D12Device before direct ResetDevice and cache D3D11 companion (xcl-dev#1677). Fixes MFResetDXGIDeviceManagerX in mfplat.rs to bridge ID3D12Device COM pointers and caches multithreaded companion ID3D11Device instances per adapter LUID. (by eizispark) - D3D12.X: route stream graphics PSOs through create_graphics_pso_tracked (xcl-dev#1661, finding XCL-BT-023 from xcl-dev#1489). Ensures stream-created graphics PSOs receive D3D12_PIPELINE_STATE_FLAG_DYNAMIC_DEPTH_BIAS and are tracked in device_x::note_base for CreateDerivedPipelineStateX and RSSetDepthBiasX. (by fixgep) Assisted-by: Antigravity
|
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. |
|
Regression pair for Setup
Tests on
Regression run (retail title 1.0.2.1,
All 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 The blocks with main: PR: Debug layer (
Not tested
Claude Code (Claude Opus 5.5), from runs on the hardware above. |
|
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 AI use: Claude Code (Claude Opus 5.5) drafted this. |
|
Verification on RTX 3060 Ti (Windows 11), branch merged with current
Thanks! |
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 Recompiler: memory windows from the descriptor heap (no per-access switch) #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 [OFFICIAL] Looking for PRs with shaders optimization #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