gpu(descriptor): bound placed-view shapes and retire idle views (VSP-19 port) #26

Manually merged
github merged 42 commits from github-bot/gh-26 into main 2026-12-04 02:46:52 +00:00 AGit
Owner

@⁠gianlukin2001-ops on GitHub · 2026-12-03 11:40 UTC · original
gianlukin2001-ops:vsp19-bounded-view-table → main · +339 −42 · 1 files · 1 commits · merged 2026-12-04 02:42 UTC

Summary

Ports the bounded placed-view table and sliced idle eviction from VSP-19 in monte-alt/vesper#25 to ReVIctory's descriptor table.

Today Views keeps every distinct placed-view shape, and every placed/constant view that does not fit a record, for the whole run. The run-65 report in descriptor.rs measured 14,000 constant-buffer views a frame, 2,450,139 entries and 1,047 MB with the index after four minutes, growing by 11,000 entries a second. This change bounds both the shape list and the table:

  • PLACED_SHAPE_CAP = 262_144 caps inline placed-view shapes; shapes past the cap overflow into the evictable table.
  • ViewEntry gains last_used (atomic, touched under the read lock) and live.
  • Sliced idle eviction retires View::Placed / View::Constant entries unused for IDLE_EVICT_FRAMES = 1_800 frames (~60 s at 30 FPS). Resource-backed views (Shader / Unordered) and samplers are never evicted.
  • Sweeps run every SWEEP_PERIOD_FRAMES = 4 from sync_heaps, plus on demand when a new entry finds free empty and the table is over EVICT_HIGH_WATER = 65_536.
  • A retired entry bumps its generation and publishes 0, so a stale descriptor resolves to None, never to the view that reuses the slot.
  • Views::index / shape_index move from BTreeMap to HashMap (View and Shape now derive Hash) for O(1) lookup.
  • VICTORY_VIEW_EVICT=0 turns the cap and eviction off (previous behavior).

Adaptation to ReVIctory

ReVIctory keeps a thread-local view cache (kept_view / keep_view) that upstream Vesper does not have. Evictable views now bypass that cache: a cache hit would not refresh last_used, so idle eviction could retire a view that is still being read. lookup_entry touches last_used on every hit; resource-backed views still use the cache.

Credit

  • Design and original implementation: @⁠adriaespii in monte-alt/vesper#25 (VSP-19; commits af69410, 7a09c02, 146eead, 177d069).
  • monte-alt/vesper, where the table and eviction were developed and benchmarked.
  • Marvisak/VIctory and ReTerryDavis/ReVIctory, whose descriptor table this adapts.
  • This port, the TLS-cache adaptation and the three tests: the author of this PR.

Testing

  • cargo test -p victory-gpu --lib: 671 passed, 45 ignored. The only 2 failures (descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes and pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws) reproduce on untouched main on this machine.
  • New tests: placed_shapes_are_bounded, idle_eviction_retires_stale_views_and_reuses_slots, idle_eviction_never_retires_resource_views_or_samplers.
  • cargo check -p victory-gpu --features diagnostics passes.
  • cargo clippy -p victory-gpu --all-targets --all-features --no-deps reports nothing in descriptor.rs; the crate's pre-existing clippy failures are unchanged (see #20).

Scope

crates/victory-gpu/src/descriptor.rs only. Independent of #8 (the Windows 10 Agility SDK change); neither depends on the other.

AI assistance

Implemented with AI assistance (OpenCode, DeepSeek V4.1 Flash Free), then reviewed and tested locally on Windows 10 22H2 (19045.6466) with an RX 9060 XT. The design is adapted from the VSP-19 implementation credited above.

