Recompiler: bound descriptor heap indices from T# and S# words to the heap #1215

Open
github-bot wants to merge 2 commits from github-bot/gh-1215 into main AGit
Owner

@⁠duudiis on GitHub · 2026-11-24 13:18 UTC · original
duudiis:pr/heap-index-bound → main · +303 −18 · 9 files · 2 commits · open

Translated shaders index ResourceDescriptorHeap with T# word 0 and SamplerDescriptorHeap with S# word 3 [11:0], and both come from console memory. If a T# was read from memory the GPU never wrote, the index can be anything. On NVIDIA an index past the heap wraps onto an unrelated slot, and if that slot holds a descriptor of the wrong kind the GPU hangs with no DRED page fault (device removal 0x887a0005). A retail title's cutscene reads T#s from memory that skipped GPU work was meant to write. This PR keeps those indices inside the heap. The shared heap now ends in null-view guard slots, and every data-derived heap index in a translated shader is bounded to them, so a garbage T# reads zeros and its stores are dropped.

Idea from VIctory (GPL-3.0), reimplemented; no code taken.

Overlaps #610 (draft): it also puts null views at the end of the heap and sends T# indices that are not views to them. The approaches differ. #610 fixes the heap at 1 000 000 views, checks word 0 against a compile-time constant and also checks word 3's TYPE. This PR keeps the heap at its OPTIONS19 size and passes the bound at run time in an io slot. It also bounds S# indices and fills shader-visible sampler heaps to 2048. The two conflict in console_heap.rs, emit.rs and runner.rs, so only one of them should land.

What is in it

  • D3D12.X: reserve null-view guard slots at the end of the shared heap:
    • hle/d3d12x/console_heap.rs: the last 14 descriptors of the shared heap are guard slots. For each view kind the emitter declares (1D, 2D, 3D, CubeArray, 1DArray, 2DArray, 2DMS) there is a null SRV with a null UAV next to it, and no console heap is ever given these slots. view_limit returns the first guard slot when the shared heap is bound, and 0 otherwise or with XCL_HEAP_CLAMP=0.
    • gpu/recomp/mod.rs: IO_VIEW_LIMIT = io slot 113. Slot 112 is already IO_UMA_BASE_HI, so the new one goes next to it in the trap-temp range. Also adds VIEW_GUARD_KINDS and SAMPLER_HEAP_SLOTS.
    • bind.rs, console_list.rs and list_x.rs write the io slot for each translated draw and dispatch, from the heaps the list has bound.
    • real.rs: shader-visible PC sampler heaps get 2048 samplers. The slots past the title's are the zero S#'s point sampler.
  • Recompiler: bound heap indices from T# and S# words to the heap (gpu/recomp/emit.rs):
    • Each T# heap index (sample, get_lod, get_resinfo, load, store, atomics) becomes one select against xcl_vlast = io[IO_VIEW_LIMIT] - 1.
    • The UAV + 1 is applied after the bound. Before, word 0 0xFFFFFFFF wrapped the UAV index to 0.
    • S# indices become min(s & 0xFFF, 2047).
    • Shaders that index no heap produce the same HLSL as before.
    • gpu/recomp/runner.rs: the kernel test runner puts the guard slots after the test textures and fills its sampler heap the same way the runtime does.

Tested

  • NVIDIA GeForce RTX 5070 (12 GB), Intel Core i7-14700KF, Windows 11; Rust 1.98.0, release.
  • cargo build --workspace --release: ok.
  • cargo test --workspace --release -- --test-threads=4 on 757ece9: 744 passed, 0 failed, 41 ignored (lib: 701 passed, 0 failed, 21 ignored).
    • SKIPPED (no wave64): gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask, gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware.
  • New tests:
    • shared_heap_guard_slots (console_heap.rs): passes.
    • heap_indices_are_bounded (gpu/recomp/tests.rs): passes, and fails with this head's emit.rs reverted.
    • gpu_heap_index_past_the_views_reads_the_guard (GPU): passes. On this NVIDIA GPU it also passes with emit.rs reverted, because the out-of-range reads there returned 0 and the stores were dropped. It shows that the guard path reads zeros and drops stores. It does not reproduce the hang.

Regression run
main (47efa2e):

xcl-smoke v1
commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3
gpu: NVIDIA GeForce RTX 5070
title: NYCMain
seconds: 60
exit: 0x0
frames shown: 386 (PresentX 387)
presents per 2 s (last 3): 11 11 14
device removals: 0
crashes: 0
peak commit: 15980 MB

