Skip to content

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

Closed
edsuuu wants to merge 2 commits into
Marvisak:mainfrom
edsuuu:pr/table-offset-past-heap
Closed

edsuuu wants to merge 2 commits into
Marvisak:mainfrom
edsuuu:pr/table-offset-past-heap

Conversation

@edsuuu

@edsuuu edsuuu commented Nov 24, 2026 •

Copy link
Copy Markdown

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, Shaders: translate for the host's wave sizes #223/Shaders: wave64 compute on 32-lane hosts, in halves and in the console flow #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 (Loader: opt-in VICTORY_NO_WATCHDOG hook for the title's watchdog (build 1.0.2.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 (fmt: Format all files #502 reformats them); this change adds none. After merging main @ffe310e (to resolve the conflict with GPU: drop draws whose fresh tables cannot be made; 2^18 dynamic slots #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

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 <noreply@anthropic.com>

@LAKSHYA-cmd-tech LAKSHYA-cmd-tech left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verified on Windows 11 D3D12 (WARP):

  • All 43 \�ictory-gpu\ tests pass, clippy clean.
  • The fix correctly prevents device hangs on NVIDIA by dropping draws/dispatches whose table offsets exceed the capped host heap (1,000,000 descriptors), instead of letting shaders index past the heap end and read garbage descriptors.
  • \�ind()\ returning \�ool\ cleanly propagates through \prepare, \dispatch, and indirect execution.
  • \past_host_heap()\ check is scoped to the specific slot, only drops when necessary.
  • Asset policy passes (151 files ok).

@rpmaster2

rpmaster2 commented Nov 24, 2026 •

Copy link
Copy Markdown

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 (comment)

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.

@mercuryVM mercuryVM left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested a8be528 on Windows 11, RTX 5070, MSVC: cargo test -p victory-gpu -- --test-threads=1 43 passed, and with --features diagnostics 45 passed. Clippy's 1 warning is the existing one in host.rs.

  • This is the CPU-side check that a heap bound needs. past_host_heap compares the table's title index against the host heap the draw actually binds (host.count()). So it catches exactly the slots a capped heap left out, whatever the cap is, and drops the draw with a one-time log instead of handing the shader an offset past the end.
  • bind returning bool, with every caller honouring it (draw, dispatch, the mesh/compute path), keeps a dropped table from leaving a half-bound root signature behind.

AI-assisted (Claude Code).

mercuryVM added a commit to mercuryVM/VIctory that referenced this pull request Nov 24, 2026
…et past the host heap

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…heap

# Conflicts:
#	crates/victory-gpu/src/draw.rs
@nopsled0x

Copy link
Copy Markdown

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

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).

Machad3x pushed a commit to Machad3x/VIctory that referenced this pull request Nov 24, 2026
…sak#550)

On NVIDIA the shader-visible view heap is capped at 1,000,000 descriptors
while the title's is 1,245,184, so title slots past the cap ('title slot
past the host heap') have no host slot. When a table there could not be
made afresh, the draw fell back to the title's offset and the shader read
past the heap's end: garbage descriptors, then device hang. Dropping that
draw trades a removed device for one missing draw.

Merged with the root-view size bound (Marvisak#650) in State::bind: both fallbacks
kept. No unit test upstream: the path needs a bound heap on a live device.

Targets symptom 1 (title slot past the host heap).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Machad3x pushed a commit to Machad3x/VIctory that referenced this pull request Nov 24, 2026
…heap runs short (PR Marvisak#688)

A capped view heap (NVIDIA, 1,000,000) keeps only MIN_DYNAMIC slots past
the title's for tables made afresh per draw. A list holds its slots until
the title resets it; when the pool runs dry mid-frame the draws fell back
to a title offset (now: dropped by Marvisak#550). The lease lets a draw reclaim
slots from lists whose submissions already ran.

Conflict was only the tests module (both sides added tests): both kept.
Upstream adds its own unit tests (lease.rs, heap capacity tests).

Targets symptoms 1 and 2 (draws lost once the dynamic range runs out).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@YaBulochka

Copy link
Copy Markdown

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.

yourmomsbasement pushed a commit to yourmomsbasement/VIctory_Dev that referenced this pull request Nov 24, 2026
…ied together

Merges Marvisak#72 Marvisak#347 Marvisak#1000 Marvisak#358 Marvisak#352 Marvisak#626 Marvisak#1152 Marvisak#1129 Marvisak#1203 Marvisak#24 Marvisak#642 Marvisak#427 Marvisak#485
Marvisak#550 Marvisak#174 Marvisak#1279 onto main (ffe310e), each head unchanged, no conflicts.

One change of mine: three of the PRs each add a `mod tests` at the end of
pipeline/host.rs, so the merge defines `tests` three times (E0428). The
second and third are named `library_tests` and `blend_tests`; nothing else
changes.

cargo clippy --workspace --all-targets --locked -- -D warnings, with and
without --all-features, is clean and cargo test --workspace --locked passes
(367 passed, 6 ignored; main has 342 passed, 6 ignored).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
yourmomsbasement pushed a commit to yourmomsbasement/VIctory_Dev that referenced this pull request Nov 24, 2026
draw.rs keeps both the breadcrumb user-data arm (Marvisak#1081) and the past-host-heap drop (Marvisak#550). indirect.rs takes the bundle's Wine-compiler clamp (Marvisak#1279), the same fix Marvisak#994 carried.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
github-actions Bot added a commit to KevinPratap/VIctory that referenced this pull request Nov 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants