Recompiler: send image heap indices that are no view to null views (#575) #610

Open
github-bot wants to merge 1 commit from github-bot/gh-610 into main AGit
Owner

@⁠xstraok on GitHub · 2026-11-24 02:27 UTC · original
xstraok:heap-index-clamp → main · +212 −22 · 5 files · 1 commits · draft

Image instructions in recompiled shaders index ResourceDescriptorHeap with T# word 0. When a T# is still in the console encoding (word 0 = BASE_ADDRESS >> 8, not a heap index), the read lands far past the shared view heap. On RADV that is an SQC page fault and the device is removed during a retail game's world loading (details in #575). Such an index now goes to a null SRV / null UAV of the declared texture type, kept at the end of the heap: it reads 0 and its writes are dropped. Where the raw T# comes from is still open (#575). Fixes #575.

What is in it (one commit, 61df188)

  • gpu/desc.rs: VIEW_HEAP_SIZE = 1 000 000 (the least a resource binding tier 3 GPU has, which SM 6.6 dynamic resources need). The last 12 slots (from NULL_VIEWS = 999 988) are null views: an SRV of each texture type the emitter declares (1D, 2D, 3D, CubeArray, 1DArray, 2DArray, 2DMS) and a UAV of each (1D, 2D, 3D, 1DArray, 2DArray), because D3D12 needs a null view's dimension to match the declaration. null_srv(ty) / null_uav(ty) give their slots. Constants, so a translation does not depend on the device or on whether the heap existed yet, and cached translations stay valid.
  • hle/d3d12x/console_heap.rs: the shared heap is VIEW_HEAP_SIZE on every device (no OPTIONS19 size, no GLOBAL_MAX); write_null_views writes the 12 null views, each with its dimension (the PC methods on an adopted device); console heaps get slots below NULL_VIEWS only.
  • gpu/recomp/emit.rs: a T# is a view when tw0 < NULL_VIEWS - 1 and word 3's TYPE is an image type (≥ 8, the test console_heap::copy_words and desc::image use). MIMG sample / gather / resinfo / load then use tw0, otherwise null_srv(type); store and atomics tw0 + 1, otherwise null_uav(type), with the type of the declaration. The TYPE check covers the all-zero T# XCL writes for a null-resource CreateShaderResourceViewX / CreateUnorderedAccessViewX, whose word 0 would be the view at index 0. A 2DMS store or atomic is refused at translation (SM 6.6 has no RWTexture2DMS; DXC refused it before).
  • gpu/recomp/runner.rs: kernel test runs with textures get the same heap with its null views.
  • gpu/recomp/tests.rs: gpu_image_with_no_heap_index_reads_zero_and_drops_writes samples, loads, stores and runs an atomic through a T# whose word 0 is a console address: it expects 0, and a real UAV next to it holding only its own stores. It fails without the index check (the stray store lands in the real texture). It also samples 3D and cube, loads a 2D array and stores 3D through that T#, and loads through an all-zero T# (expects 0) and a real T# of view 0 (expects the texture); without the TYPE check the all-zero load returns the texture. image_declarations_fall_back_to_the_null_view_of_their_type checks the emitted null slot per type (fails when every type gets the 2D one).

Tested

  • RX 9060 XT 16 GB (RDNA4, Mesa 26.2.6 RADV), Ryzen 5 7600, Arch Linux 7.2.15-zen, Linux under Wine (Proton Experimental 11.0-20261112; vkd3d-proton 3.1 with the checks relaxed as in #257). Rust 1.92.0, cross-built for x86_64-pc-windows-gnu, release.
  • Lib suite on this branch (main cb868b2 + 61df188), with XCL_DXC_DIR:
    • cargo test --release --target x86_64-pc-windows-gnu -p xcl --lib -- --test-threads=4: 643 passed, 4 failed, 21 ignored, no SKIPPED. The failures are gpu_f64_math_random, gpu_f64_roots, gpu_nonfused_mad_and_mac_prevent_fma_contraction and hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime; all 4 fail the same way on main on this machine.
    • gpu_image_with_no_heap_index_reads_zero_and_drops_writes: passes; fails with the raw tw0 index (and that run faulted the GPU, as in #575). RADV accepts a null view of the wrong dimension, so the per-type part is covered by the text test, not by this GPU run.
  • Reports from others on the previous head d2fa766: RTX 3070 / Windows 11 (upipibi) and RX 7900 XT / Windows (crosettiremi): the GPU test passes. Not rerun on 61df188.
  • Retail title (Series X profile, 1.0.2.1), on main a6f5f7a + #257 + #458 + #496 + #484, with the first version of this PR (c55352d, clamp to the heap's last slot):
    • Without it: device removed with an SQC page fault, 65–90 s into world loading, in 4 of 4 runs.
    • With it: no GPU fault in 2 runs; later runs on f4ce27c + #257 + #496 + #172 with it had none either. They stop later for other reasons (the title's watchdog during long first-bind shader compiles).

Regression run

  • None: scripts/smoke.ps1 needs Windows (see Not tested).

Not tested

  • Windows: no Windows machine here, so no MSVC build and no scripts/smoke.ps1 blocks. Someone needs to run the regression on Windows before this can be merged.
  • The retail title on 61df188 itself (the null views replace the last-slot clamp the title runs had).
  • 61df188 on NVIDIA and Windows AMD drivers (d2fa766 passed the GPU test on both, see above). A device whose heap could hold more than 1 000 000 views now uses 1 000 000.
  • Whether the redirected T#s draw correctly: they now read 0.

AI use

  • Claude Code with Claude Opus 5.5: found the cause from the logs and bo_history, wrote the patch, the test, the review follow-up and this description, and ran the tests. I ran the title.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SobdMAZZmGnBr71QeZQsUz

**@⁠xstraok** on GitHub · 2026-11-24 02:27 UTC · [original](https://github.com/xcl-dev/xcl/pull/610) `xstraok:heap-index-clamp` → `main` · +212 −22 · 5 files · 1 commits · draft Image instructions in recompiled shaders index `ResourceDescriptorHeap` with T# word 0. When a T# is still in the console encoding (word 0 = `BASE_ADDRESS >> 8`, not a heap index), the read lands far past the shared view heap. On RADV that is an SQC page fault and the device is removed during a retail game's world loading (details in #575). Such an index now goes to a null SRV / null UAV of the declared texture type, kept at the end of the heap: it reads 0 and its writes are dropped. Where the raw T# comes from is still open (#575). Fixes #575. **What is in it** (one commit, `61df188`) - `gpu/desc.rs`: `VIEW_HEAP_SIZE` = 1 000 000 (the least a resource binding tier 3 GPU has, which SM 6.6 dynamic resources need). The last 12 slots (from `NULL_VIEWS` = 999 988) are null views: an SRV of each texture type the emitter declares (1D, 2D, 3D, CubeArray, 1DArray, 2DArray, 2DMS) and a UAV of each (1D, 2D, 3D, 1DArray, 2DArray), because D3D12 needs a null view's dimension to match the declaration. `null_srv(ty)` / `null_uav(ty)` give their slots. Constants, so a translation does not depend on the device or on whether the heap existed yet, and cached translations stay valid. - `hle/d3d12x/console_heap.rs`: the shared heap is `VIEW_HEAP_SIZE` on every device (no OPTIONS19 size, no `GLOBAL_MAX`); `write_null_views` writes the 12 null views, each with its dimension (the PC methods on an adopted device); console heaps get slots below `NULL_VIEWS` only. - `gpu/recomp/emit.rs`: a T# is a view when `tw0 < NULL_VIEWS - 1` and word 3's TYPE is an image type (≥ 8, the test `console_heap::copy_words` and `desc::image` use). MIMG sample / gather / resinfo / load then use `tw0`, otherwise `null_srv(type)`; store and atomics `tw0 + 1`, otherwise `null_uav(type)`, with the type of the declaration. The TYPE check covers the all-zero T# XCL writes for a null-resource `CreateShaderResourceViewX` / `CreateUnorderedAccessViewX`, whose word 0 would be the view at index 0. A 2DMS store or atomic is refused at translation (SM 6.6 has no `RWTexture2DMS`; DXC refused it before). - `gpu/recomp/runner.rs`: kernel test runs with textures get the same heap with its null views. - `gpu/recomp/tests.rs`: `gpu_image_with_no_heap_index_reads_zero_and_drops_writes` samples, loads, stores and runs an atomic through a T# whose word 0 is a console address: it expects 0, and a real UAV next to it holding only its own stores. It fails without the index check (the stray store lands in the real texture). It also samples 3D and cube, loads a 2D array and stores 3D through that T#, and loads through an all-zero T# (expects 0) and a real T# of view 0 (expects the texture); without the TYPE check the all-zero load returns the texture. `image_declarations_fall_back_to_the_null_view_of_their_type` checks the emitted null slot per type (fails when every type gets the 2D one). **Tested** - RX 9060 XT 16 GB (RDNA4, Mesa 26.2.6 RADV), Ryzen 5 7600, Arch Linux 7.2.15-zen, **Linux under Wine** (Proton Experimental 11.0-20261112; vkd3d-proton 3.1 with the checks relaxed as in #257). Rust 1.92.0, cross-built for `x86_64-pc-windows-gnu`, release. - Lib suite on this branch (`main` `cb868b2` + `61df188`), with `XCL_DXC_DIR`: - `cargo test --release --target x86_64-pc-windows-gnu -p xcl --lib -- --test-threads=4`: **643 passed, 4 failed, 21 ignored**, no `SKIPPED`. The failures are `gpu_f64_math_random`, `gpu_f64_roots`, `gpu_nonfused_mad_and_mac_prevent_fma_contraction` and `hle::xaudio2::tests::xma2_source_voice_decodes_and_manages_lifetime`; all 4 fail the same way on `main` on this machine. - `gpu_image_with_no_heap_index_reads_zero_and_drops_writes`: passes; fails with the raw `tw0` index (and that run faulted the GPU, as in #575). RADV accepts a null view of the wrong dimension, so the per-type part is covered by the text test, not by this GPU run. - Reports from others on the previous head `d2fa766`: RTX 3070 / Windows 11 (upipibi) and RX 7900 XT / Windows (crosettiremi): the GPU test passes. Not rerun on `61df188`. - Retail title (Series X profile, 1.0.2.1), on `main` `a6f5f7a` + #257 + #458 + #496 + #484, with the **first version** of this PR (`c55352d`, clamp to the heap's last slot): - Without it: device removed with an SQC page fault, 65–90 s into world loading, in 4 of 4 runs. - With it: no GPU fault in 2 runs; later runs on `f4ce27c` + #257 + #496 + #172 with it had none either. They stop later for other reasons (the title's watchdog during long first-bind shader compiles). **Regression run** - None: `scripts/smoke.ps1` needs Windows (see Not tested). **Not tested** - **Windows**: no Windows machine here, so no MSVC build and no `scripts/smoke.ps1` blocks. Someone needs to run the regression on Windows before this can be merged. - The retail title on `61df188` itself (the null views replace the last-slot clamp the title runs had). - `61df188` on NVIDIA and Windows AMD drivers (`d2fa766` passed the GPU test on both, see above). A device whose heap could hold more than 1 000 000 views now uses 1 000 000. - Whether the redirected T#s draw correctly: they now read 0. **AI use** - Claude Code with Claude Opus 5.5: found the cause from the logs and `bo_history`, wrote the patch, the test, the review follow-up and this description, and ran the tests. I ran the title. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01SobdMAZZmGnBr71QeZQsUz
A T# that is still in the console encoding (word 0 = BASE_ADDRESS >> 8,
not an XCL heap index) made ResourceDescriptorHeap[tw0] read gigabytes
past the shader-visible view heap. On RADV that is an SQC page fault and
the device is removed during a retail game's world loading: the faulting
VAs were never covered by a BO (RADV_DEBUG=bo_history) and lie past the
1 000 000 x 32 B heap; as T# word 0 they are addresses in the title's own
mappings.

The shared view heap is now 1 000 000 descriptors on every device (the
least a resource binding tier 3 GPU has, which SM 6.6 dynamic resources
need), and its last 12 slots are null views that no console heap gets:
a null SRV of each texture type recompiled shaders declare (1D, 2D, 3D,
CubeArray, 1DArray, 2DArray, 2DMS) and a null UAV of each (1D, 2D, 3D,
1DArray, 2DArray), since D3D12 needs a null view's dimension to match
the declaration. Image instructions use word 0 as the view index only
below them and when word 3's TYPE is an image type (>= 8); otherwise the
null view of the type they declare: such a T# reads 0 and its stores and
atomics are dropped. The TYPE check covers the all-zero T# XCL writes
for a null-resource CreateShaderResourceViewX / CreateUnorderedAccessViewX,
whose word 0 would otherwise be the view at index 0. A 2DMS store or
atomic is refused at translation (SM 6.6 has no RWTexture2DMS; DXC
refused it before). The bound is a constant (gpu::desc::NULL_VIEWS), so
a translation does not depend on the device or on whether the heap
existed when it was made, and cached translations stay valid. Test runs
with textures get the same heap.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01SobdMAZZmGnBr71QeZQsUz
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:27:09 +00:00
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 04:56 UTC · original

Some thoughts on c55352d, from reading the code (not run):

  1. The clamp target isn't reserved. VIEW_HEAP_LAST = cap - 1 is an ordinary slot: reserve_global / take_range can hand it to any heap. So a garbage T# lands on either a descriptor that was never written (still undefined behaviour; RADV may stop faulting there, other drivers needn't) or a live view of some unrelated resource. For image_store and atomics, that unrelated resource gets written to. Both the SRV (min(tw0, last)) and UAV (min(tw0 + 1, last)) paths also clamp to the same slot, so one of them always reads a descriptor of the wrong type. Reserving the last two slots at shared_heap creation, filled with a null SRV (last - 1) and a null UAV (last), and clamping SRV indices to last - 1, would make the fallback defined: reads return 0 and writes are dropped.
  2. The bound is baked into the HLSL text. It's read at translation time. A shader translated before shared_heap runs gets 2^21 − 1, which is larger than the heap (GLOBAL_MAX / MaxViewDescriptorHeapSize, default 1,000,000), so it isn't protected. If translated HLSL or DXIL is cached across runs (#559 / #613 talk about warm translation caches), a value from another run or device is reused too. An alternative that avoids both: take the bound from a root constant or the heap size at bind time, or make the clamp constant independent of the device (GLOBAL_MAX - 1) and keep those slots null.
  3. The test checks text, not behaviour. image_heap_index_is_clamped_to_the_heap asserts the substring , {last}u))]. A GPU test that samples with word 0 = a large console address and expects 0 would cover the point of the fix.

