GPU: never give a shader a table offset past the host heap #550

Closed
github-bot wants to merge 2 commits from gh-pr/550/head into gh-pr/550/base
Owner

@⁠edsuuu on GitHub · 2026-11-24 04:46 UTC · original
edsuuu:pr/table-offset-past-heap → main · +23 −0 · 1 files · 2 commits · closed without merging

What

On NVIDIA the shader-visible view heap is capped at 1,000,000 descriptors (CreateDescriptorHeap fails above it; the RTX 4060 Ti also reports MaxViewDescriptorHeapSize = 1,000,000), while Grand Theft Auto VI asks for 1,245,184. HostHeap::new then mirrors the title's first slots one to one and leaves the rest out, so title slots past the cap have no host slot.

Tables that reach past the cap are made afresh (State::tables), but when that fails — no free dynamic slot (the 65,536 of a capped heap run out seconds into the world), or the table's entries reach past the title heap's end — the draw fell back to the title's offset as its user data. The shader then indexed ResourceDescriptorHeap past the end of the host heap, read garbage descriptors, and the device hung (DXGI_ERROR_DEVICE_HUNG, the world hang in #71).

DRED evidence from three hangs on an RTX 4060 Ti: 13 of 14, 22 of 29 and 20 of 29 of the tables bound by the unfinished draws started past slot 1,000,000 (the title's per-draw tables sit at the top of its heap, around 1.2 million).

This change drops such a draw or dispatch (warned once) instead of giving the shader an offset past the heap: a missing draw instead of a removed device. Since #336, State::bind returns whether the draw may run and its callers skip it when it may not; this adds the past-heap case there. It does not make those draws render; that needs the title's slots past the cap to be remapped (the existing shortcut: in HostHeap::new).

Relates to #71.

Tested

  • Hardware: NVIDIA GeForce RTX 4060 Ti 8 GB (driver 621.24), Intel Core i7-13700K, 64 GB RAM, Windows 11 Pro build 26300. Title build 1.0.2.1 (Xbox Series X|S dump).
  • In game: on a branch with main plus other open PRs merged (wave64 as two 32-lane halves, #223/#233, needed to reach the world on NVIDIA), with cargo build --profile diag -p victory --features diagnostics, VICTORY_D3D12_DRED=1 and VICTORY_NO_WATCHDOG=1 (#454). Before this change every world run hung the device 30 to 90 s after the first mesh draws. After it, two runs of several minutes each reached the world's first frames with no device hung and no DRED report.
  • On this branch (main alone): cargo test --workspace (264 passed, 0 failed), cargo clippy --workspace --all-targets (no new warnings; the one left, host.rs:267 unsafe block without a safety comment, is on main too), cargo xtask policy (151 files ok). cargo fmt --check reports differences that are already on main (#502 reformats them); this change adds none. After merging main @⁠ffe310e (to resolve the conflict with #336): cargo test -p victory-gpu 50 passed, 0 failed; cargo clippy -p victory-gpu --all-targets no warnings. Not run in game on main alone: main does not reach the world on NVIDIA without the wave64 PRs.
  • Not tested on AMD; the new path only triggers when the host heap is capped, which it is not on the RX 6700 XT the README lists.

Checklist

  • cargo fmt, cargo clippy --workspace --all-targets and cargo test --workspace pass (fmt and clippy: only what main already reports, see above).
  • cargo xtask policy passes. The change adds no game files or data taken from them (docs/asset-policy.md).
  • If an AI tool wrote part of this change, the description says so.

The change, the investigation of the DRED reports and this description were written with Claude Code (Claude Opus 5.5) and tested on the machine above.

🤖 Generated with Claude Code

**@⁠edsuuu** on GitHub · 2026-11-24 04:46 UTC · [original](https://github.com/Marvisak/VIctory/pull/550) `edsuuu:pr/table-offset-past-heap` → `main` · +23 −0 · 1 files · 2 commits · closed without merging ## What On NVIDIA the shader-visible view heap is capped at 1,000,000 descriptors (`CreateDescriptorHeap` fails above it; the RTX 4060 Ti also reports `MaxViewDescriptorHeapSize` = 1,000,000), while Grand Theft Auto VI asks for 1,245,184. `HostHeap::new` then mirrors the title's first slots one to one and leaves the rest out, so title slots past the cap have no host slot. Tables that reach past the cap are made afresh (`State::tables`), but when that fails — no free dynamic slot (the 65,536 of a capped heap run out seconds into the world), or the table's entries reach past the title heap's end — the draw fell back to the title's offset as its user data. The shader then indexed `ResourceDescriptorHeap` past the end of the host heap, read garbage descriptors, and the device hung (`DXGI_ERROR_DEVICE_HUNG`, the world hang in #71). DRED evidence from three hangs on an RTX 4060 Ti: 13 of 14, 22 of 29 and 20 of 29 of the tables bound by the unfinished draws started past slot 1,000,000 (the title's per-draw tables sit at the top of its heap, around 1.2 million). This change drops such a draw or dispatch (warned once) instead of giving the shader an offset past the heap: a missing draw instead of a removed device. Since #336, `State::bind` returns whether the draw may run and its callers skip it when it may not; this adds the past-heap case there. It does not make those draws render; that needs the title's slots past the cap to be remapped (the existing `shortcut:` in `HostHeap::new`). Relates to #71. ## Tested - Hardware: NVIDIA GeForce RTX 4060 Ti 8 GB (driver 621.24), Intel Core i7-13700K, 64 GB RAM, Windows 11 Pro build 26300. Title build 1.0.2.1 (Xbox Series X|S dump). - In game: on a branch with main plus other open PRs merged (wave64 as two 32-lane halves, #223/#233, needed to reach the world on NVIDIA), with `cargo build --profile diag -p victory --features diagnostics`, `VICTORY_D3D12_DRED=1` and `VICTORY_NO_WATCHDOG=1` (#454). Before this change every world run hung the device 30 to 90 s after the first mesh draws. After it, two runs of several minutes each reached the world's first frames with no device hung and no DRED report. - On this branch (main alone): `cargo test --workspace` (264 passed, 0 failed), `cargo clippy --workspace --all-targets` (no new warnings; the one left, `host.rs:267` unsafe block without a safety comment, is on main too), `cargo xtask policy` (151 files ok). `cargo fmt --check` reports differences that are already on main (#502 reformats them); this change adds none. After merging main @⁠ffe310e (to resolve the conflict with #336): `cargo test -p victory-gpu` 50 passed, 0 failed; `cargo clippy -p victory-gpu --all-targets` no warnings. Not run in game on main alone: main does not reach the world on NVIDIA without the wave64 PRs. - Not tested on AMD; the new path only triggers when the host heap is capped, which it is not on the RX 6700 XT the README lists. ## Checklist - [x] `cargo fmt`, `cargo clippy --workspace --all-targets` and `cargo test --workspace` pass (fmt and clippy: only what main already reports, see above). - [x] `cargo xtask policy` passes. The change adds no game files or data taken from them (`docs/asset-policy.md`). - [x] If an AI tool wrote part of this change, the description says so. The change, the investigation of the DRED reports and this description were written with Claude Code (Claude Opus 5.5) and tested on the machine above. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
A draw whose table starts at a title slot the capped host heap does not
have, and that was not made afresh, got the title's offset as its user
data; the shader then indexed ResourceDescriptorHeap past the heap's end.
On NVIDIA that reads garbage descriptors and the device hangs (#71). In
three DRED reports from an RTX 4060 Ti, 13 of 14, 22 of 29 and 20 of 29
of the tables the unfinished draws bound start past slot 1,000,000 (the
title's per-draw tables sit at its heap's top, around 1.2 million).

Such tables are made afresh, but when that fails (no free dynamic slot:
the 65,536 of a capped heap run out seconds into the world; or entries
reaching past the title heap's end) the draw fell back to the title's
offset. The draw or dispatch is dropped instead.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
# Conflicts:
#	crates/victory-gpu/src/draw.rs
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:07:58 +00:00
github-bot closed this pull request 2026-11-26 04:07:58 +00:00
Author
Owner

@⁠nopsled0x on GitHub · 2026-11-24 12:15 UTC · original

Tested #550 (head 8560817, on top of main ffe310e) combined with #175 (Agility SDK, needed on Windows 10 for SM 6.6). One run, diagnostics build, VICTORY_D3D12_DRED=1, VICTORY_D3D12_DEBUG=1, 240 s limit.

Host: RTX 5060 Ti, Windows 10 22H2.

Measured

  • past the host heap appears 0 times: the new guard did not trigger in this run.
  • no free dynamic descriptor slots: a table is not made appears once (n=12), about 51 s before the removal.
  • DXGI_ERROR_DEVICE_HUNG (0x887A0006) about 100 s after the first shader translation; host device removed after a submission of 30 lists; the process exited with a host GPU failure.
  • 0x80070057 (E_INVALIDARG) on 118 lines: 115 host pipeline refusals, 2 host texture creations, 1 "host view heap capped at 1000000".
  • The debug layer reported 40 IASetVertexBuffers resource-state errors (buffer in UNORDERED_ACCESS); one is logged right before the removal. I have not established that it is related.

Not established

  • Whether the hang happens in a main + #175 run without #550: my earlier #175-only runs varied (one with no removal, one with 2, see #732), so this single run is not an A/B.
  • Which draw or dispatch the hang came from.

So on this card, in this run, the #550 guard did not trigger and the device was still removed. The guard result agrees with the AMD report above; the failure pattern differs (n=12 well before the removal, 30 lists, vs n=133 right before it, 1 list), and I have no baseline to say the crash is unchanged.

AI-assisted (Claude Code).

**@⁠nopsled0x** on GitHub · 2026-11-24 12:15 UTC · [original](https://github.com/Marvisak/VIctory/pull/550#issuecomment-7131179826) Tested #550 (head 8560817, on top of main ffe310e) combined with #175 (Agility SDK, needed on Windows 10 for SM 6.6). One run, diagnostics build, `VICTORY_D3D12_DRED=1`, `VICTORY_D3D12_DEBUG=1`, 240 s limit. **Host:** RTX 5060 Ti, Windows 10 22H2. **Measured** - `past the host heap` appears 0 times: the new guard did not trigger in this run. - `no free dynamic descriptor slots: a table is not made` appears once (n=12), about 51 s before the removal. - `DXGI_ERROR_DEVICE_HUNG` (0x887A0006) about 100 s after the first shader translation; host device removed after a submission of 30 lists; the process exited with a host GPU failure. - `0x80070057` (E_INVALIDARG) on 118 lines: 115 host pipeline refusals, 2 host texture creations, 1 "host view heap capped at 1000000". - The debug layer reported 40 `IASetVertexBuffers` resource-state errors (buffer in UNORDERED_ACCESS); one is logged right before the removal. I have not established that it is related. **Not established** - Whether the hang happens in a main + #175 run without #550: my earlier #175-only runs varied (one with no removal, one with 2, see https://git.gtahub.st/github/Marvisak--VIctory/issues/732), so this single run is not an A/B. - Which draw or dispatch the hang came from. So on this card, in this run, the #550 guard did not trigger and the device was still removed. The guard result agrees with the AMD report above; the failure pattern differs (n=12 well before the removal, 30 lists, vs n=133 right before it, 1 list), and I have no baseline to say the crash is unchanged. AI-assisted (Claude Code).
Author
Owner

@⁠rpmaster2 on GitHub · 2026-11-24 08:32 UTC · original · edited 2026-11-24 12:31 UTC

Tested on top of main @⁠1f858b0 (diag profile): Radeon RX 9070 XT 16 GB (RDNA4), Adrenalin 26.11.2 (32.0.32029.2010), Windows 11 26300, Ryzen 5 5600, 32 GB RAM, pagefile 32/48 GB.

Result: this change does not trigger on this host and the crash is unchanged.

  • past the host heap appears 0 times in the full log (it did appear on an earlier build, so the guard itself works).
  • no free dynamic descriptor slots: a table is not made n=133 still appears right before the removal.
  • Host device removed with 0x887A0004 / 0x887A0006 before the first cutscene, after a submission of 1 list.

Timeline of the run: menus at 30 fps; world entry; 0.7-0.9 fps at 500-2400 draws/frame with 390-590 pipelines being made and 800-2700 indirect; n=133; TDR ~4 s later.

So on this GPU/driver the failing table does not sit past the host heap - it cannot be created at all because the dynamic slot pool is already full. The diagnostics in aycow:gpu/descriptor-allocation-demand @⁠82e4aa6 show ~13.9k new local tables / ~71.5k slots at the first failed rebuilt table, dominated by width 16 (8.5k tables / 60.2k slots) and width 256 (167 / 23.1k), with most of the Mixed demand flagged duplicate_untracked.

Details and the full counters: #597

No game data in this report: counts, driver version and error strings only.

AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and observations; the hardware, the dump and the runs are mine.

**@⁠rpmaster2** on GitHub · 2026-11-24 08:32 UTC · [original](https://github.com/Marvisak/VIctory/pull/550#issuecomment-7126255282) · edited 2026-11-24 12:31 UTC Tested on top of `main` @⁠1f858b0 (diag profile): Radeon RX 9070 XT 16 GB (RDNA4), Adrenalin 26.11.2 (32.0.32029.2010), Windows 11 26300, Ryzen 5 5600, 32 GB RAM, pagefile 32/48 GB. Result: this change does not trigger on this host and the crash is unchanged. - `past the host heap` appears 0 times in the full log (it did appear on an earlier build, so the guard itself works). - `no free dynamic descriptor slots: a table is not made n=133` still appears right before the removal. - Host device removed with 0x887A0004 / 0x887A0006 before the first cutscene, after a submission of 1 list. Timeline of the run: menus at 30 fps; world entry; 0.7-0.9 fps at 500-2400 draws/frame with 390-590 pipelines being made and 800-2700 indirect; `n=133`; TDR ~4 s later. So on this GPU/driver the failing table does not sit past the host heap - it cannot be created at all because the dynamic slot pool is already full. The diagnostics in `aycow:gpu/descriptor-allocation-demand` @⁠82e4aa6 show ~13.9k new local tables / ~71.5k slots at the first failed rebuilt table, dominated by width 16 (8.5k tables / 60.2k slots) and width 256 (167 / 23.1k), with most of the Mixed demand flagged `duplicate_untracked`. Details and the full counters: https://git.gtahub.st/github/Marvisak--VIctory/issues/597 No game data in this report: counts, driver version and error strings only. AI-assisted: written by DeepSeek (OpenCode harness) from my run logs and observations; the hardware, the dump and the runs are mine.
Author
Owner

@⁠YaBulochka on GitHub · 2026-11-24 17:41 UTC · original

Confirming the diagnosis with numbers from a Linux/RADV run (Mesa 26.3.1, RX 7600 XT, Wine 11.22 on a Proton prefix):

  • the prologue asks for 1,245,184 views;
  • the host caps at 1,000,000 and HostHeap::new mirrors 934,464;
  • exactly 310,720 slots are then left without a host slot — one warning each, index=934464…1245183.

So on this title it is not a rare edge: a quarter of the view heap is outside the mirror, and the title writes all of it at start-up. Dropping the tail is what shows up as the checkerboard/stripe artifacts while the loading screen is up. Nothing needed from you, just the data point.

**@⁠YaBulochka** on GitHub · 2026-11-24 17:41 UTC · [original](https://github.com/Marvisak/VIctory/pull/550#issuecomment-7139569395) Confirming the diagnosis with numbers from a Linux/RADV run (Mesa 26.3.1, RX 7600 XT, Wine 11.22 on a Proton prefix): - the prologue asks for **1,245,184** views; - the host caps at 1,000,000 and `HostHeap::new` mirrors **934,464**; - exactly **310,720** slots are then left without a host slot — one warning each, `index=934464…1245183`. So on this title it is not a rare edge: a quarter of the view heap is outside the mirror, and the title writes all of it at start-up. Dropping the tail is what shows up as the checkerboard/stripe artifacts while the loading screen is up. Nothing needed from you, just the data point.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No reviewers
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!550
No description provided.