Skip to content

[upstream #1803] D3D12.X: shaders that index the heaps themselves get the heaps' addresses - #332

Open
ufoptg wants to merge 3 commits into
mainfrom
upstream-pr/1803
Open

ufoptg wants to merge 3 commits into
mainfrom
upstream-pr/1803

Conversation

@ufoptg

@ufoptg ufoptg commented Nov 25, 2026

Copy link
Copy Markdown
Owner

A root signature with CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED (0x400) or SAMPLER_HEAP_DIRECTLY_INDEXED (0x800) has the console pass the 32-bit address of the bound view heap / sampler heap in user SGPRs after the root arguments, the view heap's first. XCL left these registers 0, so shaders that index the heaps themselves read their descriptors from address 0 on. On a retail title this showed as a flickering line at the top of the loading pictures: they ask for a clamping sampler and got a wrapping one.

What is in it

  • console_list.rs: the root signature's two flags in Layout::heaps; with_heaps appends the addresses after the arguments; unit test
  • console_heap.rs: base, the 32-bit address of a heap's slots
  • bind.rs, list_x.rs: SetDescriptorHeaps remembers the heaps' addresses per list (reset by Reset / ClearState), and draws and dispatches pass them

Tested

  • RTX 2070 SUPER (driver 617.14), i7-9700K, Windows 11 (26300), Rust 1.99.0; tests in debug, title in release
  • cargo test --workspace -- --test-threads=4: 892 passed, 0 failed, 42 ignored (run on the same tree; only the commit message was reworded after it). SKIPPED: gpu_geometry_wave32_prefix_count_over_a_mask and gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
  • new test heap_addresses_follow_the_arguments
  • registers, measured on the retail title: 110 of 153 root signatures at its first screen have a flag. All 540 built compute shaders with such a signature (218 view heap, 3 sampler heap, 319 both) have exactly one user SGPR more per flag than their arguments take. Pixel shaders, by where m0 comes from: 49,572 pipelines with 0x800 fit; with 0x400 204 fit and 102 do not take m0 from after the arguments
  • loading pictures: flickering line in 32 of 72 captured frames before and 0 of 98 after (both on my local branch with other changes), 0 of 21 with this change on b9b6ea6

Regression run

main:

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1578 (PresentX 1578)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15220 MB

PR:

xcl-smoke v1
commit: cb0075140a4eaf38b3d5b3a67727241d97e5ddb2
gpu: NVIDIA GeForce RTX 2070 SUPER
title: retail-title
seconds: 60
exit: 0x0
frames shown: 1567 (PresentX 1567)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15209 MB

Not tested

  • AMD, Intel and other NVIDIA GPUs
  • pixel shaders with both flags, and arguments that overflow the registers into memory
  • dispatches replayed from recorded console command words (console_list.rs) are unchanged: they still get no heap addresses
  • the 60 s regression runs do not reach the loading pictures or the world

AI use

  • Claude Code with Claude Opus 5.5 found the cause, wrote the code, the test, the measurements and this description, and ran the tests

🤖 Generated with Claude Code


Mirror of xcl-dev#1803 (auto-synced, do not edit).

raylitebull and others added 3 commits November 24, 2026 21:05
…-oom

dxil: eliminate giant-shader IR and CFG blowup in FormatLoad and multi-window memory
…sses

A root signature with CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED or SAMPLER_HEAP_DIRECTLY_INDEXED has the
console put the 32-bit address of the bound view heap / sampler heap into user SGPRs after the
root arguments, the view heap's first. XCL left these registers 0, so the shaders read their
descriptors from address 0 on.

Measured on a retail title: 110 of 153 root signatures at its first screen have one of the flags.
All 540 of its compute shaders with such a root signature that were built (218 with the view heap
flag, 3 with the sampler heap flag, 319 with both) have exactly one user SGPR more per flag than
their arguments take; those with both load T# from the first. The pixel shaders of 49 572 pipelines with the
sampler flag have one more as well (by where their m0 comes from). The pictures of its loading screen took a wrapping sampler
instead of the clamping one they ask for: a flickering line at their top edge.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

3 participants