The clamp is a reasonable stopgap while the source of the raw T# (#575) stays open; these are about making its fallback safe.

AI-assisted (Claude Code), read-only review.

**@⁠upipibi** on GitHub · 2026-11-24 04:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/610#issuecomment-7122474167) Some thoughts on `c55352d`, from reading the code (not run): 1. **The clamp target isn't reserved.** `VIEW_HEAP_LAST = cap - 1` is an ordinary slot: `reserve_global` / `take_range` can hand it to any heap. So a garbage T# lands on either a descriptor that was never written (still undefined behaviour; RADV may stop faulting there, other drivers needn't) or a live view of some unrelated resource. For `image_store` and atomics, that unrelated resource gets written to. Both the SRV (`min(tw0, last)`) and UAV (`min(tw0 + 1, last)`) paths also clamp to the *same* slot, so one of them always reads a descriptor of the wrong type. Reserving the last two slots at `shared_heap` creation, filled with a null SRV (`last - 1`) and a null UAV (`last`), and clamping SRV indices to `last - 1`, would make the fallback defined: reads return 0 and writes are dropped. 2. **The bound is baked into the HLSL text.** It's read at translation time. A shader translated before `shared_heap` runs gets 2^21 − 1, which is larger than the heap (`GLOBAL_MAX` / `MaxViewDescriptorHeapSize`, default 1,000,000), so it isn't protected. If translated HLSL or DXIL is cached across runs (#559 / #613 talk about warm translation caches), a value from another run or device is reused too. An alternative that avoids both: take the bound from a root constant or the heap size at bind time, or make the clamp constant independent of the device (`GLOBAL_MAX - 1`) and keep those slots null. 3. **The test checks text, not behaviour.** `image_heap_index_is_clamped_to_the_heap` asserts the substring `, {last}u))]`. A GPU test that samples with word 0 = a large console address and expects 0 would cover the point of the fix. The clamp is a reasonable stopgap while the source of the raw T# (#575) stays open; these are about making its fallback safe. AI-assisted (Claude Code), read-only review.
Author
Owner

