Skip to content

Descriptors: view indices past a capped host heap read a null slot - #11

Merged
MagiccConch merged 2 commits into
mainfrom
new-cap
Nov 25, 2026
Merged

MagiccConch merged 2 commits into
mainfrom
new-cap

Conversation

@MagiccConch

Copy link
Copy Markdown
Owner

What

Ports upstream PR Marvisak#1133 (cae16e60 "Descriptors: view indices past a capped host heap read a null slot", by rivaldodev) onto the fork, merged with the fork's fuller heap-size fallback ladder from 6ac8fbe.

Why

The 5080 hardware run ended in a flood of

title slot past the host heap index~1179606 count=934464 for_draw=false

followed by a 0xc0000005 in the title (title-image+0x2215c35) — the same crash pattern as before 6ac8fbe. 6ac8fbe's ordered fallbacks cannot help on this GPU: every rung that keeps the whole title range (count + DYNAMIC = 1,441,792; count + MIN_DYNAMIC = 1,245,184) exceeds the driver cap of 1,000,000, so the heap still lands on the PORTABLE_VIEWS cap path with count = 934,464, and every title slot from 934,464 to 1,179,648 reads a null descriptor.

How (upstream's approach)

  • victory-gpu/src/host.rs::create() probes the device with a shader-visible view heap of PORTABLE_VIEWS + 1 slots. If that is refused, the host is capped at 1,000,000 (descriptor::host::view_heap_cap).
  • The cap is stored in victory-shader::emit (set_view_heap_limit / view_heap_limit), and translated shaders clamp their createHandleFromHeap indices to cap - 1 instead of HEAP_VIEWS - 1 when the host is capped. The clamped last slot of the heap stays null, so an index past the capped range reads nothing instead of faulting the device.
  • The heap keeps its last slot out of title slots, dynamic slots and copy-back view pairs (pairs_end), including dynamic ranges ending exactly at the cap.
  • The cap joins the shader-cache translation key (shader_cache.rs), and build() initializes the host device first so the cap is known before the key is fixed.

Fork-specific merge

The upstream patch replaced the fork's fallback chain (6ac8fbe: try count + DYNAMIC, then count + MIN_DYNAMIC, before the cap) with its own .max(views) variants. This PR keeps both: the .max(views) rungs first (needed so small title heaps still span the full capped range), then the fork's plain rungs, then the cap path. On an uncapped host behavior is unchanged; on a capped host the cap rung wins exactly as upstream intends, but the fork's extra rungs still catch hosts that accept the title range only without the extra views headroom.

Verification

  • cargo check / cargo clippy -p victory-gpu -p victory-shader --all-features --all-targets --target x86_64-pc-windows-gnu: clean, zero warnings.
  • cargo test --no-run links for both crates on x86_64-pc-windows-gnu (real test runs happen in CI on windows-latest).
  • Upstream PR Descriptors: clamp view indices past a capped host heap to a null slot Marvisak/VIctory#1133 tests included: emitted DXIL handle indices at and beyond both heap bounds, small and exact-size capped heaps, cache invalidation by the cap.

After merge

Rebuild, re-run the pre-build, and run the title on the 5080. Expected: host view heaps capped: ... logged once, the title slot past the host heap flood gone (past-cap indices now read the null guard), and no null-write crash at world entry. The pipeline library will rebuild: the emitted shaders change (new clamp constant).

This PR was created by an AI agent (OpenHands) on behalf of @MagiccConch.

rivaldodev and others added 2 commits November 25, 2026 04:10
Detect hosts whose shader-visible view heaps stop at 1,000,000 slots.
Keep main's descriptor index clamps, using the smaller host cap for view
handles while leaving sampler and uncapped-host bounds intact.

Keep main's fuller fallback ladder for the heap size (6ac8fbe): a host
below HEAP_VIEWS still gets every title slot mirrored when it can take
them beside a dynamic range, and a capped heap keeps its last slot null
across title slots, dynamic slots and copy-back view pairs, including
dynamic ranges ending exactly at the cap.

Keep main's source-based shader cache fingerprint and include the host
cap among its translation settings.

Tests check emitted DXIL handle indices at and beyond both heap bounds,
small and exact-size capped heaps, and cache invalidation by the cap.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: openhands <openhands@all-hands.dev>
Co-authored-by: openhands <openhands@all-hands.dev>
@MagiccConch
MagiccConch marked this pull request as ready for review November 25, 2026 04:20
@MagiccConch
MagiccConch merged commit bb56f8a into main Nov 25, 2026
1 check passed
@MagiccConch
MagiccConch deleted the new-cap branch November 25, 2026 04:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants