D3D12.X: the T# index guard matches a 1,000,000-descriptor shared heap #2195
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2195
Loading…
Reference in a new issue
No description provided.
Delete branch "gh-pr/2195/head"
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?
@mgrein on GitHub · 2026-11-25 08:57 UTC · original
mgrein:heap-index-bound→main· +42 −15 · 4 files · 1 commits · merged 2026-11-25 10:49 UTCThe translated shaders accept a T# SRV index below 2^21 − 1 (the paired UAV is at
tw0 + 1), but the shared shader-visible view heap ismin(device limit, 2^21)descriptors – 1,000,000 on an RTX 4070, which reports no larger limit. An accepted index between the two reads past the heap's end. XCL writes only indices it reserved, but a T# the title wrote itself as raw console words passes the type andBASE_ADDRESS_HIchecks: its word 0 is the base address >> 8, so a texture at 256–512 MB gives 1–2 million. Another project running the same new retail game reports that reads past the heap's end hang NVIDIA GPUs (AMD forgives them).The shared heap is now 1,000,000 descriptors on every GPU (resource binding tier 2 and up take that many) and the guard is tied to it.
What is in it
crates/xcl/src/hle/d3d12x/console_heap.rs:GLOBAL_MAX= 1,000,000 (was 2^21), public; the heap size computation moves intoglobal_cap(), unchanged otherwise.crates/xcl/src/gpu/dxil/lower_image.rs:VIEW_HEAP_MAX_SRV = GLOBAL_MAX − 1(was(1 << 21) − 1); its tests compare against the constant.crates/xcl/src/gpu/recomp/emit.rs: the HLSL path's guard uses the same constant (was a literal2097151u).the_shaders_t_sharp_index_bound_fits_the_shared_heap(GPU): the bound against the shared heap this GPU gets. It fails without the change on the RTX 4070: "shaders accept indices up to 2097151, the shared heap holds 1000000".Tested
cargo test --workspace -- --test-threads=4at19bef42: 1155 passed, 0 failed, 46 ignored (21 test binaries). SKIPPED (25): 20 GPU subtests that need wave64, 3 wave32 per-lane f16 subtests oflower_dxil::tests(refused: unsupported f16 instructions),heap_window_out_of_memory_falls_back_to_the_switch_form(no heap windows),pso_measurement_compiles_an_exact_synthetic_record(Windows Developer Mode is off).Regression run
Same title for 100 s on each build, default settings, shader caches cold on both (the PR changes the translator).
main:
This PR:
Not tested
AI use
🤖 Generated with Claude Code
The translated shaders accept a T# SRV index below 2^21 - 1 (the UAV is at tw0 + 1), while the shared shader-visible heap is min(device limit, 2^21) descriptors: 1,000,000 on an RTX 4070. An index in between reads past the heap's end, which hangs NVIDIA GPUs. XCL writes only indices it reserved, but a T# the title wrote itself (raw console words: word 0 is the base address >> 8, so a texture at 256-512 MB gives 1-2 million) passes the type and BASE_ADDRESS_HI checks. The shared heap is now 1,000,000 descriptors on every GPU (resource binding tier 2+ takes that many) and the guard is tied to it: VIEW_HEAP_MAX_SRV = GLOBAL_MAX - 1 in the direct DXIL translator, the same constant in the HLSL path. global_cap() holds the heap size computation so a test can check it against the bound; on the RTX 4070 it fails with the old values ("shaders accept indices up to 2097151, the shared heap holds 1000000"). Co-Authored-By: Claude Opus 5.5 <[email protected]>@joeypercia on GitHub · 2026-11-25 10:39 UTC · original
In-title result on #2057, for the first point under Not tested: on an RTX 4070 Ti (12 GB) the world-load removal still happens with this PR. It came later in this run, but that's one run each.
Setup: RTX 4070 Ti 12 GB (driver 621.40), Ryzen 7 7800X3D, Windows 11 Pro 26200, release. Newer retail title 1.0.2.1, Series X profile.
XCL_DIRECT_DXIL=1 XCL_HEAP_WINDOWS=1 XCL_DRED=1, A presses scripted withXCL_PRESS_ATfrom 42 s.f7e08e6+741cb5a(the video-memory budget from #1773).19bef42, which applied cleanly.0x887a0005at 304 s0x887a0005at 463.6 s0x0, no allocations, none freedCS 1b5466f261a70cde, 1,033 ms for one dispatchCS b78fa10b425b8e54andCS 24de2aef6c31d55e, 1,581 ms and not finishedSo on this tree the removal at world load isn't (only) a read past the heap. The guard doesn't change the signature: DRED names no allocation, and long compute dispatches are still running when it comes.
Not checked: whether the title produces an index in the gap at all. I didn't log the T# words, and I ran nothing without the budget commit.
AI use
@raylitebull on GitHub · 2026-11-25 10:46 UTC · original
Code review on
19bef42:console_heap::GLOBAL_MAX(1_000_000) andlower_image::VIEW_HEAP_MAX_SRV(GLOBAL_MAX - 1) across both direct DXIL (lower_image.rs) and HLSL (emit.rs) eliminates the OOBResourceDescriptorHeapwindow (1_000_000..2_097_150) that caused hangs on 1M-descriptor GPUs, verified bythe_shaders_t_sharp_index_bound_fits_the_shared_heap.GLOBAL_MAXalso boundsglobal_cap()so every GPU's shared heap and shader guard share the exact same ceiling.Remaining before merge:
Build and testfinishing green plus dual-vendor (AMD + NVIDIA) verification on19bef42.@DarkPanda69 on GitHub · 2026-11-25 09:30 UTC · original · edited 2026-11-25 19:31 UTC
Correction:
the_shaders_t_sharp_index_bound_fits_the_shared_heapcreates its device withD3D12CreateDevice(None, ..), so it runs on DXGI adapter 0, which on this machine is the RX 9070 XT, whateverXCL_ADAPTERsays. Both runs of that test below were on the RX 9070 XT: the AMD result stands, but the RTX 3060 "heap tests 10 passed" line does not cover that test on the 3060. The per-cardgpu::counts are unaffected.AMD run (listed as untested) on an RDNA4 card, which is the Tier-3 case the guard's comment is about, plus the RTX 3060 for comparison. Nothing regresses with the lower bound compiled into the shaders.
Head
19bef42applied onmain568e7db, debug, Windows 11 Pro 26200,XCL_ADAPTERset to each card:cargo test -p xcl --lib -- console_heap heap_bounds: 10 passed, 0 failed, includingthe_shaders_t_sharp_index_bound_fits_the_shared_heap.cargo test -p xcl --lib -- gpu::: 584 passed, 2 failed, 22 ignored, 6 SKIPPED, the same counts as onmain. The 2 failures are the AMD fuzz seeds 722 and 1599 tracked in #2115.gpu::586 passed, 0 failed, 22 ignored.Not tested: this card's actual view-heap limit (I did not read OPTIONS19, so I can't say whether the shared heap gets smaller here), a title, Linux / Wine.
AI use: Claude Code (Claude Opus 5.5) ran the tests on this machine and wrote this report.