@⁠xstraok on GitHub · 2026-11-24 05:23 UTC · original

Thanks – all three check out. take_range could hand out cap - 1, so the clamp could land on a live view, and SRV and UAV shared it; the bound was read at translation time, and since #762 the translated DXIL cache doesn't key on it. Pushed d2fa766: the shared heap is now 1,000,000 views on every device (the tier-3 minimum that SM 6.6 dynamic resources need), its last two slots are a null SRV (999,998) and a null UAV (999,999) that no heap gets, and image instructions send any index that is not a view's to those constants – so nothing depends on the device or on when a shader was translated. The text test is replaced by a GPU test that samples, loads, stores and runs an atomic through a T# whose word 0 is a console address and expects 0, with a real UAV next to it untouched; it fails without the clamp (the stray store lands in the real texture). Linux / RX 9060 XT / RADV / Proton: cargo test --release --target x86_64-pc-windows-gnu -p xcl --lib -- --test-threads=4: 642 passed, 4 failed (known under Wine: gpu_f64_roots, gpu_f64_math_random, gpu_nonfused_mad_and_mac_prevent_fma_contraction, xma2_source_voice_decodes_and_manages_lifetime), 21 ignored. Windows regression still open.

(Drafted with Claude Code, Claude Opus 5.5.)