**@⁠gianlukin2001-ops** on GitHub · 2026-12-03 11:40 UTC · [original](https://github.com/ReTerryDavis/ReVIctory/pull/26) `gianlukin2001-ops:vsp19-bounded-view-table` → `main` · +339 −42 · 1 files · 1 commits · merged 2026-12-04 02:42 UTC ## Summary Ports the bounded placed-view table and sliced idle eviction from **VSP-19** in [monte-alt/vesper#25](https://github.com/monte-alt/vesper/pull/25) to ReVIctory's descriptor table. Today `Views` keeps every distinct placed-view shape, and every placed/constant view that does not fit a record, for the whole run. The run-65 report in `descriptor.rs` measured 14,000 constant-buffer views a frame, 2,450,139 entries and 1,047 MB with the index after four minutes, growing by 11,000 entries a second. This change bounds both the shape list and the table: - `PLACED_SHAPE_CAP = 262_144` caps inline placed-view shapes; shapes past the cap overflow into the evictable table. - `ViewEntry` gains `last_used` (atomic, touched under the read lock) and `live`. - Sliced idle eviction retires `View::Placed` / `View::Constant` entries unused for `IDLE_EVICT_FRAMES = 1_800` frames (~60 s at 30 FPS). Resource-backed views (`Shader` / `Unordered`) and samplers are never evicted. - Sweeps run every `SWEEP_PERIOD_FRAMES = 4` from `sync_heaps`, plus on demand when a new entry finds `free` empty and the table is over `EVICT_HIGH_WATER = 65_536`. - A retired entry bumps its generation and publishes 0, so a stale descriptor resolves to `None`, never to the view that reuses the slot. - `Views::index` / `shape_index` move from `BTreeMap` to `HashMap` (`View` and `Shape` now derive `Hash`) for O(1) lookup. - `VICTORY_VIEW_EVICT=0` turns the cap and eviction off (previous behavior). ### Adaptation to ReVIctory ReVIctory keeps a thread-local view cache (`kept_view` / `keep_view`) that upstream Vesper does not have. Evictable views now bypass that cache: a cache hit would not refresh `last_used`, so idle eviction could retire a view that is still being read. `lookup_entry` touches `last_used` on every hit; resource-backed views still use the cache. ## Credit - Design and original implementation: **@⁠adriaespii** in [monte-alt/vesper#25](https://github.com/monte-alt/vesper/pull/25) (VSP-19; commits af69410, 7a09c02, 146eead, 177d069). - [monte-alt/vesper](https://github.com/monte-alt/vesper), where the table and eviction were developed and benchmarked. - [Marvisak/VIctory](https://github.com/Marvisak/VIctory) and [ReTerryDavis/ReVIctory](https://github.com/ReTerryDavis/ReVIctory), whose descriptor table this adapts. - This port, the TLS-cache adaptation and the three tests: the author of this PR. ## Testing - `cargo test -p victory-gpu --lib`: **671 passed, 45 ignored**. The only 2 failures (`descriptor::host::tests::views_off_their_elements_get_a_copy_of_their_bytes` and `pipeline::host::tests::depth_bounds_pipeline_loads_and_filters_draws`) reproduce on untouched `main` on this machine. - New tests: `placed_shapes_are_bounded`, `idle_eviction_retires_stale_views_and_reuses_slots`, `idle_eviction_never_retires_resource_views_or_samplers`. - `cargo check -p victory-gpu --features diagnostics` passes. - `cargo clippy -p victory-gpu --all-targets --all-features --no-deps` reports nothing in `descriptor.rs`; the crate's pre-existing clippy failures are unchanged (see #20). ## Scope `crates/victory-gpu/src/descriptor.rs` only. Independent of #8 (the Windows 10 Agility SDK change); neither depends on the other. ## AI assistance Implemented with AI assistance (OpenCode, DeepSeek V4.1 Flash Free), then reviewed and tested locally on Windows 10 22H2 (19045.6466) with an RX 9060 XT. The design is adapted from the VSP-19 implementation credited above.
Port VSP-19's bounded placed-view table from monte-alt/vesper#25 by
@adriaespii: cap inline placed-view shapes, track each entry's last use,
and retire idle placed/constant views in slices from sync_heaps.
Resource-backed views and samplers are never evicted.

Adapted to ReVIctory's thread-local kept-view cache: evictable views
bypass it, because a cache hit would not refresh last_used.

Adds tests for the shape cap, slot reuse and the non-evictable kinds.

Co-authored-by: adriaespii <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-12-03 11:41:22 +00:00
github-bot force-pushed github-bot/gh-26 from 4dac84e2f8 to 1d5151a146 2026-12-04 02:46:52 +00:00 Compare
github manually merged commit fc8f19fb01 into main 2026-12-04 02:46:52 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.