This PR (757ece9):

xcl-smoke v1
commit: 757ece9795bc1f047661c77c039645d1893bb949
gpu: NVIDIA GeForce RTX 5070
title: NYCMain
seconds: 60
exit: 0x0
frames shown: 1600 (PresentX 1600)
presents per 2 s (last 3): 60 61 60
device removals: 0
crashes: 0
peak commit: 16739 MB

The main run went first with a cold shader and driver cache (both builds share the cache folder), so most of the frame difference is the cache, not this change. Both runs cover boot and the intro, not the cutscene that reads garbage T#s.

Not tested

  • AMD GPUs.
  • The retail title past its intro with this exact head: the smoke runs stop at 60 s, before the cutscene that reads garbage T#s.
  • Whether the guarded reads (zeros) let the cutscene draw correctly.

AI use

  • Claude Code, Claude Opus 5.5: wrote the code, the tests and this description.
**@⁠duudiis** on GitHub · 2026-11-24 13:18 UTC · [original](https://github.com/xcl-dev/xcl/pull/1215) `duudiis:pr/heap-index-bound` → `main` · +303 −18 · 9 files · 2 commits · open Translated shaders index `ResourceDescriptorHeap` with T# word 0 and `SamplerDescriptorHeap` with S# word 3 [11:0], and both come from console memory. If a T# was read from memory the GPU never wrote, the index can be anything. On NVIDIA an index past the heap wraps onto an unrelated slot, and if that slot holds a descriptor of the wrong kind the GPU hangs with no DRED page fault (device removal 0x887a0005). A retail title's cutscene reads T#s from memory that skipped GPU work was meant to write. This PR keeps those indices inside the heap. The shared heap now ends in null-view guard slots, and every data-derived heap index in a translated shader is bounded to them, so a garbage T# reads zeros and its stores are dropped. Idea from VIctory (GPL-3.0), reimplemented; no code taken. Overlaps #610 (draft): it also puts null views at the end of the heap and sends T# indices that are not views to them. The approaches differ. #610 fixes the heap at 1 000 000 views, checks word 0 against a compile-time constant and also checks word 3's TYPE. This PR keeps the heap at its OPTIONS19 size and passes the bound at run time in an io slot. It also bounds S# indices and fills shader-visible sampler heaps to 2048. The two conflict in `console_heap.rs`, `emit.rs` and `runner.rs`, so only one of them should land. **What is in it** - `D3D12.X: reserve null-view guard slots at the end of the shared heap`: - `hle/d3d12x/console_heap.rs`: the last 14 descriptors of the shared heap are guard slots. For each view kind the emitter declares (1D, 2D, 3D, CubeArray, 1DArray, 2DArray, 2DMS) there is a null SRV with a null UAV next to it, and no console heap is ever given these slots. `view_limit` returns the first guard slot when the shared heap is bound, and 0 otherwise or with `XCL_HEAP_CLAMP=0`. - `gpu/recomp/mod.rs`: `IO_VIEW_LIMIT` = io slot 113. Slot 112 is already `IO_UMA_BASE_HI`, so the new one goes next to it in the trap-temp range. Also adds `VIEW_GUARD_KINDS` and `SAMPLER_HEAP_SLOTS`. - `bind.rs`, `console_list.rs` and `list_x.rs` write the io slot for each translated draw and dispatch, from the heaps the list has bound. - `real.rs`: shader-visible PC sampler heaps get 2048 samplers. The slots past the title's are the zero S#'s point sampler. - `Recompiler: bound heap indices from T# and S# words to the heap` (`gpu/recomp/emit.rs`): - Each T# heap index (sample, get_lod, get_resinfo, load, store, atomics) becomes one select against `xcl_vlast = io[IO_VIEW_LIMIT] - 1`. - The UAV `+ 1` is applied after the bound. Before, word 0 0xFFFFFFFF wrapped the UAV index to 0. - S# indices become `min(s & 0xFFF, 2047)`. - Shaders that index no heap produce the same HLSL as before. - `gpu/recomp/runner.rs`: the kernel test runner puts the guard slots after the test textures and fills its sampler heap the same way the runtime does. **Tested** - NVIDIA GeForce RTX 5070 (12 GB), Intel Core i7-14700KF, Windows 11; Rust 1.98.0, release. - `cargo build --workspace --release`: ok. - `cargo test --workspace --release -- --test-threads=4` on `757ece9`: 744 passed, 0 failed, 41 ignored (lib: 701 passed, 0 failed, 21 ignored). - SKIPPED (no wave64): `gpu::recomp::tests::gpu_geometry_wave32_prefix_count_over_a_mask`, `gpu::recomp::tests::gpu_wave32_program_in_wave64_hardware`. - New tests: - `shared_heap_guard_slots` (`console_heap.rs`): passes. - `heap_indices_are_bounded` (`gpu/recomp/tests.rs`): passes, and fails with this head's `emit.rs` reverted. - `gpu_heap_index_past_the_views_reads_the_guard` (GPU): passes. On this NVIDIA GPU it also passes with `emit.rs` reverted, because the out-of-range reads there returned 0 and the stores were dropped. It shows that the guard path reads zeros and drops stores. It does not reproduce the hang. **Regression run** main (`47efa2e`): ``` xcl-smoke v1 commit: 47efa2ecea0a12934719ae69b81930cf02a4b1c3 gpu: NVIDIA GeForce RTX 5070 title: NYCMain seconds: 60 exit: 0x0 frames shown: 386 (PresentX 387) presents per 2 s (last 3): 11 11 14 device removals: 0 crashes: 0 peak commit: 15980 MB ``` This PR (`757ece9`): ``` xcl-smoke v1 commit: 757ece9795bc1f047661c77c039645d1893bb949 gpu: NVIDIA GeForce RTX 5070 title: NYCMain seconds: 60 exit: 0x0 frames shown: 1600 (PresentX 1600) presents per 2 s (last 3): 60 61 60 device removals: 0 crashes: 0 peak commit: 16739 MB ``` The main run went first with a cold shader and driver cache (both builds share the cache folder), so most of the frame difference is the cache, not this change. Both runs cover boot and the intro, not the cutscene that reads garbage T#s. **Not tested** - AMD GPUs. - The retail title past its intro with this exact head: the smoke runs stop at 60 s, before the cutscene that reads garbage T#s. - Whether the guarded reads (zeros) let the cutscene draw correctly. **AI use** - Claude Code, Claude Opus 5.5: wrote the code, the tests and this description.
Translated shaders index the shared shader-visible heap with T# word 0
and the sampler heap with S# word 3 [11:0], both read from console
memory. A T# from memory the GPU never wrote (a retail game's cutscene,
after skipped dispatches) gives an index anywhere: past the heap's end
NVIDIA is reported to wrap onto an unrelated slot, and a descriptor of
the wrong kind there hangs the GPU without a DRED page fault (device
removal 0x887a0005).