**@⁠xstraok** on GitHub · 2026-11-24 05:23 UTC · [original](https://github.com/xcl-dev/xcl/pull/610#issuecomment-7122910074) Thanks – all three check out. `take_range` could hand out `cap - 1`, so the clamp could land on a live view, and SRV and UAV shared it; the bound was read at translation time, and since #762 the translated DXIL cache doesn't key on it. Pushed `d2fa766`: the shared heap is now 1,000,000 views on every device (the tier-3 minimum that SM 6.6 dynamic resources need), its last two slots are a null SRV (999,998) and a null UAV (999,999) that no heap gets, and image instructions send any index that is not a view's to those constants – so nothing depends on the device or on when a shader was translated. The text test is replaced by a GPU test that samples, loads, stores and runs an atomic through a T# whose word 0 is a console address and expects 0, with a real UAV next to it untouched; it fails without the clamp (the stray store lands in the real texture). Linux / RX 9060 XT / RADV / Proton: `cargo test --release --target x86_64-pc-windows-gnu -p xcl --lib -- --test-threads=4`: 642 passed, 4 failed (known under Wine: `gpu_f64_roots`, `gpu_f64_math_random`, `gpu_nonfused_mad_and_mac_prevent_fma_contraction`, `xma2_source_voice_decodes_and_manages_lifetime`), 21 ignored. Windows regression still open. *(Drafted with Claude Code, Claude Opus 5.5.)*
Author
Owner

@⁠upipibi on GitHub · 2026-11-24 05:56 UTC · original

Windows NVIDIA run of d2fa766, since the description lists Windows as open (not the retail regression run; we have no title).

Tested

  • NVIDIA GeForce RTX 3070 (driver 616.56, wave32), Ryzen 9 5950X, Windows 11 Pro 26100, rustc 1.100.0 MSVC, debug
  • cargo test -p xcl --lib -- --test-threads=4:
    • this head: 646 passed, 0 failed, 21 ignored;
    • its merge base cb868b2: 645 passed, 0 failed, 21 ignored (the difference is the new test).
  • gpu_image_with_no_heap_index_reads_zero_and_drops_writes passes. So does gpu_typed_buffer_loads_and_stores alone, 3 of 3, on both trees.

For completeness: in a first full cargo test --workspace run of this head, the device was removed (0x887a0006) during gpu_typed_buffer_loads_and_stores, and 9 more GPU tests failed after it. That didn't reproduce in the reruns above (0 device removals), and other GPU jobs on this machine may have overlapped that run, so I'm not attributing it to the PR. If anyone sees DEVICE_HUNG with this head, the runner's per-dispatch 1,000,000-view heap (runner.rs) would be the first thing I'd look at.

AI-assisted (Claude Code).

**@⁠upipibi** on GitHub · 2026-11-24 05:56 UTC · [original](https://github.com/xcl-dev/xcl/pull/610#issuecomment-7123426552) Windows NVIDIA run of `d2fa766`, since the description lists Windows as open (not the retail regression run; we have no title). **Tested** - NVIDIA GeForce RTX 3070 (driver 616.56, wave32), Ryzen 9 5950X, Windows 11 Pro 26100, rustc 1.100.0 MSVC, debug - `cargo test -p xcl --lib -- --test-threads=4`: - this head: **646 passed, 0 failed, 21 ignored**; - its merge base `cb868b2`: 645 passed, 0 failed, 21 ignored (the difference is the new test). - `gpu_image_with_no_heap_index_reads_zero_and_drops_writes` passes. So does `gpu_typed_buffer_loads_and_stores` alone, 3 of 3, on both trees. For completeness: in a first full `cargo test --workspace` run of this head, the device was removed (`0x887a0006`) during `gpu_typed_buffer_loads_and_stores`, and 9 more GPU tests failed after it. That didn't reproduce in the reruns above (0 device removals), and other GPU jobs on this machine may have overlapped that run, so I'm not attributing it to the PR. If anyone sees `DEVICE_HUNG` with this head, the runner's per-dispatch 1,000,000-view heap (`runner.rs`) would be the first thing I'd look at. AI-assisted (Claude Code).
Author
Owner

@⁠xstraok on GitHub · 2026-11-24 06:16 UTC · original

Thanks to both.

@⁠crosettiremi – right: write_null_views made only Texture2D null views, while the emitter also declares 1D, 3D, CubeArray, 1DArray, 2DArray and 2DMS. Pushed 550bcd0: the heap's last 12 slots are a null SRV per declared type (1D, 2D, 3D, CubeArray, 1DArray, 2DArray, 2DMS) and a null UAV per type (1D, 2D, 3D, 1DArray, 2DArray). desc::null_srv / null_uav give the slot, and each declaration falls back to the one of its own type. A 2DMS store or atomic is now refused at translation (SM 6.6 has no RWTexture2DMS; DXC refused it before). New text test image_declarations_fall_back_to_the_null_view_of_their_type checks the emitted index per type. It fails when every type gets the 2D slot. The GPU test now also samples 3D and cube, loads a 2D array and stores 3D through the bad T#. Since your DEVICE_HUNG at 0xd000 happens with and without the PR, I'm not treating it as caused by this PR.

@⁠upipibi – thanks for the NVIDIA run. Your comment's cargo test line came through without counts; could you add them? Noted on the runner: it makes a 1,000,000-view heap only for tests that bind textures, one per run.

Linux / RX 9060 XT / Mesa 26.2.6 RADV / Proton Experimental, 550bcd0: cargo test --release --target x86_64-pc-windows-gnu -p xcl --lib -- --test-threads=4: 643 passed, 4 failed (known under Wine: gpu_f64_roots, gpu_f64_math_random, gpu_nonfused_mad_and_mac_prevent_fma_contraction, xma2_source_voice_decodes_and_manages_lifetime), 21 ignored, no SKIPPED. RADV takes a null view of the wrong dimension, so on Linux only the text test covers the per-type choice. Windows still open.

(Drafted with Claude Code, Claude Opus 5.5.)

**@⁠xstraok** on GitHub · 2026-11-24 06:16 UTC · [original](https://github.com/xcl-dev/xcl/pull/610#issuecomment-7123765036) Thanks to both. @⁠crosettiremi – right: `write_null_views` made only Texture2D null views, while the emitter also declares 1D, 3D, CubeArray, 1DArray, 2DArray and 2DMS. Pushed `550bcd0`: the heap's last 12 slots are a null SRV per declared type (1D, 2D, 3D, CubeArray, 1DArray, 2DArray, 2DMS) and a null UAV per type (1D, 2D, 3D, 1DArray, 2DArray). `desc::null_srv` / `null_uav` give the slot, and each declaration falls back to the one of its own type. A 2DMS store or atomic is now refused at translation (SM 6.6 has no `RWTexture2DMS`; DXC refused it before). New text test `image_declarations_fall_back_to_the_null_view_of_their_type` checks the emitted index per type. It fails when every type gets the 2D slot. The GPU test now also samples 3D and cube, loads a 2D array and stores 3D through the bad T#. Since your `DEVICE_HUNG` at `0xd000` happens with and without the PR, I'm not treating it as caused by this PR. @⁠upipibi – thanks for the NVIDIA run. Your comment's `cargo test` line came through without counts; could you add them? Noted on the runner: it makes a 1,000,000-view heap only for tests that bind textures, one per run. Linux / RX 9060 XT / Mesa 26.2.6 RADV / Proton Experimental, `550bcd0`: `cargo test --release --target x86_64-pc-windows-gnu -p xcl --lib -- --test-threads=4`: 643 passed, 4 failed (known under Wine: `gpu_f64_roots`, `gpu_f64_math_random`, `gpu_nonfused_mad_and_mac_prevent_fma_contraction`, `xma2_source_voice_decodes_and_manages_lifetime`), 21 ignored, no `SKIPPED`. RADV takes a null view of the wrong dimension, so on Linux only the text test covers the per-type choice. Windows still open. *(Drafted with Claude Code, Claude Opus 5.5.)*
Author
Owner

@⁠crosettiremi on GitHub · 2026-11-24 06:02 UTC · original · edited 2026-11-24 06:26 UTC

I tested head d2fa766 on Windows / RX 7900 XT in a local integration. The targeted gpu_image_with_no_heap_index_reads_zero_and_drops_writes test ran on the adapter and passed.

For the title test I used the same saved player profile (anaconda), initial application caches, compact PSO preloading and 28 GiB job cap as the baseline. I regenerated both opt-in compute packages against this emitter. Both runs reached world-loading artwork. The baseline exited with DXGI_ERROR_DEVICE_HUNG and a DRED page fault at 0xd000 at 196.172 s. With this PR the same status and GPU VA returned at 166.311 s. Player selection happened at different times. The absolute timings do not establish a speed difference. Neither compact lighting shader had a recorded bind before either failure.

The second run traced matching sequences of seven recorded dispatches on two partially completed command lists (6 of 20 operations, next breadcrumb Dispatch). Two of the six distinct programs in that sequence lower to 2D texture loads/samples. Four have no ResourceDescriptorHeap references in their conventional four-window translation. This narrows the inspection set; it does not identify which descriptor caused the fault or contradict the separate RADV result.

One independent coverage issue: write_null_views currently creates only Texture2D null SRV/UAV descriptors, while the emitter can select those same indices for Texture3D or TextureCubeArray. Microsoft's null-descriptor rules require compatible view types. VIctory's review also found that descriptor creation and even a zero read on one GPU can pass with the wrong dimension. A test of the emitted slot selection plus a non-2D access under GPU-based validation would cover that path. The two textured candidates above use 2D views, so I am not attributing this particular crash to that dimension mismatch.

https://learn.microsoft.com/en-us/windows/win32/direct3d12/descriptors-overview#null-descriptors
https://github.com/Marvisak/VIctory/pull/205#issuecomment-7122711762
Follow-up on the same Radeon with #610 still applied and a lower-memory pipeline queue. At 165.301 s the 0xd000 fault repeated. Full DRED histories put all three partially executed lists at the third of seven dispatches. Two had one Texture2D shader there and one had the other, with the same two shaders swapped between positions three and four. Both also read the guest memory windows. This locates the incomplete dispatches and leaves both binding classes under investigation.

**@⁠crosettiremi** on GitHub · 2026-11-24 06:02 UTC · [original](https://github.com/xcl-dev/xcl/pull/610#issuecomment-7123516090) · edited 2026-11-24 06:26 UTC I tested head d2fa766 on Windows / RX 7900 XT in a local integration. The targeted gpu_image_with_no_heap_index_reads_zero_and_drops_writes test ran on the adapter and passed. For the title test I used the same saved player profile (anaconda), initial application caches, compact PSO preloading and 28 GiB job cap as the baseline. I regenerated both opt-in compute packages against this emitter. Both runs reached world-loading artwork. The baseline exited with DXGI_ERROR_DEVICE_HUNG and a DRED page fault at 0xd000 at 196.172 s. With this PR the same status and GPU VA returned at 166.311 s. Player selection happened at different times. The absolute timings do not establish a speed difference. Neither compact lighting shader had a recorded bind before either failure. The second run traced matching sequences of seven recorded dispatches on two partially completed command lists (6 of 20 operations, next breadcrumb Dispatch). Two of the six distinct programs in that sequence lower to 2D texture loads/samples. Four have no ResourceDescriptorHeap references in their conventional four-window translation. This narrows the inspection set; it does not identify which descriptor caused the fault or contradict the separate RADV result. One independent coverage issue: write_null_views currently creates only Texture2D null SRV/UAV descriptors, while the emitter can select those same indices for Texture3D or TextureCubeArray. Microsoft's null-descriptor rules require compatible view types. VIctory's review also found that descriptor creation and even a zero read on one GPU can pass with the wrong dimension. A test of the emitted slot selection plus a non-2D access under GPU-based validation would cover that path. The two textured candidates above use 2D views, so I am not attributing this particular crash to that dimension mismatch. https://learn.microsoft.com/en-us/windows/win32/direct3d12/descriptors-overview#null-descriptors https://github.com/Marvisak/VIctory/pull/205#issuecomment-7122711762 Follow-up on the same Radeon with #610 still applied and a lower-memory pipeline queue. At 165.301 s the 0xd000 fault repeated. Full DRED histories put all three partially executed lists at the third of seven dispatches. Two had one Texture2D shader there and one had the other, with the same two shaders swapped between positions three and four. Both also read the guest memory windows. This locates the incomplete dispatches and leaves both binding classes under investigation.
Author
Owner

@⁠crosettiremi on GitHub · 2026-11-24 06:33 UTC · original · edited 2026-11-24 06:37 UTC

Follow-up on 550bcd0, Windows / RX 7900 XT. The expanded dimension-specific null-view GPU test passes on my local integration.

There is also a separate in-range case. XCL's null-resource CreateShaderResourceViewX and CreateUnorderedAccessViewX paths write an all-zero guest texture descriptor. The upper-bound check interprets its word 0 as PC heap index zero. In the synthetic compute test I installed an ordinary Texture2D with red=1.25 at slot zero, then loaded through a zero T# and through a valid typed T# for the same index. With the upper-bound check alone the zero T# read 1.25 on lane 0. With a check for zero index and zero texture-type word, the zero T# reads 0 and the valid T# still reads 1.25. Both variants used the same 2D native view, so this is a deterministic alias test without an invalid native access.

I am running the corrected emitter with freshly generated packages against the retail load. The isolated test establishes an aliasing defect; the recurring 0xd000 page fault is still under investigation.
Retail result: the corrected emitter rebuilt with the same Series X profile, 28 GiB cap and observed A press at 63 s. It reproduced the DRED page fault at GPU VA 0xd000 at 167.997 s. The surviving third-dispatch breadcrumb maps to the same Texture2D shader and 72-group launch as the comparison. Peak sampled process commit was 25,893 MB. The all-zero descriptor regression is fixed in the synthetic test; the title crash requires a separate fix.

**@⁠crosettiremi** on GitHub · 2026-11-24 06:33 UTC · [original](https://github.com/xcl-dev/xcl/pull/610#issuecomment-7124054442) · edited 2026-11-24 06:37 UTC Follow-up on 550bcd0, Windows / RX 7900 XT. The expanded dimension-specific null-view GPU test passes on my local integration. There is also a separate in-range case. XCL's null-resource CreateShaderResourceViewX and CreateUnorderedAccessViewX paths write an all-zero guest texture descriptor. The upper-bound check interprets its word 0 as PC heap index zero. In the synthetic compute test I installed an ordinary Texture2D with red=1.25 at slot zero, then loaded through a zero T# and through a valid typed T# for the same index. With the upper-bound check alone the zero T# read 1.25 on lane 0. With a check for zero index and zero texture-type word, the zero T# reads 0 and the valid T# still reads 1.25. Both variants used the same 2D native view, so this is a deterministic alias test without an invalid native access. I am running the corrected emitter with freshly generated packages against the retail load. The isolated test establishes an aliasing defect; the recurring 0xd000 page fault is still under investigation. Retail result: the corrected emitter rebuilt with the same Series X profile, 28 GiB cap and observed A press at 63 s. It reproduced the DRED page fault at GPU VA 0xd000 at 167.997 s. The surviving third-dispatch breadcrumb maps to the same Texture2D shader and 72-group launch as the comparison. Peak sampled process commit was 25,893 MB. The all-zero descriptor regression is fixed in the synthetic test; the title crash requires a separate fix.
Author
Owner

@⁠xstraok on GitHub · 2026-11-24 06:39 UTC · original

@⁠crosettiremi – confirmed: the null-resource CreateShaderResourceViewX / CreateUnorderedAccessViewX paths write [0; 8], and word 0 = 0 passed the bound. Pushed 61df188: a T# is used as a view only when word 0 is below the null views and word 3's TYPE is an image type (≥ 8, the same test console_heap::copy_words and desc::image use); anything else goes to the null view of its declared type. The GPU test now loads through an all-zero T# (expects 0) and through a real T# of view 0 (expects the texture). Without the TYPE check, the zero-T# load returns the texture's data. Thanks for the retail run: agreed the 0xd000 fault is separate.

Linux / RX 9060 XT / Mesa 26.2.6 RADV / Proton Experimental, 61df188: cargo test --release --target x86_64-pc-windows-gnu -p xcl --lib -- --test-threads=4: 643 passed, 4 failed (the same known Wine failures), 21 ignored, no SKIPPED.

(Drafted with Claude Code, Claude Opus 5.5.)

**@⁠xstraok** on GitHub · 2026-11-24 06:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/610#issuecomment-7124164710) @⁠crosettiremi – confirmed: the null-resource `CreateShaderResourceViewX` / `CreateUnorderedAccessViewX` paths write `[0; 8]`, and word 0 = 0 passed the bound. Pushed `61df188`: a T# is used as a view only when word 0 is below the null views **and** word 3's TYPE is an image type (≥ 8, the same test `console_heap::copy_words` and `desc::image` use); anything else goes to the null view of its declared type. The GPU test now loads through an all-zero T# (expects 0) and through a real T# of view 0 (expects the texture). Without the TYPE check, the zero-T# load returns the texture's data. Thanks for the retail run: agreed the `0xd000` fault is separate. Linux / RX 9060 XT / Mesa 26.2.6 RADV / Proton Experimental, `61df188`: `cargo test --release --target x86_64-pc-windows-gnu -p xcl --lib -- --test-threads=4`: 643 passed, 4 failed (the same known Wine failures), 21 ignored, no `SKIPPED`. *(Drafted with Claude Code, Claude Opus 5.5.)*
Author
Owner

@⁠ClosetPie107 on GitHub · 2026-11-24 11:45 UTC · original · edited 2026-11-24 12:31 UTC

Retail-title test of 61df188 on RDNA4 under Linux: the #575 fault is gone; the run ends on a different GPU page fault about 25 s after the first #101.

Tested

  • AMD Radeon RX 9070 16 GB (RADV GFX1201, Mesa 26.3.1, kernel 7.3.5), Ryzen 5 9600X, 30 GB RAM; CachyOS. Proton Experimental's Wine (experimental-11.0-20261112), vkd3d-proton v3.1 + #257's patch (-Db_ndebug=true, dxil-spirv 53aac418, so #611 is out of the way), DXC 1.9.2609.5. Rust 1.96.0, x86_64-pc-windows-gnu, release.
  • main 384f7f7 against 384f7f7 + this PR (clean merge). Retail 1.0.2.1, first-run setup done earlier, XCL_PRESS_AT=30.6:A, XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_PSO_WAIT_MS=50 XCL_COHERENT_MB=512 VKD3D_CONFIG=ignore_shared_fence.
384f7f7 384f7f7 + #610
first ListX #101 84.6 s 84.9 s
GPU page fault (journalctl -k) ~114 s (+29.6 s) ~110 s (+25.3 s)
UTCL2 client SQC (data) TCP (0x8)
faulting page 0x00008000befff000: RADV's 32-bit range, past the end of the 1 000 000-slot view heap, as in #575 0x0000c00100000000
PERMISSION_FAULTS / MAPPING_ERROR 0x3 / 0x0 0x3 / 0x0
driver comp_1.1.0 timeout, ring reset succeeded gfx_0.0.0 timeout, ring reset succeeded
D3D12 device removed: 0x887a0005 118.408 s 112.069 s (title's 0x80000003 at +0x2474606 0.1 s later)
skipped draws / dispatches 4 208 / 663 1 362 / 831
  • The scalar descriptor read past the heap does not happen with this PR. On main it came ~30 s after #101 in both runs I made (the other on 6efdabc + #905, in my #846 comment).
  • The new fault is from vector memory (buffer or image access), at 0xffffc001_00000000: 64 TiB into the high VA range, beyond anything allocated here. I have not found which descriptor or address produces it. It is not the 0xd000 fault @⁠crosettiremi reported on Windows / RX 7900 XT.
  • Edited: this fault is not from this PR, and not from skipped work. Plain main 47efa2e, without XCL_PSO_WAIT_MS (0 skipped draws or dispatches), with RADV's cache warmed (#1035): 1 of 4 runs took the same fault (TCP (0x8), 0x0000c00100000000, ~10 s after the first #101), then device removed and the watchdog at 114.8 s. The other 3 ended in the watchdog at 108.6–110.6 s (~30 s after #101) with no GPU fault. So with #610 the #575 fault is gone and this one, already in main, is what is left.
  • Only one run with the PR got that far. The next runs (with and without this PR) end earlier: the pipeline preload builds compute programs that RADV takes ~60 s and ~16 GB each to compile, and the machine runs out of RAM first. Not this PR: the same on main alone; details on #1035.

Not tested: a second run reaching the new fault, without XCL_PSO_WAIT_MS, RADV_DEBUG=bo_history / XCL_LIST_TRACE for the new fault, the lib suite on this head, Windows.

AI use: T3 Code (Claude Opus 5.5) built both trees, ran the title and wrote this comment from XCL's logs and the kernel log; I checked it before posting.

**@⁠ClosetPie107** on GitHub · 2026-11-24 11:45 UTC · [original](https://github.com/xcl-dev/xcl/pull/610#issuecomment-7130505330) · edited 2026-11-24 12:31 UTC Retail-title test of `61df188` on **RDNA4 under Linux**: the #575 fault is gone; the run ends on a different GPU page fault about 25 s after the first `#101`. **Tested** - AMD Radeon RX 9070 16 GB (RADV GFX1201, Mesa 26.3.1, kernel 7.3.5), Ryzen 5 9600X, 30 GB RAM; CachyOS. Proton Experimental's Wine (`experimental-11.0-20261112`), vkd3d-proton v3.1 + #257's patch (`-Db_ndebug=true`, dxil-spirv `53aac418`, so #611 is out of the way), DXC 1.9.2609.5. Rust 1.96.0, `x86_64-pc-windows-gnu`, release. - `main` `384f7f7` against `384f7f7` + this PR (clean merge). Retail 1.0.2.1, first-run setup done earlier, `XCL_PRESS_AT=30.6:A`, `XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_PSO_WAIT_MS=50 XCL_COHERENT_MB=512 VKD3D_CONFIG=ignore_shared_fence`. | | `384f7f7` | `384f7f7` + #610 | |---|---|---| | first ListX `#101` | 84.6 s | 84.9 s | | GPU page fault (`journalctl -k`) | ~114 s (+29.6 s) | ~110 s (+25.3 s) | | UTCL2 client | `SQC (data)` | **`TCP (0x8)`** | | faulting page | `0x00008000befff000`: RADV's 32-bit range, past the end of the 1 000 000-slot view heap, as in #575 | **`0x0000c00100000000`** | | `PERMISSION_FAULTS` / `MAPPING_ERROR` | `0x3` / `0x0` | `0x3` / `0x0` | | driver | `comp_1.1.0` timeout, ring reset succeeded | `gfx_0.0.0` timeout, ring reset succeeded | | `D3D12 device removed: 0x887a0005` | 118.408 s | 112.069 s (title's `0x80000003` at `+0x2474606` 0.1 s later) | | skipped draws / dispatches | 4 208 / 663 | 1 362 / 831 | - The scalar descriptor read past the heap does not happen with this PR. On `main` it came ~30 s after `#101` in both runs I made (the other on `6efdabc` + #905, in my #846 comment). - The new fault is from vector memory (buffer or image access), at `0xffffc001_00000000`: 64 TiB into the high VA range, beyond anything allocated here. I have not found which descriptor or address produces it. It is not the `0xd000` fault @⁠crosettiremi reported on Windows / RX 7900 XT. - **Edited:** this fault is not from this PR, and not from skipped work. Plain `main` `47efa2e`, **without** `XCL_PSO_WAIT_MS` (0 skipped draws or dispatches), with RADV's cache warmed (#1035): 1 of 4 runs took the same fault (`TCP (0x8)`, `0x0000c00100000000`, ~10 s after the first `#101`), then `device removed` and the watchdog at 114.8 s. The other 3 ended in the watchdog at 108.6–110.6 s (~30 s after `#101`) with no GPU fault. So with #610 the #575 fault is gone and this one, already in `main`, is what is left. - **Only one run with the PR got that far.** The next runs (with and without this PR) end earlier: the pipeline preload builds compute programs that RADV takes ~60 s and ~16 GB each to compile, and the machine runs out of RAM first. Not this PR: the same on `main` alone; details on #1035. **Not tested:** a second run reaching the new fault, without `XCL_PSO_WAIT_MS`, `RADV_DEBUG=bo_history` / `XCL_LIST_TRACE` for the new fault, the lib suite on this head, Windows. **AI use:** T3 Code (Claude Opus 5.5) built both trees, ran the title and wrote this comment from XCL's logs and the kernel log; I checked it before posting.
Author
Owner

@⁠Toons29 on GitHub · 2026-11-25 02:58 UTC · original

Regression run of 61df188f on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 61df188f76cf842d6ba070bf6acd7db50a2baa8e
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1544 (PresentX 1544)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14860 MB

Against the limits in CONTRIBUTING.md: 95 % of main's frames, 100 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

**@⁠Toons29** on GitHub · 2026-11-25 02:58 UTC · [original](https://github.com/xcl-dev/xcl/pull/610#issuecomment-7151444625) Regression run of `61df188f` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 61df188f76cf842d6ba070bf6acd7db50a2baa8e gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1544 (PresentX 1544) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14860 MB ``` Against the limits in CONTRIBUTING.md: 95 % of `main`'s frames, 100 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 12:55 UTC · original

Verification on RTX 3060 Ti (Windows 11): merge conflict with current main — needs a rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-25 12:55 UTC · [original](https://github.com/xcl-dev/xcl/pull/610#issuecomment-7163052388) Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** — needs a rebase before it can be tested.
This pull request has changes conflicting with the target branch.
  • crates/xcl/src/gpu/recomp/emit.rs
  • crates/xcl/src/gpu/recomp/tests.rs
  • crates/xcl/src/hle/d3d12x/console_heap.rs
View command line instructions

Manual merge helper

Use this merge commit message when completing the merge manually.

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/610/head:github-bot/gh-610'
git switch 'github-bot/gh-610'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-610'
git switch 'github-bot/gh-610'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-610'
git switch 'github-bot/gh-610'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-610'
git switch 'main'
git merge --squash 'github-bot/gh-610'
git switch 'main'
git merge --ff-only 'github-bot/gh-610'
git switch 'main'
git merge 'github-bot/gh-610'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.