Skip to content

GPU: capped view heap - a table of the title's slots, each distinct view held once - #13

Merged
wbkepler merged 2 commits into
mainfrom
gpu/per-slot-view-table
Nov 25, 2026
Merged

wbkepler merged 2 commits into
mainfrom
gpu/per-slot-view-table

Conversation

@wbkepler

Copy link
Copy Markdown
Owner

On hosts that cap shader-visible view heaps (1,000,000 slots on NVIDIA), the 1,024-slot block remap is replaced by a per-title-slot table (root SRV t254) and one host slot per distinct view of the title's.

Needs a new shader cache: the mapping is part of the translation on capped hosts (cache key changes), so caches must be pre-built again (translate --cache --pipelines).

What changes

  • Translated shaders map every view heap index they compute — heap-direct and through descriptor tables — with one dword load from the view-slot table. The host passes the title's own table offset on such heaps and makes no tables afresh in dynamic slots.
  • Table: a dword per title slot (GPU upload heap where available), CPU-written; an empty slot leads to the heap's last (null) slot.
  • Sharing key = the title's record key (view index + generation): a view another slot already holds only gets a table entry; a new one takes a free host slot. Zero-ref views are freed when the sync is over (settle).
  • Title heaps that fit keep the title's order (identity table).
  • Strides, marks, view addresses and bindless Viewed are kept by host slot. The block waiting/retry code is gone.
  • The host's multiply-add probe now runs before the translator is told heaps are capped (it binds no view-slot table; translated for a capped heap it removed the device at start-up and failed every GPU test after it).
  • Diagnostics: 5 s "host view heap stats" line (distinct views of capacity, title slots, table writes, made/remade/freed/refused).

Measured (RTX 5090, diag, one 240 s world run, capped pacing, GPU upload + lazy copy-back on)

before (#7, block remap) after
title views without a host slot ~101,000 0 (refused 0)
distinct host views – ~168,000 of 852,541 (peak 202,000), ~696,000 title slots, ~4.1 slots per view
sync_heaps 53–57 ms 31–33 ms
preparing 179–197 ms 168–195 ms
GPU 84–93 ms 91–100 ms
copy-back 45–49 ms 55–62 ms
frame (steady world) 325–355 ms 333–389 ms

Frame time is about flat: sync is ~22 ms cheaper, GPU and copy-back are a little higher. Stable 240 s, no device removal; world frames show the scene (pre-existing magenta fragments remain).

Gate

clippy -D warnings (victory-gpu, victory-shader, victory with diagnostics); cargo test -p victory-gpu -- --test-threads=1 179 passed; cargo test -p victory-shader 297 passed; cargo xtask policy ok.

🤖 Generated with Claude Code

wbkepler and others added 2 commits November 25, 2026 18:37
…iew held once

On a host that caps shader-visible view heaps (1,000,000 slots on NVIDIA)
a title heap with more slots than fit was held by blocks of 1,024 title
slots. In the world the title holds views in about 1,000 of its 1,216
blocks, the heap had 831, and ~100,000 live views had no host slot.

Such a heap now holds each distinct view of the title's once, wherever a
slot is free, and the title's slots lead there through a table:

- Translated shaders map every view heap index they compute, from the
  resource heap itself or through a descriptor table, with one dword load
  from the view-slot table (root SRV t254, which held the block table).
  The host passes where the title has a table and makes none afresh in
  dynamic slots on such hosts.
- The table has a dword per title slot, in a GPU upload heap where the
  host has one (else an upload buffer), written by the CPU only. A slot
  without a view leads to the heap's last slot, which stays null.
- The title's records already name its distinct views (index and
  generation), so a title slot write is a lookup by that key: a view some
  other slot holds only gets the table entry; a new one takes a free host
  slot and is made there. A view no title slot holds any more gives its
  host slot back when the sync is over, so one that only moves between
  slots is not made twice.
- A shared buffer view is looked up again when another slot takes it after
  host copies were made or released, and made again in place if its copy
  changed; a placed texture's view likewise when a draw reads it.
- Strides, marks, view addresses and what title memory feeds are kept by
  host slot, as before. The waiting and retry of views without a block
  are gone with the blocks.
- A title heap that fits the host's keeps the title's order; its table
  leads each slot to itself.
- The shader cache key of capped hosts changes (the mapping is part of
  the translation): caches must be pre-built again.
- The host's multiply-add probe runs before the translator is told the
  heaps are capped: it binds no view-slot table, and translated for a
  capped heap its table entry would be looked up there (a device
  removal at start-up, which failed every GPU test after it).
- Diagnostics builds log, every 5 s: distinct host views of capacity,
  title slots holding one, table writes, views made, made again, given
  back and refused.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
No conflicts; main changed no shader-crate source since 1104646, so the pre-built cache stays valid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@wbkepler
wbkepler merged commit 5f9d059 into main Nov 25, 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.

1 participant