The shared heap's last 14 descriptors become guard slots, never given
to a console heap: per kind of view a translated shader declares
(Texture1D, 2D, 3D, CubeArray, 1DArray, 2DArray, 2DMS) a null SRV and
next to it a null UAV, written when the heap is made. The heap's size
depends on the GPU (OPTIONS19, at most 2^21), so the first guard slot
goes to the shaders in io[IO_VIEW_LIMIT] (113, in the trap-temp range
next to IO_UMA_BASE_HI) for every translated draw and dispatch that
binds the shared heap; 0 otherwise (a view heap of its own when the
shared heap could not be made) and with XCL_HEAP_CLAMP=0.

Shader-visible PC sampler heaps get all 2048 samplers D3D12 allows,
the ones past the title's slots the zero S#'s point sampler, so a
sampler index bounded to 2047 always names a sampler.

Nothing reads the io slot yet: the recompiler uses it in the next
commit.

Idea from VIctory (GPL-3.0), reimplemented; no code taken.

Assisted-by: Claude Code (Claude Opus 5.5)
Every ResourceDescriptorHeap index a translated shader takes from T#
word 0 (image sample / get_lod / get_resinfo / load / store / atomics)
is now one select: below io[IO_VIEW_LIMIT] it is itself, else the guard
slot of its view kind there (a null SRV, the UAV one next to it), so a
garbage T# reads zeros and its stores go nowhere instead of indexing
past the heap. The UAV index is taken after the bound: word 0
0xFFFFFFFF used to make it 0 (wrapped), the shared heap's first SRV, as
an RWTexture. The bound is loaded once in main (xcl_vlast = io - 1, so
an io slot of 0 leaves the indices as they were). Sampler heap indices
are min(S# word 3 & 0xFFF, 2047): 4095 was past any shader-visible
sampler heap.

Only shaders that index a heap change; the others' HLSL stays byte for
byte the same. emit.rs and mod.rs are translator sources, so the
translation caches' identity changes with them.

The kernel test runner puts the guard slots after the test textures and
fills its sampler heap like the runtime's.

Assisted-by: Claude Code (Claude Opus 5.5)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:47:23 +00:00
Author
Owner

@⁠Aniseto on GitHub · 2026-11-24 13:25 UTC · original

Ran the new heap-bound tests on an NVIDIA Blackwell part at 757ece9:

Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build.

XCL_ADAPTER=nvidia cargo test -p xcl --lib heap_indices
1 passed; 0 failed; 0 ignored      (exit 0)

XCL_ADAPTER=nvidia cargo test -p xcl --lib gpu_heap_index
1 passed; 0 failed; 0 ignored      (exit 0)

XCL_ADAPTER=nvidia cargo test -p xcl --lib console_heap
4 passed; 0 failed; 0 ignored      (exit 0)

gpu_heap_index_past_the_views_reads_the_guard runs on the GPU here and reads the guard slot as expected; heap_indices_are_bounded and the console-heap unit set are unaffected. This is a debug build on a Blackwell part with driver 32.0.16.2124 (the author's run was release on an RTX 5070).

Not tested: retail titles, RDNA2/RDNA4 and Intel GPUs, Wine, native wave64.

AI-assisted (OpenCode), model: DeepSeek V4.1 Flash 1017 - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified.

**@⁠Aniseto** on GitHub · 2026-11-24 13:25 UTC · [original](https://github.com/xcl-dev/xcl/pull/1215#issuecomment-7132805973) Ran the new heap-bound tests on an NVIDIA Blackwell part at `757ece9`: Environment: Windows 11 Pro build 26200 x64, NVIDIA GeForce RTX 5070 Ti (Blackwell, wave32 only, 16 GB) driver 32.0.16.2124, Intel Core i5-12400F, 64 GB RAM, rustc 1.100.0 (0ef1bc386 2026-11-09) MSVC 14.44.35207, DXC 1.9.2609.5, debug build. ``` XCL_ADAPTER=nvidia cargo test -p xcl --lib heap_indices 1 passed; 0 failed; 0 ignored (exit 0) XCL_ADAPTER=nvidia cargo test -p xcl --lib gpu_heap_index 1 passed; 0 failed; 0 ignored (exit 0) XCL_ADAPTER=nvidia cargo test -p xcl --lib console_heap 4 passed; 0 failed; 0 ignored (exit 0) ``` `gpu_heap_index_past_the_views_reads_the_guard` runs on the GPU here and reads the guard slot as expected; `heap_indices_are_bounded` and the console-heap unit set are unaffected. This is a debug build on a Blackwell part with driver 32.0.16.2124 (the author's run was release on an RTX 5070). Not tested: retail titles, RDNA2/RDNA4 and Intel GPUs, Wine, native wave64. AI-assisted (OpenCode), model: **DeepSeek V4.1 Flash 1017** - checked out the PR's head commit in a detached worktree, built it, ran the tests, wrote this report; the worktree was not modified.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-24 13:47 UTC · original

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib recomp: 191 passed, 0 failed.

Note: the full d3d12x lib filter currently aborts with 0xc0000005 on unmodified main too (pre-existing, unrelated to this PR); the PR's own tests were run by name and pass.

**@⁠DavidM1911** on GitHub · 2026-11-24 13:47 UTC · [original](https://github.com/xcl-dev/xcl/pull/1215#issuecomment-7133335161) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - cargo test -p xcl --lib recomp: 191 passed, 0 failed. Note: the full `d3d12x` lib filter currently aborts with 0xc0000005 on unmodified `main` too (pre-existing, unrelated to this PR); the PR's own tests were run by name and pass.
Author
Owner

@⁠jessenic on GitHub · 2026-11-25 09:59 UTC · original

A measurement that supports this PR's explanation of the 0x887a0005 removal, from a retail title on an RTX 5070 Ti, on a tree without this PR. I'm now testing the PR on the same setup and will add the result here.

Setup: RTX 5070 Ti 16 GB (driver 610.88), Windows 11 Pro 26300, release, Series S profile. A local integration branch on main 8f5fca5 with #1323, #1405, #1464, #1291, #1342, #1156, #2009, #1993 and others. XCL_HEAP_WINDOWS=1 XCL_COHERENT_HEAPS=sparse:256. The title reaches the intro cutscene's title card and then loses the device 7–9 s after its first #101, in every run (about 10 so far). DRED shows no list in progress and no page fault, and Windows logs no TDR event (nvlddmkm) for it.

Where the removal comes from: cdb attached to the game at #101, with breakpoints on D3D12Core!*RemoveDevice* (public Microsoft symbols):

  • The device is removed inside an ExecuteCommandLists, in two runs one of XCL's own sparse uploads (sparse::State::submit_slot). The chain is nvwgf2umx → D3D12Core!CDevice::UMSetError_ → CDevice::ProcessDriverErrors → NDXGI::CDevice::RemoveDevice.
  • The error the NVIDIA user-mode driver passes to UMSetError_ is 0x88760870 (D3DDDIERR_DEVICEREMOVED). So the list submitted then is not the cause. The kernel had already marked the device lost, and the next submission found out.
  • The kernel's device execution state, the 5th argument of CD3D12TelemetryHelper::LogRemoveDeviceEvent, is 6, D3DKMT_DEVICEEXECUTION_ERROR_DMAFAULT. It is not a page fault (7), a hang (3) or out of memory (5).

A DMA fault with no page fault and no TDR fits what this PR describes: the GPU stops on a heap index that lands on a descriptor of the wrong kind. Two more things about main's guard, seen while applying this PR on top of it:

  • main's MIMG guard (5195e27) passes any word 0 below 2 097 151. The shared heap is smaller than that, so an index between its end and 2M still runs past it.
  • Its implicit-LOD sample path sends an invalid T# to heap index 0. With XCL_HEAP_WINDOWS=1, slot 0 is memory window 0's raw buffer UAV, so a T# that fails the check samples a buffer UAV as a texture.

When I combined this PR with main's guard, I sent the invalid-T# fallback to xcl_vlast + 1u (the guard slot when the heap is bounded, 0 when it is not), not to 0. That may be worth doing in the PR if it gets rebased onto main.

AI use: Claude Code (Claude Opus 5.5) ran the debugger sessions on the machine above and wrote this note.

**@⁠jessenic** on GitHub · 2026-11-25 09:59 UTC · [original](https://github.com/xcl-dev/xcl/pull/1215#issuecomment-7159064976) **A measurement that supports this PR's explanation of the `0x887a0005` removal, from a retail title on an RTX 5070 Ti, on a tree without this PR.** I'm now testing the PR on the same setup and will add the result here. **Setup:** RTX 5070 Ti 16 GB (driver 610.88), Windows 11 Pro 26300, release, Series S profile. A local integration branch on `main` `8f5fca5` with #1323, #1405, #1464, #1291, #1342, #1156, #2009, #1993 and others. `XCL_HEAP_WINDOWS=1 XCL_COHERENT_HEAPS=sparse:256`. The title reaches the intro cutscene's title card and then loses the device 7–9 s after its first `#101`, in every run (about 10 so far). DRED shows no list in progress and no page fault, and Windows logs no TDR event (`nvlddmkm`) for it. **Where the removal comes from:** cdb attached to the game at `#101`, with breakpoints on `D3D12Core!*RemoveDevice*` (public Microsoft symbols): - The device is removed inside an `ExecuteCommandLists`, in two runs one of XCL's own sparse uploads (`sparse::State::submit_slot`). The chain is `nvwgf2umx` → `D3D12Core!CDevice::UMSetError_` → `CDevice::ProcessDriverErrors` → `NDXGI::CDevice::RemoveDevice`. - The error the NVIDIA user-mode driver passes to `UMSetError_` is `0x88760870` (`D3DDDIERR_DEVICEREMOVED`). So the list submitted then is not the cause. The kernel had already marked the device lost, and the next submission found out. - The kernel's device execution state, the 5th argument of `CD3D12TelemetryHelper::LogRemoveDeviceEvent`, is **6, `D3DKMT_DEVICEEXECUTION_ERROR_DMAFAULT`**. It is not a page fault (7), a hang (3) or out of memory (5). A DMA fault with no page fault and no TDR fits what this PR describes: the GPU stops on a heap index that lands on a descriptor of the wrong kind. Two more things about `main`'s guard, seen while applying this PR on top of it: - `main`'s MIMG guard (`5195e27`) passes any word 0 below 2 097 151. The shared heap is smaller than that, so an index between its end and 2M still runs past it. - Its implicit-LOD sample path sends an invalid T# to heap index 0. With `XCL_HEAP_WINDOWS=1`, slot 0 is memory window 0's raw buffer UAV, so a T# that fails the check samples a buffer UAV as a texture. When I combined this PR with `main`'s guard, I sent the invalid-T# fallback to `xcl_vlast + 1u` (the guard slot when the heap is bounded, 0 when it is not), not to 0. That may be worth doing in the PR if it gets rebased onto `main`. **AI use:** Claude Code (Claude Opus 5.5) ran the debugger sessions on the machine above and wrote this note.
Author
Owner

@⁠jessenic on GitHub · 2026-11-25 14:12 UTC · original

Follow-up to my note above: with this PR, the removal 7–9 s after the title's first #101 is gone in 3 of 3 runs on the RTX 5070 Ti. Without the PR it happened in every run (about 10).

Same tree and setup as the note: the PR's two commits were cherry-picked onto the integration branch, with the conflicts against main's 5195e27 guard resolved as described there. Every compute pipeline was precompiled for the new translation first (12 threads, 3.8 h). Pixel and vertex programs were not precompiled.

run first #101 how it ends
1 (a second precompile was using the CPU and GPU) 355 s no removal until the run ended at 420 s; no presents after #101 + 2 s
2 195 s the same: no removal in 225 s, no presents after #101 + 2 s
3 191 s 0x887a0005 at 284 s, #101 + 94 s
  • The silence after #101 is not a hang on the GPU. A thread dump (cdb attached 20 s after #101, then detached) shows the title's render thread in bind::graphics_bound → pso_async::resolve_wait, waiting for a graphics pipeline that is still being built. One thread is in DXC and the other pipeline workers are idle. This PR changes the HLSL of every pixel and vertex program that reads an image, so on a cold cache the world's first draws wait for DXC and the driver. Graphics pipelines of 0.74 MB of DXIL took about 9 s each in the driver. #1798 (a draw does not wait for a graphics pipeline still being built), or precompiling --only ps / --only vs, should cover this.
  • Run 3's removal came 1.2 s after one of those huge graphics pipelines finished building (huge, wanted at once). So it is a later and different fault, probably the world's own mesh and pixel programs. The textured-world report on #505 explains why those read garbage descriptors without #1803 (the heaps' addresses in the user SGPRs). I'm testing a tree with #1803 next.

Not tested: AMD; Series X; more than 3 runs; a scripts/smoke.ps1 regression run; this PR alone on main.

AI use: Claude Code (Claude Opus 5.5) ran the runs and the debugger on the machine above and wrote this comment.

**@⁠jessenic** on GitHub · 2026-11-25 14:12 UTC · [original](https://github.com/xcl-dev/xcl/pull/1215#issuecomment-7164919059) **Follow-up to [my note above](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1215): with this PR, the removal 7–9 s after the title's first `#101` is gone in 3 of 3 runs on the RTX 5070 Ti.** Without the PR it happened in every run (about 10). Same tree and setup as the note: the PR's two commits were cherry-picked onto the integration branch, with the conflicts against `main`'s `5195e27` guard resolved as described there. Every compute pipeline was precompiled for the new translation first (12 threads, 3.8 h). Pixel and vertex programs were not precompiled. | run | first `#101` | how it ends | |---|---|---| | 1 (a second precompile was using the CPU and GPU) | 355 s | no removal until the run ended at 420 s; no presents after `#101` + 2 s | | 2 | 195 s | the same: no removal in 225 s, no presents after `#101` + 2 s | | 3 | 191 s | `0x887a0005` at 284 s, **`#101` + 94 s** | - **The silence after `#101` is not a hang on the GPU.** A thread dump (cdb attached 20 s after `#101`, then detached) shows the title's render thread in `bind::graphics_bound` → `pso_async::resolve_wait`, waiting for a graphics pipeline that is still being built. One thread is in DXC and the other pipeline workers are idle. This PR changes the HLSL of every pixel and vertex program that reads an image, so on a cold cache the world's first draws wait for DXC and the driver. Graphics pipelines of 0.74 MB of DXIL took about 9 s each in the driver. #1798 (a draw does not wait for a graphics pipeline still being built), or precompiling `--only ps` / `--only vs`, should cover this. - **Run 3's removal came 1.2 s after one of those huge graphics pipelines finished building** (`huge, wanted at once`). So it is a later and different fault, probably the world's own mesh and pixel programs. The textured-world report on #505 explains why those read garbage descriptors without #1803 (the heaps' addresses in the user SGPRs). I'm testing a tree with #1803 next. **Not tested:** AMD; Series X; more than 3 runs; a `scripts/smoke.ps1` regression run; this PR alone on `main`. **AI use:** Claude Code (Claude Opus 5.5) ran the runs and the debugger on the machine above and wrote this comment.
Author
Owner

@⁠jessenic on GitHub · 2026-11-25 15:28 UTC · original

Correction to my comment above: "gone in 3 of 3" was wrong. With a warm cache, this PR delays the removal; it does not prevent it.

In those three runs the world drew almost nothing after #101. Draws waited for the graphics pipelines this PR's changed HLSL had made cold, and run 3's removal came as soon as drawing resumed. So those runs could not tell "fixed" from "delayed".

Run 4 had the graphics driver blobs from runs 1–3 already cached. Same tree and switches, cdb attached at #101 with a breakpoint on CD3D12TelemetryHelper::LogRemoveDeviceEvent:

  • the world drew from #101 on (up to about 980 draws every 2 s, 1–2 presents every 2 s);
  • the device was removed at #101 + 18.7 s, with execution state 6 (D3DKMT_DEVICEEXECUTION_ERROR_DMAFAULT) and 0x887a0005, as without the PR.

Without the PR this removal came at #101 + 7–9 s. With it, it came at + 18.7 s in this one warm run, so the PR may move it, but one run is not enough to say. The fault itself is still there on this tree. My guess in the earlier comment, "a later and different fault", is not supported: the kernel's reason is the same.

I'm next checking whether the page budget's evictions take part (a run without XCL_PAGE_BUDGET_MB), and testing a tree with #1803.

AI use: Claude Code (Claude Opus 5.5) ran the run and the debugger and wrote this correction.

**@⁠jessenic** on GitHub · 2026-11-25 15:28 UTC · [original](https://github.com/xcl-dev/xcl/pull/1215#issuecomment-7166910579) **Correction to [my comment above](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1215): "gone in 3 of 3" was wrong. With a warm cache, this PR delays the removal; it does not prevent it.** In those three runs the world drew almost nothing after `#101`. Draws waited for the graphics pipelines this PR's changed HLSL had made cold, and run 3's removal came as soon as drawing resumed. So those runs could not tell "fixed" from "delayed". Run 4 had the graphics driver blobs from runs 1–3 already cached. Same tree and switches, cdb attached at `#101` with a breakpoint on `CD3D12TelemetryHelper::LogRemoveDeviceEvent`: - the world drew from `#101` on (up to about 980 draws every 2 s, 1–2 presents every 2 s); - the device was removed at `#101` + 18.7 s, with execution state 6 (`D3DKMT_DEVICEEXECUTION_ERROR_DMAFAULT`) and `0x887a0005`, as without the PR. Without the PR this removal came at `#101` + 7–9 s. With it, it came at + 18.7 s in this one warm run, so the PR may move it, but one run is not enough to say. The fault itself is still there on this tree. My guess in the earlier comment, "a later and different fault", is not supported: the kernel's reason is the same. I'm next checking whether the page budget's evictions take part (a run without `XCL_PAGE_BUDGET_MB`), and testing a tree with #1803. **AI use:** Claude Code (Claude Opus 5.5) ran the run and the debugger and wrote this correction.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-26 04:05 UTC · original

Re-verification on RTX 3060 Ti (Windows 11): still a merge conflict with current main on the new head — needs another rebase before it can be tested.

**@⁠DavidM1911** on GitHub · 2026-11-26 04:05 UTC · [original](https://github.com/xcl-dev/xcl/pull/1215#issuecomment-7182287485) Re-verification on RTX 3060 Ti (Windows 11): still a **merge conflict with current `main`** on the new head — needs another 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
  • crates/xcl/src/hle/d3d12x/console_list.rs
  • crates/xcl/src/hle/d3d12x/list_x.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/1215/head:github-bot/gh-1215'
git switch 'github-bot/gh-1215'

Merge

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